diff --git a/sys/dev/qat/include/common/adf_uio_cleanup.h b/sys/dev/qat/include/common/adf_uio_cleanup.h index 8f1132181355..876843cd9aa8 100644 --- a/sys/dev/qat/include/common/adf_uio_cleanup.h +++ b/sys/dev/qat/include/common/adf_uio_cleanup.h @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2023 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #ifndef ADF_UIO_CLEANUP_H #define ADF_UIO_CLEANUP_H void adf_uio_do_cleanup_orphan(int bank, struct adf_uio_control_accel *accel); - #endif diff --git a/sys/dev/qat/include/common/adf_uio_control.h b/sys/dev/qat/include/common/adf_uio_control.h index 4662c02233b6..032baa9b54c2 100644 --- a/sys/dev/qat/include/common/adf_uio_control.h +++ b/sys/dev/qat/include/common/adf_uio_control.h @@ -1,42 +1,41 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2023 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #ifndef QAT_UIO_CONTROL_H #define QAT_UIO_CONTROL_H #include struct adf_uio_instance_rings { unsigned int user_pid; u16 ring_mask; struct list_head list; }; struct adf_uio_control_bundle { uint8_t hardware_bundle_number; bool used; struct list_head list; struct mutex list_lock; /* protects list struct */ struct mutex lock; /* protects rings_used and csr_addr */ u16 rings_used; u32 rings_enabled; void *csr_addr; struct qat_uio_bundle_dev uio_priv; vm_object_t obj; }; struct adf_uio_control_accel { struct adf_accel_dev *accel_dev; struct cdev *cdev; struct mtx lock; struct adf_bar *bar; unsigned int nb_bundles; unsigned int num_ker_bundles; unsigned int total_used_bundles; unsigned int num_handles; struct cv cleanup_ok; /* bundle[] must be last to allow dynamic size allocation. */ struct adf_uio_control_bundle bundle[0]; }; - #endif /* end of include guard: QAT_UIO_CONTROL_H */ diff --git a/sys/dev/qat/qat/qat_ocf.c b/sys/dev/qat/qat/qat_ocf.c index b25135b6a678..3ed834d48e03 100644 --- a/sys/dev/qat/qat/qat_ocf.c +++ b/sys/dev/qat/qat/qat_ocf.c @@ -1,1302 +1,1301 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /* System headers */ #include #include #include #include #include #include #include #include #include /* Cryptodev headers */ #include #include "cryptodev_if.h" /* QAT specific headers */ #include "cpa.h" #include "cpa_cy_im.h" #include "cpa_cy_sym_dp.h" #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "lac_sym_hash_defs.h" #include "lac_sym_qat_hash_defs_lookup.h" /* To get only IRQ instances */ #include "icp_accel_devices.h" #include "icp_adf_accel_mgr.h" #include "lac_sal_types.h" /* To disable AEAD HW MAC verification */ #include "icp_sal_user.h" /* QAT OCF specific headers */ #include "qat_ocf_mem_pool.h" #include "qat_ocf_utils.h" #define QAT_OCF_MAX_INSTANCES (256) #define QAT_OCF_SESSION_WAIT_TIMEOUT_MS (1000) MALLOC_DEFINE(M_QAT_OCF, "qat_ocf", "qat_ocf(4) memory allocations"); /* QAT OCF internal structures */ struct qat_ocf_softc { device_t sc_dev; struct sysctl_oid *rc; uint32_t enabled; int32_t cryptodev_id; struct qat_ocf_instance cyInstHandles[QAT_OCF_MAX_INSTANCES]; int32_t numCyInstances; }; /* Function definitions */ static void qat_ocf_freesession(device_t dev, crypto_session_t cses); static int qat_ocf_probesession(device_t dev, const struct crypto_session_params *csp); static int qat_ocf_newsession(device_t dev, crypto_session_t cses, const struct crypto_session_params *csp); static int qat_ocf_attach(device_t dev); static int qat_ocf_detach(device_t dev); static void symDpCallback(CpaCySymDpOpData *pOpData, CpaStatus result, CpaBoolean verifyResult) { struct qat_ocf_cookie *qat_cookie; struct cryptop *crp; struct qat_ocf_dsession *qat_dsession = NULL; struct qat_ocf_session *qat_session = NULL; struct qat_ocf_instance *qat_instance = NULL; CpaStatus status; int rc = 0; qat_cookie = (struct qat_ocf_cookie *)pOpData->pCallbackTag; if (!qat_cookie) return; crp = qat_cookie->crp_op; qat_dsession = crypto_get_driver_session(crp->crp_session); qat_instance = qat_dsession->qatInstance; status = qat_ocf_cookie_dma_post_sync(crp, pOpData); if (CPA_STATUS_SUCCESS != status) { rc = EIO; goto exit; } status = qat_ocf_cookie_dma_unload(crp, pOpData); if (CPA_STATUS_SUCCESS != status) { rc = EIO; goto exit; } /* Verify result */ if (CPA_STATUS_SUCCESS != result) { rc = EBADMSG; goto exit; } /* Verify digest by FW (GCM and CCM only) */ if (CPA_TRUE != verifyResult) { rc = EBADMSG; goto exit; } if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) qat_session = &qat_dsession->encSession; else qat_session = &qat_dsession->decSession; /* Copy back digest result if it's stored in separated buffer */ if (pOpData->digestResult && qat_session->authLen > 0) { if ((crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) != 0) { char icv[QAT_OCF_MAX_DIGEST] = { 0 }; crypto_copydata(crp, crp->crp_digest_start, qat_session->authLen, icv); if (timingsafe_bcmp(icv, qat_cookie->qat_ocf_digest, qat_session->authLen) != 0) { rc = EBADMSG; goto exit; } } else { crypto_copyback(crp, crp->crp_digest_start, qat_session->authLen, qat_cookie->qat_ocf_digest); } } exit: qat_ocf_cookie_free(qat_instance, qat_cookie); crp->crp_etype = rc; crypto_done(crp); return; } static inline CpaPhysicalAddr qatVirtToPhys(void *virtAddr) { return (CpaPhysicalAddr)vtophys(virtAddr); } static int qat_ocf_probesession(device_t dev, const struct crypto_session_params *csp) { if ((csp->csp_flags & ~(CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD)) != 0) { return EINVAL; } switch (csp->csp_mode) { case CSP_MODE_CIPHER: switch (csp->csp_cipher_alg) { case CRYPTO_AES_CBC: case CRYPTO_AES_ICM: if (csp->csp_ivlen != AES_BLOCK_LEN) return EINVAL; break; case CRYPTO_AES_XTS: if (csp->csp_ivlen != AES_XTS_IV_LEN) return EINVAL; break; default: return EINVAL; } break; case CSP_MODE_DIGEST: switch (csp->csp_auth_alg) { case CRYPTO_SHA1: case CRYPTO_SHA1_HMAC: case CRYPTO_SHA2_256: case CRYPTO_SHA2_256_HMAC: case CRYPTO_SHA2_384: case CRYPTO_SHA2_384_HMAC: case CRYPTO_SHA2_512: case CRYPTO_SHA2_512_HMAC: break; case CRYPTO_AES_NIST_GMAC: if (csp->csp_ivlen != AES_GCM_IV_LEN) return EINVAL; break; default: return EINVAL; } break; case CSP_MODE_AEAD: switch (csp->csp_cipher_alg) { case CRYPTO_AES_NIST_GCM_16: if (csp->csp_ivlen != AES_GCM_IV_LEN) return EINVAL; break; default: return EINVAL; } break; case CSP_MODE_ETA: switch (csp->csp_auth_alg) { case CRYPTO_SHA1_HMAC: case CRYPTO_SHA2_256_HMAC: case CRYPTO_SHA2_384_HMAC: case CRYPTO_SHA2_512_HMAC: switch (csp->csp_cipher_alg) { case CRYPTO_AES_CBC: case CRYPTO_AES_ICM: if (csp->csp_ivlen != AES_BLOCK_LEN) return EINVAL; break; case CRYPTO_AES_XTS: if (csp->csp_ivlen != AES_XTS_IV_LEN) return EINVAL; break; default: return EINVAL; } break; default: return EINVAL; } break; default: return EINVAL; } return CRYPTODEV_PROBE_HARDWARE; } static CpaStatus qat_ocf_session_init(device_t dev, struct cryptop *crp, struct qat_ocf_instance *qat_instance, struct qat_ocf_session *qat_ssession) { CpaStatus status = CPA_STATUS_SUCCESS; /* Crytpodev structures */ crypto_session_t cses; const struct crypto_session_params *csp; /* DP API Session configuration */ CpaCySymSessionSetupData sessionSetupData = { 0 }; CpaCySymSessionCtx sessionCtx = NULL; Cpa32U sessionCtxSize = 0; cses = crp->crp_session; if (NULL == cses) { device_printf(dev, "no crypto session in cryptodev request\n"); return CPA_STATUS_FAIL; } csp = crypto_get_params(cses); if (NULL == csp) { device_printf(dev, "no session in cryptodev session\n"); return CPA_STATUS_FAIL; } /* Common fields */ sessionSetupData.sessionPriority = CPA_CY_PRIORITY_HIGH; /* Cipher key */ if (crp->crp_cipher_key) sessionSetupData.cipherSetupData.pCipherKey = crp->crp_cipher_key; else sessionSetupData.cipherSetupData.pCipherKey = csp->csp_cipher_key; sessionSetupData.cipherSetupData.cipherKeyLenInBytes = csp->csp_cipher_klen; /* Auth key */ if (crp->crp_auth_key) sessionSetupData.hashSetupData.authModeSetupData.authKey = crp->crp_auth_key; else sessionSetupData.hashSetupData.authModeSetupData.authKey = csp->csp_auth_key; sessionSetupData.hashSetupData.authModeSetupData.authKeyLenInBytes = csp->csp_auth_klen; qat_ssession->aadLen = crp->crp_aad_length; if (CPA_TRUE == is_sep_aad_supported(csp)) sessionSetupData.hashSetupData.authModeSetupData.aadLenInBytes = crp->crp_aad_length; else sessionSetupData.hashSetupData.authModeSetupData.aadLenInBytes = 0; /* Just setup algorithm - regardless of mode */ if (csp->csp_cipher_alg) { sessionSetupData.symOperation = CPA_CY_SYM_OP_CIPHER; switch (csp->csp_cipher_alg) { case CRYPTO_AES_CBC: sessionSetupData.cipherSetupData.cipherAlgorithm = CPA_CY_SYM_CIPHER_AES_CBC; break; case CRYPTO_AES_ICM: sessionSetupData.cipherSetupData.cipherAlgorithm = CPA_CY_SYM_CIPHER_AES_CTR; break; case CRYPTO_AES_XTS: sessionSetupData.cipherSetupData.cipherAlgorithm = CPA_CY_SYM_CIPHER_AES_XTS; break; case CRYPTO_AES_NIST_GCM_16: sessionSetupData.cipherSetupData.cipherAlgorithm = CPA_CY_SYM_CIPHER_AES_GCM; sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_AES_GCM; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; break; default: device_printf(dev, "cipher_alg: %d not supported\n", csp->csp_cipher_alg); status = CPA_STATUS_UNSUPPORTED; goto fail; } } if (csp->csp_auth_alg) { switch (csp->csp_auth_alg) { case CRYPTO_SHA1_HMAC: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA1; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; break; case CRYPTO_SHA1: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA1; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; break; case CRYPTO_SHA2_256_HMAC: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA256; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; break; case CRYPTO_SHA2_256: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA256; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; break; case CRYPTO_SHA2_224_HMAC: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA224; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; break; case CRYPTO_SHA2_224: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA224; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; break; case CRYPTO_SHA2_384_HMAC: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA384; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; break; case CRYPTO_SHA2_384: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA384; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; break; case CRYPTO_SHA2_512_HMAC: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA512; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; break; case CRYPTO_SHA2_512: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA512; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; break; case CRYPTO_AES_NIST_GMAC: sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_AES_GMAC; break; default: status = CPA_STATUS_UNSUPPORTED; goto fail; } } /* csp->csp_auth_alg */ /* Setting digest-length if no cipher-only mode is set */ if (csp->csp_mode != CSP_MODE_CIPHER) { lac_sym_qat_hash_defs_t *pHashDefsInfo = NULL; if (csp->csp_auth_mlen) { sessionSetupData.hashSetupData.digestResultLenInBytes = csp->csp_auth_mlen; qat_ssession->authLen = csp->csp_auth_mlen; } else { LacSymQat_HashDefsLookupGet( qat_instance->cyInstHandle, sessionSetupData.hashSetupData.hashAlgorithm, &pHashDefsInfo); if (NULL == pHashDefsInfo) { device_printf( dev, "unable to find corresponding hash data\n"); status = CPA_STATUS_UNSUPPORTED; goto fail; } sessionSetupData.hashSetupData.digestResultLenInBytes = pHashDefsInfo->algInfo->digestLength; qat_ssession->authLen = pHashDefsInfo->algInfo->digestLength; } sessionSetupData.verifyDigest = CPA_FALSE; } switch (csp->csp_mode) { case CSP_MODE_AEAD: case CSP_MODE_ETA: sessionSetupData.symOperation = CPA_CY_SYM_OP_ALGORITHM_CHAINING; /* Place the digest result in a buffer unrelated to srcBuffer */ sessionSetupData.digestIsAppended = CPA_FALSE; /* Due to FW limitation to verify only appended MACs */ sessionSetupData.verifyDigest = CPA_FALSE; if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { sessionSetupData.cipherSetupData.cipherDirection = CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; sessionSetupData.algChainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH; } else { sessionSetupData.cipherSetupData.cipherDirection = CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT; sessionSetupData.algChainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER; } break; case CSP_MODE_CIPHER: if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) { sessionSetupData.cipherSetupData.cipherDirection = CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; } else { sessionSetupData.cipherSetupData.cipherDirection = CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT; } sessionSetupData.symOperation = CPA_CY_SYM_OP_CIPHER; break; case CSP_MODE_DIGEST: sessionSetupData.symOperation = CPA_CY_SYM_OP_HASH; if (csp->csp_auth_alg == CRYPTO_AES_NIST_GMAC) { sessionSetupData.symOperation = CPA_CY_SYM_OP_ALGORITHM_CHAINING; /* GMAC is always encrypt */ sessionSetupData.cipherSetupData.cipherDirection = CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; sessionSetupData.algChainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH; sessionSetupData.cipherSetupData.cipherAlgorithm = CPA_CY_SYM_CIPHER_AES_GCM; sessionSetupData.hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_AES_GMAC; sessionSetupData.hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_AUTH; /* Same key for cipher and auth */ sessionSetupData.cipherSetupData.pCipherKey = csp->csp_auth_key; sessionSetupData.cipherSetupData.cipherKeyLenInBytes = csp->csp_auth_klen; /* Generated GMAC stored in separated buffer */ sessionSetupData.digestIsAppended = CPA_FALSE; /* Digest verification not allowed in GMAC case */ sessionSetupData.verifyDigest = CPA_FALSE; /* No AAD allowed */ sessionSetupData.hashSetupData.authModeSetupData .aadLenInBytes = 0; } else { sessionSetupData.cipherSetupData.cipherDirection = CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT; sessionSetupData.symOperation = CPA_CY_SYM_OP_HASH; sessionSetupData.digestIsAppended = CPA_FALSE; } break; default: device_printf(dev, "%s: unhandled crypto algorithm %d, %d\n", __func__, csp->csp_cipher_alg, csp->csp_auth_alg); status = CPA_STATUS_FAIL; goto fail; } /* Extracting session size */ status = cpaCySymSessionCtxGetSize(qat_instance->cyInstHandle, &sessionSetupData, &sessionCtxSize); if (CPA_STATUS_SUCCESS != status) { device_printf(dev, "unable to get session size\n"); goto fail; } /* Allocating contiguous memory for session */ sessionCtx = contigmalloc(sessionCtxSize, M_QAT_OCF, M_NOWAIT, 0, ~1UL, 1 << (ilog2(sessionCtxSize - 1) + 1), 0); if (NULL == sessionCtx) { device_printf(dev, "unable to allocate memory for session\n"); status = CPA_STATUS_RESOURCE; goto fail; } status = cpaCySymDpInitSession(qat_instance->cyInstHandle, &sessionSetupData, sessionCtx); if (CPA_STATUS_SUCCESS != status) { device_printf(dev, "session initialization failed\n"); goto fail; } /* NOTE: lets keep double session (both directions) approach to overcome * lack of direction update in FBSD QAT. */ qat_ssession->sessionCtx = sessionCtx; qat_ssession->sessionCtxSize = sessionCtxSize; return CPA_STATUS_SUCCESS; fail: /* Release resources if any */ if (sessionCtx) contigfree(sessionCtx, sessionCtxSize, M_QAT_OCF); return status; } static int qat_ocf_newsession(device_t dev, crypto_session_t cses, const struct crypto_session_params *csp) { /* Cryptodev QAT structures */ struct qat_ocf_softc *qat_softc; struct qat_ocf_dsession *qat_dsession; struct qat_ocf_instance *qat_instance; u_int cpu_id = PCPU_GET(cpuid); /* Create cryptodev session */ qat_softc = device_get_softc(dev); if (qat_softc->numCyInstances > 0) { qat_instance = &qat_softc ->cyInstHandles[cpu_id % qat_softc->numCyInstances]; qat_dsession = crypto_get_driver_session(cses); if (NULL == qat_dsession) { device_printf(dev, "Unable to create new session\n"); return (EINVAL); } /* Add only instance at this point remaining operations moved to * lazy session init */ qat_dsession->qatInstance = qat_instance; } else { return ENXIO; } return 0; } static CpaStatus qat_ocf_remove_session(device_t dev, CpaInstanceHandle cyInstHandle, struct qat_ocf_session *qat_session) { CpaStatus status = CPA_STATUS_SUCCESS; if (NULL == qat_session->sessionCtx) return CPA_STATUS_SUCCESS; /* User callback is executed right before decrementing pending * callback atomic counter. To avoid removing session rejection * we have to wait a very short while for counter update * after call back execution. */ status = qat_ocf_wait_for_session(qat_session->sessionCtx, QAT_OCF_SESSION_WAIT_TIMEOUT_MS); if (CPA_STATUS_SUCCESS != status) { device_printf(dev, "waiting for session un-busy failed\n"); return CPA_STATUS_FAIL; } status = cpaCySymDpRemoveSession(cyInstHandle, qat_session->sessionCtx); if (CPA_STATUS_SUCCESS != status) { device_printf(dev, "error while removing session\n"); return CPA_STATUS_FAIL; } explicit_bzero(qat_session->sessionCtx, qat_session->sessionCtxSize); contigfree(qat_session->sessionCtx, qat_session->sessionCtxSize, M_QAT_OCF); qat_session->sessionCtx = NULL; qat_session->sessionCtxSize = 0; return CPA_STATUS_SUCCESS; } static void qat_ocf_freesession(device_t dev, crypto_session_t cses) { CpaStatus status = CPA_STATUS_SUCCESS; struct qat_ocf_dsession *qat_dsession = NULL; struct qat_ocf_instance *qat_instance = NULL; qat_dsession = crypto_get_driver_session(cses); qat_instance = qat_dsession->qatInstance; mtx_lock(&qat_instance->cyInstMtx); status = qat_ocf_remove_session(dev, qat_dsession->qatInstance->cyInstHandle, &qat_dsession->encSession); if (CPA_STATUS_SUCCESS != status) device_printf(dev, "unable to remove encrypt session\n"); status = qat_ocf_remove_session(dev, qat_dsession->qatInstance->cyInstHandle, &qat_dsession->decSession); if (CPA_STATUS_SUCCESS != status) device_printf(dev, "unable to remove decrypt session\n"); mtx_unlock(&qat_instance->cyInstMtx); } /* QAT GCM/CCM FW API are only algorithms which support separated AAD. */ static CpaStatus qat_ocf_load_aad_gcm(struct cryptop *crp, struct qat_ocf_cookie *qat_cookie) { CpaCySymDpOpData *pOpData; pOpData = &qat_cookie->pOpdata; if (NULL != crp->crp_aad) memcpy(qat_cookie->qat_ocf_gcm_aad, crp->crp_aad, crp->crp_aad_length); else crypto_copydata(crp, crp->crp_aad_start, crp->crp_aad_length, qat_cookie->qat_ocf_gcm_aad); pOpData->pAdditionalAuthData = qat_cookie->qat_ocf_gcm_aad; pOpData->additionalAuthData = qat_cookie->qat_ocf_gcm_aad_paddr; return CPA_STATUS_SUCCESS; } static CpaStatus qat_ocf_load_aad(struct cryptop *crp, struct qat_ocf_cookie *qat_cookie) { CpaStatus status = CPA_STATUS_SUCCESS; const struct crypto_session_params *csp; CpaCySymDpOpData *pOpData; struct qat_ocf_load_cb_arg args; pOpData = &qat_cookie->pOpdata; pOpData->pAdditionalAuthData = NULL; pOpData->additionalAuthData = 0UL; if (crp->crp_aad_length == 0) return CPA_STATUS_SUCCESS; if (crp->crp_aad_length > ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX) return CPA_STATUS_FAIL; csp = crypto_get_params(crp->crp_session); /* Handle GCM/CCM case */ if (CPA_TRUE == is_sep_aad_supported(csp)) return qat_ocf_load_aad_gcm(crp, qat_cookie); if (NULL == crp->crp_aad) { /* AAD already embedded in source buffer */ pOpData->messageLenToCipherInBytes = crp->crp_payload_length; pOpData->cryptoStartSrcOffsetInBytes = crp->crp_payload_start; pOpData->messageLenToHashInBytes = crp->crp_aad_length + crp->crp_payload_length; pOpData->hashStartSrcOffsetInBytes = crp->crp_aad_start; return CPA_STATUS_SUCCESS; } /* Separated AAD not supported by QAT - lets place the content * of ADD buffer at the very beginning of source SGL */ args.crp_op = crp; args.qat_cookie = qat_cookie; args.pOpData = pOpData; args.error = 0; status = bus_dmamap_load(qat_cookie->gcm_aad_dma_mem.dma_tag, qat_cookie->gcm_aad_dma_mem.dma_map, crp->crp_aad, crp->crp_aad_length, qat_ocf_crypto_load_aadbuf_cb, &args, BUS_DMA_NOWAIT); qat_cookie->is_sep_aad_used = CPA_TRUE; /* Right after this step we have AAD placed in the first flat buffer * in source SGL */ pOpData->messageLenToCipherInBytes = crp->crp_payload_length; pOpData->cryptoStartSrcOffsetInBytes = crp->crp_aad_length + crp->crp_aad_start + crp->crp_payload_start; pOpData->messageLenToHashInBytes = crp->crp_aad_length + crp->crp_payload_length; pOpData->hashStartSrcOffsetInBytes = crp->crp_aad_start; return status; } static CpaStatus qat_ocf_load(struct cryptop *crp, struct qat_ocf_cookie *qat_cookie) { CpaStatus status = CPA_STATUS_SUCCESS; CpaCySymDpOpData *pOpData; struct qat_ocf_load_cb_arg args; /* cryptodev internals */ const struct crypto_session_params *csp; pOpData = &qat_cookie->pOpdata; csp = crypto_get_params(crp->crp_session); /* Load IV buffer if present */ if (csp->csp_ivlen > 0) { memset(qat_cookie->qat_ocf_iv_buf, 0, sizeof(qat_cookie->qat_ocf_iv_buf)); crypto_read_iv(crp, qat_cookie->qat_ocf_iv_buf); pOpData->iv = qat_cookie->qat_ocf_iv_buf_paddr; pOpData->pIv = qat_cookie->qat_ocf_iv_buf; pOpData->ivLenInBytes = csp->csp_ivlen; } /* GCM/CCM - load AAD to separated buffer * AES+SHA - load AAD to first flat in SGL */ status = qat_ocf_load_aad(crp, qat_cookie); if (CPA_STATUS_SUCCESS != status) goto fail; /* Load source buffer */ args.crp_op = crp; args.qat_cookie = qat_cookie; args.pOpData = pOpData; args.error = 0; status = bus_dmamap_load_crp_buffer(qat_cookie->src_dma_mem.dma_tag, qat_cookie->src_dma_mem.dma_map, &crp->crp_buf, qat_ocf_crypto_load_buf_cb, &args, BUS_DMA_NOWAIT); if (CPA_STATUS_SUCCESS != status) goto fail; pOpData->srcBuffer = qat_cookie->src_buffer_list_paddr; pOpData->srcBufferLen = CPA_DP_BUFLIST; /* Load destination buffer */ if (CRYPTO_HAS_OUTPUT_BUFFER(crp)) { status = bus_dmamap_load_crp_buffer(qat_cookie->dst_dma_mem.dma_tag, qat_cookie->dst_dma_mem.dma_map, &crp->crp_obuf, qat_ocf_crypto_load_obuf_cb, &args, BUS_DMA_NOWAIT); if (CPA_STATUS_SUCCESS != status) goto fail; pOpData->dstBuffer = qat_cookie->dst_buffer_list_paddr; pOpData->dstBufferLen = CPA_DP_BUFLIST; } else { pOpData->dstBuffer = pOpData->srcBuffer; pOpData->dstBufferLen = pOpData->srcBufferLen; } if (CPA_TRUE == is_use_sep_digest(csp)) pOpData->digestResult = qat_cookie->qat_ocf_digest_paddr; else pOpData->digestResult = 0UL; /* GMAC - aka zero length buffer */ if (CPA_TRUE == is_gmac_exception(csp)) pOpData->messageLenToCipherInBytes = 0; fail: return status; } static int qat_ocf_check_input(device_t dev, struct cryptop *crp) { const struct crypto_session_params *csp; csp = crypto_get_params(crp->crp_session); if (crypto_buffer_len(&crp->crp_buf) > QAT_OCF_MAX_LEN) return E2BIG; if (CPA_TRUE == is_sep_aad_supported(csp) && (crp->crp_aad_length > ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX)) return EBADMSG; return 0; } static int qat_ocf_process(device_t dev, struct cryptop *crp, int hint) { CpaStatus status = CPA_STATUS_SUCCESS; int rc = 0; struct qat_ocf_dsession *qat_dsession = NULL; struct qat_ocf_session *qat_session = NULL; struct qat_ocf_instance *qat_instance = NULL; CpaCySymDpOpData *pOpData = NULL; struct qat_ocf_cookie *qat_cookie = NULL; CpaBoolean memLoaded = CPA_FALSE; rc = qat_ocf_check_input(dev, crp); if (rc) goto fail; qat_dsession = crypto_get_driver_session(crp->crp_session); if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) qat_session = &qat_dsession->encSession; else qat_session = &qat_dsession->decSession; qat_instance = qat_dsession->qatInstance; status = qat_ocf_cookie_alloc(qat_instance, &qat_cookie); if (CPA_STATUS_SUCCESS != status) { rc = EAGAIN; goto fail; } qat_cookie->crp_op = crp; /* Common request fields */ pOpData = &qat_cookie->pOpdata; pOpData->instanceHandle = qat_instance->cyInstHandle; pOpData->sessionCtx = NULL; /* Cipher fields */ pOpData->cryptoStartSrcOffsetInBytes = crp->crp_payload_start; pOpData->messageLenToCipherInBytes = crp->crp_payload_length; /* Digest fields - any exceptions from this basic rules are covered * in qat_ocf_load */ pOpData->hashStartSrcOffsetInBytes = crp->crp_payload_start; pOpData->messageLenToHashInBytes = crp->crp_payload_length; status = qat_ocf_load(crp, qat_cookie); if (CPA_STATUS_SUCCESS != status) { device_printf(dev, "unable to load OCF buffers to QAT DMA " "transaction\n"); rc = EIO; goto fail; } memLoaded = CPA_TRUE; status = qat_ocf_cookie_dma_pre_sync(crp, pOpData); if (CPA_STATUS_SUCCESS != status) { device_printf(dev, "unable to sync DMA buffers\n"); rc = EIO; goto fail; } mtx_lock(&qat_instance->cyInstMtx); /* Session initialization at the first request. It's done * in such way to overcome missing QAT specific session data * such like AAD length and limited possibility to update * QAT session while handling traffic. */ if (NULL == qat_session->sessionCtx) { status = qat_ocf_session_init(dev, crp, qat_instance, qat_session); if (CPA_STATUS_SUCCESS != status) { mtx_unlock(&qat_instance->cyInstMtx); device_printf(dev, "unable to init session\n"); rc = EIO; goto fail; } } else { status = qat_ocf_handle_session_update(qat_dsession, crp); if (CPA_STATUS_RESOURCE == status) { mtx_unlock(&qat_instance->cyInstMtx); rc = EAGAIN; goto fail; } else if (CPA_STATUS_SUCCESS != status) { mtx_unlock(&qat_instance->cyInstMtx); rc = EIO; goto fail; } } pOpData->sessionCtx = qat_session->sessionCtx; status = cpaCySymDpEnqueueOp(pOpData, CPA_TRUE); mtx_unlock(&qat_instance->cyInstMtx); if (CPA_STATUS_SUCCESS != status) { if (CPA_STATUS_RETRY == status) { rc = EAGAIN; goto fail; } device_printf(dev, "unable to send request. Status: %d\n", status); rc = EIO; goto fail; } return 0; fail: if (qat_cookie) { if (memLoaded) qat_ocf_cookie_dma_unload(crp, pOpData); qat_ocf_cookie_free(qat_instance, qat_cookie); } crp->crp_etype = rc; crypto_done(crp); return 0; } static void qat_ocf_identify(driver_t *drv, device_t parent) { if (device_find_child(parent, "qat_ocf", -1) == NULL && BUS_ADD_CHILD(parent, 200, "qat_ocf", -1) == 0) device_printf(parent, "qat_ocf: could not attach!"); } static int qat_ocf_probe(device_t dev) { device_set_desc(dev, "QAT engine"); return (BUS_PROBE_NOWILDCARD); } static CpaStatus qat_ocf_get_irq_instances(CpaInstanceHandle *cyInstHandles, Cpa16U cyInstHandlesSize, Cpa16U *foundInstances) { CpaStatus status = CPA_STATUS_SUCCESS; icp_accel_dev_t **pAdfInsts = NULL; icp_accel_dev_t *dev_addr = NULL; sal_t *baseAddr = NULL; sal_list_t *listTemp = NULL; CpaInstanceHandle cyInstHandle; CpaInstanceInfo2 info; Cpa16U numDevices; Cpa32U instCtr = 0; Cpa32U i; /* Get the number of devices */ status = icp_amgr_getNumInstances(&numDevices); if (CPA_STATUS_SUCCESS != status) return status; /* Allocate memory to store addr of accel_devs */ pAdfInsts = malloc(numDevices * sizeof(icp_accel_dev_t *), M_QAT_OCF, M_WAITOK); /* Get ADF to return all accel_devs that support either * symmetric or asymmetric crypto */ status = icp_amgr_getAllAccelDevByCapabilities( (ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC), pAdfInsts, &numDevices); if (CPA_STATUS_SUCCESS != status) { free(pAdfInsts, M_QAT_OCF); return status; } for (i = 0; i < numDevices; i++) { dev_addr = (icp_accel_dev_t *)pAdfInsts[i]; baseAddr = dev_addr->pSalHandle; if (NULL == baseAddr) continue; listTemp = baseAddr->sym_services; if (NULL == listTemp) { listTemp = baseAddr->crypto_services; } while (NULL != listTemp) { cyInstHandle = SalList_getObject(listTemp); status = cpaCyInstanceGetInfo2(cyInstHandle, &info); if (CPA_STATUS_SUCCESS != status) continue; listTemp = SalList_next(listTemp); if (CPA_TRUE == info.isPolled) continue; if (instCtr >= cyInstHandlesSize) break; cyInstHandles[instCtr++] = cyInstHandle; } } free(pAdfInsts, M_QAT_OCF); *foundInstances = instCtr; return CPA_STATUS_SUCCESS; } static CpaStatus qat_ocf_start_instances(struct qat_ocf_softc *qat_softc, device_t dev) { CpaStatus status = CPA_STATUS_SUCCESS; Cpa16U numInstances = 0; CpaInstanceHandle cyInstHandles[QAT_OCF_MAX_INSTANCES] = { 0 }; CpaInstanceHandle cyInstHandle = NULL; Cpa32U startedInstances = 0; Cpa32U i; qat_softc->numCyInstances = 0; status = qat_ocf_get_irq_instances(cyInstHandles, QAT_OCF_MAX_INSTANCES, &numInstances); if (CPA_STATUS_SUCCESS != status) return status; for (i = 0; i < numInstances; i++) { struct qat_ocf_instance *qat_ocf_instance; cyInstHandle = cyInstHandles[i]; if (!cyInstHandle) continue; /* Starting instance */ status = cpaCyStartInstance(cyInstHandle); if (CPA_STATUS_SUCCESS != status) { device_printf(qat_softc->sc_dev, "unable to get start instance\n"); continue; } qat_ocf_instance = &qat_softc->cyInstHandles[startedInstances]; qat_ocf_instance->cyInstHandle = cyInstHandle; mtx_init(&qat_ocf_instance->cyInstMtx, "Instance MTX", NULL, MTX_DEF); status = cpaCySetAddressTranslation(cyInstHandle, qatVirtToPhys); if (CPA_STATUS_SUCCESS != status) { device_printf(qat_softc->sc_dev, "unable to add virt to phys callback\n"); goto fail; } status = cpaCySymDpRegCbFunc(cyInstHandle, symDpCallback); if (CPA_STATUS_SUCCESS != status) { device_printf(qat_softc->sc_dev, "unable to add user callback\n"); goto fail; } /* Initialize cookie pool */ status = qat_ocf_cookie_pool_init(qat_ocf_instance, dev); if (CPA_STATUS_SUCCESS != status) { device_printf(qat_softc->sc_dev, "unable to create cookie pool\n"); goto fail; } /* Disable forcing HW MAC validation for AEAD */ status = icp_sal_setForceAEADMACVerify(cyInstHandle, CPA_FALSE); if (CPA_STATUS_SUCCESS != status) { device_printf( qat_softc->sc_dev, "unable to disable AEAD HW MAC verification\n"); goto fail; } qat_ocf_instance->driver_id = qat_softc->cryptodev_id; startedInstances++; continue; fail: mtx_destroy(&qat_ocf_instance->cyInstMtx); /* Stop instance */ status = cpaCyStopInstance(cyInstHandle); if (CPA_STATUS_SUCCESS != status) device_printf(qat_softc->sc_dev, "unable to stop the instance\n"); } qat_softc->numCyInstances = startedInstances; return CPA_STATUS_SUCCESS; } static CpaStatus qat_ocf_stop_instances(struct qat_ocf_softc *qat_softc) { CpaStatus status = CPA_STATUS_SUCCESS; int i; for (i = 0; i < qat_softc->numCyInstances; i++) { struct qat_ocf_instance *qat_instance; qat_instance = &qat_softc->cyInstHandles[i]; status = cpaCyStopInstance(qat_instance->cyInstHandle); if (CPA_STATUS_SUCCESS != status) { pr_err("QAT: stopping instance id: %d failed\n", i); continue; } qat_ocf_cookie_pool_deinit(qat_instance); mtx_destroy(&qat_instance->cyInstMtx); } qat_softc->numCyInstances = 0; return status; } static int qat_ocf_deinit(struct qat_ocf_softc *qat_softc) { int status = 0; CpaStatus cpaStatus; if (qat_softc->cryptodev_id >= 0) { crypto_unregister_all(qat_softc->cryptodev_id); qat_softc->cryptodev_id = -1; } /* Stop QAT instances */ cpaStatus = qat_ocf_stop_instances(qat_softc); if (CPA_STATUS_SUCCESS != cpaStatus) { device_printf(qat_softc->sc_dev, "unable to stop instances\n"); status = EIO; } return status; } static int qat_ocf_init(struct qat_ocf_softc *qat_softc) { int32_t cryptodev_id; /* Starting instances for OCF */ if (qat_ocf_start_instances(qat_softc, qat_softc->sc_dev)) { device_printf(qat_softc->sc_dev, "unable to get QAT IRQ instances\n"); goto fail; } /* Register only if instances available */ if (qat_softc->numCyInstances) { cryptodev_id = crypto_get_driverid(qat_softc->sc_dev, sizeof(struct qat_ocf_dsession), CRYPTOCAP_F_HARDWARE); if (cryptodev_id < 0) { device_printf(qat_softc->sc_dev, "cannot initialize!\n"); goto fail; } qat_softc->cryptodev_id = cryptodev_id; } return 0; fail: qat_ocf_deinit(qat_softc); return ENXIO; } static int qat_ocf_sysctl_handle(SYSCTL_HANDLER_ARGS) { struct qat_ocf_softc *qat_softc = NULL; int ret = 0; device_t dev = arg1; u_int enabled; qat_softc = device_get_softc(dev); enabled = qat_softc->enabled; ret = sysctl_handle_int(oidp, &enabled, 0, req); if (ret || !req->newptr) return (ret); if (qat_softc->enabled != enabled) { if (enabled) { ret = qat_ocf_init(qat_softc); } else { ret = qat_ocf_deinit(qat_softc); } if (!ret) qat_softc->enabled = enabled; } return ret; } static int qat_ocf_attach(device_t dev) { int status; struct qat_ocf_softc *qat_softc; qat_softc = device_get_softc(dev); qat_softc->sc_dev = dev; qat_softc->cryptodev_id = -1; qat_softc->enabled = 1; qat_softc->rc = SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "enable", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, dev, 0, qat_ocf_sysctl_handle, "I", "QAT OCF support enablement"); if (!qat_softc->rc) return ENOMEM; if (qat_softc->enabled) { status = qat_ocf_init(qat_softc); if (status) { device_printf(dev, "qat_ocf init failed\n"); goto fail; } } return 0; fail: qat_ocf_deinit(qat_softc); return (ENXIO); } static int qat_ocf_detach(device_t dev) { struct qat_ocf_softc *qat_softc = device_get_softc(dev); return qat_ocf_deinit(qat_softc); } static device_method_t qat_ocf_methods[] = { DEVMETHOD(device_identify, qat_ocf_identify), DEVMETHOD(device_probe, qat_ocf_probe), DEVMETHOD(device_attach, qat_ocf_attach), DEVMETHOD(device_detach, qat_ocf_detach), /* Cryptodev interface */ DEVMETHOD(cryptodev_probesession, qat_ocf_probesession), DEVMETHOD(cryptodev_newsession, qat_ocf_newsession), DEVMETHOD(cryptodev_freesession, qat_ocf_freesession), DEVMETHOD(cryptodev_process, qat_ocf_process), DEVMETHOD_END }; static driver_t qat_ocf_driver = { .name = "qat_ocf", .methods = qat_ocf_methods, .size = sizeof(struct qat_ocf_softc), }; - DRIVER_MODULE_ORDERED(qat, nexus, qat_ocf_driver, NULL, NULL, SI_ORDER_ANY); MODULE_VERSION(qat, 1); MODULE_DEPEND(qat, qat_c62x, 1, 1, 1); MODULE_DEPEND(qat, qat_200xx, 1, 1, 1); MODULE_DEPEND(qat, qat_c3xxx, 1, 1, 1); MODULE_DEPEND(qat, qat_c4xxx, 1, 1, 1); MODULE_DEPEND(qat, qat_dh895xcc, 1, 1, 1); MODULE_DEPEND(qat, qat_4xxx, 1, 1, 1); MODULE_DEPEND(qat, crypto, 1, 1, 1); MODULE_DEPEND(qat, qat_common, 1, 1, 1); MODULE_DEPEND(qat, qat_api, 1, 1, 1); MODULE_DEPEND(qat, linuxkpi, 1, 1, 1); diff --git a/sys/dev/qat/qat_api/common/compression/dc_datapath.c b/sys/dev/qat/qat_api/common/compression/dc_datapath.c index de14be2fdb0d..f5a8600eadfa 100644 --- a/sys/dev/qat/qat_api/common/compression/dc_datapath.c +++ b/sys/dev/qat/qat_api/common/compression/dc_datapath.c @@ -1,1985 +1,1977 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file dc_datapath.c * * @defgroup Dc_DataCompression DC Data Compression * * @ingroup Dc_DataCompression * * @description * Implementation of the Data Compression datapath operations. * *****************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_dc.h" #include "cpa_dc_dp.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "dc_session.h" #include "dc_datapath.h" #include "sal_statistics.h" #include "lac_common.h" #include "lac_mem.h" #include "lac_mem_pools.h" #include "sal_types_compression.h" #include "dc_stats.h" #include "lac_buffer_desc.h" #include "lac_sal.h" #include "lac_log.h" #include "lac_sync.h" #include "sal_service_state.h" #include "sal_qat_cmn_msg.h" #include "sal_hw_gen.h" #include "dc_error_counter.h" #define DC_COMP_MAX_BUFF_SIZE (1024 * 64) static QatUtilsAtomic dcErrorCount[MAX_DC_ERROR_TYPE]; void dcErrorLog(CpaDcReqStatus dcError) { Cpa32U absError = 0; absError = abs(dcError); if ((dcError < CPA_DC_OK) && (absError < MAX_DC_ERROR_TYPE)) { qatUtilsAtomicInc(&(dcErrorCount[absError])); } } Cpa64U getDcErrorCounter(CpaDcReqStatus dcError) { Cpa32U absError = 0; absError = abs(dcError); if (!(dcError >= CPA_DC_OK || dcError < CPA_DC_EMPTY_DYM_BLK)) { return (Cpa64U)qatUtilsAtomicGet(&dcErrorCount[absError]); } return 0; } static inline void dcUpdateXltOverflowChecksumsGen4(const dc_compression_cookie_t *pCookie, const icp_qat_fw_resp_comp_pars_t *pRespPars, CpaDcRqResults *pDcResults) { dc_session_desc_t *pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pCookie->pSessionHandle); /* Recompute CRC checksum when either the checksum type * is CPA_DC_CRC32 or when the integrity CRCs are enabled. */ if (CPA_DC_CRC32 == pSessionDesc->checksumType) { pDcResults->checksum = pRespPars->crc.legacy.curr_crc32; /* No need to recalculate the swCrc64I here as this will get * handled later in dcHandleIntegrityChecksumsGen4. */ } else if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { pDcResults->checksum = pRespPars->crc.legacy.curr_adler_32; } } void dcCompression_ProcessCallback(void *pRespMsg) { CpaStatus status = CPA_STATUS_SUCCESS; icp_qat_fw_comp_resp_t *pCompRespMsg = NULL; void *callbackTag = NULL; Cpa64U *pReqData = NULL; CpaDcDpOpData *pResponse = NULL; CpaDcRqResults *pResults = NULL; CpaDcCallbackFn pCbFunc = NULL; dc_session_desc_t *pSessionDesc = NULL; sal_compression_service_t *pService = NULL; dc_compression_cookie_t *pCookie = NULL; CpaDcOpData *pOpData = NULL; CpaBoolean cmpPass = CPA_TRUE, xlatPass = CPA_TRUE; CpaBoolean isDcDp = CPA_FALSE; CpaBoolean integrityCrcCheck = CPA_FALSE; CpaBoolean verifyHwIntegrityCrcs = CPA_FALSE; Cpa8U cmpErr = ERR_CODE_NO_ERROR, xlatErr = ERR_CODE_NO_ERROR; dc_request_dir_t compDecomp = DC_COMPRESSION_REQUEST; Cpa8U opStatus = ICP_QAT_FW_COMN_STATUS_FLAG_OK; Cpa8U hdrFlags = 0; /* Cast response message to compression response message type */ pCompRespMsg = (icp_qat_fw_comp_resp_t *)pRespMsg; /* Extract request data pointer from the opaque data */ LAC_MEM_SHARED_READ_TO_PTR(pCompRespMsg->opaque_data, pReqData); /* Extract fields from the request data structure */ pCookie = (dc_compression_cookie_t *)pReqData; if (!pCookie) return; pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pCookie->pSessionHandle); pService = (sal_compression_service_t *)(pCookie->dcInstance); isDcDp = pSessionDesc->isDcDp; if (CPA_TRUE == isDcDp) { pResponse = (CpaDcDpOpData *)pReqData; pResults = &(pResponse->results); if (CPA_DC_DIR_DECOMPRESS == pSessionDesc->sessDirection) { compDecomp = DC_DECOMPRESSION_REQUEST; } pCookie = NULL; } else { pResults = pCookie->pResults; callbackTag = pCookie->callbackTag; pCbFunc = pCookie->pSessionDesc->pCompressionCb; compDecomp = pCookie->compDecomp; pOpData = pCookie->pDcOpData; } opStatus = pCompRespMsg->comn_resp.comn_status; if (NULL != pOpData) { verifyHwIntegrityCrcs = pOpData->verifyHwIntegrityCrcs; integrityCrcCheck = pOpData->integrityCrcCheck; } hdrFlags = pCompRespMsg->comn_resp.hdr_flags; /* Get the cmp error code */ cmpErr = pCompRespMsg->comn_resp.comn_error.s1.cmp_err_code; if (ICP_QAT_FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET(opStatus)) { /* Compression not supported by firmware, set produced/consumed to zero and call the cb function with status CPA_STATUS_UNSUPPORTED */ QAT_UTILS_LOG("Compression feature not supported\n"); status = CPA_STATUS_UNSUPPORTED; pResults->status = (Cpa8S)cmpErr; pResults->consumed = 0; pResults->produced = 0; if (CPA_TRUE == isDcDp) { if (pResponse) pResponse->responseStatus = CPA_STATUS_UNSUPPORTED; (pService->pDcDpCb)(pResponse); } else { /* Free the memory pool */ Lac_MemPoolEntryFree(pCookie); pCookie = NULL; if (NULL != pCbFunc) { pCbFunc(callbackTag, status); } } if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC(numCompCompletedErrors, pService); } else { COMPRESSION_STAT_INC(numDecompCompletedErrors, pService); } return; } else { /* Check compression response status */ cmpPass = (CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(opStatus)); } if (isDcGen2x(pService)) { /* QAT1.7 and QAT 1.8 hardware */ if (CPA_DC_INCOMPLETE_FILE_ERR == (Cpa8S)cmpErr) { cmpPass = CPA_TRUE; cmpErr = ERR_CODE_NO_ERROR; } } else { /* QAT2.0 hardware cancels the incomplete file errors * only for DEFLATE algorithm. * Decompression direction is not tested in the callback as * the request does not allow it. */ if ((pSessionDesc->compType == CPA_DC_DEFLATE) && (CPA_DC_INCOMPLETE_FILE_ERR == (Cpa8S)cmpErr)) { cmpPass = CPA_TRUE; cmpErr = ERR_CODE_NO_ERROR; } } /* log the slice hang and endpoint push/pull error inside the response */ if (ERR_CODE_SSM_ERROR == (Cpa8S)cmpErr) { QAT_UTILS_LOG( "Slice hang detected on the compression slice.\n"); } else if (ERR_CODE_ENDPOINT_ERROR == (Cpa8S)cmpErr) { QAT_UTILS_LOG( "PCIe End Point Push/Pull or TI/RI Parity error detected.\n"); } /* We return the compression error code for now. We would need to update * the API if we decide to return both error codes */ pResults->status = (Cpa8S)cmpErr; /* Check the translator status */ if ((DC_COMPRESSION_REQUEST == compDecomp) && (CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType)) { /* Check translator response status */ xlatPass = (CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(opStatus)); /* Get the translator error code */ xlatErr = pCompRespMsg->comn_resp.comn_error.s1.xlat_err_code; /* Return a fatal error or a potential error in the translator * slice if the compression slice did not return any error */ if ((CPA_DC_OK == pResults->status) || (CPA_DC_FATALERR == (Cpa8S)xlatErr)) { pResults->status = (Cpa8S)xlatErr; } } /* Update dc error counter */ dcErrorLog(pResults->status); if (CPA_FALSE == isDcDp) { /* In case of any error for an end of packet request, we need to * update * the request type for the following request */ if (CPA_DC_FLUSH_FINAL == pCookie->flushFlag && cmpPass && xlatPass) { pSessionDesc->requestType = DC_REQUEST_FIRST; } else { pSessionDesc->requestType = DC_REQUEST_SUBSEQUENT; } if ((CPA_DC_STATEFUL == pSessionDesc->sessState) || ((CPA_DC_STATELESS == pSessionDesc->sessState) && (DC_COMPRESSION_REQUEST == compDecomp))) { /* Overflow is a valid use case for Traditional API * only. Stateful Overflow is supported in both * compression and decompression direction. Stateless * Overflow is supported only in compression direction. */ if (CPA_DC_OVERFLOW == (Cpa8S)cmpErr) cmpPass = CPA_TRUE; if (CPA_DC_OVERFLOW == (Cpa8S)xlatErr) { if (isDcGen4x(pService) && (CPA_TRUE == pService->comp_device_data .translatorOverflow)) { pResults->consumed = pCompRespMsg->comp_resp_pars .input_byte_counter; dcUpdateXltOverflowChecksumsGen4( pCookie, &pCompRespMsg->comp_resp_pars, pResults); } xlatPass = CPA_TRUE; } } } else { if (CPA_DC_OVERFLOW == (Cpa8S)cmpErr) { cmpPass = CPA_FALSE; } if (CPA_DC_OVERFLOW == (Cpa8S)xlatErr) { /* XLT overflow is not valid for Data Plane requests */ xlatPass = CPA_FALSE; } } if ((CPA_TRUE == cmpPass) && (CPA_TRUE == xlatPass)) { /* Extract the response from the firmware */ pResults->consumed = pCompRespMsg->comp_resp_pars.input_byte_counter; pResults->produced = pCompRespMsg->comp_resp_pars.output_byte_counter; pSessionDesc->cumulativeConsumedBytes += pResults->consumed; /* Handle Checksum for end to end data integrity. */ if (CPA_TRUE == pService->generic_service_info.integrityCrcCheck && CPA_TRUE == integrityCrcCheck) { pSessionDesc->previousChecksum = pSessionDesc->seedSwCrc.swCrc32I; } else if (CPA_DC_OVERFLOW != (Cpa8S)xlatErr) { if (CPA_DC_CRC32 == pSessionDesc->checksumType) { pResults->checksum = pCompRespMsg->comp_resp_pars.crc.legacy .curr_crc32; } else if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { pResults->checksum = pCompRespMsg->comp_resp_pars.crc.legacy .curr_adler_32; } pSessionDesc->previousChecksum = pResults->checksum; } if (DC_DECOMPRESSION_REQUEST == compDecomp) { pResults->endOfLastBlock = (ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET == ICP_QAT_FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET( opStatus)); } else { /* Check if returned data is a stored block * in compression direction */ pResults->dataUncompressed = ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_GET(hdrFlags); } /* Save the checksum for the next request */ if ((CPA_DC_OVERFLOW != (Cpa8S)xlatErr) && (CPA_TRUE == verifyHwIntegrityCrcs)) { pSessionDesc->previousChecksum = pSessionDesc->seedSwCrc.swCrc32I; } /* Check if a CNV recovery happened and * increase stats counter */ if ((DC_COMPRESSION_REQUEST == compDecomp) && ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(hdrFlags) && ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_GET(hdrFlags)) { COMPRESSION_STAT_INC(numCompCnvErrorsRecovered, pService); } if (CPA_TRUE == isDcDp) { if (pResponse) pResponse->responseStatus = CPA_STATUS_SUCCESS; } else { if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC(numCompCompleted, pService); } else { COMPRESSION_STAT_INC(numDecompCompleted, pService); } } } else { #ifdef ICP_DC_RETURN_COUNTERS_ON_ERROR /* Extract the response from the firmware */ pResults->consumed = pCompRespMsg->comp_resp_pars.input_byte_counter; pResults->produced = pCompRespMsg->comp_resp_pars.output_byte_counter; if (CPA_DC_STATEFUL == pSessionDesc->sessState) { pSessionDesc->cumulativeConsumedBytes += pResults->consumed; } else { /* In the stateless case all requests have both SOP and * EOP set */ pSessionDesc->cumulativeConsumedBytes = pResults->consumed; } #else pResults->consumed = 0; pResults->produced = 0; #endif if (CPA_DC_OVERFLOW == pResults->status && CPA_DC_STATELESS == pSessionDesc->sessState) { /* This error message will be returned by Data Plane API * in both * compression and decompression direction. With * Traditional API * this error message will be returned only in stateless * decompression direction */ QAT_UTILS_LOG( "Unrecoverable error: stateless overflow. You may need to increase the size of your destination buffer.\n"); } if (CPA_TRUE == isDcDp) { if (pResponse) pResponse->responseStatus = CPA_STATUS_FAIL; } else { if (CPA_DC_OK != pResults->status && CPA_DC_INCOMPLETE_FILE_ERR != pResults->status) { status = CPA_STATUS_FAIL; } if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC(numCompCompletedErrors, pService); } else { COMPRESSION_STAT_INC(numDecompCompletedErrors, pService); } } } if (CPA_TRUE == isDcDp) { /* Decrement number of stateless pending callbacks for session */ pSessionDesc->pendingDpStatelessCbCount--; (pService->pDcDpCb)(pResponse); } else { /* Decrement number of pending callbacks for session */ if (CPA_DC_STATELESS == pSessionDesc->sessState) { qatUtilsAtomicDec( &(pCookie->pSessionDesc->pendingStatelessCbCount)); } else if (0 != qatUtilsAtomicGet(&pCookie->pSessionDesc ->pendingStatefulCbCount)) { qatUtilsAtomicDec( &(pCookie->pSessionDesc->pendingStatefulCbCount)); } /* Free the memory pool */ Lac_MemPoolEntryFree(pCookie); pCookie = NULL; if (NULL != pCbFunc) { pCbFunc(callbackTag, status); } } } /** ***************************************************************************** * @ingroup Dc_DataCompression * Check that all the parameters in the pOpData structure are valid * * @description * Check that all the parameters in the pOpData structure are valid * * @param[in] pService Pointer to the compression service * @param[in] pOpData Pointer to request information structure * holding parameters for cpaDcCompress2 and * CpaDcDecompressData2 * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in * *****************************************************************************/ CpaStatus dcCheckOpData(sal_compression_service_t *pService, CpaDcOpData *pOpData) { CpaDcSkipMode skipMode = 0; if ((pOpData->flushFlag < CPA_DC_FLUSH_NONE) || (pOpData->flushFlag > CPA_DC_FLUSH_FULL)) { LAC_INVALID_PARAM_LOG("Invalid flushFlag value"); return CPA_STATUS_INVALID_PARAM; } skipMode = pOpData->inputSkipData.skipMode; if ((skipMode < CPA_DC_SKIP_DISABLED) || (skipMode > CPA_DC_SKIP_STRIDE)) { LAC_INVALID_PARAM_LOG("Invalid input skip mode value"); return CPA_STATUS_INVALID_PARAM; } skipMode = pOpData->outputSkipData.skipMode; if ((skipMode < CPA_DC_SKIP_DISABLED) || (skipMode > CPA_DC_SKIP_STRIDE)) { LAC_INVALID_PARAM_LOG("Invalid output skip mode value"); return CPA_STATUS_INVALID_PARAM; } if (pOpData->integrityCrcCheck == CPA_FALSE && pOpData->verifyHwIntegrityCrcs == CPA_TRUE) { LAC_INVALID_PARAM_LOG( "integrityCrcCheck must be set to true" "in order to enable verifyHwIntegrityCrcs"); return CPA_STATUS_INVALID_PARAM; } if (pOpData->integrityCrcCheck != CPA_TRUE && pOpData->integrityCrcCheck != CPA_FALSE) { LAC_INVALID_PARAM_LOG("Invalid integrityCrcCheck value"); return CPA_STATUS_INVALID_PARAM; } if (pOpData->verifyHwIntegrityCrcs != CPA_TRUE && pOpData->verifyHwIntegrityCrcs != CPA_FALSE) { LAC_INVALID_PARAM_LOG("Invalid verifyHwIntegrityCrcs value"); return CPA_STATUS_INVALID_PARAM; } if (pOpData->compressAndVerify != CPA_TRUE && pOpData->compressAndVerify != CPA_FALSE) { LAC_INVALID_PARAM_LOG("Invalid cnv decompress check value"); return CPA_STATUS_INVALID_PARAM; } if (CPA_TRUE == pOpData->integrityCrcCheck && CPA_FALSE == pService->generic_service_info.integrityCrcCheck) { LAC_INVALID_PARAM_LOG("Integrity CRC check is not " "supported on this device"); return CPA_STATUS_INVALID_PARAM; } if (CPA_TRUE == pOpData->integrityCrcCheck && NULL == pOpData->pCrcData) { LAC_INVALID_PARAM_LOG("Integrity CRC data structure " - "not intialized in CpaDcOpData"); + "not initialized in CpaDcOpData"); return CPA_STATUS_INVALID_PARAM; } return CPA_STATUS_SUCCESS; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Check the compression source buffer for Batch and Pack API. * * @description * Check that all the parameters used for Pack compression * request are valid. This function essentially checks the source buffer * parameters and results structure parameters. * * @param[in] pSessionHandle Session handle * @param[in] pSrcBuff Pointer to data buffer for compression * @param[in] pDestBuff Pointer to buffer space allocated for * output data * @param[in] pResults Pointer to results structure * @param[in] flushFlag Indicates the type of flush to be * performed * @param[in] srcBuffSize Size of the source buffer * * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in * *****************************************************************************/ static CpaStatus dcCheckSourceData(CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, Cpa64U srcBuffSize, CpaDcSkipData *skipData) { dc_session_desc_t *pSessionDesc = NULL; LAC_CHECK_NULL_PARAM(pSessionHandle); LAC_CHECK_NULL_PARAM(pSrcBuff); LAC_CHECK_NULL_PARAM(pDestBuff); LAC_CHECK_NULL_PARAM(pResults); pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); if (NULL == pSessionDesc) { LAC_INVALID_PARAM_LOG("Session handle not as expected"); return CPA_STATUS_INVALID_PARAM; } if ((flushFlag < CPA_DC_FLUSH_NONE) || (flushFlag > CPA_DC_FLUSH_FULL)) { LAC_INVALID_PARAM_LOG("Invalid flushFlag value"); return CPA_STATUS_INVALID_PARAM; } if (pSrcBuff == pDestBuff) { LAC_INVALID_PARAM_LOG("In place operation not supported"); return CPA_STATUS_INVALID_PARAM; } /* Compressing zero bytes is not supported for stateless sessions * for non Batch and Pack requests */ if ((CPA_DC_STATELESS == pSessionDesc->sessState) && (0 == srcBuffSize) && (NULL == skipData)) { LAC_INVALID_PARAM_LOG( "The source buffer size needs to be greater than " "zero bytes for stateless sessions"); return CPA_STATUS_INVALID_PARAM; } if (srcBuffSize > DC_BUFFER_MAX_SIZE) { LAC_INVALID_PARAM_LOG( "The source buffer size needs to be less than or " "equal to 2^32-1 bytes"); return CPA_STATUS_INVALID_PARAM; } return CPA_STATUS_SUCCESS; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Check the compression or decompression function parameters. * * @description * Check that all the parameters used for a Batch and Pack compression * request are valid. This function essentially checks the destination * buffer parameters and intermediate buffer parameters. * * @param[in] pService Pointer to the compression service * @param[in] pSessionHandle Session handle * @param[in] pDestBuff Pointer to buffer space allocated for * output data * @param[in] compDecomp Direction of the operation * * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in * *****************************************************************************/ static CpaStatus dcCheckDestinationData(sal_compression_service_t *pService, CpaDcSessionHandle pSessionHandle, CpaBufferList *pDestBuff, dc_request_dir_t compDecomp) { dc_session_desc_t *pSessionDesc = NULL; Cpa64U destBuffSize = 0; LAC_CHECK_NULL_PARAM(pSessionHandle); LAC_CHECK_NULL_PARAM(pDestBuff); pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); if (NULL == pSessionDesc) { LAC_INVALID_PARAM_LOG("Session handle not as expected"); return CPA_STATUS_INVALID_PARAM; } if (LacBuffDesc_BufferListVerify(pDestBuff, &destBuffSize, LAC_NO_ALIGNMENT_SHIFT) != CPA_STATUS_SUCCESS) { LAC_INVALID_PARAM_LOG( "Invalid destination buffer list parameter"); return CPA_STATUS_INVALID_PARAM; } if (destBuffSize > DC_BUFFER_MAX_SIZE) { LAC_INVALID_PARAM_LOG( "The destination buffer size needs to be less " "than or equal to 2^32-1 bytes"); return CPA_STATUS_INVALID_PARAM; } if (CPA_TRUE == pSessionDesc->isDcDp) { LAC_INVALID_PARAM_LOG( "The session type should not be data plane"); return CPA_STATUS_INVALID_PARAM; } if (DC_COMPRESSION_REQUEST == compDecomp) { if (CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType) { /* Check if intermediate buffers are supported */ if ((isDcGen2x(pService)) && ((0 == pService->pInterBuffPtrsArrayPhyAddr) || (NULL == pService->pInterBuffPtrsArray))) { LAC_LOG_ERROR( "No intermediate buffer defined for this instance " "- see cpaDcStartInstance"); return CPA_STATUS_INVALID_PARAM; } /* Ensure that the destination buffer size is greater or * equal to 128B */ if (destBuffSize < DC_DEST_BUFFER_DYN_MIN_SIZE) { LAC_INVALID_PARAM_LOG( "Destination buffer size should be " "greater or equal to 128B"); return CPA_STATUS_INVALID_PARAM; } } else { /* Ensure that the destination buffer size is greater or * equal to devices min output buff size */ if (destBuffSize < pService->comp_device_data.minOutputBuffSize) { LAC_INVALID_PARAM_LOG1( "Destination buffer size should be " "greater or equal to %d bytes", pService->comp_device_data .minOutputBuffSize); return CPA_STATUS_INVALID_PARAM; } } } else { /* Ensure that the destination buffer size is greater than * 0 bytes */ if (destBuffSize < DC_DEST_BUFFER_DEC_MIN_SIZE) { LAC_INVALID_PARAM_LOG( "Destination buffer size should be " "greater than 0 bytes"); return CPA_STATUS_INVALID_PARAM; } } return CPA_STATUS_SUCCESS; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Populate the compression request parameters * * @description * This function will populate the compression request parameters * * @param[out] pCompReqParams Pointer to the compression request parameters * @param[in] pCookie Pointer to the compression cookie * *****************************************************************************/ static void dcCompRequestParamsPopulate(icp_qat_fw_comp_req_params_t *pCompReqParams, dc_compression_cookie_t *pCookie) { pCompReqParams->comp_len = pCookie->srcTotalDataLenInBytes; pCompReqParams->out_buffer_sz = pCookie->dstTotalDataLenInBytes; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Create the requests for compression or decompression * * @description * Create the requests for compression or decompression. This function * will update the cookie will all required information. * * @param{out] pCookie Pointer to the compression cookie * @param[in] pService Pointer to the compression service * @param[in] pSessionDesc Pointer to the session descriptor * @param[in pSessionHandle Session handle * @param[in] pSrcBuff Pointer to data buffer for compression * @param[in] pDestBuff Pointer to buffer space for data after * compression * @param[in] pResults Pointer to results structure * @param[in] flushFlag Indicates the type of flush to be * performed * @param[in] pOpData Pointer to request information structure * holding parameters for cpaDcCompress2 * and CpaDcDecompressData2 * @param[in] callbackTag Pointer to the callback tag * @param[in] compDecomp Direction of the operation * @param[in] compressAndVerify Compress and Verify * * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in * *****************************************************************************/ static CpaStatus dcCreateRequest(dc_compression_cookie_t *pCookie, sal_compression_service_t *pService, dc_session_desc_t *pSessionDesc, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, CpaDcOpData *pOpData, void *callbackTag, dc_request_dir_t compDecomp, dc_cnv_mode_t cnvMode) { icp_qat_fw_comp_req_t *pMsg = NULL; icp_qat_fw_comp_req_params_t *pCompReqParams = NULL; Cpa64U srcAddrPhys = 0, dstAddrPhys = 0; Cpa64U srcTotalDataLenInBytes = 0, dstTotalDataLenInBytes = 0; Cpa32U rpCmdFlags = 0; Cpa8U sop = ICP_QAT_FW_COMP_SOP; Cpa8U eop = ICP_QAT_FW_COMP_EOP; Cpa8U bFinal = ICP_QAT_FW_COMP_NOT_BFINAL; Cpa8U crcMode = ICP_QAT_FW_COMP_CRC_MODE_LEGACY; Cpa8U cnvDecompReq = ICP_QAT_FW_COMP_NO_CNV; Cpa8U cnvRecovery = ICP_QAT_FW_COMP_NO_CNV_RECOVERY; CpaBoolean cnvErrorInjection = ICP_QAT_FW_COMP_NO_CNV_DFX; CpaBoolean integrityCrcCheck = CPA_FALSE; CpaStatus status = CPA_STATUS_SUCCESS; CpaDcFlush flush = CPA_DC_FLUSH_NONE; Cpa32U initial_adler = 1; Cpa32U initial_crc32 = 0; icp_qat_fw_comp_req_t *pReqCache = NULL; /* Write the buffer descriptors */ status = LacBuffDesc_BufferListDescWriteAndGetSize( pSrcBuff, &srcAddrPhys, CPA_FALSE, &srcTotalDataLenInBytes, &(pService->generic_service_info)); if (status != CPA_STATUS_SUCCESS) { return status; } status = LacBuffDesc_BufferListDescWriteAndGetSize( pDestBuff, &dstAddrPhys, CPA_FALSE, &dstTotalDataLenInBytes, &(pService->generic_service_info)); if (status != CPA_STATUS_SUCCESS) { return status; } /* Populate the compression cookie */ pCookie->dcInstance = pService; pCookie->pSessionHandle = pSessionHandle; pCookie->callbackTag = callbackTag; pCookie->pSessionDesc = pSessionDesc; pCookie->pDcOpData = pOpData; pCookie->pResults = pResults; pCookie->compDecomp = compDecomp; pCookie->pUserSrcBuff = NULL; pCookie->pUserDestBuff = NULL; /* Extract flush flag from either the opData or from the * parameter. Opdata have been introduce with APIs * cpaDcCompressData2 and cpaDcDecompressData2 */ if (NULL != pOpData) { flush = pOpData->flushFlag; integrityCrcCheck = pOpData->integrityCrcCheck; } else { flush = flushFlag; } pCookie->flushFlag = flush; /* The firmware expects the length in bytes for source and destination * to be Cpa32U parameters. However the total data length could be * bigger as allocated by the user. We ensure that this is not the case * in dcCheckSourceData and cast the values to Cpa32U here */ pCookie->srcTotalDataLenInBytes = (Cpa32U)srcTotalDataLenInBytes; if ((isDcGen2x(pService)) && (DC_COMPRESSION_REQUEST == compDecomp) && (CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType)) { if (pService->minInterBuffSizeInBytes < (Cpa32U)dstTotalDataLenInBytes) { pCookie->dstTotalDataLenInBytes = (Cpa32U)(pService->minInterBuffSizeInBytes); } else { pCookie->dstTotalDataLenInBytes = (Cpa32U)dstTotalDataLenInBytes; } } else { pCookie->dstTotalDataLenInBytes = (Cpa32U)dstTotalDataLenInBytes; } /* Device can not decompress an odd byte decompression request * if bFinal is not set */ if (CPA_TRUE != pService->comp_device_data.oddByteDecompNobFinal) { if ((CPA_DC_STATEFUL == pSessionDesc->sessState) && (CPA_DC_FLUSH_FINAL != flushFlag) && (DC_DECOMPRESSION_REQUEST == compDecomp) && (pCookie->srcTotalDataLenInBytes & 0x1)) { pCookie->srcTotalDataLenInBytes--; } } /* Device can not decompress odd byte interim requests */ if (CPA_TRUE != pService->comp_device_data.oddByteDecompInterim) { if ((CPA_DC_STATEFUL == pSessionDesc->sessState) && (CPA_DC_FLUSH_FINAL != flushFlag) && (CPA_DC_FLUSH_FULL != flushFlag) && (DC_DECOMPRESSION_REQUEST == compDecomp) && (pCookie->srcTotalDataLenInBytes & 0x1)) { pCookie->srcTotalDataLenInBytes--; } } pMsg = (icp_qat_fw_comp_req_t *)&pCookie->request; if (DC_COMPRESSION_REQUEST == compDecomp) { pReqCache = &(pSessionDesc->reqCacheComp); } else { pReqCache = &(pSessionDesc->reqCacheDecomp); } /* Fills the msg from the template cached in the session descriptor */ memcpy((void *)pMsg, (void *)(pReqCache), LAC_QAT_DC_REQ_SZ_LW * LAC_LONG_WORD_IN_BYTES); if (DC_REQUEST_FIRST == pSessionDesc->requestType) { initial_adler = 1; initial_crc32 = 0; if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { pSessionDesc->previousChecksum = initial_adler; } else { pSessionDesc->previousChecksum = initial_crc32; } } else if (CPA_DC_STATELESS == pSessionDesc->sessState) { pSessionDesc->previousChecksum = pResults->checksum; if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { initial_adler = pSessionDesc->previousChecksum; } else { initial_crc32 = pSessionDesc->previousChecksum; } } /* Backup source and destination buffer addresses, * CRC calculations both for CNV and translator overflow * will be performed on them in the callback function. */ pCookie->pUserSrcBuff = pSrcBuff; pCookie->pUserDestBuff = pDestBuff; /* * Due to implementation of CNV support and need for backwards * compatibility certain fields in the request and response structs had * been changed, moved or placed in unions cnvMode flag signifies fields * to be selected from req/res * * Doing extended crc checks makes sense only when we want to do the * actual CNV */ if (CPA_TRUE == pService->generic_service_info.integrityCrcCheck && CPA_TRUE == integrityCrcCheck) { pMsg->comp_pars.crc.crc_data_addr = pSessionDesc->physDataIntegrityCrcs; crcMode = ICP_QAT_FW_COMP_CRC_MODE_E2E; } else { /* Legacy request structure */ pMsg->comp_pars.crc.legacy.initial_adler = initial_adler; pMsg->comp_pars.crc.legacy.initial_crc32 = initial_crc32; crcMode = ICP_QAT_FW_COMP_CRC_MODE_LEGACY; } /* Populate the cmdFlags */ if (CPA_DC_STATEFUL == pSessionDesc->sessState) { pSessionDesc->previousRequestType = pSessionDesc->requestType; if (DC_REQUEST_FIRST == pSessionDesc->requestType) { /* Update the request type for following requests */ pSessionDesc->requestType = DC_REQUEST_SUBSEQUENT; /* Reinitialise the cumulative amount of consumed bytes */ pSessionDesc->cumulativeConsumedBytes = 0; if (DC_COMPRESSION_REQUEST == compDecomp) { pSessionDesc->isSopForCompressionProcessed = CPA_TRUE; } else if (DC_DECOMPRESSION_REQUEST == compDecomp) { pSessionDesc->isSopForDecompressionProcessed = CPA_TRUE; } } else { if (DC_COMPRESSION_REQUEST == compDecomp) { if (CPA_TRUE == pSessionDesc ->isSopForCompressionProcessed) { sop = ICP_QAT_FW_COMP_NOT_SOP; } else { pSessionDesc ->isSopForCompressionProcessed = CPA_TRUE; } } else if (DC_DECOMPRESSION_REQUEST == compDecomp) { if (CPA_TRUE == pSessionDesc ->isSopForDecompressionProcessed) { sop = ICP_QAT_FW_COMP_NOT_SOP; } else { pSessionDesc ->isSopForDecompressionProcessed = CPA_TRUE; } } } if ((CPA_DC_FLUSH_FINAL == flush) || (CPA_DC_FLUSH_FULL == flush)) { /* Update the request type for following requests */ pSessionDesc->requestType = DC_REQUEST_FIRST; } else { eop = ICP_QAT_FW_COMP_NOT_EOP; } } else { if (DC_REQUEST_FIRST == pSessionDesc->requestType) { /* Reinitialise the cumulative amount of consumed bytes */ pSessionDesc->cumulativeConsumedBytes = 0; } } /* (LW 14 - 15) */ pCompReqParams = &(pMsg->comp_pars); dcCompRequestParamsPopulate(pCompReqParams, pCookie); if (CPA_DC_FLUSH_FINAL == flush) { bFinal = ICP_QAT_FW_COMP_BFINAL; } switch (cnvMode) { case DC_CNVNR: cnvRecovery = ICP_QAT_FW_COMP_CNV_RECOVERY; /* Fall through is intended here, because for CNVNR * cnvDecompReq also needs to be set */ case DC_CNV: cnvDecompReq = ICP_QAT_FW_COMP_CNV; if (isDcGen4x(pService)) { cnvErrorInjection = pSessionDesc->cnvErrorInjection; } break; case DC_NO_CNV: cnvDecompReq = ICP_QAT_FW_COMP_NO_CNV; cnvRecovery = ICP_QAT_FW_COMP_NO_CNV_RECOVERY; break; } /* LW 18 */ rpCmdFlags = ICP_QAT_FW_COMP_REQ_PARAM_FLAGS_BUILD(sop, eop, bFinal, cnvDecompReq, cnvRecovery, cnvErrorInjection, crcMode); pMsg->comp_pars.req_par_flags = rpCmdFlags; /* Populates the QAT common request middle part of the message * (LW 6 to 11) */ SalQatMsg_CmnMidWrite((icp_qat_fw_la_bulk_req_t *)pMsg, pCookie, DC_DEFAULT_QAT_PTR_TYPE, srcAddrPhys, dstAddrPhys, 0, 0); return CPA_STATUS_SUCCESS; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Send a compression request to QAT * * @description * Send the requests for compression or decompression to QAT * * @param{in] pCookie Pointer to the compression cookie * @param[in] pService Pointer to the compression service * @param[in] pSessionDesc Pointer to the session descriptor * @param[in] compDecomp Direction of the operation * * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in * *****************************************************************************/ static CpaStatus dcSendRequest(dc_compression_cookie_t *pCookie, sal_compression_service_t *pService, dc_session_desc_t *pSessionDesc, dc_request_dir_t compDecomp) { CpaStatus status = CPA_STATUS_SUCCESS; /* Send to QAT */ status = icp_adf_transPutMsg(pService->trans_handle_compression_tx, (void *)&(pCookie->request), LAC_QAT_DC_REQ_SZ_LW); if ((CPA_DC_STATEFUL == pSessionDesc->sessState) && (CPA_STATUS_RETRY == status)) { /* reset requestType after receiving an retry on * the stateful request */ pSessionDesc->requestType = pSessionDesc->previousRequestType; } return status; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Process the synchronous and asynchronous case for compression or * decompression * * @description * Process the synchronous and asynchronous case for compression or * decompression. This function will then create and send the request to * the firmware. * * @param[in] pService Pointer to the compression service * @param[in] pSessionDesc Pointer to the session descriptor * @param[in] dcInstance Instance handle derived from discovery * functions * @param[in] pSessionHandle Session handle * @param[in] numRequests Number of operations in the batch request * @param[in] pBatchOpData Address of the list of jobs to be processed * @param[in] pSrcBuff Pointer to data buffer for compression * @param[in] pDestBuff Pointer to buffer space for data after * compression * @param[in] pResults Pointer to results structure * @param[in] flushFlag Indicates the type of flush to be * performed * @param[in] pOpData Pointer to request information structure * holding parameters for cpaDcCompress2 and * CpaDcDecompressData2 * @param[in] callbackTag Pointer to the callback tag * @param[in] compDecomp Direction of the operation * @param[in] isAsyncMode Used to know if synchronous or asynchronous * mode * @param[in] cnvMode CNV Mode * * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_RETRY Retry operation * @retval CPA_STATUS_FAIL Function failed * @retval CPA_STATUS_RESOURCE Resource error * *****************************************************************************/ static CpaStatus dcCompDecompData(sal_compression_service_t *pService, dc_session_desc_t *pSessionDesc, CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, CpaDcOpData *pOpData, void *callbackTag, dc_request_dir_t compDecomp, CpaBoolean isAsyncMode, dc_cnv_mode_t cnvMode) { CpaStatus status = CPA_STATUS_SUCCESS; dc_compression_cookie_t *pCookie = NULL; if ((LacSync_GenWakeupSyncCaller == pSessionDesc->pCompressionCb) && isAsyncMode == CPA_TRUE) { lac_sync_op_data_t *pSyncCallbackData = NULL; status = LacSync_CreateSyncCookie(&pSyncCallbackData); if (CPA_STATUS_SUCCESS == status) { status = dcCompDecompData(pService, pSessionDesc, dcInstance, pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, pOpData, pSyncCallbackData, compDecomp, CPA_FALSE, cnvMode); } else { return status; } if (CPA_STATUS_SUCCESS == status) { CpaStatus syncStatus = CPA_STATUS_SUCCESS; syncStatus = LacSync_WaitForCallback(pSyncCallbackData, DC_SYNC_CALLBACK_TIMEOUT, &status, NULL); /* If callback doesn't come back */ if (CPA_STATUS_SUCCESS != syncStatus) { if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC( numCompCompletedErrors, pService); } else { COMPRESSION_STAT_INC( numDecompCompletedErrors, pService); } LAC_LOG_ERROR("Callback timed out"); status = syncStatus; } } else { /* As the Request was not sent the Callback will never * be called, so need to indicate that we're finished * with cookie so it can be destroyed. */ LacSync_SetSyncCookieComplete(pSyncCallbackData); } LacSync_DestroySyncCookie(&pSyncCallbackData); return status; } /* Allocate the compression cookie * The memory is freed in callback or in sendRequest if an error occurs */ pCookie = (dc_compression_cookie_t *)Lac_MemPoolEntryAlloc( pService->compression_mem_pool); if (NULL == pCookie) { LAC_LOG_ERROR("Cannot get mem pool entry for compression"); status = CPA_STATUS_RESOURCE; } else if ((void *)CPA_STATUS_RETRY == pCookie) { pCookie = NULL; status = CPA_STATUS_RETRY; } if (CPA_STATUS_SUCCESS == status) { status = dcCreateRequest(pCookie, pService, pSessionDesc, pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, pOpData, callbackTag, compDecomp, cnvMode); } if (CPA_STATUS_SUCCESS == status) { /* Increment number of pending callbacks for session */ if (CPA_DC_STATELESS == pSessionDesc->sessState) { qatUtilsAtomicInc( &(pSessionDesc->pendingStatelessCbCount)); } status = dcSendRequest(pCookie, pService, pSessionDesc, compDecomp); } if (CPA_STATUS_SUCCESS == status) { if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC(numCompRequests, pService); } else { COMPRESSION_STAT_INC(numDecompRequests, pService); } } else { if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC(numCompRequestsErrors, pService); } else { COMPRESSION_STAT_INC(numDecompRequestsErrors, pService); } /* Decrement number of pending callbacks for session */ if (CPA_DC_STATELESS == pSessionDesc->sessState) { qatUtilsAtomicDec( &(pSessionDesc->pendingStatelessCbCount)); } else { qatUtilsAtomicDec( &(pSessionDesc->pendingStatefulCbCount)); } /* Free the memory pool */ if (NULL != pCookie) { if (status != CPA_STATUS_UNSUPPORTED) { /* Free the memory pool */ Lac_MemPoolEntryFree(pCookie); pCookie = NULL; } } } return status; } /** ***************************************************************************** * @ingroup Dc_DataCompression * Handle zero length compression or decompression requests * * @description * Handle zero length compression or decompression requests * * @param[in] pService Pointer to the compression service * @param[in] pSessionDesc Pointer to the session descriptor * @param[in] pResults Pointer to results structure * @param[in] flushFlag Indicates the type of flush to be * performed * @param[in] callbackTag User supplied value to help correlate * the callback with its associated request * @param[in] compDecomp Direction of the operation * * @retval CPA_TRUE Zero length SOP or MOP processed * @retval CPA_FALSE Zero length EOP * *****************************************************************************/ static CpaStatus dcZeroLengthRequests(sal_compression_service_t *pService, dc_session_desc_t *pSessionDesc, CpaDcRqResults *pResults, CpaDcFlush flushFlag, void *callbackTag, dc_request_dir_t compDecomp) { CpaBoolean status = CPA_FALSE; CpaDcCallbackFn pCbFunc = pSessionDesc->pCompressionCb; if (DC_REQUEST_FIRST == pSessionDesc->requestType) { /* Reinitialise the cumulative amount of consumed bytes */ pSessionDesc->cumulativeConsumedBytes = 0; /* Zero length SOP */ if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { pResults->checksum = 1; } else { pResults->checksum = 0; } status = CPA_TRUE; } else if ((CPA_DC_FLUSH_NONE == flushFlag) || (CPA_DC_FLUSH_SYNC == flushFlag)) { /* Zero length MOP */ pResults->checksum = pSessionDesc->previousChecksum; status = CPA_TRUE; } if (CPA_TRUE == status) { pResults->status = CPA_DC_OK; pResults->produced = 0; pResults->consumed = 0; /* Increment statistics */ if (DC_COMPRESSION_REQUEST == compDecomp) { COMPRESSION_STAT_INC(numCompRequests, pService); COMPRESSION_STAT_INC(numCompCompleted, pService); } else { COMPRESSION_STAT_INC(numDecompRequests, pService); COMPRESSION_STAT_INC(numDecompCompleted, pService); } LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); if ((NULL != pCbFunc) && (LacSync_GenWakeupSyncCaller != pCbFunc)) { pCbFunc(callbackTag, CPA_STATUS_SUCCESS); } return CPA_TRUE; } return CPA_FALSE; } static CpaStatus dcParamCheck(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, sal_compression_service_t *pService, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, dc_session_desc_t *pSessionDesc, CpaDcFlush flushFlag, Cpa64U srcBuffSize) { if (dcCheckSourceData(pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, srcBuffSize, NULL) != CPA_STATUS_SUCCESS) { return CPA_STATUS_INVALID_PARAM; } if (dcCheckDestinationData( pService, pSessionHandle, pDestBuff, DC_COMPRESSION_REQUEST) != CPA_STATUS_SUCCESS) { return CPA_STATUS_INVALID_PARAM; } if (CPA_DC_DIR_DECOMPRESS == pSessionDesc->sessDirection) { LAC_INVALID_PARAM_LOG("Invalid sessDirection value"); return CPA_STATUS_INVALID_PARAM; } return CPA_STATUS_SUCCESS; } CpaStatus cpaDcCompressData(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, void *callbackTag) { sal_compression_service_t *pService = NULL; dc_session_desc_t *pSessionDesc = NULL; CpaInstanceHandle insHandle = NULL; Cpa64U srcBuffSize = 0; - if (CPA_INSTANCE_HANDLE_SINGLE == dcInstance) { insHandle = dcGetFirstHandle(); } else { insHandle = dcInstance; } pService = (sal_compression_service_t *)insHandle; LAC_CHECK_NULL_PARAM(insHandle); LAC_CHECK_NULL_PARAM(pSessionHandle); /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(insHandle); /* This check is outside the parameter checking as it is needed to * manage zero length requests */ if (LacBuffDesc_BufferListVerifyNull(pSrcBuff, &srcBuffSize, LAC_NO_ALIGNMENT_SHIFT) != CPA_STATUS_SUCCESS) { LAC_INVALID_PARAM_LOG("Invalid source buffer list parameter"); return CPA_STATUS_INVALID_PARAM; } /* Ensure this is a compression instance */ SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); if (CPA_STATUS_SUCCESS != dcParamCheck(insHandle, pSessionHandle, pService, pSrcBuff, pDestBuff, pResults, pSessionDesc, flushFlag, srcBuffSize)) { return CPA_STATUS_INVALID_PARAM; } if (CPA_DC_STATEFUL == pSessionDesc->sessState) { LAC_INVALID_PARAM_LOG( "Invalid session state, stateful sessions " "are not supported"); return CPA_STATUS_UNSUPPORTED; } if (!(pService->generic_service_info.dcExtendedFeatures & DC_CNV_EXTENDED_CAPABILITY)) { LAC_INVALID_PARAM_LOG( "CompressAndVerify feature not supported"); return CPA_STATUS_UNSUPPORTED; } if (!(pService->generic_service_info.dcExtendedFeatures & DC_CNVNR_EXTENDED_CAPABILITY)) { LAC_INVALID_PARAM_LOG( "CompressAndVerifyAndRecovery feature not supported"); return CPA_STATUS_UNSUPPORTED; } return dcCompDecompData(pService, pSessionDesc, insHandle, pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, NULL, callbackTag, DC_COMPRESSION_REQUEST, CPA_TRUE, DC_CNVNR); } CpaStatus cpaDcCompressData2(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcOpData *pOpData, CpaDcRqResults *pResults, void *callbackTag) { sal_compression_service_t *pService = NULL; dc_session_desc_t *pSessionDesc = NULL; CpaInstanceHandle insHandle = NULL; Cpa64U srcBuffSize = 0; dc_cnv_mode_t cnvMode = DC_NO_CNV; LAC_CHECK_NULL_PARAM(pOpData); if (((CPA_TRUE != pOpData->compressAndVerify) && (CPA_FALSE != pOpData->compressAndVerify)) || ((CPA_FALSE != pOpData->compressAndVerifyAndRecover) && (CPA_TRUE != pOpData->compressAndVerifyAndRecover))) { return CPA_STATUS_INVALID_PARAM; } if ((CPA_FALSE == pOpData->compressAndVerify) && (CPA_TRUE == pOpData->compressAndVerifyAndRecover)) { return CPA_STATUS_INVALID_PARAM; } - if ((CPA_TRUE == pOpData->compressAndVerify) && (CPA_TRUE == pOpData->compressAndVerifyAndRecover) && (CPA_FALSE == pOpData->integrityCrcCheck)) { return cpaDcCompressData(dcInstance, pSessionHandle, pSrcBuff, pDestBuff, pResults, pOpData->flushFlag, callbackTag); } if (CPA_FALSE == pOpData->compressAndVerify) { LAC_INVALID_PARAM_LOG( "Data compression without verification not allowed"); return CPA_STATUS_UNSUPPORTED; } - if (CPA_INSTANCE_HANDLE_SINGLE == dcInstance) { insHandle = dcGetFirstHandle(); } else { insHandle = dcInstance; } pService = (sal_compression_service_t *)insHandle; LAC_CHECK_NULL_PARAM(insHandle); LAC_CHECK_NULL_PARAM(pSessionHandle); LAC_CHECK_NULL_PARAM(pOpData); /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(insHandle); /* This check is outside the parameter checking as it is needed to * manage zero length requests */ if (LacBuffDesc_BufferListVerifyNull(pSrcBuff, &srcBuffSize, LAC_NO_ALIGNMENT_SHIFT) != CPA_STATUS_SUCCESS) { LAC_INVALID_PARAM_LOG("Invalid source buffer list parameter"); return CPA_STATUS_INVALID_PARAM; } /* Ensure this is a compression instance */ SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); if (CPA_TRUE == pOpData->compressAndVerify && CPA_DC_STATEFUL == pSessionDesc->sessState) { LAC_INVALID_PARAM_LOG( "Invalid session state, stateful sessions " "not supported with CNV"); return CPA_STATUS_UNSUPPORTED; } if (!(pService->generic_service_info.dcExtendedFeatures & DC_CNV_EXTENDED_CAPABILITY) && (CPA_TRUE == pOpData->compressAndVerify)) { LAC_INVALID_PARAM_LOG( "CompressAndVerify feature not supported"); return CPA_STATUS_UNSUPPORTED; } if (CPA_STATUS_SUCCESS != dcParamCheck(insHandle, pSessionHandle, pService, pSrcBuff, pDestBuff, pResults, pSessionDesc, pOpData->flushFlag, srcBuffSize)) { return CPA_STATUS_INVALID_PARAM; } if (CPA_STATUS_SUCCESS != dcCheckOpData(pService, pOpData)) { return CPA_STATUS_INVALID_PARAM; } if (CPA_TRUE != pOpData->compressAndVerify) { if (srcBuffSize > DC_COMP_MAX_BUFF_SIZE) { LAC_LOG_ERROR( "Compression payload greater than 64KB is " "unsupported, when CnV is disabled\n"); return CPA_STATUS_UNSUPPORTED; } } if (CPA_DC_STATEFUL == pSessionDesc->sessState) { /* Lock the session to check if there are in-flight stateful * requests */ LAC_SPINLOCK(&(pSessionDesc->sessionLock)); /* Check if there is already one in-flight stateful request */ if (0 != qatUtilsAtomicGet( &(pSessionDesc->pendingStatefulCbCount))) { LAC_LOG_ERROR( "Only one in-flight stateful request supported"); LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); return CPA_STATUS_RETRY; } if (0 == srcBuffSize) { if (CPA_TRUE == dcZeroLengthRequests(pService, pSessionDesc, pResults, pOpData->flushFlag, callbackTag, DC_COMPRESSION_REQUEST)) { return CPA_STATUS_SUCCESS; } } qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); } if (CPA_TRUE == pOpData->compressAndVerify) { cnvMode = DC_CNV; } return dcCompDecompData(pService, pSessionDesc, insHandle, pSessionHandle, pSrcBuff, pDestBuff, pResults, pOpData->flushFlag, pOpData, callbackTag, DC_COMPRESSION_REQUEST, CPA_TRUE, cnvMode); } static CpaStatus dcDecompressDataCheck(CpaInstanceHandle insHandle, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, Cpa64U *srcBufferSize) { sal_compression_service_t *pService = NULL; dc_session_desc_t *pSessionDesc = NULL; Cpa64U srcBuffSize = 0; pService = (sal_compression_service_t *)insHandle; LAC_CHECK_NULL_PARAM(insHandle); /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(insHandle); /* This check is outside the parameter checking as it is needed to * manage zero length requests */ if (LacBuffDesc_BufferListVerifyNull(pSrcBuff, &srcBuffSize, LAC_NO_ALIGNMENT_SHIFT) != CPA_STATUS_SUCCESS) { LAC_INVALID_PARAM_LOG("Invalid source buffer list parameter"); return CPA_STATUS_INVALID_PARAM; } /* Ensure this is a compression instance */ SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); if (dcCheckSourceData(pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, srcBuffSize, NULL) != CPA_STATUS_SUCCESS) { return CPA_STATUS_INVALID_PARAM; } if (dcCheckDestinationData(pService, pSessionHandle, pDestBuff, DC_DECOMPRESSION_REQUEST) != CPA_STATUS_SUCCESS) { return CPA_STATUS_INVALID_PARAM; } pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); if (CPA_DC_DIR_COMPRESS == pSessionDesc->sessDirection) { LAC_INVALID_PARAM_LOG("Invalid sessDirection value"); return CPA_STATUS_INVALID_PARAM; } - *srcBufferSize = srcBuffSize; return CPA_STATUS_SUCCESS; } CpaStatus cpaDcDecompressData(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, void *callbackTag) { sal_compression_service_t *pService = NULL; dc_session_desc_t *pSessionDesc = NULL; CpaInstanceHandle insHandle = NULL; Cpa64U srcBuffSize = 0; CpaStatus status = CPA_STATUS_SUCCESS; - if (CPA_INSTANCE_HANDLE_SINGLE == dcInstance) { insHandle = dcGetFirstHandle(); } else { insHandle = dcInstance; } status = dcDecompressDataCheck(insHandle, pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, &srcBuffSize); if (CPA_STATUS_SUCCESS != status) { return status; } pService = (sal_compression_service_t *)insHandle; /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(insHandle); /* This check is outside the parameter checking as it is needed to * manage zero length requests */ if (CPA_STATUS_SUCCESS != LacBuffDesc_BufferListVerifyNull(pSrcBuff, &srcBuffSize, LAC_NO_ALIGNMENT_SHIFT)) { QAT_UTILS_LOG("Invalid source buffer list parameter"); return CPA_STATUS_INVALID_PARAM; } /* Ensure this is a compression instance */ SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); if (dcCheckSourceData(pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, srcBuffSize, NULL) != CPA_STATUS_SUCCESS) { return CPA_STATUS_INVALID_PARAM; } if (dcCheckDestinationData(pService, pSessionHandle, pDestBuff, DC_DECOMPRESSION_REQUEST) != CPA_STATUS_SUCCESS) { return CPA_STATUS_INVALID_PARAM; } pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); if (CPA_DC_DIR_COMPRESS == pSessionDesc->sessDirection) { QAT_UTILS_LOG("Invalid sessDirection value"); return CPA_STATUS_INVALID_PARAM; } - if (CPA_DC_STATEFUL == pSessionDesc->sessState) { /* Lock the session to check if there are in-flight stateful * requests */ LAC_SPINLOCK(&(pSessionDesc->sessionLock)); /* Check if there is already one in-flight stateful request */ if (0 != qatUtilsAtomicGet( &(pSessionDesc->pendingStatefulCbCount))) { LAC_LOG_ERROR( "Only one in-flight stateful request supported"); LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); return CPA_STATUS_RETRY; } /* Gen 4 handle 0 len requests in FW */ if (isDcGen2x(pService)) { if ((0 == srcBuffSize) || ((1 == srcBuffSize) && (CPA_DC_FLUSH_FINAL != flushFlag) && (CPA_DC_FLUSH_FULL != flushFlag))) { if (CPA_TRUE == dcZeroLengthRequests( pService, pSessionDesc, pResults, flushFlag, callbackTag, DC_DECOMPRESSION_REQUEST)) { return CPA_STATUS_SUCCESS; } } } qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); } return dcCompDecompData(pService, pSessionDesc, insHandle, pSessionHandle, pSrcBuff, pDestBuff, pResults, flushFlag, NULL, callbackTag, DC_DECOMPRESSION_REQUEST, CPA_TRUE, DC_NO_CNV); } CpaStatus cpaDcDecompressData2(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcOpData *pOpData, CpaDcRqResults *pResults, void *callbackTag) { sal_compression_service_t *pService = NULL; dc_session_desc_t *pSessionDesc = NULL; CpaInstanceHandle insHandle = NULL; CpaStatus status = CPA_STATUS_SUCCESS; Cpa64U srcBuffSize = 0; LAC_CHECK_NULL_PARAM(pOpData); if (CPA_FALSE == pOpData->integrityCrcCheck) { return cpaDcDecompressData(dcInstance, pSessionHandle, pSrcBuff, pDestBuff, pResults, pOpData->flushFlag, callbackTag); } - if (CPA_INSTANCE_HANDLE_SINGLE == dcInstance) { insHandle = dcGetFirstHandle(); } else { insHandle = dcInstance; } status = dcDecompressDataCheck(insHandle, pSessionHandle, pSrcBuff, pDestBuff, pResults, pOpData->flushFlag, &srcBuffSize); if (CPA_STATUS_SUCCESS != status) { return status; } pService = (sal_compression_service_t *)insHandle; pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); LAC_CHECK_NULL_PARAM(insHandle); /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(insHandle); /* This check is outside the parameter checking as it is needed to * manage zero length requests */ if (CPA_STATUS_SUCCESS != LacBuffDesc_BufferListVerifyNull(pSrcBuff, &srcBuffSize, LAC_NO_ALIGNMENT_SHIFT)) { QAT_UTILS_LOG("Invalid source buffer list parameter"); return CPA_STATUS_INVALID_PARAM; } /* Ensure this is a compression instance */ SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); if (CPA_STATUS_SUCCESS != dcCheckSourceData(pSessionHandle, pSrcBuff, pDestBuff, pResults, CPA_DC_FLUSH_NONE, srcBuffSize, NULL)) { return CPA_STATUS_INVALID_PARAM; } if (CPA_STATUS_SUCCESS != dcCheckDestinationData(pService, pSessionHandle, pDestBuff, DC_DECOMPRESSION_REQUEST)) { return CPA_STATUS_INVALID_PARAM; } if (CPA_STATUS_SUCCESS != dcCheckOpData(pService, pOpData)) { return CPA_STATUS_INVALID_PARAM; } if (CPA_DC_DIR_COMPRESS == pSessionDesc->sessDirection) { QAT_UTILS_LOG("Invalid sessDirection value"); return CPA_STATUS_INVALID_PARAM; } - if (CPA_DC_STATEFUL == pSessionDesc->sessState) { /* Lock the session to check if there are in-flight stateful * requests */ LAC_SPINLOCK(&(pSessionDesc->sessionLock)); /* Check if there is already one in-flight stateful request */ if (0 != qatUtilsAtomicGet( &(pSessionDesc->pendingStatefulCbCount))) { LAC_LOG_ERROR( "Only one in-flight stateful request supported"); LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); return CPA_STATUS_RETRY; } /* Gen 4 handle 0 len requests in FW */ if (isDcGen2x(pService)) { if ((0 == srcBuffSize) || ((1 == srcBuffSize) && (CPA_DC_FLUSH_FINAL != pOpData->flushFlag) && (CPA_DC_FLUSH_FULL != pOpData->flushFlag))) { if (CPA_TRUE == dcZeroLengthRequests( pService, pSessionDesc, pResults, pOpData->flushFlag, callbackTag, DC_DECOMPRESSION_REQUEST)) { return CPA_STATUS_SUCCESS; } } } qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); } return dcCompDecompData(pService, pSessionDesc, insHandle, pSessionHandle, pSrcBuff, pDestBuff, pResults, pOpData->flushFlag, pOpData, callbackTag, DC_DECOMPRESSION_REQUEST, CPA_TRUE, DC_NO_CNV); } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_session.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_session.h index afb3994daad7..6c9de34e7691 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_session.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_session.h @@ -1,691 +1,691 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_session.h * * @defgroup LacSym_Session Session * * @ingroup LacSym * * Definition of symmetric session descriptor structure * * @lld_start * * @lld_overview * A session is required for each symmetric operation. The session descriptor * holds information about the session from when the session is initialised to * when the session is removed. The session descriptor is used in the * subsequent perform operations in the paths for both sending the request and * receiving the response. The session descriptor and any other state * information required for processing responses from the QAT are stored in an * internal cookie. A pointer to this cookie is stored in the opaque data * field of the QAT request. * * The user allocates the memory for the session using the size returned from * \ref cpaCySymSessionCtxGetSize(). Internally this memory is re-aligned on a * 64 byte boundary for use by the QAT engine. The aligned pointer is saved in * the first bytes (size of void *) of the session memory. This address * is then dereferenced in subsequent performs to get access to the session * descriptor. * * LAC Session Init\n The session descriptor is re-aligned and * populated. This includes populating the content descriptor which contains * the hardware setup for the QAT engine. The content descriptor is a read * only structure after session init and a pointer to it is sent to the QAT * for each perform operation. * * LAC Perform \n * The address for the session descriptor is got by dereferencing the first * bytes of the session memory (size of void *). For each successful * request put on the ring, the pendingCbCount for the session is incremented. * * LAC Callback \n * For each successful response the pendingCbCount for the session is * decremented. See \ref LacSymCb_ProcessCallbackInternal() * * LAC Session Remove \n * The address for the session descriptor is got by dereferencing the first * bytes of the session memory (size of void *). * The pendingCbCount for the session is checked to see if it is 0. If it is * non 0 then there are requests in flight. An error is returned to the user. * * Concurrency\n * A reference count is used to prevent the descriptor being removed * while there are requests in flight. * * Reference Count\n - * - The perform funcion increments the reference count for the session. + * - The perform function increments the reference count for the session. * - The callback function decrements the reference count for the session. * - The Remove function checks the reference count to ensure that it is 0. * * @lld_dependencies * - \ref LacMem "Memory" - Inline memory functions * - QatUtils: logging, locking & virt to phys translations. * * @lld_initialisation * * @lld_module_algorithms * * @lld_process_context * * @lld_end * *****************************************************************************/ /***************************************************************************/ #ifndef LAC_SYM_SESSION_H #define LAC_SYM_SESSION_H /* * Common alignment attributes to ensure * hashStatePrefixBuffer is 64-byte aligned */ #define ALIGN_START(x) #define ALIGN_END(x) __attribute__((__aligned__(x))) /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "icp_accel_devices.h" #include "lac_list.h" #include "lac_sal_types.h" #include "sal_qat_cmn_msg.h" #include "lac_sym_cipher_defs.h" #include "lac_sym.h" #include "lac_sym_hash_defs.h" #include "lac_sym_qat_hash.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ /** ***************************************************************************** * @ingroup LacSym * Spc state * * @description * This enum is used to indicate the Spc state. * *****************************************************************************/ typedef enum lac_single_pass_state_e { NON_SPC, /* Algorithms other than CHACHA-POLY and AES-GCM */ LIKELY_SPC, /* AES-GCM - Likely to handle it as single pass */ SPC /* CHACHA-POLY and AES-GCM */ } lac_single_pass_state_t; /** ******************************************************************************* * @ingroup LacSym_Session * Symmetric session descriptor * @description * This structure stores information about a session * Note: struct types lac_session_d1_s and lac_session_d2_s are subsets of * this structure. Elements in all three should retain the same order * Only this structure is used in the session init call. The other two are * for determining the size of memory to allocate. * The comments section of each of the other two structures below show * the conditions that determine which session context memory size to use. *****************************************************************************/ typedef struct lac_session_desc_s { Cpa8U contentDescriptor[LAC_SYM_QAT_CONTENT_DESC_MAX_SIZE]; /**< QAT Content Descriptor for this session. * NOTE: Field must be correctly aligned in memory for access by QAT * engine */ Cpa8U contentDescriptorOptimised[LAC_SYM_OPTIMISED_CD_SIZE]; /**< QAT Optimised Content Descriptor for this session. * NOTE: Field must be correctly aligned in memory for access by QAT * engine */ CpaCySymOp symOperation; /**< type of command to be performed */ sal_qat_content_desc_info_t contentDescInfo; /**< info on the content descriptor */ sal_qat_content_desc_info_t contentDescOptimisedInfo; /**< info on the optimised content descriptor */ icp_qat_fw_la_cmd_id_t laCmdId; /** - * - ***************************************************************************/ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_alg_chain.h * * @defgroup LacAlgChain Algorithm Chaining * * @ingroup LacSym * * Interfaces exposed by the Algorithm Chaining Component * * @lld_start * * @lld_overview * This is the LAC Algorithm-Chaining feature component. This component * implements session registration and cleanup functions, and a perform * function. Statistics are maintained to track requests issued and completed, * errors incurred, and authentication verification failures. For each * function the parameters supplied by the client are checked, and then the * function proceeds if all the parameters are valid. This component also * incorporates support for Authenticated-Encryption (CCM and GCM) which * essentially comprises of a cipher operation and a hash operation combined. * * This component can combine a cipher operation with a hash operation or just * simply create a hash only or cipher only operation and is called from the * LAC Symmetric API component. In turn it calls the LAC Cipher, LAC Hash, and * LAC Symmetric QAT components. The goal here is to duplicate as little code * as possible from the Cipher and Hash components. * * The cipher and hash operations can be combined in either order, i.e. cipher * first then hash or hash first then cipher. The client specifies this via * the algChainOrder field in the session context. This ordering choice is * stored as part of the session descriptor, so that it is known when a * perform request is issued. In the case of Authenticated-Encryption, the * ordering is an implicit part of the CCM or GCM protocol. * * When building a content descriptor, as part of session registration, this * component asks the Cipher and Hash components to build their respective * parts of the session descriptor. The key aspect here is to provide the * correct offsets to the Cipher and Hash components for where in the content * descriptor to write their Config and Hardware Setup blocks. Also the * Config block in each case must specify the appropriate next slice. * * When building request parameters, as part of a perform operation, this * component asks the Cipher and Hash components to build their respective * parts of the request parameters block. Again the key aspect here is to * provide the correct offsets to the Cipher and Hash components for where in * the request parameters block to write their parameters. Also the request * parameters block in each case must specify the appropriate next slice. * * Parameter checking for session registration and for operation perform is * mostly delegated to the Cipher and Hash components. There are a few * extra checks that this component must perform: check the algChainOrder * parameter, ensure that CCM/GCM are specified for hash/cipher algorithms * as appropriate, and ensure that requests are for full packets (partial * packets are not supported for Algorithm-Chaining). * * The perform operation allocates a cookie to capture information required * in the request callback. This cookie is then freed in the callback. * * @lld_dependencies * - \ref LacCipher "Cipher" : For taking care of the cipher aspects of * session registration and operation perform * - \ref LacHash "Hash" : For taking care of the hash aspects of session * registration and operation perform * - \ref LacSymCommon "Symmetric Common" : statistics. * - \ref LacSymQat "Symmetric QAT": To build the QAT request message, * request param structure, and populate the content descriptor. Also * for registering a callback function to process the QAT response. * - \ref QatComms "QAT Comms" : For sending messages to the QAT, and for * setting the response callback * - \ref LacMem "Mem" : For memory allocation and freeing, virtual/physical * address translation, and translating between scalar and pointer types * - OSAL : For atomics and locking * * @lld_module_algorithms * This component builds up a chain of slices at session init time * and stores it in the session descriptor. This is used for building up the * content descriptor at session init time and the request parameters structure * in the perform operation. * * The offsets for the first slice are updated so that the second slice adds * its configuration information after that of the first slice. The first * slice also configures the next slice appropriately. * * This component is very much hard-coded to just support cipher+hash or * hash+cipher. It should be quite possible to extend this idea to support * an arbitrary chain of commands, by building up a command chain that can * be traversed in order to build up the appropriate configuration for the * QAT. This notion should be looked at in the future if other forms of * Algorithm-Chaining are desired. * * @lld_process_context * * @lld_end * *****************************************************************************/ /*****************************************************************************/ #ifndef LAC_SYM_ALG_CHAIN_H #define LAC_SYM_ALG_CHAIN_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "cpa_cy_sym.h" #include "lac_session.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ /* Macro for checking if zero length buffer are supported * only for cipher is AES-GCM and hash are AES-GCM/AES-GMAC */ #define IS_ZERO_LENGTH_BUFFER_SUPPORTED(cipherAlgo, hashAlgo) \ (CPA_CY_SYM_CIPHER_AES_GCM == cipherAlgo && \ (CPA_CY_SYM_HASH_AES_GMAC == hashAlgo || \ CPA_CY_SYM_HASH_AES_GCM == hashAlgo)) /** ******************************************************************************* * @ingroup LacAlgChain * This function registers a session for an Algorithm-Chaining operation. * * @description * This function is called from the LAC session register API function for * Algorithm-Chaining operations. It validates all input parameters. If * an invalid parameter is passed, an error is returned to the calling * function. If all parameters are valid an Algorithm-Chaining session is * registered. * * @param[in] instanceHandle Instance Handle * * @param[in] pSessionCtx Pointer to session context which contains * parameters which are static for a given * cryptographic session such as operation type, * mechanisms, and keys for cipher and/or digest * operations. * @param[out] pSessionDesc Pointer to session descriptor * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * * @see cpaCySymInitSession() * *****************************************************************************/ CpaStatus LacAlgChain_SessionInit(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionCtx, lac_session_desc_t *pSessionDesc); /** ******************************************************************************* * @ingroup LacAlgChain * Data path function for the Algorithm-Chaining component * * @description * This function gets called from cpaCySymPerformOp() which is the * symmetric LAC API function. It is the data path function for the * Algorithm-Chaining component. It does the parameter checking on the * client supplied parameters and if the parameters are valid, the * operation is performed and a request sent to the QAT, otherwise an * error is returned to the client. * * @param[in] instanceHandle Instance Handle * * @param[in] pSessionDesc Pointer to session descriptor * @param[in] pCallbackTag The application's context for this call * @param[in] pOpData Pointer to a structure containing request * parameters. The client code allocates the memory for * this structure. This component takes ownership of * the memory until it is returned in the callback. * * @param[in] pSrcBuffer Source Buffer List * @param[out] pDstBuffer Destination Buffer List * @param[out] pVerifyResult Verify Result * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resource. * * @see cpaCySymPerformOp() * *****************************************************************************/ CpaStatus LacAlgChain_Perform(const CpaInstanceHandle instanceHandle, lac_session_desc_t *pSessionDesc, void *pCallbackTag, const CpaCySymOpData *pOpData, const CpaBufferList *pSrcBuffer, CpaBufferList *pDstBuffer, CpaBoolean *pVerifyResult); /** ******************************************************************************* * @ingroup LacAlgChain * This function is used to update cipher key, as specified in provided * input. * * @description * This function is called from the LAC session register API function for * Algorithm-Chaining operations. It validates all input parameters. If * an invalid parameter is passed, an error is returned to the calling * function. If all parameters are valid an Algorithm-Chaining session is * updated. * * @threadSafe * No * * @param[in] pSessionDesc Pointer to session descriptor * @param[in] pCipherKey Pointer to new cipher key. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * *****************************************************************************/ CpaStatus LacAlgChain_SessionCipherKeyUpdate(lac_session_desc_t *pSessionDesc, Cpa8U *pCipherKey); /** ******************************************************************************* * @ingroup LacAlgChain * This function is used to update authentication key, as specified in * provided input. * * @description * This function is called from the LAC session register API function for * Algorithm-Chaining operations. It validates all input parameters. If * an invalid parameter is passed, an error is returned to the calling * function. If all parameters are valid an Algorithm-Chaining session is * updated. * * @threadSafe * No * * @param[in] pSessionDesc Pointer to session descriptor * @param[in] pCipherKey Pointer to new authentication key. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * *****************************************************************************/ CpaStatus LacAlgChain_SessionAuthKeyUpdate(lac_session_desc_t *pSessionDesc, Cpa8U *pAuthKey); /** ******************************************************************************* * @ingroup LacAlgChain * This function is used to update AAD length as specified in provided * input. * * @description * This function is called from the LAC session register API function for * Algorithm-Chaining operations. It validates all input parameters. If * an invalid parameter is passed, an error is returned to the calling * function. If all parameters are valid an Algorithm-Chaining session is * updated. * * @threadSafe * No * * @param[in] pSessionDesc Pointer to session descriptor * @param[in] newAADLength New AAD length. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * *****************************************************************************/ CpaStatus LacAlgChain_SessionAADUpdate(lac_session_desc_t *pSessionDesc, Cpa32U newAADLength); #endif /* LAC_SYM_ALG_CHAIN_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cb.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cb.h index 58caa321c410..703fa92b614a 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cb.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cb.h @@ -1,54 +1,54 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_cb.h * * @defgroup LacSymCb Symmetric callback functions * * @ingroup LacSym * * Functions to assist with callback processing for the symmetric component ***************************************************************************/ #ifndef LAC_SYM_CB_H #define LAC_SYM_CB_H /** ***************************************************************************** * @ingroup LacSym * Dequeue pending requests * @description * This function is called by a callback function of a blocking - * operation (either a partial packet or a hash precompute operaion) + * operation (either a partial packet or a hash precompute operation) * in softIRQ context. It dequeues requests for the following reasons: * 1. All pre-computes that happened when initialising a session * have completed. Dequeue any requests that were queued on the * session while waiting for the precompute operations to complete. * 2. A partial packet request has completed. Dequeue any partials * that were queued for this session while waiting for a previous * partial to complete. * * @param[in] pSessionDesc Pointer to the session descriptor * * @return CpaStatus * ****************************************************************************/ CpaStatus LacSymCb_PendingReqsDequeue(lac_session_desc_t *pSessionDesc); /** ***************************************************************************** * @ingroup LacSym - * Register symmetric callback funcion handlers + * Register symmetric callback function handlers * * @description * This function registers the symmetric callback handler functions with * the main symmetric callback handler function * * @return None * ****************************************************************************/ void LacSymCb_CallbacksRegister(void); #endif /* LAC_SYM_CB_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cipher.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cipher.h index 3ae237939b2c..c3d8203dd8b0 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cipher.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_cipher.h @@ -1,331 +1,331 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_cipher.h * * @defgroup LacCipher Cipher * * @ingroup LacSym * * API functions of the cipher component * * @lld_start * @lld_overview * There is a single \ref icp_LacSym "Symmetric LAC API" for hash, cipher, * auth encryption and algorithm chaining. This API is implemented by the * \ref LacSym "Symmetric" module. It demultiplexes calls to this API into * their basic operation and does some common parameter checking and deals * with accesses to the session table. * * The cipher component supports data encryption/decryption using the AES, DES, * and Triple-DES cipher algorithms, in ECB, CBC and CTR modes. The ARC4 stream * cipher algorithm is also supported. Data may be provided as a full packet, * or as a sequence of partial packets. The result of the operation can be - * written back to the source buffer (in-place) or to a seperate output buffer + * written back to the source buffer (in-place) or to a separate output buffer * (out-of-place). Data must be encapsulated in ICP buffers. * * The cipher component is responsible for implementing the cipher-specific * functionality for registering and de-registering a session, for the perform * operation and for processing the QAT responses to cipher requests. Statistics * are maintained for cipher in the symmetric \ref CpaCySymStats64 "stats" - * structure. This module has been seperated out into two. The cipher QAT module + * structure. This module has been separated out into two. The cipher QAT module * deals entirely with QAT data structures. The cipher module itself has minimal * exposure to the QAT data structures. * * @lld_dependencies * - \ref LacCommon * - \ref LacSymQat "Symmetric QAT": Hash uses the lookup table provided by * this module to validate user input. Hash also uses this module to build * the hash QAT request message, request param structure, populate the * content descriptor, allocate and populate the hash state prefix buffer. * Hash also registers its function to process the QAT response with this * module. * - OSAL : For memory functions, atomics and locking * * @lld_module_algorithms * In general, all the cipher algorithms supported by this component are * implemented entirely by the QAT. However, in the case of the ARC4 algorithm, * it was deemed more efficient to carry out some processing on IA. During * session registration, an initial state is derived from the base key provided * by the user, using a simple ARC4 Key Scheduling Algorithm (KSA). Then the * base key is discarded, but the state is maintained for the duration of the * session. * * The ARC4 key scheduling algorithm (KSA) is specified as follows * (taken from http://en.wikipedia.org/wiki/RC4_(cipher)): * \code * for i from 0 to 255 * S[i] := i * endfor * j := 0 * for i from 0 to 255 * j := (j + S[i] + key[i mod keylength]) mod 256 * swap(S[i],S[j]) * endfor * \endcode * * On registration of a new ARC4 session, the user provides a base key of any * length from 1 to 256 bytes. This algorithm produces the initial ARC4 state * (key matrix + i & j index values) from that base key. This ARC4 state is * used as input for each ARC4 cipher operation in that session, and is updated * by the QAT after each operation. The ARC4 state is stored in a session * descriptor, and it's memory is freed when the session is deregistered. * * Block Vs. Stream Ciphers\n * Block ciphers are treated slightly differently than Stream ciphers by this * cipher component. Supported stream ciphers consist of AES and * TripleDES algorithms in CTR mode, and ARC4. The 2 primary differences are: * - Data buffers for block ciphers are required to be a multiple of the * block size defined for the algorithm (e.g. 8 bytes for DES). For stream * ciphers, there is no such restriction. * - For stream ciphers, decryption is performed by setting the QAT hardware * to encryption mode. * * Memory address alignment of data buffers \n * The QAT requires that most data buffers are aligned on an 8-byte memory * address boundary (64-byte boundary for optimum performance). For Cipher, * this applies to the cipher key buffer passed in the Content Descriptor, * and the IV/State buffer passed in the Request Parameters block in each * request. Both of these buffers are provided by the user. It does not * apply to the cipher source/destination data buffers. * Alignment of the key buffer is ensured because the key is always copied * from the user provided buffer into a new (aligned) buffer for the QAT * (the hardware setup block, which configures the QAT slice). This is done * once only during session registration, and the user's key buffer can be * effectively discarded after that. * The IV/State buffer is provided per-request by the user, so it is recommended * to the user to provide aligned buffers for optimal performance. In the case * where an unaligned buffer is provided, a new temporary buffer is allocated * and the user's IV/State data is copied into this buffer. The aligned buffer * is then passed to the QAT in the request. In the response callback, if the * IV was updated by the QAT, the contents are copied back to the user's buffer * and the temporary buffer is freed. * * @lld_process_context * * Session Register Sequence Diagram: For ARC4 cipher algorithm * \msc * APP [label="Application"], SYM [label="Symmetric LAC"], * Achain [label="Alg chain"], Cipher, SQAT [label="Symmetric QAT"]; * * APP=>SYM [ label = "cpaCySymInitSession(cbFunc)", * URL="\ref cpaCySymInitSession()"] ; * SYM=>SYM [ label = "LacSymSession_ParamCheck()", * URL="\ref LacSymSession_ParamCheck()"]; * SYM=>Achain [ label = "LacAlgChain_SessionInit()", * URL="\ref LacAlgChain_SessionInit()"]; * Achain=>Cipher [ label = "LacCipher_SessionSetupDataCheck()", * URL="\ref LacCipher_SessionSetupDataCheck()"]; * Achain<SQAT [ label = "LacSymQat_CipherContentDescPopulate()", * URL="\ref LacSymQat_CipherContentDescPopulate()"]; * Achain<SQAT [ label = "LacSymQat_CipherArc4StateInit()", * URL="\ref LacSymQat_CipherArc4StateInit()"]; * Achain<SYM [label = "LAC_SYM_STAT_INC", URL="\ref LAC_SYM_STAT_INC"]; * APP<SYM [ label = "cpaCySymPerformOp()", * URL="\ref cpaCySymPerformOp()"] ; * SYM=>SYM [ label = "LacSym_Perform()", * URL="\ref LacSym_Perform()"]; * SYM=>SYM [ label = "LacSymPerform_BufferParamCheck()", * URL="\ref LacSymPerform_BufferParamCheck()"]; * SYM<Achain [ label = "LacAlgChain_Perform()", * URL="\ref LacCipher()"]; * Achain=>Cipher [ label = "LacCipher_PerformParamCheck()", * URL="\ref LacCipher_PerformParamCheck()"]; * Achain<LMP [label="Lac_MemPoolEntryAlloc()", * URL="\ref Lac_MemPoolEntryAlloc()"]; * Achain<Cipher [ label = "LacCipher_PerformIvCheckAndAlign()", * URL="\ref LacCipher_PerformIvCheckAndAlign()"]; * Achain<SQAT [ label = "LacSymQat_CipherRequestParamsPopulate()", * URL="\ref LacSymQat_CipherRequestParamsPopulate()"]; * Achain<BUF [ label = "LacBuffDesc_BufferListDescWrite()", * URL = "\ref LacBuffDesc_BufferListDescWrite()"]; * Achain<SQAT [ label = "SalQatMsg_CmnMsgAndReqParamsPopulate()", * URL="\ref SalQatMsg_CmnMsgAndReqParamsPopulate()"]; * Achain<SYMQ [ label = "LacSymQueue_RequestSend()", * URL="\ref LacSymQueue_RequestSend()"]; * SYMQ=>QATCOMMS [ label = "QatComms_MsgSend()", * URL="\ref QatComms_MsgSend()"]; * SYMQ<SYM [ label = "LacSym_PartialPacketStateUpdate()", * URL="\ref LacSym_PartialPacketStateUpdate()"]; * SYM<SC [label = "LAC_SYM_STAT_INC", URL="\ref LAC_SYM_STAT_INC"]; * SYM<QATCOMMS [label ="QatComms_ResponseMsgHandler()", * URL="\ref QatComms_ResponseMsgHandler()"]; * QATCOMMS=>SQAT [label ="LacSymQat_SymRespHandler()", * URL="\ref LacSymQat_SymRespHandler()"]; * SQAT=>SYMCB [label="LacSymCb_ProcessCallback()", * URL="\ref LacSymCb_ProcessCallback()"]; * SYMCB=>SYMCB [label="LacSymCb_ProcessCallbackInternal()", * URL="\ref LacSymCb_ProcessCallbackInternal()"]; * SYMCB=>LMP [label="Lac_MemPoolEntryFree()", * URL="\ref Lac_MemPoolEntryFree()"]; * SYMCB<SC [label = "LAC_SYM_STAT_INC", URL="\ref LAC_SYM_STAT_INC"]; * SYMCB<APP [label="cbFunc"]; * SYMCB< - * - ***************************************************************************/ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_hash.h * * @defgroup LacHash Hash * * @ingroup LacSym * * API functions of the Hash component * * @lld_start * @lld_overview * There is a single \ref cpaCySym "Symmetric LAC API" for hash, cipher, * auth encryption and algorithm chaining. This API is implemented by the * \ref LacSym "Symmetric" module. It demultiplexes calls to this API into * their basic operation and does some common parameter checking and deals * with accesses to the session table. * * The hash component supports hashing in 3 modes. PLAIN, AUTH and NESTED. * Plain mode is used to provide data integrity while auth mode is used to - * provide integrity as well as its authenticity. Nested mode is inteded + * provide integrity as well as its authenticity. Nested mode is intended * for use by non standard HMAC like algorithms such as for the SSL master * key secret. Partial packets is supported for both plain and auth modes. * In-place and out-of-place processing is supported for all modes. The * verify operation is supported for PLAIN and AUTH modes only. * * The hash component is responsible for implementing the hash specific * functionality for initialising a session and for a perform operation. * Statistics are maintained in the symmetric \ref CpaCySymStats64 "stats" - * structure. This module has been seperated out into two. The hash QAT module + * structure. This module has been separated out into two. The hash QAT module * deals entirely with QAT data structures. The hash module itself has minimal * exposure to the QAT data structures. * * @lld_dependencies * - \ref LacCommon * - \ref LacSymQat "Symmetric QAT": Hash uses the lookup table provided by * this module to validate user input. Hash also uses this module to build * the hash QAT request message, request param structure, populate the * content descriptor, allocate and populate the hash state prefix buffer. * Hash also registers its function to process the QAT response with this * module. * - OSAL : For memory functions, atomics and locking * * @lld_module_algorithms * a. HMAC Precomputes\n * HMAC algorithm is specified as follows: * \f$ HMAC(msg) = hash((key \oplus opad) \parallel * hash((key \oplus ipad) \parallel msg ))\f$. * The key is fixed per session, and is padded up to the block size of the * algorithm if necessary and xored with the ipad/opad. The following portion * of the operation can be precomputed: \f$ hash(key \oplus ipad) \f$ as the * output of this intermediate hash will be the same for every perform * operation. This intermediate state is the intermediate state of a partial * partial packet. It is used as the initialiser state to \f$ hash(msg) \f$. * The same applies to \f$ hash(key \oplus ipad) \f$. There is a saving in * the data path by the length of time it takes to do two hashes on a block * size of data. Note: a partial packet operation generates an intermediate * state. The final operation on a partial packet or when a full packet is - * used applies padding and gives the final hash result. Esentially for the + * used applies padding and gives the final hash result. Essentially for the * inner hash, a partial packet final is issued on the data, using the * precomputed intermediate state and returns the digest. * * For the HMAC precomputes, \ref LacSymHash_HmacPreCompute(), there are two * hash operations done using a internal content descriptor to configure the * QAT. A first partial packet is specified as the packet type for the * pre-computes as we need the state that uses the initialiser constants * specific to the algorithm. The resulting output is copied from the hash * state prefix buffer into the QAT content descriptor for the session being * initialised. The state is used each perform operation as the initialiser * to the algorithm * * b. AES XCBC Precomputes\n * A similar technique to HMAC will be used to generate the precomputes for * AES XCBC. In this case a cipher operation will be used to generate the * precomputed result. The Pre-compute operation involves deriving 3 128-bit * keys (K1, K2 and K3) from the 128-bit secret key K. * * - K1 = 0x01010101010101010101010101010101 encrypted with Key K * - K2 = 0x02020202020202020202020202020202 encrypted with Key K * - K3 = 0x03030303030303030303030303030303 encrypted with Key K * * A content descriptor is created with the cipher algorithm set to AES * in ECB mode and with the keysize set to 128 bits. The 3 constants, 16 bytes * each, are copied into the src buffer and an in-place cipher operation is * performed on the 48 bytes. ECB mode does not maintain the state, therefore * the 3 keys can be encrypted in one perform. The encrypted result is used by * the state2 field in the hash setup block of the content descriptor. * * The precompute operations use a different lac command ID and thus have a * different route in the response path to the symmetric code. In this * precompute callback function the output of the precompute operation is * copied into the content descriptor for the session being registered. * * c. AES CCM Precomputes\n * The precomputes for AES CCM are trivial, i.e. there is no need to perform * a cipher or a digest operation. Instead, the key is stored directly in * the state2 field. * * d. AES GCM Precomputes\n * As with AES XCBC precomputes, a cipher operation will be used to generate * the precomputed result for AES GCM. In this case the Galois Hash * Multiplier (H) must be derived and stored in the state2 field. H is * derived by encrypting a 16-byte block of zeroes with the * cipher/authentication key, using AES in ECB mode. * * Key size for Auth algorithms\n * Min Size\n * RFC 2104 states "The key for HMAC can be of any length. However, less than * L bytes is strongly discouraged as it would decrease the security strength * of the function." * * FIPS 198a states "The size of the key, K, shall be equal to or greater than * L/2, where L is the size of the hash function output." * * RFC 4434 states "If the key has fewer than 128 bits, lengthen it to exactly * 128 bits by padding it on the right with zero bits. * * A key length of 0 upwards is accepted. It is up to the client to pass in a * key that complies with the standard they wish to support. * * Max Size\n * RFC 2104 section 2 states : "Applications that use keys longer than B bytes * will first hash the key using H and then use the resultant L byte string * as the actual key to HMAC * * RFC 4434 section 2 states: * "If the key is 129 bits or longer, shorten it to exactly 128 bits * by performing the steps in AES-XCBC-PRF-128 (that is, the * algorithm described in this document). In that re-application of * this algorithm, the key is 128 zero bits; the message is the * too-long current key." * * We push this up to the client. They need to do the hash operation through * the LAC API if the key is greater than the block size of the algorithm. This * will reduce the key size to the digest size of the algorithm. * * RFC 3566 section 4 states: * AES-XCBC-MAC-96 is a secret key algorithm. For use with either ESP or * AH a fixed key length of 128-bits MUST be supported. Key lengths * other than 128-bits MUST NOT be supported (i.e., only 128-bit keys are * to be used by AES-XCBC-MAC-96). * * In this case it is up to the client to provide a key that complies with * the standards. i.e. exactly 128 bits in size. * * * HMAC-MD5-96 and HMAC-SHA1-96\n * HMAC-MD5-96 and HMAC-SHA1-96 are defined as requirements by Look Aside * IPsec. The differences between HMAC-SHA1 and HMAC-SHA1-96 are that the * digest produced is truncated and there are strict requirements on the * size of the key that is used. * * They are supported in LAC by HMAC-MD5 and HMAC-SHA1. The field * \ref CpaCySymHashSetupData::digestResultLenInBytes in the LAC API in * bytes needs to be set to 12 bytes. There are also requirements regarding * the keysize. It is up to the client to ensure the key size meets the * requirements of the standards they are using. * * RFC 2403: HMAC-MD5-96 Key lengths other than 128-bits MUST NOT be supported. * HMAC-MD5-96 produces a 128-bit authenticator value. For use with either * ESP or AH, a truncated value using the first 96 bits MUST be supported. * * RFC2404: HMAC-SHA1-96 Key lengths other than 160- bits MUST NOT be supported * HMAC-SHA-1-96 produces a 160-bit authenticator value. For use with either * ESP or AH, a truncated value using the first 96 bits MUST be supported. * * Out of place operations * When verify is disabled, the digest will be written to the destination * buffer. When verify is enabled, the digest calculated is compared to the * digest stored in the source buffer. * * Partial Packets * Partial packets are handled in the \ref LacSym "Symmetric" component for * the request. The hash callback function handles the update of the state * in the callback. * * * @lld_process_context * * Session Register Sequence Diagram: For hash modes plain and nested. * \msc * APP [label="Application"], SYM [label="Symmetric LAC"], * Achain [label="Alg chain"], Hash, SQAT [label="Symmetric QAT"]; * * APP=>SYM [ label = "cpaCySymInitSession(cbFunc)", * URL="\ref cpaCySymInitSession()"] ; * SYM=>SYM [ label = "LacSymSession_ParamCheck()", * URL="\ref LacSymSession_ParamCheck()"]; * SYM=>Achain [ label = "LacAlgChain_SessionInit()", * URL="\ref LacAlgChain_SessionInit()"]; * Achain=>Hash [ label = "LacHash_HashContextCheck()", * URL="\ref LacHash_HashContextCheck()"]; * Achain<SQAT [ label = "LacSymQat_HashContentDescInit()", * URL="\ref LacSymQat_HashContentDescInit()"]; * Achain<Hash [ label = "LacHash_StatePrefixAadBufferInit()", * URL="\ref LacHash_StatePrefixAadBufferInit()"]; * Hash=>SQAT [ label = "LacSymQat_HashStatePrefixAadBufferSizeGet()", * URL="\ref LacSymQat_HashStatePrefixAadBufferSizeGet()"]; * Hash<SQAT [ label = "LacSymQat_HashStatePrefixAadBufferPopulate()", * URL="\ref LacSymQat_HashStatePrefixAadBufferPopulate()"]; * Hash<SYM [label = "LAC_SYM_STAT_INC", URL="\ref LAC_SYM_STAT_INC"]; * APP<SYM [ label = "cpaCySymPerformOp()", * URL="\ref cpaCySymPerformOp()"] ; * SYM=>SYM [ label = "LacSymPerform_BufferParamCheck()", * URL="\ref LacSymPerform_BufferParamCheck()"]; * SYM=>Achain [ label = "LacAlgChain_Perform()", * URL="\ref LacAlgChain_Perform()"]; * Achain=>Achain [ label = "Lac_MemPoolEntryAlloc()", * URL="\ref Lac_MemPoolEntryAlloc()"]; * Achain=>SQAT [ label = "LacSymQat_packetTypeGet()", * URL="\ref LacSymQat_packetTypeGet()"]; * Achain<Achain [ label = "LacBuffDesc_BufferListTotalSizeGet()", * URL="\ref LacBuffDesc_BufferListTotalSizeGet()"]; * Achain=>Hash [ label = "LacHash_PerformParamCheck()", * URL = "\ref LacHash_PerformParamCheck()"]; * Achain<SQAT [ label = "LacSymQat_HashRequestParamsPopulate()", * URL="\ref LacSymQat_HashRequestParamsPopulate()"]; * Achain<Achain [ label = "LacBuffDesc_BufferListDescWrite()", * URL="\ref LacBuffDesc_BufferListDescWrite()"]; * Achain=>SQAT [ label = "SalQatMsg_CmnMsgAndReqParamsPopulate()", * URL="\ref SalQatMsg_CmnMsgAndReqParamsPopulate()"]; * Achain<SYM [ label = "LacSymQueue_RequestSend()", * URL="\ref LacSymQueue_RequestSend()"]; * SYM=>QATCOMMS [ label = "QatComms_MsgSend()", * URL="\ref QatComms_MsgSend()"]; * SYM<SYM [label = "LAC_SYM_STAT_INC", URL="\ref LAC_SYM_STAT_INC"]; * APP<QATCOMMS [label ="QatComms_ResponseMsgHandler()", * URL="\ref QatComms_ResponseMsgHandler()"]; * QATCOMMS=>SQAT [label ="LacSymQat_SymRespHandler()", * URL="\ref LacSymQat_SymRespHandler()"]; * SQAT=>SYM [label="LacSymCb_ProcessCallback()", * URL="\ref LacSymCb_ProcessCallback()"]; * SYM=>SYM [label = "LacSymCb_ProcessCallbackInternal()", * URL="\ref LacSymCb_ProcessCallbackInternal()"]; * SYM=>SYM [label = "Lac_MemPoolEntryFree()", * URL="\ref Lac_MemPoolEntryFree()"]; * SYM=>SYM [label = "LAC_SYM_STAT_INC", URL="\ref LAC_SYM_STAT_INC"]; * SYM=>APP [label="cbFunc"]; * APP>>SYM [label="return"]; * SYM>>SQAT [label="return"]; * SQAT>>QATCOMMS [label="return"]; * \endmsc * * @lld_end * *****************************************************************************/ /*****************************************************************************/ #ifndef LAC_SYM_HASH_H #define LAC_SYM_HASH_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "cpa_cy_sym.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_session.h" #include "lac_buffer_desc.h" /** ***************************************************************************** * @ingroup LacHash * Definition of callback function. * * @description * This is the callback function prototype. The callback function is * invoked when a hash precompute operation completes. * * @param[in] pCallbackTag Opaque value provided by user while making * individual function call. * * @retval * None *****************************************************************************/ typedef void (*lac_hash_precompute_done_cb_t)(void *pCallbackTag); /* * WARNING: There are no checks done on the parameters of the functions in * this file. The expected values of the parameters are documented and it is * up to the caller to provide valid values. */ /** ******************************************************************************* * @ingroup LacHash * validate the hash context * * @description * The client populates the hash context in the session context structure * This is passed as parameter to the session register API function and * needs to be validated. * * @param[in] pHashSetupData pointer to hash context structure * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_INVALID_PARAM Invalid parameter * *****************************************************************************/ CpaStatus LacHash_HashContextCheck(CpaInstanceHandle instanceHandle, const CpaCySymHashSetupData *pHashSetupData); /** ****************************************************************************** * @ingroup LacHash * Populate the hash pre-compute data. * * @description * This function populates the state1 and state2 fields with the hash * pre-computes. This is only done for authentication. The state1 * and state2 pointers must be set to point to the correct locations * in the content descriptor where the precompute result(s) will be * written, before this function is called. * * @param[in] instanceHandle Instance Handle * @param[in] pSessionSetup pointer to session setup data * @param[in] callbackFn Callback function which is invoked when * the precompute operation is completed * @param[in] pCallbackTag Opaque data which is passed back to the user * as a parameter in the callback function * @param[out] pWorkingBuffer Pointer to working buffer, sufficient memory * must be allocated by the caller for this. * Assumption that this is 8 byte aligned. * @param[out] pState1 pointer to State 1 in content descriptor * @param[out] pState2 pointer to State 2 in content descriptor * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_RETRY Retry the operation. * @retval CPA_STATUS_RESOURCE Error Allocating memory * @retval CPA_STATUS_FAIL Operation Failed * *****************************************************************************/ CpaStatus LacHash_PrecomputeDataCreate(const CpaInstanceHandle instanceHandle, CpaCySymSessionSetupData *pSessionSetup, lac_hash_precompute_done_cb_t callbackFn, void *pCallbackTag, Cpa8U *pWorkingBuffer, Cpa8U *pState1, Cpa8U *pState2); /** ****************************************************************************** * @ingroup LacHash * populate the hash state prefix aad buffer. * * @description * This function populates the hash state prefix aad buffer. This function * is not called for CCM/GCM operations as the AAD data varies per request * and is stored in the cookie as opposed to the session descriptor. * * @param[in] pHashSetupData pointer to hash setup structure * @param[in] pHashControlBlock pointer to hash control block * @param[in] qatHashMode QAT Mode for hash * @param[in] pHashStateBuffer pointer to hash state prefix aad buffer * @param[in] pHashStateBufferInfo Pointer to hash state prefix buffer info * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_FAIL Operation Failed * *****************************************************************************/ CpaStatus LacHash_StatePrefixAadBufferInit( sal_service_t *pService, const CpaCySymHashSetupData *pHashSetupData, icp_qat_la_bulk_req_ftr_t *pHashControlBlock, icp_qat_hw_auth_mode_t qatHashMode, Cpa8U *pHashStateBuffer, lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo); /** ******************************************************************************* * @ingroup LacHash * Check parameters for a hash perform operation * * @description * This function checks the parameters for a hash perform operation. * * @param[in] pSessionDesc Pointer to session descriptor. * @param[in] pOpData Pointer to request parameters. * @param[in] srcPktSize Total size of the Buffer List * @param[in] pVerifyResult Pointer to user flag * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_INVALID_PARAM Invalid Parameter * *****************************************************************************/ CpaStatus LacHash_PerformParamCheck(CpaInstanceHandle instanceHandle, lac_session_desc_t *pSessionDesc, const CpaCySymOpData *pOpData, Cpa64U srcPktSize, const CpaBoolean *pVerifyResult); /** ******************************************************************************* * @ingroup LacHash * Perform hash precompute operation for HMAC * * @description * This function sends 2 requests to the CPM for the hmac precompute * operations. The results of the ipad and opad state calculation * is copied into pState1 and pState2 (e.g. these may be the state1 and * state2 buffers in a hash content descriptor) and when * the final operation has completed the condition passed as a param to * this function is set to true. * * This function performs the XORing of the IPAD and OPAD constants to * the key (which was padded to the block size of the algorithm) * * @param[in] instanceHandle Instance Handle * @param[in] hashAlgorithm Hash Algorithm * @param[in] authKeyLenInBytes Length of Auth Key * @param[in] pAuthKey Pointer to Auth Key * @param[out] pWorkingMemory Pointer to working memory that is carved * up and used in the pre-compute operations. * Assumption that this is 8 byte aligned. * @param[out] pState1 Pointer to State 1 in content descriptor * @param[out] pState2 Pointer to State 2 in content descriptor * @param[in] callbackFn Callback function which is invoked when * the precompute operation is completed * @param[in] pCallbackTag Opaque data which is passed back to the user * as a parameter in the callback function * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_RETRY Retry the operation. * @retval CPA_STATUS_FAIL Operation Failed * *****************************************************************************/ CpaStatus LacSymHash_HmacPreComputes(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, Cpa32U authKeyLenInBytes, Cpa8U *pAuthKey, Cpa8U *pWorkingMemory, Cpa8U *pState1, Cpa8U *pState2, lac_hash_precompute_done_cb_t callbackFn, void *pCallbackTag); /** ******************************************************************************* * @ingroup LacHash * Perform hash precompute operation for XCBC MAC and GCM * * @description * This function sends 1 request to the CPM for the precompute operation * based on an AES ECB cipher. The results of the calculation is copied * into pState (this may be a pointer to the State 2 buffer in a Hash * content descriptor) and when the operation has completed the condition * passed as a param to this function is set to true. * * @param[in] instanceHandle Instance Handle * @param[in] hashAlgorithm Hash Algorithm * @param[in] authKeyLenInBytes Length of Auth Key * @param[in] pAuthKey Auth Key * @param[out] pWorkingMemory Pointer to working memory that is carved * up and used in the pre-compute operations. * Assumption that this is 8 byte aligned. * @param[out] pState Pointer to output state * @param[in] callbackFn Callback function which is invoked when * the precompute operation is completed * @param[in] pCallbackTag Opaque data which is passed back to the user * as a parameter in the callback function * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_RETRY Retry the operation. * @retval CPA_STATUS_FAIL Operation Failed * *****************************************************************************/ CpaStatus LacSymHash_AesECBPreCompute(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, Cpa32U authKeyLenInBytes, Cpa8U *pAuthKey, Cpa8U *pWorkingMemory, Cpa8U *pState, lac_hash_precompute_done_cb_t callbackFn, void *pCallbackTag); /** ******************************************************************************* * @ingroup LacHash * initialise data structures for the hash precompute operations * * @description * This function registers the precompute callback handler function, which * is different to the default one used by symmetric. Content descriptors * are preallocted for the hmac precomputes as they are constant for these * operations. * * @retval CPA_STATUS_SUCCESS Success * @retval CPA_STATUS_RESOURCE Error allocating memory * *****************************************************************************/ CpaStatus LacSymHash_HmacPrecompInit(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHash * free resources allocated for the precompute operations * * @description * free up the memory allocated on init time for the content descriptors * that were allocated for the HMAC precompute operations. * * @return none * *****************************************************************************/ void LacSymHash_HmacPrecompShutdown(CpaInstanceHandle instanceHandle); void LacSync_GenBufListVerifyCb(void *pCallbackTag, CpaStatus status, CpaCySymOp operationType, void *pOpData, CpaBufferList *pDstBuffer, CpaBoolean opResult); #endif /* LAC_SYM_HASH_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_defs.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_defs.h index 6ebdcf659360..de9e74b31577 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_defs.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_defs.h @@ -1,334 +1,334 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_hash_defs.h * * @defgroup LacHashDefs Hash Definitions * * @ingroup LacHash * * Constants for hash algorithms * ***************************************************************************/ #ifndef LAC_SYM_HASH_DEFS_H #define LAC_SYM_HASH_DEFS_H /* Constant for MD5 algorithm */ #define LAC_HASH_MD5_BLOCK_SIZE 64 /**< @ingroup LacHashDefs * MD5 block size in bytes */ #define LAC_HASH_MD5_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * MD5 digest length in bytes */ #define LAC_HASH_MD5_STATE_SIZE 16 /**< @ingroup LacHashDefs * MD5 state size */ /* Constants for SHA1 algorithm */ #define LAC_HASH_SHA1_BLOCK_SIZE 64 /**< @ingroup LacHashDefs * SHA1 Block size in bytes */ #define LAC_HASH_SHA1_DIGEST_SIZE 20 /**< @ingroup LacHashDefs * SHA1 digest length in bytes */ #define LAC_HASH_SHA1_STATE_SIZE 20 /**< @ingroup LacHashDefs * SHA1 state size */ /* Constants for SHA224 algorithm */ #define LAC_HASH_SHA224_BLOCK_SIZE 64 /**< @ingroup LacHashDefs * SHA224 block size in bytes */ #define LAC_HASH_SHA224_DIGEST_SIZE 28 /**< @ingroup LacHashDefs * SHA224 digest length in bytes */ #define LAC_HASH_SHA224_STATE_SIZE 32 /**< @ingroup LacHashDefs * SHA224 state size */ /* Constants for SHA256 algorithm */ #define LAC_HASH_SHA256_BLOCK_SIZE 64 /**< @ingroup LacHashDefs * SHA256 block size in bytes */ #define LAC_HASH_SHA256_DIGEST_SIZE 32 /**< @ingroup LacHashDefs * SHA256 digest length */ #define LAC_HASH_SHA256_STATE_SIZE 32 /**< @ingroup LacHashDefs * SHA256 state size */ /* Constants for SHA384 algorithm */ #define LAC_HASH_SHA384_BLOCK_SIZE 128 /**< @ingroup LacHashDefs * SHA384 block size in bytes */ #define LAC_HASH_SHA384_DIGEST_SIZE 48 /**< @ingroup LacHashDefs * SHA384 digest length in bytes */ #define LAC_HASH_SHA384_STATE_SIZE 64 /**< @ingroup LacHashDefs * SHA384 state size */ /* Constants for SHA512 algorithm */ #define LAC_HASH_SHA512_BLOCK_SIZE 128 /**< @ingroup LacHashDefs * SHA512 block size in bytes */ #define LAC_HASH_SHA512_DIGEST_SIZE 64 /**< @ingroup LacHashDefs * SHA512 digest length in bytes */ #define LAC_HASH_SHA512_STATE_SIZE 64 /**< @ingroup LacHashDefs * SHA512 state size */ /* Constants for SHA3_224 algorithm */ #define LAC_HASH_SHA3_224_BLOCK_SIZE 144 /**< @ingroup LacHashDefs * SHA3_224 block size in bytes */ #define LAC_HASH_SHA3_224_DIGEST_SIZE 28 /**< @ingroup LacHashDefs * SHA3_224 digest length in bytes */ #define LAC_HASH_SHA3_224_STATE_SIZE 28 /**< @ingroup LacHashDefs * SHA3_224 state size */ /* Constants for SHA3_256 algorithm */ #define LAC_HASH_SHA3_256_BLOCK_SIZE 136 /**< @ingroup LacHashDefs * SHA3_256 block size in bytes */ #define LAC_HASH_SHA3_256_DIGEST_SIZE 32 /**< @ingroup LacHashDefs * SHA3_256 digest length in bytes */ #define LAC_HASH_SHA3_256_STATE_SIZE 32 /**< @ingroup LacHashDefs * SHA3_256 state size */ /* Constants for SHA3_384 algorithm */ #define LAC_HASH_SHA3_384_BLOCK_SIZE 104 /**< @ingroup LacHashDefs * SHA3_384 block size in bytes */ #define LAC_HASH_SHA3_384_DIGEST_SIZE 48 /**< @ingroup LacHashDefs * SHA3_384 digest length in bytes */ #define LAC_HASH_SHA3_384_STATE_SIZE 48 /**< @ingroup LacHashDefs * SHA3_384 state size */ /* Constants for SHA3_512 algorithm */ #define LAC_HASH_SHA3_512_BLOCK_SIZE 72 /**< @ingroup LacHashDefs * SHA3_512 block size in bytes */ #define LAC_HASH_SHA3_512_DIGEST_SIZE 64 /**< @ingroup LacHashDefs * SHA3_512 digest length in bytes */ #define LAC_HASH_SHA3_512_STATE_SIZE 64 /**< @ingroup LacHashDefs * SHA3_512 state size */ #define LAC_HASH_SHA3_STATEFUL_STATE_SIZE 200 /* Constants for SM3 algorithm */ #define LAC_HASH_SM3_BLOCK_SIZE 64 /**< @ingroup LacHashDefs * SM3 block size in bytes */ #define LAC_HASH_SM3_DIGEST_SIZE 32 /**< @ingroup LacHashDefs * SM3 digest length */ #define LAC_HASH_SM3_STATE_SIZE 32 /**< @ingroup LacHashDefs * SM3 state size */ /* Constants for POLY algorithm */ #define LAC_HASH_POLY_BLOCK_SIZE 64 /**< @ingroup LacHashDefs * POLY block size in bytes */ #define LAC_HASH_POLY_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * POLY digest length */ #define LAC_HASH_POLY_STATE_SIZE 0 /**< @ingroup LacHashDefs * POLY state size */ /* Constants for XCBC precompute algorithm */ #define LAC_HASH_XCBC_PRECOMP_KEY_NUM 3 /**< @ingroup LacHashDefs * The Pre-compute operation involves deriving 3 128-bit * keys (K1, K2 and K3) */ /* Constants for XCBC MAC algorithm */ #define LAC_HASH_XCBC_MAC_BLOCK_SIZE 16 /**< @ingroup LacHashDefs * XCBC_MAC block size in bytes */ #define LAC_HASH_XCBC_MAC_128_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * XCBC_MAC_PRF_128 digest length in bytes */ /* Constants for AES CMAC algorithm */ #define LAC_HASH_CMAC_BLOCK_SIZE 16 /**< @ingroup LacHashDefs * AES CMAC block size in bytes */ #define LAC_HASH_CMAC_128_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * AES CMAC digest length in bytes */ /* constants for AES CCM */ #define LAC_HASH_AES_CCM_BLOCK_SIZE 16 /**< @ingroup LacHashDefs * block size for CBC-MAC part of CCM */ #define LAC_HASH_AES_CCM_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * untruncated size of authentication field */ /* constants for AES GCM */ #define LAC_HASH_AES_GCM_BLOCK_SIZE 16 /**< @ingroup LacHashDefs * block size for Galois Hash 128 part of CCM */ #define LAC_HASH_AES_GCM_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * untruncated size of authentication field */ /* constants for KASUMI F9 */ #define LAC_HASH_KASUMI_F9_BLOCK_SIZE 8 /**< @ingroup LacHashDefs * KASUMI_F9 block size in bytes */ #define LAC_HASH_KASUMI_F9_DIGEST_SIZE 4 /**< @ingroup LacHashDefs * KASUMI_F9 digest size in bytes */ /* constants for SNOW3G UIA2 */ #define LAC_HASH_SNOW3G_UIA2_BLOCK_SIZE 8 /**< @ingroup LacHashDefs * SNOW3G UIA2 block size in bytes */ #define LAC_HASH_SNOW3G_UIA2_DIGEST_SIZE 4 /**< @ingroup LacHashDefs * SNOW3G UIA2 digest size in bytes */ /* constants for AES CBC MAC */ #define LAC_HASH_AES_CBC_MAC_BLOCK_SIZE 16 /**< @ingroup LacHashDefs * AES CBC MAC block size in bytes */ #define LAC_HASH_AES_CBC_MAC_DIGEST_SIZE 16 /**< @ingroup LacHashDefs * AES CBC MAC digest size in bytes */ #define LAC_HASH_ZUC_EIA3_BLOCK_SIZE 4 /**< @ingroup LacHashDefs * ZUC EIA3 block size in bytes */ #define LAC_HASH_ZUC_EIA3_DIGEST_SIZE 4 /**< @ingroup LacHashDefs * ZUC EIA3 digest size in bytes */ /* constants for AES GCM ICV allowed sizes */ #define LAC_HASH_AES_GCM_ICV_SIZE_8 8 #define LAC_HASH_AES_GCM_ICV_SIZE_12 12 #define LAC_HASH_AES_GCM_ICV_SIZE_16 16 /* constants for AES CCM ICV allowed sizes */ #define LAC_HASH_AES_CCM_ICV_SIZE_MIN 4 #define LAC_HASH_AES_CCM_ICV_SIZE_MAX 16 /* constants for authentication algorithms */ #define LAC_HASH_IPAD_BYTE 0x36 /**< @ingroup LacHashDefs * Ipad Byte */ #define LAC_HASH_OPAD_BYTE 0x5c /**< @ingroup LacHashDefs * Opad Byte */ #define LAC_HASH_IPAD_4_BYTES 0x36363636 /**< @ingroup LacHashDefs * Ipad for 4 Bytes */ #define LAC_HASH_OPAD_4_BYTES 0x5c5c5c5c /**< @ingroup LacHashDefs * Opad for 4 Bytes */ /* Key Modifier (KM) value used in Kasumi algorithm in F9 mode to XOR * Integrity Key (IK) */ #define LAC_HASH_KASUMI_F9_KEY_MODIFIER_4_BYTES 0xAAAAAAAA /**< @ingroup LacHashDefs * Kasumi F9 Key Modifier for 4 bytes */ #define LAC_SYM_QAT_HASH_IV_REQ_MAX_SIZE_QW 2 /**< @ingroup LacSymQatHash * Maximum size of IV embedded in the request. * This is set to 2, namely 4 LONGWORDS. */ #define LAC_SYM_QAT_HASH_STATE1_MAX_SIZE_BYTES LAC_HASH_SHA512_BLOCK_SIZE /**< @ingroup LacSymQatHash * Maximum size of state1 in the hash setup block of the content descriptor. * This is set to the block size of SHA512. */ #define LAC_SYM_QAT_HASH_STATE2_MAX_SIZE_BYTES LAC_HASH_SHA512_BLOCK_SIZE /**< @ingroup LacSymQatHash * Maximum size of state2 in the hash setup block of the content descriptor. * This is set to the block size of SHA512. */ #define LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES 255 /**< Maximum size of the inner and outer prefix for nested hashing operations. * This is got from the maximum size supported by the accelerator which stores * the size in an 8bit field */ #define LAC_MAX_HASH_STATE_STORAGE_SIZE \ (sizeof(icp_qat_hw_auth_counter_t) + LAC_HASH_SHA3_STATEFUL_STATE_SIZE) /**< Maximum size of the hash state storage section of the hash state prefix * buffer */ #define LAC_MAX_HASH_STATE_BUFFER_SIZE_BYTES \ LAC_MAX_HASH_STATE_STORAGE_SIZE + \ (LAC_ALIGN_POW2_ROUNDUP(LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES, \ LAC_QUAD_WORD_IN_BYTES) * \ 2) /**< Maximum size of the hash state prefix buffer will be for nested hash when * there is the maximum sized inner prefix and outer prefix */ #define LAC_MAX_AAD_SIZE_BYTES 256 /**< Maximum size of AAD in bytes */ #define IS_HMAC_ALG(algorithm) \ ((algorithm == CPA_CY_SYM_HASH_MD5) || \ (algorithm == CPA_CY_SYM_HASH_SHA1) || \ (algorithm == CPA_CY_SYM_HASH_SHA224) || \ (algorithm == CPA_CY_SYM_HASH_SHA256) || \ (algorithm == CPA_CY_SYM_HASH_SHA384) || \ (algorithm == CPA_CY_SYM_HASH_SHA512) || \ (algorithm == CPA_CY_SYM_HASH_SM3)) || \ (LAC_HASH_IS_SHA3(algorithm)) /**< @ingroup LacSymQatHash * Macro to detect if the hash algorithm is a HMAC algorithm */ #define IS_HASH_MODE_1(qatHashMode) (ICP_QAT_HW_AUTH_MODE1 == qatHashMode) /**< @ingroup LacSymQatHash * Macro to detect is qat hash mode is set to 1 (precompute mode) * only used with algorithms in hash mode CPA_CY_SYM_HASH_MODE_AUTH */ #define IS_HASH_MODE_2(qatHashMode) (ICP_QAT_HW_AUTH_MODE2 == qatHashMode) /**< @ingroup LacSymQatHash * Macro to detect is qat hash mode is set to 2. This is used for TLS and * mode 2 HMAC (no preompute mode) */ #define IS_HASH_MODE_2_AUTH(qatHashMode, hashMode) \ ((IS_HASH_MODE_2(qatHashMode)) && \ (CPA_CY_SYM_HASH_MODE_AUTH == hashMode)) /**< @ingroup LacSymQatHash * Macro to check for qat hash mode is set to 2 and the hash mode is * Auth. This applies to HMAC algorithms (no pre compute). This is used - * to differntiate between TLS and HMAC */ + * to differentiate between TLS and HMAC */ #define IS_HASH_MODE_2_NESTED(qatHashMode, hashMode) \ ((IS_HASH_MODE_2(qatHashMode)) && \ (CPA_CY_SYM_HASH_MODE_NESTED == hashMode)) /**< @ingroup LacSymQatHash * Macro to check for qat hash mode is set to 2 and the LAC hash mode is * Nested. This applies to TLS. This is used to differentiate between * TLS and HMAC */ #define LAC_HASH_IS_SHA3(algo) \ ((algo == CPA_CY_SYM_HASH_SHA3_224) || \ (algo == CPA_CY_SYM_HASH_SHA3_256) || \ (algo == CPA_CY_SYM_HASH_SHA3_384) || \ (algo == CPA_CY_SYM_HASH_SHA3_512)) /**< @ingroup LacSymQatHash * Macro to check if the hash algorithm is SHA3 */ #endif /* LAC_SYM_HASH_DEFS_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_precomputes.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_precomputes.h index cdb252fb5b46..cf5e21a14c5f 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_precomputes.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_hash_precomputes.h @@ -1,175 +1,175 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_hash_precomputes.h * * @defgroup LacHashDefs Hash Definitions * * @ingroup LacHash * * Constants for hash algorithms * ***************************************************************************/ #ifndef LAC_SYM_HASH_PRECOMPUTES_H #define LAC_SYM_HASH_PRECOMPUTES_H #include "lac_sym_hash.h" #define LAC_SYM_AES_CMAC_RB_128 0x87 /* constant used for */ /* CMAC calculation */ #define LAC_SYM_HASH_MSBIT_MASK 0x80 /* Mask to check MSB top bit */ /* zero or one */ #define LAC_SINGLE_BUFFER_HW_META_SIZE \ (sizeof(icp_buffer_list_desc_t) + sizeof(icp_flat_buffer_desc_t)) /**< size of memory to allocate for the HW buffer list that is sent to the * QAT */ #define LAC_SYM_HASH_PRECOMP_MAX_WORKING_BUFFER \ ((sizeof(lac_sym_hash_precomp_op_data_t) * 2) + \ sizeof(lac_sym_hash_precomp_op_t)) /**< maximum size of the working data for the HMAC precompute operations * * Maximum size of lac_sym_hash_precomp_op_data_t is 264 bytes. For hash - * precomputes there are 2 of these structrues and a further + * precomputes there are 2 of these structures and a further * lac_sym_hash_precomp_op_t structure required. This comes to a total of 536 * bytes. * For the asynchronous version of the precomputes, the memory for the hash * state prefix buffer is used as the working memory. There are 584 bytes * which are alloacted for the hash state prefix buffer which is enough to * carve up for the precomputes. */ #define LAC_SYM_HASH_PRECOMP_MAX_AES_ECB_DATA \ ((ICP_QAT_HW_AES_128_KEY_SZ) * (3)) /**< Maximum size for the data that an AES ECB precompute is generated on */ /** ***************************************************************************** * @ingroup LacHashDefs * Precompute type enum * @description * Enum used to distinguish between precompute types * *****************************************************************************/ typedef enum { LAC_SYM_HASH_PRECOMP_HMAC = 1, /**< Hmac precompute operation. Copy state from hash state buffer */ LAC_SYM_HASH_PRECOMP_AES_ECB, /**< XCBC/CGM precompute, Copy state from data buffer */ } lac_sym_hash_precomp_type_t; /** ***************************************************************************** * @ingroup LacHashDefs * overall precompute management structure * @description * structure used to manage the precompute operations for a session * *****************************************************************************/ typedef struct lac_sym_hash_precomp_op_s { lac_hash_precompute_done_cb_t callbackFn; /**< Callback function to be invoked when the final precompute completes */ void *pCallbackTag; /**< Opaque data to be passed back as a parameter in the callback */ QatUtilsAtomic opsPending; /**< counter used to determine if the current precompute is the * final one. */ } lac_sym_hash_precomp_op_t; /** ***************************************************************************** * @ingroup LacHashDefs * hmac precompute structure as used by the QAT * @description * data used by the QAT for HMAC precomputes * * Must be allocated on an 8-byte aligned memory address. * *****************************************************************************/ typedef struct lac_sym_hash_hmac_precomp_qat_s { Cpa8U data[LAC_HASH_SHA512_BLOCK_SIZE]; /**< data to be hashed - block size of data for the algorithm */ /* NOTE: to save space we could have got the QAT to overwrite * this with the hash state storage */ icp_qat_fw_la_auth_req_params_t hashReqParams; /**< Request parameters as read in by the QAT */ Cpa8U bufferDesc[LAC_SINGLE_BUFFER_HW_META_SIZE]; /**< Buffer descriptor structure */ Cpa8U hashStateStorage[LAC_MAX_HASH_STATE_STORAGE_SIZE]; /**< Internal buffer where QAT writes the intermediate partial * state that is used in the precompute */ } lac_sym_hash_hmac_precomp_qat_t; /** ***************************************************************************** * @ingroup LacHashDefs * AES ECB precompute structure as used by the QAT * @description * data used by the QAT for AES ECB precomptes * * Must be allocated on an 8-byte aligned memory address. * *****************************************************************************/ typedef struct lac_sym_hash_aes_precomp_qat_s { Cpa8U contentDesc[LAC_SYM_QAT_MAX_CIPHER_SETUP_BLK_SZ]; /**< Content descriptor for a cipher operation */ Cpa8U data[LAC_SYM_HASH_PRECOMP_MAX_AES_ECB_DATA]; - /**< The data to be ciphered is conatined here and the result is + /**< The data to be ciphered is contained here and the result is * written in place back into this buffer */ icp_qat_fw_la_cipher_req_params_t cipherReqParams; /**< Request parameters as read in by the QAT */ Cpa8U bufferDesc[LAC_SINGLE_BUFFER_HW_META_SIZE]; /**< Buffer descriptor structure */ } lac_sym_hash_aes_precomp_qat_t; /** ***************************************************************************** * @ingroup LacHashDefs * overall structure for managing a single precompute operation * @description * overall structure for managing a single precompute operation * * Must be allocated on an 8-byte aligned memory address. * *****************************************************************************/ typedef struct lac_sym_hash_precomp_op_data_s { sal_crypto_service_t *pInstance; /**< Instance handle for the operation */ Cpa8U reserved[4]; /**< padding to align later structures on minimum 8-Byte address */ lac_sym_hash_precomp_type_t opType; /**< operation type to determine the precompute type in the callback */ lac_sym_hash_precomp_op_t *pOpStatus; /**< structure containing the counter and the condition for the overall * precompute operation. This is a pointer because the memory structure * may be shared between precomputes when there are more than 1 as in * the * case of HMAC */ union { lac_sym_hash_hmac_precomp_qat_t hmacQatData; /**< Data sent to the QAT for hmac precomputes */ lac_sym_hash_aes_precomp_qat_t aesQatData; /**< Data sent to the QAT for AES ECB precomputes */ } u; /**< ASSUMPTION: The above structures are 8 byte aligned if the overall * struct is 8 byte aligned, as there are two 4 byte fields before this * union */ Cpa32U stateSize; /**< Size of the state to be copied into the state pointer in the * content * descriptor */ Cpa8U *pState; /**< pointer to the state in the content descriptor where the result of * the precompute should be copied to */ } lac_sym_hash_precomp_op_data_t; #endif /* LAC_SYM_HASH_PRECOMPUTES_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_key.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_key.h index bae0d8faabc7..25c919d9b38d 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_key.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_key.h @@ -1,184 +1,181 @@ -/*************************************************************************** - * - * - * - ***************************************************************************/ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_key.h * * @defgroup LacSymKey Key Generation * * @ingroup LacSym * * @lld_start * * @lld_overview * - * Key generation component is reponsible for SSL, TLS & MGF operations. All + * Key generation component is responsible for SSL, TLS & MGF operations. All * memory required for the keygen operations is got from the keygen cookie * structure which is carved up as required. * * For SSL the QAT accelerates the nested hash function with MD5 as the * outer hash and SHA1 as the inner hash. * * Refer to sections in draft-freier-ssl-version3-02.txt: - * 6.1 Asymmetric cryptographic computations - This refers to coverting - * the pre master secret to the master secret. + * 6.1 Asymmetric cryptographic computations - This refers to converting + * the pre-master secret to the master secret. * 6.2.2 Converting the master secret into keys and MAC secrets - Using * the master secret to generate the key material. * * For TLS the QAT accelerates the PRF function as described in * rfc4346 - TLS version 1.1 (this obsoletes rfc2246 - TLS version 1.0) * 5. HMAC and the pseudorandom function - For the TLS PRF and getting * S1 and S2 from the secret. * 6.3. Key calculation - For how the key material is generated * 7.4.9. Finished - How the finished message uses the TLS PRF * 8.1. Computing the master secret * * * @lld_dependencies * \ref LacSymQatHash: for building up hash content descriptor - * \ref LacMem: for virt to phys coversions + * \ref LacMem: for virt to phys conversions * * @lld_initialisation - * The reponse handler is registered with Symmetric. The Maximum SSL is - * allocated. A structure is allocated containing all the TLS lables that + * The response handler is registered with Symmetric. The Maximum SSL is + * allocated. A structure is allocated containing all the TLS labels that * are supported. On shutdown the memory for these structures are freed. * * @lld_module_algorithms * @lld_process_context * * @lld_end * * *****************************************************************************/ #ifndef LAC_SYM_KEY_H_ #define LAC_SYM_KEY_H_ #include "icp_qat_fw_la.h" #include "cpa_cy_key.h" /**< @ingroup LacSymKey * Label for SSL. Size is 136 bytes for 16 iterations, which can theroretically * generate up to 256 bytes of output data. QAT will generate a maximum of * 255 bytes */ #define LAC_SYM_KEY_TLS_MASTER_SECRET_LABEL ("master secret") /**< @ingroup LacSymKey * Label for TLS Master Secret Key Derivation, as defined in RFC4346 */ #define LAC_SYM_KEY_TLS_KEY_MATERIAL_LABEL ("key expansion") /**< @ingroup LacSymKey * Label for TLS Key Material Generation, as defined in RFC4346. */ #define LAC_SYM_KEY_TLS_CLIENT_FIN_LABEL ("client finished") /**< @ingroup LacSymKey * Label for TLS Client finished Message, as defined in RFC4346. */ #define LAC_SYM_KEY_TLS_SERVER_FIN_LABEL ("server finished") /**< @ingroup LacSymKey * Label for TLS Server finished Message, as defined in RFC4346. */ /* ******************************************************************************* * Define Constants and Macros for SSL, TLS and MGF ******************************************************************************* */ #define LAC_SYM_KEY_NO_HASH_BLK_OFFSET_QW 0 /**< Used to indicate there is no hash block offset in the content descriptor */ /* ******************************************************************************* * Define Constant lengths for HKDF TLS v1.3 sublabels. ******************************************************************************* */ #define HKDF_SUB_LABEL_KEY_LENGTH ((Cpa8U)13) #define HKDF_SUB_LABEL_IV_LENGTH ((Cpa8U)12) #define HKDF_SUB_LABEL_RESUMPTION_LENGTH ((Cpa8U)20) #define HKDF_SUB_LABEL_FINISHED_LENGTH ((Cpa8U)18) #define HKDF_SUB_LABELS_ALL \ (CPA_CY_HKDF_SUBLABEL_KEY | CPA_CY_HKDF_SUBLABEL_IV | \ CPA_CY_HKDF_SUBLABEL_RESUMPTION | CPA_CY_HKDF_SUBLABEL_FINISHED) #define LAC_KEY_HKDF_SUBLABELS_NUM 4 #define LAC_KEY_HKDF_DIGESTS 0 #define LAC_KEY_HKDF_CIPHERS_MAX (CPA_CY_HKDF_TLS_AES_128_CCM_8_SHA256 + 1) #define LAC_KEY_HKDF_SUBLABELS_MAX (LAC_KEY_HKDF_SUBLABELS_NUM + 1) /** ****************************************************************************** * @ingroup LacSymKey * TLS label struct * * @description * This structure is used to hold the various TLS labels. Each field is - * on an 8 byte boundary provided the structure itslef is 8 bytes aligned. + * on an 8 byte boundary provided the structure itself is 8 bytes aligned. *****************************************************************************/ typedef struct lac_sym_key_tls_labels_s { Cpa8U masterSecret[ICP_QAT_FW_LA_TLS_LABEL_LEN_MAX]; /**< Master secret label */ Cpa8U keyMaterial[ICP_QAT_FW_LA_TLS_LABEL_LEN_MAX]; /**< Key material label */ Cpa8U clientFinished[ICP_QAT_FW_LA_TLS_LABEL_LEN_MAX]; /**< client finished label */ Cpa8U serverFinished[ICP_QAT_FW_LA_TLS_LABEL_LEN_MAX]; /**< server finished label */ } lac_sym_key_tls_labels_t; /** ****************************************************************************** * @ingroup LacSymKey * TLS HKDF sub label struct * * @description * This structure is used to hold the various TLS HKDF sub labels. * Each field is on an 8 byte boundary. *****************************************************************************/ typedef struct lac_sym_key_tls_hkdf_sub_labels_s { CpaCyKeyGenHKDFExpandLabel keySublabel256; /**< CPA_CY_HKDF_SUBLABEL_KEY */ CpaCyKeyGenHKDFExpandLabel ivSublabel256; /**< CPA_CY_HKDF_SUBLABEL_IV */ CpaCyKeyGenHKDFExpandLabel resumptionSublabel256; /**< CPA_CY_HKDF_SUBLABEL_RESUMPTION */ CpaCyKeyGenHKDFExpandLabel finishedSublabel256; /**< CPA_CY_HKDF_SUBLABEL_FINISHED */ CpaCyKeyGenHKDFExpandLabel keySublabel384; /**< CPA_CY_HKDF_SUBLABEL_KEY */ CpaCyKeyGenHKDFExpandLabel ivSublabel384; /**< CPA_CY_HKDF_SUBLABEL_IV */ CpaCyKeyGenHKDFExpandLabel resumptionSublabel384; /**< CPA_CY_HKDF_SUBLABEL_RESUMPTION */ CpaCyKeyGenHKDFExpandLabel finishedSublabel384; /**< CPA_CY_HKDF_SUBLABEL_FINISHED */ CpaCyKeyGenHKDFExpandLabel keySublabelChaChaPoly; /**< CPA_CY_HKDF_SUBLABEL_KEY */ CpaCyKeyGenHKDFExpandLabel ivSublabelChaChaPoly; /**< CPA_CY_HKDF_SUBLABEL_IV */ CpaCyKeyGenHKDFExpandLabel resumptionSublabelChaChaPoly; /**< CPA_CY_HKDF_SUBLABEL_RESUMPTION */ CpaCyKeyGenHKDFExpandLabel finishedSublabelChaChaPoly; /**< CPA_CY_HKDF_SUBLABEL_FINISHED */ Cpa64U sublabelPhysAddr256; /**< Physical address of the SHA-256 subLabels */ Cpa64U sublabelPhysAddr384; /**< Physical address of the SHA-384 subLabels */ Cpa64U sublabelPhysAddrChaChaPoly; /**< Physical address of the ChaChaPoly subLabels */ } lac_sym_key_tls_hkdf_sub_labels_t; /** ****************************************************************************** * @ingroup LacSymKey * This function prints the stats to standard out. * * @retval CPA_STATUS_SUCCESS Status Success * @retval CPA_STATUS_FAIL General failure * *****************************************************************************/ void LacKeygen_StatsShow(CpaInstanceHandle instanceHandle); #endif diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_partial.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_partial.h index 3f6c75ca7fb7..633d1c7afa96 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_partial.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_partial.h @@ -1,120 +1,120 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_partial.h * * @defgroup LacSymPartial Partial Packets * * @ingroup LacSymCommon * * Partial packet handling code * * @lld_start * * Partials In Flight\n * The API states that for partial packets the client should not submit * the next partial request until the callback for the current partial has * been called. We have chosen to enforce this rather than letting the user * proceed where they would get an incorrect digest, cipher result. * * Maintain a SpinLock for partials in flight per session. Try and acquire this - * SpinLock. If it cant be acquired return an error straight away to the client + * SpinLock. If it can't be acquired return an error straight away to the client * as there is already a partial in flight. There is no blocking in the data * path for this. * * By preventing any other partials from coming in while a partial is in flight * we can check and change the state of the session without having to lock * round it (dont want to have to lock and block in the data path). The state * of the session indicates the previous packet type that a request was * successfully completed for. The last packet type is only updated for partial * packets. This state determines the packet types that can be accepted. * e.g a last partial will not be accepted unless the previous packet was a * partial. By only allowing one partial packet to be in flight, there is no * need to lock around the update of the previous packet type for the session. * * The ECB Cipher mode, ciphers each block separately. No state is maintained * between blocks. There is no need to wait for the callback for previous * partial in ECB mode as the result of the previous partial has no impact on * it. The API and our implementation only allows 1 partial packet to be in * flight per session, therefore a partial packet request for ECB mode must * be fully completed (ie. callback called) before the next partial request * can be issued. * * Partial Ordering\n * The ordering that the user submits partial packets will be checked. * (we could have let the user proceed where they will get an incorrect * digest/cipher result but chose against this). * * -# Maintain the last packet type of a partial operation for the session. If * there have been no previous partials, we will accept only first partials * -# The state must be set to partial before we will accept a final partial. * i.e. a partial request must have already completed. * * The last packet type is updated in the callback for partial packets as this * is the only place we can guarantee that a partial packet operation has been * completed. When a partial completes the state can be updated from FULL to * PARTIAL. The SpinLock for partial packets in flight for the session can be * unlocked at this point. On a final Partial request the last packet type is * reset back to FULL. NOTE: This is not done at the same time as the check in * the perform as if an error occurs we would have to roll back the state * * For Hash mode it is possible to interleave full and a single partial * packet stream in a session as the hash state buffer is updated for partial * packets. It is not touched by full packets. For cipher mode, as the client * manages the state, they can interleave full and a single partial packets. * For ARC4, the state is managed internally and the packet type will always * be set to partial internally. * * @lld_end * ***************************************************************************/ /***************************************************************************/ #ifndef LAC_SYM_PARTIAL_H #define LAC_SYM_PARTIAL_H #include "cpa.h" #include "cpa_cy_sym.h" /***************************************************************************/ /** ******************************************************************************* * @ingroup LacSymPartial * check if partial packet request is valid for a session * * @description * This function checks to see if there is a partial packet request in * flight and then if the partial state is correct * * @param[in] packetType Partial packet request * @param[in] partialState Partial state of session * * @retval CPA_STATUS_SUCCESS Normal Operation * @retval CPA_STATUS_INVALID_PARAM Invalid Parameter * *****************************************************************************/ CpaStatus LacSym_PartialPacketStateCheck(CpaCySymPacketType packetType, CpaCySymPacketType partialState); /** ******************************************************************************* * @ingroup LacSymPartial * update the state of the partial packet in a session * * @description * This function is called in callback operation. It updates the state * of a partial packet in a session and indicates that there is no * longer a partial packet in flight for the session * * @param[in] packetType Partial packet request * @param[out] pPartialState Pointer to partial state of session * *****************************************************************************/ void LacSym_PartialPacketStateUpdate(CpaCySymPacketType packetType, CpaCySymPacketType *pPartialState); #endif /* LAC_SYM_PARTIAL_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat.h index 986e230dc1ff..dc72601bae44 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat.h @@ -1,247 +1,247 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_qat.h * * @defgroup LacSymQat Symmetric QAT * * @ingroup LacSym * * Interfaces for populating the qat structures for a symmetric operation * * @lld_start * * @lld_overview * This file documents the interfaces for populating the qat structures * that are common for all symmetric operations. * * @lld_dependencies * - \ref LacSymQatHash "Hash QAT Comms" Sym Qat commons for Hash * - \ref LacSymQat_Cipher "Cipher QAT Comms" Sym Qat commons for Cipher * - OSAL: logging * - \ref LacMem "Memory" - Inline memory functions * * @lld_initialisation - * This component is initialied during the LAC initialisation sequence. It + * This component is initialized during the LAC initialisation sequence. It * is called by the Symmetric Initialisation function. * * @lld_module_algorithms * * @lld_process_context * Refer to \ref LacHash "Hash" and \ref LacCipher "Cipher" for sequence * diagrams to see their interactions with this code. * * * @lld_end * *****************************************************************************/ /*****************************************************************************/ #ifndef LAC_SYM_QAT_H #define LAC_SYM_QAT_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_accel_devices.h" #include "icp_qat_fw_la.h" #include "icp_qat_hw.h" #include "lac_session.h" #include "sal_qat_cmn_msg.h" #include "lac_common.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #define LAC_SYM_DEFAULT_QAT_PTR_TYPE QAT_COMN_PTR_TYPE_SGL #define LAC_SYM_DP_QAT_PTR_TYPE QAT_COMN_PTR_TYPE_FLAT #define LAC_SYM_KEY_QAT_PTR_TYPE QAT_COMN_PTR_TYPE_FLAT /**< @ingroup LacSymQat * LAC SYM Source & Destination buffer type (FLAT/SGL) */ #define LAC_QAT_SYM_REQ_SZ_LW 32 #define SYM_TX_MSG_SIZE (LAC_QAT_SYM_REQ_SZ_LW * LAC_LONG_WORD_IN_BYTES) #define NRBG_TX_MSG_SIZE (LAC_QAT_SYM_REQ_SZ_LW * LAC_LONG_WORD_IN_BYTES) #define LAC_QAT_SYM_RESP_SZ_LW 8 #define SYM_RX_MSG_SIZE (LAC_QAT_SYM_RESP_SZ_LW * LAC_LONG_WORD_IN_BYTES) #define NRBG_RX_MSG_SIZE (LAC_QAT_SYM_RESP_SZ_LW * LAC_LONG_WORD_IN_BYTES) /** ******************************************************************************* * @ingroup LacSymQat * Symmetric crypto response handler * * @description * This function handles the symmetric crypto response * * @param[in] trans_handle transport handle (if ICP_QAT_DBG set) * @param[in] instanceHandle void* pRespMsg * * *****************************************************************************/ void LacSymQat_SymRespHandler(void *pRespMsg); /** ******************************************************************************* * @ingroup LacSymQat * Initialise the Symmetric QAT code * * @description * This function initialises the symmetric QAT code * * @param[in] device Pointer to the acceleration device * structure * @param[in] instanceHandle Instance handle * @param[in] numSymRequests Number of concurrent requests a pair * (tx and rx) need to support * * @return CPA_STATUS_SUCCESS Operation successful * @return CPA_STATUS_FAIL Initialisation Failed * *****************************************************************************/ CpaStatus LacSymQat_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacSymQat * Register a response handler function for a symmetric command ID * * @description * This function registers a response handler function for a symmetric * operation. * * Note: This operation should only be performed once by the init function * of a component. There is no corresponding deregister function, but * registering a NULL function pointer will have the same effect. There * MUST not be any requests in flight when calling this function. * * @param[in] lacCmdId Command Id of operation * @param[in] pCbHandler callback handler function * * @return None * *****************************************************************************/ void LacSymQat_RespHandlerRegister(icp_qat_fw_la_cmd_id_t lacCmdId, sal_qat_resp_handler_func_t pCbHandler); /** ****************************************************************************** * @ingroup LacSymQat * get the QAT packet type * * @description * This function returns the QAT packet type for a LAC packet type. The * LAC packet type does not indicate a first partial. therefore for a * partial request, the previous packet type needs to be looked at to * figure out if the current partial request is a first partial. * * * @param[in] packetType LAC Packet type * @param[in] packetState LAC Previous Packet state * @param[out] pQatPacketType Packet type using the QAT macros * * @return none * *****************************************************************************/ void LacSymQat_packetTypeGet(CpaCySymPacketType packetType, CpaCySymPacketType packetState, Cpa32U *pQatPacketType); /** ****************************************************************************** * @ingroup LacSymQat * Populate the command flags based on the packet type * * @description * This function populates the following flags in the Symmetric Crypto * service_specif_flags field of the common header of the request: * - LA_PARTIAL * - UPDATE_STATE * - RET_AUTH_RES * - CMP_AUTH_RES * based on looking at the input params listed below. * * @param[in] qatPacketType Packet type * @param[in] cmdId Command Id * @param[in] cipherAlgorithm Cipher Algorithm * @param[out] pLaCommandFlags Command Flags * * @return none * *****************************************************************************/ void LacSymQat_LaPacketCommandFlagSet(Cpa32U qatPacketType, icp_qat_fw_la_cmd_id_t laCmdId, CpaCySymCipherAlgorithm cipherAlgorithm, Cpa16U *pLaCommandFlags, Cpa32U ivLenInBytes); /** ****************************************************************************** * @ingroup LacSymQat * * * @description * defaults the common request service specific flags * * @param[in] laCmdFlags Common request service specific flags * @param[in] symOp Type of operation performed e.g hash or cipher * * @return none * *****************************************************************************/ void LacSymQat_LaSetDefaultFlags(icp_qat_fw_serv_specif_flags *laCmdFlags, CpaCySymOp symOp); /** ****************************************************************************** * @ingroup LacSymQat * * * @description * this function defines whether the shared constants table can be used * for a particular cipher and hash algorithm * * @param[in] ptr to session * @param[in] ptr to return offset into table for cipher config * @param[in] ptr to return offset into table for hash config * * @return CPA_TRUE if Constants table is available for use, CPA_FALSE if it's * not. * *****************************************************************************/ CpaBoolean LacSymQat_UseSymConstantsTable(lac_session_desc_t *pSession, Cpa8U *cipherOffset, Cpa8U *hashOffset); /** ****************************************************************************** * @ingroup LacSymQat * * * @description * this function calculates whether the optimized content descriptor can * be used for a particular chained cipher and hash algorithm * * @param[in] ptr to session * * @return CPA_TRUE if optimized CD can be used, CPA_FALSE if it's not. * *****************************************************************************/ CpaBoolean LacSymQat_UseOptimisedContentDesc(lac_session_desc_t *pSession); #endif /* LAC_SYM_QAT_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_cipher.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_cipher.h index 2f1d36dcd669..2f4a4511f4fc 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_cipher.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_cipher.h @@ -1,301 +1,301 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_qat_cipher.h * * @defgroup LacSymQat_Cipher Cipher QAT * * @ingroup LacSymQat * * external interfaces for populating QAT structures for cipher operations. * *****************************************************************************/ /*****************************************************************************/ #ifndef LAC_SYM_QAT_CIPHER_H #define LAC_SYM_QAT_CIPHER_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa_cy_sym.h" #include "icp_qat_fw_la.h" #include "lac_session.h" #include "lac_sal_types_crypto.h" /* ************************************************************************** * @ingroup LacSymQat_Cipher * * @description * Defines for building the cipher request params cache * ************************************************************************** */ #define LAC_SYM_QAT_CIPHER_NEXT_ID_BIT_OFFSET 24 #define LAC_SYM_QAT_CIPHER_CURR_ID_BIT_OFFSET 16 #define LAC_SYM_QAT_CIPHER_STATE_SIZE_BIT_OFFSET 8 #define LAC_SYM_QAT_CIPHER_GCM_SPC_OFFSET_IN_DRAM 9 #define LAC_SYM_QAT_CIPHER_CCM_SPC_OFFSET_IN_DRAM 8 #define LAC_SYM_QAT_CIPHER_CHACHA_SPC_OFFSET_IN_DRAM 2 #define LAC_SYM_QAT_CIPHER_SPC_STATE_SIZE 48 /** ****************************************************************************** * @ingroup LacSymQat_Cipher * Retrieve the cipher block size in bytes for a given algorithm * * @description * This function returns a hard-coded block size for the specific cipher * algorithm * * @param[in] cipherAlgorithm Cipher algorithm for the current session * * @retval The block size, in bytes, for the given cipher algorithm * *****************************************************************************/ Cpa8U LacSymQat_CipherBlockSizeBytesGet(CpaCySymCipherAlgorithm cipherAlgorithm); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * Retrieve the cipher IV/state size in bytes for a given algorithm * * @description * This function returns a hard-coded IV/state size for the specific cipher * algorithm * * @param[in] cipherAlgorithm Cipher algorithm for the current session * * @retval The IV/state size, in bytes, for the given cipher algorithm * *****************************************************************************/ Cpa32U LacSymQat_CipherIvSizeBytesGet(CpaCySymCipherAlgorithm cipherAlgorithm); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * Populate the cipher request params structure * * @description * This function is passed a pointer to the 128B request block. * (This memory must be allocated prior to calling this function). It * populates: * - the cipher fields of the req_params block in the request. No * need to zero this first, all fields will be populated. * - the corresponding CIPH_IV_FLD flag in the serv_specif_flags field * of the common header. * To do this it uses the parameters described below and the following *fields from the request block which must be populated prior to calling this *function: * - cd_ctrl.cipher_state_sz * - UPDATE_STATE flag in comn_hdr.serv_specif_flags * * * @param[in] pReq Pointer to request block. * * * @param[in] cipherOffsetInBytes Offset to cipher data in user data buffer * * @param[in] cipherLenInBytes Length of cipher data in buffer * * @param[in] ivBufferPhysAddr Physical address of aligned IV/state * buffer * @param[in] pIvBufferVirt Virtual address of aligned IV/state * buffer * @retval void * *****************************************************************************/ CpaStatus LacSymQat_CipherRequestParamsPopulate(lac_session_desc_t *pSessionDesc, icp_qat_fw_la_bulk_req_t *pReq, Cpa32U cipherOffsetInBytes, Cpa32U cipherLenInBytes, Cpa64U ivBufferPhysAddr, Cpa8U *pIvBufferVirt); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * Derive initial ARC4 cipher state from a base key * * @description * An initial state for an ARC4 cipher session is derived from the base * key provided by the user, using the ARC4 Key Scheduling Algorithm (KSA) * * @param[in] pKey The base key provided by the user * * @param[in] keyLenInBytes The length of the base key provided. * The range of valid values is 1-256 bytes * * @param[out] pArc4CipherState The initial state is written to this buffer, * including i and j values, and 6 bytes of padding * so 264 bytes must be allocated for this buffer * by the caller * * @retval void * *****************************************************************************/ void LacSymQat_CipherArc4StateInit(const Cpa8U *pKey, Cpa32U keyLenInBytes, Cpa8U *pArc4CipherState); /** ****************************************************************************** * @ingroup LacSymQat_CipherXTSModeUpdateKeyLen * Update the initial XTS key after the first partial has been received. * * @description * For XTS mode using partial packets, after the first partial response * has been received, the key length needs to be halved for subsequent * partials. * * @param[in] pSessionDesc The session descriptor. * * @param[in] newKeySizeInBytes The new key size.. * * @retval void * *****************************************************************************/ void LacSymQat_CipherXTSModeUpdateKeyLen(lac_session_desc_t *pSessionDesc, Cpa32U newKeySizeInBytes); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * LacSymQat_CipherCtrlBlockInitialize() * * @description - * intialize the cipher control block with all zeros + * initialize the cipher control block with all zeros * * @param[in] pMsg Pointer to the common request message * * @retval void * *****************************************************************************/ void LacSymQat_CipherCtrlBlockInitialize(icp_qat_fw_la_bulk_req_t *pMsg); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * LacSymQat_CipherCtrlBlockWrite() * * @description * This function populates the cipher control block of the common request * message * * @param[in] pMsg Pointer to the common request message * * @param[in] cipherAlgorithm Cipher Algorithm to be used * * @param[in] targetKeyLenInBytes cipher key length in bytes of selected * algorithm * * @param[in] sliceType Cipher slice type to be used * * @param[out] nextSlice SliceID for next control block * entry. This value is known only by * the calling component * * @param[out] cipherCfgOffsetInQuadWord Offset into the config table in QW * * @retval void * *****************************************************************************/ void LacSymQat_CipherCtrlBlockWrite(icp_qat_la_bulk_req_ftr_t *pMsg, Cpa32U cipherAlgorithm, Cpa32U targetKeyLenInBytes, Cpa32U sliceType, icp_qat_fw_slice_t nextSlice, Cpa8U cipherCfgOffsetInQuadWord); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * LacSymQat_CipherHwBlockPopulateCfgData() * * @description * Populate the physical HW block with config data * * @param[in] pSession Pointer to the session data * * @param[in] pCipherHwBlock pointer to the hardware control block * in the common message * * @param[in] pSizeInBytes * * @retval void * *****************************************************************************/ void LacSymQat_CipherHwBlockPopulateCfgData(lac_session_desc_t *pSession, const void *pCipherHwBlock, Cpa32U *pSizeInBytes); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * LacSymQat_CipherGetCfgData() * * @description * setup the config data for cipher * * @param[in] pSession Pointer to the session data * * @param[in] pAlgorithm * * @param[in] pMode * @param[in] pDir * @param[in] pKey_convert * * @retval void * *****************************************************************************/ void LacSymQat_CipherGetCfgData(lac_session_desc_t *pSession, icp_qat_hw_cipher_algo_t *pAlgorithm, icp_qat_hw_cipher_mode_t *pMode, icp_qat_hw_cipher_dir_t *pDir, icp_qat_hw_cipher_convert_t *pKey_convert); /** ****************************************************************************** * @ingroup LacSymQat_Cipher * LacSymQat_CipherHwBlockPopulateKeySetup() * * @description * populate the key setup data in the cipher hardware control block * in the common request message * * param[in] pCipherSetupData Pointer to cipher setup data * * @param[in] targetKeyLenInBytes Target key length. If key length given * in cipher setup data is less that this, * the key will be "rounded up" to this * target length by padding it with 0's. * In normal no-padding case, the target * key length MUST match the key length * in the cipher setup data. * * @param[in] sliceType Cipher slice type to be used * * @param[in] pCipherHwBlock Pointer to the cipher hardware block * * @param[out] pCipherHwBlockSizeBytes Size in bytes of cipher setup block * * * @retval void * *****************************************************************************/ void LacSymQat_CipherHwBlockPopulateKeySetup( lac_session_desc_t *pSessionDesc, const CpaCySymCipherSetupData *pCipherSetupData, Cpa32U targetKeyLenInBytes, Cpa32U sliceType, const void *pCipherHwBlock, Cpa32U *pCipherHwBlockSizeBytes); #endif /* LAC_SYM_QAT_CIPHER_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash.h index 38c5892b0cc4..51a215ffc72a 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash.h @@ -1,313 +1,313 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_qat_hash.h * * @defgroup LacSymQatHash Hash QAT * * @ingroup LacSymQat * * interfaces for populating qat structures for a hash operation * *****************************************************************************/ /*****************************************************************************/ #ifndef LAC_SYM_QAT_HASH_H #define LAC_SYM_QAT_HASH_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_qat_fw_la.h" #include "icp_qat_hw.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_common.h" /** ****************************************************************************** * @ingroup LacSymQatHash * hash precomputes * * @description - * This structure contains infomation on the hash precomputes + * This structure contains information on the hash precomputes * *****************************************************************************/ typedef struct lac_sym_qat_hash_precompute_info_s { Cpa8U *pState1; /**< state1 pointer */ Cpa32U state1Size; /**< state1 size */ Cpa8U *pState2; /**< state2 pointer */ Cpa32U state2Size; /**< state2 size */ } lac_sym_qat_hash_precompute_info_t; /** ****************************************************************************** * @ingroup LacSymQatHash * hash state prefix buffer info * * @description - * This structure contains infomation on the hash state prefix aad buffer + * This structure contains information on the hash state prefix aad buffer * *****************************************************************************/ typedef struct lac_sym_qat_hash_state_buffer_info_s { Cpa64U pDataPhys; /**< Physical pointer to the hash state prefix buffer */ Cpa8U *pData; /**< Virtual pointer to the hash state prefix buffer */ Cpa8U stateStorageSzQuadWords; /**< hash state storage size in quad words */ Cpa8U prefixAadSzQuadWords; /**< inner prefix/aad and outer prefix size in quad words */ } lac_sym_qat_hash_state_buffer_info_t; /** ****************************************************************************** * @ingroup LacSymQatHash * Init the hash specific part of the content descriptor. * * @description * This function populates the hash specific fields of the control block * and the hardware setup block for a digest session. This function sets * the size param to hold the size of the hash setup block. * * In the case of hash only, the content descriptor will contain just a * hash control block and hash setup block. In the case of chaining it * will contain the hash control block and setup block along with the * control block and setup blocks of additional services. * * Note: The memory for the content descriptor MUST be allocated prior to * calling this function. The memory for the hash control block and hash * setup block MUST be set to 0 prior to calling this function. * * @image html contentDescriptor.png "Content Descriptor" * * @param[in] pMsg Pointer to req Parameter Footer * * @param[in] pHashSetupData Pointer to the hash setup data as * defined in the LAC API. * * @param[in] pHwBlockBase Pointer to the base of the hardware * setup block * * @param[in] hashBlkOffsetInHwBlock Offset in quad-words from the base of * the hardware setup block where the * hash block will start. This offset * is stored in the control block. It * is used to figure out where to write * that hash setup block. * * @param[in] nextSlice SliceID for next control block * entry This value is known only by * the calling component * * @param[in] qatHashMode QAT hash mode * * @param[in] useSymConstantsTable Indicate if Shared-SRAM constants table * is used for this session. If TRUE, the * h/w setup block is NOT populated * * @param[in] useOptimisedContentDesc Indicate if optimised content desc * is used for this session. * * @param[in] useStatefulSha3ContentDesc * Indicate if stateful SHA3 content desc * is used for this session. * * @param[in] pPrecompute For auth mode, this is the pointer * to the precompute data. Otherwise this * should be set to NULL * * @param[out] pHashBlkSizeInBytes size in bytes of hash setup block * * @return void * *****************************************************************************/ void LacSymQat_HashContentDescInit(icp_qat_la_bulk_req_ftr_t *pMsg, CpaInstanceHandle instanceHandle, const CpaCySymHashSetupData *pHashSetupData, void *pHwBlockBase, Cpa32U hashBlkOffsetInHwBlock, icp_qat_fw_slice_t nextSlice, icp_qat_hw_auth_mode_t qatHashMode, CpaBoolean useSymConstantsTable, CpaBoolean useOptimisedContentDesc, CpaBoolean useStatefulSha3ContentDesc, lac_sym_qat_hash_precompute_info_t *pPrecompute, Cpa32U *pHashBlkSizeInBytes); /** ****************************************************************************** * @ingroup LacSymQatHash * Calculate the size of the hash state prefix aad buffer * * @description * This function inspects the hash control block and based on the values * in the fields, it calculates the size of the hash state prefix aad * buffer. * * A partial packet processing request is possible at any stage during a * hash session. In this case, there will always be space for the hash * state storage field of the hash state prefix buffer. When there is * AAD data just the inner prefix AAD data field is used. * * @param[in] pMsg Pointer to the Request Message * * @param[out] pHashStateBuf Pointer to hash state prefix buffer info * structure. * * @return None * *****************************************************************************/ void LacSymQat_HashStatePrefixAadBufferSizeGet( icp_qat_la_bulk_req_ftr_t *pMsg, lac_sym_qat_hash_state_buffer_info_t *pHashStateBuf); /** ****************************************************************************** * @ingroup LacSymQatHash * Populate the fields of the hash state prefix buffer * * @description * This function populates the inner prefix/aad fields and/or the outer * prefix field of the hash state prefix buffer. * * @param[in] pHashStateBuf Pointer to hash state prefix buffer info * structure. * * @param[in] pMsg Pointer to the Request Message * * @param[in] pInnerPrefixAad Pointer to the Inner Prefix or Aad data * This is NULL where if the data size is 0 * * @param[in] innerPrefixSize Size of inner prefix/aad data in bytes * * @param[in] pOuterPrefix Pointer to the Outer Prefix data. This is * NULL where the data size is 0. * * @param[in] outerPrefixSize Size of the outer prefix data in bytes * * @return void * *****************************************************************************/ void LacSymQat_HashStatePrefixAadBufferPopulate( lac_sym_qat_hash_state_buffer_info_t *pHashStateBuf, icp_qat_la_bulk_req_ftr_t *pMsg, Cpa8U *pInnerPrefixAad, Cpa8U innerPrefixSize, Cpa8U *pOuterPrefix, Cpa8U outerPrefixSize); /** ****************************************************************************** * @ingroup LacSymQatHash * Populate the hash request params structure * * @description * This function is passed a pointer to the 128B Request block. * (This memory must be allocated prior to calling this function). It * populates the fields of this block using the parameters as described * below. It is also expected that this structure has been set to 0 * prior to calling this function. * * * @param[in] pReq Pointer to 128B request block. * * @param[in] authOffsetInBytes start offset of data that the digest is to * be computed on. * * @param[in] authLenInBytes Length of data digest calculated on * * @param[in] pService Pointer to service data * * @param[in] pHashStateBuf Pointer to hash state buffer info. This * structure contains the pointers and sizes. * If there is no hash state prefix buffer * required, this parameter can be set to NULL * * @param[in] qatPacketType Packet type using QAT macros. The hash * state buffer pointer and state size will be * different depending on the packet type * * @param[in] hashResultSize Size of the final hash result in bytes. * * @param[in] digestVerify Indicates if verify is enabled or not * * @param[in] pAuthResult Virtual pointer to digest * * @return CPA_STATUS_SUCCESS or CPA_STATUS_FAIL * *****************************************************************************/ CpaStatus LacSymQat_HashRequestParamsPopulate( icp_qat_fw_la_bulk_req_t *pReq, Cpa32U authOffsetInBytes, Cpa32U authLenInBytes, sal_service_t *pService, lac_sym_qat_hash_state_buffer_info_t *pHashStateBuf, Cpa32U qatPacketType, Cpa32U hashResultSize, CpaBoolean digestVerify, Cpa8U *pAuthResult, CpaCySymHashAlgorithm alg, void *data); /** ****************************************************************************** * @ingroup LacSymQatHash * * * @description * This fn returns the QAT values for hash algorithm and nested fields * * * @param[in] pInstance Pointer to service instance. * * @param[in] qatHashMode value for hash mode on the fw qat *interface. * * @param[in] apiHashMode value for hash mode on the QA API. * * @param[in] apiHashAlgorithm value for hash algorithm on the QA API. * * @param[out] pQatAlgorithm Pointer to return fw qat value for *algorithm. * * @param[out] pQatNested Pointer to return fw qat value for nested. * * * @return * none * *****************************************************************************/ void LacSymQat_HashGetCfgData(CpaInstanceHandle pInstance, icp_qat_hw_auth_mode_t qatHashMode, CpaCySymHashMode apiHashMode, CpaCySymHashAlgorithm apiHashAlgorithm, icp_qat_hw_auth_algo_t *pQatAlgorithm, CpaBoolean *pQatNested); void LacSymQat_HashSetupReqParamsMetaData( icp_qat_la_bulk_req_ftr_t *pMsg, CpaInstanceHandle instanceHandle, const CpaCySymHashSetupData *pHashSetupData, CpaBoolean hashStateBuffer, icp_qat_hw_auth_mode_t qatHashMode, CpaBoolean digestVerify); #endif /* LAC_SYM_QAT_HASH_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash_defs_lookup.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash_defs_lookup.h index decc5d8c491b..050dd42ba9b2 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash_defs_lookup.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_qat_hash_defs_lookup.h @@ -1,138 +1,138 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_qat_hash_defs_lookup.h * * @defgroup LacSymQatHashDefsLookup Hash Defs Lookup * * @ingroup LacSymQatHash * * API to be used for the hash defs lookup table. * *****************************************************************************/ #ifndef LAC_SYM_QAT_HASH_DEFS_LOOKUP_P_H #define LAC_SYM_QAT_HASH_DEFS_LOOKUP_P_H #include "cpa.h" #include "cpa_cy_sym.h" /** ****************************************************************************** * @ingroup LacSymQatHashDefsLookup * Finishing Hash algorithm * @description * This define points to the last available hash algorithm * @NOTE: If a new algorithm is added to the api, this #define * MUST be updated to being the last hash algorithm in the struct * CpaCySymHashAlgorithm in the file cpa_cy_sym.h *****************************************************************************/ #define CPA_CY_HASH_ALG_END CPA_CY_SYM_HASH_SM3 /***************************************************************************/ /** ****************************************************************************** * @ingroup LacSymQatHashDefsLookup * hash algorithm specific structure * @description * This structure contain constants specific to an algorithm. *****************************************************************************/ typedef struct lac_sym_qat_hash_alg_info_s { Cpa32U digestLength; /**< Digest length in bytes */ Cpa32U blockLength; /**< Block length in bytes */ Cpa8U *initState; /**< Initialiser state for hash algorithm */ Cpa32U stateSize; /**< size of above state in bytes */ } lac_sym_qat_hash_alg_info_t; /** ****************************************************************************** * @ingroup LacSymQatHashDefsLookup * hash qat specific structure * @description * This structure contain constants as defined by the QAT for an * algorithm. *****************************************************************************/ typedef struct lac_sym_qat_hash_qat_info_s { Cpa32U algoEnc; /**< QAT Algorithm encoding */ Cpa32U authCounter; /**< Counter value for Auth */ Cpa32U state1Length; /**< QAT state1 length in bytes */ Cpa32U state2Length; /**< QAT state2 length in bytes */ } lac_sym_qat_hash_qat_info_t; /** ****************************************************************************** * @ingroup LacSymQatHashDefsLookup * hash defs structure * @description * This type contains pointers to the hash algorithm structure and * to the hash qat specific structure *****************************************************************************/ typedef struct lac_sym_qat_hash_defs_s { lac_sym_qat_hash_alg_info_t *algInfo; /**< pointer to hash info structure */ lac_sym_qat_hash_qat_info_t *qatInfo; /**< pointer to hash QAT info structure */ } lac_sym_qat_hash_defs_t; /** ******************************************************************************* * @ingroup LacSymQatHashDefsLookup * initialise the hash lookup table * * @description * This function initialises the digest lookup table. * * @note * This function does not have a corresponding shutdown function. * * @return CPA_STATUS_SUCCESS Operation successful * @return CPA_STATUS_RESOURCE Allocating of hash lookup table failed * *****************************************************************************/ CpaStatus LacSymQat_HashLookupInit(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacSymQatHashDefsLookup * get hash algorithm specific structure from lookup table * * @description * This function looks up the hash lookup array for a structure * containing data specific to a hash algorithm. The hashAlgorithm enum * value MUST be in the correct range prior to calling this function. * * @param[in] hashAlgorithm Hash Algorithm * @param[out] ppHashAlgInfo Hash Alg Info structure * * @return None * *****************************************************************************/ void LacSymQat_HashAlgLookupGet(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, lac_sym_qat_hash_alg_info_t **ppHashAlgInfo); /** ******************************************************************************* * @ingroup LacSymQatHashDefsLookup -* get hash defintions from lookup table. +* get hash definitions from lookup table. * * @description * This function looks up the hash lookup array for a structure * containing data specific to a hash algorithm. This includes both * algorithm specific info and qat specific infro. The hashAlgorithm enum * value MUST be in the correct range prior to calling this function. * * @param[in] hashAlgorithm Hash Algorithm * @param[out] ppHashDefsInfo Hash Defs structure * * @return void * *****************************************************************************/ void LacSymQat_HashDefsLookupGet(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, lac_sym_qat_hash_defs_t **ppHashDefsInfo); #endif /* LAC_SYM_QAT_HASH_DEFS_LOOKUP_P_H */ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_stats.h b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_stats.h index 96f579b26c4c..ac7439713681 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_stats.h +++ b/sys/dev/qat/qat_api/common/crypto/sym/include/lac_sym_stats.h @@ -1,190 +1,190 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_stats.h * * @defgroup LacSymCommon Symmetric Common * * @ingroup LacSym * - * Symetric Common consists of common statistics, buffer and partial packet + * Symmetric Common consists of common statistics, buffer and partial packet * functionality. * ***************************************************************************/ /** *************************************************************************** * @defgroup LacSymStats Statistics * * @ingroup LacSymCommon * * definitions and prototypes for LAC symmetric statistics. * * @lld_start * In the LAC API the stats fields are defined as Cpa32U but * QatUtilsAtomic is the type that the atomic API supports. Therefore we * need to define a structure internally with the same fields as the API * stats structure, but each field must be of type QatUtilsAtomic. * * - Incrementing Statistics:\n * Atomically increment the statistic on the internal stats structure. * * - Providing a copy of the stats back to the user:\n * Use atomicGet to read the atomic variable for each stat field in the * local internal stat structure. These values are saved in structure * (as defined by the LAC API) that the client will provide a pointer * to as a parameter. * * - Stats Show:\n * Use atomicGet to read the atomic variables for each field in the local * internal stat structure and print to the screen * * - Stats Array:\n * A macro is used to get the offset off the stat in the structure. This * offset is passed to a function which uses it to increment the stat * at that offset. * * @lld_end * ***************************************************************************/ /***************************************************************************/ #ifndef LAC_SYM_STATS_H #define LAC_SYM_STATS_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "cpa_cy_sym.h" #include "cpa_cy_common.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ /** ******************************************************************************* * @ingroup LacSymStats * increment a symmetric statistic * * @description * Increment the statistics * * @param statistic IN The field in the symmetric statistics structure to be * incremented * @param instanceHandle IN engine Id Number * * @retval None * *****************************************************************************/ #define LAC_SYM_STAT_INC(statistic, instanceHandle) \ LacSym_StatsInc(offsetof(CpaCySymStats64, statistic), instanceHandle) /** ******************************************************************************* * @ingroup LacSymStats * initialises the symmetric stats * * @description * This function allocates and initialises the stats array to 0 * * @param instanceHandle Instance Handle * * @retval CPA_STATUS_SUCCESS initialisation successful * @retval CPA_STATUS_RESOURCE array allocation failed * *****************************************************************************/ CpaStatus LacSym_StatsInit(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacSymStats * Frees the symmetric stats * * @description * This function frees the stats array * * @param instanceHandle Instance Handle * * @retval None * *****************************************************************************/ void LacSym_StatsFree(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacSymStats -* Inrement a stat +* Increment a stat * * @description * This function incrementes a stat for a specific engine. * * @param offset IN offset of stat field in structure * @param instanceHandle IN qat Handle * * @retval None * *****************************************************************************/ void LacSym_StatsInc(Cpa32U offset, CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacSymStats * Copy the contents of the statistics structure for an engine * * @description * This function copies the 32bit symmetric statistics structure for * a specific engine into an address supplied as a parameter. * * @param instanceHandle IN engine Id Number * @param pSymStats OUT stats structure to copy the stats for the into * * @retval None * *****************************************************************************/ void LacSym_Stats32CopyGet(CpaInstanceHandle instanceHandle, struct _CpaCySymStats *const pSymStats); /** ******************************************************************************* * @ingroup LacSymStats * Copy the contents of the statistics structure for an engine * * @description * This function copies the 64bit symmetric statistics structure for * a specific engine into an address supplied as a parameter. * * @param instanceHandle IN engine Id Number * @param pSymStats OUT stats structure to copy the stats for the into * * @retval None * *****************************************************************************/ void LacSym_Stats64CopyGet(CpaInstanceHandle instanceHandle, CpaCySymStats64 *const pSymStats); /** ******************************************************************************* * @ingroup LacSymStats * print the symmetric stats to standard output * * @description * The statistics for symmetric are printed to standard output. * * @retval None * * @see LacSym_StatsCopyGet() * *****************************************************************************/ void LacSym_StatsShow(CpaInstanceHandle instanceHandle); #endif /*LAC_SYM_STATS_H_*/ diff --git a/sys/dev/qat/qat_api/common/crypto/sym/key/lac_sym_key.c b/sys/dev/qat/qat_api/common/crypto/sym/key/lac_sym_key.c index cab8d6c7796c..965874e7466f 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/key/lac_sym_key.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/key/lac_sym_key.c @@ -1,3016 +1,3006 @@ -/*************************************************************************** - * - * - * - ***************************************************************************/ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_key.c * * @ingroup LacSymKey * * This file contains the implementation of all keygen functionality * *****************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_key.h" #include "cpa_cy_im.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "qat_utils.h" #include "lac_log.h" #include "lac_hooks.h" #include "lac_sym.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sym_qat.h" #include "lac_sal.h" #include "lac_sym_key.h" #include "lac_sal_types_crypto.h" #include "sal_service_state.h" #include "lac_sym_qat_key.h" #include "lac_sym_hash_defs.h" #include "sal_statistics.h" /* Number of statistics */ #define LAC_KEY_NUM_STATS (sizeof(CpaCyKeyGenStats64) / sizeof(Cpa64U)) #define LAC_KEY_STAT_INC(statistic, instanceHandle) \ do { \ sal_crypto_service_t *pService = NULL; \ pService = (sal_crypto_service_t *)instanceHandle; \ if (CPA_TRUE == \ pService->generic_service_info.stats \ ->bKeyGenStatsEnabled) { \ qatUtilsAtomicInc( \ &pService \ ->pLacKeyStats[offsetof(CpaCyKeyGenStats64, \ statistic) / \ sizeof(Cpa64U)]); \ } \ } while (0) /**< Macro to increment a Key stat (derives offset into array of atomics) */ #define LAC_KEY_STATS32_GET(keyStats, instanceHandle) \ do { \ int i; \ sal_crypto_service_t *pService = \ (sal_crypto_service_t *)instanceHandle; \ for (i = 0; i < LAC_KEY_NUM_STATS; i++) { \ ((Cpa32U *)&(keyStats))[i] = \ (Cpa32U)qatUtilsAtomicGet( \ &pService->pLacKeyStats[i]); \ } \ } while (0) /**< Macro to get all 32bit Key stats (from internal array of atomics) */ #define LAC_KEY_STATS64_GET(keyStats, instanceHandle) \ do { \ int i; \ sal_crypto_service_t *pService = \ (sal_crypto_service_t *)instanceHandle; \ for (i = 0; i < LAC_KEY_NUM_STATS; i++) { \ ((Cpa64U *)&(keyStats))[i] = \ qatUtilsAtomicGet(&pService->pLacKeyStats[i]); \ } \ } while (0) /**< Macro to get all 64bit Key stats (from internal array of atomics) */ #define IS_HKDF_UNSUPPORTED(cmdId, hkdfSupported) \ ((ICP_QAT_FW_LA_CMD_HKDF_EXTRACT <= cmdId && \ ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL >= cmdId) && \ !hkdfSupported) /**< macro to check whether the HKDF algorithm can be \ supported on the device */ /* Sublabel for HKDF TLS Key Generation, as defined in RFC8446. */ const static Cpa8U key256[HKDF_SUB_LABEL_KEY_LENGTH] = { 0, 16, 9, 't', 'l', 's', '1', '3', ' ', 'k', 'e', 'y', 0 }; const static Cpa8U key384[HKDF_SUB_LABEL_KEY_LENGTH] = { 0, 32, 9, 't', 'l', 's', '1', '3', ' ', 'k', 'e', 'y', 0 }; const static Cpa8U keyChaChaPoly[HKDF_SUB_LABEL_KEY_LENGTH] = { 0, 32, 9, 't', 'l', 's', '1', '3', ' ', 'k', 'e', 'y', 0 }; /* Sublabel for HKDF TLS IV key Generation, as defined in RFC8446. */ const static Cpa8U iv256[HKDF_SUB_LABEL_IV_LENGTH] = { 0, 12, 8, 't', 'l', 's', '1', '3', ' ', 'i', 'v', 0 }; const static Cpa8U iv384[HKDF_SUB_LABEL_IV_LENGTH] = { 0, 12, 8, 't', 'l', 's', '1', '3', ' ', 'i', 'v', 0 }; /* Sublabel for HKDF TLS RESUMPTION key Generation, as defined in RFC8446. */ const static Cpa8U resumption256[HKDF_SUB_LABEL_RESUMPTION_LENGTH] = { 0, 32, 16, 't', 'l', 's', '1', '3', ' ', 'r', 'e', 's', 'u', 'm', 'p', 't', 'i', 'o', 'n', 0 }; const static Cpa8U resumption384[HKDF_SUB_LABEL_RESUMPTION_LENGTH] = { 0, 48, 16, 't', 'l', 's', '1', '3', ' ', 'r', 'e', 's', 'u', 'm', 'p', 't', 'i', 'o', 'n', 0 }; /* Sublabel for HKDF TLS FINISHED key Generation, as defined in RFC8446. */ const static Cpa8U finished256[HKDF_SUB_LABEL_FINISHED_LENGTH] = { 0, 32, 14, 't', 'l', 's', '1', '3', ' ', 'f', 'i', 'n', 'i', 's', 'h', 'e', 'd', 0 }; const static Cpa8U finished384[HKDF_SUB_LABEL_FINISHED_LENGTH] = { 0, 48, 14, 't', 'l', 's', '1', '3', ' ', 'f', 'i', 'n', 'i', 's', 'h', 'e', 'd', 0 }; /** ****************************************************************************** * @ingroup LacSymKey * SSL/TLS stat type * * @description * This enum determines which stat should be incremented *****************************************************************************/ typedef enum { LAC_KEY_REQUESTS = 0, /**< Key requests sent */ LAC_KEY_REQUEST_ERRORS, /**< Key requests errors */ LAC_KEY_COMPLETED, /**< Key requests which received responses */ LAC_KEY_COMPLETED_ERRORS /**< Key requests which received responses with errors */ } lac_key_stat_type_t; /*** Local functions prototypes ***/ static void LacSymKey_MgfHandleResponse(icp_qat_fw_la_cmd_id_t lacCmdId, void *pOpaqueData, icp_qat_fw_comn_flags cmnRespFlags); static CpaStatus LacSymKey_MgfSync(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const void *pKeyGenMgfOpData, CpaFlatBuffer *pGeneratedMaskBuffer, CpaBoolean bIsExtRequest); static void LacSymKey_SslTlsHandleResponse(icp_qat_fw_la_cmd_id_t lacCmdId, void *pOpaqueData, icp_qat_fw_comn_flags cmnRespFlags); static CpaStatus LacSymKey_SslTlsSync(CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, icp_qat_fw_la_cmd_id_t lacCmdId, void *pKeyGenSslTlsOpData, Cpa8U hashAlgorithm, CpaFlatBuffer *pKeyGenOutpuData); /*** Implementation ***/ /** ****************************************************************************** * @ingroup LacSymKey * Get the instance handle. Support single handle. * @param[in] instanceHandle_in user supplied handle. * @retval CpaInstanceHandle the instance handle */ static CpaInstanceHandle LacKey_GetHandle(CpaInstanceHandle instanceHandle_in) { CpaInstanceHandle instanceHandle = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } return instanceHandle; } /** ******************************************************************************* * @ingroup LacSymKey * Perform SSL/TLS key gen operation * * @description * Perform SSL/TLS key gen operation * * @param[in] instanceHandle QAT device handle. * @param[in] pKeyGenCb Pointer to callback function to be invoked * when the operation is complete. * @param[in] pCallbackTag Opaque User Data for this specific call. * @param[in] lacCmdId Lac command ID (identify SSL & TLS ops) * @param[in] pKeyGenSslTlsOpData Structure containing all the data needed to * perform the SSL/TLS key generation * operation. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pKeyGenOutputData pointer to where output result should be * written * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Function should be retried. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * *****************************************************************************/ static CpaStatus LacSymKey_KeyGenSslTls_GenCommon(CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, icp_qat_fw_la_cmd_id_t lacCmdId, void *pKeyGenSslTlsOpData, Cpa8U hashAlgorithm, CpaFlatBuffer *pKeyGenOutputData); /** ****************************************************************************** * @ingroup LacSymKey * Increment stat for TLS or SSL operation * * @description * This is a generic function to update the stats for either a TLS or SSL * operation. * * @param[in] lacCmdId Indicate SSL or TLS operations * @param[in] statType Statistics Type * @param[in] instanceHandle Instance Handle * * @return None * *****************************************************************************/ static void LacKey_StatsInc(icp_qat_fw_la_cmd_id_t lacCmdId, lac_key_stat_type_t statType, CpaInstanceHandle instanceHandle) { if (ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE == lacCmdId) { switch (statType) { case LAC_KEY_REQUESTS: LAC_KEY_STAT_INC(numSslKeyGenRequests, instanceHandle); break; case LAC_KEY_REQUEST_ERRORS: LAC_KEY_STAT_INC(numSslKeyGenRequestErrors, instanceHandle); break; case LAC_KEY_COMPLETED: LAC_KEY_STAT_INC(numSslKeyGenCompleted, instanceHandle); break; case LAC_KEY_COMPLETED_ERRORS: LAC_KEY_STAT_INC(numSslKeyGenCompletedErrors, instanceHandle); break; default: QAT_UTILS_LOG("Invalid statistics type\n"); break; } } else /* TLS v1.0/1.1 and 1.2 */ { switch (statType) { case LAC_KEY_REQUESTS: LAC_KEY_STAT_INC(numTlsKeyGenRequests, instanceHandle); break; case LAC_KEY_REQUEST_ERRORS: LAC_KEY_STAT_INC(numTlsKeyGenRequestErrors, instanceHandle); break; case LAC_KEY_COMPLETED: LAC_KEY_STAT_INC(numTlsKeyGenCompleted, instanceHandle); break; case LAC_KEY_COMPLETED_ERRORS: LAC_KEY_STAT_INC(numTlsKeyGenCompletedErrors, instanceHandle); break; default: QAT_UTILS_LOG("Invalid statistics type\n"); break; } } } void LacKeygen_StatsShow(CpaInstanceHandle instanceHandle) { CpaCyKeyGenStats64 keyStats = { 0 }; LAC_KEY_STATS64_GET(keyStats, instanceHandle); QAT_UTILS_LOG(SEPARATOR BORDER " Key Stats: " BORDER "\n" SEPARATOR); QAT_UTILS_LOG(BORDER " SSL Key Requests: %16llu " BORDER "\n" BORDER " SSL Key Request Errors: %16llu " BORDER "\n" BORDER " SSL Key Completed %16llu " BORDER "\n" BORDER " SSL Key Complete Errors: %16llu " BORDER "\n" SEPARATOR, (unsigned long long)keyStats.numSslKeyGenRequests, (unsigned long long)keyStats.numSslKeyGenRequestErrors, (unsigned long long)keyStats.numSslKeyGenCompleted, (unsigned long long)keyStats.numSslKeyGenCompletedErrors); QAT_UTILS_LOG(BORDER " TLS Key Requests: %16llu " BORDER "\n" BORDER " TLS Key Request Errors: %16llu " BORDER "\n" BORDER " TLS Key Completed %16llu " BORDER "\n" BORDER " TLS Key Complete Errors: %16llu " BORDER "\n" SEPARATOR, (unsigned long long)keyStats.numTlsKeyGenRequests, (unsigned long long)keyStats.numTlsKeyGenRequestErrors, (unsigned long long)keyStats.numTlsKeyGenCompleted, (unsigned long long)keyStats.numTlsKeyGenCompletedErrors); QAT_UTILS_LOG(BORDER " MGF Key Requests: %16llu " BORDER "\n" BORDER " MGF Key Request Errors: %16llu " BORDER "\n" BORDER " MGF Key Completed %16llu " BORDER "\n" BORDER " MGF Key Complete Errors: %16llu " BORDER "\n" SEPARATOR, (unsigned long long)keyStats.numMgfKeyGenRequests, (unsigned long long)keyStats.numMgfKeyGenRequestErrors, (unsigned long long)keyStats.numMgfKeyGenCompleted, (unsigned long long)keyStats.numMgfKeyGenCompletedErrors); } /** @ingroup LacSymKey */ CpaStatus cpaCyKeyGenQueryStats(CpaInstanceHandle instanceHandle_in, struct _CpaCyKeyGenStats *pSymKeyStats) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSymKeyStats); SAL_RUNNING_CHECK(instanceHandle); LAC_KEY_STATS32_GET(*pSymKeyStats, instanceHandle); return CPA_STATUS_SUCCESS; } /** @ingroup LacSymKey */ CpaStatus cpaCyKeyGenQueryStats64(CpaInstanceHandle instanceHandle_in, CpaCyKeyGenStats64 *pSymKeyStats) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSymKeyStats); SAL_RUNNING_CHECK(instanceHandle); LAC_KEY_STATS64_GET(*pSymKeyStats, instanceHandle); return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup LacSymKey * Return the size of the digest for a specific hash algorithm. * @description * Return the expected digest size based on the sha algorithm submitted. * The only supported value are sha256, sha384 and sha512. * * @param[in] hashAlgorithm either sha256, sha384 or sha512. * @return the expected size or 0 for an invalid hash. * *****************************************************************************/ static Cpa32U getDigestSizeFromHashAlgo(CpaCySymHashAlgorithm hashAlgorithm) { switch (hashAlgorithm) { case CPA_CY_SYM_HASH_SHA256: return LAC_HASH_SHA256_DIGEST_SIZE; case CPA_CY_SYM_HASH_SHA384: return LAC_HASH_SHA384_DIGEST_SIZE; case CPA_CY_SYM_HASH_SHA512: return LAC_HASH_SHA512_DIGEST_SIZE; case CPA_CY_SYM_HASH_SM3: return LAC_HASH_SM3_DIGEST_SIZE; default: return 0; } } /** ****************************************************************************** * @ingroup LacSymKey * Return the hash algorithm for a specific cipher. * @description * Return the hash algorithm related to the cipher suite. * Supported hash's are SHA256, and SHA384. * * @param[in] cipherSuite AES_128_GCM, AES_256_GCM, AES_128_CCM, * and CHACHA20_POLY1305. * @return the expected hash algorithm or 0 for an invalid cipher. * *****************************************************************************/ static CpaCySymHashAlgorithm getHashAlgorithmFromCipherSuiteHKDF(CpaCyKeyHKDFCipherSuite cipherSuite) { switch (cipherSuite) { case CPA_CY_HKDF_TLS_AES_128_GCM_SHA256: /* Fall through */ case CPA_CY_HKDF_TLS_CHACHA20_POLY1305_SHA256: case CPA_CY_HKDF_TLS_AES_128_CCM_SHA256: case CPA_CY_HKDF_TLS_AES_128_CCM_8_SHA256: return CPA_CY_SYM_HASH_SHA256; case CPA_CY_HKDF_TLS_AES_256_GCM_SHA384: return CPA_CY_SYM_HASH_SHA384; default: return 0; } } /** ****************************************************************************** * @ingroup LacSymKey * Return the digest size of cipher. * @description * Return the output key size of specific cipher, for specified sub label * * @param[in] cipherSuite = AES_128_GCM, AES_256_GCM, AES_128_CCM, * and CHACHA20_POLY1305. * subLabels = KEY, IV, RESUMPTION, and FINISHED. * @return the expected digest size of the cipher. * *****************************************************************************/ static const Cpa32U cipherSuiteHKDFHashSizes [LAC_KEY_HKDF_CIPHERS_MAX][LAC_KEY_HKDF_SUBLABELS_MAX] = { {}, /* Not used */ { 32, 16, 12, 32, 32 }, /* AES_128_GCM_SHA256 */ { 48, 32, 12, 48, 48 }, /* AES_256_GCM_SHA384 */ { 32, 32, 12, 32, 32 }, /* CHACHA20_POLY1305_SHA256 */ { 32, 16, 12, 32, 32 }, /* AES_128_CCM_SHA256 */ { 32, 16, 12, 32, 32 } /* AES_128_CCM_8_SHA256 */ }; /** ****************************************************************************** * @ingroup LacSymKey * Key Generation MGF response handler * * @description * Handles Key Generation MGF response messages from the QAT. * * @param[in] lacCmdId Command id of the original request * @param[in] pOpaqueData Pointer to opaque data that was in request * @param[in] cmnRespFlags Indicates whether request succeeded * * @return void * *****************************************************************************/ static void LacSymKey_MgfHandleResponse(icp_qat_fw_la_cmd_id_t lacCmdId, void *pOpaqueData, icp_qat_fw_comn_flags cmnRespFlags) { CpaCyKeyGenMgfOpData *pMgfOpData = NULL; lac_sym_key_cookie_t *pCookie = NULL; CpaCyGenFlatBufCbFunc pKeyGenMgfCb = NULL; void *pCallbackTag = NULL; CpaFlatBuffer *pGeneratedKeyBuffer = NULL; CpaStatus status = CPA_STATUS_SUCCESS; CpaBoolean respStatusOk = (ICP_QAT_FW_COMN_STATUS_FLAG_OK == ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(cmnRespFlags)) ? CPA_TRUE : CPA_FALSE; pCookie = (lac_sym_key_cookie_t *)pOpaqueData; if (CPA_TRUE == respStatusOk) { status = CPA_STATUS_SUCCESS; LAC_KEY_STAT_INC(numMgfKeyGenCompleted, pCookie->instanceHandle); } else { status = CPA_STATUS_FAIL; LAC_KEY_STAT_INC(numMgfKeyGenCompletedErrors, pCookie->instanceHandle); } pKeyGenMgfCb = (CpaCyGenFlatBufCbFunc)(pCookie->pKeyGenCb); pMgfOpData = pCookie->pKeyGenOpData; pCallbackTag = pCookie->pCallbackTag; pGeneratedKeyBuffer = pCookie->pKeyGenOutputData; Lac_MemPoolEntryFree(pCookie); (*pKeyGenMgfCb)(pCallbackTag, status, pMgfOpData, pGeneratedKeyBuffer); } /** ****************************************************************************** * @ingroup LacSymKey * Synchronous mode of operation wrapper function * * @description * Wrapper function to implement synchronous mode of operation for * cpaCyKeyGenMgf and cpaCyKeyGenMgfExt function. * * @param[in] instanceHandle Instance handle * @param[in] pKeyGenCb Internal callback function pointer * @param[in] pCallbackTag Callback tag * @param[in] pKeyGenMgfOpData Pointer to user provided Op Data structure * @param[in] pGeneratedMaskBuffer Pointer to a buffer where generated mask * will be stored * @param[in] bIsExtRequest Indicates origin of function call; * if CPA_TRUE then the call comes from * cpaCyKeyGenMgfExt function, otherwise * from cpaCyKeyGenMgf * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Function should be retried. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * *****************************************************************************/ static CpaStatus LacSymKey_MgfSync(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const void *pKeyGenMgfOpData, CpaFlatBuffer *pGeneratedMaskBuffer, CpaBoolean bIsExtRequest) { CpaStatus status = CPA_STATUS_SUCCESS; lac_sync_op_data_t *pSyncCallbackData = NULL; status = LacSync_CreateSyncCookie(&pSyncCallbackData); if (CPA_STATUS_SUCCESS == status) { if (CPA_TRUE == bIsExtRequest) { status = cpaCyKeyGenMgfExt( instanceHandle, LacSync_GenFlatBufCb, pSyncCallbackData, (const CpaCyKeyGenMgfOpDataExt *)pKeyGenMgfOpData, pGeneratedMaskBuffer); } else { status = cpaCyKeyGenMgf(instanceHandle, LacSync_GenFlatBufCb, pSyncCallbackData, (const CpaCyKeyGenMgfOpData *) pKeyGenMgfOpData, pGeneratedMaskBuffer); } } else { /* Failure allocating sync cookie */ LAC_KEY_STAT_INC(numMgfKeyGenRequestErrors, instanceHandle); return status; } if (CPA_STATUS_SUCCESS == status) { CpaStatus syncStatus = CPA_STATUS_SUCCESS; syncStatus = LacSync_WaitForCallback(pSyncCallbackData, LAC_SYM_SYNC_CALLBACK_TIMEOUT, &status, NULL); /* If callback doesn't come back */ if (CPA_STATUS_SUCCESS != syncStatus) { LAC_KEY_STAT_INC(numMgfKeyGenCompletedErrors, instanceHandle); LAC_LOG_ERROR("Callback timed out"); status = syncStatus; } } else { /* As the Request was not sent the Callback will never * be called, so need to indicate that we're finished * with cookie so it can be destroyed. */ LacSync_SetSyncCookieComplete(pSyncCallbackData); } LacSync_DestroySyncCookie(&pSyncCallbackData); return status; } /** ****************************************************************************** * @ingroup LacSymKey * Perform MGF key gen operation * * @description * This function performs MGF key gen operation. It is common for requests * coming from both cpaCyKeyGenMgf and cpaCyKeyGenMgfExt QAT API * functions. * * @param[in] instanceHandle Instance handle * @param[in] pKeyGenCb Pointer to callback function to be invoked * when the operation is complete. * @param[in] pCallbackTag Opaque User Data for this specific call. * @param[in] pOpData Pointer to the Op Data structure provided by * the user in API function call. For calls * originating from cpaCyKeyGenMgfExt it will * point to CpaCyKeyGenMgfOpDataExt type of * structure while for calls originating from * cpaCyKeyGenMgf it will point to * CpaCyKeyGenMgfOpData type of structure. * @param[in] pKeyGenMgfOpData Pointer to the user provided * CpaCyKeyGenMgfOpData structure. For calls * originating from cpaCyKeyGenMgf it will * point to the same structure as pOpData * parameter; for calls originating from * cpaCyKeyGenMgfExt it will point to the * baseOpData member of the * CpaCyKeyGenMgfOpDataExt structure passed in * as a parameter to the API function call. * @param[in] pGeneratedMaskBuffer Pointer to a buffer where generated mask * will be stored * @param[in] hashAlgorithm Indicates which hash algorithm is to be used * to perform MGF key gen operation. For calls * originating from cpaCyKeyGenMgf it will * always be CPA_CY_SYM_HASH_SHA1. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Function should be retried. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * *****************************************************************************/ static CpaStatus LacSymKey_MgfCommon(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const void *pOpData, const CpaCyKeyGenMgfOpData *pKeyGenMgfOpData, CpaFlatBuffer *pGeneratedMaskBuffer, CpaCySymHashAlgorithm hashAlgorithm) { CpaStatus status = CPA_STATUS_SUCCESS; icp_qat_fw_la_bulk_req_t keyGenReq = { { 0 } }; icp_qat_la_bulk_req_hdr_t keyGenReqHdr = { { 0 } }; icp_qat_fw_la_key_gen_common_t keyGenReqMid = { { 0 } }; icp_qat_la_bulk_req_ftr_t keyGenReqFtr = { { { 0 } } }; Cpa8U *pMsgDummy = NULL; Cpa8U *pCacheDummyHdr = NULL; Cpa8U *pCacheDummyMid = NULL; Cpa8U *pCacheDummyFtr = NULL; sal_qat_content_desc_info_t contentDescInfo = { 0 }; lac_sym_key_cookie_t *pCookie = NULL; lac_sym_cookie_t *pSymCookie = NULL; sal_crypto_service_t *pService = NULL; Cpa64U inputPhysAddr = 0; Cpa64U outputPhysAddr = 0; /* Structure initializer is supported by C99, but it is * not supported by some former Intel compiler. */ CpaCySymHashSetupData hashSetupData = { 0 }; Cpa32U hashBlkSizeInBytes = 0; lac_sym_qat_hash_alg_info_t *pHashAlgInfo = NULL; icp_qat_fw_serv_specif_flags laCmdFlags = 0; icp_qat_fw_comn_flags cmnRequestFlags = ICP_QAT_FW_COMN_FLAGS_BUILD(QAT_COMN_PTR_TYPE_FLAT, QAT_COMN_CD_FLD_TYPE_64BIT_ADR); pService = (sal_crypto_service_t *)instanceHandle; LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); SAL_RUNNING_CHECK(instanceHandle); LAC_CHECK_NULL_PARAM(pOpData); LAC_CHECK_NULL_PARAM(pKeyGenMgfOpData); LAC_CHECK_NULL_PARAM(pGeneratedMaskBuffer); LAC_CHECK_NULL_PARAM(pGeneratedMaskBuffer->pData); LAC_CHECK_NULL_PARAM(pKeyGenMgfOpData->seedBuffer.pData); /* Maximum seed length for MGF1 request */ if (pKeyGenMgfOpData->seedBuffer.dataLenInBytes > ICP_QAT_FW_LA_MGF_SEED_LEN_MAX) { LAC_INVALID_PARAM_LOG("seedBuffer.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* Maximum mask length for MGF1 request */ if (pKeyGenMgfOpData->maskLenInBytes > ICP_QAT_FW_LA_MGF_MASK_LEN_MAX) { LAC_INVALID_PARAM_LOG("maskLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* check for enough space in the flat buffer */ if (pKeyGenMgfOpData->maskLenInBytes > pGeneratedMaskBuffer->dataLenInBytes) { LAC_INVALID_PARAM_LOG("pGeneratedMaskBuffer.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* Get hash alg info */ LacSymQat_HashAlgLookupGet(instanceHandle, hashAlgorithm, &pHashAlgInfo); /* Allocate the cookie */ pCookie = (lac_sym_key_cookie_t *)Lac_MemPoolEntryAlloc( pService->lac_sym_cookie_pool); if (NULL == pCookie) { LAC_LOG_ERROR("Cannot get mem pool entry"); status = CPA_STATUS_RESOURCE; } else if ((void *)CPA_STATUS_RETRY == pCookie) { pCookie = NULL; status = CPA_STATUS_RETRY; } else { pSymCookie = (lac_sym_cookie_t *)pCookie; } if (CPA_STATUS_SUCCESS == status) { /* populate the cookie */ pCookie->instanceHandle = instanceHandle; pCookie->pCallbackTag = pCallbackTag; pCookie->pKeyGenOpData = (void *)LAC_CONST_PTR_CAST(pOpData); pCookie->pKeyGenCb = pKeyGenCb; pCookie->pKeyGenOutputData = pGeneratedMaskBuffer; hashSetupData.hashAlgorithm = hashAlgorithm; hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_PLAIN; hashSetupData.digestResultLenInBytes = pHashAlgInfo->digestLength; /* Populate the CD ctrl Block (LW 27 - LW 31) * and the CD Hash HW setup block */ LacSymQat_HashContentDescInit( &(keyGenReqFtr), instanceHandle, &hashSetupData, /* point to base of hw setup block */ (Cpa8U *)pCookie->contentDesc, LAC_SYM_KEY_NO_HASH_BLK_OFFSET_QW, ICP_QAT_FW_SLICE_DRAM_WR, ICP_QAT_HW_AUTH_MODE0, /* just a plain hash */ CPA_FALSE, /* Not using sym Constants Table in Shared SRAM */ CPA_FALSE, /* not using the optimised Content Desc */ CPA_FALSE, /* Not using the stateful SHA3 Content Desc */ NULL, &hashBlkSizeInBytes); /* Populate the Req param LW 14-26 */ LacSymQat_KeyMgfRequestPopulate( &keyGenReqHdr, &keyGenReqMid, pKeyGenMgfOpData->seedBuffer.dataLenInBytes, pKeyGenMgfOpData->maskLenInBytes, (Cpa8U)pHashAlgInfo->digestLength); contentDescInfo.pData = pCookie->contentDesc; contentDescInfo.hardwareSetupBlockPhys = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyContentDescPhyAddr); contentDescInfo.hwBlkSzQuadWords = LAC_BYTES_TO_QUADWORDS(hashBlkSizeInBytes); /* Populate common request fields */ inputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64(LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, pKeyGenMgfOpData->seedBuffer.pData)); if (inputPhysAddr == 0) { LAC_LOG_ERROR( "Unable to get the seed buffer physical address"); status = CPA_STATUS_FAIL; } outputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64( LAC_OS_VIRT_TO_PHYS_EXTERNAL(pService->generic_service_info, pGeneratedMaskBuffer->pData)); if (outputPhysAddr == 0) { LAC_LOG_ERROR( "Unable to get the physical address of the mask"); status = CPA_STATUS_FAIL; } } if (CPA_STATUS_SUCCESS == status) { /* Make up the full keyGenReq struct from its constituents */ pMsgDummy = (Cpa8U *)&(keyGenReq); pCacheDummyHdr = (Cpa8U *)&(keyGenReqHdr); pCacheDummyMid = (Cpa8U *)&(keyGenReqMid); pCacheDummyFtr = (Cpa8U *)&(keyGenReqFtr); memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memset((pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)), 0, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_TO_CLEAR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_MID_IN_LW), pCacheDummyMid, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_MID_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); SalQatMsg_ContentDescHdrWrite((icp_qat_fw_comn_req_t *)&( keyGenReq), &(contentDescInfo)); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)&keyGenReq, ICP_QAT_FW_COMN_REQ_CPM_FW_LA, ICP_QAT_FW_LA_CMD_MGF1, cmnRequestFlags, laCmdFlags); /* * MGF uses a flat buffer but we can use zero for source and * dest length because the firmware will use the seed length, * hash length and mask length to find source length. */ SalQatMsg_CmnMidWrite((icp_qat_fw_la_bulk_req_t *)&(keyGenReq), pCookie, LAC_SYM_KEY_QAT_PTR_TYPE, inputPhysAddr, outputPhysAddr, 0, 0); /* Send to QAT */ status = icp_adf_transPutMsg(pService->trans_handle_sym_tx, (void *)&(keyGenReq), LAC_QAT_SYM_REQ_SZ_LW); } if (CPA_STATUS_SUCCESS == status) { /* Update stats */ LAC_KEY_STAT_INC(numMgfKeyGenRequests, instanceHandle); } else { LAC_KEY_STAT_INC(numMgfKeyGenRequestErrors, instanceHandle); /* clean up memory */ if (NULL != pCookie) { Lac_MemPoolEntryFree(pCookie); } } return status; } /** * cpaCyKeyGenMgf */ CpaStatus cpaCyKeyGenMgf(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenMgfOpData *pKeyGenMgfOpData, CpaFlatBuffer *pGeneratedMaskBuffer) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } /* If synchronous Operation */ if (NULL == pKeyGenCb) { return LacSymKey_MgfSync(instanceHandle, pKeyGenCb, pCallbackTag, (const void *)pKeyGenMgfOpData, pGeneratedMaskBuffer, CPA_FALSE); } /* Asynchronous Operation */ return LacSymKey_MgfCommon(instanceHandle, pKeyGenCb, pCallbackTag, (const void *)pKeyGenMgfOpData, pKeyGenMgfOpData, pGeneratedMaskBuffer, CPA_CY_SYM_HASH_SHA1); } /** * cpaCyKeyGenMgfExt */ CpaStatus cpaCyKeyGenMgfExt(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenMgfOpDataExt *pKeyGenMgfOpDataExt, CpaFlatBuffer *pGeneratedMaskBuffer) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } /* If synchronous Operation */ if (NULL == pKeyGenCb) { return LacSymKey_MgfSync(instanceHandle, pKeyGenCb, pCallbackTag, (const void *)pKeyGenMgfOpDataExt, pGeneratedMaskBuffer, CPA_TRUE); } /* Param check specific for Ext function, rest of parameters validated * in LacSymKey_MgfCommon */ LAC_CHECK_NULL_PARAM(pKeyGenMgfOpDataExt); if (CPA_CY_SYM_HASH_MD5 > pKeyGenMgfOpDataExt->hashAlgorithm || CPA_CY_SYM_HASH_SHA512 < pKeyGenMgfOpDataExt->hashAlgorithm) { LAC_INVALID_PARAM_LOG("hashAlgorithm"); return CPA_STATUS_INVALID_PARAM; } /* Asynchronous Operation */ return LacSymKey_MgfCommon(instanceHandle, pKeyGenCb, pCallbackTag, (const void *)pKeyGenMgfOpDataExt, &pKeyGenMgfOpDataExt->baseOpData, pGeneratedMaskBuffer, pKeyGenMgfOpDataExt->hashAlgorithm); } /** ****************************************************************************** * @ingroup LacSymKey * Key Generation SSL & TLS response handler * * @description * Handles Key Generation SSL & TLS response messages from the QAT. * * @param[in] lacCmdId Command id of the original request * @param[in] pOpaqueData Pointer to opaque data that was in request * @param[in] cmnRespFlags LA response flags * * @return void * *****************************************************************************/ static void LacSymKey_SslTlsHandleResponse(icp_qat_fw_la_cmd_id_t lacCmdId, void *pOpaqueData, icp_qat_fw_comn_flags cmnRespFlags) { void *pSslTlsOpData = NULL; CpaCyGenFlatBufCbFunc pKeyGenSslTlsCb = NULL; lac_sym_key_cookie_t *pCookie = NULL; void *pCallbackTag = NULL; CpaFlatBuffer *pGeneratedKeyBuffer = NULL; CpaStatus status = CPA_STATUS_SUCCESS; CpaBoolean respStatusOk = (ICP_QAT_FW_COMN_STATUS_FLAG_OK == ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(cmnRespFlags)) ? CPA_TRUE : CPA_FALSE; pCookie = (lac_sym_key_cookie_t *)pOpaqueData; pSslTlsOpData = pCookie->pKeyGenOpData; if (CPA_TRUE == respStatusOk) { LacKey_StatsInc(lacCmdId, LAC_KEY_COMPLETED, pCookie->instanceHandle); } else { status = CPA_STATUS_FAIL; LacKey_StatsInc(lacCmdId, LAC_KEY_COMPLETED_ERRORS, pCookie->instanceHandle); } pKeyGenSslTlsCb = (CpaCyGenFlatBufCbFunc)(pCookie->pKeyGenCb); pCallbackTag = pCookie->pCallbackTag; pGeneratedKeyBuffer = pCookie->pKeyGenOutputData; Lac_MemPoolEntryFree(pCookie); (*pKeyGenSslTlsCb)(pCallbackTag, status, pSslTlsOpData, pGeneratedKeyBuffer); } /** ******************************************************************************* * @ingroup LacSymKey * Synchronous mode of operation function wrapper for performing SSL/TLS * key gen operation * * @description * Synchronous mode of operation function wrapper for performing SSL/TLS * key gen operation * * @param[in] instanceHandle QAT device handle. * @param[in] pKeyGenCb Pointer to callback function to be invoked * when the operation is complete. * @param[in] pCallbackTag Opaque User Data for this specific call. * @param[in] lacCmdId Lac command ID (identify SSL & TLS ops) * @param[in] pKeyGenSslTlsOpData Structure containing all the data needed to * perform the SSL/TLS key generation * operation. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pKeyGenOutputData pointer to where output result should be * written * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Function should be retried. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * *****************************************************************************/ static CpaStatus LacSymKey_SslTlsSync(CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, icp_qat_fw_la_cmd_id_t lacCmdId, void *pKeyGenSslTlsOpData, Cpa8U hashAlgorithm, CpaFlatBuffer *pKeyGenOutpuData) { lac_sync_op_data_t *pSyncCallbackData = NULL; CpaStatus status = CPA_STATUS_SUCCESS; status = LacSync_CreateSyncCookie(&pSyncCallbackData); if (CPA_STATUS_SUCCESS == status) { status = LacSymKey_KeyGenSslTls_GenCommon(instanceHandle, pKeyGenCb, pSyncCallbackData, lacCmdId, pKeyGenSslTlsOpData, hashAlgorithm, pKeyGenOutpuData); } else { /* Failure allocating sync cookie */ LacKey_StatsInc(lacCmdId, LAC_KEY_REQUEST_ERRORS, instanceHandle); return status; } if (CPA_STATUS_SUCCESS == status) { CpaStatus syncStatus = CPA_STATUS_SUCCESS; syncStatus = LacSync_WaitForCallback(pSyncCallbackData, LAC_SYM_SYNC_CALLBACK_TIMEOUT, &status, NULL); /* If callback doesn't come back */ if (CPA_STATUS_SUCCESS != syncStatus) { LacKey_StatsInc(lacCmdId, LAC_KEY_COMPLETED_ERRORS, instanceHandle); LAC_LOG_ERROR("Callback timed out"); status = syncStatus; } } else { /* As the Request was not sent the Callback will never * be called, so need to indicate that we're finished * with cookie so it can be destroyed. */ LacSync_SetSyncCookieComplete(pSyncCallbackData); } LacSync_DestroySyncCookie(&pSyncCallbackData); return status; } static CpaStatus computeHashKey(CpaFlatBuffer *secret, CpaFlatBuffer *hash, CpaCySymHashAlgorithm *hashAlgorithm) { CpaStatus status = CPA_STATUS_SUCCESS; switch (*hashAlgorithm) { case CPA_CY_SYM_HASH_MD5: status = qatUtilsHashMD5Full(secret->pData, hash->pData, secret->dataLenInBytes); break; case CPA_CY_SYM_HASH_SHA1: status = qatUtilsHashSHA1Full(secret->pData, hash->pData, secret->dataLenInBytes); break; case CPA_CY_SYM_HASH_SHA256: status = qatUtilsHashSHA256Full(secret->pData, hash->pData, secret->dataLenInBytes); break; case CPA_CY_SYM_HASH_SHA384: status = qatUtilsHashSHA384Full(secret->pData, hash->pData, secret->dataLenInBytes); break; case CPA_CY_SYM_HASH_SHA512: status = qatUtilsHashSHA512Full(secret->pData, hash->pData, secret->dataLenInBytes); break; default: status = CPA_STATUS_FAIL; } return status; } static CpaStatus LacSymKey_KeyGenSslTls_GenCommon(CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, icp_qat_fw_la_cmd_id_t lacCmdId, void *pKeyGenSslTlsOpData, Cpa8U hashAlgCipher, CpaFlatBuffer *pKeyGenOutputData) { CpaStatus status = CPA_STATUS_SUCCESS; CpaBoolean precompute = CPA_FALSE; icp_qat_fw_la_bulk_req_t keyGenReq = { { 0 } }; icp_qat_la_bulk_req_hdr_t keyGenReqHdr = { { 0 } }; icp_qat_fw_la_key_gen_common_t keyGenReqMid = { { 0 } }; icp_qat_la_bulk_req_ftr_t keyGenReqFtr = { { { 0 } } }; Cpa8U *pMsgDummy = NULL; Cpa8U *pCacheDummyHdr = NULL; Cpa8U *pCacheDummyMid = NULL; Cpa8U *pCacheDummyFtr = NULL; lac_sym_key_cookie_t *pCookie = NULL; lac_sym_cookie_t *pSymCookie = NULL; Cpa64U inputPhysAddr = 0; Cpa64U outputPhysAddr = 0; /* Structure initializer is supported by C99, but it is * not supported by some former Intel compiler. */ CpaCySymHashSetupData hashSetupData = { 0 }; sal_qat_content_desc_info_t contentDescInfo = { 0 }; Cpa32U hashBlkSizeInBytes = 0; Cpa32U tlsPrefixLen = 0; CpaFlatBuffer inputSecret = { 0 }; CpaFlatBuffer hashKeyOutput = { 0 }; Cpa32U uSecretLen = 0; CpaCySymHashNestedModeSetupData *pNestedModeSetupData = &(hashSetupData.nestedModeSetupData); icp_qat_fw_serv_specif_flags laCmdFlags = 0; icp_qat_fw_comn_flags cmnRequestFlags = ICP_QAT_FW_COMN_FLAGS_BUILD(QAT_COMN_PTR_TYPE_FLAT, QAT_COMN_CD_FLD_TYPE_64BIT_ADR); sal_crypto_service_t *pService = (sal_crypto_service_t *)instanceHandle; /* If synchronous Operation */ if (NULL == pKeyGenCb) { return LacSymKey_SslTlsSync(instanceHandle, LacSync_GenFlatBufCb, pCallbackTag, lacCmdId, pKeyGenSslTlsOpData, hashAlgCipher, pKeyGenOutputData); } /* Allocate the cookie */ pCookie = (lac_sym_key_cookie_t *)Lac_MemPoolEntryAlloc( pService->lac_sym_cookie_pool); if (NULL == pCookie) { LAC_LOG_ERROR("Cannot get mem pool entry"); status = CPA_STATUS_RESOURCE; } else if ((void *)CPA_STATUS_RETRY == pCookie) { pCookie = NULL; status = CPA_STATUS_RETRY; } else { pSymCookie = (lac_sym_cookie_t *)pCookie; } if (CPA_STATUS_SUCCESS == status) { icp_qat_hw_auth_mode_t qatHashMode = 0; if (ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE == lacCmdId) { qatHashMode = ICP_QAT_HW_AUTH_MODE0; } else /* TLS v1.1, v1.2, v1.3 */ { qatHashMode = ICP_QAT_HW_AUTH_MODE2; } pCookie->instanceHandle = pService; pCookie->pCallbackTag = pCallbackTag; pCookie->pKeyGenCb = pKeyGenCb; pCookie->pKeyGenOpData = pKeyGenSslTlsOpData; pCookie->pKeyGenOutputData = pKeyGenOutputData; hashSetupData.hashMode = CPA_CY_SYM_HASH_MODE_NESTED; /* SSL3 */ if (ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE == lacCmdId) { hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA1; hashSetupData.digestResultLenInBytes = LAC_HASH_MD5_DIGEST_SIZE; pNestedModeSetupData->outerHashAlgorithm = CPA_CY_SYM_HASH_MD5; pNestedModeSetupData->pInnerPrefixData = NULL; pNestedModeSetupData->innerPrefixLenInBytes = 0; pNestedModeSetupData->pOuterPrefixData = NULL; pNestedModeSetupData->outerPrefixLenInBytes = 0; } /* TLS v1.1 */ else if (ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE == lacCmdId) { CpaCyKeyGenTlsOpData *pKeyGenTlsOpData = (CpaCyKeyGenTlsOpData *)pKeyGenSslTlsOpData; hashSetupData.hashAlgorithm = CPA_CY_SYM_HASH_SHA1; hashSetupData.digestResultLenInBytes = LAC_HASH_MD5_DIGEST_SIZE; pNestedModeSetupData->outerHashAlgorithm = CPA_CY_SYM_HASH_MD5; uSecretLen = pKeyGenTlsOpData->secret.dataLenInBytes; /* We want to handle pre_master_secret > 128 bytes * therefore we * only verify if the current operation is Master Secret * Derive. * The other operations remain unchanged. */ if ((uSecretLen > ICP_QAT_FW_LA_TLS_V1_1_SECRET_LEN_MAX) && (CPA_CY_KEY_TLS_OP_MASTER_SECRET_DERIVE == pKeyGenTlsOpData->tlsOp || CPA_CY_KEY_TLS_OP_USER_DEFINED == pKeyGenTlsOpData->tlsOp)) { CpaCySymHashAlgorithm hashAlgorithm = (CpaCySymHashAlgorithm)hashAlgCipher; /* secret = [s1 | s2 ] * s1 = outer prefix, s2 = inner prefix * length of s1 and s2 = ceil(secret_length / 2) * (secret length + 1)/2 will always give the * ceil as * division by 2 * (>>1) will give the smallest integral value * not less than * arg */ tlsPrefixLen = (pKeyGenTlsOpData->secret.dataLenInBytes + 1) >> 1; inputSecret.dataLenInBytes = tlsPrefixLen; inputSecret.pData = pKeyGenTlsOpData->secret.pData; /* Since the pre_master_secret is > 128, we * split the input * pre_master_secret in 2 halves and compute the * MD5 of the * first half and the SHA1 on the second half. */ hashAlgorithm = CPA_CY_SYM_HASH_MD5; /* Initialize pointer where MD5 key will go. */ hashKeyOutput.pData = &pCookie->hashKeyBuffer[0]; hashKeyOutput.dataLenInBytes = LAC_HASH_MD5_DIGEST_SIZE; computeHashKey(&inputSecret, &hashKeyOutput, &hashAlgorithm); pNestedModeSetupData->pOuterPrefixData = &pCookie->hashKeyBuffer[0]; pNestedModeSetupData->outerPrefixLenInBytes = LAC_HASH_MD5_DIGEST_SIZE; /* Point to the second half of the * pre_master_secret */ inputSecret.pData = pKeyGenTlsOpData->secret.pData + (pKeyGenTlsOpData->secret.dataLenInBytes - tlsPrefixLen); /* Compute SHA1 on the second half of the * pre_master_secret */ hashAlgorithm = CPA_CY_SYM_HASH_SHA1; /* Initialize pointer where SHA1 key will go. */ hashKeyOutput.pData = &pCookie->hashKeyBuffer [LAC_HASH_MD5_DIGEST_SIZE]; hashKeyOutput.dataLenInBytes = LAC_HASH_SHA1_DIGEST_SIZE; computeHashKey(&inputSecret, &hashKeyOutput, &hashAlgorithm); pNestedModeSetupData->pInnerPrefixData = &pCookie->hashKeyBuffer [LAC_HASH_MD5_DIGEST_SIZE]; pNestedModeSetupData->innerPrefixLenInBytes = LAC_HASH_SHA1_DIGEST_SIZE; } else { /* secret = [s1 | s2 ] * s1 = outer prefix, s2 = inner prefix * length of s1 and s2 = ceil(secret_length / 2) * (secret length + 1)/2 will always give the * ceil as * division by 2 * (>>1) will give the smallest integral value * not less than * arg */ tlsPrefixLen = (pKeyGenTlsOpData->secret.dataLenInBytes + 1) >> 1; /* last byte of s1 will be first byte of s2 if * Length is odd */ pNestedModeSetupData->pInnerPrefixData = pKeyGenTlsOpData->secret.pData + (pKeyGenTlsOpData->secret.dataLenInBytes - tlsPrefixLen); pNestedModeSetupData->pOuterPrefixData = pKeyGenTlsOpData->secret.pData; pNestedModeSetupData->innerPrefixLenInBytes = pNestedModeSetupData ->outerPrefixLenInBytes = tlsPrefixLen; } } /* TLS v1.2 */ else if (ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE == lacCmdId) { CpaCyKeyGenTlsOpData *pKeyGenTlsOpData = (CpaCyKeyGenTlsOpData *)pKeyGenSslTlsOpData; CpaCySymHashAlgorithm hashAlgorithm = (CpaCySymHashAlgorithm)hashAlgCipher; uSecretLen = pKeyGenTlsOpData->secret.dataLenInBytes; hashSetupData.hashAlgorithm = (CpaCySymHashAlgorithm)hashAlgorithm; hashSetupData.digestResultLenInBytes = (Cpa32U)getDigestSizeFromHashAlgo(hashAlgorithm); pNestedModeSetupData->outerHashAlgorithm = (CpaCySymHashAlgorithm)hashAlgorithm; if (CPA_CY_KEY_TLS_OP_MASTER_SECRET_DERIVE == pKeyGenTlsOpData->tlsOp || CPA_CY_KEY_TLS_OP_USER_DEFINED == pKeyGenTlsOpData->tlsOp) { switch (hashAlgorithm) { case CPA_CY_SYM_HASH_SM3: precompute = CPA_FALSE; break; case CPA_CY_SYM_HASH_SHA256: if (uSecretLen > ICP_QAT_FW_LA_TLS_V1_2_SECRET_LEN_MAX) { precompute = CPA_TRUE; } break; case CPA_CY_SYM_HASH_SHA384: case CPA_CY_SYM_HASH_SHA512: if (uSecretLen > ICP_QAT_FW_LA_TLS_SECRET_LEN_MAX) { precompute = CPA_TRUE; } break; default: break; } } if (CPA_TRUE == precompute) { /* Case when secret > algorithm block size * RFC 4868: For SHA-256 Block size is 512 bits, * for SHA-384 * and SHA-512 Block size is 1024 bits * Initialize pointer * where SHAxxx key will go. */ hashKeyOutput.pData = &pCookie->hashKeyBuffer[0]; hashKeyOutput.dataLenInBytes = hashSetupData.digestResultLenInBytes; computeHashKey(&pKeyGenTlsOpData->secret, &hashKeyOutput, &hashSetupData.hashAlgorithm); /* Outer prefix = secret , inner prefix = secret * secret < 64 bytes */ pNestedModeSetupData->pInnerPrefixData = hashKeyOutput.pData; pNestedModeSetupData->pOuterPrefixData = hashKeyOutput.pData; pNestedModeSetupData->innerPrefixLenInBytes = hashKeyOutput.dataLenInBytes; pNestedModeSetupData->outerPrefixLenInBytes = hashKeyOutput.dataLenInBytes; } else { /* Outer prefix = secret , inner prefix = secret * secret <= 64 bytes */ pNestedModeSetupData->pInnerPrefixData = pKeyGenTlsOpData->secret.pData; pNestedModeSetupData->pOuterPrefixData = pKeyGenTlsOpData->secret.pData; pNestedModeSetupData->innerPrefixLenInBytes = pKeyGenTlsOpData->secret.dataLenInBytes; pNestedModeSetupData->outerPrefixLenInBytes = pKeyGenTlsOpData->secret.dataLenInBytes; } } /* TLS v1.3 */ else if ((ICP_QAT_FW_LA_CMD_HKDF_EXTRACT <= lacCmdId) && (ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL >= lacCmdId)) { CpaCyKeyGenHKDFOpData *pKeyGenTlsOpData = (CpaCyKeyGenHKDFOpData *)pKeyGenSslTlsOpData; CpaCySymHashAlgorithm hashAlgorithm = getHashAlgorithmFromCipherSuiteHKDF(hashAlgCipher); /* Set HASH data */ hashSetupData.hashAlgorithm = hashAlgorithm; /* Calculate digest length from the HASH type */ hashSetupData.digestResultLenInBytes = cipherSuiteHKDFHashSizes[hashAlgCipher] [LAC_KEY_HKDF_DIGESTS]; /* Outer Hash type is the same as inner hash type */ pNestedModeSetupData->outerHashAlgorithm = hashAlgorithm; /* EXPAND (PRK): * Outer prefix = secret, inner prefix = secret * EXTRACT (SEED/SALT): * Outer prefix = seed, inner prefix = seed * Secret <= 64 Bytes * We do not pre compute as secret can't be larger than * 64 bytes */ if ((ICP_QAT_FW_LA_CMD_HKDF_EXPAND == lacCmdId) || (ICP_QAT_FW_LA_CMD_HKDF_EXPAND_LABEL == lacCmdId)) { pNestedModeSetupData->pInnerPrefixData = pKeyGenTlsOpData->secret; pNestedModeSetupData->pOuterPrefixData = pKeyGenTlsOpData->secret; pNestedModeSetupData->innerPrefixLenInBytes = pKeyGenTlsOpData->secretLen; pNestedModeSetupData->outerPrefixLenInBytes = pKeyGenTlsOpData->secretLen; } else { pNestedModeSetupData->pInnerPrefixData = pKeyGenTlsOpData->seed; pNestedModeSetupData->pOuterPrefixData = pKeyGenTlsOpData->seed; pNestedModeSetupData->innerPrefixLenInBytes = pKeyGenTlsOpData->seedLen; pNestedModeSetupData->outerPrefixLenInBytes = pKeyGenTlsOpData->seedLen; } } /* Set the footer Data. * Note that following function doesn't look at inner/outer * prefix pointers in nested digest ctx */ LacSymQat_HashContentDescInit( &keyGenReqFtr, instanceHandle, &hashSetupData, pCookie ->contentDesc, /* Pointer to base of hw setup block */ LAC_SYM_KEY_NO_HASH_BLK_OFFSET_QW, ICP_QAT_FW_SLICE_DRAM_WR, qatHashMode, CPA_FALSE, /* Not using sym Constants Table in Shared SRAM */ CPA_FALSE, /* not using the optimised content Desc */ CPA_FALSE, /* Not using the stateful SHA3 Content Desc */ NULL, /* precompute data */ &hashBlkSizeInBytes); /* SSL3 */ if (ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE == lacCmdId) { CpaCyKeyGenSslOpData *pKeyGenSslOpData = (CpaCyKeyGenSslOpData *)pKeyGenSslTlsOpData; Cpa8U *pLabel = NULL; Cpa32U labelLen = 0; Cpa8U iterations = 0; Cpa64U labelPhysAddr = 0; /* Iterations = ceiling of output required / output per * iteration Ceiling of a / b = (a + (b-1)) / b */ iterations = (pKeyGenSslOpData->generatedKeyLenInBytes + (LAC_SYM_QAT_KEY_SSL_BYTES_PER_ITERATION - 1)) >> LAC_SYM_QAT_KEY_SSL_ITERATIONS_SHIFT; if (CPA_CY_KEY_SSL_OP_USER_DEFINED == pKeyGenSslOpData->sslOp) { pLabel = pKeyGenSslOpData->userLabel.pData; labelLen = pKeyGenSslOpData->userLabel.dataLenInBytes; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, pLabel); if (labelPhysAddr == 0) { LAC_LOG_ERROR( "Unable to get the physical address of the" " label"); status = CPA_STATUS_FAIL; } } else { pLabel = pService->pSslLabel; /* Calculate label length. * eg. 3 iterations is ABBCCC so length is 6 */ labelLen = ((iterations * iterations) + iterations) >> 1; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_INTERNAL(pLabel); } LacSymQat_KeySslRequestPopulate( &keyGenReqHdr, &keyGenReqMid, pKeyGenSslOpData->generatedKeyLenInBytes, labelLen, pKeyGenSslOpData->secret.dataLenInBytes, iterations); LacSymQat_KeySslKeyMaterialInputPopulate( &(pService->generic_service_info), &(pCookie->u.sslKeyInput), pKeyGenSslOpData->seed.pData, labelPhysAddr, pKeyGenSslOpData->secret.pData); inputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keySslKeyInputPhyAddr); } /* TLS v1.1, v1.2 */ else if (ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE == lacCmdId || ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE == lacCmdId) { CpaCyKeyGenTlsOpData *pKeyGenTlsOpData = (CpaCyKeyGenTlsOpData *)pKeyGenSslTlsOpData; lac_sym_qat_hash_state_buffer_info_t hashStateBufferInfo = { 0 }; CpaBoolean hashStateBuffer = CPA_FALSE; icp_qat_fw_auth_cd_ctrl_hdr_t *pHashControlBlock = (icp_qat_fw_auth_cd_ctrl_hdr_t *)&( keyGenReqFtr.cd_ctrl); icp_qat_la_auth_req_params_t *pHashReqParams = NULL; Cpa8U *pLabel = NULL; Cpa32U labelLen = 0; Cpa64U labelPhysAddr = 0; hashStateBufferInfo.pData = pCookie->hashStateBuffer; hashStateBufferInfo.pDataPhys = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyHashStateBufferPhyAddr); hashStateBufferInfo.stateStorageSzQuadWords = 0; LacSymQat_HashSetupReqParamsMetaData(&(keyGenReqFtr), instanceHandle, &(hashSetupData), hashStateBuffer, qatHashMode, CPA_FALSE); pHashReqParams = (icp_qat_la_auth_req_params_t *)&( keyGenReqFtr.serv_specif_rqpars); hashStateBufferInfo.prefixAadSzQuadWords = LAC_BYTES_TO_QUADWORDS( pHashReqParams->u2.inner_prefix_sz + pHashControlBlock->outer_prefix_sz); /* Copy prefix data into hash state buffer */ pMsgDummy = (Cpa8U *)&(keyGenReq); pCacheDummyHdr = (Cpa8U *)&(keyGenReqHdr); pCacheDummyMid = (Cpa8U *)&(keyGenReqMid); pCacheDummyFtr = (Cpa8U *)&(keyGenReqFtr); memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_MID_IN_LW), pCacheDummyMid, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_MID_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); LacSymQat_HashStatePrefixAadBufferPopulate( &hashStateBufferInfo, &keyGenReqFtr, pNestedModeSetupData->pInnerPrefixData, pNestedModeSetupData->innerPrefixLenInBytes, pNestedModeSetupData->pOuterPrefixData, pNestedModeSetupData->outerPrefixLenInBytes); /* Firmware only looks at hash state buffer pointer and * the * hash state buffer size so all other fields are set to * 0 */ LacSymQat_HashRequestParamsPopulate( &(keyGenReq), 0, /* Auth offset */ 0, /* Auth length */ &(pService->generic_service_info), &hashStateBufferInfo, /* Hash state prefix buffer */ ICP_QAT_FW_LA_PARTIAL_NONE, 0, /* Hash result size */ CPA_FALSE, NULL, CPA_CY_SYM_HASH_NONE, /* Hash algorithm */ NULL); /* HKDF only */ /* Set up the labels and their length */ if (CPA_CY_KEY_TLS_OP_USER_DEFINED == pKeyGenTlsOpData->tlsOp) { pLabel = pKeyGenTlsOpData->userLabel.pData; labelLen = pKeyGenTlsOpData->userLabel.dataLenInBytes; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, pLabel); if (labelPhysAddr == 0) { LAC_LOG_ERROR( "Unable to get the physical address of the" " label"); status = CPA_STATUS_FAIL; } } else if (CPA_CY_KEY_TLS_OP_MASTER_SECRET_DERIVE == pKeyGenTlsOpData->tlsOp) { pLabel = pService->pTlsLabel->masterSecret; labelLen = sizeof( LAC_SYM_KEY_TLS_MASTER_SECRET_LABEL) - 1; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_INTERNAL(pLabel); } else if (CPA_CY_KEY_TLS_OP_KEY_MATERIAL_DERIVE == pKeyGenTlsOpData->tlsOp) { pLabel = pService->pTlsLabel->keyMaterial; labelLen = sizeof(LAC_SYM_KEY_TLS_KEY_MATERIAL_LABEL) - 1; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_INTERNAL(pLabel); } else if (CPA_CY_KEY_TLS_OP_CLIENT_FINISHED_DERIVE == pKeyGenTlsOpData->tlsOp) { pLabel = pService->pTlsLabel->clientFinished; labelLen = sizeof(LAC_SYM_KEY_TLS_CLIENT_FIN_LABEL) - 1; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_INTERNAL(pLabel); } else { pLabel = pService->pTlsLabel->serverFinished; labelLen = sizeof(LAC_SYM_KEY_TLS_SERVER_FIN_LABEL) - 1; labelPhysAddr = LAC_OS_VIRT_TO_PHYS_INTERNAL(pLabel); } LacSymQat_KeyTlsRequestPopulate( &keyGenReqMid, pKeyGenTlsOpData->generatedKeyLenInBytes, labelLen, pKeyGenTlsOpData->secret.dataLenInBytes, pKeyGenTlsOpData->seed.dataLenInBytes, lacCmdId); LacSymQat_KeyTlsKeyMaterialInputPopulate( &(pService->generic_service_info), &(pCookie->u.tlsKeyInput), pKeyGenTlsOpData->seed.pData, labelPhysAddr); inputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyTlsKeyInputPhyAddr); } /* TLS v1.3 */ else if (ICP_QAT_FW_LA_CMD_HKDF_EXTRACT <= lacCmdId && ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND >= lacCmdId) { CpaCyKeyGenHKDFOpData *pKeyGenTlsOpData = (CpaCyKeyGenHKDFOpData *)pKeyGenSslTlsOpData; lac_sym_qat_hash_state_buffer_info_t hashStateBufferInfo = { 0 }; CpaBoolean hashStateBuffer = CPA_FALSE; icp_qat_fw_auth_cd_ctrl_hdr_t *pHashControlBlock = (icp_qat_fw_auth_cd_ctrl_hdr_t *)&( keyGenReqFtr.cd_ctrl); icp_qat_la_auth_req_params_t *pHashReqParams = NULL; hashStateBufferInfo.pData = pCookie->hashStateBuffer; hashStateBufferInfo.pDataPhys = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyHashStateBufferPhyAddr); hashStateBufferInfo.stateStorageSzQuadWords = 0; LacSymQat_HashSetupReqParamsMetaData(&(keyGenReqFtr), instanceHandle, &(hashSetupData), hashStateBuffer, qatHashMode, CPA_FALSE); pHashReqParams = (icp_qat_la_auth_req_params_t *)&( keyGenReqFtr.serv_specif_rqpars); hashStateBufferInfo.prefixAadSzQuadWords = LAC_BYTES_TO_QUADWORDS( pHashReqParams->u2.inner_prefix_sz + pHashControlBlock->outer_prefix_sz); /* Copy prefix data into hash state buffer */ pMsgDummy = (Cpa8U *)&(keyGenReq); pCacheDummyHdr = (Cpa8U *)&(keyGenReqHdr); pCacheDummyMid = (Cpa8U *)&(keyGenReqMid); pCacheDummyFtr = (Cpa8U *)&(keyGenReqFtr); memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_MID_IN_LW), pCacheDummyMid, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_MID_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); LacSymQat_HashStatePrefixAadBufferPopulate( &hashStateBufferInfo, &keyGenReqFtr, pNestedModeSetupData->pInnerPrefixData, pNestedModeSetupData->innerPrefixLenInBytes, pNestedModeSetupData->pOuterPrefixData, pNestedModeSetupData->outerPrefixLenInBytes); /* Firmware only looks at hash state buffer pointer and * the * hash state buffer size so all other fields are set to * 0 */ LacSymQat_HashRequestParamsPopulate( &(keyGenReq), 0, /* Auth offset */ 0, /* Auth length */ &(pService->generic_service_info), &hashStateBufferInfo, /* Hash state prefix buffer */ ICP_QAT_FW_LA_PARTIAL_NONE, 0, /* Hash result size */ CPA_FALSE, NULL, CPA_CY_SYM_HASH_NONE, /* Hash algorithm */ pKeyGenTlsOpData->secret); /* IKM or PRK */ LacSymQat_KeyTlsRequestPopulate( &keyGenReqMid, cipherSuiteHKDFHashSizes[hashAlgCipher] [LAC_KEY_HKDF_DIGESTS], /* For EXTRACT, EXPAND, FW expects info to be passed as label */ pKeyGenTlsOpData->infoLen, pKeyGenTlsOpData->secretLen, pKeyGenTlsOpData->seedLen, lacCmdId); LacSymQat_KeyTlsHKDFKeyMaterialInputPopulate( &(pService->generic_service_info), &(pCookie->u.tlsHKDFKeyInput), pKeyGenTlsOpData, 0, /* No subLabels used */ lacCmdId); /* Pass op being performed */ inputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyTlsKeyInputPhyAddr); } /* TLS v1.3 LABEL */ else if (ICP_QAT_FW_LA_CMD_HKDF_EXPAND_LABEL == lacCmdId || ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL == lacCmdId) { CpaCyKeyGenHKDFOpData *pKeyGenTlsOpData = (CpaCyKeyGenHKDFOpData *)pKeyGenSslTlsOpData; Cpa64U subLabelsPhysAddr = 0; lac_sym_qat_hash_state_buffer_info_t hashStateBufferInfo = { 0 }; CpaBoolean hashStateBuffer = CPA_FALSE; icp_qat_fw_auth_cd_ctrl_hdr_t *pHashControlBlock = (icp_qat_fw_auth_cd_ctrl_hdr_t *)&( keyGenReqFtr.cd_ctrl); icp_qat_la_auth_req_params_t *pHashReqParams = NULL; hashStateBufferInfo.pData = pCookie->hashStateBuffer; hashStateBufferInfo.pDataPhys = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyHashStateBufferPhyAddr); hashStateBufferInfo.stateStorageSzQuadWords = 0; LacSymQat_HashSetupReqParamsMetaData(&(keyGenReqFtr), instanceHandle, &(hashSetupData), hashStateBuffer, qatHashMode, CPA_FALSE); pHashReqParams = (icp_qat_la_auth_req_params_t *)&( keyGenReqFtr.serv_specif_rqpars); hashStateBufferInfo.prefixAadSzQuadWords = LAC_BYTES_TO_QUADWORDS( pHashReqParams->u2.inner_prefix_sz + pHashControlBlock->outer_prefix_sz); /* Copy prefix data into hash state buffer */ pMsgDummy = (Cpa8U *)&(keyGenReq); pCacheDummyHdr = (Cpa8U *)&(keyGenReqHdr); pCacheDummyMid = (Cpa8U *)&(keyGenReqMid); pCacheDummyFtr = (Cpa8U *)&(keyGenReqFtr); memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_MID_IN_LW), pCacheDummyMid, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_MID_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); LacSymQat_HashStatePrefixAadBufferPopulate( &hashStateBufferInfo, &keyGenReqFtr, pNestedModeSetupData->pInnerPrefixData, pNestedModeSetupData->innerPrefixLenInBytes, pNestedModeSetupData->pOuterPrefixData, pNestedModeSetupData->outerPrefixLenInBytes); /* Firmware only looks at hash state buffer pointer and * the * hash state buffer size so all other fields are set to * 0 */ LacSymQat_HashRequestParamsPopulate( &(keyGenReq), 0, /* Auth offset */ 0, /* Auth length */ &(pService->generic_service_info), &hashStateBufferInfo, /* Hash state prefix buffer */ ICP_QAT_FW_LA_PARTIAL_NONE, 0, /* Hash result size */ CPA_FALSE, NULL, CPA_CY_SYM_HASH_NONE, /* Hash algorithm */ pKeyGenTlsOpData->secret); /* IKM or PRK */ LacSymQat_KeyTlsRequestPopulate( &keyGenReqMid, cipherSuiteHKDFHashSizes[hashAlgCipher] [LAC_KEY_HKDF_DIGESTS], pKeyGenTlsOpData->numLabels, /* Number of Labels */ pKeyGenTlsOpData->secretLen, pKeyGenTlsOpData->seedLen, lacCmdId); /* Get physical address of subLabels */ switch (hashAlgCipher) { case CPA_CY_HKDF_TLS_AES_128_GCM_SHA256: /* Fall Through */ case CPA_CY_HKDF_TLS_AES_128_CCM_SHA256: case CPA_CY_HKDF_TLS_AES_128_CCM_8_SHA256: subLabelsPhysAddr = pService->pTlsHKDFSubLabel ->sublabelPhysAddr256; break; case CPA_CY_HKDF_TLS_CHACHA20_POLY1305_SHA256: subLabelsPhysAddr = pService->pTlsHKDFSubLabel ->sublabelPhysAddrChaChaPoly; break; case CPA_CY_HKDF_TLS_AES_256_GCM_SHA384: subLabelsPhysAddr = pService->pTlsHKDFSubLabel ->sublabelPhysAddr384; break; default: break; } LacSymQat_KeyTlsHKDFKeyMaterialInputPopulate( &(pService->generic_service_info), &(pCookie->u.tlsHKDFKeyInput), pKeyGenTlsOpData, subLabelsPhysAddr, lacCmdId); /* Pass op being performed */ inputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyTlsKeyInputPhyAddr); } outputPhysAddr = LAC_MEM_CAST_PTR_TO_UINT64( LAC_OS_VIRT_TO_PHYS_EXTERNAL(pService->generic_service_info, pKeyGenOutputData->pData)); if (outputPhysAddr == 0) { LAC_LOG_ERROR( "Unable to get the physical address of the" " output buffer"); status = CPA_STATUS_FAIL; } } if (CPA_STATUS_SUCCESS == status) { Cpa8U lw26[4]; char *tmp = NULL; unsigned char a; int n = 0; /* Make up the full keyGenReq struct from its constituents * before calling the SalQatMsg functions below. * Note: The full cache struct has been reduced to a * header, mid and footer for memory size reduction */ pMsgDummy = (Cpa8U *)&(keyGenReq); pCacheDummyHdr = (Cpa8U *)&(keyGenReqHdr); pCacheDummyMid = (Cpa8U *)&(keyGenReqMid); pCacheDummyFtr = (Cpa8U *)&(keyGenReqFtr); memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_MID_IN_LW), pCacheDummyMid, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_MID_IN_LW)); memcpy(&lw26, pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), LAC_LONG_WORD_IN_BYTES); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); tmp = (char *)(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW)); /* Copy LW26, or'd with what's already there, into the Msg, for * TLS */ for (n = 0; n < LAC_LONG_WORD_IN_BYTES; n++) { a = (unsigned char)*(tmp + n); lw26[n] = lw26[n] | a; } memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), &lw26, LAC_LONG_WORD_IN_BYTES); contentDescInfo.pData = pCookie->contentDesc; contentDescInfo.hardwareSetupBlockPhys = LAC_MEM_CAST_PTR_TO_UINT64( pSymCookie->keyContentDescPhyAddr); contentDescInfo.hwBlkSzQuadWords = LAC_BYTES_TO_QUADWORDS(hashBlkSizeInBytes); /* Populate common request fields */ SalQatMsg_ContentDescHdrWrite((icp_qat_fw_comn_req_t *)&( keyGenReq), &(contentDescInfo)); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)&keyGenReq, ICP_QAT_FW_COMN_REQ_CPM_FW_LA, lacCmdId, cmnRequestFlags, laCmdFlags); SalQatMsg_CmnMidWrite((icp_qat_fw_la_bulk_req_t *)&(keyGenReq), pCookie, LAC_SYM_KEY_QAT_PTR_TYPE, inputPhysAddr, outputPhysAddr, 0, 0); /* Send to QAT */ status = icp_adf_transPutMsg(pService->trans_handle_sym_tx, (void *)&(keyGenReq), LAC_QAT_SYM_REQ_SZ_LW); } if (CPA_STATUS_SUCCESS == status) { /* Update stats */ LacKey_StatsInc(lacCmdId, LAC_KEY_REQUESTS, pCookie->instanceHandle); } else { /* Clean up cookie memory */ if (NULL != pCookie) { LacKey_StatsInc(lacCmdId, LAC_KEY_REQUEST_ERRORS, pCookie->instanceHandle); Lac_MemPoolEntryFree(pCookie); } } return status; } /** * @ingroup LacSymKey * Parameters check for TLS v1.0/1.1, v1.2, v1.3 and SSL3 * @description * Check user parameters against the firmware/spec requirements. * * @param[in] pKeyGenOpData Pointer to a structure containing all * the data needed to perform the key * generation operation. * @param[in] hashAlgCipher Specifies the hash algorithm, * or cipher we are using. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[in] pGeneratedKeyBuffer User output buffers. * @param[in] cmdId Keygen operation to perform. */ static CpaStatus LacSymKey_CheckParamSslTls(const void *pKeyGenOpData, Cpa8U hashAlgCipher, const CpaFlatBuffer *pGeneratedKeyBuffer, icp_qat_fw_la_cmd_id_t cmdId) { /* Api max value */ Cpa32U maxSecretLen = 0; Cpa32U maxSeedLen = 0; Cpa32U maxOutputLen = 0; Cpa32U maxInfoLen = 0; Cpa32U maxLabelLen = 0; /* User info */ Cpa32U uSecretLen = 0; Cpa32U uSeedLen = 0; Cpa32U uOutputLen = 0; LAC_CHECK_NULL_PARAM(pKeyGenOpData); LAC_CHECK_NULL_PARAM(pGeneratedKeyBuffer); LAC_CHECK_NULL_PARAM(pGeneratedKeyBuffer->pData); if (ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE == cmdId) { CpaCyKeyGenSslOpData *opData = (CpaCyKeyGenSslOpData *)pKeyGenOpData; /* User info */ uSecretLen = opData->secret.dataLenInBytes; uSeedLen = opData->seed.dataLenInBytes; uOutputLen = opData->generatedKeyLenInBytes; /* Api max value */ maxSecretLen = ICP_QAT_FW_LA_SSL_SECRET_LEN_MAX; maxSeedLen = ICP_QAT_FW_LA_SSL_SEED_LEN_MAX; maxOutputLen = ICP_QAT_FW_LA_SSL_OUTPUT_LEN_MAX; /* Check user buffers */ LAC_CHECK_NULL_PARAM(opData->secret.pData); LAC_CHECK_NULL_PARAM(opData->seed.pData); /* Check operation */ if ((Cpa32U)opData->sslOp > CPA_CY_KEY_SSL_OP_USER_DEFINED) { LAC_INVALID_PARAM_LOG("opData->sslOp"); return CPA_STATUS_INVALID_PARAM; } if ((Cpa32U)opData->sslOp == CPA_CY_KEY_SSL_OP_USER_DEFINED) { LAC_CHECK_NULL_PARAM(opData->userLabel.pData); /* Maximum label length for SSL Key Gen request */ if (opData->userLabel.dataLenInBytes > ICP_QAT_FW_LA_SSL_LABEL_LEN_MAX) { LAC_INVALID_PARAM_LOG( "userLabel.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } /* Only seed length for SSL3 Key Gen request */ if (maxSeedLen != uSeedLen) { LAC_INVALID_PARAM_LOG("seed.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* Maximum output length for SSL3 Key Gen request */ if (uOutputLen > maxOutputLen) { LAC_INVALID_PARAM_LOG("generatedKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } /* TLS v1.1 or TLS v.12 */ else if (ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE == cmdId || ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE == cmdId) { CpaCyKeyGenTlsOpData *opData = (CpaCyKeyGenTlsOpData *)pKeyGenOpData; /* User info */ uSecretLen = opData->secret.dataLenInBytes; uSeedLen = opData->seed.dataLenInBytes; uOutputLen = opData->generatedKeyLenInBytes; if (ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE == cmdId) { /* Api max value */ /* ICP_QAT_FW_LA_TLS_V1_1_SECRET_LEN_MAX needs to be * multiplied - * by 4 in order to verifiy the 512 conditions. We did + * by 4 in order to verify the 512 conditions. We did * not change * ICP_QAT_FW_LA_TLS_V1_1_SECRET_LEN_MAX as it * represents - * the max value tha firmware can handle. + * the max value that firmware can handle. */ maxSecretLen = ICP_QAT_FW_LA_TLS_V1_1_SECRET_LEN_MAX * 4; } else { /* Api max value */ /* ICP_QAT_FW_LA_TLS_V1_2_SECRET_LEN_MAX needs to be * multiplied - * by 8 in order to verifiy the 512 conditions. We did + * by 8 in order to verify the 512 conditions. We did * not change * ICP_QAT_FW_LA_TLS_V1_2_SECRET_LEN_MAX as it * represents - * the max value tha firmware can handle. + * the max value that firmware can handle. */ maxSecretLen = ICP_QAT_FW_LA_TLS_V1_2_SECRET_LEN_MAX * 8; /* Check Hash algorithm */ if (0 == getDigestSizeFromHashAlgo(hashAlgCipher)) { LAC_INVALID_PARAM_LOG("hashAlgorithm"); return CPA_STATUS_INVALID_PARAM; } } maxSeedLen = ICP_QAT_FW_LA_TLS_SEED_LEN_MAX; maxOutputLen = ICP_QAT_FW_LA_TLS_OUTPUT_LEN_MAX; /* Check user buffers */ LAC_CHECK_NULL_PARAM(opData->secret.pData); LAC_CHECK_NULL_PARAM(opData->seed.pData); /* Check operation */ if ((Cpa32U)opData->tlsOp > CPA_CY_KEY_TLS_OP_USER_DEFINED) { LAC_INVALID_PARAM_LOG("opData->tlsOp"); return CPA_STATUS_INVALID_PARAM; } else if ((Cpa32U)opData->tlsOp == CPA_CY_KEY_TLS_OP_USER_DEFINED) { LAC_CHECK_NULL_PARAM(opData->userLabel.pData); /* Maximum label length for TLS Key Gen request */ if (opData->userLabel.dataLenInBytes > ICP_QAT_FW_LA_TLS_LABEL_LEN_MAX) { LAC_INVALID_PARAM_LOG( "userLabel.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } /* Maximum/only seed length for TLS Key Gen request */ if (((Cpa32U)opData->tlsOp != CPA_CY_KEY_TLS_OP_MASTER_SECRET_DERIVE) && ((Cpa32U)opData->tlsOp != CPA_CY_KEY_TLS_OP_KEY_MATERIAL_DERIVE)) { if (uSeedLen > maxSeedLen) { LAC_INVALID_PARAM_LOG("seed.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else { if (maxSeedLen != uSeedLen) { LAC_INVALID_PARAM_LOG("seed.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } /* Maximum output length for TLS Key Gen request */ if (uOutputLen > maxOutputLen) { LAC_INVALID_PARAM_LOG("generatedKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } /* TLS v1.3 */ else if (cmdId >= ICP_QAT_FW_LA_CMD_HKDF_EXTRACT && cmdId <= ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL) { CpaCyKeyGenHKDFOpData *HKDF_Data = (CpaCyKeyGenHKDFOpData *)pKeyGenOpData; CpaCyKeyHKDFCipherSuite cipherSuite = hashAlgCipher; CpaCySymHashAlgorithm hashAlgorithm = getHashAlgorithmFromCipherSuiteHKDF(cipherSuite); maxSeedLen = cipherSuiteHKDFHashSizes[cipherSuite][LAC_KEY_HKDF_DIGESTS]; maxSecretLen = CPA_CY_HKDF_KEY_MAX_SECRET_SZ; maxInfoLen = CPA_CY_HKDF_KEY_MAX_INFO_SZ; maxLabelLen = CPA_CY_HKDF_KEY_MAX_LABEL_SZ; uSecretLen = HKDF_Data->secretLen; /* Check using supported hash function */ if (0 == (uOutputLen = getDigestSizeFromHashAlgo(hashAlgorithm))) { LAC_INVALID_PARAM_LOG("Hash function not supported"); return CPA_STATUS_INVALID_PARAM; } /* Number of labels does not exceed the MAX */ if (HKDF_Data->numLabels > CPA_CY_HKDF_KEY_MAX_LABEL_COUNT) { LAC_INVALID_PARAM_LOG( "CpaCyKeyGenHKDFOpData.numLabels"); return CPA_STATUS_INVALID_PARAM; } switch (cmdId) { case ICP_QAT_FW_LA_CMD_HKDF_EXTRACT: if (maxSeedLen < HKDF_Data->seedLen) { LAC_INVALID_PARAM_LOG( "CpaCyKeyGenHKDFOpData.seedLen"); return CPA_STATUS_INVALID_PARAM; } break; case ICP_QAT_FW_LA_CMD_HKDF_EXPAND: maxSecretLen = cipherSuiteHKDFHashSizes[cipherSuite] [LAC_KEY_HKDF_DIGESTS]; if (maxInfoLen < HKDF_Data->infoLen) { LAC_INVALID_PARAM_LOG( "CpaCyKeyGenHKDFOpData.infoLen"); return CPA_STATUS_INVALID_PARAM; } break; case ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND: uOutputLen *= 2; if (maxSeedLen < HKDF_Data->seedLen) { LAC_INVALID_PARAM_LOG( "CpaCyKeyGenHKDFOpData.seedLen"); return CPA_STATUS_INVALID_PARAM; } if (maxInfoLen < HKDF_Data->infoLen) { LAC_INVALID_PARAM_LOG( "CpaCyKeyGenHKDFOpData.infoLen"); return CPA_STATUS_INVALID_PARAM; } break; case ICP_QAT_FW_LA_CMD_HKDF_EXPAND_LABEL: /* Fall through */ case ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL: { Cpa8U subl_mask = 0, subl_number = 1; Cpa8U i = 0; if (maxSeedLen < HKDF_Data->seedLen) { LAC_INVALID_PARAM_LOG( "CpaCyKeyGenHKDFOpData.seedLen"); return CPA_STATUS_INVALID_PARAM; } /* If EXPAND set uOutputLen to zero */ if (ICP_QAT_FW_LA_CMD_HKDF_EXPAND_LABEL == cmdId) { uOutputLen = 0; maxSecretLen = cipherSuiteHKDFHashSizes [cipherSuite][LAC_KEY_HKDF_DIGESTS]; } for (i = 0; i < HKDF_Data->numLabels; i++) { /* Check that the labelLen does not overflow */ if (maxLabelLen < HKDF_Data->label[i].labelLen) { LAC_INVALID_PARAM_LOG1( "CpaCyKeyGenHKDFOpData.label[%d].labelLen", i); return CPA_STATUS_INVALID_PARAM; } if (HKDF_Data->label[i].sublabelFlag & ~HKDF_SUB_LABELS_ALL) { LAC_INVALID_PARAM_LOG1( "CpaCyKeyGenHKDFOpData.label[%d]." "subLabelFlag", i); return CPA_STATUS_INVALID_PARAM; } /* Calculate the appended subLabel output * lengths and * check that the output buffer that the user * has * supplied is the correct length. */ uOutputLen += cipherSuiteHKDFHashSizes [cipherSuite][LAC_KEY_HKDF_DIGESTS]; /* Get mask of subLabel */ subl_mask = HKDF_Data->label[i].sublabelFlag; for (subl_number = 1; subl_number <= LAC_KEY_HKDF_SUBLABELS_NUM; subl_number++) { /* Add the used subLabel key lengths */ if (subl_mask & 1) { uOutputLen += cipherSuiteHKDFHashSizes [cipherSuite] [subl_number]; } subl_mask >>= 1; } } } break; default: break; } } else { LAC_INVALID_PARAM_LOG("TLS/SSL operation"); return CPA_STATUS_INVALID_PARAM; } /* Maximum secret length for TLS/SSL Key Gen request */ if (uSecretLen > maxSecretLen) { LAC_INVALID_PARAM_LOG("HKFD.secretLen/secret.dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* Check for enough space in the flat buffer */ if (uOutputLen > pGeneratedKeyBuffer->dataLenInBytes) { LAC_INVALID_PARAM_LOG("pGeneratedKeyBuffer->dataLenInBytes"); return CPA_STATUS_INVALID_PARAM; } return CPA_STATUS_SUCCESS; } /** * */ /** * @ingroup LacSymKey * Common Keygen Code for TLS v1.0/1.1, v1.2 and SSL3. * @description * Check user parameters and perform the required operation. * * @param[in] instanceHandle_in Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenOpData Pointer to a structure containing all * the data needed to perform the key * generation operation. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pGeneratedKeyBuffer User output buffer. * @param[in] cmdId Keygen operation to perform. */ static CpaStatus LacSymKey_KeyGenSslTls(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const void *pKeyGenOpData, Cpa8U hashAlgorithm, CpaFlatBuffer *pGeneratedKeyBuffer, icp_qat_fw_la_cmd_id_t cmdId) { CpaStatus status = CPA_STATUS_FAIL; CpaInstanceHandle instanceHandle = LacKey_GetHandle(instanceHandle_in); LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); SAL_RUNNING_CHECK(instanceHandle); status = LacSymKey_CheckParamSslTls(pKeyGenOpData, hashAlgorithm, pGeneratedKeyBuffer, cmdId); if (CPA_STATUS_SUCCESS != status) return status; return LacSymKey_KeyGenSslTls_GenCommon(instanceHandle, pKeyGenCb, pCallbackTag, cmdId, LAC_CONST_PTR_CAST( pKeyGenOpData), hashAlgorithm, pGeneratedKeyBuffer); } /** * @ingroup LacSymKey * SSL Key Generation Function. * @description * This function is used for SSL key generation. It implements the key * generation function defined in section 6.2.2 of the SSL 3.0 * specification as described in * http://www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt. * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * * @param[in] instanceHandle_in Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenSslOpData Pointer to a structure containing all * the data needed to perform the SSL key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. */ CpaStatus cpaCyKeyGenSsl(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenSslOpData *pKeyGenSslOpData, CpaFlatBuffer *pGeneratedKeyBuffer) { CpaInstanceHandle instanceHandle = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } return LacSymKey_KeyGenSslTls(instanceHandle, pKeyGenCb, pCallbackTag, LAC_CONST_PTR_CAST(pKeyGenSslOpData), CPA_CY_SYM_HASH_NONE, /* Hash algorithm */ pGeneratedKeyBuffer, ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE); } /** * @ingroup LacSymKey * TLS Key Generation Function. * @description * This function is used for TLS key generation. It implements the * TLS PRF (Pseudo Random Function) as defined by RFC2246 (TLS v1.0) * and RFC4346 (TLS v1.1). * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * * @param[in] instanceHandle_in Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenTlsOpData Pointer to a structure containing all * the data needed to perform the TLS key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * */ CpaStatus cpaCyKeyGenTls(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenTlsOpData *pKeyGenTlsOpData, CpaFlatBuffer *pGeneratedKeyBuffer) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } return LacSymKey_KeyGenSslTls(instanceHandle, pKeyGenCb, pCallbackTag, LAC_CONST_PTR_CAST(pKeyGenTlsOpData), CPA_CY_SYM_HASH_NONE, /* Hash algorithm */ pGeneratedKeyBuffer, ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE); } /** * @ingroup LacSymKey * @description * This function is used for TLS key generation. It implements the * TLS PRF (Pseudo Random Function) as defined by RFC5246 (TLS v1.2). * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * * @param[in] instanceHandle_in Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenTlsOpData Pointer to a structure containing all * the data needed to perform the TLS key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. */ CpaStatus cpaCyKeyGenTls2(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenTlsOpData *pKeyGenTlsOpData, CpaCySymHashAlgorithm hashAlgorithm, CpaFlatBuffer *pGeneratedKeyBuffer) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } return LacSymKey_KeyGenSslTls(instanceHandle, pKeyGenCb, pCallbackTag, LAC_CONST_PTR_CAST(pKeyGenTlsOpData), hashAlgorithm, pGeneratedKeyBuffer, ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE); } /** * @ingroup LacSymKey * @description * This function is used for TLS1.3 HKDF key generation. It implements * the "extract-then-expand" paradigm as defined by RFC 5869. * * The input seed/secret/info is taken as a flat buffer and the generated * key(s)/labels are returned to caller in a flat data buffer. * * @param[in] instanceHandle_in Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenTlsOpData Pointer to a structure containing * the data needed to perform the HKDF key * generation operation. * The client code allocates the memory * for this structure as contiguous * pinned memory. * This component takes ownership of the * memory until it is returned in the * callback. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. */ CpaStatus cpaCyKeyGenTls3(const CpaInstanceHandle instanceHandle_in, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenHKDFOpData *pKeyGenTlsOpData, CpaCyKeyHKDFCipherSuite cipherSuite, CpaFlatBuffer *pGeneratedKeyBuffer) { LAC_CHECK_NULL_PARAM(pKeyGenTlsOpData); switch (pKeyGenTlsOpData->hkdfKeyOp) { case CPA_CY_HKDF_KEY_EXTRACT: /* Fall through */ case CPA_CY_HKDF_KEY_EXPAND: case CPA_CY_HKDF_KEY_EXTRACT_EXPAND: case CPA_CY_HKDF_KEY_EXPAND_LABEL: case CPA_CY_HKDF_KEY_EXTRACT_EXPAND_LABEL: break; default: LAC_INVALID_PARAM_LOG("HKDF operation not supported"); return CPA_STATUS_INVALID_PARAM; } - return LacSymKey_KeyGenSslTls(instanceHandle_in, pKeyGenCb, pCallbackTag, LAC_CONST_PTR_CAST(pKeyGenTlsOpData), cipherSuite, pGeneratedKeyBuffer, (icp_qat_fw_la_cmd_id_t) pKeyGenTlsOpData->hkdfKeyOp); } /* * LacSymKey_Init */ CpaStatus LacSymKey_Init(CpaInstanceHandle instanceHandle_in) { CpaStatus status = CPA_STATUS_SUCCESS; CpaInstanceHandle instanceHandle = LacKey_GetHandle(instanceHandle_in); sal_crypto_service_t *pService = NULL; LAC_CHECK_INSTANCE_HANDLE(instanceHandle); pService = (sal_crypto_service_t *)instanceHandle; pService->pLacKeyStats = LAC_OS_MALLOC(LAC_KEY_NUM_STATS * sizeof(QatUtilsAtomic)); if (NULL != pService->pLacKeyStats) { LAC_OS_BZERO((void *)pService->pLacKeyStats, LAC_KEY_NUM_STATS * sizeof(QatUtilsAtomic)); status = LAC_OS_CAMALLOC(&pService->pSslLabel, ICP_QAT_FW_LA_SSL_LABEL_LEN_MAX, LAC_8BYTE_ALIGNMENT, pService->nodeAffinity); } else { status = CPA_STATUS_RESOURCE; } if (CPA_STATUS_SUCCESS == status) { Cpa32U i = 0; Cpa32U offset = 0; /* Initialise SSL label ABBCCC..... */ for (i = 0; i < ICP_QAT_FW_LA_SSL_ITERATES_LEN_MAX; i++) { memset(pService->pSslLabel + offset, 'A' + i, i + 1); offset += (i + 1); } /* Allocate memory for TLS labels */ status = LAC_OS_CAMALLOC(&pService->pTlsLabel, sizeof(lac_sym_key_tls_labels_t), LAC_8BYTE_ALIGNMENT, pService->nodeAffinity); } if (CPA_STATUS_SUCCESS == status) { /* Allocate memory for HKDF sub_labels */ status = LAC_OS_CAMALLOC(&pService->pTlsHKDFSubLabel, sizeof(lac_sym_key_tls_hkdf_sub_labels_t), LAC_8BYTE_ALIGNMENT, pService->nodeAffinity); } if (CPA_STATUS_SUCCESS == status) { LAC_OS_BZERO(pService->pTlsLabel, sizeof(lac_sym_key_tls_labels_t)); /* Copy the TLS v1.2 labels into the dynamically allocated * structure */ memcpy(pService->pTlsLabel->masterSecret, LAC_SYM_KEY_TLS_MASTER_SECRET_LABEL, sizeof(LAC_SYM_KEY_TLS_MASTER_SECRET_LABEL) - 1); memcpy(pService->pTlsLabel->keyMaterial, LAC_SYM_KEY_TLS_KEY_MATERIAL_LABEL, sizeof(LAC_SYM_KEY_TLS_KEY_MATERIAL_LABEL) - 1); memcpy(pService->pTlsLabel->clientFinished, LAC_SYM_KEY_TLS_CLIENT_FIN_LABEL, sizeof(LAC_SYM_KEY_TLS_CLIENT_FIN_LABEL) - 1); memcpy(pService->pTlsLabel->serverFinished, LAC_SYM_KEY_TLS_SERVER_FIN_LABEL, sizeof(LAC_SYM_KEY_TLS_SERVER_FIN_LABEL) - 1); LAC_OS_BZERO(pService->pTlsHKDFSubLabel, sizeof(lac_sym_key_tls_hkdf_sub_labels_t)); /* Copy the TLS v1.3 subLabels into the dynamically allocated * struct */ /* KEY SHA-256 */ memcpy(&pService->pTlsHKDFSubLabel->keySublabel256, &key256, HKDF_SUB_LABEL_KEY_LENGTH); pService->pTlsHKDFSubLabel->keySublabel256.labelLen = HKDF_SUB_LABEL_KEY_LENGTH; pService->pTlsHKDFSubLabel->keySublabel256.sublabelFlag = 1 << QAT_FW_HKDF_INNER_SUBLABEL_16_BYTE_OKM_BITPOS; /* KEY SHA-384 */ memcpy(&pService->pTlsHKDFSubLabel->keySublabel384, &key384, HKDF_SUB_LABEL_KEY_LENGTH); pService->pTlsHKDFSubLabel->keySublabel384.labelLen = HKDF_SUB_LABEL_KEY_LENGTH; pService->pTlsHKDFSubLabel->keySublabel384.sublabelFlag = 1 << QAT_FW_HKDF_INNER_SUBLABEL_32_BYTE_OKM_BITPOS; /* KEY CHACHAPOLY */ memcpy(&pService->pTlsHKDFSubLabel->keySublabelChaChaPoly, &keyChaChaPoly, HKDF_SUB_LABEL_KEY_LENGTH); pService->pTlsHKDFSubLabel->keySublabelChaChaPoly.labelLen = HKDF_SUB_LABEL_KEY_LENGTH; pService->pTlsHKDFSubLabel->keySublabelChaChaPoly.sublabelFlag = 1 << QAT_FW_HKDF_INNER_SUBLABEL_32_BYTE_OKM_BITPOS; /* IV SHA-256 */ memcpy(&pService->pTlsHKDFSubLabel->ivSublabel256, &iv256, HKDF_SUB_LABEL_IV_LENGTH); pService->pTlsHKDFSubLabel->ivSublabel256.labelLen = HKDF_SUB_LABEL_IV_LENGTH; pService->pTlsHKDFSubLabel->ivSublabel256.sublabelFlag = 1 << QAT_FW_HKDF_INNER_SUBLABEL_12_BYTE_OKM_BITPOS; /* IV SHA-384 */ memcpy(&pService->pTlsHKDFSubLabel->ivSublabel384, &iv384, HKDF_SUB_LABEL_IV_LENGTH); pService->pTlsHKDFSubLabel->ivSublabel384.labelLen = HKDF_SUB_LABEL_IV_LENGTH; pService->pTlsHKDFSubLabel->ivSublabel384.sublabelFlag = 1 << QAT_FW_HKDF_INNER_SUBLABEL_12_BYTE_OKM_BITPOS; /* IV CHACHAPOLY */ memcpy(&pService->pTlsHKDFSubLabel->ivSublabelChaChaPoly, &iv256, HKDF_SUB_LABEL_IV_LENGTH); pService->pTlsHKDFSubLabel->ivSublabelChaChaPoly.labelLen = HKDF_SUB_LABEL_IV_LENGTH; pService->pTlsHKDFSubLabel->ivSublabelChaChaPoly.sublabelFlag = 1 << QAT_FW_HKDF_INNER_SUBLABEL_12_BYTE_OKM_BITPOS; /* RESUMPTION SHA-256 */ memcpy(&pService->pTlsHKDFSubLabel->resumptionSublabel256, &resumption256, HKDF_SUB_LABEL_RESUMPTION_LENGTH); pService->pTlsHKDFSubLabel->resumptionSublabel256.labelLen = HKDF_SUB_LABEL_RESUMPTION_LENGTH; /* RESUMPTION SHA-384 */ memcpy(&pService->pTlsHKDFSubLabel->resumptionSublabel384, &resumption384, HKDF_SUB_LABEL_RESUMPTION_LENGTH); pService->pTlsHKDFSubLabel->resumptionSublabel384.labelLen = HKDF_SUB_LABEL_RESUMPTION_LENGTH; /* RESUMPTION CHACHAPOLY */ memcpy( &pService->pTlsHKDFSubLabel->resumptionSublabelChaChaPoly, &resumption256, HKDF_SUB_LABEL_RESUMPTION_LENGTH); pService->pTlsHKDFSubLabel->resumptionSublabelChaChaPoly .labelLen = HKDF_SUB_LABEL_RESUMPTION_LENGTH; /* FINISHED SHA-256 */ memcpy(&pService->pTlsHKDFSubLabel->finishedSublabel256, &finished256, HKDF_SUB_LABEL_FINISHED_LENGTH); pService->pTlsHKDFSubLabel->finishedSublabel256.labelLen = HKDF_SUB_LABEL_FINISHED_LENGTH; /* FINISHED SHA-384 */ memcpy(&pService->pTlsHKDFSubLabel->finishedSublabel384, &finished384, HKDF_SUB_LABEL_FINISHED_LENGTH); pService->pTlsHKDFSubLabel->finishedSublabel384.labelLen = HKDF_SUB_LABEL_FINISHED_LENGTH; /* FINISHED CHACHAPOLY */ memcpy(&pService->pTlsHKDFSubLabel->finishedSublabelChaChaPoly, &finished256, HKDF_SUB_LABEL_FINISHED_LENGTH); pService->pTlsHKDFSubLabel->finishedSublabelChaChaPoly .labelLen = HKDF_SUB_LABEL_FINISHED_LENGTH; /* Set physical address of sublabels */ pService->pTlsHKDFSubLabel->sublabelPhysAddr256 = LAC_OS_VIRT_TO_PHYS_INTERNAL( &pService->pTlsHKDFSubLabel->keySublabel256); pService->pTlsHKDFSubLabel->sublabelPhysAddr384 = LAC_OS_VIRT_TO_PHYS_INTERNAL( &pService->pTlsHKDFSubLabel->keySublabel384); pService->pTlsHKDFSubLabel->sublabelPhysAddrChaChaPoly = LAC_OS_VIRT_TO_PHYS_INTERNAL( &pService->pTlsHKDFSubLabel->keySublabelChaChaPoly); /* Register request handlers */ LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister( ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister( ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_HKDF_EXTRACT, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_HKDF_EXPAND, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister( ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister( ICP_QAT_FW_LA_CMD_HKDF_EXPAND_LABEL, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister( ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL, LacSymKey_SslTlsHandleResponse); LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_MGF1, LacSymKey_MgfHandleResponse); } if (CPA_STATUS_SUCCESS != status) { LAC_OS_FREE(pService->pLacKeyStats); LAC_OS_CAFREE(pService->pSslLabel); LAC_OS_CAFREE(pService->pTlsLabel); LAC_OS_CAFREE(pService->pTlsHKDFSubLabel); } return status; } /* * LacSymKey_Shutdown */ CpaStatus LacSymKey_Shutdown(CpaInstanceHandle instanceHandle_in) { CpaStatus status = CPA_STATUS_SUCCESS; CpaInstanceHandle instanceHandle = LacKey_GetHandle(instanceHandle_in); sal_crypto_service_t *pService = NULL; LAC_CHECK_INSTANCE_HANDLE(instanceHandle); pService = (sal_crypto_service_t *)instanceHandle; if (NULL != pService->pLacKeyStats) { LAC_OS_FREE(pService->pLacKeyStats); } LAC_OS_CAFREE(pService->pSslLabel); LAC_OS_CAFREE(pService->pTlsLabel); LAC_OS_CAFREE(pService->pTlsHKDFSubLabel); return status; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_alg_chain.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_alg_chain.c index 5b4ebdc85654..56f211025103 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_alg_chain.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_alg_chain.c @@ -1,2395 +1,2391 @@ -/*************************************************************************** - * - * - * - ***************************************************************************/ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_alg_chain.c Algorithm Chaining Perform * * @ingroup LacAlgChain ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_accel_devices.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_adf_debug.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_mem.h" #include "lac_log.h" #include "lac_sym.h" #include "lac_list.h" #include "icp_qat_fw_la.h" #include "lac_sal_types_crypto.h" #include "lac_sal.h" #include "lac_sal_ctrl.h" #include "lac_sym_alg_chain.h" #include "lac_sym_cipher.h" #include "lac_sym_cipher_defs.h" #include "lac_sym_hash.h" #include "lac_sym_hash_defs.h" #include "lac_sym_qat_cipher.h" #include "lac_sym_qat_hash.h" #include "lac_sym_stats.h" #include "lac_sym_queue.h" #include "lac_sym_cb.h" #include "sal_string_parse.h" #include "lac_sym_auth_enc.h" #include "lac_sym_qat.h" #include "sal_hw_gen.h" /** * @ingroup LacAlgChain * This callback function will be invoked whenever a hash precompute * operation completes. It will dequeue and send any QAT requests * which were queued up while the precompute was in progress. * * @param[in] callbackTag Opaque value provided by user. This will * be a pointer to the session descriptor. * * @retval * None * */ static void LacSymAlgChain_HashPrecomputeDoneCb(void *callbackTag) { LacSymCb_PendingReqsDequeue((lac_session_desc_t *)callbackTag); } /** * @ingroup LacAlgChain * Walk the buffer list and find the address for the given offset within * a buffer. * * @param[in] pBufferList Buffer List * @param[in] packetOffset Offset in the buffer list for which address * is to be found. * @param[out] ppDataPtr This is where the sought pointer will be put * @param[out] pSpaceLeft Pointer to a variable in which information about * available space from the given offset to the end * of the flat buffer it is located in will be returned * * @retval CPA_STATUS_SUCCESS Address with a given offset is found in the list * @retval CPA_STATUS_FAIL Address with a given offset not found in the list. * */ static CpaStatus LacSymAlgChain_PtrFromOffsetGet(const CpaBufferList *pBufferList, const Cpa32U packetOffset, Cpa8U **ppDataPtr) { Cpa32U currentOffset = 0; Cpa32U i = 0; for (i = 0; i < pBufferList->numBuffers; i++) { Cpa8U *pCurrData = pBufferList->pBuffers[i].pData; Cpa32U currDataSize = pBufferList->pBuffers[i].dataLenInBytes; /* If the offset is within the address space of the current * buffer */ if ((packetOffset >= currentOffset) && (packetOffset < (currentOffset + currDataSize))) { /* increment by offset of the address in the current * buffer */ *ppDataPtr = pCurrData + (packetOffset - currentOffset); return CPA_STATUS_SUCCESS; } /* Increment by the size of the buffer */ currentOffset += currDataSize; } return CPA_STATUS_FAIL; } /** * @ingroup LacAlgChain * Function which checks for support of partial packets for symmetric * crypto operations * * @param[in] pService Pointer to service descriptor * @param[in/out] pSessionDesc Pointer to session descriptor * */ static void LacSymCheck_IsPartialSupported(Cpa32U capabilitiesMask, lac_session_desc_t *pSessionDesc) { CpaBoolean isHashPartialSupported = CPA_FALSE; CpaBoolean isCipherPartialSupported = CPA_FALSE; CpaBoolean isPartialSupported = CPA_FALSE; switch (pSessionDesc->cipherAlgorithm) { /* Following ciphers don't support partial */ case CPA_CY_SYM_CIPHER_KASUMI_F8: case CPA_CY_SYM_CIPHER_AES_F8: case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: case CPA_CY_SYM_CIPHER_CHACHA: case CPA_CY_SYM_CIPHER_ZUC_EEA3: break; /* All others support partial */ default: isCipherPartialSupported = CPA_TRUE; break; } switch (pSessionDesc->hashAlgorithm) { /* Following hash don't support partial */ case CPA_CY_SYM_HASH_KASUMI_F9: case CPA_CY_SYM_HASH_SNOW3G_UIA2: case CPA_CY_SYM_HASH_POLY: case CPA_CY_SYM_HASH_ZUC_EIA3: break; /* Following hash may support partial based on device capabilities */ case CPA_CY_SYM_HASH_SHA3_256: if (ICP_ACCEL_CAPABILITIES_SHA3_EXT & capabilitiesMask) { isHashPartialSupported = CPA_TRUE; } break; /* All others support partial */ default: isHashPartialSupported = CPA_TRUE; break; } switch (pSessionDesc->symOperation) { case CPA_CY_SYM_OP_CIPHER: isPartialSupported = isCipherPartialSupported; break; case CPA_CY_SYM_OP_HASH: isPartialSupported = isHashPartialSupported; break; case CPA_CY_SYM_OP_ALGORITHM_CHAINING: if (isCipherPartialSupported && isHashPartialSupported) { isPartialSupported = CPA_TRUE; } break; case CPA_CY_SYM_OP_NONE: break; default: break; } if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == pSessionDesc->cipherSliceType) { /* UCS slice has no support for state flush and * because of that is not able to do partial processing */ isPartialSupported = CPA_FALSE; } pSessionDesc->isPartialSupported = isPartialSupported; } static void LacAlgChain_CipherCDBuild_ForOptimisedCD( const CpaCySymCipherSetupData *pCipherData, lac_session_desc_t *pSessionDesc, icp_qat_fw_slice_t nextSlice, Cpa8U cipherOffsetInConstantsTable, Cpa8U *pOptimisedHwBlockBaseInDRAM, Cpa32U *pOptimisedHwBlockOffsetInDRAM) { Cpa8U *pCipherKeyField = NULL; Cpa32U sizeInBytes = 0; pCipherKeyField = pOptimisedHwBlockBaseInDRAM; /* Need to build up the alternative CD for SHRAM Constants Table use * with an optimised content desc of 64 bytes for this case. Cipher key * will be in the Content desc in DRAM, The cipher config data * is now in the SHRAM constants table. */ LacSymQat_CipherHwBlockPopulateKeySetup( pSessionDesc, pCipherData, pCipherData->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, pCipherKeyField, &sizeInBytes); LacSymQat_CipherCtrlBlockWrite(&(pSessionDesc->shramReqCacheFtr), pSessionDesc->cipherAlgorithm, pSessionDesc->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, nextSlice, cipherOffsetInConstantsTable); *pOptimisedHwBlockOffsetInDRAM += sizeInBytes; } static void LacAlgChain_CipherCDBuild_ForSHRAM(const CpaCySymCipherSetupData *pCipherData, lac_session_desc_t *pSessionDesc, icp_qat_fw_slice_t nextSlice, Cpa8U cipherOffsetInConstantsTable) { Cpa32U sizeInBytes = 0; Cpa8U *pCipherKeyField = NULL; /* Need to build up the alternative CD for SHRAM Constants Table use * Cipher key will be in the Request, The cipher config data is now in * the SHRAM constants table. And nothing is now stored in the content * desc */ pCipherKeyField = (Cpa8U *)&( pSessionDesc->shramReqCacheHdr.cd_pars.s1.serv_specif_fields); LacSymQat_CipherHwBlockPopulateKeySetup( pSessionDesc, pCipherData, pCipherData->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, pCipherKeyField, &sizeInBytes); LacSymQat_CipherCtrlBlockWrite(&(pSessionDesc->shramReqCacheFtr), pSessionDesc->cipherAlgorithm, pSessionDesc->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, nextSlice, cipherOffsetInConstantsTable); } static void LacAlgChain_CipherCDBuild(const CpaCySymCipherSetupData *pCipherData, lac_session_desc_t *pSessionDesc, icp_qat_fw_slice_t nextSlice, Cpa8U cipherOffsetInConstantsTable, icp_qat_fw_comn_flags *pCmnRequestFlags, icp_qat_fw_serv_specif_flags *pLaCmdFlags, Cpa8U *pHwBlockBaseInDRAM, Cpa32U *pHwBlockOffsetInDRAM, Cpa32U capabilitiesMask) { Cpa8U *pCipherKeyField = NULL; Cpa8U cipherOffsetInReqQW = 0; Cpa32U sizeInBytes = 0; void *pCfgData = NULL; Cpa32U cfgOffset = 0; /* Construct the ContentDescriptor in DRAM */ cipherOffsetInReqQW = (*pHwBlockOffsetInDRAM / LAC_QUAD_WORD_IN_BYTES); ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_SET( *pLaCmdFlags, ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_CD_SETUP); /* construct cipherConfig in CD in DRAM */ cfgOffset = *pHwBlockOffsetInDRAM; pCfgData = pHwBlockBaseInDRAM + cfgOffset; LacSymQat_CipherHwBlockPopulateCfgData(pSessionDesc, pCfgData, &sizeInBytes); ICP_QAT_FW_LA_SLICE_TYPE_SET(*pLaCmdFlags, pSessionDesc->cipherSliceType); *pHwBlockOffsetInDRAM += sizeInBytes; /* Cipher key will be in CD in DRAM. * The Request contains a ptr to the CD. * This ptr will be copied into the request later once the CD is * fully constructed, but the flag is set here. */ pCipherKeyField = pHwBlockBaseInDRAM + *pHwBlockOffsetInDRAM; ICP_QAT_FW_COMN_CD_FLD_TYPE_SET(*pCmnRequestFlags, QAT_COMN_CD_FLD_TYPE_64BIT_ADR); LacSymQat_CipherHwBlockPopulateKeySetup( pSessionDesc, pCipherData, pCipherData->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, pCipherKeyField, &sizeInBytes); /* update offset */ *pHwBlockOffsetInDRAM += sizeInBytes; LacSymQat_CipherCtrlBlockWrite(&(pSessionDesc->reqCacheFtr), pSessionDesc->cipherAlgorithm, pSessionDesc->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, nextSlice, cipherOffsetInReqQW); if (NON_SPC != pSessionDesc->singlePassState) { LacSymQat_CipherCtrlBlockWrite( &(pSessionDesc->reqSpcCacheFtr), pSessionDesc->cipherAlgorithm, pSessionDesc->cipherKeyLenInBytes, pSessionDesc->cipherSliceType, ICP_QAT_FW_SLICE_DRAM_WR, cipherOffsetInReqQW); } } static void LacAlgChain_HashCDBuild( const CpaCySymHashSetupData *pHashData, CpaInstanceHandle instanceHandle, lac_session_desc_t *pSessionDesc, icp_qat_fw_slice_t nextSlice, Cpa8U hashOffsetInConstantsTable, icp_qat_fw_comn_flags *pCmnRequestFlags, icp_qat_fw_serv_specif_flags *pLaCmdFlags, lac_sym_qat_hash_precompute_info_t *pPrecomputeData, lac_sym_qat_hash_precompute_info_t *pPrecomputeDataOptimisedCd, Cpa8U *pHwBlockBaseInDRAM, Cpa32U *pHwBlockOffsetInDRAM, Cpa8U *pOptimisedHwBlockBaseInDRAM, Cpa32U *pOptimisedHwBlockOffsetInDRAM) { Cpa32U sizeInBytes = 0; Cpa32U hwBlockOffsetInQuadWords = *pHwBlockOffsetInDRAM / LAC_QUAD_WORD_IN_BYTES; /* build: * - the hash part of the ContentDescriptor in DRAM */ /* - the hash part of the CD control block in the Request template */ LacSymQat_HashContentDescInit(&(pSessionDesc->reqCacheFtr), instanceHandle, pHashData, pHwBlockBaseInDRAM, hwBlockOffsetInQuadWords, nextSlice, pSessionDesc->qatHashMode, CPA_FALSE, CPA_FALSE, pSessionDesc->useStatefulSha3ContentDesc, pPrecomputeData, &sizeInBytes); /* Using DRAM CD so update offset */ *pHwBlockOffsetInDRAM += sizeInBytes; sizeInBytes = 0; if (pSessionDesc->useOptimisedContentDesc) { LacSymQat_HashContentDescInit(&(pSessionDesc->shramReqCacheFtr), instanceHandle, pHashData, pOptimisedHwBlockBaseInDRAM, hashOffsetInConstantsTable, nextSlice, pSessionDesc->qatHashMode, CPA_TRUE, CPA_TRUE, CPA_FALSE, pPrecomputeDataOptimisedCd, &sizeInBytes); *pOptimisedHwBlockOffsetInDRAM += sizeInBytes; } else if (pSessionDesc->useSymConstantsTable) { /* Need to build up the alternative CD for SHRAM Constants Table * use */ LacSymQat_HashContentDescInit(&(pSessionDesc->shramReqCacheFtr), instanceHandle, pHashData, pHwBlockBaseInDRAM, hashOffsetInConstantsTable, nextSlice, pSessionDesc->qatHashMode, CPA_TRUE, CPA_FALSE, CPA_FALSE, pPrecomputeData, &sizeInBytes); } } - static Cpa16U LacAlgChain_GetCipherConfigSize(lac_session_desc_t *pSessionDesc) { if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == pSessionDesc->cipherSliceType) { return sizeof(icp_qat_hw_ucs_cipher_config_t); } else { return sizeof(icp_qat_hw_cipher_config_t); } } static Cpa16U LacAlgChain_GetCipherConfigOffset(lac_session_desc_t *pSessionDesc) { Cpa16U offset = 0; if (CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionDesc->symOperation || SPC == pSessionDesc->singlePassState) { icp_qat_fw_cipher_auth_cd_ctrl_hdr_t *cd_ctrl = (icp_qat_fw_cipher_auth_cd_ctrl_hdr_t *)&pSessionDesc ->reqCacheFtr.cd_ctrl; offset = cd_ctrl->cipher_cfg_offset; } else if (CPA_CY_SYM_OP_CIPHER == pSessionDesc->symOperation) { icp_qat_fw_cipher_cd_ctrl_hdr_t *cd_ctrl = (icp_qat_fw_cipher_cd_ctrl_hdr_t *)&pSessionDesc ->reqCacheFtr.cd_ctrl; offset = cd_ctrl->cipher_cfg_offset; } return offset * LAC_QUAD_WORD_IN_BYTES; } CpaStatus LacAlgChain_SessionAADUpdate(lac_session_desc_t *pSessionDesc, Cpa32U newAADLength) { icp_qat_la_bulk_req_ftr_t *req_ftr = &pSessionDesc->reqCacheFtr; icp_qat_la_auth_req_params_t *req_params = &req_ftr->serv_specif_rqpars; if (!pSessionDesc) return CPA_STATUS_FAIL; pSessionDesc->aadLenInBytes = newAADLength; req_params->u2.aad_sz = LAC_ALIGN_POW2_ROUNDUP(newAADLength, LAC_HASH_AES_GCM_BLOCK_SIZE); if (SPC == pSessionDesc->singlePassState) { Cpa8U *pHwBlockBaseInDRAM = NULL; Cpa32U hwBlockOffsetInDRAM = 0; Cpa32U pSizeInBytes = 0; CpaCySymCipherAlgorithm cipher = pSessionDesc->cipherAlgorithm; pHwBlockBaseInDRAM = (Cpa8U *)pSessionDesc->contentDescInfo.pData; if (pSessionDesc->cipherDirection == CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT) { if (LAC_CIPHER_IS_GCM(cipher)) { hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_GCM_SPC_OFFSET_IN_DRAM); } else { hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_CHACHA_SPC_OFFSET_IN_DRAM); } } LacSymQat_CipherHwBlockPopulateCfgData(pSessionDesc, pHwBlockBaseInDRAM + hwBlockOffsetInDRAM, &pSizeInBytes); } return CPA_STATUS_SUCCESS; } CpaStatus LacAlgChain_SessionCipherKeyUpdate(lac_session_desc_t *pSessionDesc, Cpa8U *pCipherKey) { CpaStatus status = CPA_STATUS_SUCCESS; if (pSessionDesc == NULL || pCipherKey == NULL) return CPA_STATUS_FAIL; if (LAC_CIPHER_IS_ARC4(pSessionDesc->cipherAlgorithm)) { LacSymQat_CipherArc4StateInit( pCipherKey, pSessionDesc->cipherKeyLenInBytes, pSessionDesc->cipherARC4InitialState); } else { CpaCySymCipherSetupData cipherSetupData = { 0 }; Cpa32U sizeInBytes; Cpa8U *pCipherKeyField; Cpa16U cipherConfigSize; Cpa16U cipherConfigOffset; sal_qat_content_desc_info_t *pCdInfo = &(pSessionDesc->contentDescInfo); cipherSetupData.cipherAlgorithm = pSessionDesc->cipherAlgorithm; cipherSetupData.cipherKeyLenInBytes = pSessionDesc->cipherKeyLenInBytes; cipherSetupData.pCipherKey = pCipherKey; cipherSetupData.cipherDirection = pSessionDesc->cipherDirection; cipherConfigSize = LacAlgChain_GetCipherConfigSize(pSessionDesc); cipherConfigOffset = LacAlgChain_GetCipherConfigOffset(pSessionDesc); pCipherKeyField = (Cpa8U *)pCdInfo->pData + cipherConfigOffset + cipherConfigSize; switch (pSessionDesc->symOperation) { case CPA_CY_SYM_OP_CIPHER: { LacSymQat_CipherHwBlockPopulateKeySetup( pSessionDesc, &(cipherSetupData), cipherSetupData.cipherKeyLenInBytes, pSessionDesc->cipherSliceType, pCipherKeyField, &sizeInBytes); if (pSessionDesc->useSymConstantsTable) { pCipherKeyField = (Cpa8U *)&( pSessionDesc->shramReqCacheHdr.cd_pars.s1 .serv_specif_fields); LacSymQat_CipherHwBlockPopulateKeySetup( pSessionDesc, &(cipherSetupData), cipherSetupData.cipherKeyLenInBytes, pSessionDesc->cipherSliceType, pCipherKeyField, &sizeInBytes); } } break; case CPA_CY_SYM_OP_ALGORITHM_CHAINING: { LacSymQat_CipherHwBlockPopulateKeySetup( pSessionDesc, &(cipherSetupData), cipherSetupData.cipherKeyLenInBytes, pSessionDesc->cipherSliceType, pCipherKeyField, &sizeInBytes); } break; default: LAC_LOG_ERROR("Invalid sym operation\n"); status = CPA_STATUS_INVALID_PARAM; break; } } return status; } CpaStatus LacAlgChain_SessionAuthKeyUpdate(lac_session_desc_t *pSessionDesc, Cpa8U *pAuthKey) { CpaStatus status = CPA_STATUS_SUCCESS; Cpa8U *pHwBlockBaseInDRAM = NULL; Cpa8U *pOutHashSetup = NULL; Cpa8U *pInnerState1 = NULL; Cpa8U *pInnerState2 = NULL; CpaCySymSessionSetupData sessionSetup = { 0 }; Cpa16U cipherConfigSize; if (pSessionDesc == NULL || pAuthKey == NULL) return CPA_STATUS_FAIL; cipherConfigSize = LacAlgChain_GetCipherConfigSize(pSessionDesc); icp_qat_fw_cipher_auth_cd_ctrl_hdr_t *cd_ctrl = (icp_qat_fw_cipher_auth_cd_ctrl_hdr_t *)&pSessionDesc->reqCacheFtr .cd_ctrl; pHwBlockBaseInDRAM = (Cpa8U *)pSessionDesc->contentDescInfo.pData; sessionSetup.hashSetupData.hashAlgorithm = pSessionDesc->hashAlgorithm; sessionSetup.hashSetupData.hashMode = pSessionDesc->hashMode; sessionSetup.hashSetupData.authModeSetupData.authKey = pAuthKey; sessionSetup.hashSetupData.authModeSetupData.authKeyLenInBytes = pSessionDesc->authKeyLenInBytes; sessionSetup.hashSetupData.authModeSetupData.aadLenInBytes = pSessionDesc->aadLenInBytes; sessionSetup.hashSetupData.digestResultLenInBytes = pSessionDesc->hashResultSize; sessionSetup.cipherSetupData.cipherAlgorithm = pSessionDesc->cipherAlgorithm; sessionSetup.cipherSetupData.cipherKeyLenInBytes = pSessionDesc->cipherKeyLenInBytes; /* Calculate hash states offsets */ pInnerState1 = pHwBlockBaseInDRAM + cd_ctrl->hash_cfg_offset * LAC_QUAD_WORD_IN_BYTES + sizeof(icp_qat_hw_auth_setup_t); pInnerState2 = pInnerState1 + cd_ctrl->inner_state1_sz; pOutHashSetup = pInnerState2 + cd_ctrl->inner_state2_sz; /* Calculate offset of cipher key */ if (pSessionDesc->laCmdId == ICP_QAT_FW_LA_CMD_CIPHER_HASH) { sessionSetup.cipherSetupData.pCipherKey = (Cpa8U *)pHwBlockBaseInDRAM + cipherConfigSize; } else if (pSessionDesc->laCmdId == ICP_QAT_FW_LA_CMD_HASH_CIPHER) { sessionSetup.cipherSetupData.pCipherKey = pOutHashSetup + cipherConfigSize; } else if (SPC == pSessionDesc->singlePassState) { CpaCySymCipherAlgorithm cipher = pSessionDesc->cipherAlgorithm; Cpa32U hwBlockOffsetInDRAM = 0; if (pSessionDesc->cipherDirection == CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT) { sessionSetup.cipherSetupData.pCipherKey = (Cpa8U *)pHwBlockBaseInDRAM + cipherConfigSize; } else { if (LAC_CIPHER_IS_GCM(cipher)) hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_GCM_SPC_OFFSET_IN_DRAM); else hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_CHACHA_SPC_OFFSET_IN_DRAM); sessionSetup.cipherSetupData.pCipherKey = (Cpa8U *)pHwBlockBaseInDRAM + hwBlockOffsetInDRAM + cipherConfigSize; } } if (!sessionSetup.cipherSetupData.pCipherKey) return CPA_STATUS_FAIL; if (CPA_CY_SYM_HASH_SHA3_256 == pSessionDesc->hashAlgorithm) { if (CPA_FALSE == pSessionDesc->isAuthEncryptOp) { lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo = &(pSessionDesc->hashStateBufferInfo); sal_crypto_service_t *pService = (sal_crypto_service_t *)pSessionDesc->pInstance; status = LacHash_StatePrefixAadBufferInit( &(pService->generic_service_info), &(sessionSetup.hashSetupData), &(pSessionDesc->reqCacheFtr), pSessionDesc->qatHashMode, pSessionDesc->hashStatePrefixBuffer, pHashStateBufferInfo); /* SHRAM Constants Table not used for Auth-Enc */ } } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pSessionDesc->hashAlgorithm) { Cpa8U *authKey = (Cpa8U *)pOutHashSetup + cipherConfigSize; memcpy(authKey, pAuthKey, pSessionDesc->authKeyLenInBytes); } else if (CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm || CPA_CY_SYM_HASH_AES_CBC_MAC == pSessionDesc->hashAlgorithm) { memcpy(pInnerState2, pAuthKey, pSessionDesc->authKeyLenInBytes); } else if (CPA_CY_SYM_HASH_AES_CMAC == pSessionDesc->hashAlgorithm || CPA_CY_SYM_HASH_KASUMI_F9 == pSessionDesc->hashAlgorithm || IS_HASH_MODE_1(pSessionDesc->qatHashMode)) { if (CPA_CY_SYM_HASH_AES_CMAC == pSessionDesc->hashAlgorithm) { memset(pInnerState2, 0, cd_ctrl->inner_state2_sz); } /* Block messages until precompute is completed */ pSessionDesc->nonBlockingOpsInProgress = CPA_FALSE; status = LacHash_PrecomputeDataCreate( pSessionDesc->pInstance, (CpaCySymSessionSetupData *)&(sessionSetup), LacSymAlgChain_HashPrecomputeDoneCb, pSessionDesc, pSessionDesc->hashStatePrefixBuffer, pInnerState1, pInnerState2); } return status; } static void buildCmdData(sal_crypto_service_t *pService, lac_session_desc_t *pSessionDesc, CpaCySymAlgChainOrder *chainOrder, Cpa16U *proto, icp_qat_fw_serv_specif_flags *laCmdFlags, icp_qat_fw_comn_flags *cmnRequestFlags) { /* LW 28 is used to set hash flags for AlgChaining. */ icp_qat_fw_cipher_auth_cd_ctrl_hdr_t *cd_ctrl = (icp_qat_fw_cipher_auth_cd_ctrl_hdr_t *)&pSessionDesc->reqCacheFtr .cd_ctrl; /* proto refers to Protocol Flags, which is legacy FW <=> IA interface * for ZUC and Snow3G. Use extended protocol flags for AlgChaining. */ *proto = ICP_QAT_FW_LA_NO_PROTO; /* no CCM/GCM/Snow3G */ switch (pSessionDesc->symOperation) { case CPA_CY_SYM_OP_CIPHER: pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_CIPHER; if (CPA_CY_SYM_CIPHER_SNOW3G_UEA2 == pSessionDesc->cipherAlgorithm) { *proto = ICP_QAT_FW_LA_SNOW_3G_PROTO; } else if (CPA_CY_SYM_CIPHER_ZUC_EEA3 == pSessionDesc->cipherAlgorithm) { *proto = ICP_QAT_FW_LA_ZUC_3G_PROTO; } if (LAC_CIPHER_IS_CCM(pSessionDesc->cipherAlgorithm)) { *proto = ICP_QAT_FW_LA_CCM_PROTO; } break; case CPA_CY_SYM_OP_HASH: pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_AUTH; if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pSessionDesc->hashAlgorithm) { *proto = ICP_QAT_FW_LA_SNOW_3G_PROTO; } else if (CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm) { *proto = ICP_QAT_FW_LA_ZUC_3G_PROTO; } break; case CPA_CY_SYM_OP_ALGORITHM_CHAINING: if (LAC_CIPHER_IS_CCM(pSessionDesc->cipherAlgorithm)) { *proto = ICP_QAT_FW_LA_CCM_PROTO; /* Derive chainOrder from direction for isAuthEncryptOp * cases */ /* For CCM & GCM modes: force digest verify flag _TRUE for decrypt and _FALSE for encrypt. For all other cases use user defined value */ if (CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT == pSessionDesc->cipherDirection) { *chainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER; pSessionDesc->digestVerify = CPA_FALSE; } else { *chainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH; if (CPA_TRUE == pService->forceAEADMacVerify) { pSessionDesc->digestVerify = CPA_TRUE; } } } else if (LAC_CIPHER_IS_GCM(pSessionDesc->cipherAlgorithm)) { *proto = ICP_QAT_FW_LA_GCM_PROTO; /* Derive chainOrder from direction for isAuthEncryptOp * cases */ /* For CCM & GCM modes: force digest verify flag _TRUE for decrypt and _FALSE for encrypt. For all other cases use user defined value */ if (CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT == pSessionDesc->cipherDirection) { *chainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH; pSessionDesc->digestVerify = CPA_FALSE; } else { *chainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER; if (CPA_TRUE == pService->forceAEADMacVerify) { pSessionDesc->digestVerify = CPA_TRUE; } } } else if (LAC_CIPHER_IS_CHACHA( pSessionDesc->cipherAlgorithm)) { if (CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT == pSessionDesc->cipherDirection) { *chainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH; } else { *chainOrder = CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER; } } else { pSessionDesc->isAuthEncryptOp = CPA_FALSE; if (CPA_CY_SYM_CIPHER_SNOW3G_UEA2 == pSessionDesc->cipherAlgorithm) { *proto = ICP_QAT_FW_LA_SNOW_3G_PROTO; } else if (CPA_CY_SYM_CIPHER_ZUC_EEA3 == pSessionDesc->cipherAlgorithm) { *proto = ICP_QAT_FW_LA_ZUC_3G_PROTO; } if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pSessionDesc->hashAlgorithm) { /* Need to set LW 28 hash flags as well. */ ICP_QAT_FW_HASH_FLAG_SNOW3G_UIA2_SET( cd_ctrl->hash_flags, QAT_FW_LA_SNOW3G_UIA2); } else if (CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm) { /* Need to set LW 28 hash flags as well. */ ICP_QAT_FW_HASH_FLAG_ZUC_EIA3_SET( cd_ctrl->hash_flags, QAT_FW_LA_ZUC_EIA3); } } if (CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH == *chainOrder) { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_CIPHER_HASH; } else if (CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER == *chainOrder) { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_HASH_CIPHER; } break; default: break; } /* * Build the header flags with the default settings for this session. */ if (pSessionDesc->isDPSession == CPA_TRUE) { *cmnRequestFlags = ICP_QAT_FW_COMN_FLAGS_BUILD(QAT_COMN_CD_FLD_TYPE_64BIT_ADR, LAC_SYM_DP_QAT_PTR_TYPE); } else { *cmnRequestFlags = ICP_QAT_FW_COMN_FLAGS_BUILD(QAT_COMN_CD_FLD_TYPE_64BIT_ADR, LAC_SYM_DEFAULT_QAT_PTR_TYPE); } LacSymQat_LaSetDefaultFlags(laCmdFlags, pSessionDesc->symOperation); return; } static void updateLaCmdFlags(lac_session_desc_t *pSessionDesc, Cpa16U proto, icp_qat_fw_serv_specif_flags *laCmdFlags) { if (pSessionDesc->isAuth) { if (pSessionDesc->digestVerify) { ICP_QAT_FW_LA_CMP_AUTH_SET(*laCmdFlags, ICP_QAT_FW_LA_CMP_AUTH_RES); ICP_QAT_FW_LA_RET_AUTH_SET( *laCmdFlags, ICP_QAT_FW_LA_NO_RET_AUTH_RES); } else { ICP_QAT_FW_LA_RET_AUTH_SET(*laCmdFlags, ICP_QAT_FW_LA_RET_AUTH_RES); ICP_QAT_FW_LA_CMP_AUTH_SET( *laCmdFlags, ICP_QAT_FW_LA_NO_CMP_AUTH_RES); } } if ((CPA_CY_SYM_CIPHER_ZUC_EEA3 == pSessionDesc->cipherAlgorithm) || (CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm)) { /* New bit position (12) for ZUC. The FW provides a specific * macro to use to set the ZUC proto flag. With the new FW I/F * this needs to be set for both Cipher and Auth */ ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_SET(*laCmdFlags, proto); } else { /* Configure the common header */ ICP_QAT_FW_LA_PROTO_SET(*laCmdFlags, proto); } /* set Append flag, if digest is appended */ if (pSessionDesc->digestIsAppended) { ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET( *laCmdFlags, ICP_QAT_FW_LA_DIGEST_IN_BUFFER); } else { ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET( *laCmdFlags, ICP_QAT_FW_LA_NO_DIGEST_IN_BUFFER); } } static lac_single_pass_state_t LacSymAlgChain_GetSpcState(CpaCySymCipherAlgorithm cipher, CpaCySymHashAlgorithm hash, Cpa32U capabilitiesMask) { lac_single_pass_state_t state = NON_SPC; if (capabilitiesMask & ICP_ACCEL_CAPABILITIES_CHACHA_POLY) { switch (cipher) { case CPA_CY_SYM_CIPHER_CHACHA: { if (CPA_CY_SYM_HASH_POLY == hash) state = SPC; break; } case CPA_CY_SYM_CIPHER_AES_GCM: { if ((CPA_CY_SYM_HASH_AES_GCM == hash) || (CPA_CY_SYM_HASH_AES_GMAC == hash)) state = LIKELY_SPC; break; } case CPA_CY_SYM_CIPHER_AES_CCM: { if (LAC_CIPHER_AES_V2(capabilitiesMask)) state = SPC; } default: /* Do Nothing as it is NON_SPC */ break; } } return state; } static CpaBoolean LacAlgChain_UseStatefulSha3ContentDesc(CpaBoolean partialsNotRequired, Cpa32U capabilitiesMask, lac_session_desc_t *pSessionDesc) { CpaBoolean hasSha3Ext = ICP_ACCEL_CAPABILITIES_SHA3_EXT & capabilitiesMask; CpaBoolean useStatefulSha3DescFlag = CPA_FALSE; if (hasSha3Ext && !partialsNotRequired && (pSessionDesc->symOperation == CPA_CY_SYM_OP_HASH) && LAC_HASH_IS_SHA3(pSessionDesc->hashAlgorithm)) { useStatefulSha3DescFlag = CPA_TRUE; } return useStatefulSha3DescFlag; } /** @ingroup LacAlgChain */ CpaStatus LacAlgChain_SessionInit(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, lac_session_desc_t *pSessionDesc) { CpaStatus stat, status = CPA_STATUS_SUCCESS; sal_qat_content_desc_info_t *pCdInfo = NULL; sal_qat_content_desc_info_t *pCdInfoOptimised = NULL; sal_crypto_service_t *pService = (sal_crypto_service_t *)instanceHandle; Cpa32U capabilitiesMask = pService->generic_service_info.capabilitiesMask; Cpa8U *pHwBlockBaseInDRAM = NULL; Cpa8U *pOptimisedHwBlockBaseInDRAM = NULL; Cpa32U hwBlockOffsetInDRAM = 0; Cpa32U optimisedHwBlockOffsetInDRAM = 0; Cpa8U cipherOffsetInConstantsTable = 0; Cpa8U hashOffsetInConstantsTable = 0; icp_qat_fw_comn_flags cmnRequestFlags = 0; icp_qat_fw_comn_req_t *pMsg = NULL; icp_qat_fw_comn_req_t *pMsgS = NULL; const CpaCySymCipherSetupData *pCipherData; const CpaCySymHashSetupData *pHashData; Cpa16U proto = ICP_QAT_FW_LA_NO_PROTO; /* no CCM/GCM/Snow3G */ CpaCySymAlgChainOrder chainOrder = 0; lac_sym_qat_hash_precompute_info_t precomputeData = { 0 }; lac_sym_qat_hash_precompute_info_t precomputeDataOptimisedCd = { 0 }; pCipherData = &(pSessionSetupData->cipherSetupData); pHashData = &(pSessionSetupData->hashSetupData); /*------------------------------------------------------------------------- * Populate session data *-----------------------------------------------------------------------*/ /* Initialise Request Queue */ stat = LAC_SPINLOCK_INIT(&pSessionDesc->requestQueueLock); if (CPA_STATUS_SUCCESS != stat) { LAC_LOG_ERROR("Spinlock init failed for sessionLock"); return CPA_STATUS_RESOURCE; } pSessionDesc->pRequestQueueHead = NULL; pSessionDesc->pRequestQueueTail = NULL; pSessionDesc->nonBlockingOpsInProgress = CPA_TRUE; pSessionDesc->pInstance = instanceHandle; pSessionDesc->digestIsAppended = pSessionSetupData->digestIsAppended; pSessionDesc->digestVerify = pSessionSetupData->verifyDigest; /* Reset the pending callback counter */ qatUtilsAtomicSet(0, &pSessionDesc->u.pendingCbCount); qatUtilsAtomicSet(0, &pSessionDesc->u.pendingDpCbCount); /* Partial state must be set to full, to indicate that next packet * expected on the session is a full packet or the start of a * partial packet. */ pSessionDesc->partialState = CPA_CY_SYM_PACKET_TYPE_FULL; pSessionDesc->symOperation = pSessionSetupData->symOperation; switch (pSessionDesc->symOperation) { case CPA_CY_SYM_OP_CIPHER: pSessionDesc->isCipher = CPA_TRUE; pSessionDesc->isAuth = CPA_FALSE; pSessionDesc->isAuthEncryptOp = CPA_FALSE; pSessionDesc->singlePassState = NON_SPC; break; case CPA_CY_SYM_OP_HASH: pSessionDesc->isCipher = CPA_FALSE; pSessionDesc->isAuth = CPA_TRUE; pSessionDesc->isAuthEncryptOp = CPA_FALSE; pSessionDesc->singlePassState = NON_SPC; break; case CPA_CY_SYM_OP_ALGORITHM_CHAINING: { pSessionDesc->isCipher = CPA_TRUE; pSessionDesc->isAuth = CPA_TRUE; pSessionDesc->singlePassState = LacSymAlgChain_GetSpcState(pCipherData->cipherAlgorithm, pHashData->hashAlgorithm, capabilitiesMask); switch (pSessionSetupData->cipherSetupData.cipherAlgorithm) { case CPA_CY_SYM_CIPHER_AES_CCM: { pSessionDesc->isAuthEncryptOp = CPA_TRUE; pSessionDesc->digestIsAppended = CPA_TRUE; } break; case CPA_CY_SYM_CIPHER_AES_GCM: case CPA_CY_SYM_CIPHER_CHACHA: pSessionDesc->isAuthEncryptOp = CPA_TRUE; break; default: { pSessionDesc->isAuthEncryptOp = CPA_FALSE; /* Use the chainOrder passed in */ chainOrder = pSessionSetupData->algChainOrder; if ((chainOrder != CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER) && (chainOrder != CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH)) { LAC_INVALID_PARAM_LOG("algChainOrder"); return CPA_STATUS_INVALID_PARAM; } } break; } } break; default: pSessionDesc->singlePassState = NON_SPC; break; } if (pSessionDesc->isCipher) { /* Populate cipher specific session data */ status = LacCipher_SessionSetupDataCheck(pCipherData, capabilitiesMask); if (CPA_STATUS_SUCCESS == status) { pSessionDesc->cipherAlgorithm = pCipherData->cipherAlgorithm; pSessionDesc->cipherKeyLenInBytes = pCipherData->cipherKeyLenInBytes; pSessionDesc->cipherDirection = pCipherData->cipherDirection; /* ARC4 base key isn't added to the content descriptor, * because we don't need to pass it directly to the QAT * engine. Instead an initial cipher state & key matrix * is derived from the base key and provided to the QAT * through the state pointer in the request params. * We'll store this initial state in the session * descriptor. */ if (LAC_CIPHER_IS_ARC4(pSessionDesc->cipherAlgorithm)) { LacSymQat_CipherArc4StateInit( pCipherData->pCipherKey, pSessionDesc->cipherKeyLenInBytes, pSessionDesc->cipherARC4InitialState); pSessionDesc->cipherARC4InitialStatePhysAddr = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, pSessionDesc->cipherARC4InitialState); if (0 == pSessionDesc ->cipherARC4InitialStatePhysAddr) { LAC_LOG_ERROR( "Unable to get the physical address of " "the initial state for ARC4\n"); status = CPA_STATUS_FAIL; } } } } if ((CPA_STATUS_SUCCESS == status) && pSessionDesc->isAuth) { /* Populate auth-specific session data */ const CpaCySymHashSetupData *pHashData = &pSessionSetupData->hashSetupData; status = LacHash_HashContextCheck(instanceHandle, pHashData); if (CPA_STATUS_SUCCESS == status) { pSessionDesc->hashResultSize = pHashData->digestResultLenInBytes; pSessionDesc->hashMode = pHashData->hashMode; pSessionDesc->hashAlgorithm = pHashData->hashAlgorithm; /* Save the authentication key length for further update */ if (CPA_CY_SYM_HASH_MODE_AUTH == pHashData->hashMode) { pSessionDesc->authKeyLenInBytes = pHashData->authModeSetupData .authKeyLenInBytes; } if (CPA_TRUE == pSessionDesc->isAuthEncryptOp || (pHashData->hashAlgorithm == CPA_CY_SYM_HASH_SNOW3G_UIA2 || pHashData->hashAlgorithm == CPA_CY_SYM_HASH_ZUC_EIA3)) { pSessionDesc->aadLenInBytes = pHashData->authModeSetupData.aadLenInBytes; } /* Set the QAT hash mode */ if ((pHashData->hashMode == CPA_CY_SYM_HASH_MODE_NESTED) || (pHashData->hashMode == CPA_CY_SYM_HASH_MODE_PLAIN) || (pHashData->hashMode == CPA_CY_SYM_HASH_MODE_AUTH && pHashData->hashAlgorithm == CPA_CY_SYM_HASH_AES_CBC_MAC)) { pSessionDesc->qatHashMode = ICP_QAT_HW_AUTH_MODE0; } else /* CPA_CY_SYM_HASH_MODE_AUTH && anything except CPA_CY_SYM_HASH_AES_CBC_MAC */ { if (IS_HMAC_ALG(pHashData->hashAlgorithm)) { /* SHA3 HMAC and SM3 do not support * precompute, force MODE2 for AUTH */ if (LAC_HASH_IS_SHA3( pHashData->hashAlgorithm) || (CPA_CY_SYM_HASH_SM3 == pHashData->hashAlgorithm)) { pSessionDesc->qatHashMode = ICP_QAT_HW_AUTH_MODE2; } else { pSessionDesc->qatHashMode = pService->qatHmacMode; } } else if (CPA_CY_SYM_HASH_ZUC_EIA3 == pHashData->hashAlgorithm) { pSessionDesc->qatHashMode = ICP_QAT_HW_AUTH_MODE0; } else { pSessionDesc->qatHashMode = ICP_QAT_HW_AUTH_MODE1; } } } } /*------------------------------------------------------------------------- * build the message templates * create two content descriptors in the case we can support using SHRAM * constants and an optimised content descriptor. we have to do this in * case of partials. 64 byte content descriptor is used in the SHRAM * case for AES-128-HMAC-SHA1 *-----------------------------------------------------------------------*/ if (CPA_STATUS_SUCCESS == status) { pSessionDesc->cipherSliceType = LacCipher_GetCipherSliceType(pService, pSessionDesc->cipherAlgorithm, pSessionDesc->hashAlgorithm); LacSymCheck_IsPartialSupported(capabilitiesMask, pSessionDesc); pSessionDesc->useOptimisedContentDesc = CPA_FALSE; pSessionDesc->useStatefulSha3ContentDesc = CPA_FALSE; /* Build configuration data */ buildCmdData(pService, pSessionDesc, &chainOrder, &proto, &pSessionDesc->laCmdFlags, &cmnRequestFlags); if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == pSessionDesc->cipherSliceType) pSessionDesc->useSymConstantsTable = CPA_FALSE; else pSessionDesc->useSymConstantsTable = LacSymQat_UseSymConstantsTable( pSessionDesc, &cipherOffsetInConstantsTable, &hashOffsetInConstantsTable); - /* for a certain combination of Algorthm Chaining we want to + /* for a certain combination of Algorithm Chaining we want to use an optimised cd block */ if (pSessionDesc->symOperation == CPA_CY_SYM_OP_ALGORITHM_CHAINING && pSessionDesc->useSymConstantsTable == CPA_TRUE) { pSessionDesc->useOptimisedContentDesc = LacSymQat_UseOptimisedContentDesc(pSessionDesc); } /* check whether we need to construct content desc for stateful * SHA3 */ pSessionDesc->useStatefulSha3ContentDesc = LacAlgChain_UseStatefulSha3ContentDesc( pSessionSetupData->partialsNotRequired, capabilitiesMask, pSessionDesc); /* setup some convenience pointers */ pCdInfo = &(pSessionDesc->contentDescInfo); pHwBlockBaseInDRAM = (Cpa8U *)pCdInfo->pData; hwBlockOffsetInDRAM = 0; /* set up the pointer for the optimised content desc if this is * possible we still have to support both cd types in case of * partials so we construct both */ if (pSessionDesc->useOptimisedContentDesc == CPA_TRUE) { pCdInfoOptimised = &(pSessionDesc->contentDescOptimisedInfo); pOptimisedHwBlockBaseInDRAM = (Cpa8U *)pCdInfoOptimised->pData; optimisedHwBlockOffsetInDRAM = 0; } switch (pSessionDesc->symOperation) { case CPA_CY_SYM_OP_CIPHER: { LacAlgChain_CipherCDBuild( pCipherData, pSessionDesc, ICP_QAT_FW_SLICE_DRAM_WR, cipherOffsetInConstantsTable, &pSessionDesc->cmnRequestFlags, &pSessionDesc->laCmdFlags, pHwBlockBaseInDRAM, &hwBlockOffsetInDRAM, capabilitiesMask); if (pSessionDesc->useSymConstantsTable) { LacAlgChain_CipherCDBuild_ForSHRAM( pCipherData, pSessionDesc, ICP_QAT_FW_SLICE_DRAM_WR, cipherOffsetInConstantsTable); } } break; case CPA_CY_SYM_OP_HASH: LacAlgChain_HashCDBuild(pHashData, instanceHandle, pSessionDesc, ICP_QAT_FW_SLICE_NULL, hashOffsetInConstantsTable, &pSessionDesc->cmnRequestFlags, &pSessionDesc->laCmdFlags, &precomputeData, &precomputeDataOptimisedCd, pHwBlockBaseInDRAM, &hwBlockOffsetInDRAM, NULL, NULL); break; case CPA_CY_SYM_OP_ALGORITHM_CHAINING: /* For CCM/GCM, CPM firmware currently expects the * cipher and hash h/w setup blocks to be arranged * according to the chain order (Except for GCM/CCM, * order doesn't actually matter as long as the config * offsets are set correctly in CD control blocks */ if (CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER == chainOrder) { LacAlgChain_HashCDBuild( pHashData, instanceHandle, pSessionDesc, ICP_QAT_FW_SLICE_CIPHER, hashOffsetInConstantsTable, &pSessionDesc->cmnRequestFlags, &pSessionDesc->laCmdFlags, &precomputeData, &precomputeDataOptimisedCd, pHwBlockBaseInDRAM, &hwBlockOffsetInDRAM, pOptimisedHwBlockBaseInDRAM, &optimisedHwBlockOffsetInDRAM); LacAlgChain_CipherCDBuild( pCipherData, pSessionDesc, ICP_QAT_FW_SLICE_DRAM_WR, cipherOffsetInConstantsTable, &pSessionDesc->cmnRequestFlags, &pSessionDesc->laCmdFlags, pHwBlockBaseInDRAM, &hwBlockOffsetInDRAM, capabilitiesMask); if (pSessionDesc->useOptimisedContentDesc) { LacAlgChain_CipherCDBuild_ForOptimisedCD( pCipherData, pSessionDesc, ICP_QAT_FW_SLICE_DRAM_WR, cipherOffsetInConstantsTable, pOptimisedHwBlockBaseInDRAM, &optimisedHwBlockOffsetInDRAM); } if (NON_SPC != pSessionDesc->singlePassState) { pCdInfo->hwBlkSzQuadWords = (LAC_BYTES_TO_QUADWORDS( hwBlockOffsetInDRAM)); pMsg = (icp_qat_fw_comn_req_t *)&( pSessionDesc->reqSpcCacheHdr); SalQatMsg_ContentDescHdrWrite( (icp_qat_fw_comn_req_t *)pMsg, pCdInfo); } } else /* CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH */ { LacAlgChain_CipherCDBuild( pCipherData, pSessionDesc, ICP_QAT_FW_SLICE_AUTH, cipherOffsetInConstantsTable, &pSessionDesc->cmnRequestFlags, &pSessionDesc->laCmdFlags, pHwBlockBaseInDRAM, &hwBlockOffsetInDRAM, capabilitiesMask); if (pSessionDesc->useOptimisedContentDesc) { LacAlgChain_CipherCDBuild_ForOptimisedCD( pCipherData, pSessionDesc, ICP_QAT_FW_SLICE_AUTH, cipherOffsetInConstantsTable, pOptimisedHwBlockBaseInDRAM, &optimisedHwBlockOffsetInDRAM); } if (NON_SPC != pSessionDesc->singlePassState) { pCdInfo->hwBlkSzQuadWords = LAC_BYTES_TO_QUADWORDS( hwBlockOffsetInDRAM); pMsg = (icp_qat_fw_comn_req_t *)&( pSessionDesc->reqSpcCacheHdr); SalQatMsg_ContentDescHdrWrite( (icp_qat_fw_comn_req_t *)pMsg, pCdInfo); } LacAlgChain_HashCDBuild( pHashData, instanceHandle, pSessionDesc, ICP_QAT_FW_SLICE_DRAM_WR, hashOffsetInConstantsTable, &pSessionDesc->cmnRequestFlags, &pSessionDesc->laCmdFlags, &precomputeData, &precomputeDataOptimisedCd, pHwBlockBaseInDRAM, &hwBlockOffsetInDRAM, pOptimisedHwBlockBaseInDRAM, &optimisedHwBlockOffsetInDRAM); } break; default: LAC_LOG_ERROR("Invalid sym operation\n"); status = CPA_STATUS_INVALID_PARAM; } } if ((CPA_STATUS_SUCCESS == status) && pSessionDesc->isAuth) { lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo = &(pSessionDesc->hashStateBufferInfo); CpaBoolean hashStateBuffer = CPA_TRUE; /* set up fields in both the cd_ctrl and reqParams which * describe the ReqParams block */ LacSymQat_HashSetupReqParamsMetaData( &(pSessionDesc->reqCacheFtr), instanceHandle, pHashData, hashStateBuffer, pSessionDesc->qatHashMode, pSessionDesc->digestVerify); if (pSessionDesc->useSymConstantsTable) { /* Need to set up for SHRAM Constants Table use also */ LacSymQat_HashSetupReqParamsMetaData( &(pSessionDesc->shramReqCacheFtr), instanceHandle, pHashData, hashStateBuffer, pSessionDesc->qatHashMode, pSessionDesc->digestVerify); } /* populate the hash state prefix buffer info structure * (part of user allocated session memory & the * buffer itself. For CCM/GCM the buffer is stored in the * cookie and is not initialised here) */ if (CPA_FALSE == pSessionDesc->isAuthEncryptOp) { LAC_CHECK_64_BYTE_ALIGNMENT( &(pSessionDesc->hashStatePrefixBuffer[0])); status = LacHash_StatePrefixAadBufferInit( &(pService->generic_service_info), pHashData, &(pSessionDesc->reqCacheFtr), pSessionDesc->qatHashMode, pSessionDesc->hashStatePrefixBuffer, pHashStateBufferInfo); /* SHRAM Constants Table not used for Auth-Enc */ } if (CPA_STATUS_SUCCESS == status) { if (IS_HASH_MODE_1(pSessionDesc->qatHashMode) || CPA_CY_SYM_HASH_ZUC_EIA3 == pHashData->hashAlgorithm) { LAC_CHECK_64_BYTE_ALIGNMENT( &(pSessionDesc->hashStatePrefixBuffer[0])); /* Block messages until precompute is completed */ pSessionDesc->nonBlockingOpsInProgress = CPA_FALSE; status = LacHash_PrecomputeDataCreate( instanceHandle, (CpaCySymSessionSetupData *) pSessionSetupData, LacSymAlgChain_HashPrecomputeDoneCb, pSessionDesc, pSessionDesc->hashStatePrefixBuffer, precomputeData.pState1, precomputeData.pState2); if (pSessionDesc->useOptimisedContentDesc) { status = LacHash_PrecomputeDataCreate( instanceHandle, (CpaCySymSessionSetupData *) pSessionSetupData, LacSymAlgChain_HashPrecomputeDoneCb, pSessionDesc, pSessionDesc->hashStatePrefixBuffer, precomputeDataOptimisedCd.pState1, precomputeDataOptimisedCd.pState2); } } else if (pHashData->hashAlgorithm == CPA_CY_SYM_HASH_AES_CBC_MAC) { if (NULL != precomputeData.pState2) { LAC_OS_BZERO(precomputeData.pState2, precomputeData.state2Size); memcpy(precomputeData.pState2, pHashData->authModeSetupData .authKey, pHashData->authModeSetupData .authKeyLenInBytes); } } } } if (CPA_STATUS_SUCCESS == status) { /* Configure the ContentDescriptor field in the request if not done already */ pCdInfo->hwBlkSzQuadWords = LAC_BYTES_TO_QUADWORDS(hwBlockOffsetInDRAM); pMsg = (icp_qat_fw_comn_req_t *)&(pSessionDesc->reqCacheHdr); SalQatMsg_ContentDescHdrWrite((icp_qat_fw_comn_req_t *)pMsg, pCdInfo); pMsgS = (icp_qat_fw_comn_req_t *)&(pSessionDesc->shramReqCacheHdr); /*If we are using the optimised CD then we have to set this up correctly in the SHARM reqCache*/ if (pSessionDesc->useOptimisedContentDesc) { pCdInfoOptimised->hwBlkSzQuadWords = LAC_BYTES_TO_QUADWORDS( optimisedHwBlockOffsetInDRAM); SalQatMsg_ContentDescHdrWrite( (icp_qat_fw_comn_req_t *)pMsgS, pCdInfoOptimised); } /* Updates command flags basing on configured alg */ updateLaCmdFlags(pSessionDesc, proto, &pSessionDesc->laCmdFlags); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)pMsg, ICP_QAT_FW_COMN_REQ_CPM_FW_LA, pSessionDesc->laCmdId, pSessionDesc->cmnRequestFlags, pSessionDesc->laCmdFlags); /* Need to duplicate if SHRAM Constants Table used */ if (pSessionDesc->useSymConstantsTable) { ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_SET( pSessionDesc->laCmdFlags, ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_SHRAM_CP); if (pSessionDesc->isCipher && !pSessionDesc->useOptimisedContentDesc) { ICP_QAT_FW_COMN_CD_FLD_TYPE_SET( cmnRequestFlags, QAT_COMN_CD_FLD_TYPE_16BYTE_DATA); } SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)pMsgS, ICP_QAT_FW_COMN_REQ_CPM_FW_LA, pSessionDesc->laCmdId, cmnRequestFlags, pSessionDesc->laCmdFlags); } } return status; } static void LacAlgChain_StatefulSha3_SkipStateLoadFlags(icp_qat_fw_la_bulk_req_t *pMsg, Cpa32U packetType, icp_qat_hw_auth_mode_t qatHashMode) { icp_qat_fw_auth_cd_ctrl_hdr_t *pAuthCdCtrlHdr = NULL; pAuthCdCtrlHdr = (icp_qat_fw_auth_cd_ctrl_hdr_t *)&(pMsg->cd_ctrl); if (IS_HASH_MODE_2(qatHashMode)) { if ((ICP_QAT_FW_LA_PARTIAL_START == packetType) || (ICP_QAT_FW_LA_PARTIAL_NONE == packetType)) { ICP_QAT_FW_HASH_FLAG_SKIP_INNER_STATE1_LOAD_SET( pAuthCdCtrlHdr->hash_flags, QAT_FW_LA_SKIP_INNER_STATE1_LOAD); ICP_QAT_FW_HASH_FLAG_SKIP_OUTER_STATE1_LOAD_SET( pAuthCdCtrlHdr->hash_flags, QAT_FW_LA_SKIP_OUTER_STATE1_LOAD); } else if (ICP_QAT_FW_LA_PARTIAL_END == packetType) { ICP_QAT_FW_HASH_FLAG_SKIP_OUTER_STATE1_LOAD_SET( pAuthCdCtrlHdr->hash_flags, QAT_FW_LA_SKIP_OUTER_STATE1_LOAD); } } else { if ((ICP_QAT_FW_LA_PARTIAL_START == packetType) || (ICP_QAT_FW_LA_PARTIAL_NONE == packetType)) { ICP_QAT_FW_HASH_FLAG_SKIP_INNER_STATE1_LOAD_SET( pAuthCdCtrlHdr->hash_flags, QAT_FW_LA_SKIP_INNER_STATE1_LOAD); } } } /** @ingroup LacAlgChain */ CpaStatus LacAlgChain_Perform(const CpaInstanceHandle instanceHandle, lac_session_desc_t *pSessionDesc, void *pCallbackTag, const CpaCySymOpData *pOpData, const CpaBufferList *pSrcBuffer, CpaBufferList *pDstBuffer, CpaBoolean *pVerifyResult) { CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = (sal_crypto_service_t *)instanceHandle; Cpa32U capabilitiesMask = pService->generic_service_info.capabilitiesMask; lac_sym_bulk_cookie_t *pCookie = NULL; lac_sym_cookie_t *pSymCookie = NULL; icp_qat_fw_la_bulk_req_t *pMsg = NULL; Cpa8U *pMsgDummy = NULL; Cpa8U *pCacheDummyHdr = NULL; Cpa8U *pCacheDummyFtr = NULL; Cpa32U qatPacketType = 0; CpaBufferList *pBufferList = NULL; Cpa8U *pDigestResult = NULL; Cpa64U srcAddrPhys = 0; Cpa64U dstAddrPhys = 0; icp_qat_fw_la_cmd_id_t laCmdId; sal_qat_content_desc_info_t *pCdInfo = NULL; Cpa8U *pHwBlockBaseInDRAM = NULL; Cpa32U hwBlockOffsetInDRAM = 0; Cpa32U sizeInBytes = 0; icp_qat_fw_cipher_cd_ctrl_hdr_t *pSpcCdCtrlHdr = NULL; CpaCySymCipherAlgorithm cipher; CpaCySymHashAlgorithm hash; Cpa8U paddingLen = 0; Cpa8U blockLen = 0; CpaBoolean digestIsAppended = CPA_FALSE; Cpa32U aadLenInBytes = 0; Cpa64U srcPktSize = 0; Cpa64U dstPktSize = 0; /* Set the command id */ laCmdId = pSessionDesc->laCmdId; cipher = pSessionDesc->cipherAlgorithm; hash = pSessionDesc->hashAlgorithm; CpaBoolean isSpCcm = (LAC_CIPHER_IS_CCM(cipher) && LAC_CIPHER_AES_V2(capabilitiesMask)); if (CPA_CY_SYM_HASH_AES_GMAC == hash) { pSessionDesc->aadLenInBytes = pOpData->messageLenToHashInBytes; if (pOpData->messageLenToHashInBytes == 0 || pOpData->pAdditionalAuthData != NULL) { LAC_INVALID_PARAM_LOG( "For AES_GMAC, AAD Length " "(messageLenToHashInBytes) must " "be non zero and pAdditionalAuthData " "must be NULL"); return CPA_STATUS_INVALID_PARAM; } } aadLenInBytes = pSessionDesc->aadLenInBytes; /* Convert Alg Chain Request to Cipher Request for CCP and * AES_GCM single pass */ if ((NON_SPC != pSessionDesc->singlePassState) && (isSpCcm || (LAC_CIPHER_SPC_IV_SIZE == pOpData->ivLenInBytes))) { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_CIPHER; laCmdId = pSessionDesc->laCmdId; pSessionDesc->symOperation = CPA_CY_SYM_OP_CIPHER; pSessionDesc->singlePassState = SPC; pSessionDesc->isCipher = CPA_TRUE; pSessionDesc->isAuthEncryptOp = CPA_FALSE; pSessionDesc->isAuth = CPA_FALSE; if (CPA_CY_SYM_HASH_AES_GMAC == hash) { if (ICP_QAT_FW_SPC_AAD_SZ_MAX < aadLenInBytes) { LAC_INVALID_PARAM_LOG( "aadLenInBytes for AES_GMAC"); return CPA_STATUS_INVALID_PARAM; } } /* New bit position (13) for SINGLE PASS. * The FW provides a specific macro to use to set the proto flag */ ICP_QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_SET( pSessionDesc->laCmdFlags, ICP_QAT_FW_LA_SINGLE_PASS_PROTO); if (isCyGen2x(pService)) { ICP_QAT_FW_LA_PROTO_SET(pSessionDesc->laCmdFlags, 0); } pCdInfo = &(pSessionDesc->contentDescInfo); pHwBlockBaseInDRAM = (Cpa8U *)pCdInfo->pData; if (CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT == pSessionDesc->cipherDirection) { if (LAC_CIPHER_IS_GCM(cipher)) hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_GCM_SPC_OFFSET_IN_DRAM); else if (LAC_CIPHER_IS_CHACHA(cipher)) hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_CHACHA_SPC_OFFSET_IN_DRAM); } else if (isSpCcm) { hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_CCM_SPC_OFFSET_IN_DRAM); } /* Update cipher slice type */ pSessionDesc->cipherSliceType = LacCipher_GetCipherSliceType(pService, pSessionDesc->cipherAlgorithm, pSessionDesc->hashAlgorithm); ICP_QAT_FW_LA_SLICE_TYPE_SET(pSessionDesc->laCmdFlags, pSessionDesc->cipherSliceType); /* construct cipherConfig in CD in DRAM */ LacSymQat_CipherHwBlockPopulateCfgData(pSessionDesc, pHwBlockBaseInDRAM + hwBlockOffsetInDRAM, &sizeInBytes); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)&( pSessionDesc->reqSpcCacheHdr), ICP_QAT_FW_COMN_REQ_CPM_FW_LA, laCmdId, pSessionDesc->cmnRequestFlags, pSessionDesc->laCmdFlags); } else if ((SPC == pSessionDesc->singlePassState) && (LAC_CIPHER_SPC_IV_SIZE != pOpData->ivLenInBytes)) { pSessionDesc->symOperation = CPA_CY_SYM_OP_ALGORITHM_CHAINING; pSessionDesc->singlePassState = LIKELY_SPC; pSessionDesc->isCipher = CPA_TRUE; pSessionDesc->isAuthEncryptOp = CPA_TRUE; pSessionDesc->isAuth = CPA_TRUE; pCdInfo = &(pSessionDesc->contentDescInfo); pHwBlockBaseInDRAM = (Cpa8U *)pCdInfo->pData; if (CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT == pSessionDesc->cipherDirection) { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_CIPHER_HASH; } else { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_HASH_CIPHER; } laCmdId = pSessionDesc->laCmdId; ICP_QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_SET( pSessionDesc->laCmdFlags, 0); ICP_QAT_FW_LA_PROTO_SET(pSessionDesc->laCmdFlags, ICP_QAT_FW_LA_GCM_PROTO); LacSymQat_CipherHwBlockPopulateCfgData(pSessionDesc, pHwBlockBaseInDRAM + hwBlockOffsetInDRAM, &sizeInBytes); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)&( pSessionDesc->reqCacheHdr), ICP_QAT_FW_COMN_REQ_CPM_FW_LA, laCmdId, pSessionDesc->cmnRequestFlags, pSessionDesc->laCmdFlags); } else if (LAC_CIPHER_IS_CHACHA(cipher) && (LAC_CIPHER_SPC_IV_SIZE != pOpData->ivLenInBytes)) { LAC_INVALID_PARAM_LOG("IV for CHACHA"); return CPA_STATUS_INVALID_PARAM; } if ((CPA_TRUE == pSessionDesc->isAuthEncryptOp) || isSpCcm) { if (CPA_CY_SYM_HASH_AES_CCM == hash) { status = LacSymAlgChain_CheckCCMData( pOpData->pAdditionalAuthData, pOpData->pIv, pOpData->messageLenToCipherInBytes, pOpData->ivLenInBytes); if (CPA_STATUS_SUCCESS == status) { LacSymAlgChain_PrepareCCMData( pSessionDesc, pOpData->pAdditionalAuthData, pOpData->pIv, pOpData->messageLenToCipherInBytes, pOpData->ivLenInBytes); } } else if (CPA_CY_SYM_HASH_AES_GCM == hash) { if (aadLenInBytes != 0 && pOpData->pAdditionalAuthData == NULL) { LAC_INVALID_PARAM_LOG("pAdditionalAuthData"); status = CPA_STATUS_INVALID_PARAM; } if (CPA_STATUS_SUCCESS == status) { LacSymAlgChain_PrepareGCMData( pSessionDesc, pOpData->pAdditionalAuthData); } } } /* allocate cookie (used by callback function) */ if (CPA_STATUS_SUCCESS == status) { pSymCookie = (lac_sym_cookie_t *)Lac_MemPoolEntryAlloc( pService->lac_sym_cookie_pool); if (pSymCookie == NULL) { LAC_LOG_ERROR("Cannot allocate cookie - NULL"); status = CPA_STATUS_RESOURCE; } else if ((void *)CPA_STATUS_RETRY == pSymCookie) { pSymCookie = NULL; status = CPA_STATUS_RETRY; } else { pCookie = &(pSymCookie->u.bulkCookie); } } if (CPA_STATUS_SUCCESS == status) { /* write the buffer descriptors */ if (IS_ZERO_LENGTH_BUFFER_SUPPORTED(cipher, hash)) { status = LacBuffDesc_BufferListDescWriteAndAllowZeroBuffer( (CpaBufferList *)pSrcBuffer, &srcAddrPhys, CPA_FALSE, &(pService->generic_service_info)); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR( "Unable to write src buffer descriptors"); } /* For out of place operations */ if ((pSrcBuffer != pDstBuffer) && (CPA_STATUS_SUCCESS == status)) { status = LacBuffDesc_BufferListDescWriteAndAllowZeroBuffer( pDstBuffer, &dstAddrPhys, CPA_FALSE, &(pService->generic_service_info)); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR( "Unable to write dest buffer descriptors"); } } } else { status = LacBuffDesc_BufferListDescWrite( (CpaBufferList *)pSrcBuffer, &srcAddrPhys, CPA_FALSE, &(pService->generic_service_info)); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR( "Unable to write src buffer descriptors in " "LacBuffDesc_BufferListDescWrite"); } /* For out of place operations */ if ((pSrcBuffer != pDstBuffer) && (CPA_STATUS_SUCCESS == status)) { status = LacBuffDesc_BufferListDescWrite( pDstBuffer, &dstAddrPhys, CPA_FALSE, &(pService->generic_service_info)); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR( "Unable to write dest buffer descriptors in " "LacBuffDesc_BufferListDescWrite"); } } } } if (CPA_STATUS_SUCCESS == status) { /* populate the cookie */ pCookie->pCallbackTag = pCallbackTag; pCookie->sessionCtx = pOpData->sessionCtx; pCookie->pOpData = (const CpaCySymOpData *)pOpData; pCookie->pDstBuffer = pDstBuffer; pCookie->updateSessionIvOnSend = CPA_FALSE; pCookie->updateUserIvOnRecieve = CPA_FALSE; pCookie->updateKeySizeOnRecieve = CPA_FALSE; pCookie->pNext = NULL; pCookie->instanceHandle = pService; /* get the qat packet type for LAC packet type */ LacSymQat_packetTypeGet(pOpData->packetType, pSessionDesc->partialState, &qatPacketType); /* * For XTS mode, the key size must be updated after * the first partial has been sent. Set a flag here so the * response knows to do this. */ if (LAC_CIPHER_IS_XTS_MODE(cipher) && (laCmdId != ICP_QAT_FW_LA_CMD_AUTH) && (CPA_CY_SYM_PACKET_TYPE_PARTIAL == pOpData->packetType) && (qatPacketType == ICP_QAT_FW_LA_PARTIAL_START)) { pCookie->updateKeySizeOnRecieve = CPA_TRUE; } /* * Now create the Request. * Start by populating it from the cache in the session * descriptor. */ pMsg = &(pCookie->qatMsg); pMsgDummy = (Cpa8U *)pMsg; if (SPC == pSessionDesc->singlePassState) { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->reqSpcCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->reqSpcCacheFtr); } else { /* Normally, we want to use the SHRAM Constants Table if * possible for best performance (less DRAM accesses * incurred by CPM). But we can't use it for * partial-packet hash operations. This is why we build * 2 versions of the message template at sessionInit, * one for SHRAM Constants Table usage and the other * (default) for Content Descriptor h/w setup data in * DRAM. And we chose between them here on a * per-request basis, when we know the packetType */ if ((!pSessionDesc->useSymConstantsTable) || (pSessionDesc->isAuth && (CPA_CY_SYM_PACKET_TYPE_FULL != pOpData->packetType))) { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->reqCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->reqCacheFtr); } else { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->shramReqCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->shramReqCacheFtr); } } memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memset((pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)), 0, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_TO_CLEAR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); /* * Populate the comn_mid section */ SalQatMsg_CmnMidWrite(pMsg, pCookie, LAC_SYM_DEFAULT_QAT_PTR_TYPE, srcAddrPhys, dstAddrPhys, 0, 0); /* * Populate the serv_specif_flags field of the Request header * Some of the flags are set up here. * Others are set up later when the RequestParams are set up. */ LacSymQat_LaPacketCommandFlagSet( qatPacketType, laCmdId, cipher, &pMsg->comn_hdr.serv_specif_flags, pOpData->ivLenInBytes); if (SPC == pSessionDesc->singlePassState) { ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET( pMsg->comn_hdr.serv_specif_flags, ICP_QAT_FW_LA_GCM_IV_LEN_NOT_12_OCTETS); if (CPA_CY_SYM_PACKET_TYPE_PARTIAL == pOpData->packetType) { ICP_QAT_FW_LA_RET_AUTH_SET( pMsg->comn_hdr.serv_specif_flags, ICP_QAT_FW_LA_NO_RET_AUTH_RES); ICP_QAT_FW_LA_CMP_AUTH_SET( pMsg->comn_hdr.serv_specif_flags, ICP_QAT_FW_LA_NO_CMP_AUTH_RES); } } ICP_QAT_FW_LA_SLICE_TYPE_SET(pMsg->comn_hdr.serv_specif_flags, pSessionDesc->cipherSliceType); LacBuffDesc_BufferListTotalSizeGet(pSrcBuffer, &srcPktSize); LacBuffDesc_BufferListTotalSizeGet(pDstBuffer, &dstPktSize); /* * Populate the CipherRequestParams section of the Request */ if (laCmdId != ICP_QAT_FW_LA_CMD_AUTH) { Cpa8U *pIvBuffer = NULL; status = LacCipher_PerformParamCheck(cipher, pOpData, srcPktSize); if (CPA_STATUS_SUCCESS != status) { /* free the cookie */ Lac_MemPoolEntryFree(pCookie); return status; } if (CPA_STATUS_SUCCESS == status) { /* align cipher IV */ status = LacCipher_PerformIvCheck( &(pService->generic_service_info), pCookie, qatPacketType, &pIvBuffer); } if ((SPC == pSessionDesc->singlePassState) && ((ICP_QAT_FW_LA_PARTIAL_MID == qatPacketType) || (ICP_QAT_FW_LA_PARTIAL_END == qatPacketType))) { /* For SPC stateful cipher state size for mid * and end partial packet is 48 bytes */ pSpcCdCtrlHdr = (icp_qat_fw_cipher_cd_ctrl_hdr_t *)&( pMsg->cd_ctrl); pSpcCdCtrlHdr->cipher_state_sz = LAC_BYTES_TO_QUADWORDS( LAC_SYM_QAT_CIPHER_SPC_STATE_SIZE); } /*populate the cipher request parameters */ if (CPA_STATUS_SUCCESS == status) { Cpa64U ivBufferPhysAddr = 0; if (pIvBuffer != NULL) { /* User OpData memory being used for IV * buffer */ /* get the physical address */ ivBufferPhysAddr = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, pIvBuffer); if (0 == ivBufferPhysAddr) { LAC_LOG_ERROR( "Unable to get the physical address " "of the IV\n"); status = CPA_STATUS_FAIL; } } if (status == CPA_STATUS_SUCCESS) { status = LacSymQat_CipherRequestParamsPopulate( pSessionDesc, pMsg, pOpData ->cryptoStartSrcOffsetInBytes, pOpData ->messageLenToCipherInBytes, ivBufferPhysAddr, pIvBuffer); } } if ((SPC == pSessionDesc->singlePassState) && CPA_STATUS_SUCCESS == status) { Cpa64U aadBufferPhysAddr = 0; /* For CHACHA and AES-GCM there is an AAD buffer * if aadLenInBytes is nonzero In case of * AES-GMAC, AAD buffer passed in the src * buffer. */ if ((0 != aadLenInBytes && CPA_CY_SYM_HASH_AES_GMAC != hash) || isSpCcm) { LAC_CHECK_NULL_PARAM( pOpData->pAdditionalAuthData); Cpa32U aadDataLen = pSessionDesc->aadLenInBytes; /* In case of AES_CCM, B0 block size and * 2 bytes of AAD len encoding need to * be added to total AAD data len */ if (isSpCcm) aadDataLen += LAC_CIPHER_CCM_AAD_OFFSET; blockLen = LacSymQat_CipherBlockSizeBytesGet( cipher); if ((aadDataLen % blockLen) != 0) { paddingLen = blockLen - (aadDataLen % blockLen); memset( &pOpData ->pAdditionalAuthData [aadDataLen], 0, paddingLen); } /* User OpData memory being used for AAD * buffer */ /* get the physical address */ aadBufferPhysAddr = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, pOpData->pAdditionalAuthData); if (0 == aadBufferPhysAddr) { LAC_LOG_ERROR( "Unable to get the physical address " "of the aad\n"); status = CPA_STATUS_FAIL; } } if (CPA_STATUS_SUCCESS == status) { icp_qat_fw_la_cipher_req_params_t *pCipherReqParams = (icp_qat_fw_la_cipher_req_params_t *)((Cpa8U *)&( pMsg->serv_specif_rqpars) + ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET); icp_qat_fw_la_cipher_20_req_params_t *pCipher20ReqParams = (void *)((Cpa8U *)&( pMsg->serv_specif_rqpars) + ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET); if (isCyGen4x(pService)) { pCipher20ReqParams ->spc_aad_addr = aadBufferPhysAddr; pCipher20ReqParams->spc_aad_sz = pSessionDesc->aadLenInBytes; pCipher20ReqParams ->spc_aad_offset = 0; if (isSpCcm) pCipher20ReqParams ->spc_aad_sz += LAC_CIPHER_CCM_AAD_OFFSET; } else { pCipherReqParams->spc_aad_addr = aadBufferPhysAddr; pCipherReqParams->spc_aad_sz = (Cpa16U)pSessionDesc ->aadLenInBytes; } if (CPA_TRUE != pSessionDesc->digestIsAppended) { Cpa64U digestBufferPhysAddr = 0; /* User OpData memory being used * for digest buffer */ /* get the physical address */ digestBufferPhysAddr = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService ->generic_service_info, pOpData->pDigestResult); if (0 != digestBufferPhysAddr) { if (isCyGen4x( pService)) { pCipher20ReqParams ->spc_auth_res_addr = digestBufferPhysAddr; pCipher20ReqParams ->spc_auth_res_sz = (Cpa8U)pSessionDesc ->hashResultSize; } else { pCipherReqParams ->spc_auth_res_addr = digestBufferPhysAddr; pCipherReqParams ->spc_auth_res_sz = (Cpa8U)pSessionDesc ->hashResultSize; } } else { LAC_LOG_ERROR( "Unable to get the physical address " "of the digest\n"); status = CPA_STATUS_FAIL; } } else { /* Check if the dest buffer can * handle the digest, only for * last packet */ if (((ICP_QAT_FW_LA_PARTIAL_NONE == qatPacketType) || (ICP_QAT_FW_LA_PARTIAL_END == qatPacketType))) { if (dstPktSize < (pOpData ->cryptoStartSrcOffsetInBytes + pOpData ->messageLenToCipherInBytes + pSessionDesc ->hashResultSize)) status = CPA_STATUS_INVALID_PARAM; } if (isCyGen4x(pService)) { pCipher20ReqParams ->spc_auth_res_sz = (Cpa8U)pSessionDesc ->hashResultSize; } else { pCipherReqParams ->spc_auth_res_sz = (Cpa8U)pSessionDesc ->hashResultSize; } } } } } /* * Set up HashRequestParams part of Request */ if ((status == CPA_STATUS_SUCCESS) && (laCmdId != ICP_QAT_FW_LA_CMD_CIPHER)) { Cpa32U authOffsetInBytes = pOpData->hashStartSrcOffsetInBytes; Cpa32U authLenInBytes = pOpData->messageLenToHashInBytes; status = LacHash_PerformParamCheck(instanceHandle, pSessionDesc, pOpData, srcPktSize, pVerifyResult); if (CPA_STATUS_SUCCESS != status) { /* free the cookie */ Lac_MemPoolEntryFree(pCookie); return status; } if (CPA_STATUS_SUCCESS == status) { /* Info structure for CCM/GCM */ lac_sym_qat_hash_state_buffer_info_t hashStateBufferInfo = { 0 }; lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo = &(pSessionDesc->hashStateBufferInfo); if (CPA_TRUE == pSessionDesc->isAuthEncryptOp) { icp_qat_fw_la_auth_req_params_t *pHashReqParams = (icp_qat_fw_la_auth_req_params_t *)((Cpa8U *)&( pMsg->serv_specif_rqpars) + ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET); hashStateBufferInfo.pData = pOpData->pAdditionalAuthData; if (pOpData->pAdditionalAuthData == NULL) { hashStateBufferInfo.pDataPhys = 0; } else { hashStateBufferInfo .pDataPhys = LAC_MEM_CAST_PTR_TO_UINT64( LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService ->generic_service_info, pOpData ->pAdditionalAuthData)); } hashStateBufferInfo .stateStorageSzQuadWords = 0; hashStateBufferInfo .prefixAadSzQuadWords = LAC_BYTES_TO_QUADWORDS( pHashReqParams->u2.aad_sz); /* Overwrite hash state buffer info * structure pointer with the one * created for CCM/GCM */ pHashStateBufferInfo = &hashStateBufferInfo; /* Aad buffer could be null in the GCM * case */ if (0 == hashStateBufferInfo.pDataPhys && CPA_CY_SYM_HASH_AES_GCM != hash && CPA_CY_SYM_HASH_AES_GMAC != hash) { LAC_LOG_ERROR( "Unable to get the physical address" "of the AAD\n"); status = CPA_STATUS_FAIL; } /* for CCM/GCM the hash and cipher data * regions are equal */ authOffsetInBytes = pOpData ->cryptoStartSrcOffsetInBytes; /* For authenticated encryption, * authentication length is determined * by messageLenToCipherInBytes for * AES-GCM and AES-CCM, and by * messageLenToHashInBytes for AES-GMAC. * You don't see the latter here, as * that is the initial value of * authLenInBytes. */ if (hash != CPA_CY_SYM_HASH_AES_GMAC) authLenInBytes = pOpData ->messageLenToCipherInBytes; } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == hash || CPA_CY_SYM_HASH_ZUC_EIA3 == hash) { hashStateBufferInfo.pData = pOpData->pAdditionalAuthData; hashStateBufferInfo.pDataPhys = LAC_OS_VIRT_TO_PHYS_EXTERNAL( pService->generic_service_info, hashStateBufferInfo.pData); hashStateBufferInfo .stateStorageSzQuadWords = 0; hashStateBufferInfo .prefixAadSzQuadWords = LAC_BYTES_TO_QUADWORDS( aadLenInBytes); pHashStateBufferInfo = &hashStateBufferInfo; if (0 == hashStateBufferInfo.pDataPhys) { LAC_LOG_ERROR( "Unable to get the physical address" "of the AAD\n"); status = CPA_STATUS_FAIL; } } if (CPA_CY_SYM_HASH_AES_CCM == hash) { if (CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT == pSessionDesc->cipherDirection) { /* On a decrypt path pSrcBuffer * is used as this is where * encrypted digest is located. * Firmware uses encrypted * digest for * compare/verification*/ pBufferList = (CpaBufferList *)pSrcBuffer; } else { /* On an encrypt path pDstBuffer * is used as this is where * encrypted digest will be * written */ pBufferList = (CpaBufferList *)pDstBuffer; } status = LacSymAlgChain_PtrFromOffsetGet( pBufferList, pOpData->cryptoStartSrcOffsetInBytes + pOpData ->messageLenToCipherInBytes, &pDigestResult); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR( "Cannot set digest pointer within the" " buffer list - offset out of bounds"); } } else { pDigestResult = pOpData->pDigestResult; } if (CPA_TRUE == pSessionDesc->useStatefulSha3ContentDesc) { LacAlgChain_StatefulSha3_SkipStateLoadFlags( pMsg, qatPacketType, pSessionDesc->qatHashMode); } if (CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionDesc->symOperation) { /* In alg chaining mode, packets are not * seen as partials for hash operations. * Override to NONE. */ qatPacketType = ICP_QAT_FW_LA_PARTIAL_NONE; } digestIsAppended = pSessionDesc->digestIsAppended; if (CPA_TRUE == digestIsAppended) { /*Check if the destination buffer can * handle the digest if digestIsAppend * is true*/ if (srcPktSize < (authOffsetInBytes + authLenInBytes + pSessionDesc->hashResultSize)) { status = CPA_STATUS_INVALID_PARAM; } } if (CPA_STATUS_SUCCESS == status) { /* populate the hash request parameters */ status = LacSymQat_HashRequestParamsPopulate( pMsg, authOffsetInBytes, authLenInBytes, &(pService ->generic_service_info), pHashStateBufferInfo, qatPacketType, pSessionDesc->hashResultSize, pSessionDesc->digestVerify, digestIsAppended ? NULL : pDigestResult, hash, NULL); } } } } /* * send the message to the QAT */ if (CPA_STATUS_SUCCESS == status) { qatUtilsAtomicInc(&(pSessionDesc->u.pendingCbCount)); status = LacSymQueue_RequestSend(instanceHandle, pCookie, pSessionDesc); if (CPA_STATUS_SUCCESS != status) { /* Decrease pending callback counter on send fail. */ qatUtilsAtomicDec(&(pSessionDesc->u.pendingCbCount)); } } /* Case that will catch all error status's for this function */ if (CPA_STATUS_SUCCESS != status) { /* free the cookie */ if (NULL != pSymCookie) { Lac_MemPoolEntryFree(pSymCookie); } } return status; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_api.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_api.c index a0891278cb52..6f330835902c 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_api.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_api.c @@ -1,1121 +1,1113 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_api.c Implementation of the symmetric API * * @ingroup LacSym * ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "cpa_cy_im.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_adf_transport_dp.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "icp_qat_fw_la.h" /* ****************************************************************************** * Include private header files ****************************************************************************** */ #include "lac_common.h" #include "lac_log.h" #include "lac_mem.h" #include "lac_mem_pools.h" #include "lac_list.h" #include "lac_sym.h" #include "lac_sym_qat.h" #include "lac_sal.h" #include "lac_sal_ctrl.h" #include "lac_session.h" #include "lac_sym_cipher.h" #include "lac_sym_hash.h" #include "lac_sym_alg_chain.h" #include "lac_sym_stats.h" #include "lac_sym_partial.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sym_cb.h" #include "lac_buffer_desc.h" #include "lac_sync.h" #include "lac_hooks.h" #include "lac_sal_types_crypto.h" #include "sal_service_state.h" #define IS_EXT_ALG_CHAIN_UNSUPPORTED(cipherAlgorithm, \ hashAlgorithm, \ extAlgchainSupported) \ ((((CPA_CY_SYM_CIPHER_ZUC_EEA3 == cipherAlgorithm || \ CPA_CY_SYM_CIPHER_SNOW3G_UEA2 == cipherAlgorithm) && \ CPA_CY_SYM_HASH_AES_CMAC == hashAlgorithm) || \ ((CPA_CY_SYM_CIPHER_NULL == cipherAlgorithm || \ CPA_CY_SYM_CIPHER_AES_CTR == cipherAlgorithm || \ CPA_CY_SYM_CIPHER_ZUC_EEA3 == cipherAlgorithm) && \ CPA_CY_SYM_HASH_SNOW3G_UIA2 == hashAlgorithm) || \ ((CPA_CY_SYM_CIPHER_NULL == cipherAlgorithm || \ CPA_CY_SYM_CIPHER_AES_CTR == cipherAlgorithm || \ CPA_CY_SYM_CIPHER_SNOW3G_UEA2 == cipherAlgorithm) && \ CPA_CY_SYM_HASH_ZUC_EIA3 == hashAlgorithm)) && \ !extAlgchainSupported) /*** Local functions definitions ***/ static CpaStatus LacSymPerform_BufferParamCheck(const CpaBufferList *const pSrcBuffer, const CpaBufferList *const pDstBuffer, const lac_session_desc_t *const pSessionDesc, const CpaCySymOpData *const pOpData); void LacDp_WriteRingMsgFull(CpaCySymDpOpData *pRequest, icp_qat_fw_la_bulk_req_t *pCurrentQatMsg); void LacDp_WriteRingMsgOpt(CpaCySymDpOpData *pRequest, icp_qat_fw_la_bulk_req_t *pCurrentQatMsg); void getCtxSize(const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes); /** ***************************************************************************** * @ingroup LacSym * Generic bufferList callback function. * @description * This function is used when the API is called in synchronous mode. * It's assumed the callbackTag holds a lac_sync_op_data_t type * and when the callback is received, this callback shall set the * status and opResult element of that cookie structure and * kick the sid. * This function may be used directly as a callback function. * * @param[in] callbackTag Callback Tag * @param[in] status Status of callback * @param[in] operationType Operation Type * @param[in] pOpData Pointer to the Op Data * @param[out] pDstBuffer Pointer to destination buffer list * @param[out] opResult Boolean to indicate the result of the operation * * @return void * *****************************************************************************/ void LacSync_GenBufListVerifyCb(void *pCallbackTag, CpaStatus status, CpaCySymOp operationType, void *pOpData, CpaBufferList *pDstBuffer, CpaBoolean opResult) { LacSync_GenVerifyWakeupSyncCaller(pCallbackTag, status, opResult); } /* ******************************************************************************* * Define static function definitions ******************************************************************************* */ /** * @ingroup LacSym * Function which perform parameter checks on session setup data * * @param[in] CpaInstanceHandle Instance Handle * @param[in] pSessionSetupData Pointer to session setup data * * @retval CPA_STATUS_SUCCESS The operation succeeded * @retval CPA_STATUS_INVALID_PARAM An invalid parameter value was found */ static CpaStatus LacSymSession_ParamCheck(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData) { /* initialize convenient pointers to cipher and hash contexts */ const CpaCySymCipherSetupData *const pCipherSetupData = (const CpaCySymCipherSetupData *)&pSessionSetupData ->cipherSetupData; const CpaCySymHashSetupData *const pHashSetupData = &pSessionSetupData->hashSetupData; CpaCySymCapabilitiesInfo capInfo; CpaCyCapabilitiesInfo cyCapInfo; cpaCySymQueryCapabilities(instanceHandle, &capInfo); SalCtrl_CyQueryCapabilities(instanceHandle, &cyCapInfo); /* Ensure cipher algorithm is correct and supported */ if ((CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionSetupData->symOperation) || (CPA_CY_SYM_OP_CIPHER == pSessionSetupData->symOperation)) { /* Protect against value of cipher outside the bitmap * and check if cipher algorithm is correct */ if (pCipherSetupData->cipherAlgorithm >= CPA_CY_SYM_CIPHER_CAP_BITMAP_SIZE) { LAC_INVALID_PARAM_LOG("cipherAlgorithm"); return CPA_STATUS_INVALID_PARAM; } if (!CPA_BITMAP_BIT_TEST(capInfo.ciphers, pCipherSetupData->cipherAlgorithm)) { LAC_UNSUPPORTED_PARAM_LOG( "UnSupported cipherAlgorithm"); return CPA_STATUS_UNSUPPORTED; } } /* Ensure hash algorithm is correct and supported */ if ((CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionSetupData->symOperation) || (CPA_CY_SYM_OP_HASH == pSessionSetupData->symOperation)) { /* Protect against value of hash outside the bitmap * and check if hash algorithm is correct */ if (pHashSetupData->hashAlgorithm >= CPA_CY_SYM_HASH_CAP_BITMAP_SIZE) { LAC_INVALID_PARAM_LOG("hashAlgorithm"); return CPA_STATUS_INVALID_PARAM; } if (!CPA_BITMAP_BIT_TEST(capInfo.hashes, pHashSetupData->hashAlgorithm)) { LAC_UNSUPPORTED_PARAM_LOG("UnSupported hashAlgorithm"); return CPA_STATUS_UNSUPPORTED; } } /* ensure CCM, GCM, Kasumi, Snow3G and ZUC cipher and hash algorithms * are selected together for Algorithm Chaining */ if (CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionSetupData->symOperation) { /* ensure both hash and cipher algorithms are POLY and CHACHA */ if (((CPA_CY_SYM_CIPHER_CHACHA == pCipherSetupData->cipherAlgorithm) && (CPA_CY_SYM_HASH_POLY != pHashSetupData->hashAlgorithm)) || ((CPA_CY_SYM_HASH_POLY == pHashSetupData->hashAlgorithm) && (CPA_CY_SYM_CIPHER_CHACHA != pCipherSetupData->cipherAlgorithm))) { LAC_INVALID_PARAM_LOG( "Invalid combination of Cipher/Hash " "Algorithms for CHACHA/POLY"); return CPA_STATUS_INVALID_PARAM; } /* ensure both hash and cipher algorithms are CCM */ if (((CPA_CY_SYM_CIPHER_AES_CCM == pCipherSetupData->cipherAlgorithm) && (CPA_CY_SYM_HASH_AES_CCM != pHashSetupData->hashAlgorithm)) || ((CPA_CY_SYM_HASH_AES_CCM == pHashSetupData->hashAlgorithm) && (CPA_CY_SYM_CIPHER_AES_CCM != pCipherSetupData->cipherAlgorithm))) { LAC_INVALID_PARAM_LOG( "Invalid combination of Cipher/Hash Algorithms for CCM"); return CPA_STATUS_INVALID_PARAM; } /* ensure both hash and cipher algorithms are GCM/GMAC */ if ((CPA_CY_SYM_CIPHER_AES_GCM == pCipherSetupData->cipherAlgorithm && (CPA_CY_SYM_HASH_AES_GCM != pHashSetupData->hashAlgorithm && CPA_CY_SYM_HASH_AES_GMAC != pHashSetupData->hashAlgorithm)) || ((CPA_CY_SYM_HASH_AES_GCM == pHashSetupData->hashAlgorithm || CPA_CY_SYM_HASH_AES_GMAC == pHashSetupData->hashAlgorithm) && CPA_CY_SYM_CIPHER_AES_GCM != pCipherSetupData->cipherAlgorithm)) { LAC_INVALID_PARAM_LOG( "Invalid combination of Cipher/Hash Algorithms for GCM"); return CPA_STATUS_INVALID_PARAM; } /* ensure both hash and cipher algorithms are Kasumi */ if (((CPA_CY_SYM_CIPHER_KASUMI_F8 == pCipherSetupData->cipherAlgorithm) && (CPA_CY_SYM_HASH_KASUMI_F9 != pHashSetupData->hashAlgorithm)) || ((CPA_CY_SYM_HASH_KASUMI_F9 == pHashSetupData->hashAlgorithm) && (CPA_CY_SYM_CIPHER_KASUMI_F8 != pCipherSetupData->cipherAlgorithm))) { LAC_INVALID_PARAM_LOG( "Invalid combination of Cipher/Hash Algorithms for Kasumi"); return CPA_STATUS_INVALID_PARAM; } if (IS_EXT_ALG_CHAIN_UNSUPPORTED( pCipherSetupData->cipherAlgorithm, pHashSetupData->hashAlgorithm, cyCapInfo.extAlgchainSupported)) { LAC_UNSUPPORTED_PARAM_LOG( "ExtAlgChain feature not supported"); return CPA_STATUS_UNSUPPORTED; } /* ensure both hash and cipher algorithms are Snow3G */ if (((CPA_CY_SYM_CIPHER_SNOW3G_UEA2 == pCipherSetupData->cipherAlgorithm) && (CPA_CY_SYM_HASH_SNOW3G_UIA2 != pHashSetupData->hashAlgorithm)) || ((CPA_CY_SYM_HASH_SNOW3G_UIA2 == pHashSetupData->hashAlgorithm) && (CPA_CY_SYM_CIPHER_SNOW3G_UEA2 != pCipherSetupData->cipherAlgorithm))) { LAC_INVALID_PARAM_LOG( "Invalid combination of Cipher/Hash Algorithms for Snow3G"); return CPA_STATUS_INVALID_PARAM; } /* ensure both hash and cipher algorithms are ZUC */ if (((CPA_CY_SYM_CIPHER_ZUC_EEA3 == pCipherSetupData->cipherAlgorithm) && (CPA_CY_SYM_HASH_ZUC_EIA3 != pHashSetupData->hashAlgorithm)) || ((CPA_CY_SYM_HASH_ZUC_EIA3 == pHashSetupData->hashAlgorithm) && (CPA_CY_SYM_CIPHER_ZUC_EEA3 != pCipherSetupData->cipherAlgorithm))) { LAC_INVALID_PARAM_LOG( "Invalid combination of Cipher/Hash Algorithms for ZUC"); return CPA_STATUS_INVALID_PARAM; } } /* not Algorithm Chaining so prevent CCM/GCM being selected */ else if (CPA_CY_SYM_OP_CIPHER == pSessionSetupData->symOperation) { /* ensure cipher algorithm is not CCM or GCM */ if ((CPA_CY_SYM_CIPHER_AES_CCM == pCipherSetupData->cipherAlgorithm) || (CPA_CY_SYM_CIPHER_AES_GCM == pCipherSetupData->cipherAlgorithm) || (CPA_CY_SYM_CIPHER_CHACHA == pCipherSetupData->cipherAlgorithm)) { LAC_INVALID_PARAM_LOG( "Invalid Cipher Algorithm for non-Algorithm " "Chaining operation"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_OP_HASH == pSessionSetupData->symOperation) { /* ensure hash algorithm is not CCM or GCM/GMAC */ if ((CPA_CY_SYM_HASH_AES_CCM == pHashSetupData->hashAlgorithm) || (CPA_CY_SYM_HASH_AES_GCM == pHashSetupData->hashAlgorithm) || (CPA_CY_SYM_HASH_AES_GMAC == pHashSetupData->hashAlgorithm) || (CPA_CY_SYM_HASH_POLY == pHashSetupData->hashAlgorithm)) { LAC_INVALID_PARAM_LOG( "Invalid Hash Algorithm for non-Algorithm Chaining operation"); return CPA_STATUS_INVALID_PARAM; } } /* Unsupported operation. Return error */ else { LAC_INVALID_PARAM_LOG("symOperation"); return CPA_STATUS_INVALID_PARAM; } /* ensure that cipher direction param is * valid for cipher and algchain ops */ if (CPA_CY_SYM_OP_HASH != pSessionSetupData->symOperation) { if ((pCipherSetupData->cipherDirection != CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT) && (pCipherSetupData->cipherDirection != CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT)) { LAC_INVALID_PARAM_LOG("Invalid Cipher Direction"); return CPA_STATUS_INVALID_PARAM; } } return CPA_STATUS_SUCCESS; } - /** * @ingroup LacSym * Function which perform parameter checks on data buffers for symmetric * crypto operations * * @param[in] pSrcBuffer Pointer to source buffer list * @param[in] pDstBuffer Pointer to destination buffer list * @param[in] pSessionDesc Pointer to session descriptor * @param[in] pOpData Pointer to CryptoSymOpData. * * @retval CPA_STATUS_SUCCESS The operation succeeded * @retval CPA_STATUS_INVALID_PARAM An invalid parameter value was found */ static CpaStatus LacSymPerform_BufferParamCheck(const CpaBufferList *const pSrcBuffer, const CpaBufferList *const pDstBuffer, const lac_session_desc_t *const pSessionDesc, const CpaCySymOpData *const pOpData) { Cpa64U srcBufferLen = 0, dstBufferLen = 0; CpaStatus status = CPA_STATUS_SUCCESS; /* verify packet type is in correct range */ switch (pOpData->packetType) { case CPA_CY_SYM_PACKET_TYPE_FULL: case CPA_CY_SYM_PACKET_TYPE_PARTIAL: case CPA_CY_SYM_PACKET_TYPE_LAST_PARTIAL: break; default: { LAC_INVALID_PARAM_LOG("packetType"); return CPA_STATUS_INVALID_PARAM; } } if (!((CPA_CY_SYM_OP_CIPHER != pSessionDesc->symOperation && CPA_CY_SYM_HASH_MODE_PLAIN == pSessionDesc->hashMode) && (0 == pOpData->messageLenToHashInBytes))) { if (IS_ZERO_LENGTH_BUFFER_SUPPORTED( pSessionDesc->cipherAlgorithm, pSessionDesc->hashAlgorithm)) { status = LacBuffDesc_BufferListVerifyNull( pSrcBuffer, &srcBufferLen, LAC_NO_ALIGNMENT_SHIFT); } else { status = LacBuffDesc_BufferListVerify( pSrcBuffer, &srcBufferLen, LAC_NO_ALIGNMENT_SHIFT); } if (CPA_STATUS_SUCCESS != status) { LAC_INVALID_PARAM_LOG("Source buffer invalid"); return CPA_STATUS_INVALID_PARAM; } } else { /* check MetaData !NULL */ if (NULL == pSrcBuffer->pPrivateMetaData) { LAC_INVALID_PARAM_LOG( "Source buffer MetaData cannot be NULL"); return CPA_STATUS_INVALID_PARAM; } } /* out of place checks */ if (pSrcBuffer != pDstBuffer) { /* exception for this check is zero length hash requests to * allow */ /* for srcBufflen=DstBufferLen=0 */ if (!((CPA_CY_SYM_OP_CIPHER != pSessionDesc->symOperation && CPA_CY_SYM_HASH_MODE_PLAIN == pSessionDesc->hashMode) && (0 == pOpData->messageLenToHashInBytes))) { /* Verify buffer(s) for dest packet & return packet * length */ if (IS_ZERO_LENGTH_BUFFER_SUPPORTED( pSessionDesc->cipherAlgorithm, pSessionDesc->hashAlgorithm)) { status = LacBuffDesc_BufferListVerifyNull( pDstBuffer, &dstBufferLen, LAC_NO_ALIGNMENT_SHIFT); } else { status = LacBuffDesc_BufferListVerify( pDstBuffer, &dstBufferLen, LAC_NO_ALIGNMENT_SHIFT); } if (CPA_STATUS_SUCCESS != status) { LAC_INVALID_PARAM_LOG( "Destination buffer invalid"); return CPA_STATUS_INVALID_PARAM; } } else { /* check MetaData !NULL */ if (NULL == pDstBuffer->pPrivateMetaData) { LAC_INVALID_PARAM_LOG( "Dest buffer MetaData cannot be NULL"); return CPA_STATUS_INVALID_PARAM; } } /* Check that src Buffer and dst Buffer Lengths are equal */ /* CCM output needs to be longer than input buffer for appending * tag*/ if (srcBufferLen != dstBufferLen && pSessionDesc->cipherAlgorithm != CPA_CY_SYM_CIPHER_AES_CCM) { LAC_INVALID_PARAM_LOG( "Source and Dest buffer lengths need to be equal "); return CPA_STATUS_INVALID_PARAM; } } - /* check for partial packet suport for the session operation */ + /* check for partial packet support for the session operation */ if (CPA_CY_SYM_PACKET_TYPE_FULL != pOpData->packetType) { if (CPA_FALSE == pSessionDesc->isPartialSupported) { /* return out here to simplify cleanup */ LAC_INVALID_PARAM_LOG( "Partial packets not supported for operation"); return CPA_STATUS_INVALID_PARAM; } else { /* This function checks to see if the partial packet * sequence is correct */ if (CPA_STATUS_SUCCESS != LacSym_PartialPacketStateCheck( pOpData->packetType, pSessionDesc->partialState)) { LAC_INVALID_PARAM_LOG("Partial packet Type"); return CPA_STATUS_INVALID_PARAM; } } } return CPA_STATUS_SUCCESS; } /** @ingroup LacSym */ CpaStatus cpaCySymInitSession(const CpaInstanceHandle instanceHandle_in, const CpaCySymCbFunc pSymCb, const CpaCySymSessionSetupData *pSessionSetupData, CpaCySymSessionCtx pSessionCtx) { CpaStatus status = CPA_STATUS_SUCCESS; CpaInstanceHandle instanceHandle = NULL; sal_service_t *pService = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); pService = (sal_service_t *)instanceHandle; /* check crypto service is running otherwise return an error */ SAL_RUNNING_CHECK(pService); status = LacSym_InitSession(instanceHandle, pSymCb, pSessionSetupData, CPA_FALSE, /* isDPSession */ pSessionCtx); if (CPA_STATUS_SUCCESS == status) { /* Increment the stats for a session registered successfully */ LAC_SYM_STAT_INC(numSessionsInitialized, instanceHandle); } else /* if there was an error */ { LAC_SYM_STAT_INC(numSessionErrors, instanceHandle); } return status; } CpaStatus cpaCySymSessionInUse(CpaCySymSessionCtx pSessionCtx, CpaBoolean *pSessionInUse) { CpaStatus status = CPA_STATUS_SUCCESS; lac_session_desc_t *pSessionDesc = NULL; LAC_CHECK_NULL_PARAM(pSessionInUse); LAC_CHECK_INSTANCE_HANDLE(pSessionCtx); *pSessionInUse = CPA_FALSE; pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pSessionCtx); /* If there are pending requests */ if (pSessionDesc->isDPSession) { if (qatUtilsAtomicGet(&(pSessionDesc->u.pendingDpCbCount))) *pSessionInUse = CPA_TRUE; } else { if (qatUtilsAtomicGet(&(pSessionDesc->u.pendingCbCount))) *pSessionInUse = CPA_TRUE; } return status; } CpaStatus LacSym_InitSession(const CpaInstanceHandle instanceHandle, const CpaCySymCbFunc pSymCb, const CpaCySymSessionSetupData *pSessionSetupData, const CpaBoolean isDPSession, CpaCySymSessionCtx pSessionCtx) { CpaStatus status = CPA_STATUS_SUCCESS; lac_session_desc_t *pSessionDesc = NULL; Cpa32U sessionCtxSizeInBytes = 0; CpaPhysicalAddr physAddress = 0; CpaPhysicalAddr physAddressAligned = 0; sal_service_t *pService = NULL; const CpaCySymCipherSetupData *pCipherSetupData = NULL; const CpaCySymHashSetupData *pHashSetupData = NULL; /* Instance param checking done by calling function */ LAC_CHECK_NULL_PARAM(pSessionSetupData); LAC_CHECK_NULL_PARAM(pSessionCtx); status = LacSymSession_ParamCheck(instanceHandle, pSessionSetupData); LAC_CHECK_STATUS(status); /* set the session priority for QAT AL*/ if ((CPA_CY_PRIORITY_HIGH == pSessionSetupData->sessionPriority) || (CPA_CY_PRIORITY_NORMAL == pSessionSetupData->sessionPriority)) { // do nothing - clean up this code. use RANGE macro } else { LAC_INVALID_PARAM_LOG("sessionPriority"); return CPA_STATUS_INVALID_PARAM; } - pCipherSetupData = &pSessionSetupData->cipherSetupData; pHashSetupData = &pSessionSetupData->hashSetupData; pService = (sal_service_t *)instanceHandle; /* Re-align the session structure to 64 byte alignment */ physAddress = LAC_OS_VIRT_TO_PHYS_EXTERNAL((*pService), (Cpa8U *)pSessionCtx + sizeof(void *)); if (0 == physAddress) { LAC_LOG_ERROR( "Unable to get the physical address of the session\n"); return CPA_STATUS_FAIL; } physAddressAligned = LAC_ALIGN_POW2_ROUNDUP(physAddress, LAC_64BYTE_ALIGNMENT); pSessionDesc = (lac_session_desc_t *) /* Move the session pointer by the physical offset between aligned and unaligned memory */ ((Cpa8U *)pSessionCtx + sizeof(void *) + (physAddressAligned - physAddress)); /* save the aligned pointer in the first bytes (size of unsigned long) * of the session memory */ *((LAC_ARCH_UINT *)pSessionCtx) = (LAC_ARCH_UINT)pSessionDesc; /* start off with a clean session */ /* Choose Session Context size */ getCtxSize(pSessionSetupData, &sessionCtxSizeInBytes); switch (sessionCtxSizeInBytes) { case LAC_SYM_SESSION_D1_SIZE: memset(pSessionDesc, 0, sizeof(lac_session_desc_d1_t)); break; case LAC_SYM_SESSION_D2_SIZE: memset(pSessionDesc, 0, sizeof(lac_session_desc_d2_t)); break; default: memset(pSessionDesc, 0, sizeof(lac_session_desc_t)); break; } /* Setup content descriptor info structure * assumption that content descriptor is the first field in * in the session descriptor */ pSessionDesc->contentDescInfo.pData = (Cpa8U *)pSessionDesc; pSessionDesc->contentDescInfo.hardwareSetupBlockPhys = physAddressAligned; pSessionDesc->contentDescOptimisedInfo.pData = ((Cpa8U *)pSessionDesc + LAC_SYM_QAT_CONTENT_DESC_MAX_SIZE); pSessionDesc->contentDescOptimisedInfo.hardwareSetupBlockPhys = (physAddressAligned + LAC_SYM_QAT_CONTENT_DESC_MAX_SIZE); /* Set the Common Session Information */ pSessionDesc->symOperation = pSessionSetupData->symOperation; if (CPA_FALSE == isDPSession) { /* For asynchronous - use the user supplied callback * for synchronous - use the internal synchronous callback */ pSessionDesc->pSymCb = ((void *)NULL != (void *)pSymCb) ? pSymCb : LacSync_GenBufListVerifyCb; } pSessionDesc->isDPSession = isDPSession; if ((CPA_CY_SYM_HASH_AES_GCM == pHashSetupData->hashAlgorithm) || (CPA_CY_SYM_HASH_AES_GMAC == pHashSetupData->hashAlgorithm) || (CPA_CY_SYM_HASH_AES_CCM == pHashSetupData->hashAlgorithm) || (CPA_CY_SYM_CIPHER_CHACHA == pCipherSetupData->cipherAlgorithm) || (CPA_CY_SYM_CIPHER_ARC4 == pCipherSetupData->cipherAlgorithm)) { pSessionDesc->writeRingMsgFunc = LacDp_WriteRingMsgFull; } else { pSessionDesc->writeRingMsgFunc = LacDp_WriteRingMsgOpt; } if (CPA_STATUS_SUCCESS == status) { /* Session set up via API call (not internal one) */ /* Services such as DRBG call the crypto api as part of their * service hence the need to for the flag, it is needed to * distinguish between an internal and external session. */ pSessionDesc->internalSession = CPA_FALSE; status = LacAlgChain_SessionInit(instanceHandle, pSessionSetupData, pSessionDesc); } return status; } /** @ingroup LacSym */ CpaStatus cpaCySymRemoveSession(const CpaInstanceHandle instanceHandle_in, CpaCySymSessionCtx pSessionCtx) { lac_session_desc_t *pSessionDesc = NULL; CpaStatus status = CPA_STATUS_SUCCESS; CpaInstanceHandle instanceHandle = NULL; Cpa64U numPendingRequests = 0; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSessionCtx); /* check crypto service is running otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pSessionCtx); LAC_CHECK_NULL_PARAM(pSessionDesc); if (CPA_TRUE == pSessionDesc->isDPSession) { /* * Based on one instance, we can initialize multiple sessions. * For example, we can initialize the session "X" and session * "Y" with the same instance "A". If there is no operation * pending for session "X", we can remove the session "X". * * Now we only check the @pSessionDesc->pendingDpCbCount, if it * becomes zero, we can remove the session. * * Why? * (1) We increase it in the cpaCySymDpEnqueueOp/ * cpaCySymDpEnqueueOpBatch. * (2) We decrease it in the LacSymCb_ProcessCallback. * * If the @pSessionDesc->pendingDpCbCount becomes zero, it means * there is no operation pending for the session "X" anymore, so * we can remove this session. Maybe there is still some * requests left in the instance's ring * (icp_adf_queueDataToSend() returns true), but the request * does not belong to "X", it belongs to session "Y". */ numPendingRequests = qatUtilsAtomicGet(&(pSessionDesc->u.pendingDpCbCount)); } else { numPendingRequests = qatUtilsAtomicGet(&(pSessionDesc->u.pendingCbCount)); } /* If there are pending requests */ if (0 != numPendingRequests) { QAT_UTILS_LOG("There are %llu requests pending\n", (unsigned long long)numPendingRequests); status = CPA_STATUS_RETRY; if (CPA_TRUE == pSessionDesc->isDPSession) { /* Need to update tail if messages queue on tx hi ring for data plane api */ icp_comms_trans_handle trans_handle = ((sal_crypto_service_t *)instanceHandle) ->trans_handle_sym_tx; if (CPA_TRUE == icp_adf_queueDataToSend(trans_handle)) { /* process the remaining messages in the ring */ QAT_UTILS_LOG("Submitting enqueued requests\n"); /* * SalQatMsg_updateQueueTail */ SalQatMsg_updateQueueTail(trans_handle); return status; } } } if (CPA_STATUS_SUCCESS == status) { LAC_SPINLOCK_DESTROY(&pSessionDesc->requestQueueLock); if (CPA_FALSE == pSessionDesc->isDPSession) { LAC_SYM_STAT_INC(numSessionsRemoved, instanceHandle); } } else if (CPA_FALSE == pSessionDesc->isDPSession) { LAC_SYM_STAT_INC(numSessionErrors, instanceHandle); } return status; } /** @ingroup LacSym */ static CpaStatus LacSym_Perform(const CpaInstanceHandle instanceHandle, void *callbackTag, const CpaCySymOpData *pOpData, const CpaBufferList *pSrcBuffer, CpaBufferList *pDstBuffer, CpaBoolean *pVerifyResult, CpaBoolean isAsyncMode) { lac_session_desc_t *pSessionDesc = NULL; CpaStatus status = CPA_STATUS_SUCCESS; LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); /* check crypto service is running otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); LAC_CHECK_NULL_PARAM(pOpData); LAC_CHECK_NULL_PARAM(pOpData->sessionCtx); LAC_CHECK_NULL_PARAM(pSrcBuffer); LAC_CHECK_NULL_PARAM(pDstBuffer); pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pOpData->sessionCtx); LAC_CHECK_NULL_PARAM(pSessionDesc); /*check whether Payload size is zero for CHACHA-POLY*/ if ((CPA_CY_SYM_CIPHER_CHACHA == pSessionDesc->cipherAlgorithm) && (CPA_CY_SYM_HASH_POLY == pSessionDesc->hashAlgorithm) && (CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionDesc->symOperation)) { if (!pOpData->messageLenToCipherInBytes) { LAC_INVALID_PARAM_LOG( "Invalid messageLenToCipherInBytes for CHACHA-POLY"); return CPA_STATUS_INVALID_PARAM; } } - /* If synchronous Operation - Callback function stored in the session * descriptor so a flag is set in the perform to indicate that * the perform is being re-called for the synchronous operation */ if ((LacSync_GenBufListVerifyCb == pSessionDesc->pSymCb) && isAsyncMode == CPA_TRUE) { CpaBoolean opResult = CPA_FALSE; lac_sync_op_data_t *pSyncCallbackData = NULL; status = LacSync_CreateSyncCookie(&pSyncCallbackData); if (CPA_STATUS_SUCCESS == status) { status = LacSym_Perform(instanceHandle, pSyncCallbackData, pOpData, pSrcBuffer, pDstBuffer, pVerifyResult, CPA_FALSE); } else { /* Failure allocating sync cookie */ LAC_SYM_STAT_INC(numSymOpRequestErrors, instanceHandle); return status; } if (CPA_STATUS_SUCCESS == status) { CpaStatus syncStatus = CPA_STATUS_SUCCESS; syncStatus = LacSync_WaitForCallback( pSyncCallbackData, LAC_SYM_SYNC_CALLBACK_TIMEOUT, &status, &opResult); /* If callback doesn't come back */ if (CPA_STATUS_SUCCESS != syncStatus) { LAC_SYM_STAT_INC(numSymOpCompletedErrors, instanceHandle); LAC_LOG_ERROR("Callback timed out"); status = syncStatus; } } else { /* As the Request was not sent the Callback will never * be called, so need to indicate that we're finished * with cookie so it can be destroyed. */ LacSync_SetSyncCookieComplete(pSyncCallbackData); } if (CPA_STATUS_SUCCESS == status) { if (NULL != pVerifyResult) { *pVerifyResult = opResult; } } LacSync_DestroySyncCookie(&pSyncCallbackData); return status; } status = LacSymPerform_BufferParamCheck((const CpaBufferList *)pSrcBuffer, pDstBuffer, pSessionDesc, pOpData); LAC_CHECK_STATUS(status); if ((!pSessionDesc->digestIsAppended) && (CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionDesc->symOperation)) { /* Check that pDigestResult is not NULL */ LAC_CHECK_NULL_PARAM(pOpData->pDigestResult); } status = LacAlgChain_Perform(instanceHandle, pSessionDesc, callbackTag, pOpData, pSrcBuffer, pDstBuffer, pVerifyResult); if (CPA_STATUS_SUCCESS == status) { - /* check for partial packet suport for the session operation */ + /* check for partial packet support for the session operation */ if (CPA_CY_SYM_PACKET_TYPE_FULL != pOpData->packetType) { LacSym_PartialPacketStateUpdate( pOpData->packetType, &pSessionDesc->partialState); } /* increment #requests stat */ LAC_SYM_STAT_INC(numSymOpRequests, instanceHandle); } /* Retry also results in the errors stat been incremented */ else { /* increment #errors stat */ LAC_SYM_STAT_INC(numSymOpRequestErrors, instanceHandle); } return status; } /** @ingroup LacSym */ CpaStatus cpaCySymPerformOp(const CpaInstanceHandle instanceHandle_in, void *callbackTag, const CpaCySymOpData *pOpData, const CpaBufferList *pSrcBuffer, CpaBufferList *pDstBuffer, CpaBoolean *pVerifyResult) { CpaInstanceHandle instanceHandle = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } return LacSym_Perform(instanceHandle, callbackTag, pOpData, pSrcBuffer, pDstBuffer, pVerifyResult, CPA_TRUE); } /** @ingroup LacSym */ CpaStatus cpaCySymQueryStats(const CpaInstanceHandle instanceHandle_in, struct _CpaCySymStats *pSymStats) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSymStats); /* check if crypto service is running * otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); /* copy the fields from the internal structure into the api defined * structure */ LacSym_Stats32CopyGet(instanceHandle, pSymStats); return CPA_STATUS_SUCCESS; } /** @ingroup LacSym */ CpaStatus cpaCySymQueryStats64(const CpaInstanceHandle instanceHandle_in, CpaCySymStats64 *pSymStats) { CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSymStats); /* check if crypto service is running * otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); /* copy the fields from the internal structure into the api defined * structure */ LacSym_Stats64CopyGet(instanceHandle, pSymStats); return CPA_STATUS_SUCCESS; } /** @ingroup LacSym */ CpaStatus cpaCySymSessionCtxGetSize(const CpaInstanceHandle instanceHandle_in, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes) { CpaInstanceHandle instanceHandle = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSessionSetupData); LAC_CHECK_NULL_PARAM(pSessionCtxSizeInBytes); /* check crypto service is running otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); *pSessionCtxSizeInBytes = LAC_SYM_SESSION_SIZE; return CPA_STATUS_SUCCESS; } /** @ingroup LacSym */ CpaStatus cpaCySymSessionCtxGetDynamicSize( const CpaInstanceHandle instanceHandle_in, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes) { CpaInstanceHandle instanceHandle = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSessionSetupData); LAC_CHECK_NULL_PARAM(pSessionCtxSizeInBytes); /* check crypto service is running otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); /* Choose Session Context size */ getCtxSize(pSessionSetupData, pSessionCtxSizeInBytes); - return CPA_STATUS_SUCCESS; } void getCtxSize(const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes) { /* using lac_session_desc_d1_t */ if ((pSessionSetupData->cipherSetupData.cipherAlgorithm != CPA_CY_SYM_CIPHER_ARC4) && (pSessionSetupData->cipherSetupData.cipherAlgorithm != CPA_CY_SYM_CIPHER_SNOW3G_UEA2) && (pSessionSetupData->hashSetupData.hashAlgorithm != CPA_CY_SYM_HASH_SNOW3G_UIA2) && (pSessionSetupData->cipherSetupData.cipherAlgorithm != CPA_CY_SYM_CIPHER_AES_CCM) && (pSessionSetupData->cipherSetupData.cipherAlgorithm != CPA_CY_SYM_CIPHER_AES_GCM) && (pSessionSetupData->hashSetupData.hashMode != CPA_CY_SYM_HASH_MODE_AUTH) && (pSessionSetupData->hashSetupData.hashMode != CPA_CY_SYM_HASH_MODE_NESTED) && (pSessionSetupData->partialsNotRequired == CPA_TRUE)) { *pSessionCtxSizeInBytes = LAC_SYM_SESSION_D1_SIZE; } /* using lac_session_desc_d2_t */ else if (((pSessionSetupData->cipherSetupData.cipherAlgorithm == CPA_CY_SYM_CIPHER_AES_CCM) || (pSessionSetupData->cipherSetupData.cipherAlgorithm == CPA_CY_SYM_CIPHER_AES_GCM)) && (pSessionSetupData->partialsNotRequired == CPA_TRUE)) { *pSessionCtxSizeInBytes = LAC_SYM_SESSION_D2_SIZE; } /* using lac_session_desc_t */ else { *pSessionCtxSizeInBytes = LAC_SYM_SESSION_SIZE; } } /** ****************************************************************************** * @ingroup LacSym *****************************************************************************/ CpaStatus cpaCyBufferListGetMetaSize(const CpaInstanceHandle instanceHandle_in, Cpa32U numBuffers, Cpa32U *pSizeInBytes) { CpaInstanceHandle instanceHandle = NULL; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSizeInBytes); /* In the case of zero buffers we still need to allocate one * descriptor to pass to the firmware */ if (0 == numBuffers) { numBuffers = 1; } /* Note: icp_buffer_list_desc_t is 8 bytes in size and * icp_flat_buffer_desc_t is 16 bytes in size. Therefore if * icp_buffer_list_desc_t is aligned * so will each icp_flat_buffer_desc_t structure */ *pSizeInBytes = sizeof(icp_buffer_list_desc_t) + (sizeof(icp_flat_buffer_desc_t) * numBuffers) + ICP_DESCRIPTOR_ALIGNMENT_BYTES; - return CPA_STATUS_SUCCESS; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_auth_enc.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_auth_enc.c index dd018a25a88c..67ffeafcd48d 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_auth_enc.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_auth_enc.c @@ -1,196 +1,195 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_auth_enc.c * * @ingroup LacAuthEnc * * @description * Authenticated encryption specific functionality. * For CCM related code NIST SP 800-38C is followed. * For GCM related code NIST SP 800-38D is followed. ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_accel_devices.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_adf_debug.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_log.h" #include "lac_common.h" #include "lac_session.h" #include "lac_sym_auth_enc.h" /* These defines describe position of the flag fields * in B0 block for CCM algorithm*/ #define LAC_ALG_CHAIN_CCM_B0_FLAGS_ADATA_SHIFT 6 #define LAC_ALG_CHAIN_CCM_B0_FLAGS_T_SHIFT 3 /* This macro builds flags field to be put in B0 block for CCM algorithm */ #define LAC_ALG_CHAIN_CCM_BUILD_B0_FLAGS(Adata, t, q) \ ((((Adata) > 0 ? 1 : 0) << LAC_ALG_CHAIN_CCM_B0_FLAGS_ADATA_SHIFT) | \ ((((t)-2) >> 1) << LAC_ALG_CHAIN_CCM_B0_FLAGS_T_SHIFT) | ((q)-1)) /** * @ingroup LacAuthEnc */ CpaStatus LacSymAlgChain_CheckCCMData(Cpa8U *pAdditionalAuthData, Cpa8U *pIv, Cpa32U messageLenToCipherInBytes, Cpa32U ivLenInBytes) { Cpa8U q = 0; LAC_CHECK_NULL_PARAM(pIv); LAC_CHECK_NULL_PARAM(pAdditionalAuthData); /* check if n is within permitted range */ if (ivLenInBytes < LAC_ALG_CHAIN_CCM_N_LEN_IN_BYTES_MIN || ivLenInBytes > LAC_ALG_CHAIN_CCM_N_LEN_IN_BYTES_MAX) { LAC_INVALID_PARAM_LOG2("ivLenInBytes for CCM algorithm " "must be between %d and %d inclusive", LAC_ALG_CHAIN_CCM_N_LEN_IN_BYTES_MIN, LAC_ALG_CHAIN_CCM_N_LEN_IN_BYTES_MAX); return CPA_STATUS_INVALID_PARAM; } q = LAC_ALG_CHAIN_CCM_NQ_CONST - ivLenInBytes; /* Check if q is big enough to hold actual length of message to cipher * if q = 8 -> maxlen = 2^64 always good as * messageLenToCipherInBytes is 32 bits * if q = 7 -> maxlen = 2^56 always good * if q = 6 -> maxlen = 2^48 always good * if q = 5 -> maxlen = 2^40 always good * if q = 4 -> maxlen = 2^32 always good. */ if ((messageLenToCipherInBytes >= (1 << (q * LAC_NUM_BITS_IN_BYTE))) && (q < sizeof(Cpa32U))) { LAC_INVALID_PARAM_LOG( "messageLenToCipherInBytes too long for the given" " ivLenInBytes for CCM algorithm\n"); return CPA_STATUS_INVALID_PARAM; } return CPA_STATUS_SUCCESS; } - /** * @ingroup LacAuthEnc */ void LacSymAlgChain_PrepareCCMData(lac_session_desc_t *pSessionDesc, Cpa8U *pAdditionalAuthData, Cpa8U *pIv, Cpa32U messageLenToCipherInBytes, Cpa32U ivLenInBytes) { Cpa8U n = ivLenInBytes; /* assumes ivLenInBytes has been param checked */ Cpa8U q = LAC_ALG_CHAIN_CCM_NQ_CONST - n; Cpa8U lenOfEncodedLen = 0; Cpa16U lenAEncoded = 0; Cpa32U bitStrQ = 0; /* populate Ctr0 block - stored in pIv */ pIv[0] = (q - 1); /* bytes 1 to n are already set with nonce by the user */ /* set last q bytes with 0 */ memset(pIv + n + 1, 0, q); /* Encode the length of associated data 'a'. As the API limits the * length * of an array pointed by pAdditionalAuthData to be 240 bytes max, the * maximum length of 'a' might be 240 - 16 - 2 = 222. Hence the encoding * below is simplified. */ if (pSessionDesc->aadLenInBytes > 0) { lenOfEncodedLen = sizeof(Cpa16U); lenAEncoded = QAT_UTILS_HOST_TO_NW_16( (Cpa16U)pSessionDesc->aadLenInBytes); } /* populate B0 block */ /* first, set the flags field */ pAdditionalAuthData[0] = LAC_ALG_CHAIN_CCM_BUILD_B0_FLAGS(lenOfEncodedLen, pSessionDesc->hashResultSize, q); /* bytes 1 to n are already set with nonce by the user*/ /* put Q in bytes 16-q...15 */ bitStrQ = QAT_UTILS_HOST_TO_NW_32(messageLenToCipherInBytes); if (q > sizeof(bitStrQ)) { memset(pAdditionalAuthData + n + 1, 0, q); memcpy(pAdditionalAuthData + n + 1 + (q - sizeof(bitStrQ)), (Cpa8U *)&bitStrQ, sizeof(bitStrQ)); } else { memcpy(pAdditionalAuthData + n + 1, ((Cpa8U *)&bitStrQ) + (sizeof(bitStrQ) - q), q); } /* populate B1-Bn blocks */ if (lenAEncoded > 0) { *(Cpa16U *)(&pAdditionalAuthData[1 + LAC_ALG_CHAIN_CCM_NQ_CONST]) = lenAEncoded; /* Next bytes are already set by the user with * the associated data 'a' */ /* Check if padding is required */ if (((pSessionDesc->aadLenInBytes + lenOfEncodedLen) % LAC_HASH_AES_CCM_BLOCK_SIZE) != 0) { Cpa8U paddingLen = 0; Cpa8U paddingIndex = 0; paddingLen = LAC_HASH_AES_CCM_BLOCK_SIZE - ((pSessionDesc->aadLenInBytes + lenOfEncodedLen) % LAC_HASH_AES_CCM_BLOCK_SIZE); paddingIndex = 1 + LAC_ALG_CHAIN_CCM_NQ_CONST; paddingIndex += lenOfEncodedLen + pSessionDesc->aadLenInBytes; memset(&pAdditionalAuthData[paddingIndex], 0, paddingLen); } } } /** * @ingroup LacAuthEnc */ void LacSymAlgChain_PrepareGCMData(lac_session_desc_t *pSessionDesc, Cpa8U *pAdditionalAuthData) { Cpa8U paddingLen = 0; if ((pSessionDesc->aadLenInBytes % LAC_HASH_AES_GCM_BLOCK_SIZE) != 0) { paddingLen = LAC_HASH_AES_GCM_BLOCK_SIZE - (pSessionDesc->aadLenInBytes % LAC_HASH_AES_GCM_BLOCK_SIZE); memset(&pAdditionalAuthData[pSessionDesc->aadLenInBytes], 0, paddingLen); } } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cb.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cb.c index 4e47de384a1a..d88c6707b9df 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cb.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cb.c @@ -1,526 +1,525 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_cb.c Callback handler functions for symmetric components * * @ingroup LacSym * ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_accel_devices.h" #include "icp_adf_init.h" #include "icp_qat_fw_la.h" #include "icp_adf_transport.h" #include "icp_adf_debug.h" #include "lac_sym.h" #include "lac_sym_cipher.h" #include "lac_common.h" #include "lac_list.h" #include "lac_sal_types_crypto.h" #include "lac_sal.h" #include "lac_sal_ctrl.h" #include "lac_session.h" #include "lac_sym_stats.h" #include "lac_log.h" #include "lac_sym_cb.h" #include "lac_sym_hash.h" #include "lac_sym_qat_cipher.h" #include "lac_sym_qat.h" #define DEQUEUE_MSGPUT_MAX_RETRIES 10000 /* ******************************************************************************* * Define static function definitions ******************************************************************************* */ /** ***************************************************************************** * @ingroup LacSymCb * Function to clean computed data. * * @description * This function cleans GCM or CCM data in the case of a failure. * * @param[in] pSessionDesc pointer to the session descriptor * @param[out] pBufferList pointer to the bufferlist to clean * @param[in] pOpData pointer to operation data * @param[in] isCCM is it a CCM operation boolean * * @return None *****************************************************************************/ static void LacSymCb_CleanUserData(const lac_session_desc_t *pSessionDesc, CpaBufferList *pBufferList, const CpaCySymOpData *pOpData, CpaBoolean isCCM) { Cpa32U authTagLen = 0; /* Retrieve authTagLen */ authTagLen = pSessionDesc->hashResultSize; /* Cleaning */ if (isCCM) { /* for CCM the digest is inside the buffer list */ LacBuffDesc_BufferListZeroFromOffset( pBufferList, pOpData->cryptoStartSrcOffsetInBytes, pOpData->messageLenToCipherInBytes + authTagLen); } else { /* clean buffer list */ LacBuffDesc_BufferListZeroFromOffset( pBufferList, pOpData->cryptoStartSrcOffsetInBytes, pOpData->messageLenToCipherInBytes); } if ((CPA_TRUE != pSessionDesc->digestIsAppended) && (NULL != pOpData->pDigestResult)) { /* clean digest */ memset(pOpData->pDigestResult, 0, authTagLen); } } /** ***************************************************************************** * @ingroup LacSymCb * Definition of callback function for processing symmetric responses * * @description * This callback is invoked to process symmetric response messages from * the QAT. It will extract some details from the message and invoke * the user's callback to complete a symmetric operation. * * @param[in] pCookie Pointer to cookie associated with this request * @param[in] qatRespStatusOkFlag Boolean indicating ok/fail status from QAT * @param[in] status Status variable indicating an error occurred * in sending the message (e.g. when dequeueing) * @param[in] pSessionDesc Session descriptor * * @return None *****************************************************************************/ static void LacSymCb_ProcessCallbackInternal(lac_sym_bulk_cookie_t *pCookie, CpaBoolean qatRespStatusOkFlag, CpaStatus status, lac_session_desc_t *pSessionDesc) { CpaCySymCbFunc pSymCb = NULL; void *pCallbackTag = NULL; CpaCySymOpData *pOpData = NULL; CpaBufferList *pDstBuffer = NULL; CpaCySymOp operationType = CPA_CY_SYM_OP_NONE; CpaStatus dequeueStatus = CPA_STATUS_SUCCESS; CpaInstanceHandle instanceHandle = CPA_INSTANCE_HANDLE_SINGLE; /* NOTE: cookie pointer validated in previous function */ instanceHandle = pCookie->instanceHandle; pOpData = (CpaCySymOpData *)LAC_CONST_PTR_CAST(pCookie->pOpData); operationType = pSessionDesc->symOperation; /* Set the destination pointer to the one supplied in the cookie. */ pDstBuffer = pCookie->pDstBuffer; /* For a digest verify operation - for full packet and final partial * only, perform a comparison with the digest generated and with the one * supplied in the packet. In case of AES_GCM in SPC mode, destination * buffer needs to be cleared if digest verify operation fails */ if (((SPC == pSessionDesc->singlePassState) || (CPA_CY_SYM_OP_CIPHER != operationType)) && (CPA_TRUE == pSessionDesc->digestVerify) && ((CPA_CY_SYM_PACKET_TYPE_FULL == pOpData->packetType) || (CPA_CY_SYM_PACKET_TYPE_LAST_PARTIAL == pOpData->packetType))) { if (CPA_FALSE == qatRespStatusOkFlag) { LAC_SYM_STAT_INC(numSymOpVerifyFailures, instanceHandle); /* The comparison has failed at this point (status is * fail), need to clean any sensitive calculated data up * to this point. The data calculated is no longer * useful to the end result and does not need to be * returned to the user so setting buffers to zero. */ if (pSessionDesc->cipherAlgorithm == CPA_CY_SYM_CIPHER_AES_CCM) { LacSymCb_CleanUserData(pSessionDesc, pDstBuffer, pOpData, CPA_TRUE); } else if (pSessionDesc->cipherAlgorithm == CPA_CY_SYM_CIPHER_AES_GCM) { LacSymCb_CleanUserData(pSessionDesc, pDstBuffer, pOpData, CPA_FALSE); } } } else { /* Most commands have no point of failure and always return * success. This is the default response from the QAT. * If status is already set to an error value, don't overwrite * it */ if ((CPA_STATUS_SUCCESS == status) && (CPA_TRUE != qatRespStatusOkFlag)) { LAC_LOG_ERROR("Response status value not as expected"); status = CPA_STATUS_FAIL; } } pSymCb = pSessionDesc->pSymCb; pCallbackTag = pCookie->pCallbackTag; /* State returned to the client for intermediate partials packets * for hash only and cipher only partial packets. Cipher update * allow next partial through */ if (CPA_CY_SYM_PACKET_TYPE_PARTIAL == pOpData->packetType) { if ((CPA_CY_SYM_OP_CIPHER == operationType) || (CPA_CY_SYM_OP_ALGORITHM_CHAINING == operationType)) { if (CPA_TRUE == pCookie->updateUserIvOnRecieve) { /* Update the user's IV buffer * Very important to do this BEFORE dequeuing * subsequent partial requests, as the state * buffer may get overwritten */ memcpy(pCookie->pOpData->pIv, pSessionDesc->cipherPartialOpState, pCookie->pOpData->ivLenInBytes); } if (CPA_TRUE == pCookie->updateKeySizeOnRecieve && LAC_CIPHER_IS_XTS_MODE( pSessionDesc->cipherAlgorithm)) { LacSymQat_CipherXTSModeUpdateKeyLen( pSessionDesc, pSessionDesc->cipherKeyLenInBytes / 2); } } } else if (CPA_CY_SYM_PACKET_TYPE_LAST_PARTIAL == pOpData->packetType) { if ((CPA_CY_SYM_OP_CIPHER == operationType) || (CPA_CY_SYM_OP_ALGORITHM_CHAINING == operationType)) { if (CPA_TRUE == LAC_CIPHER_IS_XTS_MODE( pSessionDesc->cipherAlgorithm)) { /* * For XTS mode, we replace the updated key with * the original key - for subsequent partial * requests * */ LacSymQat_CipherXTSModeUpdateKeyLen( pSessionDesc, pSessionDesc->cipherKeyLenInBytes); } } } if ((CPA_CY_SYM_PACKET_TYPE_FULL != pOpData->packetType) && (qatRespStatusOkFlag != CPA_FALSE)) { /* There may be requests blocked pending the completion of this * operation */ dequeueStatus = LacSymCb_PendingReqsDequeue(pSessionDesc); if (CPA_STATUS_SUCCESS != dequeueStatus) { LAC_SYM_STAT_INC(numSymOpCompletedErrors, instanceHandle); qatRespStatusOkFlag = CPA_FALSE; if (CPA_STATUS_SUCCESS == status) { status = dequeueStatus; } } } if (CPA_STATUS_SUCCESS == status) { /* update stats */ if (pSessionDesc->internalSession == CPA_FALSE) { LAC_SYM_STAT_INC(numSymOpCompleted, instanceHandle); if (CPA_STATUS_SUCCESS != status) { LAC_SYM_STAT_INC(numSymOpCompletedErrors, instanceHandle); } } } qatUtilsAtomicDec(&(pSessionDesc->u.pendingCbCount)); /* deallocate the memory for the internal callback cookie */ Lac_MemPoolEntryFree(pCookie); /* user callback function is the last thing to be called */ pSymCb(pCallbackTag, status, operationType, pOpData, pDstBuffer, qatRespStatusOkFlag); } /** ****************************************************************************** * @ingroup LacSymCb * Definition of callback function for processing symmetric Data Plane * responses * * @description * This callback checks the status, decrements the number of operations * pending and calls the user callback * * @param[in/out] pResponse pointer to the response structure * @param[in] qatRespStatusOkFlag status * @param[in] pSessionDesc pointer to the session descriptor * * @return None ******************************************************************************/ static void LacSymCb_ProcessDpCallback(CpaCySymDpOpData *pResponse, CpaBoolean qatRespStatusOkFlag, CpaStatus status, lac_session_desc_t *pSessionDesc) { CpaCySymDpCbFunc pSymDpCb = NULL; /* For CCM and GCM, if qatRespStatusOkFlag is false, the data has to be * cleaned as stated in RFC 3610; in DP mode, it is the user - * responsability to do so */ + * responsibility to do so */ if (((CPA_CY_SYM_OP_CIPHER == pSessionDesc->symOperation) && SPC != pSessionDesc->singlePassState) || (CPA_FALSE == pSessionDesc->digestVerify)) { /* If not doing digest compare and qatRespStatusOkFlag != CPA_TRUE then there is something very wrong */ if ((CPA_FALSE == qatRespStatusOkFlag) && (status != CPA_STATUS_UNSUPPORTED)) { LAC_LOG_ERROR("Response status value not as expected"); status = CPA_STATUS_FAIL; } } pSymDpCb = ((sal_crypto_service_t *)pResponse->instanceHandle)->pSymDpCb; pSymDpCb(pResponse, status, qatRespStatusOkFlag); /* * Decrement the number of pending CB. * * If the @pendingDpCbCount becomes zero, we may remove the session, * please read more information in the cpaCySymRemoveSession(). * * But there is a field in the @pResponse to store the session, * the "sessionCtx". In another word, in the above @->pSymDpCb() * callback, it may use the session again. If we decrease the * @pendingDpCbCount before the @->pSymDpCb(), there is a _risk_ the * @->pSymDpCb() may reference to a deleted session. * * So in order to avoid the risk, we decrease the @pendingDpCbCount * after the @->pSymDpCb() callback. */ qatUtilsAtomicDec(&pSessionDesc->u.pendingDpCbCount); } /** ****************************************************************************** * @ingroup LacSymCb * Definition of callback function for processing symmetric responses * * @description * This callback, which is registered with the common symmetric response * message handler, is invoked to process symmetric response messages from * the QAT. It will extract the response status from the cmnRespFlags set * by the QAT, and then will pass it to @ref * LacSymCb_ProcessCallbackInternal to complete the response processing. * * @param[in] lacCmdId ID of the symmetric QAT command of the request * message * @param[in] pOpaqueData pointer to opaque data in the request message * @param[in] cmnRespFlags Flags set by QAT to indicate response status * * @return None ******************************************************************************/ static void LacSymCb_ProcessCallback(icp_qat_fw_la_cmd_id_t lacCmdId, void *pOpaqueData, icp_qat_fw_comn_flags cmnRespFlags) { CpaStatus status = CPA_STATUS_SUCCESS; CpaCySymDpOpData *pDpOpData = (CpaCySymDpOpData *)pOpaqueData; lac_session_desc_t *pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pDpOpData->sessionCtx); CpaBoolean qatRespStatusOkFlag = (CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(cmnRespFlags)); if (CPA_TRUE == pSessionDesc->isDPSession) { /* DP session */ if (ICP_QAT_FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET( cmnRespFlags)) { status = CPA_STATUS_UNSUPPORTED; } LacSymCb_ProcessDpCallback(pDpOpData, qatRespStatusOkFlag, status, pSessionDesc); } else { /* Trad session */ LacSymCb_ProcessCallbackInternal((lac_sym_bulk_cookie_t *) pOpaqueData, qatRespStatusOkFlag, CPA_STATUS_SUCCESS, pSessionDesc); } } /* ******************************************************************************* * Define public/global function definitions ******************************************************************************* */ /** * @ingroup LacSymCb * * @return CpaStatus * value returned will be the result of icp_adf_transPutMsg */ CpaStatus LacSymCb_PendingReqsDequeue(lac_session_desc_t *pSessionDesc) { CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = NULL; Cpa32U retries = 0; pService = (sal_crypto_service_t *)pSessionDesc->pInstance; /* Need to protect access to queue head and tail pointers, which may * be accessed by multiple contexts simultaneously for enqueue and * dequeue operations */ LAC_SPINLOCK(&pSessionDesc->requestQueueLock); /* Clear the blocking flag in the session descriptor */ pSessionDesc->nonBlockingOpsInProgress = CPA_TRUE; while ((NULL != pSessionDesc->pRequestQueueHead) && (CPA_TRUE == pSessionDesc->nonBlockingOpsInProgress)) { /* If we send a partial packet request, set the * blockingOpsInProgress flag for the session to indicate that * subsequent requests must be queued up until this request * completes */ if (CPA_CY_SYM_PACKET_TYPE_FULL != pSessionDesc->pRequestQueueHead->pOpData->packetType) { pSessionDesc->nonBlockingOpsInProgress = CPA_FALSE; } /* At this point, we're clear to send the request. For cipher * requests, we need to check if the session IV needs to be * updated. This can only be done when no other partials are in * flight for this session, to ensure the cipherPartialOpState * buffer in the session descriptor is not currently in use */ if (CPA_TRUE == pSessionDesc->pRequestQueueHead->updateSessionIvOnSend) { if (LAC_CIPHER_IS_ARC4(pSessionDesc->cipherAlgorithm)) { memcpy(pSessionDesc->cipherPartialOpState, pSessionDesc->cipherARC4InitialState, LAC_CIPHER_ARC4_STATE_LEN_BYTES); } else { memcpy(pSessionDesc->cipherPartialOpState, pSessionDesc->pRequestQueueHead->pOpData ->pIv, pSessionDesc->pRequestQueueHead->pOpData ->ivLenInBytes); } } /* - * Now we'll attempt to send the message directly to QAT. We'll - * keep looing until it succeeds (or at least a very high number - * of retries), as the failure only happens when the ring is - * full, and this is only a temporary situation. After a few - * retries, space will become availble, allowing the putMsg to - * succeed. + * Now we'll attempt to send the message directly to QAT. We'll keep + * looking until it succeeds (or at least a very high number of + * retries), as the failure only happens when the ring is full, + * and this is only a temporary situation. After a few retries, + * space will become available, allowing the putMsg to succeed. */ retries = 0; do { /* Send to QAT */ status = icp_adf_transPutMsg( pService->trans_handle_sym_tx, (void *)&(pSessionDesc->pRequestQueueHead->qatMsg), LAC_QAT_SYM_REQ_SZ_LW); retries++; /* * Yield to allow other threads that may be on this * session to poll and make some space on the ring */ if (CPA_STATUS_SUCCESS != status) { qatUtilsYield(); } } while ((CPA_STATUS_SUCCESS != status) && (retries < DEQUEUE_MSGPUT_MAX_RETRIES)); if ((CPA_STATUS_SUCCESS != status) || (retries >= DEQUEUE_MSGPUT_MAX_RETRIES)) { LAC_LOG_ERROR( "Failed to SalQatMsg_transPutMsg, maximum retries exceeded."); goto cleanup; } pSessionDesc->pRequestQueueHead = pSessionDesc->pRequestQueueHead->pNext; } /* If we've drained the queue, ensure the tail pointer is set to NULL */ if (NULL == pSessionDesc->pRequestQueueHead) { pSessionDesc->pRequestQueueTail = NULL; } cleanup: LAC_SPINUNLOCK(&pSessionDesc->requestQueueLock); return status; } /** * @ingroup LacSymCb */ void LacSymCb_CallbacksRegister(void) { /*** HASH ***/ LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_AUTH, LacSymCb_ProcessCallback); /*** ALGORITHM-CHAINING CIPHER_HASH***/ LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_CIPHER_HASH, LacSymCb_ProcessCallback); /*** ALGORITHM-CHAINING HASH_CIPHER***/ LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_HASH_CIPHER, LacSymCb_ProcessCallback); /*** CIPHER ***/ LacSymQat_RespHandlerRegister(ICP_QAT_FW_LA_CMD_CIPHER, LacSymCb_ProcessCallback); /* Call compile time param check function to ensure it is included in the build by the compiler - this compile time check ensures callbacks run as expected */ LacSym_CompileTimeAssertions(); } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cipher.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cipher.c index 1c24c13a5ebe..0c01ceac2e19 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cipher.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_cipher.c @@ -1,459 +1,458 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_cipher.c Cipher * * @ingroup LacCipher * * @description Functions specific to cipher ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "icp_qat_fw_la.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_sym_cipher.h" #include "lac_session.h" #include "lac_mem.h" #include "lac_common.h" #include "lac_list.h" #include "lac_sym.h" #include "lac_sym_key.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sal_types_crypto.h" #include "lac_sal.h" #include "lac_sal_ctrl.h" #include "lac_sym_cipher_defs.h" #include "lac_sym_cipher.h" #include "lac_sym_stats.h" #include "lac_sym.h" #include "lac_sym_qat_cipher.h" #include "lac_log.h" #include "lac_buffer_desc.h" #include "sal_hw_gen.h" /* ******************************************************************************* * Static Variables ******************************************************************************* */ CpaStatus LacCipher_PerformIvCheck(sal_service_t *pService, lac_sym_bulk_cookie_t *pCbCookie, Cpa32U qatPacketType, Cpa8U **ppIvBuffer) { const CpaCySymOpData *pOpData = pCbCookie->pOpData; lac_session_desc_t *pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pOpData->sessionCtx); CpaCySymCipherAlgorithm algorithm = pSessionDesc->cipherAlgorithm; unsigned ivLenInBytes = 0; switch (algorithm) { /* Perform IV check for CTR, CBC, XTS, F8 MODE. */ case CPA_CY_SYM_CIPHER_AES_CTR: case CPA_CY_SYM_CIPHER_3DES_CTR: case CPA_CY_SYM_CIPHER_SM4_CTR: case CPA_CY_SYM_CIPHER_AES_CCM: case CPA_CY_SYM_CIPHER_AES_GCM: case CPA_CY_SYM_CIPHER_CHACHA: case CPA_CY_SYM_CIPHER_AES_CBC: case CPA_CY_SYM_CIPHER_DES_CBC: case CPA_CY_SYM_CIPHER_3DES_CBC: case CPA_CY_SYM_CIPHER_SM4_CBC: case CPA_CY_SYM_CIPHER_AES_F8: case CPA_CY_SYM_CIPHER_AES_XTS: { ivLenInBytes = LacSymQat_CipherIvSizeBytesGet(algorithm); LAC_CHECK_NULL_PARAM(pOpData->pIv); if (pOpData->ivLenInBytes != ivLenInBytes) { if (!(/* GCM with 12 byte IV is OK */ (LAC_CIPHER_IS_GCM(algorithm) && pOpData->ivLenInBytes == LAC_CIPHER_IV_SIZE_GCM_12) || /* IV len for CCM has been checked before */ LAC_CIPHER_IS_CCM(algorithm))) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } } /* Always copy the user's IV into another cipher state buffer if * the request is part of a partial packet sequence * (ensures that pipelined partial requests use same * buffer) */ if (ICP_QAT_FW_LA_PARTIAL_NONE == qatPacketType) { /* Set the value of the ppIvBuffer to that supplied * by the user. * NOTE: There is no guarantee that this address is * aligned on an 8 or 64 Byte address. */ *ppIvBuffer = pOpData->pIv; } else { /* For partial packets, we use a per-session buffer to * maintain the IV. This allows us to easily pass the * updated IV forward to the next partial in the * sequence. This makes internal buffering of partials * easier to implement. */ *ppIvBuffer = pSessionDesc->cipherPartialOpState; /* Ensure that the user's IV buffer gets updated between * partial requests so that they may also see the * residue from the previous partial. Not needed for * final partials though. */ if ((ICP_QAT_FW_LA_PARTIAL_START == qatPacketType) || (ICP_QAT_FW_LA_PARTIAL_MID == qatPacketType)) { pCbCookie->updateUserIvOnRecieve = CPA_TRUE; if (ICP_QAT_FW_LA_PARTIAL_START == qatPacketType) { /* if the previous partial state was * full, then this is the first partial * in the sequence so we need to copy in * the user's IV. But, we have to be * very careful here not to overwrite * the cipherPartialOpState just yet in * case there's a previous partial * sequence in flight, so we defer the * copy for now. This will be completed * in the LacSymQueue_RequestSend() * function. */ pCbCookie->updateSessionIvOnSend = CPA_TRUE; } /* For subsequent partials in a sequence, we'll - * re-use the IV that was written back by the + * reuse the IV that was written back by the * QAT, using internal request queueing if * necessary to ensure that the next partial * request isn't issued to the QAT until the * previous one completes */ } } } break; case CPA_CY_SYM_CIPHER_KASUMI_F8: { LAC_CHECK_NULL_PARAM(pOpData->pIv); if (pOpData->ivLenInBytes != LAC_CIPHER_KASUMI_F8_IV_LENGTH) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } *ppIvBuffer = pOpData->pIv; } break; case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: { LAC_CHECK_NULL_PARAM(pOpData->pIv); if (pOpData->ivLenInBytes != ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } *ppIvBuffer = pOpData->pIv; } break; case CPA_CY_SYM_CIPHER_ARC4: { if (ICP_QAT_FW_LA_PARTIAL_NONE == qatPacketType) { /* For full packets, the initial ARC4 state is stored in * the session descriptor. Use it directly. */ *ppIvBuffer = pSessionDesc->cipherARC4InitialState; } else { /* For partial packets, we maintain the running ARC4 * state in dedicated buffer in the session descriptor */ *ppIvBuffer = pSessionDesc->cipherPartialOpState; if (ICP_QAT_FW_LA_PARTIAL_START == qatPacketType) { /* if the previous partial state was full, then * this is the first partial in the sequence so * we need to (re-)initialise the contents of * the state buffer using the initial state that * is stored in the session descriptor. But, we * have to be very careful here not to overwrite * the cipherPartialOpState just yet in case * there's a previous partial sequence in * flight, so we defer the copy for now. This * will be completed in the * LacSymQueue_RequestSend() function when clear * to send. */ pCbCookie->updateSessionIvOnSend = CPA_TRUE; } } } break; case CPA_CY_SYM_CIPHER_ZUC_EEA3: { LAC_CHECK_NULL_PARAM(pOpData->pIv); if (pOpData->ivLenInBytes != ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } *ppIvBuffer = pOpData->pIv; } break; default: *ppIvBuffer = NULL; } return CPA_STATUS_SUCCESS; } - CpaStatus LacCipher_SessionSetupDataCheck(const CpaCySymCipherSetupData *pCipherSetupData, Cpa32U capabilitiesMask) { /* No key required for NULL algorithm */ if (!LAC_CIPHER_IS_NULL(pCipherSetupData->cipherAlgorithm)) { LAC_CHECK_NULL_PARAM(pCipherSetupData->pCipherKey); /* Check that algorithm and keys passed in are correct size */ switch (pCipherSetupData->cipherAlgorithm) { case CPA_CY_SYM_CIPHER_ARC4: if (pCipherSetupData->cipherKeyLenInBytes > ICP_QAT_HW_ARC4_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid ARC4 cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_AES_CCM: if (!LAC_CIPHER_AES_V2(capabilitiesMask) && pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_128_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid AES CCM cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_AES_XTS: if ((pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_128_XTS_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_256_XTS_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_UCS_AES_128_XTS_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_UCS_AES_256_XTS_KEY_SZ)) { LAC_INVALID_PARAM_LOG( "Invalid AES XTS cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_AES_ECB: case CPA_CY_SYM_CIPHER_AES_CBC: case CPA_CY_SYM_CIPHER_AES_CTR: case CPA_CY_SYM_CIPHER_AES_GCM: if ((pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_128_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_192_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_256_KEY_SZ)) { LAC_INVALID_PARAM_LOG( "Invalid AES cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_AES_F8: if ((pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_128_F8_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_192_F8_KEY_SZ) && (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_AES_256_F8_KEY_SZ)) { LAC_INVALID_PARAM_LOG( "Invalid AES cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_DES_ECB: case CPA_CY_SYM_CIPHER_DES_CBC: if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_DES_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid DES cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_3DES_ECB: case CPA_CY_SYM_CIPHER_3DES_CBC: case CPA_CY_SYM_CIPHER_3DES_CTR: if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_3DES_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid Triple-DES cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_KASUMI_F8: /* QAT-FW only supports 128 bits Cipher Key size for * Kasumi F8 Ref: 3GPP TS 55.216 V6.2.0 */ if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_KASUMI_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid Kasumi cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: /* QAT-FW only supports 256 bits Cipher Key size for * Snow_3G */ if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_SNOW_3G_UEA2_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid Snow_3G cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_ZUC_EEA3: /* ZUC EEA3 */ if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_ZUC_3G_EEA3_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid ZUC cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_CHACHA: if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_CHACHAPOLY_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid CHACHAPOLY cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; case CPA_CY_SYM_CIPHER_SM4_ECB: case CPA_CY_SYM_CIPHER_SM4_CBC: case CPA_CY_SYM_CIPHER_SM4_CTR: if (pCipherSetupData->cipherKeyLenInBytes != ICP_QAT_HW_SM4_KEY_SZ) { LAC_INVALID_PARAM_LOG( "Invalid SM4 cipher key length"); return CPA_STATUS_INVALID_PARAM; } break; default: LAC_INVALID_PARAM_LOG("Invalid cipher algorithm"); return CPA_STATUS_INVALID_PARAM; } } return CPA_STATUS_SUCCESS; } CpaStatus LacCipher_PerformParamCheck(CpaCySymCipherAlgorithm algorithm, const CpaCySymOpData *pOpData, const Cpa64U packetLen) { CpaStatus status = CPA_STATUS_SUCCESS; /* The following check will cover the dstBuffer as well, since * the dstBuffer cannot be smaller than the srcBuffer (checked in * LacSymPerform_BufferParamCheck() called from LacSym_Perform()) */ if ((pOpData->messageLenToCipherInBytes + pOpData->cryptoStartSrcOffsetInBytes) > packetLen) { LAC_INVALID_PARAM_LOG("cipher len + offset greater than " "srcBuffer packet len"); status = CPA_STATUS_INVALID_PARAM; } else { /* Perform algorithm-specific checks */ switch (algorithm) { case CPA_CY_SYM_CIPHER_ARC4: case CPA_CY_SYM_CIPHER_AES_CTR: case CPA_CY_SYM_CIPHER_3DES_CTR: case CPA_CY_SYM_CIPHER_SM4_CTR: case CPA_CY_SYM_CIPHER_AES_CCM: case CPA_CY_SYM_CIPHER_AES_GCM: case CPA_CY_SYM_CIPHER_CHACHA: case CPA_CY_SYM_CIPHER_KASUMI_F8: case CPA_CY_SYM_CIPHER_AES_F8: case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: case CPA_CY_SYM_CIPHER_ZUC_EEA3: /* No action needed */ break; /* * XTS Mode allow for ciphers which are not multiples of * the block size. */ case CPA_CY_SYM_CIPHER_AES_XTS: if ((pOpData->packetType == CPA_CY_SYM_PACKET_TYPE_FULL) || (pOpData->packetType == CPA_CY_SYM_PACKET_TYPE_LAST_PARTIAL)) { /* * If this is the last of a partial request */ if (pOpData->messageLenToCipherInBytes < ICP_QAT_HW_AES_BLK_SZ) { LAC_INVALID_PARAM_LOG( "data size must be greater than block" " size for last XTS partial or XTS " "full packet"); status = CPA_STATUS_INVALID_PARAM; } } break; default: /* Mask & check below is based on assumption that block * size is a power of 2. If data size is not a multiple * of the block size, the "remainder" bits selected by * the mask be non-zero */ if (pOpData->messageLenToCipherInBytes & (LacSymQat_CipherBlockSizeBytesGet(algorithm) - 1)) { LAC_INVALID_PARAM_LOG( "data size must be block size" " multiple"); status = CPA_STATUS_INVALID_PARAM; } } } return status; } Cpa32U LacCipher_GetCipherSliceType(sal_crypto_service_t *pService, CpaCySymCipherAlgorithm cipherAlgorithm, CpaCySymHashAlgorithm hashAlgorithm) { Cpa32U sliceType = ICP_QAT_FW_LA_USE_LEGACY_SLICE_TYPE; Cpa32U capabilitiesMask = pService->generic_service_info.capabilitiesMask; - /* UCS Slice is supproted only in Gen4 */ + /* UCS Slice is supported only in Gen4 */ if (isCyGen4x(pService)) { if (LAC_CIPHER_IS_XTS_MODE(cipherAlgorithm) || LAC_CIPHER_IS_CHACHA(cipherAlgorithm) || LAC_CIPHER_IS_GCM(cipherAlgorithm)) { sliceType = ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE; } else if (LAC_CIPHER_IS_CCM(cipherAlgorithm) && LAC_CIPHER_AES_V2(capabilitiesMask)) { sliceType = ICP_QAT_FW_LA_USE_LEGACY_SLICE_TYPE; } else if (LAC_CIPHER_IS_AES(cipherAlgorithm) && LAC_CIPHER_IS_CTR_MODE(cipherAlgorithm)) { sliceType = ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE; } } return sliceType; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_compile_check.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_compile_check.c index d732add29c76..0313032aac84 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_compile_check.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_compile_check.c @@ -1,45 +1,42 @@ -/*************************************************************************** - * - * - * - ***************************************************************************/ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_compile_check.c * * @ingroup LacSym * * This file checks at compile time that some assumptions about the layout * of key structures are as expected. * * ***************************************************************************/ #include "cpa.h" #include "lac_common.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "lac_sym.h" #include "cpa_cy_sym_dp.h" #define COMPILE_TIME_ASSERT(pred) \ switch (0) { \ case 0: \ case pred:; \ } void LacSym_CompileTimeAssertions(void) { /* ************************************************************* * Check sessionCtx is at the same location in bulk cookie and * CpaCySymDpOpData. * This is required for the callbacks to work as expected - * see LacSymCb_ProcessCallback * ************************************************************* */ COMPILE_TIME_ASSERT(offsetof(lac_sym_bulk_cookie_t, sessionCtx) == offsetof(CpaCySymDpOpData, sessionCtx)); } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_dp.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_dp.c index 1957126e0f1c..65a0d17d307f 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_dp.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_dp.c @@ -1,1184 +1,1179 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_dp.c * Implementation of the symmetric data plane API * * @ingroup cpaCySymDp ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "cpa_cy_sym_dp.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "icp_accel_devices.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_adf_transport_dp.h" #include "icp_adf_debug.h" #include "icp_sal_poll.h" #include "qat_utils.h" #include "lac_list.h" #include "lac_log.h" #include "lac_mem.h" #include "lac_sal_types_crypto.h" #include "lac_sym.h" #include "lac_sym_cipher.h" #include "lac_sym_auth_enc.h" #include "lac_sym_qat_cipher.h" #include "sal_service_state.h" #include "sal_hw_gen.h" typedef void (*write_ringMsgFunc_t)(CpaCySymDpOpData *pRequest, icp_qat_fw_la_bulk_req_t *pCurrentQatMsg); /** ***************************************************************************** * @ingroup cpaCySymDp * Check that the operation data is valid * * @description * Check that all the parameters defined in the operation data are valid * * @param[in] pRequest Pointer to an operation data for crypto * data plane API * * @retval CPA_STATUS_SUCCESS Function executed successfully * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in * *****************************************************************************/ static CpaStatus LacDp_EnqueueParamCheck(const CpaCySymDpOpData *pRequest) { lac_session_desc_t *pSessionDesc = NULL; CpaCySymCipherAlgorithm cipher = 0; CpaCySymHashAlgorithm hash = 0; Cpa32U capabilitiesMask = 0; LAC_CHECK_NULL_PARAM(pRequest); LAC_CHECK_NULL_PARAM(pRequest->instanceHandle); LAC_CHECK_NULL_PARAM(pRequest->sessionCtx); /* Ensure this is a crypto instance */ SAL_CHECK_INSTANCE_TYPE(pRequest->instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pRequest->sessionCtx); if (NULL == pSessionDesc) { do { qatUtilsSleep(500); pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET( pRequest->sessionCtx); } while (NULL == pSessionDesc); } if (NULL == pSessionDesc) { LAC_INVALID_PARAM_LOG("Session context not as expected"); return CPA_STATUS_INVALID_PARAM; } if (CPA_FALSE == pSessionDesc->isDPSession) { LAC_INVALID_PARAM_LOG( "Session not initialised for data plane API"); return CPA_STATUS_INVALID_PARAM; } /*check whether Payload size is zero for CHACHA-POLY */ if ((CPA_CY_SYM_CIPHER_CHACHA == pSessionDesc->cipherAlgorithm) && (CPA_CY_SYM_HASH_POLY == pSessionDesc->hashAlgorithm) && (CPA_CY_SYM_OP_ALGORITHM_CHAINING == pSessionDesc->symOperation)) { if (!pRequest->messageLenToCipherInBytes) { LAC_INVALID_PARAM_LOG( "Invalid messageLenToCipherInBytes for CHACHA-POLY"); return CPA_STATUS_INVALID_PARAM; } } if (0 == pRequest->srcBuffer) { LAC_INVALID_PARAM_LOG("Invalid srcBuffer"); return CPA_STATUS_INVALID_PARAM; } if (0 == pRequest->dstBuffer) { LAC_INVALID_PARAM_LOG("Invalid destBuffer"); return CPA_STATUS_INVALID_PARAM; } if (0 == pRequest->thisPhys) { LAC_INVALID_PARAM_LOG("Invalid thisPhys"); return CPA_STATUS_INVALID_PARAM; } /* Check that src buffer Len = dst buffer Len Note this also checks that they are of the same type */ if (pRequest->srcBufferLen != pRequest->dstBufferLen) { LAC_INVALID_PARAM_LOG( "Source and Destination buffer lengths need to be equal"); return CPA_STATUS_INVALID_PARAM; } /* digestVerify and digestIsAppended on Hash-Only operation not * supported */ if (pSessionDesc->digestIsAppended && pSessionDesc->digestVerify && (pSessionDesc->symOperation == CPA_CY_SYM_OP_HASH)) { LAC_INVALID_PARAM_LOG( "digestVerify and digestIsAppended set " "on Hash-Only operation is not supported"); return CPA_STATUS_INVALID_PARAM; } /* Cipher specific tests */ if (CPA_CY_SYM_OP_HASH != pSessionDesc->symOperation) { /* Perform IV check */ switch (pSessionDesc->cipherAlgorithm) { case CPA_CY_SYM_CIPHER_AES_CTR: case CPA_CY_SYM_CIPHER_3DES_CTR: case CPA_CY_SYM_CIPHER_SM4_CTR: case CPA_CY_SYM_CIPHER_AES_GCM: case CPA_CY_SYM_CIPHER_CHACHA: case CPA_CY_SYM_CIPHER_AES_CBC: case CPA_CY_SYM_CIPHER_DES_CBC: case CPA_CY_SYM_CIPHER_3DES_CBC: case CPA_CY_SYM_CIPHER_SM4_CBC: case CPA_CY_SYM_CIPHER_AES_F8: { Cpa32U ivLenInBytes = LacSymQat_CipherIvSizeBytesGet( pSessionDesc->cipherAlgorithm); if (pRequest->ivLenInBytes != ivLenInBytes) { if (!(/* GCM with 12 byte IV is OK */ (LAC_CIPHER_IS_GCM( pSessionDesc->cipherAlgorithm) && pRequest->ivLenInBytes == LAC_CIPHER_IV_SIZE_GCM_12))) { LAC_INVALID_PARAM_LOG( "invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } } if (0 == pRequest->iv) { LAC_INVALID_PARAM_LOG("invalid iv of 0"); return CPA_STATUS_INVALID_PARAM; } /* pRequest->pIv is only used for CCM so is not checked * here */ } break; case CPA_CY_SYM_CIPHER_KASUMI_F8: { if (LAC_CIPHER_KASUMI_F8_IV_LENGTH != pRequest->ivLenInBytes) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } if (0 == pRequest->iv) { LAC_INVALID_PARAM_LOG("invalid iv of 0"); return CPA_STATUS_INVALID_PARAM; } } break; case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: { if (ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ != pRequest->ivLenInBytes) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } if (0 == pRequest->iv) { LAC_INVALID_PARAM_LOG("invalid iv of 0"); return CPA_STATUS_INVALID_PARAM; } } break; case CPA_CY_SYM_CIPHER_ZUC_EEA3: { if (ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ != pRequest->ivLenInBytes) { LAC_INVALID_PARAM_LOG("invalid cipher IV size"); return CPA_STATUS_INVALID_PARAM; } if (0 == pRequest->iv) { LAC_INVALID_PARAM_LOG("invalid iv of 0"); return CPA_STATUS_INVALID_PARAM; } } break; case CPA_CY_SYM_CIPHER_AES_CCM: { if (CPA_STATUS_SUCCESS != LacSymAlgChain_CheckCCMData( pRequest->pAdditionalAuthData, pRequest->pIv, pRequest->messageLenToCipherInBytes, pRequest->ivLenInBytes)) { return CPA_STATUS_INVALID_PARAM; } } break; default: break; } /* Perform algorithm-specific checks */ switch (pSessionDesc->cipherAlgorithm) { case CPA_CY_SYM_CIPHER_ARC4: case CPA_CY_SYM_CIPHER_AES_CTR: case CPA_CY_SYM_CIPHER_3DES_CTR: case CPA_CY_SYM_CIPHER_SM4_CTR: case CPA_CY_SYM_CIPHER_AES_CCM: case CPA_CY_SYM_CIPHER_AES_GCM: case CPA_CY_SYM_CIPHER_CHACHA: case CPA_CY_SYM_CIPHER_KASUMI_F8: case CPA_CY_SYM_CIPHER_AES_F8: case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: case CPA_CY_SYM_CIPHER_ZUC_EEA3: /* No action needed */ break; default: { /* Mask & check below is based on assumption that block * size is a power of 2. If data size is not a multiple * of the block size, the "remainder" bits selected by * the mask be non-zero */ if (pRequest->messageLenToCipherInBytes & (LacSymQat_CipherBlockSizeBytesGet( pSessionDesc->cipherAlgorithm) - 1)) { LAC_INVALID_PARAM_LOG( "Data size must be block size" " multiple"); return CPA_STATUS_INVALID_PARAM; } } } cipher = pSessionDesc->cipherAlgorithm; hash = pSessionDesc->hashAlgorithm; capabilitiesMask = ((sal_crypto_service_t *)pRequest->instanceHandle) ->generic_service_info.capabilitiesMask; if (LAC_CIPHER_IS_SPC(cipher, hash, capabilitiesMask) && (LAC_CIPHER_SPC_IV_SIZE == pRequest->ivLenInBytes)) { /* For CHACHA and AES_GCM single pass there is an AAD * buffer if aadLenInBytes is nonzero. AES_GMAC AAD is * stored in source buffer, therefore there is no * separate AAD buffer. */ if ((0 != pSessionDesc->aadLenInBytes) && (CPA_CY_SYM_HASH_AES_GMAC != pSessionDesc->hashAlgorithm)) { LAC_CHECK_NULL_PARAM( pRequest->pAdditionalAuthData); } /* Ensure AAD length for AES_GMAC spc */ if ((CPA_CY_SYM_HASH_AES_GMAC == hash) && (ICP_QAT_FW_SPC_AAD_SZ_MAX < pRequest->messageLenToHashInBytes)) { LAC_INVALID_PARAM_LOG( "aadLenInBytes for AES_GMAC"); return CPA_STATUS_INVALID_PARAM; } } } /* Hash specific tests */ if (CPA_CY_SYM_OP_CIPHER != pSessionDesc->symOperation) { /* For CCM, snow3G and ZUC there is always an AAD buffer For GCM there is an AAD buffer if aadLenInBytes is nonzero */ if ((CPA_CY_SYM_HASH_AES_CCM == pSessionDesc->hashAlgorithm) || (CPA_CY_SYM_HASH_AES_GCM == pSessionDesc->hashAlgorithm && (0 != pSessionDesc->aadLenInBytes))) { LAC_CHECK_NULL_PARAM(pRequest->pAdditionalAuthData); if (0 == pRequest->additionalAuthData) { LAC_INVALID_PARAM_LOG( "Invalid additionalAuthData"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pSessionDesc->hashAlgorithm || CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm) { if (0 == pRequest->additionalAuthData) { LAC_INVALID_PARAM_LOG( "Invalid additionalAuthData"); return CPA_STATUS_INVALID_PARAM; } } if ((CPA_CY_SYM_HASH_AES_CCM != pSessionDesc->hashAlgorithm) && (!pSessionDesc->digestIsAppended) && (0 == pRequest->digestResult)) { LAC_INVALID_PARAM_LOG("Invalid digestResult"); return CPA_STATUS_INVALID_PARAM; } if (CPA_CY_SYM_HASH_AES_CCM == pSessionDesc->hashAlgorithm) { if ((pRequest->cryptoStartSrcOffsetInBytes + pRequest->messageLenToCipherInBytes + pSessionDesc->hashResultSize) > pRequest->dstBufferLen) { LAC_INVALID_PARAM_LOG( "CCM - Not enough room for" " digest in destination buffer"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_TRUE == pSessionDesc->digestIsAppended) { if (CPA_CY_SYM_HASH_AES_GMAC == pSessionDesc->hashAlgorithm) { if ((pRequest->hashStartSrcOffsetInBytes + pRequest->messageLenToHashInBytes + pSessionDesc->hashResultSize) > pRequest->dstBufferLen) { LAC_INVALID_PARAM_LOG( "Append Digest - Not enough room for" " digest in destination buffer for " "AES GMAC algorithm"); return CPA_STATUS_INVALID_PARAM; } } if (CPA_CY_SYM_HASH_AES_GCM == pSessionDesc->hashAlgorithm) { if ((pRequest->cryptoStartSrcOffsetInBytes + pRequest->messageLenToCipherInBytes + pSessionDesc->hashResultSize) > pRequest->dstBufferLen) { LAC_INVALID_PARAM_LOG( "Append Digest - Not enough room " "for digest in destination buffer" " for GCM algorithm"); return CPA_STATUS_INVALID_PARAM; } } if ((pRequest->hashStartSrcOffsetInBytes + pRequest->messageLenToHashInBytes + pSessionDesc->hashResultSize) > pRequest->dstBufferLen) { LAC_INVALID_PARAM_LOG( "Append Digest - Not enough room for" " digest in destination buffer"); return CPA_STATUS_INVALID_PARAM; } } if (CPA_CY_SYM_HASH_AES_GMAC == pSessionDesc->hashAlgorithm) { if (pRequest->messageLenToHashInBytes == 0 || pRequest->pAdditionalAuthData != NULL) { LAC_INVALID_PARAM_LOG( "For AES_GMAC, AAD Length " "(messageLenToHashInBytes) must be " "non zero and pAdditionalAuthData " "must be NULL"); return CPA_STATUS_INVALID_PARAM; } } } if (CPA_DP_BUFLIST != pRequest->srcBufferLen) { if ((CPA_CY_SYM_OP_HASH != pSessionDesc->symOperation) && ((pRequest->messageLenToCipherInBytes + pRequest->cryptoStartSrcOffsetInBytes) > pRequest->srcBufferLen)) { LAC_INVALID_PARAM_LOG( "cipher len + offset greater than " "srcBufferLen"); return CPA_STATUS_INVALID_PARAM; } else if ((CPA_CY_SYM_OP_CIPHER != pSessionDesc->symOperation) && (CPA_CY_SYM_HASH_AES_CCM != pSessionDesc->hashAlgorithm) && (CPA_CY_SYM_HASH_AES_GCM != pSessionDesc->hashAlgorithm) && (CPA_CY_SYM_HASH_AES_GMAC != pSessionDesc->hashAlgorithm) && ((pRequest->messageLenToHashInBytes + pRequest->hashStartSrcOffsetInBytes) > pRequest->srcBufferLen)) { LAC_INVALID_PARAM_LOG( "hash len + offset greater than srcBufferLen"); return CPA_STATUS_INVALID_PARAM; } } else { LAC_CHECK_8_BYTE_ALIGNMENT(pRequest->srcBuffer); LAC_CHECK_8_BYTE_ALIGNMENT(pRequest->dstBuffer); } LAC_CHECK_8_BYTE_ALIGNMENT(pRequest->thisPhys); return CPA_STATUS_SUCCESS; } /** ***************************************************************************** * @ingroup cpaCySymDp * Write Message on the ring and write request params * This is the optimized version, which should not be used for * algorithm of CCM, GCM, CHACHA and RC4 * * @description * Write Message on the ring and write request params * * @param[in/out] pRequest Pointer to operation data for crypto * data plane API * @param[in/out] pCurrentQatMsg Pointer to ring memory where msg will * be written * * @retval none * *****************************************************************************/ void LacDp_WriteRingMsgOpt(CpaCySymDpOpData *pRequest, icp_qat_fw_la_bulk_req_t *pCurrentQatMsg) { lac_session_desc_t *pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pRequest->sessionCtx); Cpa8U *pMsgDummy = NULL; Cpa8U *pCacheDummyHdr = NULL; Cpa8U *pCacheDummyFtr = NULL; pMsgDummy = (Cpa8U *)pCurrentQatMsg; /* Write Request */ /* * Fill in the header and footer bytes of the ET ring message - cached * from the session descriptor. */ if (!pSessionDesc->useSymConstantsTable) { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->reqCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->reqCacheFtr); } else { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->shramReqCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->shramReqCacheFtr); } memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memset((pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)), 0, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_TO_CLEAR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); SalQatMsg_CmnMidWrite(pCurrentQatMsg, pRequest, (CPA_DP_BUFLIST == pRequest->srcBufferLen ? QAT_COMN_PTR_TYPE_SGL : QAT_COMN_PTR_TYPE_FLAT), pRequest->srcBuffer, pRequest->dstBuffer, pRequest->srcBufferLen, pRequest->dstBufferLen); /* Write Request Params */ if (pSessionDesc->isCipher) { LacSymQat_CipherRequestParamsPopulate( pSessionDesc, pCurrentQatMsg, pRequest->cryptoStartSrcOffsetInBytes, pRequest->messageLenToCipherInBytes, pRequest->iv, pRequest->pIv); } if (pSessionDesc->isAuth) { lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo = &(pSessionDesc->hashStateBufferInfo); icp_qat_fw_la_auth_req_params_t *pAuthReqPars = (icp_qat_fw_la_auth_req_params_t *)((Cpa8U *)&(pCurrentQatMsg->serv_specif_rqpars) + ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET); if ((CPA_CY_SYM_HASH_SNOW3G_UIA2 != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_AES_CCM != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_AES_GCM != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_AES_GMAC != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_ZUC_EIA3 != pSessionDesc->hashAlgorithm) && (pHashStateBufferInfo->prefixAadSzQuadWords > 0)) { /* prefixAadSzQuadWords > 0 when there is prefix data - i.e. nested hash or HMAC no precompute cases Note partials not supported on DP api so we do not need dynamic hash state in this case */ pRequest->additionalAuthData = pHashStateBufferInfo->pDataPhys + LAC_QUADWORDS_TO_BYTES( pHashStateBufferInfo->stateStorageSzQuadWords); } /* The first 24 bytes in icp_qat_fw_la_auth_req_params_t can be * copied directly from the op request data because they share a * corresponding layout. The remaining 4 bytes are taken * from the session message template and use values * preconfigured at sessionInit (updated per request for some * specific cases below) */ /* We force a specific compiler optimisation here. The length * to be copied turns out to be always 16, and by coding a * memcpy with a literal value the compiler will compile inline * code (in fact, only two vector instructions) to effect the * copy. This gives us a huge performance increase. */ unsigned long cplen = (unsigned long)&(pAuthReqPars->u2.inner_prefix_sz) - (unsigned long)pAuthReqPars; if (cplen == 16) memcpy(pAuthReqPars, (Cpa32U *)&(pRequest->hashStartSrcOffsetInBytes), 16); else memcpy(pAuthReqPars, (Cpa32U *)&(pRequest->hashStartSrcOffsetInBytes), cplen); if (CPA_TRUE == pSessionDesc->isAuthEncryptOp) { pAuthReqPars->hash_state_sz = LAC_BYTES_TO_QUADWORDS(pAuthReqPars->u2.aad_sz); } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pSessionDesc->hashAlgorithm || CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm) { pAuthReqPars->hash_state_sz = LAC_BYTES_TO_QUADWORDS(pSessionDesc->aadLenInBytes); } } } /** ***************************************************************************** * @ingroup cpaCySymDp * Write Message on the ring and write request params * * @description * Write Message on the ring and write request params * * @param[in/out] pRequest Pointer to operation data for crypto * data plane API * @param[in/out] pCurrentQatMsg Pointer to ring memory where msg will * be written * * @retval none * *****************************************************************************/ void LacDp_WriteRingMsgFull(CpaCySymDpOpData *pRequest, icp_qat_fw_la_bulk_req_t *pCurrentQatMsg) { lac_session_desc_t *pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pRequest->sessionCtx); Cpa8U *pMsgDummy = NULL; Cpa8U *pCacheDummyHdr = NULL; Cpa8U *pCacheDummyFtr = NULL; sal_qat_content_desc_info_t *pCdInfo = NULL; Cpa8U *pHwBlockBaseInDRAM = NULL; Cpa32U hwBlockOffsetInDRAM = 0; Cpa32U sizeInBytes = 0; CpaCySymCipherAlgorithm cipher = pSessionDesc->cipherAlgorithm; CpaCySymHashAlgorithm hash = pSessionDesc->hashAlgorithm; sal_crypto_service_t *pService = (sal_crypto_service_t *)pRequest->instanceHandle; Cpa32U capabilitiesMask = ((sal_crypto_service_t *)pRequest->instanceHandle) ->generic_service_info.capabilitiesMask; CpaBoolean isSpCcm = LAC_CIPHER_IS_CCM(cipher) && LAC_CIPHER_IS_SPC(cipher, hash, capabilitiesMask); Cpa8U paddingLen = 0; Cpa8U blockLen = 0; Cpa32U aadDataLen = 0; pMsgDummy = (Cpa8U *)pCurrentQatMsg; /* Write Request */ /* * Fill in the header and footer bytes of the ET ring message - cached * from the session descriptor. */ if ((NON_SPC != pSessionDesc->singlePassState) && (isSpCcm || (LAC_CIPHER_SPC_IV_SIZE == pRequest->ivLenInBytes))) { pSessionDesc->singlePassState = SPC; pSessionDesc->isCipher = CPA_TRUE; pSessionDesc->isAuthEncryptOp = CPA_FALSE; pSessionDesc->isAuth = CPA_FALSE; pSessionDesc->symOperation = CPA_CY_SYM_OP_CIPHER; pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_CIPHER; if (CPA_CY_SYM_HASH_AES_GMAC == pSessionDesc->hashAlgorithm) { pSessionDesc->aadLenInBytes = pRequest->messageLenToHashInBytes; } /* New bit position (13) for SINGLE PASS. * The FW provides a specific macro to use to set the proto flag */ ICP_QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_SET( pSessionDesc->laCmdFlags, ICP_QAT_FW_LA_SINGLE_PASS_PROTO); if (isCyGen2x(pService)) ICP_QAT_FW_LA_PROTO_SET(pSessionDesc->laCmdFlags, 0); pCdInfo = &(pSessionDesc->contentDescInfo); pHwBlockBaseInDRAM = (Cpa8U *)pCdInfo->pData; if (CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT == pSessionDesc->cipherDirection) { if (LAC_CIPHER_IS_GCM(cipher)) hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_GCM_SPC_OFFSET_IN_DRAM); else if (LAC_CIPHER_IS_CHACHA(cipher)) hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_CHACHA_SPC_OFFSET_IN_DRAM); } else if (isSpCcm) { hwBlockOffsetInDRAM = LAC_QUADWORDS_TO_BYTES( LAC_SYM_QAT_CIPHER_CCM_SPC_OFFSET_IN_DRAM); } /* Update slice type, as used algos changed */ pSessionDesc->cipherSliceType = LacCipher_GetCipherSliceType(pService, cipher, hash); ICP_QAT_FW_LA_SLICE_TYPE_SET(pSessionDesc->laCmdFlags, pSessionDesc->cipherSliceType); /* construct cipherConfig in CD in DRAM */ LacSymQat_CipherHwBlockPopulateCfgData(pSessionDesc, pHwBlockBaseInDRAM + hwBlockOffsetInDRAM, &sizeInBytes); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)&( pSessionDesc->reqSpcCacheHdr), ICP_QAT_FW_COMN_REQ_CPM_FW_LA, pSessionDesc->laCmdId, pSessionDesc->cmnRequestFlags, pSessionDesc->laCmdFlags); } else if ((SPC == pSessionDesc->singlePassState) && (LAC_CIPHER_SPC_IV_SIZE != pRequest->ivLenInBytes)) { pSessionDesc->symOperation = CPA_CY_SYM_OP_ALGORITHM_CHAINING; pSessionDesc->singlePassState = LIKELY_SPC; pSessionDesc->isCipher = CPA_TRUE; pSessionDesc->isAuthEncryptOp = CPA_TRUE; pSessionDesc->isAuth = CPA_TRUE; pCdInfo = &(pSessionDesc->contentDescInfo); pHwBlockBaseInDRAM = (Cpa8U *)pCdInfo->pData; if (CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT == pSessionDesc->cipherDirection) { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_CIPHER_HASH; } else { pSessionDesc->laCmdId = ICP_QAT_FW_LA_CMD_HASH_CIPHER; } ICP_QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_SET( pSessionDesc->laCmdFlags, 0); ICP_QAT_FW_LA_PROTO_SET(pSessionDesc->laCmdFlags, ICP_QAT_FW_LA_GCM_PROTO); LacSymQat_CipherHwBlockPopulateCfgData(pSessionDesc, pHwBlockBaseInDRAM + hwBlockOffsetInDRAM, &sizeInBytes); SalQatMsg_CmnHdrWrite((icp_qat_fw_comn_req_t *)&( pSessionDesc->reqCacheHdr), ICP_QAT_FW_COMN_REQ_CPM_FW_LA, pSessionDesc->laCmdId, pSessionDesc->cmnRequestFlags, pSessionDesc->laCmdFlags); } else if (CPA_CY_SYM_HASH_AES_GMAC == pSessionDesc->hashAlgorithm) { pSessionDesc->aadLenInBytes = pRequest->messageLenToHashInBytes; } if (SPC == pSessionDesc->singlePassState) { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->reqSpcCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->reqSpcCacheFtr); } else { if (!pSessionDesc->useSymConstantsTable) { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->reqCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->reqCacheFtr); } else { pCacheDummyHdr = (Cpa8U *)&(pSessionDesc->shramReqCacheHdr); pCacheDummyFtr = (Cpa8U *)&(pSessionDesc->shramReqCacheFtr); } } memcpy(pMsgDummy, pCacheDummyHdr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)); memset((pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_HDR_IN_LW)), 0, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_TO_CLEAR_IN_LW)); memcpy(pMsgDummy + (LAC_LONG_WORD_IN_BYTES * LAC_START_OF_CACHE_FTR_IN_LW), pCacheDummyFtr, (LAC_LONG_WORD_IN_BYTES * LAC_SIZE_OF_CACHE_FTR_IN_LW)); SalQatMsg_CmnMidWrite(pCurrentQatMsg, pRequest, (CPA_DP_BUFLIST == pRequest->srcBufferLen ? QAT_COMN_PTR_TYPE_SGL : QAT_COMN_PTR_TYPE_FLAT), pRequest->srcBuffer, pRequest->dstBuffer, pRequest->srcBufferLen, pRequest->dstBufferLen); if ((CPA_CY_SYM_HASH_AES_CCM == pSessionDesc->hashAlgorithm && pSessionDesc->isAuth == CPA_TRUE) || isSpCcm) { /* prepare IV and AAD for CCM */ LacSymAlgChain_PrepareCCMData( pSessionDesc, pRequest->pAdditionalAuthData, pRequest->pIv, pRequest->messageLenToCipherInBytes, pRequest->ivLenInBytes); /* According to the API, for CCM and GCM, * messageLenToHashInBytes and hashStartSrcOffsetInBytes are not * initialized by the user and must be set by the driver */ pRequest->hashStartSrcOffsetInBytes = pRequest->cryptoStartSrcOffsetInBytes; pRequest->messageLenToHashInBytes = pRequest->messageLenToCipherInBytes; } else if ((SPC != pSessionDesc->singlePassState) && (CPA_CY_SYM_HASH_AES_GCM == pSessionDesc->hashAlgorithm || CPA_CY_SYM_HASH_AES_GMAC == pSessionDesc->hashAlgorithm)) { /* GCM case */ if (CPA_CY_SYM_HASH_AES_GMAC != pSessionDesc->hashAlgorithm) { /* According to the API, for CCM and GCM, * messageLenToHashInBytes and hashStartSrcOffsetInBytes * are not initialized by the user and must be set * by the driver */ pRequest->hashStartSrcOffsetInBytes = pRequest->cryptoStartSrcOffsetInBytes; pRequest->messageLenToHashInBytes = pRequest->messageLenToCipherInBytes; LacSymAlgChain_PrepareGCMData( pSessionDesc, pRequest->pAdditionalAuthData); } if (LAC_CIPHER_IV_SIZE_GCM_12 == pRequest->ivLenInBytes) { ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET( pCurrentQatMsg->comn_hdr.serv_specif_flags, ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS); } } /* Write Request Params */ if (pSessionDesc->isCipher) { if (CPA_CY_SYM_CIPHER_ARC4 == pSessionDesc->cipherAlgorithm) { /* ARC4 does not have an IV but the field is used to * store the initial state */ pRequest->iv = pSessionDesc->cipherARC4InitialStatePhysAddr; } ICP_QAT_FW_LA_SLICE_TYPE_SET( pCurrentQatMsg->comn_hdr.serv_specif_flags, pSessionDesc->cipherSliceType); LacSymQat_CipherRequestParamsPopulate( pSessionDesc, pCurrentQatMsg, pRequest->cryptoStartSrcOffsetInBytes, pRequest->messageLenToCipherInBytes, pRequest->iv, pRequest->pIv); if (SPC == pSessionDesc->singlePassState) { icp_qat_fw_la_cipher_req_params_t *pCipherReqParams = (icp_qat_fw_la_cipher_req_params_t *)((Cpa8U *)&( pCurrentQatMsg->serv_specif_rqpars) + ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET); icp_qat_fw_la_cipher_20_req_params_t *pCipher20ReqParams = (void *)((Cpa8U *)&( pCurrentQatMsg->serv_specif_rqpars) + ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET); if (isCyGen4x(pService)) { pCipher20ReqParams->spc_aad_addr = (uint64_t)pRequest->additionalAuthData; pCipher20ReqParams->spc_aad_sz = pSessionDesc->aadLenInBytes; pCipher20ReqParams->spc_aad_offset = 0; if (isSpCcm) pCipher20ReqParams->spc_aad_sz += LAC_CIPHER_CCM_AAD_OFFSET; pCipher20ReqParams->spc_auth_res_addr = (uint64_t)pRequest->digestResult; pCipher20ReqParams->spc_auth_res_sz = (Cpa8U)pSessionDesc->hashResultSize; } else { pCipherReqParams->spc_aad_addr = (uint64_t)pRequest->additionalAuthData; pCipherReqParams->spc_aad_sz = (Cpa16U)pSessionDesc->aadLenInBytes; pCipherReqParams->spc_auth_res_addr = (uint64_t)pRequest->digestResult; pCipherReqParams->spc_auth_res_sz = (Cpa8U)pSessionDesc->hashResultSize; } /* For CHACHA and AES_GCM single pass AAD buffer needs * alignment if aadLenInBytes is nonzero. In case of * AES-GMAC, AAD buffer passed in the src buffer. */ if (0 != pSessionDesc->aadLenInBytes && CPA_CY_SYM_HASH_AES_GMAC != pSessionDesc->hashAlgorithm) { blockLen = LacSymQat_CipherBlockSizeBytesGet( pSessionDesc->cipherAlgorithm); aadDataLen = pSessionDesc->aadLenInBytes; /* In case of AES_CCM, B0 block size and 2 bytes * of AAD len * encoding need to be added to total AAD data * len */ if (isSpCcm) aadDataLen += LAC_CIPHER_CCM_AAD_OFFSET; if ((aadDataLen % blockLen) != 0) { paddingLen = blockLen - (aadDataLen % blockLen); memset(&pRequest->pAdditionalAuthData [aadDataLen], 0, paddingLen); } } } } if (pSessionDesc->isAuth) { lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo = &(pSessionDesc->hashStateBufferInfo); icp_qat_fw_la_auth_req_params_t *pAuthReqPars = (icp_qat_fw_la_auth_req_params_t *)((Cpa8U *)&(pCurrentQatMsg->serv_specif_rqpars) + ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET); if ((CPA_CY_SYM_HASH_SNOW3G_UIA2 != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_AES_CCM != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_AES_GCM != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_AES_GMAC != pSessionDesc->hashAlgorithm && CPA_CY_SYM_HASH_ZUC_EIA3 != pSessionDesc->hashAlgorithm) && (pHashStateBufferInfo->prefixAadSzQuadWords > 0)) { /* prefixAadSzQuadWords > 0 when there is prefix data - i.e. nested hash or HMAC no precompute cases Note partials not supported on DP api so we do not need dynamic hash state in this case */ pRequest->additionalAuthData = pHashStateBufferInfo->pDataPhys + LAC_QUADWORDS_TO_BYTES( pHashStateBufferInfo->stateStorageSzQuadWords); } /* The first 24 bytes in icp_qat_fw_la_auth_req_params_t can be * copied directly from the op request data because they share a * corresponding layout. The remaining 4 bytes are taken * from the session message template and use values * preconfigured at sessionInit (updated per request for some * specific cases below) */ memcpy(pAuthReqPars, (Cpa32U *)&(pRequest->hashStartSrcOffsetInBytes), ((uintptr_t) & (pAuthReqPars->u2.inner_prefix_sz) - (uintptr_t)pAuthReqPars)); if (CPA_TRUE == pSessionDesc->isAuthEncryptOp) { pAuthReqPars->hash_state_sz = LAC_BYTES_TO_QUADWORDS(pAuthReqPars->u2.aad_sz); } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pSessionDesc->hashAlgorithm || CPA_CY_SYM_HASH_ZUC_EIA3 == pSessionDesc->hashAlgorithm) { pAuthReqPars->hash_state_sz = LAC_BYTES_TO_QUADWORDS(pSessionDesc->aadLenInBytes); } } } CpaStatus cpaCySymDpSessionCtxGetSize(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes) { CpaStatus status = CPA_STATUS_SUCCESS; /* CPA_INSTANCE_HANDLE_SINGLE is not supported on DP apis */ LAC_CHECK_INSTANCE_HANDLE(instanceHandle); /* All other param checks are common with trad api */ /* Check for valid pointers */ LAC_CHECK_NULL_PARAM(pSessionCtxSizeInBytes); status = cpaCySymSessionCtxGetSize(instanceHandle, pSessionSetupData, pSessionCtxSizeInBytes); return status; } CpaStatus cpaCySymDpSessionCtxGetDynamicSize( const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes) { CpaStatus status = CPA_STATUS_SUCCESS; /* CPA_INSTANCE_HANDLE_SINGLE is not supported on DP apis */ LAC_CHECK_INSTANCE_HANDLE(instanceHandle); /* All other param checks are common with trad api */ /* Check for valid pointers */ LAC_CHECK_NULL_PARAM(pSessionCtxSizeInBytes); status = cpaCySymSessionCtxGetDynamicSize(instanceHandle, pSessionSetupData, pSessionCtxSizeInBytes); return status; } /** @ingroup cpaCySymDp */ CpaStatus cpaCySymDpInitSession(CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, CpaCySymDpSessionCtx sessionCtx) { CpaStatus status = CPA_STATUS_FAIL; sal_service_t *pService = NULL; - LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSessionSetupData); pService = (sal_service_t *)instanceHandle; /* Check crypto service is running otherwise return an error */ SAL_RUNNING_CHECK(pService); status = LacSym_InitSession(instanceHandle, NULL, /* Callback */ pSessionSetupData, CPA_TRUE, /* isDPSession */ sessionCtx); return status; } CpaStatus cpaCySymDpRemoveSession(const CpaInstanceHandle instanceHandle, CpaCySymDpSessionCtx sessionCtx) { /* CPA_INSTANCE_HANDLE_SINGLE is not supported on DP apis */ LAC_CHECK_INSTANCE_HANDLE(instanceHandle); /* All other param checks are common with trad api */ return cpaCySymRemoveSession(instanceHandle, sessionCtx); } CpaStatus cpaCySymDpRegCbFunc(const CpaInstanceHandle instanceHandle, const CpaCySymDpCbFunc pSymDpCb) { sal_crypto_service_t *pService = (sal_crypto_service_t *)instanceHandle; - LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pSymDpCb); SAL_RUNNING_CHECK(instanceHandle); pService->pSymDpCb = pSymDpCb; return CPA_STATUS_SUCCESS; } CpaStatus cpaCySymDpEnqueueOp(CpaCySymDpOpData *pRequest, const CpaBoolean performOpNow) { icp_qat_fw_la_bulk_req_t *pCurrentQatMsg = NULL; icp_comms_trans_handle trans_handle = NULL; lac_session_desc_t *pSessionDesc = NULL; write_ringMsgFunc_t callFunc; CpaStatus status = CPA_STATUS_SUCCESS; - LAC_CHECK_NULL_PARAM(pRequest); status = LacDp_EnqueueParamCheck(pRequest); if (CPA_STATUS_SUCCESS != status) { return status; } /* Check if SAL is running in crypto data plane otherwise return an * error */ SAL_RUNNING_CHECK(pRequest->instanceHandle); trans_handle = ((sal_crypto_service_t *)pRequest->instanceHandle) ->trans_handle_sym_tx; pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pRequest->sessionCtx); icp_adf_getSingleQueueAddr(trans_handle, (void **)&pCurrentQatMsg); if (NULL == pCurrentQatMsg) { /* * No space is available on the queue. */ return CPA_STATUS_RETRY; } callFunc = (write_ringMsgFunc_t)pSessionDesc->writeRingMsgFunc; LAC_CHECK_NULL_PARAM(callFunc); callFunc(pRequest, pCurrentQatMsg); qatUtilsAtomicInc(&(pSessionDesc->u.pendingDpCbCount)); if (CPA_TRUE == performOpNow) { SalQatMsg_updateQueueTail(trans_handle); } return CPA_STATUS_SUCCESS; } CpaStatus cpaCySymDpPerformOpNow(const CpaInstanceHandle instanceHandle) { icp_comms_trans_handle trans_handle = NULL; - LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); trans_handle = ((sal_crypto_service_t *)instanceHandle)->trans_handle_sym_tx; if (CPA_TRUE == icp_adf_queueDataToSend(trans_handle)) { SalQatMsg_updateQueueTail(trans_handle); } return CPA_STATUS_SUCCESS; } CpaStatus cpaCySymDpEnqueueOpBatch(const Cpa32U numberRequests, CpaCySymDpOpData *pRequests[], const CpaBoolean performOpNow) { icp_qat_fw_la_bulk_req_t *pCurrentQatMsg = NULL; icp_comms_trans_handle trans_handle = NULL; lac_session_desc_t *pSessionDesc = NULL; write_ringMsgFunc_t callFunc; Cpa32U i = 0; CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = NULL; - LAC_CHECK_NULL_PARAM(pRequests); LAC_CHECK_NULL_PARAM(pRequests[0]); LAC_CHECK_NULL_PARAM(pRequests[0]->instanceHandle); pService = (sal_crypto_service_t *)(pRequests[0]->instanceHandle); if ((0 == numberRequests) || (numberRequests > pService->maxNumSymReqBatch)) { LAC_INVALID_PARAM_LOG1( "The number of requests needs to be between 1 " "and %d", pService->maxNumSymReqBatch); return CPA_STATUS_INVALID_PARAM; } for (i = 0; i < numberRequests; i++) { status = LacDp_EnqueueParamCheck(pRequests[i]); if (CPA_STATUS_SUCCESS != status) { return status; } /* Check that all instance handles are the same */ if (pRequests[i]->instanceHandle != pRequests[0]->instanceHandle) { LAC_INVALID_PARAM_LOG( "All instance handles should be the same " "in the requests"); return CPA_STATUS_INVALID_PARAM; } } /* Check if SAL is running in crypto data plane otherwise return an * error */ SAL_RUNNING_CHECK(pRequests[0]->instanceHandle); trans_handle = ((sal_crypto_service_t *)pRequests[0]->instanceHandle) ->trans_handle_sym_tx; pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pRequests[0]->sessionCtx); icp_adf_getQueueMemory(trans_handle, numberRequests, (void **)&pCurrentQatMsg); if (NULL == pCurrentQatMsg) { /* * No space is available on the queue. */ return CPA_STATUS_RETRY; } for (i = 0; i < numberRequests; i++) { pSessionDesc = LAC_SYM_SESSION_DESC_FROM_CTX_GET(pRequests[i]->sessionCtx); callFunc = (write_ringMsgFunc_t)pSessionDesc->writeRingMsgFunc; callFunc(pRequests[i], pCurrentQatMsg); icp_adf_getQueueNext(trans_handle, (void **)&pCurrentQatMsg); qatUtilsAtomicAdd(1, &(pSessionDesc->u.pendingDpCbCount)); } if (CPA_TRUE == performOpNow) { SalQatMsg_updateQueueTail(trans_handle); } return CPA_STATUS_SUCCESS; } CpaStatus icp_sal_CyPollDpInstance(const CpaInstanceHandle instanceHandle, const Cpa32U responseQuota) { icp_comms_trans_handle trans_handle = NULL; LAC_CHECK_INSTANCE_HANDLE(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); /* Check if SAL is initialised otherwise return an error */ SAL_RUNNING_CHECK(instanceHandle); trans_handle = ((sal_crypto_service_t *)instanceHandle)->trans_handle_sym_rx; return icp_adf_pollQueue(trans_handle, responseQuota); } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash.c index a2d313c956ba..5ad64ca09a0b 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash.c @@ -1,765 +1,764 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_hash.c * * @ingroup LacHash * * Hash specific functionality ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_common.h" #include "lac_mem.h" #include "lac_sym.h" #include "lac_session.h" #include "lac_sym_hash.h" #include "lac_log.h" #include "lac_sym_qat_hash.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sym_cb.h" #include "lac_sync.h" #define LAC_HASH_ALG_MODE_NOT_SUPPORTED(alg, mode) \ ((((CPA_CY_SYM_HASH_KASUMI_F9 == (alg)) || \ (CPA_CY_SYM_HASH_SNOW3G_UIA2 == (alg)) || \ (CPA_CY_SYM_HASH_AES_XCBC == (alg)) || \ (CPA_CY_SYM_HASH_AES_CCM == (alg)) || \ (CPA_CY_SYM_HASH_AES_GCM == (alg)) || \ (CPA_CY_SYM_HASH_AES_GMAC == (alg)) || \ (CPA_CY_SYM_HASH_AES_CMAC == (alg)) || \ (CPA_CY_SYM_HASH_ZUC_EIA3 == (alg))) && \ (CPA_CY_SYM_HASH_MODE_AUTH != (mode))) || \ ((LAC_HASH_IS_SHA3(alg)) && (CPA_CY_SYM_HASH_MODE_NESTED == (mode)))) /**< Macro to check for valid algorithm-mode combination */ void LacSync_GenBufListVerifyCb(void *pCallbackTag, CpaStatus status, CpaCySymOp operationType, void *pOpData, CpaBufferList *pDstBuffer, CpaBoolean opResult); /** * @ingroup LacHash * This callback function will be invoked whenever a synchronous * hash precompute operation completes. It will set the wait * queue flag for the synchronous operation. * * @param[in] pCallbackTag Opaque value provided by user. This will * be a pointer to a wait queue flag. * * @retval * None * */ static void LacHash_SyncPrecomputeDoneCb(void *pCallbackTag) { LacSync_GenWakeupSyncCaller(pCallbackTag, CPA_STATUS_SUCCESS); } /** @ingroup LacHash */ CpaStatus LacHash_StatePrefixAadBufferInit( sal_service_t *pService, const CpaCySymHashSetupData *pHashSetupData, icp_qat_la_bulk_req_ftr_t *pReq, icp_qat_hw_auth_mode_t qatHashMode, Cpa8U *pHashStateBuffer, lac_sym_qat_hash_state_buffer_info_t *pHashStateBufferInfo) { /* set up the hash state prefix buffer info structure */ pHashStateBufferInfo->pData = pHashStateBuffer; pHashStateBufferInfo->pDataPhys = LAC_MEM_CAST_PTR_TO_UINT64( LAC_OS_VIRT_TO_PHYS_EXTERNAL((*pService), pHashStateBuffer)); if (pHashStateBufferInfo->pDataPhys == 0) { LAC_LOG_ERROR("Unable to get the physical address of " "the hash state buffer\n"); return CPA_STATUS_FAIL; } LacSymQat_HashStatePrefixAadBufferSizeGet(pReq, pHashStateBufferInfo); /* Prefix data gets copied to the hash state buffer for nested mode */ if (CPA_CY_SYM_HASH_MODE_NESTED == pHashSetupData->hashMode) { LacSymQat_HashStatePrefixAadBufferPopulate( pHashStateBufferInfo, pReq, pHashSetupData->nestedModeSetupData.pInnerPrefixData, (Cpa8U)pHashSetupData->nestedModeSetupData .innerPrefixLenInBytes, pHashSetupData->nestedModeSetupData.pOuterPrefixData, (Cpa8U)pHashSetupData->nestedModeSetupData .outerPrefixLenInBytes); } /* For mode2 HMAC the key gets copied into both the inner and * outer prefix fields */ else if (IS_HASH_MODE_2_AUTH(qatHashMode, pHashSetupData->hashMode)) { LacSymQat_HashStatePrefixAadBufferPopulate( pHashStateBufferInfo, pReq, pHashSetupData->authModeSetupData.authKey, (Cpa8U)pHashSetupData->authModeSetupData.authKeyLenInBytes, pHashSetupData->authModeSetupData.authKey, (Cpa8U)pHashSetupData->authModeSetupData.authKeyLenInBytes); } /* else do nothing for the other cases */ return CPA_STATUS_SUCCESS; } /** @ingroup LacHash */ CpaStatus LacHash_PrecomputeDataCreate(const CpaInstanceHandle instanceHandle, CpaCySymSessionSetupData *pSessionSetup, lac_hash_precompute_done_cb_t callbackFn, void *pCallbackTag, Cpa8U *pWorkingBuffer, Cpa8U *pState1, Cpa8U *pState2) { CpaStatus status = CPA_STATUS_SUCCESS; Cpa8U *pAuthKey = NULL; Cpa32U authKeyLenInBytes = 0; CpaCySymHashAlgorithm hashAlgorithm = pSessionSetup->hashSetupData.hashAlgorithm; CpaCySymHashAuthModeSetupData *pAuthModeSetupData = &pSessionSetup->hashSetupData.authModeSetupData; /* synchronous operation */ if (NULL == callbackFn) { lac_sync_op_data_t *pSyncCallbackData = NULL; status = LacSync_CreateSyncCookie(&pSyncCallbackData); if (CPA_STATUS_SUCCESS == status) { status = LacHash_PrecomputeDataCreate( instanceHandle, pSessionSetup, LacHash_SyncPrecomputeDoneCb, /* wait queue condition from sync cookie */ pSyncCallbackData, pWorkingBuffer, pState1, pState2); } else { return status; } if (CPA_STATUS_SUCCESS == status) { CpaStatus syncStatus = CPA_STATUS_SUCCESS; syncStatus = LacSync_WaitForCallback( pSyncCallbackData, LAC_SYM_SYNC_CALLBACK_TIMEOUT, &status, NULL); /* If callback doesn't come back */ if (CPA_STATUS_SUCCESS != syncStatus) { QAT_UTILS_LOG( "callback functions for precomputes did not return\n"); status = syncStatus; } } else { /* As the Request was not sent the Callback will never * be called, so need to indicate that we're finished * with cookie so it can be destroyed. */ LacSync_SetSyncCookieComplete(pSyncCallbackData); } LacSync_DestroySyncCookie(&pSyncCallbackData); return status; } /* set up convenience pointers */ pAuthKey = pAuthModeSetupData->authKey; authKeyLenInBytes = pAuthModeSetupData->authKeyLenInBytes; /* Pre-compute data state pointers must already be set up * by LacSymQat_HashSetupBlockInit() */ /* state1 is not allocated for AES XCBC/CCM/GCM/Kasumi/UIA2 * so for these algorithms set state2 only */ if (CPA_CY_SYM_HASH_AES_XCBC == hashAlgorithm) { status = LacSymHash_AesECBPreCompute(instanceHandle, hashAlgorithm, authKeyLenInBytes, pAuthKey, pWorkingBuffer, pState2, callbackFn, pCallbackTag); } else if (CPA_CY_SYM_HASH_AES_CMAC == hashAlgorithm) { /* First, copy the original key to pState2 */ memcpy(pState2, pAuthKey, authKeyLenInBytes); /* Then precompute */ status = LacSymHash_AesECBPreCompute(instanceHandle, hashAlgorithm, authKeyLenInBytes, pAuthKey, pWorkingBuffer, pState2, callbackFn, pCallbackTag); } else if (CPA_CY_SYM_HASH_AES_CCM == hashAlgorithm) { /* * The Inner Hash Initial State2 block is 32 bytes long. * Therefore, for keys bigger than 128 bits (16 bytes), * there is no space for 16 zeroes. */ if (pSessionSetup->cipherSetupData.cipherKeyLenInBytes == ICP_QAT_HW_AES_128_KEY_SZ) { /* * The Inner Hash Initial State2 block must contain K * (the cipher key) and 16 zeroes which will be replaced * with EK(Ctr0) by the QAT-ME. */ /* write the auth key which for CCM is equivalent to * cipher key */ memcpy( pState2, pSessionSetup->cipherSetupData.pCipherKey, pSessionSetup->cipherSetupData.cipherKeyLenInBytes); /* initialize remaining buffer space to all zeroes */ LAC_OS_BZERO(pState2 + pSessionSetup->cipherSetupData .cipherKeyLenInBytes, ICP_QAT_HW_AES_CCM_CBC_E_CTR0_SZ); } /* There is no request sent to the QAT for this operation, * so just invoke the user's callback directly to signal * completion of the precompute */ callbackFn(pCallbackTag); } else if (CPA_CY_SYM_HASH_AES_GCM == hashAlgorithm || CPA_CY_SYM_HASH_AES_GMAC == hashAlgorithm) { /* * The Inner Hash Initial State2 block contains the following * H (the Galois Hash Multiplier) * len(A) (the length of A), (length before padding) * 16 zeroes which will be replaced with EK(Ctr0) by the * QAT. */ /* Memset state2 to 0 */ LAC_OS_BZERO(pState2, ICP_QAT_HW_GALOIS_H_SZ + ICP_QAT_HW_GALOIS_LEN_A_SZ + ICP_QAT_HW_GALOIS_E_CTR0_SZ); /* write H (the Galois Hash Multiplier) where H = E(K, 0...0) * This will only write bytes 0-15 of pState2 */ status = LacSymHash_AesECBPreCompute( instanceHandle, hashAlgorithm, pSessionSetup->cipherSetupData.cipherKeyLenInBytes, pSessionSetup->cipherSetupData.pCipherKey, pWorkingBuffer, pState2, callbackFn, pCallbackTag); if (CPA_STATUS_SUCCESS == status) { /* write len(A) (the length of A) into bytes 16-19 of * pState2 in big-endian format. This field is 8 bytes */ *(Cpa32U *)&pState2[ICP_QAT_HW_GALOIS_H_SZ] = LAC_MEM_WR_32(pAuthModeSetupData->aadLenInBytes); } } else if (CPA_CY_SYM_HASH_KASUMI_F9 == hashAlgorithm) { Cpa32U wordIndex = 0; Cpa32U *pTempKey = (Cpa32U *)(pState2 + authKeyLenInBytes); /* * The Inner Hash Initial State2 block must contain IK * (Initialisation Key), followed by IK XOR-ed with KM * (Key Modifier): IK||(IK^KM). */ /* write the auth key */ memcpy(pState2, pAuthKey, authKeyLenInBytes); /* initialise temp key with auth key */ memcpy(pTempKey, pAuthKey, authKeyLenInBytes); /* XOR Key with KASUMI F9 key modifier at 4 bytes level */ for (wordIndex = 0; wordIndex < LAC_BYTES_TO_LONGWORDS(authKeyLenInBytes); wordIndex++) { pTempKey[wordIndex] ^= LAC_HASH_KASUMI_F9_KEY_MODIFIER_4_BYTES; } /* There is no request sent to the QAT for this operation, * so just invoke the user's callback directly to signal * completion of the precompute */ callbackFn(pCallbackTag); } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == hashAlgorithm) { /* * The Inner Hash Initial State2 should be all zeros */ LAC_OS_BZERO(pState2, ICP_QAT_HW_SNOW_3G_UIA2_STATE2_SZ); /* There is no request sent to the QAT for this operation, * so just invoke the user's callback directly to signal * completion of the precompute */ callbackFn(pCallbackTag); } else if (CPA_CY_SYM_HASH_ZUC_EIA3 == hashAlgorithm) { /* * The Inner Hash Initial State2 should contain the key * and zero the rest of the state. */ LAC_OS_BZERO(pState2, ICP_QAT_HW_ZUC_3G_EIA3_STATE2_SZ); memcpy(pState2, pAuthKey, authKeyLenInBytes); /* There is no request sent to the QAT for this operation, * so just invoke the user's callback directly to signal * completion of the precompute */ callbackFn(pCallbackTag); } else if (CPA_CY_SYM_HASH_POLY == hashAlgorithm) { /* There is no request sent to the QAT for this operation, * so just invoke the user's callback directly to signal * completion of the precompute */ callbackFn(pCallbackTag); } else /* For Hmac Precomputes */ { status = LacSymHash_HmacPreComputes(instanceHandle, hashAlgorithm, authKeyLenInBytes, pAuthKey, pWorkingBuffer, pState1, pState2, callbackFn, pCallbackTag); } return status; } - /** @ingroup LacHash */ CpaStatus LacHash_HashContextCheck(CpaInstanceHandle instanceHandle, const CpaCySymHashSetupData *pHashSetupData) { lac_sym_qat_hash_alg_info_t *pHashAlgInfo = NULL; lac_sym_qat_hash_alg_info_t *pOuterHashAlgInfo = NULL; CpaCySymCapabilitiesInfo capInfo; /*Protect against value of hash outside the bitmap*/ if (pHashSetupData->hashAlgorithm >= CPA_CY_SYM_HASH_CAP_BITMAP_SIZE) { LAC_INVALID_PARAM_LOG("hashAlgorithm"); return CPA_STATUS_INVALID_PARAM; } cpaCySymQueryCapabilities(instanceHandle, &capInfo); if (!CPA_BITMAP_BIT_TEST(capInfo.hashes, pHashSetupData->hashAlgorithm) && pHashSetupData->hashAlgorithm != CPA_CY_SYM_HASH_AES_CBC_MAC) { LAC_INVALID_PARAM_LOG("hashAlgorithm"); return CPA_STATUS_INVALID_PARAM; } switch (pHashSetupData->hashMode) { case CPA_CY_SYM_HASH_MODE_PLAIN: case CPA_CY_SYM_HASH_MODE_AUTH: case CPA_CY_SYM_HASH_MODE_NESTED: break; default: { LAC_INVALID_PARAM_LOG("hashMode"); return CPA_STATUS_INVALID_PARAM; } } if (LAC_HASH_ALG_MODE_NOT_SUPPORTED(pHashSetupData->hashAlgorithm, pHashSetupData->hashMode)) { LAC_UNSUPPORTED_PARAM_LOG( "hashAlgorithm and hashMode combination"); return CPA_STATUS_UNSUPPORTED; } LacSymQat_HashAlgLookupGet(instanceHandle, pHashSetupData->hashAlgorithm, &pHashAlgInfo); /* note: nested hash mode checks digest length against outer algorithm */ if ((CPA_CY_SYM_HASH_MODE_PLAIN == pHashSetupData->hashMode) || (CPA_CY_SYM_HASH_MODE_AUTH == pHashSetupData->hashMode)) { /* Check Digest Length is permitted by the algorithm */ if ((0 == pHashSetupData->digestResultLenInBytes) || (pHashSetupData->digestResultLenInBytes > pHashAlgInfo->digestLength)) { LAC_INVALID_PARAM_LOG("digestResultLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } if (CPA_CY_SYM_HASH_MODE_AUTH == pHashSetupData->hashMode) { if (CPA_CY_SYM_HASH_AES_GCM == pHashSetupData->hashAlgorithm || CPA_CY_SYM_HASH_AES_GMAC == pHashSetupData->hashAlgorithm) { Cpa32U aadDataSize = 0; /* RFC 4106: Implementations MUST support a full-length * 16-octet ICV, and MAY support 8 or 12 octet ICVs, and * MUST NOT support other ICV lengths. */ if ((pHashSetupData->digestResultLenInBytes != LAC_HASH_AES_GCM_ICV_SIZE_8) && (pHashSetupData->digestResultLenInBytes != LAC_HASH_AES_GCM_ICV_SIZE_12) && (pHashSetupData->digestResultLenInBytes != LAC_HASH_AES_GCM_ICV_SIZE_16)) { LAC_INVALID_PARAM_LOG("digestResultLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* ensure aadLen is within maximum limit imposed by QAT */ aadDataSize = pHashSetupData->authModeSetupData.aadLenInBytes; /* round the aad size to the multiple of GCM hash block * size. */ aadDataSize = LAC_ALIGN_POW2_ROUNDUP(aadDataSize, LAC_HASH_AES_GCM_BLOCK_SIZE); if (aadDataSize > ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX && CPA_CY_SYM_HASH_AES_GMAC != pHashSetupData->hashAlgorithm) { LAC_INVALID_PARAM_LOG("aadLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_AES_CCM == pHashSetupData->hashAlgorithm) { Cpa32U aadDataSize = 0; /* RFC 3610: Valid values are 4, 6, 8, 10, 12, 14, and * 16 octets */ if ((pHashSetupData->digestResultLenInBytes >= LAC_HASH_AES_CCM_ICV_SIZE_MIN) && (pHashSetupData->digestResultLenInBytes <= LAC_HASH_AES_CCM_ICV_SIZE_MAX)) { if ((pHashSetupData->digestResultLenInBytes & 0x01) != 0) { LAC_INVALID_PARAM_LOG( "digestResultLenInBytes must be a multiple of 2"); return CPA_STATUS_INVALID_PARAM; } } else { LAC_INVALID_PARAM_LOG("digestResultLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* ensure aadLen is within maximum limit imposed by QAT */ /* at the beginning of the buffer there is B0 block */ aadDataSize = LAC_HASH_AES_CCM_BLOCK_SIZE; /* then, if there is some 'a' data, the buffer will * store encoded length of 'a' and 'a' itself */ if (pHashSetupData->authModeSetupData.aadLenInBytes > 0) { /* as the QAT API puts the requirement on the * pAdditionalAuthData not to be bigger than 240 * bytes then we just need 2 bytes to store * encoded length of 'a' */ aadDataSize += sizeof(Cpa16U); aadDataSize += pHashSetupData->authModeSetupData .aadLenInBytes; } /* round the aad size to the multiple of CCM block * size.*/ aadDataSize = LAC_ALIGN_POW2_ROUNDUP(aadDataSize, LAC_HASH_AES_CCM_BLOCK_SIZE); if (aadDataSize > ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX) { LAC_INVALID_PARAM_LOG("aadLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_KASUMI_F9 == pHashSetupData->hashAlgorithm) { /* QAT-FW only supports 128 bit Integrity Key size for * Kasumi f9 * Ref: 3GPP TS 35.201 version 7.0.0 Release 7 */ if (pHashSetupData->authModeSetupData .authKeyLenInBytes != ICP_QAT_HW_KASUMI_KEY_SZ) { LAC_INVALID_PARAM_LOG("authKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_SNOW3G_UIA2 == pHashSetupData->hashAlgorithm) { /* QAT-FW only supports 128 bits Integrity Key size for * Snow3g */ if (pHashSetupData->authModeSetupData .authKeyLenInBytes != ICP_QAT_HW_SNOW_3G_UEA2_KEY_SZ) { LAC_INVALID_PARAM_LOG("authKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* For Snow3g hash aad field contains IV - it needs to * be 16 bytes long */ if (pHashSetupData->authModeSetupData.aadLenInBytes != ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ) { LAC_INVALID_PARAM_LOG("aadLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_AES_XCBC == pHashSetupData->hashAlgorithm || CPA_CY_SYM_HASH_AES_CMAC == pHashSetupData->hashAlgorithm || CPA_CY_SYM_HASH_AES_CBC_MAC == pHashSetupData->hashAlgorithm) { /* ensure auth key len is valid (128-bit keys supported) */ if ((pHashSetupData->authModeSetupData .authKeyLenInBytes != ICP_QAT_HW_AES_128_KEY_SZ)) { LAC_INVALID_PARAM_LOG("authKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_ZUC_EIA3 == pHashSetupData->hashAlgorithm) { /* QAT-FW only supports 128 bits Integrity Key size for * ZUC */ if (pHashSetupData->authModeSetupData .authKeyLenInBytes != ICP_QAT_HW_ZUC_3G_EEA3_KEY_SZ) { LAC_INVALID_PARAM_LOG("authKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } /* For ZUC EIA3 hash aad field contains IV - it needs to * be 16 bytes long */ if (pHashSetupData->authModeSetupData.aadLenInBytes != ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ) { LAC_INVALID_PARAM_LOG("aadLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } else if (CPA_CY_SYM_HASH_POLY == pHashSetupData->hashAlgorithm) { if (pHashSetupData->digestResultLenInBytes != ICP_QAT_HW_SPC_CTR_SZ) { LAC_INVALID_PARAM_LOG("Digest Length for CCP"); return CPA_STATUS_INVALID_PARAM; } if (pHashSetupData->authModeSetupData.aadLenInBytes > ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX) { LAC_INVALID_PARAM_LOG("AAD Length for CCP"); return CPA_STATUS_INVALID_PARAM; } } else { /* The key size must be less than or equal the block * length */ if (pHashSetupData->authModeSetupData .authKeyLenInBytes > pHashAlgInfo->blockLength) { LAC_INVALID_PARAM_LOG("authKeyLenInBytes"); return CPA_STATUS_INVALID_PARAM; } } /* when the key size is greater than 0 check pointer is not null */ if (CPA_CY_SYM_HASH_AES_CCM != pHashSetupData->hashAlgorithm && CPA_CY_SYM_HASH_AES_GCM != pHashSetupData->hashAlgorithm && pHashSetupData->authModeSetupData.authKeyLenInBytes > 0) { LAC_CHECK_NULL_PARAM( pHashSetupData->authModeSetupData.authKey); } } else if (CPA_CY_SYM_HASH_MODE_NESTED == pHashSetupData->hashMode) { if (!CPA_BITMAP_BIT_TEST(capInfo.hashes, pHashSetupData->nestedModeSetupData .outerHashAlgorithm)) { LAC_INVALID_PARAM_LOG("outerHashAlgorithm"); return CPA_STATUS_INVALID_PARAM; } if (LAC_HASH_ALG_MODE_NOT_SUPPORTED( pHashSetupData->nestedModeSetupData.outerHashAlgorithm, pHashSetupData->hashMode)) { LAC_INVALID_PARAM_LOG( "outerHashAlgorithm and hashMode combination"); return CPA_STATUS_INVALID_PARAM; } LacSymQat_HashAlgLookupGet( instanceHandle, pHashSetupData->nestedModeSetupData.outerHashAlgorithm, &pOuterHashAlgInfo); /* Check Digest Length is permitted by the algorithm */ if ((0 == pHashSetupData->digestResultLenInBytes) || (pHashSetupData->digestResultLenInBytes > pOuterHashAlgInfo->digestLength)) { LAC_INVALID_PARAM_LOG("digestResultLenInBytes"); return CPA_STATUS_INVALID_PARAM; } if (pHashSetupData->nestedModeSetupData.innerPrefixLenInBytes > LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES) { LAC_INVALID_PARAM_LOG("innerPrefixLenInBytes"); return CPA_STATUS_INVALID_PARAM; } if (pHashSetupData->nestedModeSetupData.innerPrefixLenInBytes > 0) { LAC_CHECK_NULL_PARAM(pHashSetupData->nestedModeSetupData .pInnerPrefixData); } if (pHashSetupData->nestedModeSetupData.outerPrefixLenInBytes > LAC_MAX_INNER_OUTER_PREFIX_SIZE_BYTES) { LAC_INVALID_PARAM_LOG("outerPrefixLenInBytes"); return CPA_STATUS_INVALID_PARAM; } if (pHashSetupData->nestedModeSetupData.outerPrefixLenInBytes > 0) { LAC_CHECK_NULL_PARAM(pHashSetupData->nestedModeSetupData .pOuterPrefixData); } } return CPA_STATUS_SUCCESS; } /** @ingroup LacHash */ CpaStatus LacHash_PerformParamCheck(CpaInstanceHandle instanceHandle, lac_session_desc_t *pSessionDesc, const CpaCySymOpData *pOpData, Cpa64U srcPktSize, const CpaBoolean *pVerifyResult) { CpaStatus status = CPA_STATUS_SUCCESS; lac_sym_qat_hash_alg_info_t *pHashAlgInfo = NULL; CpaBoolean digestIsAppended = pSessionDesc->digestIsAppended; CpaBoolean digestVerify = pSessionDesc->digestVerify; CpaCySymOp symOperation = pSessionDesc->symOperation; CpaCySymHashAlgorithm hashAlgorithm = pSessionDesc->hashAlgorithm; /* digestVerify and digestIsAppended on Hash-Only operation not * supported */ if (digestIsAppended && digestVerify && (CPA_CY_SYM_OP_HASH == symOperation)) { LAC_INVALID_PARAM_LOG( "digestVerify and digestIsAppended set " "on Hash-Only operation is not supported"); return CPA_STATUS_INVALID_PARAM; } /* check the digest result pointer */ if ((CPA_CY_SYM_PACKET_TYPE_PARTIAL != pOpData->packetType) && !digestIsAppended && (NULL == pOpData->pDigestResult)) { LAC_INVALID_PARAM_LOG("pDigestResult is NULL"); return CPA_STATUS_INVALID_PARAM; } /* * Check if the pVerifyResult pointer is not null for hash operation * when the packet is the last one and user has set verifyDigest flag * Also, this is only needed for symchronous operation, so check if the * callback pointer is the internal synchronous one rather than a user- * supplied one. */ if ((CPA_TRUE == digestVerify) && (CPA_CY_SYM_PACKET_TYPE_PARTIAL != pOpData->packetType) && (LacSync_GenBufListVerifyCb == pSessionDesc->pSymCb)) { if (NULL == pVerifyResult) { LAC_INVALID_PARAM_LOG( "Null pointer pVerifyResult for hash op"); return CPA_STATUS_INVALID_PARAM; } } /* verify start offset + messageLenToDigest is inside the source packet. * this also verifies that the start offset is inside the packet * Note: digest is specified as a pointer therefore it can be * written anywhere so we cannot check for this been inside a buffer * CCM/GCM specify the auth region using just the cipher params as this * region is the same for auth and cipher. It is not checked here */ if ((CPA_CY_SYM_HASH_AES_CCM == hashAlgorithm) || (CPA_CY_SYM_HASH_AES_GCM == hashAlgorithm)) { /* ensure AAD data pointer is non-NULL if AAD len > 0 */ if ((pSessionDesc->aadLenInBytes > 0) && (NULL == pOpData->pAdditionalAuthData)) { LAC_INVALID_PARAM_LOG("pAdditionalAuthData is NULL"); return CPA_STATUS_INVALID_PARAM; } } else { if ((pOpData->hashStartSrcOffsetInBytes + pOpData->messageLenToHashInBytes) > srcPktSize) { LAC_INVALID_PARAM_LOG( "hashStartSrcOffsetInBytes + " "messageLenToHashInBytes > Src Buffer Packet Length"); return CPA_STATUS_INVALID_PARAM; } } /* For Snow3g & ZUC hash pAdditionalAuthData field * of OpData should contain IV */ if ((CPA_CY_SYM_HASH_SNOW3G_UIA2 == hashAlgorithm) || (CPA_CY_SYM_HASH_ZUC_EIA3 == hashAlgorithm)) { if (NULL == pOpData->pAdditionalAuthData) { LAC_INVALID_PARAM_LOG("pAdditionalAuthData is NULL"); return CPA_STATUS_INVALID_PARAM; } } /* partial packets need to be multiples of the algorithm block size in * hash only mode (except for final partial packet) */ if ((CPA_CY_SYM_PACKET_TYPE_PARTIAL == pOpData->packetType) && (CPA_CY_SYM_OP_HASH == symOperation)) { LacSymQat_HashAlgLookupGet(instanceHandle, hashAlgorithm, &pHashAlgInfo); /* check if the message is a multiple of the block size. */ if ((pOpData->messageLenToHashInBytes % pHashAlgInfo->blockLength) != 0) { LAC_INVALID_PARAM_LOG( "messageLenToHashInBytes not block size"); return CPA_STATUS_INVALID_PARAM; } } return status; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash_sw_precomputes.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash_sw_precomputes.c index 05bbd3a52d6e..e29de6f1c729 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash_sw_precomputes.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_hash_sw_precomputes.c @@ -1,352 +1,352 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_hash_sw_precomputes.c * * @ingroup LacHashDefs * * Hash Software ***************************************************************************/ /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "cpa_cy_sym.h" #include "icp_accel_devices.h" #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_adf_debug.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "qat_utils.h" #include "lac_mem.h" #include "lac_sym.h" #include "lac_log.h" #include "lac_mem_pools.h" #include "lac_list.h" #include "lac_sym_hash_defs.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sal_types_crypto.h" #include "lac_sal.h" #include "lac_session.h" #include "lac_sym_hash_precomputes.h" static CpaStatus LacSymHash_Compute(CpaCySymHashAlgorithm hashAlgorithm, lac_sym_qat_hash_alg_info_t *pHashAlgInfo, Cpa8U *in, Cpa8U *out) { /* * Note: from SHA hashes appropriate endian swapping is required. * For sha1, sha224 and sha256 double words based swapping. * For sha384 and sha512 quad words swapping. - * No endianes swapping for md5 is required. + * No endianness swapping for md5 is required. */ CpaStatus status = CPA_STATUS_FAIL; Cpa32U i = 0; switch (hashAlgorithm) { case CPA_CY_SYM_HASH_MD5: if (CPA_STATUS_SUCCESS != qatUtilsHashMD5(in, out)) { LAC_LOG_ERROR("qatUtilsHashMD5 Failed\n"); return status; } status = CPA_STATUS_SUCCESS; break; case CPA_CY_SYM_HASH_SHA1: if (CPA_STATUS_SUCCESS != qatUtilsHashSHA1(in, out)) { LAC_LOG_ERROR("qatUtilsHashSHA1 Failed\n"); return status; } for (i = 0; i < LAC_BYTES_TO_LONGWORDS(pHashAlgInfo->stateSize); i++) { ((Cpa32U *)(out))[i] = LAC_MEM_WR_32(((Cpa32U *)(out))[i]); } status = CPA_STATUS_SUCCESS; break; case CPA_CY_SYM_HASH_SHA224: if (CPA_STATUS_SUCCESS != qatUtilsHashSHA224(in, out)) { LAC_LOG_ERROR("qatUtilsHashSHA224 Failed\n"); return status; } for (i = 0; i < LAC_BYTES_TO_LONGWORDS(pHashAlgInfo->stateSize); i++) { ((Cpa32U *)(out))[i] = LAC_MEM_WR_32(((Cpa32U *)(out))[i]); } status = CPA_STATUS_SUCCESS; break; case CPA_CY_SYM_HASH_SHA256: if (CPA_STATUS_SUCCESS != qatUtilsHashSHA256(in, out)) { LAC_LOG_ERROR("qatUtilsHashSHA256 Failed\n"); return status; } for (i = 0; i < LAC_BYTES_TO_LONGWORDS(pHashAlgInfo->stateSize); i++) { ((Cpa32U *)(out))[i] = LAC_MEM_WR_32(((Cpa32U *)(out))[i]); } status = CPA_STATUS_SUCCESS; break; case CPA_CY_SYM_HASH_SHA384: if (CPA_STATUS_SUCCESS != qatUtilsHashSHA384(in, out)) { LAC_LOG_ERROR("qatUtilsHashSHA384 Failed\n"); return status; } for (i = 0; i < LAC_BYTES_TO_QUADWORDS(pHashAlgInfo->stateSize); i++) { ((Cpa64U *)(out))[i] = LAC_MEM_WR_64(((Cpa64U *)(out))[i]); } status = CPA_STATUS_SUCCESS; break; case CPA_CY_SYM_HASH_SHA512: if (CPA_STATUS_SUCCESS != qatUtilsHashSHA512(in, out)) { LAC_LOG_ERROR("qatUtilsHashSHA512 Failed\n"); return status; } for (i = 0; i < LAC_BYTES_TO_QUADWORDS(pHashAlgInfo->stateSize); i++) { ((Cpa64U *)(out))[i] = LAC_MEM_WR_64(((Cpa64U *)(out))[i]); } status = CPA_STATUS_SUCCESS; break; default: return CPA_STATUS_INVALID_PARAM; } return status; } CpaStatus LacSymHash_HmacPreComputes(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, Cpa32U authKeyLenInBytes, Cpa8U *pAuthKey, Cpa8U *pWorkingMemory, Cpa8U *pState1, Cpa8U *pState2, lac_hash_precompute_done_cb_t callbackFn, void *pCallbackTag) { Cpa8U *pIpadData = NULL; Cpa8U *pOpadData = NULL; CpaStatus status = CPA_STATUS_FAIL; lac_sym_hash_precomp_op_data_t *pHmacIpadOpData = (lac_sym_hash_precomp_op_data_t *)pWorkingMemory; lac_sym_hash_precomp_op_data_t *pHmacOpadOpData = pHmacIpadOpData + 1; /* Convenience pointers */ lac_sym_hash_hmac_precomp_qat_t *pHmacIpadQatData = &pHmacIpadOpData->u.hmacQatData; lac_sym_hash_hmac_precomp_qat_t *pHmacOpadQatData = &pHmacOpadOpData->u.hmacQatData; lac_sym_qat_hash_alg_info_t *pHashAlgInfo = NULL; Cpa32U i = 0; Cpa32U padLenBytes = 0; LacSymQat_HashAlgLookupGet(instanceHandle, hashAlgorithm, &pHashAlgInfo); pHmacIpadOpData->stateSize = pHashAlgInfo->stateSize; pHmacOpadOpData->stateSize = pHashAlgInfo->stateSize; /* Copy HMAC key into buffers */ if (authKeyLenInBytes > 0) { memcpy(pHmacIpadQatData->data, pAuthKey, authKeyLenInBytes); memcpy(pHmacOpadQatData->data, pAuthKey, authKeyLenInBytes); } padLenBytes = pHashAlgInfo->blockLength - authKeyLenInBytes; /* Clear the remaining buffer space */ if (padLenBytes > 0) { LAC_OS_BZERO(pHmacIpadQatData->data + authKeyLenInBytes, padLenBytes); LAC_OS_BZERO(pHmacOpadQatData->data + authKeyLenInBytes, padLenBytes); } /* XOR Key with IPAD at 4-byte level */ for (i = 0; i < pHashAlgInfo->blockLength; i++) { Cpa8U *ipad = pHmacIpadQatData->data + i; Cpa8U *opad = pHmacOpadQatData->data + i; *ipad ^= LAC_HASH_IPAD_BYTE; *opad ^= LAC_HASH_OPAD_BYTE; } pIpadData = (Cpa8U *)pHmacIpadQatData->data; pOpadData = (Cpa8U *)pHmacOpadQatData->data; status = LacSymHash_Compute(hashAlgorithm, pHashAlgInfo, (Cpa8U *)pIpadData, pState1); if (CPA_STATUS_SUCCESS == status) { status = LacSymHash_Compute(hashAlgorithm, pHashAlgInfo, (Cpa8U *)pOpadData, pState2); } if (CPA_STATUS_SUCCESS == status) { callbackFn(pCallbackTag); } return status; } CpaStatus LacSymHash_AesECBPreCompute(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, Cpa32U authKeyLenInBytes, Cpa8U *pAuthKey, Cpa8U *pWorkingMemory, Cpa8U *pState, lac_hash_precompute_done_cb_t callbackFn, void *pCallbackTag) { CpaStatus status = CPA_STATUS_FAIL; Cpa32U stateSize = 0, x = 0; lac_sym_qat_hash_alg_info_t *pHashAlgInfo = NULL; if (CPA_CY_SYM_HASH_AES_XCBC == hashAlgorithm) { Cpa8U *in = pWorkingMemory; Cpa8U *out = pState; LacSymQat_HashAlgLookupGet(instanceHandle, hashAlgorithm, &pHashAlgInfo); stateSize = pHashAlgInfo->stateSize; memcpy(pWorkingMemory, pHashAlgInfo->initState, stateSize); for (x = 0; x < LAC_HASH_XCBC_PRECOMP_KEY_NUM; x++) { if (CPA_STATUS_SUCCESS != qatUtilsAESEncrypt( pAuthKey, authKeyLenInBytes, in, out)) { return status; } in += LAC_HASH_XCBC_MAC_BLOCK_SIZE; out += LAC_HASH_XCBC_MAC_BLOCK_SIZE; } status = CPA_STATUS_SUCCESS; } else if (CPA_CY_SYM_HASH_AES_CMAC == hashAlgorithm) { Cpa8U *out = pState; Cpa8U k1[LAC_HASH_CMAC_BLOCK_SIZE], k2[LAC_HASH_CMAC_BLOCK_SIZE]; Cpa8U *ptr = NULL, i = 0; stateSize = LAC_HASH_CMAC_BLOCK_SIZE; LacSymQat_HashAlgLookupGet(instanceHandle, hashAlgorithm, &pHashAlgInfo); /* Original state size includes K, K1 and K2 which are of equal * length. * For precompute state size is only of the length of K which is * equal * to the block size for CPA_CY_SYM_HASH_AES_CMAC. * The algorithm is described in rfc4493 * K is just copeid, K1 and K2 need to be single inplace encrypt * with AES. * */ memcpy(out, pHashAlgInfo->initState, stateSize); memcpy(out, pAuthKey, authKeyLenInBytes); out += LAC_HASH_CMAC_BLOCK_SIZE; for (x = 0; x < LAC_HASH_XCBC_PRECOMP_KEY_NUM - 1; x++) { if (CPA_STATUS_SUCCESS != qatUtilsAESEncrypt( pAuthKey, authKeyLenInBytes, out, out)) { return status; } out += LAC_HASH_CMAC_BLOCK_SIZE; } ptr = pState + LAC_HASH_CMAC_BLOCK_SIZE; /* Derived keys (k1 and k2), copy them to * pPrecompOpData->pState, * but remember that at the beginning is original key (K0) */ /* Calculating K1 */ for (i = 0; i < LAC_HASH_CMAC_BLOCK_SIZE; i++, ptr++) { k1[i] = (*ptr) << 1; if (i != 0) { k1[i - 1] |= (*ptr) >> (LAC_NUM_BITS_IN_BYTE - 1); } if (i + 1 == LAC_HASH_CMAC_BLOCK_SIZE) { /* If msb of pState + LAC_HASH_CMAC_BLOCK_SIZE is set xor with RB. Because only the final byte of RB is non-zero this is all we need to xor */ if ((*(pState + LAC_HASH_CMAC_BLOCK_SIZE)) & LAC_SYM_HASH_MSBIT_MASK) { k1[i] ^= LAC_SYM_AES_CMAC_RB_128; } } } /* Calculating K2 */ for (i = 0; i < LAC_HASH_CMAC_BLOCK_SIZE; i++) { k2[i] = (k1[i]) << 1; if (i != 0) { k2[i - 1] |= (k1[i]) >> (LAC_NUM_BITS_IN_BYTE - 1); } if (i + 1 == LAC_HASH_CMAC_BLOCK_SIZE) { /* If msb of k1 is set xor last byte with RB */ if (k1[0] & LAC_SYM_HASH_MSBIT_MASK) { k2[i] ^= LAC_SYM_AES_CMAC_RB_128; } } } /* Now, when we have K1 & K2 lets copy them to the state2 */ ptr = pState + LAC_HASH_CMAC_BLOCK_SIZE; memcpy(ptr, k1, LAC_HASH_CMAC_BLOCK_SIZE); ptr += LAC_HASH_CMAC_BLOCK_SIZE; memcpy(ptr, k2, LAC_HASH_CMAC_BLOCK_SIZE); status = CPA_STATUS_SUCCESS; } else if (CPA_CY_SYM_HASH_AES_GCM == hashAlgorithm || CPA_CY_SYM_HASH_AES_GMAC == hashAlgorithm) { Cpa8U *in = pWorkingMemory; Cpa8U *out = pState; LAC_OS_BZERO(pWorkingMemory, ICP_QAT_HW_GALOIS_H_SZ); if (CPA_STATUS_SUCCESS != qatUtilsAESEncrypt(pAuthKey, authKeyLenInBytes, in, out)) { return status; } status = CPA_STATUS_SUCCESS; } else { return CPA_STATUS_INVALID_PARAM; } callbackFn(pCallbackTag); return status; } CpaStatus LacSymHash_HmacPrecompInit(CpaInstanceHandle instanceHandle) { CpaStatus status = CPA_STATUS_SUCCESS; return status; } void LacSymHash_HmacPrecompShutdown(CpaInstanceHandle instanceHandle) { return; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_queue.c b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_queue.c index a840882acaf9..5c76d5d81324 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_queue.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/lac_sym_queue.c @@ -1,157 +1,157 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_queue.c Functions for sending/queuing symmetric requests * * @ingroup LacSym * ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "cpa_cy_sym.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "icp_accel_devices.h" #include "icp_adf_init.h" #include "icp_adf_debug.h" #include "icp_adf_transport.h" #include "lac_sym_queue.h" #include "lac_sym_qat.h" #include "lac_session.h" #include "lac_sym.h" #include "lac_log.h" #include "icp_qat_fw_la.h" #include "lac_sal_types_crypto.h" #define GetSingleBitFromByte(byte, bit) ((byte) & (1 << (bit))) /* ******************************************************************************* * Define public/global function definitions ******************************************************************************* */ CpaStatus LacSymQueue_RequestSend(const CpaInstanceHandle instanceHandle, lac_sym_bulk_cookie_t *pRequest, lac_session_desc_t *pSessionDesc) { CpaStatus status = CPA_STATUS_SUCCESS; CpaBoolean enqueued = CPA_FALSE; sal_crypto_service_t *pService = (sal_crypto_service_t *)instanceHandle; /* Enqueue the message instead of sending directly if: * (i) a blocking operation is in progress * (ii) there are previous requests already in the queue */ if ((CPA_FALSE == pSessionDesc->nonBlockingOpsInProgress) || (NULL != pSessionDesc->pRequestQueueTail)) { LAC_SPINLOCK(&pSessionDesc->requestQueueLock); /* Re-check blockingOpsInProgress and pRequestQueueTail in case * either * changed before the lock was acquired. The lock is shared * with * the callback context which drains this queue */ if ((CPA_FALSE == pSessionDesc->nonBlockingOpsInProgress) || (NULL != pSessionDesc->pRequestQueueTail)) { /* Enqueue the message and exit */ /* The FIFO queue is made up of a head and tail pointer. * The head pointer points to the first/oldest, entry * in the queue, and the tail pointer points to the * last/newest * entry in the queue */ if (NULL != pSessionDesc->pRequestQueueTail) { /* Queue is non-empty. Add this request to the * list */ pSessionDesc->pRequestQueueTail->pNext = pRequest; } else { /* Queue is empty. Initialise the head pointer * as well */ pSessionDesc->pRequestQueueHead = pRequest; } pSessionDesc->pRequestQueueTail = pRequest; /* request is queued, don't send to QAT here */ enqueued = CPA_TRUE; } LAC_SPINUNLOCK(&pSessionDesc->requestQueueLock); } if (CPA_FALSE == enqueued) { /* If we send a partial packet request, set the * blockingOpsInProgress * flag for the session to indicate that subsequent requests * must be * queued up until this request completes * * @assumption * If we have got here it means that there were no previous * blocking * operations in progress and, since multiple partial packet * requests * on a given session cannot be issued concurrently, there * should be * no need for a critical section around the following code */ if (CPA_CY_SYM_PACKET_TYPE_FULL != pRequest->pOpData->packetType) { - /* Select blocking operations which this reqest will + /* Select blocking operations which this request will * complete */ pSessionDesc->nonBlockingOpsInProgress = CPA_FALSE; } /* At this point, we're clear to send the request. For cipher * requests, * we need to check if the session IV needs to be updated. This * can * only be done when no other partials are in flight for this * session, * to ensure the cipherPartialOpState buffer in the session * descriptor * is not currently in use */ if (CPA_TRUE == pRequest->updateSessionIvOnSend) { if (LAC_CIPHER_IS_ARC4(pSessionDesc->cipherAlgorithm)) { memcpy(pSessionDesc->cipherPartialOpState, pSessionDesc->cipherARC4InitialState, LAC_CIPHER_ARC4_STATE_LEN_BYTES); } else { memcpy(pSessionDesc->cipherPartialOpState, pRequest->pOpData->pIv, pRequest->pOpData->ivLenInBytes); } } /* Send to QAT */ status = icp_adf_transPutMsg(pService->trans_handle_sym_tx, (void *)&(pRequest->qatMsg), LAC_QAT_SYM_REQ_SZ_LW); /* if fail to send request, we need to change * nonBlockingOpsInProgress * to CPA_TRUE */ if ((CPA_STATUS_SUCCESS != status) && (CPA_CY_SYM_PACKET_TYPE_FULL != pRequest->pOpData->packetType)) { pSessionDesc->nonBlockingOpsInProgress = CPA_TRUE; } } return status; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat.c b/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat.c index 6b436edf16cd..7735d07bc620 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat.c @@ -1,331 +1,331 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sym_qat.c Interfaces for populating the symmetric qat structures * * @ingroup LacSymQat * *****************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "icp_accel_devices.h" #include "icp_adf_cfg.h" #include "lac_log.h" #include "lac_sym.h" #include "lac_sym_qat.h" #include "lac_sal_types_crypto.h" #include "sal_string_parse.h" #include "lac_sym_key.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sym_qat_constants_table.h" #include "lac_sym_qat_cipher.h" #include "lac_sym_qat_hash.h" #define EMBEDDED_CIPHER_KEY_MAX_SIZE 16 static void LacSymQat_SymLogSliceHangError(icp_qat_fw_la_cmd_id_t symCmdId) { Cpa8U cmdId = symCmdId; switch (cmdId) { case ICP_QAT_FW_LA_CMD_CIPHER: case ICP_QAT_FW_LA_CMD_CIPHER_PRE_COMP: LAC_LOG_ERROR("slice hang detected on CPM cipher slice."); break; case ICP_QAT_FW_LA_CMD_AUTH: case ICP_QAT_FW_LA_CMD_AUTH_PRE_COMP: LAC_LOG_ERROR("slice hang detected on CPM auth slice."); break; case ICP_QAT_FW_LA_CMD_CIPHER_HASH: case ICP_QAT_FW_LA_CMD_HASH_CIPHER: case ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE: case ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE: case ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE: case ICP_QAT_FW_LA_CMD_MGF1: default: LAC_LOG_ERROR( "slice hang detected on CPM cipher or auth slice."); } return; } /* sym crypto response handlers */ static sal_qat_resp_handler_func_t respHandlerSymTbl[ICP_QAT_FW_LA_CMD_DELIMITER]; void LacSymQat_SymRespHandler(void *pRespMsg) { Cpa8U lacCmdId = 0; void *pOpaqueData = NULL; icp_qat_fw_la_resp_t *pRespMsgFn = NULL; Cpa8U opStatus = ICP_QAT_FW_COMN_STATUS_FLAG_OK; Cpa8U comnErr = ERR_CODE_NO_ERROR; pRespMsgFn = (icp_qat_fw_la_resp_t *)pRespMsg; LAC_MEM_SHARED_READ_TO_PTR(pRespMsgFn->opaque_data, pOpaqueData); lacCmdId = pRespMsgFn->comn_resp.cmd_id; opStatus = pRespMsgFn->comn_resp.comn_status; comnErr = pRespMsgFn->comn_resp.comn_error.s.comn_err_code; /* log the slice hang and endpoint push/pull error inside the response */ if (ERR_CODE_SSM_ERROR == (Cpa8S)comnErr) { LacSymQat_SymLogSliceHangError(lacCmdId); } else if (ERR_CODE_ENDPOINT_ERROR == (Cpa8S)comnErr) { LAC_LOG_ERROR("The PCIe End Point Push/Pull or" " TI/RI Parity error detected."); } /* call the response message handler registered for the command ID */ respHandlerSymTbl[lacCmdId]((icp_qat_fw_la_cmd_id_t)lacCmdId, pOpaqueData, (icp_qat_fw_comn_flags)opStatus); } CpaStatus LacSymQat_Init(CpaInstanceHandle instanceHandle) { CpaStatus status = CPA_STATUS_SUCCESS; /* Initialize the SHRAM constants table */ LacSymQat_ConstantsInitLookupTables(instanceHandle); /* Initialise the Hash lookup table */ status = LacSymQat_HashLookupInit(instanceHandle); return status; } void LacSymQat_RespHandlerRegister(icp_qat_fw_la_cmd_id_t lacCmdId, sal_qat_resp_handler_func_t pCbHandler) { if (lacCmdId >= ICP_QAT_FW_LA_CMD_DELIMITER) { QAT_UTILS_LOG("Invalid Command ID\n"); return; } /* set the response handler for the command ID */ respHandlerSymTbl[lacCmdId] = pCbHandler; } void LacSymQat_LaPacketCommandFlagSet(Cpa32U qatPacketType, icp_qat_fw_la_cmd_id_t laCmdId, CpaCySymCipherAlgorithm cipherAlgorithm, Cpa16U *pLaCommandFlags, Cpa32U ivLenInBytes) { /* For SM4/Chacha ciphers set command flag as partial none to proceed * with stateless processing */ if (LAC_CIPHER_IS_SM4(cipherAlgorithm) || LAC_CIPHER_IS_CHACHA(cipherAlgorithm)) { ICP_QAT_FW_LA_PARTIAL_SET(*pLaCommandFlags, ICP_QAT_FW_LA_PARTIAL_NONE); return; } ICP_QAT_FW_LA_PARTIAL_SET(*pLaCommandFlags, qatPacketType); /* For ECB-mode ciphers, IV is NULL so update-state flag * must be disabled always. * For all other ciphers and auth * update state is disabled for full packets and final partials */ if ((ICP_QAT_FW_LA_PARTIAL_NONE == qatPacketType) || (ICP_QAT_FW_LA_PARTIAL_END == qatPacketType) || ((laCmdId != ICP_QAT_FW_LA_CMD_AUTH) && LAC_CIPHER_IS_ECB_MODE(cipherAlgorithm))) { ICP_QAT_FW_LA_UPDATE_STATE_SET(*pLaCommandFlags, ICP_QAT_FW_LA_NO_UPDATE_STATE); } /* For first or middle partials set the update state command flag */ else { ICP_QAT_FW_LA_UPDATE_STATE_SET(*pLaCommandFlags, ICP_QAT_FW_LA_UPDATE_STATE); if (laCmdId == ICP_QAT_FW_LA_CMD_AUTH) { /* For hash only partial - verify and return auth result * are * disabled */ ICP_QAT_FW_LA_RET_AUTH_SET( *pLaCommandFlags, ICP_QAT_FW_LA_NO_RET_AUTH_RES); ICP_QAT_FW_LA_CMP_AUTH_SET( *pLaCommandFlags, ICP_QAT_FW_LA_NO_CMP_AUTH_RES); } } if ((LAC_CIPHER_IS_GCM(cipherAlgorithm)) && (LAC_CIPHER_IV_SIZE_GCM_12 == ivLenInBytes)) { ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET( *pLaCommandFlags, ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS); } } void LacSymQat_packetTypeGet(CpaCySymPacketType packetType, CpaCySymPacketType packetState, Cpa32U *pQatPacketType) { switch (packetType) { /* partial */ case CPA_CY_SYM_PACKET_TYPE_PARTIAL: /* if the previous state was full, then this is the first packet */ if (CPA_CY_SYM_PACKET_TYPE_FULL == packetState) { *pQatPacketType = ICP_QAT_FW_LA_PARTIAL_START; } else { *pQatPacketType = ICP_QAT_FW_LA_PARTIAL_MID; } break; /* final partial */ case CPA_CY_SYM_PACKET_TYPE_LAST_PARTIAL: *pQatPacketType = ICP_QAT_FW_LA_PARTIAL_END; break; /* full packet - CPA_CY_SYM_PACKET_TYPE_FULL */ default: *pQatPacketType = ICP_QAT_FW_LA_PARTIAL_NONE; } } void LacSymQat_LaSetDefaultFlags(icp_qat_fw_serv_specif_flags *laCmdFlags, CpaCySymOp symOp) { ICP_QAT_FW_LA_PARTIAL_SET(*laCmdFlags, ICP_QAT_FW_LA_PARTIAL_NONE); ICP_QAT_FW_LA_UPDATE_STATE_SET(*laCmdFlags, ICP_QAT_FW_LA_NO_UPDATE_STATE); if (symOp != CPA_CY_SYM_OP_CIPHER) { ICP_QAT_FW_LA_RET_AUTH_SET(*laCmdFlags, ICP_QAT_FW_LA_RET_AUTH_RES); } else { ICP_QAT_FW_LA_RET_AUTH_SET(*laCmdFlags, ICP_QAT_FW_LA_NO_RET_AUTH_RES); } ICP_QAT_FW_LA_CMP_AUTH_SET(*laCmdFlags, ICP_QAT_FW_LA_NO_CMP_AUTH_RES); ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET( *laCmdFlags, ICP_QAT_FW_LA_GCM_IV_LEN_NOT_12_OCTETS); } CpaBoolean LacSymQat_UseSymConstantsTable(lac_session_desc_t *pSession, Cpa8U *pCipherOffset, Cpa8U *pHashOffset) { CpaBoolean useOptimisedContentDesc = CPA_FALSE; CpaBoolean useSHRAMConstants = CPA_FALSE; *pCipherOffset = 0; *pHashOffset = 0; - /* for chaining can we use the optimised content descritor */ + /* for chaining can we use the optimised content descriptor */ if (pSession->laCmdId == ICP_QAT_FW_LA_CMD_CIPHER_HASH || pSession->laCmdId == ICP_QAT_FW_LA_CMD_HASH_CIPHER) { useOptimisedContentDesc = LacSymQat_UseOptimisedContentDesc(pSession); } /* Cipher-only case or chaining */ if (pSession->laCmdId == ICP_QAT_FW_LA_CMD_CIPHER || useOptimisedContentDesc) { icp_qat_hw_cipher_algo_t algorithm; icp_qat_hw_cipher_mode_t mode; icp_qat_hw_cipher_dir_t dir; icp_qat_hw_cipher_convert_t key_convert; if (pSession->cipherKeyLenInBytes > sizeof(icp_qat_fw_comn_req_hdr_cd_pars_t)) { return CPA_FALSE; } LacSymQat_CipherGetCfgData( pSession, &algorithm, &mode, &dir, &key_convert); /* Check if cipher config is available in table. */ LacSymQat_ConstantsGetCipherOffset(pSession->pInstance, algorithm, mode, dir, key_convert, pCipherOffset); if (*pCipherOffset > 0) { useSHRAMConstants = CPA_TRUE; } else { useSHRAMConstants = CPA_FALSE; } } /* hash only case or when chaining, cipher must be found in SHRAM table * for * optimised CD case */ if (pSession->laCmdId == ICP_QAT_FW_LA_CMD_AUTH || (useOptimisedContentDesc && useSHRAMConstants)) { icp_qat_hw_auth_algo_t algorithm; CpaBoolean nested; if (pSession->digestVerify) { return CPA_FALSE; } if ((!(useOptimisedContentDesc && useSHRAMConstants)) && (pSession->qatHashMode == ICP_QAT_HW_AUTH_MODE1)) { /* we can only use the SHA1-mode1 in the SHRAM constants * table when - * we are using the opimised content desc */ + * we are using the optimised content desc */ return CPA_FALSE; } LacSymQat_HashGetCfgData(pSession->pInstance, pSession->qatHashMode, pSession->hashMode, pSession->hashAlgorithm, &algorithm, &nested); /* Check if config data is available in table. */ LacSymQat_ConstantsGetAuthOffset(pSession->pInstance, algorithm, pSession->qatHashMode, nested, pHashOffset); if (*pHashOffset > 0) { useSHRAMConstants = CPA_TRUE; } else { useSHRAMConstants = CPA_FALSE; } } return useSHRAMConstants; } CpaBoolean LacSymQat_UseOptimisedContentDesc(lac_session_desc_t *pSession) { return CPA_FALSE; } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_cipher.c b/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_cipher.c index 4900cf7996aa..c6fbeb1b888a 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_cipher.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_cipher.c @@ -1,1009 +1,1008 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_qat_cipher.c QAT-related support functions for Cipher * * @ingroup LacSymQat_Cipher * * @description Functions to support the QAT related operations for Cipher ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "lac_sym_qat.h" #include "lac_sym_qat_cipher.h" #include "lac_mem.h" #include "lac_common.h" #include "cpa_cy_sym.h" #include "lac_sym_qat.h" #include "lac_sym_cipher_defs.h" #include "icp_qat_hw.h" #include "icp_qat_fw_la.h" #include "sal_hw_gen.h" #define LAC_UNUSED_POS_MASK 0x3 /***************************************************************************** * Internal data *****************************************************************************/ typedef enum _icp_qat_hw_key_depend { IS_KEY_DEP_NO = 0, IS_KEY_DEP_YES, } icp_qat_hw_key_depend; /* LAC_CIPHER_IS_XTS_MODE */ static const uint8_t key_size_xts[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES128, /* ICP_QAT_HW_AES_128_XTS_KEY_SZ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES256 /* ICP_QAT_HW_AES_256_XTS_KEY_SZ */ }; /* LAC_CIPHER_IS_AES */ static const uint8_t key_size_aes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES128, /* ICP_QAT_HW_AES_128_KEY_SZ */ 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES192, /* ICP_QAT_HW_AES_192_KEY_SZ */ 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES256 /* ICP_QAT_HW_AES_256_KEY_SZ */ }; /* LAC_CIPHER_IS_AES_F8 */ static const uint8_t key_size_f8[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES128, /* ICP_QAT_HW_AES_128_F8_KEY_SZ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES192, /* ICP_QAT_HW_AES_192_F8_KEY_SZ */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ICP_QAT_HW_CIPHER_ALGO_AES256 /* ICP_QAT_HW_AES_256_F8_KEY_SZ */ }; typedef struct _icp_qat_hw_cipher_info { icp_qat_hw_cipher_algo_t algorithm; icp_qat_hw_cipher_mode_t mode; icp_qat_hw_cipher_convert_t key_convert[2]; icp_qat_hw_cipher_dir_t dir[2]; icp_qat_hw_key_depend isKeyLenDepend; const uint8_t *pAlgByKeySize; } icp_qat_hw_cipher_info; static const icp_qat_hw_cipher_info icp_qat_alg_info[] = { /* CPA_CY_SYM_CIPHER_NULL */ { ICP_QAT_HW_CIPHER_ALGO_NULL, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_ARC4 */ { ICP_QAT_HW_CIPHER_ALGO_ARC4, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_AES_ECB */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_ECB_MODE, /* AES decrypt key needs to be reversed. Instead of reversing the * key at session registration, it is instead reversed on-the-fly by * setting the KEY_CONVERT bit here */ { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_YES, key_size_aes, }, /* CPA_CY_SYM_CIPHER_AES_CBC */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_CBC_MODE, /* AES decrypt key needs to be reversed. Instead of reversing the * key at session registration, it is instead reversed on-the-fly by * setting the KEY_CONVERT bit here */ { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_YES, key_size_aes, }, /* CPA_CY_SYM_CIPHER_AES_CTR */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_CTR_MODE, /* AES decrypt key needs to be reversed. Instead of reversing the * key at session registration, it is instead reversed on-the-fly by * setting the KEY_CONVERT bit here */ { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt * Overriding default values previously set for AES */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_YES, key_size_aes, }, /* CPA_CY_SYM_CIPHER_AES_CCM */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_CTR_MODE, /* AES decrypt key needs to be reversed. Instead of reversing the * key at session registration, it is instead reversed on-the-fly by * setting the KEY_CONVERT bit here */ { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt * Overriding default values previously set for AES */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_YES, key_size_aes, }, /* CPA_CY_SYM_CIPHER_AES_GCM */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_CTR_MODE, /* AES decrypt key needs to be reversed. Instead of reversing the * key at session registration, it is instead reversed on-the-fly by * setting the KEY_CONVERT bit here */ { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt * Overriding default values previously set for AES */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_YES, key_size_aes, }, /* CPA_CY_SYM_CIPHER_DES_ECB */ { ICP_QAT_HW_CIPHER_ALGO_DES, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_DES_CBC */ { ICP_QAT_HW_CIPHER_ALGO_DES, ICP_QAT_HW_CIPHER_CBC_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_3DES_ECB */ { ICP_QAT_HW_CIPHER_ALGO_3DES, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_3DES_CBC */ { ICP_QAT_HW_CIPHER_ALGO_3DES, ICP_QAT_HW_CIPHER_CBC_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_3DES_CTR */ { ICP_QAT_HW_CIPHER_ALGO_3DES, ICP_QAT_HW_CIPHER_CTR_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt * Overriding default values previously set for AES */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_KASUMI_F8 */ { ICP_QAT_HW_CIPHER_ALGO_KASUMI, ICP_QAT_HW_CIPHER_F8_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_SNOW3G_UEA2 */ { /* The KEY_CONVERT bit has to be set for Snow_3G operation */ ICP_QAT_HW_CIPHER_ALGO_SNOW_3G_UEA2, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_KEY_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_AES_F8 */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_F8_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, /* Streaming ciphers are a special case. Decrypt = encrypt */ { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_YES, key_size_f8, }, /* CPA_CY_SYM_CIPHER_AES_XTS */ { ICP_QAT_HW_CIPHER_ALGO_AES128, ICP_QAT_HW_CIPHER_XTS_MODE, /* AES decrypt key needs to be reversed. Instead of reversing the * key at session registration, it is instead reversed on-the-fly by * setting the KEY_CONVERT bit here */ { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_YES, key_size_xts, }, /* CPA_CY_SYM_CIPHER_ZUC_EEA3 */ { ICP_QAT_HW_CIPHER_ALGO_ZUC_3G_128_EEA3, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_KEY_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_CHACHA */ { ICP_QAT_HW_CIPHER_ALGO_CHACHA20_POLY1305, ICP_QAT_HW_CIPHER_CTR_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_SM4_ECB */ { ICP_QAT_HW_CIPHER_ALGO_SM4, ICP_QAT_HW_CIPHER_ECB_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_SM4_CBC */ { ICP_QAT_HW_CIPHER_ALGO_SM4, ICP_QAT_HW_CIPHER_CBC_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_KEY_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_DECRYPT }, IS_KEY_DEP_NO, NULL, }, /* CPA_CY_SYM_CIPHER_SM4_CTR */ { ICP_QAT_HW_CIPHER_ALGO_SM4, ICP_QAT_HW_CIPHER_CTR_MODE, { ICP_QAT_HW_CIPHER_NO_CONVERT, ICP_QAT_HW_CIPHER_NO_CONVERT }, { ICP_QAT_HW_CIPHER_ENCRYPT, ICP_QAT_HW_CIPHER_ENCRYPT }, IS_KEY_DEP_NO, NULL, }, }; /***************************************************************************** * Internal functions *****************************************************************************/ void LacSymQat_CipherCtrlBlockWrite(icp_qat_la_bulk_req_ftr_t *pMsg, Cpa32U cipherAlgorithm, Cpa32U targetKeyLenInBytes, Cpa32U sliceType, icp_qat_fw_slice_t nextSlice, Cpa8U cipherCfgOffsetInQuadWord) { icp_qat_fw_cipher_cd_ctrl_hdr_t *cd_ctrl = (icp_qat_fw_cipher_cd_ctrl_hdr_t *)&(pMsg->cd_ctrl); /* state_padding_sz is nonzero for f8 mode only */ cd_ctrl->cipher_padding_sz = 0; /* Special handling of AES 192 key for UCS slice. UCS requires it to have 32 bytes - set is as targetKeyLen in this case, and add padding. It makes no sense to force applications to provide such key length for couple reasons: 1. It won't be possible to distinguish between AES 192 and 256 based - on key lenght only + on key length only 2. Only some modes of AES will use UCS slice, then application will have to know which ones */ if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == sliceType && ICP_QAT_HW_AES_192_KEY_SZ == targetKeyLenInBytes) { targetKeyLenInBytes = ICP_QAT_HW_UCS_AES_192_KEY_SZ; } switch (cipherAlgorithm) { /* Base Key is not passed down to QAT in the case of ARC4 or NULL */ case CPA_CY_SYM_CIPHER_ARC4: case CPA_CY_SYM_CIPHER_NULL: cd_ctrl->cipher_key_sz = 0; break; case CPA_CY_SYM_CIPHER_KASUMI_F8: cd_ctrl->cipher_key_sz = LAC_BYTES_TO_QUADWORDS(ICP_QAT_HW_KASUMI_F8_KEY_SZ); cd_ctrl->cipher_padding_sz = ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR; break; /* For Snow3G UEA2 content descriptor key size is key size plus iv size */ case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: cd_ctrl->cipher_key_sz = LAC_BYTES_TO_QUADWORDS(ICP_QAT_HW_SNOW_3G_UEA2_KEY_SZ + ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ); break; case CPA_CY_SYM_CIPHER_AES_F8: cd_ctrl->cipher_key_sz = LAC_BYTES_TO_QUADWORDS(targetKeyLenInBytes); cd_ctrl->cipher_padding_sz = (2 * ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR); break; /* For ZUC EEA3 content descriptor key size is key size plus iv size */ case CPA_CY_SYM_CIPHER_ZUC_EEA3: cd_ctrl->cipher_key_sz = LAC_BYTES_TO_QUADWORDS(ICP_QAT_HW_ZUC_3G_EEA3_KEY_SZ + ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ); break; default: cd_ctrl->cipher_key_sz = LAC_BYTES_TO_QUADWORDS(targetKeyLenInBytes); } cd_ctrl->cipher_state_sz = LAC_BYTES_TO_QUADWORDS( LacSymQat_CipherIvSizeBytesGet(cipherAlgorithm)); cd_ctrl->cipher_cfg_offset = cipherCfgOffsetInQuadWord; ICP_QAT_FW_COMN_NEXT_ID_SET(cd_ctrl, nextSlice); ICP_QAT_FW_COMN_CURR_ID_SET(cd_ctrl, ICP_QAT_FW_SLICE_CIPHER); } void LacSymQat_CipherGetCfgData(lac_session_desc_t *pSession, icp_qat_hw_cipher_algo_t *pAlgorithm, icp_qat_hw_cipher_mode_t *pMode, icp_qat_hw_cipher_dir_t *pDir, icp_qat_hw_cipher_convert_t *pKey_convert) { sal_crypto_service_t *pService = (sal_crypto_service_t *)pSession->pInstance; CpaCySymCipherAlgorithm cipherAlgorithm = 0; icp_qat_hw_cipher_dir_t cipherDirection = 0; /* Set defaults */ *pKey_convert = ICP_QAT_HW_CIPHER_NO_CONVERT; *pAlgorithm = ICP_QAT_HW_CIPHER_ALGO_NULL; *pMode = ICP_QAT_HW_CIPHER_ECB_MODE; *pDir = ICP_QAT_HW_CIPHER_ENCRYPT; /* decrease since it's numbered from 1 instead of 0 */ cipherAlgorithm = pSession->cipherAlgorithm - 1; cipherDirection = pSession->cipherDirection == CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT ? ICP_QAT_HW_CIPHER_ENCRYPT : ICP_QAT_HW_CIPHER_DECRYPT; *pAlgorithm = icp_qat_alg_info[cipherAlgorithm].algorithm; *pMode = icp_qat_alg_info[cipherAlgorithm].mode; *pDir = icp_qat_alg_info[cipherAlgorithm].dir[cipherDirection]; *pKey_convert = icp_qat_alg_info[cipherAlgorithm].key_convert[cipherDirection]; if (IS_KEY_DEP_NO != icp_qat_alg_info[cipherAlgorithm].isKeyLenDepend) { *pAlgorithm = icp_qat_alg_info[cipherAlgorithm] .pAlgByKeySize[pSession->cipherKeyLenInBytes]; } /* CCP and AES_GCM single pass, despite being limited to CTR/AEAD mode, * support both Encrypt/Decrypt modes - this is because of the * differences in the hash computation/verification paths in * encrypt/decrypt modes respectively. * By default CCP is set as CTR Mode.Set AEAD Mode for AES_GCM. */ if (SPC == pSession->singlePassState) { if (LAC_CIPHER_IS_GCM(pSession->cipherAlgorithm)) *pMode = ICP_QAT_HW_CIPHER_AEAD_MODE; else if (isCyGen4x(pService) && LAC_CIPHER_IS_CCM(pSession->cipherAlgorithm)) *pMode = ICP_QAT_HW_CIPHER_CCM_MODE; if (cipherDirection == ICP_QAT_HW_CIPHER_DECRYPT) *pDir = ICP_QAT_HW_CIPHER_DECRYPT; } } void LacSymQat_CipherHwBlockPopulateCfgData(lac_session_desc_t *pSession, const void *pCipherHwBlock, Cpa32U *pSizeInBytes) { icp_qat_hw_cipher_algo_t algorithm = ICP_QAT_HW_CIPHER_ALGO_NULL; icp_qat_hw_cipher_mode_t mode = ICP_QAT_HW_CIPHER_ECB_MODE; icp_qat_hw_cipher_dir_t dir = ICP_QAT_HW_CIPHER_ENCRYPT; icp_qat_hw_cipher_convert_t key_convert; icp_qat_hw_cipher_config_t *pCipherConfig = (icp_qat_hw_cipher_config_t *)pCipherHwBlock; icp_qat_hw_ucs_cipher_config_t *pUCSCipherConfig = (icp_qat_hw_ucs_cipher_config_t *)pCipherHwBlock; Cpa32U val, reserved; Cpa32U aed_hash_cmp_length = 0; *pSizeInBytes = 0; LacSymQat_CipherGetCfgData( pSession, &algorithm, &mode, &dir, &key_convert); /* Build the cipher config into the hardware setup block */ if (SPC == pSession->singlePassState) { aed_hash_cmp_length = pSession->hashResultSize; reserved = ICP_QAT_HW_CIPHER_CONFIG_BUILD_UPPER( pSession->aadLenInBytes); } else { reserved = 0; } val = ICP_QAT_HW_CIPHER_CONFIG_BUILD( mode, algorithm, key_convert, dir, aed_hash_cmp_length); /* UCS slice has 128-bit configuration register. Leacy cipher slice has 64-bit config register */ if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == pSession->cipherSliceType) { pUCSCipherConfig->val = val; pUCSCipherConfig->reserved[0] = reserved; pUCSCipherConfig->reserved[1] = 0; pUCSCipherConfig->reserved[2] = 0; *pSizeInBytes = sizeof(icp_qat_hw_ucs_cipher_config_t); } else { pCipherConfig->val = val; pCipherConfig->reserved = reserved; *pSizeInBytes = sizeof(icp_qat_hw_cipher_config_t); } } void LacSymQat_CipherHwBlockPopulateKeySetup( lac_session_desc_t *pSessionDesc, const CpaCySymCipherSetupData *pCipherSetupData, Cpa32U targetKeyLenInBytes, Cpa32U sliceType, const void *pCipherHwBlock, Cpa32U *pSizeInBytes) { Cpa8U *pCipherKey = (Cpa8U *)pCipherHwBlock; Cpa32U actualKeyLenInBytes = pCipherSetupData->cipherKeyLenInBytes; *pSizeInBytes = 0; /* Key is copied into content descriptor for all cases except for * Arc4 and Null cipher */ if (!(LAC_CIPHER_IS_ARC4(pCipherSetupData->cipherAlgorithm) || LAC_CIPHER_IS_NULL(pCipherSetupData->cipherAlgorithm))) { /* Special handling of AES 192 key for UCS slice. UCS requires it to have 32 bytes - set is as targetKeyLen in this case, and add padding. It makes no sense - to force applications to provide such key length for couple - reasons: - 1. It won't be possible to distinguish between AES 192 and - 256 based on key lenght only - 2. Only some modes of AES will use UCS slice, then - application will have to know which ones */ + to force applications to provide such key length for couple reasons: + 1. It won't be possible to distinguish between AES 192 and 256 based + on key length only + 2. Only some modes of AES will use UCS slice, then application will + have to know which ones */ if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == sliceType && ICP_QAT_HW_AES_192_KEY_SZ == targetKeyLenInBytes) { targetKeyLenInBytes = ICP_QAT_HW_UCS_AES_192_KEY_SZ; } /* Set the Cipher key field in the cipher block */ memcpy(pCipherKey, pCipherSetupData->pCipherKey, actualKeyLenInBytes); /* Pad the key with 0's if required */ if (0 < (targetKeyLenInBytes - actualKeyLenInBytes)) { LAC_OS_BZERO(pCipherKey + actualKeyLenInBytes, targetKeyLenInBytes - actualKeyLenInBytes); } *pSizeInBytes += targetKeyLenInBytes; switch (pCipherSetupData->cipherAlgorithm) { /* For Kasumi in F8 mode Cipher Key is concatenated with * Cipher Key XOR-ed with Key Modifier (CK||CK^KM) */ case CPA_CY_SYM_CIPHER_KASUMI_F8: { Cpa32U wordIndex = 0; Cpa32U *pu32CipherKey = (Cpa32U *)pCipherSetupData->pCipherKey; Cpa32U *pTempKey = (Cpa32U *)(pCipherKey + targetKeyLenInBytes); /* XOR Key with KASUMI F8 key modifier at 4 bytes level */ for (wordIndex = 0; wordIndex < LAC_BYTES_TO_LONGWORDS(targetKeyLenInBytes); wordIndex++) { pTempKey[wordIndex] = pu32CipherKey[wordIndex] ^ LAC_CIPHER_KASUMI_F8_KEY_MODIFIER_4_BYTES; } *pSizeInBytes += targetKeyLenInBytes; /* also add padding for F8 */ *pSizeInBytes += LAC_QUADWORDS_TO_BYTES( ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR); LAC_OS_BZERO((Cpa8U *)pTempKey + targetKeyLenInBytes, LAC_QUADWORDS_TO_BYTES( ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR)); } break; /* For AES in F8 mode Cipher Key is concatenated with * Cipher Key XOR-ed with Key Mask (CK||CK^KM) */ case CPA_CY_SYM_CIPHER_AES_F8: { Cpa32U index = 0; Cpa8U *pTempKey = pCipherKey + (targetKeyLenInBytes / 2); *pSizeInBytes += targetKeyLenInBytes; /* XOR Key with key Mask */ for (index = 0; index < targetKeyLenInBytes; index++) { pTempKey[index] = pCipherKey[index] ^ pTempKey[index]; } pTempKey = (pCipherKey + targetKeyLenInBytes); /* also add padding for AES F8 */ *pSizeInBytes += 2 * targetKeyLenInBytes; LAC_OS_BZERO(pTempKey, 2 * targetKeyLenInBytes); } break; case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: { /* For Snow3G zero area after the key for FW */ LAC_OS_BZERO(pCipherKey + targetKeyLenInBytes, ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ); *pSizeInBytes += ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ; } break; case CPA_CY_SYM_CIPHER_ZUC_EEA3: { /* For ZUC zero area after the key for FW */ LAC_OS_BZERO(pCipherKey + targetKeyLenInBytes, ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ); *pSizeInBytes += ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ; } break; case CPA_CY_SYM_CIPHER_AES_XTS: { /* For AES in XTS mode Cipher Key is concatenated with * second Cipher Key which is used for tweak calculation * (CK1||CK2). For decryption Cipher Key needs to be * converted to reverse key.*/ if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == sliceType) { Cpa32U key_len = pCipherSetupData->cipherKeyLenInBytes / 2; memcpy(pSessionDesc->cipherAesXtsKey1Forward, pCipherSetupData->pCipherKey, key_len); qatUtilsAESKeyExpansionForward( pSessionDesc->cipherAesXtsKey1Forward, key_len, (uint32_t *) pSessionDesc->cipherAesXtsKey1Reverse); memcpy(pSessionDesc->cipherAesXtsKey2, pCipherSetupData->pCipherKey + key_len, key_len); if (CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT == pCipherSetupData->cipherDirection) { memcpy(pCipherKey, pSessionDesc ->cipherAesXtsKey1Reverse, key_len); } else { memcpy(pCipherKey, pSessionDesc ->cipherAesXtsKey1Forward, key_len); } } } break; default: break; } } } /***************************************************************************** * External functions *****************************************************************************/ Cpa8U LacSymQat_CipherBlockSizeBytesGet(CpaCySymCipherAlgorithm cipherAlgorithm) { Cpa8U blockSize = 0; switch (cipherAlgorithm) { case CPA_CY_SYM_CIPHER_ARC4: blockSize = LAC_CIPHER_ARC4_BLOCK_LEN_BYTES; break; /* Handle AES or AES_F8 */ case CPA_CY_SYM_CIPHER_AES_ECB: case CPA_CY_SYM_CIPHER_AES_CBC: case CPA_CY_SYM_CIPHER_AES_CTR: case CPA_CY_SYM_CIPHER_AES_CCM: case CPA_CY_SYM_CIPHER_AES_GCM: case CPA_CY_SYM_CIPHER_AES_XTS: case CPA_CY_SYM_CIPHER_AES_F8: blockSize = ICP_QAT_HW_AES_BLK_SZ; break; /* Handle DES */ case CPA_CY_SYM_CIPHER_DES_ECB: case CPA_CY_SYM_CIPHER_DES_CBC: blockSize = ICP_QAT_HW_DES_BLK_SZ; break; /* Handle TRIPLE DES */ case CPA_CY_SYM_CIPHER_3DES_ECB: case CPA_CY_SYM_CIPHER_3DES_CBC: case CPA_CY_SYM_CIPHER_3DES_CTR: blockSize = ICP_QAT_HW_3DES_BLK_SZ; break; case CPA_CY_SYM_CIPHER_KASUMI_F8: blockSize = ICP_QAT_HW_KASUMI_BLK_SZ; break; case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: blockSize = ICP_QAT_HW_SNOW_3G_BLK_SZ; break; case CPA_CY_SYM_CIPHER_ZUC_EEA3: blockSize = ICP_QAT_HW_ZUC_3G_BLK_SZ; break; case CPA_CY_SYM_CIPHER_NULL: blockSize = LAC_CIPHER_NULL_BLOCK_LEN_BYTES; break; case CPA_CY_SYM_CIPHER_CHACHA: blockSize = ICP_QAT_HW_CHACHAPOLY_BLK_SZ; break; case CPA_CY_SYM_CIPHER_SM4_ECB: case CPA_CY_SYM_CIPHER_SM4_CBC: case CPA_CY_SYM_CIPHER_SM4_CTR: blockSize = ICP_QAT_HW_SM4_BLK_SZ; break; default: QAT_UTILS_LOG("Algorithm not supported in Cipher"); } return blockSize; } Cpa32U LacSymQat_CipherIvSizeBytesGet(CpaCySymCipherAlgorithm cipherAlgorithm) { Cpa32U ivSize = 0; switch (cipherAlgorithm) { case CPA_CY_SYM_CIPHER_ARC4: ivSize = LAC_CIPHER_ARC4_STATE_LEN_BYTES; break; case CPA_CY_SYM_CIPHER_KASUMI_F8: ivSize = ICP_QAT_HW_KASUMI_BLK_SZ; break; case CPA_CY_SYM_CIPHER_SNOW3G_UEA2: ivSize = ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ; break; case CPA_CY_SYM_CIPHER_ZUC_EEA3: ivSize = ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ; break; case CPA_CY_SYM_CIPHER_CHACHA: ivSize = ICP_QAT_HW_CHACHAPOLY_IV_SZ; break; case CPA_CY_SYM_CIPHER_AES_ECB: case CPA_CY_SYM_CIPHER_DES_ECB: case CPA_CY_SYM_CIPHER_3DES_ECB: case CPA_CY_SYM_CIPHER_SM4_ECB: case CPA_CY_SYM_CIPHER_NULL: /* for all ECB Mode IV size is 0 */ break; default: ivSize = LacSymQat_CipherBlockSizeBytesGet(cipherAlgorithm); } return ivSize; } inline CpaStatus LacSymQat_CipherRequestParamsPopulate(lac_session_desc_t *pSessionDesc, icp_qat_fw_la_bulk_req_t *pReq, Cpa32U cipherOffsetInBytes, Cpa32U cipherLenInBytes, Cpa64U ivBufferPhysAddr, Cpa8U *pIvBufferVirt) { icp_qat_fw_la_cipher_req_params_t *pCipherReqParams; icp_qat_fw_cipher_cd_ctrl_hdr_t *pCipherCdCtrlHdr; icp_qat_fw_serv_specif_flags *pCipherSpecificFlags; Cpa32U usedBufSize = 0; Cpa32U totalBufSize = 0; pCipherReqParams = (icp_qat_fw_la_cipher_req_params_t *)((Cpa8U *)&(pReq->serv_specif_rqpars) + ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET); pCipherCdCtrlHdr = (icp_qat_fw_cipher_cd_ctrl_hdr_t *)&(pReq->cd_ctrl); pCipherSpecificFlags = &(pReq->comn_hdr.serv_specif_flags); pCipherReqParams->cipher_offset = cipherOffsetInBytes; pCipherReqParams->cipher_length = cipherLenInBytes; /* Don't copy the buffer into the Msg if * it's too big for the cipher_IV_array * OR if the FW needs to update it * OR if there's no buffer supplied * OR if last partial */ if ((pCipherCdCtrlHdr->cipher_state_sz > LAC_SYM_QAT_HASH_IV_REQ_MAX_SIZE_QW) || (ICP_QAT_FW_LA_UPDATE_STATE_GET(*pCipherSpecificFlags) == ICP_QAT_FW_LA_UPDATE_STATE) || (pIvBufferVirt == NULL) || (ICP_QAT_FW_LA_PARTIAL_GET(*pCipherSpecificFlags) == ICP_QAT_FW_LA_PARTIAL_END)) { /* Populate the field with a ptr to the flat buffer */ pCipherReqParams->u.s.cipher_IV_ptr = ivBufferPhysAddr; pCipherReqParams->u.s.resrvd1 = 0; /* Set the flag indicating the field format */ ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET( *pCipherSpecificFlags, ICP_QAT_FW_CIPH_IV_64BIT_PTR); } else { /* Populate the field with the contents of the buffer, * zero field first as data may be smaller than the field */ - /* In case of XTS mode using UCS slice always embedd IV. - * IV provided by user needs to be encrypted to calculate - * initial tweak, use pCipherReqParams->u.cipher_IV_array as - * destination buffer for tweak value */ + /* In case of XTS mode using UCS slice always encrypt the embedded IV. + * IV provided by user needs to be encrypted to calculate initial tweak, + * use pCipherReqParams->u.cipher_IV_array as destination buffer for + * tweak value */ if (ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE == pSessionDesc->cipherSliceType && LAC_CIPHER_IS_XTS_MODE(pSessionDesc->cipherAlgorithm)) { memset(pCipherReqParams->u.cipher_IV_array, 0, LAC_LONGWORDS_TO_BYTES( ICP_QAT_FW_NUM_LONGWORDS_4)); qatUtilsAESEncrypt( pSessionDesc->cipherAesXtsKey2, pSessionDesc->cipherKeyLenInBytes / 2, pIvBufferVirt, (Cpa8U *)pCipherReqParams->u.cipher_IV_array); } else { totalBufSize = LAC_LONGWORDS_TO_BYTES(ICP_QAT_FW_NUM_LONGWORDS_4); usedBufSize = LAC_QUADWORDS_TO_BYTES( pCipherCdCtrlHdr->cipher_state_sz); /* Only initialise unused buffer if applicable*/ if (usedBufSize < totalBufSize) { memset( (&pCipherReqParams->u.cipher_IV_array [usedBufSize & LAC_UNUSED_POS_MASK]), 0, totalBufSize - usedBufSize); } memcpy(pCipherReqParams->u.cipher_IV_array, pIvBufferVirt, usedBufSize); } /* Set the flag indicating the field format */ ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET( *pCipherSpecificFlags, ICP_QAT_FW_CIPH_IV_16BYTE_DATA); } return CPA_STATUS_SUCCESS; } void LacSymQat_CipherArc4StateInit(const Cpa8U *pKey, Cpa32U keyLenInBytes, Cpa8U *pArc4CipherState) { Cpa32U i = 0; Cpa32U j = 0; Cpa32U k = 0; for (i = 0; i < LAC_CIPHER_ARC4_KEY_MATRIX_LEN_BYTES; ++i) { pArc4CipherState[i] = (Cpa8U)i; } for (i = 0, k = 0; i < LAC_CIPHER_ARC4_KEY_MATRIX_LEN_BYTES; ++i, ++k) { Cpa8U swap = 0; if (k >= keyLenInBytes) k -= keyLenInBytes; j = (j + pArc4CipherState[i] + pKey[k]); if (j >= LAC_CIPHER_ARC4_KEY_MATRIX_LEN_BYTES) j %= LAC_CIPHER_ARC4_KEY_MATRIX_LEN_BYTES; /* Swap state[i] & state[j] */ swap = pArc4CipherState[i]; pArc4CipherState[i] = pArc4CipherState[j]; pArc4CipherState[j] = swap; } /* Initialise i & j values for QAT */ pArc4CipherState[LAC_CIPHER_ARC4_KEY_MATRIX_LEN_BYTES] = 0; pArc4CipherState[LAC_CIPHER_ARC4_KEY_MATRIX_LEN_BYTES + 1] = 0; } /* Update the cipher_key_sz in the Request cache prepared and stored * in the session */ void LacSymQat_CipherXTSModeUpdateKeyLen(lac_session_desc_t *pSessionDesc, Cpa32U newKeySizeInBytes) { icp_qat_fw_cipher_cd_ctrl_hdr_t *pCipherControlBlock = NULL; pCipherControlBlock = (icp_qat_fw_cipher_cd_ctrl_hdr_t *)&( pSessionDesc->reqCacheFtr.cd_ctrl); pCipherControlBlock->cipher_key_sz = LAC_BYTES_TO_QUADWORDS(newKeySizeInBytes); } diff --git a/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_hash_defs_lookup.c b/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_hash_defs_lookup.c index 40ae7b1d1de7..e99f264ccd67 100644 --- a/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_hash_defs_lookup.c +++ b/sys/dev/qat/qat_api/common/crypto/sym/qat/lac_sym_qat_hash_defs_lookup.c @@ -1,512 +1,512 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sym_qat_hash_defs_lookup.c Hash Definitions Lookup * * @ingroup LacHashDefsLookup ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_common.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "icp_adf_transport.h" #include "lac_sym.h" #include "icp_qat_fw_la.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sal_types_crypto.h" #include "lac_sym_hash_defs.h" /* state size for xcbc mac consists of 3 * 16 byte keys */ #define LAC_SYM_QAT_XCBC_STATE_SIZE ((LAC_HASH_XCBC_MAC_BLOCK_SIZE)*3) #define LAC_SYM_QAT_CMAC_STATE_SIZE ((LAC_HASH_CMAC_BLOCK_SIZE)*3) /* This type is used for the mapping between the hash algorithm and * the corresponding hash definitions structure */ typedef struct lac_sym_qat_hash_def_map_s { CpaCySymHashAlgorithm hashAlgorithm; /* hash algorithm */ lac_sym_qat_hash_defs_t hashDefs; - /* hash defintions pointers */ + /* hash definitions pointers */ } lac_sym_qat_hash_def_map_t; /* ******************************************************************************* * Static Variables ******************************************************************************* */ /* initialisers as defined in FIPS and RFCS for digest operations */ /* md5 16 bytes - Initialiser state can be found in RFC 1321*/ static Cpa8U md5InitialState[LAC_HASH_MD5_STATE_SIZE] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, }; /* SHA1 - 20 bytes - Initialiser state can be found in FIPS stds 180-2 */ static Cpa8U sha1InitialState[LAC_HASH_SHA1_STATE_SIZE] = { 0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0 }; /* SHA 224 - 32 bytes - Initialiser state can be found in FIPS stds 180-2 */ static Cpa8U sha224InitialState[LAC_HASH_SHA224_STATE_SIZE] = { 0xc1, 0x05, 0x9e, 0xd8, 0x36, 0x7c, 0xd5, 0x07, 0x30, 0x70, 0xdd, 0x17, 0xf7, 0x0e, 0x59, 0x39, 0xff, 0xc0, 0x0b, 0x31, 0x68, 0x58, 0x15, 0x11, 0x64, 0xf9, 0x8f, 0xa7, 0xbe, 0xfa, 0x4f, 0xa4 }; /* SHA 256 - 32 bytes - Initialiser state can be found in FIPS stds 180-2 */ static Cpa8U sha256InitialState[LAC_HASH_SHA256_STATE_SIZE] = { 0x6a, 0x09, 0xe6, 0x67, 0xbb, 0x67, 0xae, 0x85, 0x3c, 0x6e, 0xf3, 0x72, 0xa5, 0x4f, 0xf5, 0x3a, 0x51, 0x0e, 0x52, 0x7f, 0x9b, 0x05, 0x68, 0x8c, 0x1f, 0x83, 0xd9, 0xab, 0x5b, 0xe0, 0xcd, 0x19 }; /* SHA 384 - 64 bytes - Initialiser state can be found in FIPS stds 180-2 */ static Cpa8U sha384InitialState[LAC_HASH_SHA384_STATE_SIZE] = { 0xcb, 0xbb, 0x9d, 0x5d, 0xc1, 0x05, 0x9e, 0xd8, 0x62, 0x9a, 0x29, 0x2a, 0x36, 0x7c, 0xd5, 0x07, 0x91, 0x59, 0x01, 0x5a, 0x30, 0x70, 0xdd, 0x17, 0x15, 0x2f, 0xec, 0xd8, 0xf7, 0x0e, 0x59, 0x39, 0x67, 0x33, 0x26, 0x67, 0xff, 0xc0, 0x0b, 0x31, 0x8e, 0xb4, 0x4a, 0x87, 0x68, 0x58, 0x15, 0x11, 0xdb, 0x0c, 0x2e, 0x0d, 0x64, 0xf9, 0x8f, 0xa7, 0x47, 0xb5, 0x48, 0x1d, 0xbe, 0xfa, 0x4f, 0xa4 }; /* SHA 512 - 64 bytes - Initialiser state can be found in FIPS stds 180-2 */ static Cpa8U sha512InitialState[LAC_HASH_SHA512_STATE_SIZE] = { 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08, 0xbb, 0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b, 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94, 0xf8, 0x2b, 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1, 0x51, 0x0e, 0x52, 0x7f, 0xad, 0xe6, 0x82, 0xd1, 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f, 0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b, 0x5b, 0xe0, 0xcd, 0x19, 0x13, 0x7e, 0x21, 0x79 }; /* SHA3 224 - 28 bytes */ static Cpa8U sha3_224InitialState[LAC_HASH_SHA3_224_STATE_SIZE] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* SHA3 256 - 32 bytes */ static Cpa8U sha3_256InitialState[LAC_HASH_SHA3_256_STATE_SIZE] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* SHA3 384 - 48 bytes */ static Cpa8U sha3_384InitialState[LAC_HASH_SHA3_384_STATE_SIZE] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* SHA3 512 - 64 bytes */ static Cpa8U sha3_512InitialState[LAC_HASH_SHA3_512_STATE_SIZE] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* SM3 - 32 bytes */ static Cpa8U sm3InitialState[LAC_HASH_SM3_STATE_SIZE] = { 0x73, 0x80, 0x16, 0x6f, 0x49, 0x14, 0xb2, 0xb9, 0x17, 0x24, 0x42, 0xd7, 0xda, 0x8a, 0x06, 0x00, 0xa9, 0x6f, 0x30, 0xbc, 0x16, 0x31, 0x38, 0xaa, 0xe3, 0x8d, 0xee, 0x4d, 0xb0, 0xfb, 0x0e, 0x4e }; /* Constants used in generating K1, K2, K3 from a Key for AES_XCBC_MAC * State defined in RFC 3566 */ static Cpa8U aesXcbcKeySeed[LAC_SYM_QAT_XCBC_STATE_SIZE] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, }; static Cpa8U aesCmacKeySeed[LAC_HASH_CMAC_BLOCK_SIZE] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Hash Algorithm specific structure */ static lac_sym_qat_hash_alg_info_t md5Info = { LAC_HASH_MD5_DIGEST_SIZE, LAC_HASH_MD5_BLOCK_SIZE, md5InitialState, LAC_HASH_MD5_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha1Info = { LAC_HASH_SHA1_DIGEST_SIZE, LAC_HASH_SHA1_BLOCK_SIZE, sha1InitialState, LAC_HASH_SHA1_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha224Info = { LAC_HASH_SHA224_DIGEST_SIZE, LAC_HASH_SHA224_BLOCK_SIZE, sha224InitialState, LAC_HASH_SHA224_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha256Info = { LAC_HASH_SHA256_DIGEST_SIZE, LAC_HASH_SHA256_BLOCK_SIZE, sha256InitialState, LAC_HASH_SHA256_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha384Info = { LAC_HASH_SHA384_DIGEST_SIZE, LAC_HASH_SHA384_BLOCK_SIZE, sha384InitialState, LAC_HASH_SHA384_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha512Info = { LAC_HASH_SHA512_DIGEST_SIZE, LAC_HASH_SHA512_BLOCK_SIZE, sha512InitialState, LAC_HASH_SHA512_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha3_224Info = { LAC_HASH_SHA3_224_DIGEST_SIZE, LAC_HASH_SHA3_224_BLOCK_SIZE, sha3_224InitialState, LAC_HASH_SHA3_224_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha3_256Info = { LAC_HASH_SHA3_256_DIGEST_SIZE, LAC_HASH_SHA3_256_BLOCK_SIZE, sha3_256InitialState, LAC_HASH_SHA3_256_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha3_384Info = { LAC_HASH_SHA3_384_DIGEST_SIZE, LAC_HASH_SHA3_384_BLOCK_SIZE, sha3_384InitialState, LAC_HASH_SHA3_384_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sha3_512Info = { LAC_HASH_SHA3_512_DIGEST_SIZE, LAC_HASH_SHA3_512_BLOCK_SIZE, sha3_512InitialState, LAC_HASH_SHA3_512_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t sm3Info = { LAC_HASH_SM3_DIGEST_SIZE, LAC_HASH_SM3_BLOCK_SIZE, sm3InitialState, LAC_HASH_SM3_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t polyInfo = { LAC_HASH_POLY_DIGEST_SIZE, LAC_HASH_POLY_BLOCK_SIZE, - NULL, /* intial state */ + NULL, /* initial state */ LAC_HASH_POLY_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t xcbcMacInfo = { LAC_HASH_XCBC_MAC_128_DIGEST_SIZE, LAC_HASH_XCBC_MAC_BLOCK_SIZE, aesXcbcKeySeed, LAC_SYM_QAT_XCBC_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t aesCmacInfo = { LAC_HASH_CMAC_128_DIGEST_SIZE, LAC_HASH_CMAC_BLOCK_SIZE, aesCmacKeySeed, LAC_SYM_QAT_CMAC_STATE_SIZE }; static lac_sym_qat_hash_alg_info_t aesCcmInfo = { LAC_HASH_AES_CCM_DIGEST_SIZE, LAC_HASH_AES_CCM_BLOCK_SIZE, - NULL, /* intial state */ + NULL, /* initial state */ 0 /* state size */ }; static lac_sym_qat_hash_alg_info_t aesGcmInfo = { LAC_HASH_AES_GCM_DIGEST_SIZE, LAC_HASH_AES_GCM_BLOCK_SIZE, NULL, /* initial state */ 0 /* state size */ }; static lac_sym_qat_hash_alg_info_t kasumiF9Info = { LAC_HASH_KASUMI_F9_DIGEST_SIZE, LAC_HASH_KASUMI_F9_BLOCK_SIZE, NULL, /* initial state */ 0 /* state size */ }; static lac_sym_qat_hash_alg_info_t snow3gUia2Info = { LAC_HASH_SNOW3G_UIA2_DIGEST_SIZE, LAC_HASH_SNOW3G_UIA2_BLOCK_SIZE, NULL, /* initial state */ 0 /* state size */ }; static lac_sym_qat_hash_alg_info_t aesCbcMacInfo = { LAC_HASH_AES_CBC_MAC_DIGEST_SIZE, LAC_HASH_AES_CBC_MAC_BLOCK_SIZE, NULL, 0 }; static lac_sym_qat_hash_alg_info_t zucEia3Info = { LAC_HASH_ZUC_EIA3_DIGEST_SIZE, LAC_HASH_ZUC_EIA3_BLOCK_SIZE, NULL, /* initial state */ 0 /* state size */ }; /* Hash QAT specific structures */ static lac_sym_qat_hash_qat_info_t md5Config = { ICP_QAT_HW_AUTH_ALGO_MD5, LAC_HASH_MD5_BLOCK_SIZE, ICP_QAT_HW_MD5_STATE1_SZ, ICP_QAT_HW_MD5_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha1Config = { ICP_QAT_HW_AUTH_ALGO_SHA1, LAC_HASH_SHA1_BLOCK_SIZE, ICP_QAT_HW_SHA1_STATE1_SZ, ICP_QAT_HW_SHA1_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha224Config = { ICP_QAT_HW_AUTH_ALGO_SHA224, LAC_HASH_SHA224_BLOCK_SIZE, ICP_QAT_HW_SHA224_STATE1_SZ, ICP_QAT_HW_SHA224_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha256Config = { ICP_QAT_HW_AUTH_ALGO_SHA256, LAC_HASH_SHA256_BLOCK_SIZE, ICP_QAT_HW_SHA256_STATE1_SZ, ICP_QAT_HW_SHA256_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha384Config = { ICP_QAT_HW_AUTH_ALGO_SHA384, LAC_HASH_SHA384_BLOCK_SIZE, ICP_QAT_HW_SHA384_STATE1_SZ, ICP_QAT_HW_SHA384_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha512Config = { ICP_QAT_HW_AUTH_ALGO_SHA512, LAC_HASH_SHA512_BLOCK_SIZE, ICP_QAT_HW_SHA512_STATE1_SZ, ICP_QAT_HW_SHA512_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha3_224Config = { ICP_QAT_HW_AUTH_ALGO_SHA3_224, LAC_HASH_SHA3_224_BLOCK_SIZE, ICP_QAT_HW_SHA3_224_STATE1_SZ, ICP_QAT_HW_SHA3_224_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha3_256Config = { ICP_QAT_HW_AUTH_ALGO_SHA3_256, LAC_HASH_SHA3_256_BLOCK_SIZE, ICP_QAT_HW_SHA3_256_STATE1_SZ, ICP_QAT_HW_SHA3_256_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha3_384Config = { ICP_QAT_HW_AUTH_ALGO_SHA3_384, LAC_HASH_SHA3_384_BLOCK_SIZE, ICP_QAT_HW_SHA3_384_STATE1_SZ, ICP_QAT_HW_SHA3_384_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sha3_512Config = { ICP_QAT_HW_AUTH_ALGO_SHA3_512, LAC_HASH_SHA3_512_BLOCK_SIZE, ICP_QAT_HW_SHA3_512_STATE1_SZ, ICP_QAT_HW_SHA3_512_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t sm3Config = { ICP_QAT_HW_AUTH_ALGO_SM3, LAC_HASH_SM3_BLOCK_SIZE, ICP_QAT_HW_SM3_STATE1_SZ, ICP_QAT_HW_SM3_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t polyConfig = { ICP_QAT_HW_AUTH_ALGO_POLY, LAC_HASH_POLY_BLOCK_SIZE, 0, 0 }; static lac_sym_qat_hash_qat_info_t xcbcMacConfig = { ICP_QAT_HW_AUTH_ALGO_AES_XCBC_MAC, 0, ICP_QAT_HW_AES_XCBC_MAC_STATE1_SZ, LAC_SYM_QAT_XCBC_STATE_SIZE }; static lac_sym_qat_hash_qat_info_t aesCmacConfig = { ICP_QAT_HW_AUTH_ALGO_AES_XCBC_MAC, 0, ICP_QAT_HW_AES_XCBC_MAC_STATE1_SZ, LAC_SYM_QAT_CMAC_STATE_SIZE }; static lac_sym_qat_hash_qat_info_t aesCcmConfig = { ICP_QAT_HW_AUTH_ALGO_AES_CBC_MAC, 0, ICP_QAT_HW_AES_CBC_MAC_STATE1_SZ, ICP_QAT_HW_AES_CBC_MAC_KEY_SZ + ICP_QAT_HW_AES_CCM_CBC_E_CTR0_SZ }; static lac_sym_qat_hash_qat_info_t aesGcmConfig = { ICP_QAT_HW_AUTH_ALGO_GALOIS_128, 0, ICP_QAT_HW_GALOIS_128_STATE1_SZ, ICP_QAT_HW_GALOIS_H_SZ + ICP_QAT_HW_GALOIS_LEN_A_SZ + ICP_QAT_HW_GALOIS_E_CTR0_SZ }; static lac_sym_qat_hash_qat_info_t kasumiF9Config = { ICP_QAT_HW_AUTH_ALGO_KASUMI_F9, 0, ICP_QAT_HW_KASUMI_F9_STATE1_SZ, ICP_QAT_HW_KASUMI_F9_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t snow3gUia2Config = { ICP_QAT_HW_AUTH_ALGO_SNOW_3G_UIA2, 0, ICP_QAT_HW_SNOW_3G_UIA2_STATE1_SZ, ICP_QAT_HW_SNOW_3G_UIA2_STATE2_SZ }; static lac_sym_qat_hash_qat_info_t aesCbcMacConfig = { ICP_QAT_HW_AUTH_ALGO_AES_CBC_MAC, 0, ICP_QAT_HW_AES_CBC_MAC_STATE1_SZ, ICP_QAT_HW_AES_CBC_MAC_STATE1_SZ + ICP_QAT_HW_AES_CBC_MAC_STATE1_SZ }; static lac_sym_qat_hash_qat_info_t zucEia3Config = { ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3, 0, ICP_QAT_HW_ZUC_3G_EIA3_STATE1_SZ, ICP_QAT_HW_ZUC_3G_EIA3_STATE2_SZ }; /* Array of mappings between algorithm and info structure * This array is used to populate the lookup table */ static lac_sym_qat_hash_def_map_t lacHashDefsMapping[] = { { CPA_CY_SYM_HASH_MD5, { &md5Info, &md5Config } }, { CPA_CY_SYM_HASH_SHA1, { &sha1Info, &sha1Config } }, { CPA_CY_SYM_HASH_SHA224, { &sha224Info, &sha224Config } }, { CPA_CY_SYM_HASH_SHA256, { &sha256Info, &sha256Config } }, { CPA_CY_SYM_HASH_SHA384, { &sha384Info, &sha384Config } }, { CPA_CY_SYM_HASH_SHA512, { &sha512Info, &sha512Config } }, { CPA_CY_SYM_HASH_SHA3_224, { &sha3_224Info, &sha3_224Config } }, { CPA_CY_SYM_HASH_SHA3_256, { &sha3_256Info, &sha3_256Config } }, { CPA_CY_SYM_HASH_SHA3_384, { &sha3_384Info, &sha3_384Config } }, { CPA_CY_SYM_HASH_SHA3_512, { &sha3_512Info, &sha3_512Config } }, { CPA_CY_SYM_HASH_SM3, { &sm3Info, &sm3Config } }, { CPA_CY_SYM_HASH_POLY, { &polyInfo, &polyConfig } }, { CPA_CY_SYM_HASH_AES_XCBC, { &xcbcMacInfo, &xcbcMacConfig } }, { CPA_CY_SYM_HASH_AES_CMAC, { &aesCmacInfo, &aesCmacConfig } }, { CPA_CY_SYM_HASH_AES_CCM, { &aesCcmInfo, &aesCcmConfig } }, { CPA_CY_SYM_HASH_AES_GCM, { &aesGcmInfo, &aesGcmConfig } }, { CPA_CY_SYM_HASH_KASUMI_F9, { &kasumiF9Info, &kasumiF9Config } }, { CPA_CY_SYM_HASH_SNOW3G_UIA2, { &snow3gUia2Info, &snow3gUia2Config } }, { CPA_CY_SYM_HASH_AES_GMAC, { &aesGcmInfo, &aesGcmConfig } }, { CPA_CY_SYM_HASH_ZUC_EIA3, { &zucEia3Info, &zucEia3Config } }, { CPA_CY_SYM_HASH_AES_CBC_MAC, { &aesCbcMacInfo, &aesCbcMacConfig } } }; /* * LacSymQat_HashLookupInit */ CpaStatus LacSymQat_HashLookupInit(CpaInstanceHandle instanceHandle) { Cpa32U entry = 0; Cpa32U numEntries = 0; Cpa32U arraySize = 0; CpaStatus status = CPA_STATUS_SUCCESS; CpaCySymHashAlgorithm hashAlg = CPA_CY_SYM_HASH_NONE; sal_service_t *pService = (sal_service_t *)instanceHandle; lac_sym_qat_hash_defs_t **pLacHashLookupDefs; arraySize = (CPA_CY_HASH_ALG_END + 1) * sizeof(lac_sym_qat_hash_defs_t *); /* Size round up for performance */ arraySize = LAC_ALIGN_POW2_ROUNDUP(arraySize, LAC_64BYTE_ALIGNMENT); pLacHashLookupDefs = LAC_OS_MALLOC(arraySize); if (NULL == pLacHashLookupDefs) { return CPA_STATUS_RESOURCE; } LAC_OS_BZERO(pLacHashLookupDefs, arraySize); numEntries = sizeof(lacHashDefsMapping) / sizeof(lac_sym_qat_hash_def_map_t); /* initialise the hash lookup definitions table so that the algorithm * can be used to index into the table */ for (entry = 0; entry < numEntries; entry++) { hashAlg = lacHashDefsMapping[entry].hashAlgorithm; pLacHashLookupDefs[hashAlg] = &(lacHashDefsMapping[entry].hashDefs); } ((sal_crypto_service_t *)pService)->pLacHashLookupDefs = pLacHashLookupDefs; return status; } /* * LacSymQat_HashAlgLookupGet */ void LacSymQat_HashAlgLookupGet(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, lac_sym_qat_hash_alg_info_t **ppHashAlgInfo) { sal_service_t *pService = (sal_service_t *)instanceHandle; lac_sym_qat_hash_defs_t **pLacHashLookupDefs = ((sal_crypto_service_t *)pService)->pLacHashLookupDefs; *ppHashAlgInfo = pLacHashLookupDefs[hashAlgorithm]->algInfo; } /* * LacSymQat_HashDefsLookupGet */ void LacSymQat_HashDefsLookupGet(CpaInstanceHandle instanceHandle, CpaCySymHashAlgorithm hashAlgorithm, lac_sym_qat_hash_defs_t **ppHashDefsInfo) { sal_service_t *pService = (sal_service_t *)instanceHandle; lac_sym_qat_hash_defs_t **pLacHashLookupDefs = ((sal_crypto_service_t *)pService)->pLacHashLookupDefs; *ppHashDefsInfo = pLacHashLookupDefs[hashAlgorithm]; } diff --git a/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c b/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c index cba75eb41c17..e8a5ab1361e7 100644 --- a/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c +++ b/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c @@ -1,2009 +1,1991 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file sal_crypto.c Instance handling functions for crypto * * @ingroup SalCtrl * ***************************************************************************/ /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ /* QAT-API includes */ #include "cpa.h" #include "cpa_types.h" #include "cpa_cy_common.h" #include "cpa_cy_im.h" #include "cpa_cy_key.h" #include "cpa_cy_sym.h" #include "qat_utils.h" /* ADF includes */ #include "icp_adf_init.h" #include "icp_adf_transport.h" #include "icp_accel_devices.h" #include "icp_adf_cfg.h" #include "icp_adf_accel_mgr.h" #include "icp_adf_poll.h" #include "icp_adf_debug.h" /* SAL includes */ #include "lac_log.h" #include "lac_mem.h" #include "lac_mem_pools.h" #include "sal_statistics.h" #include "lac_common.h" #include "lac_list.h" #include "lac_hooks.h" #include "lac_sym_qat_hash_defs_lookup.h" #include "lac_sym.h" #include "lac_sym_key.h" #include "lac_sym_hash.h" #include "lac_sym_cb.h" #include "lac_sym_stats.h" #include "lac_sal_types_crypto.h" #include "lac_sal.h" #include "lac_sal_ctrl.h" #include "sal_string_parse.h" #include "sal_service_state.h" #include "icp_sal_poll.h" #include "lac_sync.h" #include "lac_sym_qat.h" #include "icp_sal_versions.h" #include "icp_sal_user.h" #include "sal_hw_gen.h" #define HMAC_MODE_1 1 #define HMAC_MODE_2 2 #define TH_CY_RX_0 0 #define TH_CY_RX_1 1 #define MAX_CY_RX_RINGS 2 #define DOUBLE_INCR 2 #define TH_SINGLE_RX 0 #define NUM_CRYPTO_SYM_RX_RINGS 1 #define NUM_CRYPTO_ASYM_RX_RINGS 1 #define NUM_CRYPTO_NRBG_RX_RINGS 1 static CpaInstanceHandle Lac_CryptoGetFirstHandle(void) { CpaInstanceHandle instHandle; instHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO); if (!instHandle) { instHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); if (!instHandle) { instHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_ASYM); } } return instHandle; } - /* Function to release the sym handles. */ static CpaStatus SalCtrl_SymReleaseTransHandle(sal_service_t *service) { CpaStatus status = CPA_STATUS_SUCCESS; CpaStatus ret_status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; if (NULL != pCryptoService->trans_handle_sym_tx) { status = icp_adf_transReleaseHandle( pCryptoService->trans_handle_sym_tx); if (CPA_STATUS_SUCCESS != status) { ret_status = status; } } if (NULL != pCryptoService->trans_handle_sym_rx) { status = icp_adf_transReleaseHandle( pCryptoService->trans_handle_sym_rx); if (CPA_STATUS_SUCCESS != status) { ret_status = status; } } return ret_status; } - /* * @ingroup sal_crypto * Frees resources (memory and transhandles) if allocated * * @param[in] pCryptoService Pointer to sym service instance * @retval SUCCESS if transhandles released * successfully. */ static CpaStatus SalCtrl_SymFreeResources(sal_crypto_service_t *pCryptoService) { CpaStatus status = CPA_STATUS_SUCCESS; /* Free memory pools if not NULL */ Lac_MemPoolDestroy(pCryptoService->lac_sym_cookie_pool); /* Free misc memory if allocated */ /* Frees memory allocated for Hmac precomputes */ LacSymHash_HmacPrecompShutdown(pCryptoService); /* Free memory allocated for key labels Also clears key stats */ LacSymKey_Shutdown(pCryptoService); /* Free hash lookup table if allocated */ if (NULL != pCryptoService->pLacHashLookupDefs) { LAC_OS_FREE(pCryptoService->pLacHashLookupDefs); } /* Free statistics */ LacSym_StatsFree(pCryptoService); /* Free transport handles */ status = SalCtrl_SymReleaseTransHandle((sal_service_t *)pCryptoService); return status; } - /** *********************************************************************** * @ingroup SalCtrl * This macro verifies that the status is _SUCCESS * If status is not _SUCCESS then Sym Instance resources are * freed before the function returns the error * * @param[in] status status we are checking * * @return void status is ok (CPA_STATUS_SUCCESS) * @return status The value in the status parameter is an error one * ****************************************************************************/ #define LAC_CHECK_STATUS_SYM_INIT(status) \ do { \ if (CPA_STATUS_SUCCESS != status) { \ SalCtrl_SymFreeResources(pCryptoService); \ return status; \ } \ } while (0) - /* Function that creates the Sym Handles. */ static CpaStatus SalCtrl_SymCreateTransHandle(icp_accel_dev_t *device, sal_service_t *service, Cpa32U numSymRequests, char *section) { CpaStatus status = CPA_STATUS_SUCCESS; char temp_string[SAL_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; icp_resp_deliv_method rx_resp_type = ICP_RESP_TYPE_IRQ; Cpa32U msgSize = 0; if (SAL_RESP_POLL_CFG_FILE == pCryptoService->isPolled) { rx_resp_type = ICP_RESP_TYPE_POLL; } if (CPA_FALSE == pCryptoService->generic_service_info.is_dyn) { section = icpGetProcessName(); } /* Parse Sym ring details */ status = Sal_StringParsing("Cy", pCryptoService->generic_service_info.instance, "RingSymTx", temp_string); /* Need to free resources in case not _SUCCESS from here */ LAC_CHECK_STATUS_SYM_INIT(status); msgSize = LAC_QAT_SYM_REQ_SZ_LW * LAC_LONG_WORD_IN_BYTES; status = icp_adf_transCreateHandle(device, ICP_TRANS_TYPE_ETR, section, pCryptoService->acceleratorNum, pCryptoService->bankNumSym, temp_string, lac_getRingType(SAL_RING_TYPE_A_SYM_HI), NULL, ICP_RESP_TYPE_NONE, numSymRequests, msgSize, (icp_comms_trans_handle *)&( pCryptoService->trans_handle_sym_tx)); LAC_CHECK_STATUS_SYM_INIT(status); status = Sal_StringParsing("Cy", pCryptoService->generic_service_info.instance, "RingSymRx", temp_string); LAC_CHECK_STATUS_SYM_INIT(status); msgSize = LAC_QAT_SYM_RESP_SZ_LW * LAC_LONG_WORD_IN_BYTES; status = icp_adf_transCreateHandle( device, ICP_TRANS_TYPE_ETR, section, pCryptoService->acceleratorNum, pCryptoService->bankNumSym, temp_string, lac_getRingType(SAL_RING_TYPE_NONE), (icp_trans_callback)LacSymQat_SymRespHandler, rx_resp_type, numSymRequests, msgSize, (icp_comms_trans_handle *)&(pCryptoService->trans_handle_sym_rx)); LAC_CHECK_STATUS_SYM_INIT(status); return status; } static int SalCtrl_CryptoDebug(void *private_data, char *data, int size, int offset) { CpaStatus status = CPA_STATUS_SUCCESS; Cpa32U len = 0; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)private_data; switch (offset) { case SAL_STATS_SYM: { CpaCySymStats64 symStats = { 0 }; if (CPA_TRUE != pCryptoService->generic_service_info.stats ->bSymStatsEnabled) { break; } status = cpaCySymQueryStats64(pCryptoService, &symStats); if (status != CPA_STATUS_SUCCESS) { LAC_LOG_ERROR("cpaCySymQueryStats64 returned error\n"); return 0; } /* Engine Info */ len += snprintf( data + len, size - len, SEPARATOR BORDER " Statistics for Instance %24s |\n" BORDER " Symmetric Stats " BORDER "\n" SEPARATOR, pCryptoService->debug_file->name); /* Session Info */ len += snprintf( data + len, size - len, BORDER " Sessions Initialized: %16llu " BORDER "\n" BORDER " Sessions Removed: %16llu " BORDER "\n" BORDER " Session Errors: %16llu " BORDER "\n" SEPARATOR, (long long unsigned int)symStats.numSessionsInitialized, (long long unsigned int)symStats.numSessionsRemoved, (long long unsigned int)symStats.numSessionErrors); /* Session info */ len += snprintf( data + len, size - len, BORDER " Symmetric Requests: %16llu " BORDER "\n" BORDER " Symmetric Request Errors: %16llu " BORDER "\n" BORDER " Symmetric Completed: %16llu " BORDER "\n" BORDER " Symmetric Completed Errors: %16llu " BORDER "\n" BORDER " Symmetric Verify Failures: %16llu " BORDER "\n", (long long unsigned int)symStats.numSymOpRequests, (long long unsigned int)symStats.numSymOpRequestErrors, (long long unsigned int)symStats.numSymOpCompleted, (long long unsigned int)symStats.numSymOpCompletedErrors, (long long unsigned int)symStats.numSymOpVerifyFailures); break; } default: { len += snprintf(data + len, size - len, SEPARATOR); return 0; } } return ++offset; } - static CpaStatus SalCtrl_SymInit(icp_accel_dev_t *device, sal_service_t *service) { CpaStatus status = CPA_STATUS_SUCCESS; Cpa32U qatHmacMode = 0; Cpa32U numSymConcurrentReq = 0; char adfGetParam[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char temp_string[SAL_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; char *section = DYN_SEC; /*Instance may not in the DYN section*/ if (CPA_FALSE == pCryptoService->generic_service_info.is_dyn) { section = icpGetProcessName(); } - /* Register callbacks for the symmetric services * (Hash, Cipher, Algorithm-Chaining) (returns void)*/ LacSymCb_CallbacksRegister(); qatHmacMode = (Cpa32U)Sal_Strtoul(adfGetParam, NULL, SAL_CFG_BASE_DEC); switch (qatHmacMode) { case HMAC_MODE_1: pCryptoService->qatHmacMode = ICP_QAT_HW_AUTH_MODE1; break; case HMAC_MODE_2: pCryptoService->qatHmacMode = ICP_QAT_HW_AUTH_MODE2; break; default: pCryptoService->qatHmacMode = ICP_QAT_HW_AUTH_MODE1; break; } /* Get num concurrent requests from config file */ status = Sal_StringParsing("Cy", pCryptoService->generic_service_info.instance, "NumConcurrentSymRequests", temp_string); LAC_CHECK_STATUS(status); status = icp_adf_cfgGetParamValue(device, section, temp_string, adfGetParam); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG("Failed to get %s from configuration file\n", temp_string); return status; } numSymConcurrentReq = (Cpa32U)Sal_Strtoul(adfGetParam, NULL, SAL_CFG_BASE_DEC); if (CPA_STATUS_FAIL == validateConcurrRequest(numSymConcurrentReq)) { LAC_LOG_ERROR("Invalid NumConcurrentSymRequests, valid " "values {64, 128, 256, ... 32768, 65536}"); return CPA_STATUS_FAIL; } /* ADF does not allow us to completely fill the ring for batch requests */ pCryptoService->maxNumSymReqBatch = (numSymConcurrentReq - SAL_BATCH_SUBMIT_FREE_SPACE); /* Create transport handles */ status = SalCtrl_SymCreateTransHandle(device, service, numSymConcurrentReq, section); LAC_CHECK_STATUS(status); /* Allocates memory pools */ /* Create and initialise symmetric cookie memory pool */ pCryptoService->lac_sym_cookie_pool = LAC_MEM_POOL_INIT_POOL_ID; status = Sal_StringParsing("Cy", pCryptoService->generic_service_info.instance, "SymPool", temp_string); LAC_CHECK_STATUS_SYM_INIT(status); /* Note we need twice (i.e. <<1) the number of sym cookies to support sym ring pairs (and some, for partials) */ status = Lac_MemPoolCreate(&pCryptoService->lac_sym_cookie_pool, temp_string, ((numSymConcurrentReq + numSymConcurrentReq + 1) << 1), sizeof(lac_sym_cookie_t), LAC_64BYTE_ALIGNMENT, CPA_FALSE, pCryptoService->nodeAffinity); LAC_CHECK_STATUS_SYM_INIT(status); /* For all sym cookies fill out the physical address of data that will be set to QAT */ Lac_MemPoolInitSymCookiesPhyAddr(pCryptoService->lac_sym_cookie_pool); /* Clear stats */ /* Clears Key stats and allocate memory of SSL and TLS labels These labels are initialised to standard values */ status = LacSymKey_Init(pCryptoService); LAC_CHECK_STATUS_SYM_INIT(status); /* Initialises the hash lookup table*/ status = LacSymQat_Init(pCryptoService); LAC_CHECK_STATUS_SYM_INIT(status); /* Fills out content descriptor for precomputes and registers the hash precompute callback */ status = LacSymHash_HmacPrecompInit(pCryptoService); LAC_CHECK_STATUS_SYM_INIT(status); /* Init the Sym stats */ status = LacSym_StatsInit(pCryptoService); LAC_CHECK_STATUS_SYM_INIT(status); return status; } static void SalCtrl_DebugShutdown(icp_accel_dev_t *device, sal_service_t *service) { sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; sal_statistics_collection_t *pStatsCollection = (sal_statistics_collection_t *)device->pQatStats; if (CPA_TRUE == pStatsCollection->bStatsEnabled) { /* Clean stats */ if (NULL != pCryptoService->debug_file) { icp_adf_debugRemoveFile(pCryptoService->debug_file); LAC_OS_FREE(pCryptoService->debug_file->name); LAC_OS_FREE(pCryptoService->debug_file); pCryptoService->debug_file = NULL; } } pCryptoService->generic_service_info.stats = NULL; } static CpaStatus SalCtrl_DebugInit(icp_accel_dev_t *device, sal_service_t *service) { char adfGetParam[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char temp_string[SAL_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char *instance_name = NULL; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; sal_statistics_collection_t *pStatsCollection = (sal_statistics_collection_t *)device->pQatStats; CpaStatus status = CPA_STATUS_SUCCESS; char *section = DYN_SEC; /*Instance may not in the DYN section*/ if (CPA_FALSE == pCryptoService->generic_service_info.is_dyn) { section = icpGetProcessName(); } if (CPA_TRUE == pStatsCollection->bStatsEnabled) { /* Get instance name for stats */ instance_name = LAC_OS_MALLOC(ADF_CFG_MAX_VAL_LEN_IN_BYTES); if (NULL == instance_name) { return CPA_STATUS_RESOURCE; } status = Sal_StringParsing( "Cy", pCryptoService->generic_service_info.instance, "Name", temp_string); if (CPA_STATUS_SUCCESS != status) { LAC_OS_FREE(instance_name); return status; } status = icp_adf_cfgGetParamValue(device, section, temp_string, adfGetParam); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG( "Failed to get %s from configuration file\n", temp_string); LAC_OS_FREE(instance_name); return status; } snprintf(instance_name, ADF_CFG_MAX_VAL_LEN_IN_BYTES, "%s", adfGetParam); pCryptoService->debug_file = LAC_OS_MALLOC(sizeof(debug_file_info_t)); if (NULL == pCryptoService->debug_file) { LAC_OS_FREE(instance_name); return CPA_STATUS_RESOURCE; } memset(pCryptoService->debug_file, 0, sizeof(debug_file_info_t)); pCryptoService->debug_file->name = instance_name; pCryptoService->debug_file->seq_read = SalCtrl_CryptoDebug; pCryptoService->debug_file->private_data = pCryptoService; pCryptoService->debug_file->parent = pCryptoService->generic_service_info.debug_parent_dir; status = icp_adf_debugAddFile(device, pCryptoService->debug_file); if (CPA_STATUS_SUCCESS != status) { LAC_OS_FREE(instance_name); LAC_OS_FREE(pCryptoService->debug_file); return status; } } pCryptoService->generic_service_info.stats = pStatsCollection; return status; } static CpaStatus SalCtrl_GetBankNum(icp_accel_dev_t *device, Cpa32U inst, char *section, char *bank_name, Cpa16U *bank) { char adfParamValue[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char adfParamName[SAL_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; CpaStatus status = CPA_STATUS_SUCCESS; status = Sal_StringParsing("Cy", inst, bank_name, adfParamName); LAC_CHECK_STATUS(status); status = icp_adf_cfgGetParamValue(device, section, adfParamName, adfParamValue); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG("Failed to get %s from configuration file\n", adfParamName); return status; } *bank = (Cpa16U)Sal_Strtoul(adfParamValue, NULL, SAL_CFG_BASE_DEC); return status; } static CpaStatus SalCtr_InstInit(icp_accel_dev_t *device, sal_service_t *service) { char adfGetParam[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char temp_string[SAL_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char temp_string2[SAL_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; CpaStatus status = CPA_STATUS_SUCCESS; char *section = DYN_SEC; /*Instance may not in the DYN section*/ if (CPA_FALSE == pCryptoService->generic_service_info.is_dyn) { section = icpGetProcessName(); } - /* Get Config Info: Accel Num, bank Num, packageID, coreAffinity, nodeAffinity and response mode */ pCryptoService->acceleratorNum = 0; /* Gen4, a bank only has 2 rings (1 ring pair), only one type of service can be assigned one time. asym and sym will be in different bank*/ if (isCyGen4x(pCryptoService)) { switch (service->type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: status = SalCtrl_GetBankNum( device, pCryptoService->generic_service_info.instance, section, "BankNumberAsym", &pCryptoService->bankNumAsym); if (CPA_STATUS_SUCCESS != status) return status; break; case SAL_SERVICE_TYPE_CRYPTO_SYM: status = SalCtrl_GetBankNum( device, pCryptoService->generic_service_info.instance, section, "BankNumberSym", &pCryptoService->bankNumSym); if (CPA_STATUS_SUCCESS != status) return status; break; case SAL_SERVICE_TYPE_CRYPTO: status = SalCtrl_GetBankNum( device, pCryptoService->generic_service_info.instance, section, "BankNumberAsym", &pCryptoService->bankNumAsym); if (CPA_STATUS_SUCCESS != status) return status; status = SalCtrl_GetBankNum( device, pCryptoService->generic_service_info.instance, section, "BankNumberSym", &pCryptoService->bankNumSym); if (CPA_STATUS_SUCCESS != status) return status; break; default: return CPA_STATUS_FAIL; } } else { status = SalCtrl_GetBankNum( device, pCryptoService->generic_service_info.instance, section, "BankNumber", &pCryptoService->bankNumSym); if (CPA_STATUS_SUCCESS != status) return status; pCryptoService->bankNumAsym = pCryptoService->bankNumSym; } status = Sal_StringParsing("Cy", pCryptoService->generic_service_info.instance, "IsPolled", temp_string); LAC_CHECK_STATUS(status); status = icp_adf_cfgGetParamValue(device, section, temp_string, adfGetParam); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG("Failed to get %s from configuration file\n", temp_string); return status; } pCryptoService->isPolled = (Cpa8U)Sal_Strtoul(adfGetParam, NULL, SAL_CFG_BASE_DEC); /* Kernel instances do not support epoll mode */ if (SAL_RESP_EPOLL_CFG_FILE == pCryptoService->isPolled) { QAT_UTILS_LOG( "IsPolled %u is not supported for kernel instance %s", pCryptoService->isPolled, temp_string); return CPA_STATUS_FAIL; } status = icp_adf_cfgGetParamValue(device, LAC_CFG_SECTION_GENERAL, ADF_DEV_PKG_ID, adfGetParam); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG("Failed to get %s from configuration file\n", ADF_DEV_PKG_ID); return status; } pCryptoService->pkgID = (Cpa16U)Sal_Strtoul(adfGetParam, NULL, SAL_CFG_BASE_DEC); status = icp_adf_cfgGetParamValue(device, LAC_CFG_SECTION_GENERAL, ADF_DEV_NODE_ID, adfGetParam); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG("Failed to get %s from configuration file\n", ADF_DEV_NODE_ID); return status; } pCryptoService->nodeAffinity = (Cpa32U)Sal_Strtoul(adfGetParam, NULL, SAL_CFG_BASE_DEC); /* In case of interrupt instance, use the bank affinity set by adf_ctl * Otherwise, use the instance affinity for backwards compatibility */ if (SAL_RESP_POLL_CFG_FILE != pCryptoService->isPolled) { /* Next need to read the [AcceleratorX] section of the config * file */ status = Sal_StringParsing("Accelerator", pCryptoService->acceleratorNum, "", temp_string2); LAC_CHECK_STATUS(status); if (service->type == SAL_SERVICE_TYPE_CRYPTO_ASYM) status = Sal_StringParsing("Bank", pCryptoService->bankNumAsym, "CoreAffinity", temp_string); else /* For cy service, asym bank and sym bank will set the same core affinity. So Just read one*/ status = Sal_StringParsing("Bank", pCryptoService->bankNumSym, "CoreAffinity", temp_string); LAC_CHECK_STATUS(status); } else { strncpy(temp_string2, section, (strlen(section) + 1)); status = Sal_StringParsing( "Cy", pCryptoService->generic_service_info.instance, "CoreAffinity", temp_string); LAC_CHECK_STATUS(status); } status = icp_adf_cfgGetParamValue(device, temp_string2, temp_string, adfGetParam); if (CPA_STATUS_SUCCESS != status) { QAT_UTILS_LOG("Failed to get %s from configuration file\n", temp_string); return status; } pCryptoService->coreAffinity = (Cpa32U)Sal_Strtoul(adfGetParam, NULL, SAL_CFG_BASE_DEC); /*No Execution Engine in DH895xcc, so make sure it is zero*/ pCryptoService->executionEngine = 0; return status; } /* This function: * 1. Creates sym and asym transport handles * 2. Allocates memory pools required by sym and asym services .* 3. Clears the sym and asym stats counters * 4. In case service asym or sym is enabled then this function * only allocates resources for these services. i.e if the * service asym is enabled then only asym transport handles * are created and vice versa. */ CpaStatus SalCtrl_CryptoInit(icp_accel_dev_t *device, sal_service_t *service) { CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; sal_service_type_t svc_type = service->type; SAL_SERVICE_GOOD_FOR_INIT(pCryptoService); pCryptoService->generic_service_info.state = SAL_SERVICE_STATE_INITIALIZING; /* Set up the instance parameters such as bank number, * coreAffinity, pkgId and node affinity etc */ status = SalCtr_InstInit(device, service); LAC_CHECK_STATUS(status); /* Create debug directory for service */ status = SalCtrl_DebugInit(device, service); LAC_CHECK_STATUS(status); switch (svc_type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: break; case SAL_SERVICE_TYPE_CRYPTO_SYM: status = SalCtrl_SymInit(device, service); if (CPA_STATUS_SUCCESS != status) { SalCtrl_DebugShutdown(device, service); return status; } break; case SAL_SERVICE_TYPE_CRYPTO: status = SalCtrl_SymInit(device, service); if (CPA_STATUS_SUCCESS != status) { SalCtrl_DebugShutdown(device, service); return status; } break; default: LAC_LOG_ERROR("Invalid service type\n"); status = CPA_STATUS_FAIL; break; } pCryptoService->generic_service_info.state = SAL_SERVICE_STATE_INITIALIZED; return status; } CpaStatus SalCtrl_CryptoStart(icp_accel_dev_t *device, sal_service_t *service) { sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; CpaStatus status = CPA_STATUS_SUCCESS; if (pCryptoService->generic_service_info.state != SAL_SERVICE_STATE_INITIALIZED) { LAC_LOG_ERROR("Not in the correct state to call start\n"); return CPA_STATUS_FAIL; } pCryptoService->generic_service_info.state = SAL_SERVICE_STATE_RUNNING; return status; } CpaStatus SalCtrl_CryptoStop(icp_accel_dev_t *device, sal_service_t *service) { sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; if (SAL_SERVICE_STATE_RUNNING != pCryptoService->generic_service_info.state) { LAC_LOG_ERROR("Not in the correct state to call stop"); } pCryptoService->generic_service_info.state = SAL_SERVICE_STATE_SHUTTING_DOWN; return CPA_STATUS_SUCCESS; } CpaStatus SalCtrl_CryptoShutdown(icp_accel_dev_t *device, sal_service_t *service) { sal_crypto_service_t *pCryptoService = (sal_crypto_service_t *)service; CpaStatus status = CPA_STATUS_SUCCESS; sal_service_type_t svc_type = service->type; if ((SAL_SERVICE_STATE_INITIALIZED != pCryptoService->generic_service_info.state) && (SAL_SERVICE_STATE_SHUTTING_DOWN != pCryptoService->generic_service_info.state)) { LAC_LOG_ERROR("Not in the correct state to call shutdown \n"); return CPA_STATUS_FAIL; } - /* Free memory and transhandles */ switch (svc_type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: break; case SAL_SERVICE_TYPE_CRYPTO_SYM: if (SalCtrl_SymFreeResources(pCryptoService)) { status = CPA_STATUS_FAIL; } break; case SAL_SERVICE_TYPE_CRYPTO: if (SalCtrl_SymFreeResources(pCryptoService)) { status = CPA_STATUS_FAIL; } break; default: LAC_LOG_ERROR("Invalid service type\n"); status = CPA_STATUS_FAIL; break; } SalCtrl_DebugShutdown(device, service); pCryptoService->generic_service_info.state = SAL_SERVICE_STATE_SHUTDOWN; return status; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyGetStatusText(const CpaInstanceHandle instanceHandle, CpaStatus errStatus, Cpa8S *pStatusText) { CpaStatus status = CPA_STATUS_SUCCESS; - LAC_CHECK_NULL_PARAM(pStatusText); switch (errStatus) { case CPA_STATUS_SUCCESS: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_SUCCESS); break; case CPA_STATUS_FAIL: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_FAIL); break; case CPA_STATUS_RETRY: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_RETRY); break; case CPA_STATUS_RESOURCE: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_RESOURCE); break; case CPA_STATUS_INVALID_PARAM: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_INVALID_PARAM); break; case CPA_STATUS_FATAL: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_FATAL); break; case CPA_STATUS_UNSUPPORTED: LAC_COPY_STRING(pStatusText, CPA_STATUS_STR_UNSUPPORTED); break; default: status = CPA_STATUS_INVALID_PARAM; break; } return status; } void SalCtrl_CyQueryCapabilities(sal_service_t *pGenericService, CpaCyCapabilitiesInfo *pCapInfo) { memset(pCapInfo, 0, sizeof(CpaCyCapabilitiesInfo)); if (SAL_SERVICE_TYPE_CRYPTO == pGenericService->type || SAL_SERVICE_TYPE_CRYPTO_SYM == pGenericService->type) { pCapInfo->symSupported = CPA_TRUE; if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_EXT_ALGCHAIN) { pCapInfo->extAlgchainSupported = CPA_TRUE; } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_HKDF) { pCapInfo->hkdfSupported = CPA_TRUE; } } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_ECEDMONT) { pCapInfo->ecEdMontSupported = CPA_TRUE; } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_RANDOM_NUMBER) { pCapInfo->nrbgSupported = CPA_TRUE; } pCapInfo->drbgSupported = CPA_FALSE; pCapInfo->randSupported = CPA_FALSE; pCapInfo->nrbgSupported = CPA_FALSE; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyStartInstance(CpaInstanceHandle instanceHandle_in) { CpaInstanceHandle instanceHandle = NULL; /* Structure initializer is supported by C99, but it is * not supported by some former Intel compilers. */ CpaInstanceInfo2 info = { 0 }; icp_accel_dev_t *dev = NULL; CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO); if (!instanceHandle) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); pService = (sal_crypto_service_t *)instanceHandle; status = cpaCyInstanceGetInfo2(instanceHandle, &info); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR("Can not get instance info\n"); return status; } dev = icp_adf_getAccelDevByAccelId(info.physInstId.packageId); if (NULL == dev) { LAC_LOG_ERROR("Can not find device for the instance\n"); return CPA_STATUS_FAIL; } pService->generic_service_info.isInstanceStarted = CPA_TRUE; /* Increment dev ref counter */ icp_qa_dev_get(dev); return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyStopInstance(CpaInstanceHandle instanceHandle_in) { CpaInstanceHandle instanceHandle = NULL; /* Structure initializer is supported by C99, but it is * not supported by some former Intel compilers. */ CpaInstanceInfo2 info = { 0 }; icp_accel_dev_t *dev = NULL; CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); status = cpaCyInstanceGetInfo2(instanceHandle, &info); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR("Can not get instance info\n"); return status; } dev = icp_adf_getAccelDevByAccelId(info.physInstId.packageId); if (NULL == dev) { LAC_LOG_ERROR("Can not find device for the instance\n"); return CPA_STATUS_FAIL; } pService = (sal_crypto_service_t *)instanceHandle; pService->generic_service_info.isInstanceStarted = CPA_FALSE; /* Decrement dev ref counter */ icp_qa_dev_put(dev); return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyInstanceSetNotificationCb( const CpaInstanceHandle instanceHandle, const CpaCyInstanceNotificationCbFunc pInstanceNotificationCb, void *pCallbackTag) { CpaStatus status = CPA_STATUS_SUCCESS; sal_service_t *gen_handle = instanceHandle; - LAC_CHECK_NULL_PARAM(gen_handle); gen_handle->notification_cb = pInstanceNotificationCb; gen_handle->cb_tag = pCallbackTag; return status; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyGetNumInstances(Cpa16U *pNumInstances) { CpaStatus status = CPA_STATUS_SUCCESS; CpaInstanceHandle cyInstanceHandle; CpaInstanceInfo2 info; icp_accel_dev_t **pAdfInsts = NULL; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; sal_list_t *list_temp = NULL; Cpa16U num_accel_dev = 0; Cpa16U num_inst = 0; Cpa16U i = 0; LAC_CHECK_NULL_PARAM(pNumInstances); /* Get the number of accel_dev in the system */ status = icp_amgr_getNumInstances(&num_accel_dev); LAC_CHECK_STATUS(status); /* Allocate memory to store addr of accel_devs */ pAdfInsts = malloc(num_accel_dev * sizeof(icp_accel_dev_t *), M_QAT, M_WAITOK); num_accel_dev = 0; /* Get ADF to return all accel_devs that support either * symmetric or asymmetric crypto */ status = icp_amgr_getAllAccelDevByCapabilities( (ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC), pAdfInsts, &num_accel_dev); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR("No support for crypto\n"); *pNumInstances = 0; free(pAdfInsts, M_QAT); return status; } for (i = 0; i < num_accel_dev; i++) { dev_addr = (icp_accel_dev_t *)pAdfInsts[i]; if (NULL == dev_addr || NULL == dev_addr->pSalHandle) { continue; } base_addr = dev_addr->pSalHandle; list_temp = base_addr->crypto_services; while (NULL != list_temp) { cyInstanceHandle = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); if (CPA_STATUS_SUCCESS == status && CPA_TRUE == info.isPolled) { num_inst++; } list_temp = SalList_next(list_temp); } list_temp = base_addr->asym_services; while (NULL != list_temp) { cyInstanceHandle = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); if (CPA_STATUS_SUCCESS == status && CPA_TRUE == info.isPolled) { num_inst++; } list_temp = SalList_next(list_temp); } list_temp = base_addr->sym_services; while (NULL != list_temp) { cyInstanceHandle = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); if (CPA_STATUS_SUCCESS == status && CPA_TRUE == info.isPolled) { num_inst++; } list_temp = SalList_next(list_temp); } } *pNumInstances = num_inst; free(pAdfInsts, M_QAT); return status; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyGetInstances(Cpa16U numInstances, CpaInstanceHandle *pCyInstances) { CpaStatus status = CPA_STATUS_SUCCESS; CpaInstanceHandle cyInstanceHandle; CpaInstanceInfo2 info; icp_accel_dev_t **pAdfInsts = NULL; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; sal_list_t *list_temp = NULL; Cpa16U num_accel_dev = 0; Cpa16U num_allocated_instances = 0; Cpa16U index = 0; Cpa16U i = 0; LAC_CHECK_NULL_PARAM(pCyInstances); if (0 == numInstances) { LAC_INVALID_PARAM_LOG("NumInstances is 0"); return CPA_STATUS_INVALID_PARAM; } /* Get the number of crypto instances */ status = cpaCyGetNumInstances(&num_allocated_instances); if (CPA_STATUS_SUCCESS != status) { return status; } if (numInstances > num_allocated_instances) { QAT_UTILS_LOG("Only %d crypto instances available\n", num_allocated_instances); return CPA_STATUS_RESOURCE; } /* Get the number of accel devices in the system */ status = icp_amgr_getNumInstances(&num_accel_dev); LAC_CHECK_STATUS(status); /* Allocate memory to store addr of accel_devs */ pAdfInsts = malloc(num_accel_dev * sizeof(icp_accel_dev_t *), M_QAT, M_WAITOK); num_accel_dev = 0; /* Get ADF to return all accel_devs that support either * symmetric or asymmetric crypto */ status = icp_amgr_getAllAccelDevByCapabilities( (ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC), pAdfInsts, &num_accel_dev); if (CPA_STATUS_SUCCESS != status) { LAC_LOG_ERROR("No support for crypto\n"); free(pAdfInsts, M_QAT); return status; } for (i = 0; i < num_accel_dev; i++) { dev_addr = (icp_accel_dev_t *)pAdfInsts[i]; /* Note dev_addr cannot be NULL here as numInstances = 0 * is not valid and if dev_addr = NULL then index = 0 (which * is less than numInstances and status is set to _RESOURCE * above */ base_addr = dev_addr->pSalHandle; if (NULL == base_addr) { continue; } list_temp = base_addr->crypto_services; while (NULL != list_temp) { if (index > (numInstances - 1)) { break; } cyInstanceHandle = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); list_temp = SalList_next(list_temp); if (CPA_STATUS_SUCCESS != status || CPA_TRUE != info.isPolled) { continue; } pCyInstances[index] = cyInstanceHandle; index++; } list_temp = base_addr->asym_services; while (NULL != list_temp) { if (index > (numInstances - 1)) { break; } cyInstanceHandle = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); list_temp = SalList_next(list_temp); if (CPA_STATUS_SUCCESS != status || CPA_TRUE != info.isPolled) { continue; } pCyInstances[index] = cyInstanceHandle; index++; } list_temp = base_addr->sym_services; while (NULL != list_temp) { if (index > (numInstances - 1)) { break; } cyInstanceHandle = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); list_temp = SalList_next(list_temp); if (CPA_STATUS_SUCCESS != status || CPA_TRUE != info.isPolled) { continue; } pCyInstances[index] = cyInstanceHandle; index++; } } free(pAdfInsts, M_QAT); return status; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyInstanceGetInfo(const CpaInstanceHandle instanceHandle_in, struct _CpaInstanceInfo *pInstanceInfo) { CpaInstanceHandle instanceHandle = NULL; sal_crypto_service_t *pCryptoService = NULL; sal_service_t *pGenericService = NULL; Cpa8U name[CPA_INST_NAME_SIZE] = "Intel(R) DH89XXCC instance number: %02x, type: Crypto"; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); LAC_CHECK_NULL_PARAM(pInstanceInfo); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); pCryptoService = (sal_crypto_service_t *)instanceHandle; pInstanceInfo->type = CPA_INSTANCE_TYPE_CRYPTO; /* According to cpa.h instance state is initialized and ready for use * or shutdown. Therefore need to map our running state to initialised * or shutdown */ if (SAL_SERVICE_STATE_RUNNING == pCryptoService->generic_service_info.state) { pInstanceInfo->state = CPA_INSTANCE_STATE_INITIALISED; } else { pInstanceInfo->state = CPA_INSTANCE_STATE_SHUTDOWN; } pGenericService = (sal_service_t *)instanceHandle; snprintf((char *)pInstanceInfo->name, CPA_INST_NAME_SIZE, (char *)name, pGenericService->instance); pInstanceInfo->name[CPA_INST_NAME_SIZE - 1] = '\0'; snprintf((char *)pInstanceInfo->version, CPA_INSTANCE_MAX_NAME_SIZE_IN_BYTES, "%d.%d", CPA_CY_API_VERSION_NUM_MAJOR, CPA_CY_API_VERSION_NUM_MINOR); pInstanceInfo->version[CPA_INSTANCE_MAX_VERSION_SIZE_IN_BYTES - 1] = '\0'; return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyInstanceGetInfo2(const CpaInstanceHandle instanceHandle_in, CpaInstanceInfo2 *pInstanceInfo2) { CpaInstanceHandle instanceHandle = NULL; sal_crypto_service_t *pCryptoService = NULL; icp_accel_dev_t *dev = NULL; CpaStatus status = CPA_STATUS_SUCCESS; char keyStr[ADF_CFG_MAX_KEY_LEN_IN_BYTES] = { 0 }; char valStr[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char *section = DYN_SEC; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); LAC_CHECK_NULL_PARAM(pInstanceInfo2); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_OS_BZERO(pInstanceInfo2, sizeof(CpaInstanceInfo2)); pInstanceInfo2->accelerationServiceType = CPA_ACC_SVC_TYPE_CRYPTO; snprintf((char *)pInstanceInfo2->vendorName, CPA_INST_VENDOR_NAME_SIZE, "%s", SAL_INFO2_VENDOR_NAME); pInstanceInfo2->vendorName[CPA_INST_VENDOR_NAME_SIZE - 1] = '\0'; snprintf((char *)pInstanceInfo2->swVersion, CPA_INST_SW_VERSION_SIZE, "Version %d.%d", SAL_INFO2_DRIVER_SW_VERSION_MAJ_NUMBER, SAL_INFO2_DRIVER_SW_VERSION_MIN_NUMBER); pInstanceInfo2->swVersion[CPA_INST_SW_VERSION_SIZE - 1] = '\0'; /* Note we can safely read the contents of the crypto service instance here because icp_amgr_getAllAccelDevByCapabilities() only returns devs that have started */ pCryptoService = (sal_crypto_service_t *)instanceHandle; pInstanceInfo2->physInstId.packageId = pCryptoService->pkgID; pInstanceInfo2->physInstId.acceleratorId = pCryptoService->acceleratorNum; pInstanceInfo2->physInstId.executionEngineId = pCryptoService->executionEngine; pInstanceInfo2->physInstId.busAddress = icp_adf_get_busAddress(pInstanceInfo2->physInstId.packageId); /*set coreAffinity to zero before use */ LAC_OS_BZERO(pInstanceInfo2->coreAffinity, sizeof(pInstanceInfo2->coreAffinity)); CPA_BITMAP_BIT_SET(pInstanceInfo2->coreAffinity, pCryptoService->coreAffinity); pInstanceInfo2->nodeAffinity = pCryptoService->nodeAffinity; if (SAL_SERVICE_STATE_RUNNING == pCryptoService->generic_service_info.state) { pInstanceInfo2->operState = CPA_OPER_STATE_UP; } else { pInstanceInfo2->operState = CPA_OPER_STATE_DOWN; } pInstanceInfo2->requiresPhysicallyContiguousMemory = CPA_TRUE; if (SAL_RESP_POLL_CFG_FILE == pCryptoService->isPolled) { pInstanceInfo2->isPolled = CPA_TRUE; } else { pInstanceInfo2->isPolled = CPA_FALSE; } pInstanceInfo2->isOffloaded = CPA_TRUE; - /* Get the instance name and part name*/ + /* Get the instance name and part name */ dev = icp_adf_getAccelDevByAccelId(pCryptoService->pkgID); if (NULL == dev) { LAC_LOG_ERROR("Can not find device for the instance\n"); LAC_OS_BZERO(pInstanceInfo2, sizeof(CpaInstanceInfo2)); return CPA_STATUS_FAIL; } snprintf((char *)pInstanceInfo2->partName, CPA_INST_PART_NAME_SIZE, SAL_INFO2_PART_NAME, dev->deviceName); pInstanceInfo2->partName[CPA_INST_PART_NAME_SIZE - 1] = '\0'; status = Sal_StringParsing("Cy", pCryptoService->generic_service_info.instance, "Name", keyStr); LAC_CHECK_STATUS(status); if (CPA_FALSE == pCryptoService->generic_service_info.is_dyn) { section = icpGetProcessName(); } status = icp_adf_cfgGetParamValue(dev, section, keyStr, valStr); LAC_CHECK_STATUS(status); snprintf((char *)pInstanceInfo2->instName, CPA_INST_NAME_SIZE, "%s", valStr); snprintf((char *)pInstanceInfo2->instID, CPA_INST_ID_SIZE, "%s_%s", section, valStr); return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCyQueryCapabilities(const CpaInstanceHandle instanceHandle_in, CpaCyCapabilitiesInfo *pCapInfo) { /* Verify Instance exists */ CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pCapInfo); SalCtrl_CyQueryCapabilities((sal_service_t *)instanceHandle, pCapInfo); return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCySym *****************************************************************************/ CpaStatus cpaCySymQueryCapabilities(const CpaInstanceHandle instanceHandle_in, CpaCySymCapabilitiesInfo *pCapInfo) { sal_crypto_service_t *pCryptoService = NULL; sal_service_t *pGenericService = NULL; CpaInstanceHandle instanceHandle = NULL; /* Verify Instance exists */ if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO); if (!instanceHandle) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO_SYM); } } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(pCapInfo); pCryptoService = (sal_crypto_service_t *)instanceHandle; pGenericService = &(pCryptoService->generic_service_info); memset(pCapInfo, '\0', sizeof(CpaCySymCapabilitiesInfo)); /* An asym crypto instance does not support sym service */ if (SAL_SERVICE_TYPE_CRYPTO_ASYM == pGenericService->type) { return CPA_STATUS_SUCCESS; } CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_NULL); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_ECB); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_CBC); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_CTR); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_CCM); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_GCM); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_XTS); if (isCyGen2x(pCryptoService)) { CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_ARC4); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_DES_ECB); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_DES_CBC); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_3DES_ECB); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_3DES_CBC); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_3DES_CTR); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_KASUMI_F8); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_SNOW3G_UEA2); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_AES_F8); } CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA1); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA224); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA256); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA384); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA512); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_AES_XCBC); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_AES_CCM); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_AES_GCM); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_AES_CMAC); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_AES_GMAC); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_AES_CBC_MAC); if (isCyGen2x(pCryptoService)) { CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_MD5); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_KASUMI_F9); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SNOW3G_UIA2); } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_CRYPTO_ZUC) { CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_ZUC_EEA3); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_ZUC_EIA3); } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_CHACHA_POLY) { CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_POLY); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_CHACHA); } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_SM3) { CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SM3); } pCapInfo->partialPacketSupported = CPA_TRUE; if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_SHA3) { CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA3_256); pCapInfo->partialPacketSupported = CPA_FALSE; } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_SHA3_EXT) { CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA3_224); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA3_256); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA3_384); CPA_BITMAP_BIT_SET(pCapInfo->hashes, CPA_CY_SYM_HASH_SHA3_512); pCapInfo->partialPacketSupported = CPA_FALSE; } if (pGenericService->capabilitiesMask & ICP_ACCEL_CAPABILITIES_SM4) { CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_SM4_ECB); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_SM4_CBC); CPA_BITMAP_BIT_SET(pCapInfo->ciphers, CPA_CY_SYM_CIPHER_SM4_CTR); pCapInfo->partialPacketSupported = CPA_FALSE; } return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCyCommon *****************************************************************************/ CpaStatus cpaCySetAddressTranslation(const CpaInstanceHandle instanceHandle_in, CpaVirtualToPhysical virtual2physical) { CpaInstanceHandle instanceHandle = NULL; sal_service_t *pService = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { instanceHandle = instanceHandle_in; } LAC_CHECK_NULL_PARAM(instanceHandle); SAL_CHECK_INSTANCE_TYPE(instanceHandle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); LAC_CHECK_NULL_PARAM(virtual2physical); pService = (sal_service_t *)instanceHandle; pService->virt2PhysClient = virtual2physical; return CPA_STATUS_SUCCESS; } /** ****************************************************************************** * @ingroup cpaCyCommon * Crypto specific polling function which polls a crypto instance. *****************************************************************************/ CpaStatus icp_sal_CyPollInstance(CpaInstanceHandle instanceHandle_in, Cpa32U response_quota) { CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *crypto_handle = NULL; sal_service_t *gen_handle = NULL; icp_comms_trans_handle trans_hndTable[MAX_CY_RX_RINGS] = { 0 }; Cpa32U num_rx_rings = 0; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { crypto_handle = (sal_crypto_service_t *)Lac_CryptoGetFirstHandle(); } else { crypto_handle = (sal_crypto_service_t *)instanceHandle_in; } LAC_CHECK_NULL_PARAM(crypto_handle); SAL_RUNNING_CHECK(crypto_handle); SAL_CHECK_INSTANCE_TYPE(crypto_handle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_ASYM | SAL_SERVICE_TYPE_CRYPTO_SYM)); gen_handle = &(crypto_handle->generic_service_info); /* * From the instanceHandle we must get the trans_handle and send * down to adf for polling. * Populate our trans handle table with the appropriate handles. */ switch (gen_handle->type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: trans_hndTable[TH_CY_RX_0] = crypto_handle->trans_handle_asym_rx; num_rx_rings = 1; break; case SAL_SERVICE_TYPE_CRYPTO_SYM: trans_hndTable[TH_CY_RX_0] = crypto_handle->trans_handle_sym_rx; num_rx_rings = 1; break; case SAL_SERVICE_TYPE_CRYPTO: trans_hndTable[TH_CY_RX_0] = crypto_handle->trans_handle_sym_rx; trans_hndTable[TH_CY_RX_1] = crypto_handle->trans_handle_asym_rx; num_rx_rings = MAX_CY_RX_RINGS; break; default: break; } /* Call adf to do the polling. */ status = icp_adf_pollInstance(trans_hndTable, num_rx_rings, response_quota); return status; } /** ****************************************************************************** * @ingroup cpaCyCommon * Crypto specific polling function which polls sym crypto ring. *****************************************************************************/ CpaStatus icp_sal_CyPollSymRing(CpaInstanceHandle instanceHandle_in, Cpa32U response_quota) { CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *crypto_handle = NULL; icp_comms_trans_handle trans_hndTable[NUM_CRYPTO_SYM_RX_RINGS] = { 0 }; if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { crypto_handle = (sal_crypto_service_t *)Lac_GetFirstHandle( SAL_SERVICE_TYPE_CRYPTO_SYM); } else { crypto_handle = (sal_crypto_service_t *)instanceHandle_in; } LAC_CHECK_NULL_PARAM(crypto_handle); SAL_CHECK_INSTANCE_TYPE(crypto_handle, (SAL_SERVICE_TYPE_CRYPTO | SAL_SERVICE_TYPE_CRYPTO_SYM)); SAL_RUNNING_CHECK(crypto_handle); /* * From the instanceHandle we must get the trans_handle and send * down to adf for polling. * Populate our trans handle table with the appropriate handles. */ trans_hndTable[TH_SINGLE_RX] = crypto_handle->trans_handle_sym_rx; /* Call adf to do the polling. */ status = icp_adf_pollInstance(trans_hndTable, NUM_CRYPTO_SYM_RX_RINGS, response_quota); return status; } - /** ****************************************************************************** * @ingroup cpaCyCommon * Crypto specific polling function which polls an nrbg crypto ring. *****************************************************************************/ CpaStatus icp_sal_CyPollNRBGRing(CpaInstanceHandle instanceHandle_in, Cpa32U response_quota) { return CPA_STATUS_UNSUPPORTED; } /* Returns the handle to the first asym crypto instance */ static CpaInstanceHandle Lac_GetFirstAsymHandle(icp_accel_dev_t *adfInsts[ADF_MAX_DEVICES], Cpa16U num_dev) { CpaStatus status = CPA_STATUS_SUCCESS; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; sal_list_t *list_temp = NULL; CpaInstanceHandle cyInst = NULL; CpaInstanceInfo2 info; Cpa16U i = 0; for (i = 0; i < num_dev; i++) { dev_addr = (icp_accel_dev_t *)adfInsts[i]; base_addr = dev_addr->pSalHandle; if (NULL == base_addr) { continue; } list_temp = base_addr->asym_services; while (NULL != list_temp) { cyInst = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInst, &info); list_temp = SalList_next(list_temp); if (CPA_STATUS_SUCCESS != status || CPA_TRUE != info.isPolled) { cyInst = NULL; continue; } break; } if (cyInst) { break; } } return cyInst; } /* Returns the handle to the first sym crypto instance */ static CpaInstanceHandle Lac_GetFirstSymHandle(icp_accel_dev_t *adfInsts[ADF_MAX_DEVICES], Cpa16U num_dev) { CpaStatus status = CPA_STATUS_SUCCESS; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; sal_list_t *list_temp = NULL; CpaInstanceHandle cyInst = NULL; CpaInstanceInfo2 info; Cpa16U i = 0; for (i = 0; i < num_dev; i++) { dev_addr = (icp_accel_dev_t *)adfInsts[i]; base_addr = dev_addr->pSalHandle; if (NULL == base_addr) { continue; } list_temp = base_addr->sym_services; while (NULL != list_temp) { cyInst = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInst, &info); list_temp = SalList_next(list_temp); if (CPA_STATUS_SUCCESS != status || CPA_TRUE != info.isPolled) { cyInst = NULL; continue; } break; } if (cyInst) { break; } } return cyInst; } /* Returns the handle to the first crypto instance * Note that the crypto instance in this case supports * both asym and sym services */ static CpaInstanceHandle Lac_GetFirstCyHandle(icp_accel_dev_t *adfInsts[ADF_MAX_DEVICES], Cpa16U num_dev) { CpaStatus status = CPA_STATUS_SUCCESS; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; sal_list_t *list_temp = NULL; CpaInstanceHandle cyInst = NULL; CpaInstanceInfo2 info; Cpa16U i = 0; for (i = 0; i < num_dev; i++) { dev_addr = (icp_accel_dev_t *)adfInsts[i]; base_addr = dev_addr->pSalHandle; if (NULL == base_addr) { continue; } list_temp = base_addr->crypto_services; while (NULL != list_temp) { cyInst = SalList_getObject(list_temp); status = cpaCyInstanceGetInfo2(cyInst, &info); list_temp = SalList_next(list_temp); if (CPA_STATUS_SUCCESS != status || CPA_TRUE != info.isPolled) { cyInst = NULL; continue; } break; } if (cyInst) { break; } } return cyInst; } CpaInstanceHandle Lac_GetFirstHandle(sal_service_type_t svc_type) { CpaStatus status = CPA_STATUS_SUCCESS; static icp_accel_dev_t *adfInsts[ADF_MAX_DEVICES] = { 0 }; CpaInstanceHandle cyInst = NULL; Cpa16U num_cy_dev = 0; Cpa32U capabilities = 0; switch (svc_type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: capabilities = ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC; break; case SAL_SERVICE_TYPE_CRYPTO_SYM: capabilities = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC; break; case SAL_SERVICE_TYPE_CRYPTO: capabilities = ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC; capabilities |= ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC; break; default: LAC_LOG_ERROR("Invalid service type\n"); return NULL; break; } /* Only need 1 dev with crypto enabled - so check all devices*/ status = icp_amgr_getAllAccelDevByEachCapability(capabilities, adfInsts, &num_cy_dev); if ((0 == num_cy_dev) || (CPA_STATUS_SUCCESS != status)) { LAC_LOG_ERROR("No crypto devices enabled in the system\n"); return NULL; } switch (svc_type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: /* Try to find an asym only instance first */ cyInst = Lac_GetFirstAsymHandle(adfInsts, num_cy_dev); /* Try to find a cy instance since it also supports asym */ if (NULL == cyInst) { cyInst = Lac_GetFirstCyHandle(adfInsts, num_cy_dev); } break; case SAL_SERVICE_TYPE_CRYPTO_SYM: /* Try to find a sym only instance first */ cyInst = Lac_GetFirstSymHandle(adfInsts, num_cy_dev); /* Try to find a cy instance since it also supports sym */ if (NULL == cyInst) { cyInst = Lac_GetFirstCyHandle(adfInsts, num_cy_dev); } break; case SAL_SERVICE_TYPE_CRYPTO: /* Try to find a cy instance */ cyInst = Lac_GetFirstCyHandle(adfInsts, num_cy_dev); break; default: break; } if (NULL == cyInst) { LAC_LOG_ERROR("No remaining crypto instances available\n"); } return cyInst; } CpaStatus icp_sal_NrbgGetInflightRequests(CpaInstanceHandle instanceHandle_in, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests) { return CPA_STATUS_UNSUPPORTED; } CpaStatus icp_sal_SymGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests) { sal_crypto_service_t *crypto_handle = NULL; crypto_handle = (sal_crypto_service_t *)instanceHandle; LAC_CHECK_NULL_PARAM(crypto_handle); LAC_CHECK_NULL_PARAM(maxInflightRequests); LAC_CHECK_NULL_PARAM(numInflightRequests); SAL_RUNNING_CHECK(crypto_handle); return icp_adf_getInflightRequests(crypto_handle->trans_handle_sym_tx, maxInflightRequests, numInflightRequests); } - CpaStatus icp_sal_dp_SymGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests) { sal_crypto_service_t *crypto_handle = NULL; crypto_handle = (sal_crypto_service_t *)instanceHandle; return icp_adf_dp_getInflightRequests( crypto_handle->trans_handle_sym_tx, maxInflightRequests, numInflightRequests); } - CpaStatus icp_sal_setForceAEADMACVerify(CpaInstanceHandle instanceHandle, CpaBoolean forceAEADMacVerify) { sal_crypto_service_t *crypto_handle = NULL; crypto_handle = (sal_crypto_service_t *)instanceHandle; LAC_CHECK_NULL_PARAM(crypto_handle); crypto_handle->forceAEADMacVerify = forceAEADMacVerify; return CPA_STATUS_SUCCESS; } diff --git a/sys/dev/qat/qat_api/common/include/lac_common.h b/sys/dev/qat/qat_api/common/include/lac_common.h index 18ab5d049a47..6962e6f43a6d 100644 --- a/sys/dev/qat/qat_api/common/include/lac_common.h +++ b/sys/dev/qat/qat_api/common/include/lac_common.h @@ -1,843 +1,842 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_common.h Common macros * * @defgroup Lac Look Aside Crypto LLD Doc * *****************************************************************************/ /** ***************************************************************************** * @defgroup LacCommon LAC Common * Common code for Lac which includes init/shutdown, memory, logging and * hooks. * * @ingroup Lac * *****************************************************************************/ /***************************************************************************/ #ifndef LAC_COMMON_H #define LAC_COMMON_H /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" #include "qat_utils.h" #include "cpa_cy_common.h" #include "icp_adf_init.h" #define LAC_ARCH_UINT uintptr_t #define LAC_ARCH_INT intptr_t /* ***************************************************************************** * Max range values for some primitive param checking ***************************************************************************** */ /**< Maximum number of instances */ #define SAL_MAX_NUM_INSTANCES_PER_DEV 512 #define SAL_DEFAULT_RING_SIZE 256 /**< Default ring size */ #define SAL_64_CONCURR_REQUESTS 64 #define SAL_128_CONCURR_REQUESTS 128 #define SAL_256_CONCURR_REQUESTS 256 #define SAL_512_CONCURR_REQUESTS 512 #define SAL_1024_CONCURR_REQUESTS 1024 #define SAL_2048_CONCURR_REQUESTS 2048 #define SAL_4096_CONCURR_REQUESTS 4096 #define SAL_MAX_CONCURR_REQUESTS 65536 /**< Valid options for the num of concurrent requests per ring pair read from the config file. These values are used to size the rings */ #define SAL_BATCH_SUBMIT_FREE_SPACE 2 /**< For data plane batch submissions ADF leaves 2 spaces free on the ring */ /* ****************************************************************************** * Some common settings for QA API queries ****************************************************************************** */ #define SAL_INFO2_VENDOR_NAME "Intel(R)" /**< @ingroup LacCommon * Name of vendor of this driver */ #define SAL_INFO2_PART_NAME "%s with Intel(R) QuickAssist Technology" /**< @ingroup LacCommon */ /* ******************************************************************************** * User process name defines and functions ******************************************************************************** */ #define LAC_USER_PROCESS_NAME_MAX_LEN 32 /**< @ingroup LacCommon * Max length of user process name */ #define LAC_KERNEL_PROCESS_NAME "KERNEL_QAT" /**< @ingroup LacCommon * Default name for kernel process */ /* ******************************************************************************** * response mode indicator from Config file ******************************************************************************** */ #define SAL_RESP_POLL_CFG_FILE 1 #define SAL_RESP_EPOLL_CFG_FILE 2 /* * @ingroup LacCommon * @description * This function sets the process name * * @context * This functions is called from module_init or from user space process * initialization function * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No * * param[in] processName Process name to be set */ CpaStatus icpSetProcessName(const char *processName); /* * @ingroup LacCommon * @description * This function gets the process name * * @context * This functions is called from LAC context * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ char *icpGetProcessName(void); /* Sections of the config file */ #define LAC_CFG_SECTION_GENERAL "GENERAL" #define LAC_CFG_SECTION_INTERNAL "INTERNAL" /* ******************************************************************************** * Debug Macros and settings ******************************************************************************** */ #define SEPARATOR "+--------------------------------------------------+\n" /**< @ingroup LacCommon * separator used for printing stats to standard output*/ #define BORDER "|" /**< @ingroup LacCommon * separator used for printing stats to standard output*/ /** ***************************************************************************** * @ingroup LacCommon * Component state * * @description * This enum is used to indicate the state that the component is in. Its * purpose is to prevent components from being initialised or shutdown * incorrectly. * *****************************************************************************/ typedef enum { LAC_COMP_SHUT_DOWN = 0, /**< Component in the Shut Down state */ LAC_COMP_SHUTTING_DOWN, /**< Component in the Process of Shutting down */ LAC_COMP_INITIALISING, /**< Component in the Process of being initialised */ LAC_COMP_INITIALISED, /**< Component in the initialised state */ } lac_comp_state_t; /** ******************************************************************************* * @ingroup LacCommon * This macro checks if a parameter is NULL * * @param[in] param Parameter * * @return CPA_STATUS_INVALID_PARAM Parameter is NULL * @return void Parameter is not NULL ******************************************************************************/ #define LAC_CHECK_NULL_PARAM(param) \ do { \ if (NULL == (param)) { \ return CPA_STATUS_INVALID_PARAM; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This macro checks if a parameter is within a specified range * * @param[in] param Parameter * @param[in] min Parameter must be greater than OR equal to *min * @param[in] max Parameter must be less than max * * @return CPA_STATUS_INVALID_PARAM Parameter is outside range * @return void Parameter is within range ******************************************************************************/ #define LAC_CHECK_PARAM_RANGE(param, min, max) \ do { \ if (((param) < (min)) || ((param) >= (max))) { \ return CPA_STATUS_INVALID_PARAM; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This checks if a param is 8 byte aligned. * ******************************************************************************/ #define LAC_CHECK_8_BYTE_ALIGNMENT(param) \ do { \ if ((Cpa64U)param % 8 != 0) { \ return CPA_STATUS_INVALID_PARAM; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This checks if a param is 64 byte aligned. * ******************************************************************************/ #define LAC_CHECK_64_BYTE_ALIGNMENT(param) \ do { \ if ((LAC_ARCH_UINT)param % 64 != 0) { \ return CPA_STATUS_INVALID_PARAM; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This macro returns the size of the buffer list structure given the * number of elements in the buffer list - note: only the sizeof the * buffer list structure is returned. * * @param[in] numBuffers The number of flatbuffers in a buffer list * * @return size of the buffer list structure ******************************************************************************/ #define LAC_BUFFER_LIST_SIZE_GET(numBuffers) \ (sizeof(CpaBufferList) + (numBuffers * sizeof(CpaFlatBuffer))) /** ******************************************************************************* * @ingroup LacCommon * This macro checks that a flatbuffer is valid i.e. that it is not * null and the data it points to is not null * * @param[in] pFlatBuffer Pointer to flatbuffer * * @return CPA_STATUS_INVALID_PARAM Invalid flatbuffer pointer * @return void flatbuffer is ok ******************************************************************************/ #define LAC_CHECK_FLAT_BUFFER(pFlatBuffer) \ do { \ LAC_CHECK_NULL_PARAM((pFlatBuffer)); \ LAC_CHECK_NULL_PARAM((pFlatBuffer)->pData); \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This macro verifies that the status is ok i.e. equal to CPA_STATUS_SUCCESS * * @param[in] status status we are checking * * @return void status is ok (CPA_STATUS_SUCCESS) * @return status The value in the status parameter is an error one * ******************************************************************************/ #define LAC_CHECK_STATUS(status) \ do { \ if (CPA_STATUS_SUCCESS != (status)) { \ return status; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This macro verifies that the Instance Handle is valid. * * @param[in] instanceHandle Instance Handle * * @return CPA_STATUS_INVALID_PARAM Parameter is NULL * @return void Parameter is not NULL * ******************************************************************************/ #define LAC_CHECK_INSTANCE_HANDLE(instanceHandle) \ do { \ if (NULL == (instanceHandle)) { \ return CPA_STATUS_INVALID_PARAM; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This macro copies a string from one location to another * * @param[out] pDestinationBuffer Pointer to destination buffer * @param[in] pSource Pointer to source buffer * ******************************************************************************/ #define LAC_COPY_STRING(pDestinationBuffer, pSource) \ do { \ memcpy(pDestinationBuffer, pSource, (sizeof(pSource) - 1)); \ pDestinationBuffer[(sizeof(pSource) - 1)] = '\0'; \ } while (0) /** ******************************************************************************* * @ingroup LacCommon * This macro fills a memory zone with ZEROES * * @param[in] pBuffer Pointer to buffer * @param[in] count Buffer length * * @return void * ******************************************************************************/ #define LAC_OS_BZERO(pBuffer, count) memset(pBuffer, 0, count); /** ******************************************************************************* * @ingroup LacCommon * This macro calculates the position of the given member in a struct * Only for use on a struct where all members are of equal size to map * the struct member position to an array index * * @param[in] structType the struct * @param[in] member the member of the given struct * ******************************************************************************/ #define LAC_IDX_OF(structType, member) \ (offsetof(structType, member) / sizeof(((structType *)0)->member)) /* ******************************************************************************** * Alignment, Bid define and Bit Operation Macros ******************************************************************************** */ #define LAC_BIT31_SET 0x80000000 /**< bit 31 == 1 */ #define LAC_BIT7_SET 0x80 /**< bit 7 == 1 */ #define LAC_BIT6_SET 0x40 /**< bit 6 == 1 */ #define LAC_BIT5_SET 0x20 /**< bit 5 == 1 */ #define LAC_BIT4_SET 0x10 /**< bit 4 == 1 */ #define LAC_BIT3_SET 0x08 /**< bit 3 == 1 */ #define LAC_BIT2_SET 0x04 /**< bit 2 == 1 */ #define LAC_BIT1_SET 0x02 /**< bit 1 == 1 */ #define LAC_BIT0_SET 0x01 /**< bit 0 == 1 */ #define LAC_NUM_BITS_IN_BYTE (8) /**< @ingroup LacCommon * Number of bits in a byte */ #define LAC_LONG_WORD_IN_BYTES (4) /**< @ingroup LacCommon * Number of bytes in an IA word */ #define LAC_QUAD_WORD_IN_BYTES (8) /**< @ingroup LacCommon * Number of bytes in a QUAD word */ #define LAC_QAT_MAX_MSG_SZ_LW (32) /**< @ingroup LacCommon * Maximum size in Long Words for a QAT message */ /** ***************************************************************************** * @ingroup LacCommon * Alignment shift requirements of a buffer. * * @description * This enum is used to indicate the alignment shift of a buffer. * All alignments are to power of 2 * *****************************************************************************/ typedef enum lac_aligment_shift_s { LAC_NO_ALIGNMENT_SHIFT = 0, /**< No alignment shift (to a power of 2)*/ LAC_8BYTE_ALIGNMENT_SHIFT = 3, /**< 8 byte alignment shift (to a power of 2)*/ LAC_16BYTE_ALIGNMENT_SHIFT = 4, /**< 16 byte alignment shift (to a power of 2)*/ LAC_64BYTE_ALIGNMENT_SHIFT = 6, /**< 64 byte alignment shift (to a power of 2)*/ LAC_4KBYTE_ALIGNMENT_SHIFT = 12, /**< 4k byte alignment shift (to a power of 2)*/ } lac_aligment_shift_t; /** ***************************************************************************** * @ingroup LacCommon * Alignment of a buffer. * * @description * This enum is used to indicate the alignment requirements of a buffer. * *****************************************************************************/ typedef enum lac_aligment_s { LAC_NO_ALIGNMENT = 0, /**< No alignment */ LAC_1BYTE_ALIGNMENT = 1, /**< 1 byte alignment */ LAC_8BYTE_ALIGNMENT = 8, /**< 8 byte alignment*/ LAC_64BYTE_ALIGNMENT = 64, /**< 64 byte alignment*/ LAC_4KBYTE_ALIGNMENT = 4096, /**< 4k byte alignment */ } lac_aligment_t; /** ***************************************************************************** * @ingroup LacCommon * Size of a buffer. * * @description * This enum is used to indicate the required size. * The buffer must be a multiple of the required size. * *****************************************************************************/ typedef enum lac_expected_size_s { LAC_NO_LENGTH_REQUIREMENTS = 0, /**< No requirement for size */ LAC_4KBYTE_MULTIPLE_REQUIRED = 4096, /**< 4k multiple requirement for size */ } lac_expected_size_t; #define LAC_OPTIMAL_ALIGNMENT_SHIFT LAC_64BYTE_ALIGNMENT_SHIFT /**< @ingroup LacCommon * optimal alignment to a power of 2 */ #define LAC_SHIFT_8 (1 << LAC_8BYTE_ALIGNMENT_SHIFT) /**< shift by 8 bits */ #define LAC_SHIFT_24 \ ((1 << LAC_8BYTE_ALIGNMENT_SHIFT) + (1 << LAC_16BYTE_ALIGNMENT_SHIFT)) /**< shift by 24 bits */ #define LAC_MAX_16_BIT_VALUE ((1 << 16) - 1) /**< @ingroup LacCommon * maximum value a 16 bit type can hold */ /** ******************************************************************************* * @ingroup LacCommon * This macro can be used to avoid an unused variable warning from the * compiler * * @param[in] variable unused variable * ******************************************************************************/ #define LAC_UNUSED_VARIABLE(x) (void)(x) /** ******************************************************************************* * @ingroup LacCommon * This macro checks if an address is aligned to the specified power of 2 * Returns 0 if alignment is ok, or non-zero otherwise * * @param[in] address the address we are checking * * @param[in] alignment the byte alignment to check (specified as power of 2) * ******************************************************************************/ #define LAC_ADDRESS_ALIGNED(address, alignment) \ (!((LAC_ARCH_UINT)(address) & ((1 << (alignment)) - 1))) /** ******************************************************************************* * @ingroup LacCommon * This macro rounds up a number to a be a multiple of the alignment when * the alignment is a power of 2. * * @param[in] num Number * @param[in] align Alignment (must be a power of 2) * ******************************************************************************/ #define LAC_ALIGN_POW2_ROUNDUP(num, align) (((num) + (align)-1) & ~((align)-1)) /** ******************************************************************************* * @ingroup LacCommon * This macro generates a bit mask to select a particular bit * * @param[in] bitPos Bit position to select * ******************************************************************************/ #define LAC_BIT(bitPos) (0x1 << (bitPos)) /** ******************************************************************************* * @ingroup LacCommon * This macro converts a size in bits to the equivalent size in bytes, * using a bit shift to divide by 8 * * @param[in] x size in bits * ******************************************************************************/ #define LAC_BITS_TO_BYTES(x) ((x) >> 3) /** ******************************************************************************* * @ingroup LacCommon * This macro converts a size in bytes to the equivalent size in bits, * using a bit shift to multiply by 8 * * @param[in] x size in bytes * ******************************************************************************/ #define LAC_BYTES_TO_BITS(x) ((x) << 3) /** ******************************************************************************* * @ingroup LacCommon * This macro converts a size in bytes to the equivalent size in longwords, * using a bit shift to divide by 4 * * @param[in] x size in bytes * ******************************************************************************/ #define LAC_BYTES_TO_LONGWORDS(x) ((x) >> 2) /** ******************************************************************************* * @ingroup LacCommon * This macro converts a size in longwords to the equivalent size in bytes, * using a bit shift to multiply by 4 * * @param[in] x size in long words * ******************************************************************************/ #define LAC_LONGWORDS_TO_BYTES(x) ((x) << 2) /** ******************************************************************************* * @ingroup LacCommon * This macro converts a size in bytes to the equivalent size in quadwords, * using a bit shift to divide by 8 * * @param[in] x size in bytes * ******************************************************************************/ #define LAC_BYTES_TO_QUADWORDS(x) (((x) >> 3) + (((x) % 8) ? 1 : 0)) /** ******************************************************************************* * @ingroup LacCommon * This macro converts a size in quadwords to the equivalent size in bytes, * using a bit shift to multiply by 8 * * @param[in] x size in quad words * ******************************************************************************/ #define LAC_QUADWORDS_TO_BYTES(x) ((x) << 3) - /******************************************************************************/ /* ******************************************************************************* * Mutex Macros ******************************************************************************* */ /** ******************************************************************************* * @ingroup LacCommon * This macro tries to acquire a mutex and returns the status * * @param[in] pLock Pointer to Lock * @param[in] timeout Timeout * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with Mutex ******************************************************************************/ #define LAC_LOCK_MUTEX(pLock, timeout) \ ((CPA_STATUS_SUCCESS != qatUtilsMutexLock((pLock), (timeout))) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro unlocks a mutex and returns the status * * @param[in] pLock Pointer to Lock * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with Mutex ******************************************************************************/ #define LAC_UNLOCK_MUTEX(pLock) \ ((CPA_STATUS_SUCCESS != qatUtilsMutexUnlock((pLock))) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro initialises a mutex and returns the status * * @param[in] pLock Pointer to Lock * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with Mutex ******************************************************************************/ #define LAC_INIT_MUTEX(pLock) \ ((CPA_STATUS_SUCCESS != qatUtilsMutexInit((pLock))) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro destroys a mutex and returns the status * * @param[in] pLock Pointer to Lock * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with Mutex ******************************************************************************/ #define LAC_DESTROY_MUTEX(pLock) \ ((CPA_STATUS_SUCCESS != qatUtilsMutexDestroy((pLock))) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro calls a trylock on a mutex * * @param[in] pLock Pointer to Lock * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with Mutex ******************************************************************************/ #define LAC_TRYLOCK_MUTEX(pLock) \ ((CPA_STATUS_SUCCESS != \ qatUtilsMutexTryLock((pLock), QAT_UTILS_WAIT_NONE)) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /* ******************************************************************************* * Semaphore Macros ******************************************************************************* */ /** ******************************************************************************* * @ingroup LacCommon * This macro waits on a semaphore and returns the status * * @param[in] sid The semaphore * @param[in] timeout Timeout * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with semaphore ******************************************************************************/ #define LAC_WAIT_SEMAPHORE(sid, timeout) \ ((CPA_STATUS_SUCCESS != qatUtilsSemaphoreWait(&sid, (timeout))) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro checks a semaphore and returns the status * * @param[in] sid The semaphore * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with semaphore ******************************************************************************/ #define LAC_CHECK_SEMAPHORE(sid) \ ((CPA_STATUS_SUCCESS != qatUtilsSemaphoreTryWait(&sid)) ? \ CPA_STATUS_RETRY : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro post a semaphore and returns the status * * @param[in] sid The semaphore * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with semaphore ******************************************************************************/ #define LAC_POST_SEMAPHORE(sid) \ ((CPA_STATUS_SUCCESS != qatUtilsSemaphorePost(&sid)) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro initialises a semaphore and returns the status * * @param[in] sid The semaphore * @param[in] semValue Initial semaphore value * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with semaphore ******************************************************************************/ #define LAC_INIT_SEMAPHORE(sid, semValue) \ ((CPA_STATUS_SUCCESS != qatUtilsSemaphoreInit(&sid, semValue)) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /** ******************************************************************************* * @ingroup LacCommon * This macro destroys a semaphore and returns the status * * @param[in] sid The semaphore * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_RESOURCE Error with semaphore ******************************************************************************/ #define LAC_DESTROY_SEMAPHORE(sid) \ ((CPA_STATUS_SUCCESS != qatUtilsSemaphoreDestroy(&sid)) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) /* ******************************************************************************* * Spinlock Macros ******************************************************************************* */ typedef struct mtx *lac_lock_t; #define LAC_SPINLOCK_INIT(lock) \ ((CPA_STATUS_SUCCESS != qatUtilsLockInit(lock)) ? \ CPA_STATUS_RESOURCE : \ CPA_STATUS_SUCCESS) #define LAC_SPINLOCK(lock) \ ({ \ (void)qatUtilsLock(lock); \ }) #define LAC_SPINUNLOCK(lock) \ ({ \ (void)qatUtilsUnlock(lock); \ }) #define LAC_SPINLOCK_DESTROY(lock) \ ({ \ (void)qatUtilsLockDestroy(lock); \ }) #define LAC_CONST_PTR_CAST(castee) ((void *)(LAC_ARCH_UINT)(castee)) #define LAC_CONST_VOLATILE_PTR_CAST(castee) ((void *)(LAC_ARCH_UINT)(castee)) /* Type of ring */ #define SAL_RING_TYPE_NONE 0 #define SAL_RING_TYPE_A_SYM_HI 1 #define SAL_RING_TYPE_A_SYM_LO 2 #define SAL_RING_TYPE_A_ASYM 3 #define SAL_RING_TYPE_B_SYM_HI 4 #define SAL_RING_TYPE_B_SYM_LO 5 #define SAL_RING_TYPE_B_ASYM 6 #define SAL_RING_TYPE_DC 7 #define SAL_RING_TYPE_ADMIN 8 #define SAL_RING_TYPE_TRNG 9 /* Maps Ring Service to generic service type */ static inline icp_adf_ringInfoService_t lac_getRingType(int type) { switch (type) { case SAL_RING_TYPE_NONE: return ICP_ADF_RING_SERVICE_0; case SAL_RING_TYPE_A_SYM_HI: return ICP_ADF_RING_SERVICE_1; case SAL_RING_TYPE_A_SYM_LO: return ICP_ADF_RING_SERVICE_2; case SAL_RING_TYPE_A_ASYM: return ICP_ADF_RING_SERVICE_3; case SAL_RING_TYPE_B_SYM_HI: return ICP_ADF_RING_SERVICE_4; case SAL_RING_TYPE_B_SYM_LO: return ICP_ADF_RING_SERVICE_5; case SAL_RING_TYPE_B_ASYM: return ICP_ADF_RING_SERVICE_6; case SAL_RING_TYPE_DC: return ICP_ADF_RING_SERVICE_7; case SAL_RING_TYPE_ADMIN: return ICP_ADF_RING_SERVICE_8; case SAL_RING_TYPE_TRNG: return ICP_ADF_RING_SERVICE_9; default: return ICP_ADF_RING_SERVICE_0; } return ICP_ADF_RING_SERVICE_0; } /* Maps generic service type to Ring Service type */ static inline int lac_getServiceType(icp_adf_ringInfoService_t type) { switch (type) { case ICP_ADF_RING_SERVICE_0: return SAL_RING_TYPE_NONE; case ICP_ADF_RING_SERVICE_1: return SAL_RING_TYPE_A_SYM_HI; case ICP_ADF_RING_SERVICE_2: return SAL_RING_TYPE_A_SYM_LO; case ICP_ADF_RING_SERVICE_3: return SAL_RING_TYPE_A_ASYM; case ICP_ADF_RING_SERVICE_4: return SAL_RING_TYPE_B_SYM_HI; case ICP_ADF_RING_SERVICE_5: return SAL_RING_TYPE_B_SYM_LO; case ICP_ADF_RING_SERVICE_6: return SAL_RING_TYPE_B_ASYM; case ICP_ADF_RING_SERVICE_7: return SAL_RING_TYPE_DC; case ICP_ADF_RING_SERVICE_8: return SAL_RING_TYPE_ADMIN; default: return SAL_RING_TYPE_NONE; } return SAL_RING_TYPE_NONE; } #endif /* LAC_COMMON_H */ diff --git a/sys/dev/qat/qat_api/common/include/lac_hooks.h b/sys/dev/qat/qat_api/common/include/lac_hooks.h index 37ea65396086..6386eed53f8c 100644 --- a/sys/dev/qat/qat_api/common/include/lac_hooks.h +++ b/sys/dev/qat/qat_api/common/include/lac_hooks.h @@ -1,233 +1,233 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ******************************************************************************* * @file lac_hooks.h * * @defgroup LacHooks Hooks * * @ingroup LacCommon * * Component Init/Shutdown functions. These are: - * - an init function which is called during the intialisation sequence, + * - an init function which is called during the initialisation sequence, * - a shutdown function which is called by the overall shutdown function, * ******************************************************************************/ #ifndef LAC_HOOKS_H #define LAC_HOOKS_H /* ******************************************************************************** * Include public/global header files ******************************************************************************** */ #include "cpa.h" /* ******************************************************************************** * Include private header files ******************************************************************************** */ /******************************************************************************/ /** ******************************************************************************* * @ingroup LacHooks * This function initialises the Large Number (ModExp and ModInv) module * * @description * This function clears the Large Number statistics * * @param[in] instanceHandle * ******************************************************************************/ CpaStatus LacLn_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function frees statistics array for Large Number module * * @description * This function frees statistics array for Large Number module * * @param[in] instanceHandle * ******************************************************************************/ void LacLn_StatsFree(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function initialises the Prime module * * @description * This function clears the Prime statistics * * @param[in] instanceHandle * ******************************************************************************/ CpaStatus LacPrime_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function frees the Prime module statistics array * * @description * This function frees the Prime module statistics array * * @param[in] instanceHandle * ******************************************************************************/ void LacPrime_StatsFree(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function initialises the DSA module * * @param[in] instanceHandle * * @description * This function clears the DSA statistics * ******************************************************************************/ CpaStatus LacDsa_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function frees the DSA module statistics array * * @param[in] instanceHandle * * @description * This function frees the DSA statistics array * ******************************************************************************/ void LacDsa_StatsFree(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function initialises the Diffie Hellmann module * * @description * This function initialises the Diffie Hellman statistics * * @param[in] instanceHandle * ******************************************************************************/ CpaStatus LacDh_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function frees the Diffie Hellmann module statistics * * @description * This function frees the Diffie Hellmann module statistics * * @param[in] instanceHandle * ******************************************************************************/ void LacDh_StatsFree(CpaInstanceHandle instanceHandle); /** ****************************************************************************** * @ingroup LacSymKey * This function registers the callback handlers to SSL/TLS and MGF, * allocates resources that are needed for the component and clears * the stats. * * @param[in] instanceHandle * * @retval CPA_STATUS_SUCCESS Status Success * @retval CPA_STATUS_FAIL General failure * @retval CPA_STATUS_RESOURCE Resource allocation failure * *****************************************************************************/ CpaStatus LacSymKey_Init(CpaInstanceHandle instanceHandle); /** ****************************************************************************** * @ingroup LacSymKey * This function frees up resources obtained by the key gen component * and clears the stats * * @param[in] instanceHandle * * @retval CPA_STATUS_SUCCESS Status Success * *****************************************************************************/ CpaStatus LacSymKey_Shutdown(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function initialises the RSA module * * @description * This function clears the RSA statistics * * @param[in] instanceHandle * ******************************************************************************/ CpaStatus LacRsa_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function frees the RSA module statistics * * @description * This function frees the RSA module statistics * * @param[in] instanceHandle * ******************************************************************************/ void LacRsa_StatsFree(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function initialises the EC module * * @description * This function clears the EC statistics * * @param[in] instanceHandle * ******************************************************************************/ CpaStatus LacEc_Init(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacHooks * This function frees the EC module stats array * * @description * This function frees the EC module stats array * * @param[in] instanceHandle * ******************************************************************************/ void LacEc_StatsFree(CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacSymNrbg * Initialise the NRBG module * * @description * This function registers NRBG callback handlers. * * *****************************************************************************/ void LacSymNrbg_Init(void); #endif /* LAC_HOOKS_H */ diff --git a/sys/dev/qat/qat_api/common/include/lac_mem.h b/sys/dev/qat/qat_api/common/include/lac_mem.h index ce4c8045a27c..5392606a4c49 100644 --- a/sys/dev/qat/qat_api/common/include/lac_mem.h +++ b/sys/dev/qat/qat_api/common/include/lac_mem.h @@ -1,576 +1,576 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_mem.h * * @defgroup LacMem Memory * * @ingroup LacCommon * * Memory re-sizing functions and memory accessor macros. * ***************************************************************************/ #ifndef LAC_MEM_H #define LAC_MEM_H /*************************************************************************** * Include header files ***************************************************************************/ #include "cpa.h" #include "qat_utils.h" #include "lac_common.h" /** ******************************************************************************* * @ingroup LacMem * These macros are used to Endian swap variables from IA to QAT. * * @param[out] x The variable to be swapped. * * @retval none ******************************************************************************/ #if (BYTE_ORDER == LITTLE_ENDIAN) #define LAC_MEM_WR_64(x) QAT_UTILS_HOST_TO_NW_64(x) #define LAC_MEM_WR_32(x) QAT_UTILS_HOST_TO_NW_32(x) #define LAC_MEM_WR_16(x) QAT_UTILS_HOST_TO_NW_16(x) #define LAC_MEM_RD_64(x) QAT_UTILS_NW_TO_HOST_64(x) #define LAC_MEM_RD_32(x) QAT_UTILS_NW_TO_HOST_32(x) #define LAC_MEM_RD_16(x) QAT_UTILS_NW_TO_HOST_16(x) #else #define LAC_MEM_WR_64(x) (x) #define LAC_MEM_WR_32(x) (x) #define LAC_MEM_WR_16(x) (x) #define LAC_MEM_RD_64(x) (x) #define LAC_MEM_RD_32(x) (x) #define LAC_MEM_RD_16(x) (x) #endif /* ******************************************************************************* * Shared Memory Macros (memory accessible by Acceleration Engines, e.g. QAT) ******************************************************************************* */ /** ******************************************************************************* * @ingroup LacMem * This macro can be used to write to a variable that will be read by the * QAT. The macro will automatically detect the size of the target variable and * will select the correct method for performing the write. The data is cast to * the type of the field that it will be written to. * This macro swaps data if required. * * @param[out] var The variable to be written. Can be a field of a struct. * * @param[in] data The value to be written. Will be cast to the size of the * target. * * @retval none ******************************************************************************/ #define LAC_MEM_SHARED_WRITE_SWAP(var, data) \ do { \ switch (sizeof(var)) { \ case 1: \ (var) = (Cpa8U)(data); \ break; \ case 2: \ (var) = (Cpa16U)(data); \ (var) = LAC_MEM_WR_16(((Cpa16U)var)); \ break; \ case 4: \ (var) = (Cpa32U)(data); \ (var) = LAC_MEM_WR_32(((Cpa32U)var)); \ break; \ case 8: \ (var) = (Cpa64U)(data); \ (var) = LAC_MEM_WR_64(((Cpa64U)var)); \ break; \ default: \ break; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacMem * This macro can be used to read a variable that was written by the QAT. * The macro will automatically detect the size of the data to be read and will * select the correct method for performing the read. The value read from the * variable is cast to the size of the data type it will be stored in. * This macro swaps data if required. * * @param[in] var The variable to be read. Can be a field of a struct. * * @param[out] data The variable to hold the result of the read. Data read * will be cast to the size of this variable * * @retval none ******************************************************************************/ #define LAC_MEM_SHARED_READ_SWAP(var, data) \ do { \ switch (sizeof(var)) { \ case 1: \ (data) = (var); \ break; \ case 2: \ (data) = LAC_MEM_RD_16(((Cpa16U)var)); \ break; \ case 4: \ (data) = LAC_MEM_RD_32(((Cpa32U)var)); \ break; \ case 8: \ (data) = LAC_MEM_RD_64(((Cpa64U)var)); \ break; \ default: \ break; \ } \ } while (0) /** ******************************************************************************* * @ingroup LacMem * This macro can be used to write a pointer to a QAT request. The fields * for pointers in the QAT request and response messages are always 64 bits * * @param[out] var The variable to be written to. Can be a field of a struct. * * @param[in] data The value to be written. Will be cast to size of target * variable * * @retval none ******************************************************************************/ /* cast pointer to scalar of same size of the native pointer */ #define LAC_MEM_SHARED_WRITE_FROM_PTR(var, data) \ ((var) = (Cpa64U)(LAC_ARCH_UINT)(data)) /* Note: any changes to this macro implementation should also be made to the * similar LAC_MEM_CAST_PTR_TO_UINT64 macro */ /** ******************************************************************************* * @ingroup LacMem * This macro can be used to read a pointer from a QAT response. The fields * for pointers in the QAT request and response messages are always 64 bits * * @param[in] var The variable to be read. Can be a field of a struct. * * @param[out] data The variable to hold the result of the read. Data read * will be cast to the size of this variable * * @retval none ******************************************************************************/ /* Cast back to native pointer */ #define LAC_MEM_SHARED_READ_TO_PTR(var, data) \ ((data) = (void *)(LAC_ARCH_UINT)(var)) /** ******************************************************************************* * @ingroup LacMem * This macro safely casts a pointer to a Cpa64U type. * * @param[in] pPtr The pointer to be cast. * * @retval pointer cast to Cpa64U ******************************************************************************/ #define LAC_MEM_CAST_PTR_TO_UINT64(pPtr) ((Cpa64U)(pPtr)) /** ******************************************************************************* * @ingroup LacMem * This macro uses an QAT Utils macro to convert from a virtual address to *a * physical address for internally allocated memory. * * @param[in] pVirtAddr The address to be converted. * * @retval The converted physical address ******************************************************************************/ #define LAC_OS_VIRT_TO_PHYS_INTERNAL(pVirtAddr) \ (QAT_UTILS_MMU_VIRT_TO_PHYS(pVirtAddr)) /** ******************************************************************************* * @ingroup LacMem * This macro should be called on all externally allocated memory it calls * SalMem_virt2PhysExternal function which allows a user * to set the virt2phys function used by an instance. * Defaults to virt to phys for kernel. * * @param[in] genService Generic sal_service_t structure. * @param[in] pVirtAddr The address to be converted. * * @retval The converted physical address ******************************************************************************/ #define LAC_OS_VIRT_TO_PHYS_EXTERNAL(genService, pVirtAddr) \ ((SalMem_virt2PhysExternal(pVirtAddr, &(genService)))) /** ******************************************************************************* * @ingroup LacMem * This macro can be used to write an address variable that will be read by * the QAT. The macro will perform the necessary virt2phys address translation * This macro is only to be called on memory allocated internally by the driver. * * @param[out] var The address variable to write. Can be a field of a struct. * * @param[in] pPtr The pointer variable to containing the address to be * written * * @retval none ******************************************************************************/ #define LAC_MEM_SHARED_WRITE_VIRT_TO_PHYS_PTR_INTERNAL(var, pPtr) \ do { \ Cpa64U physAddr = 0; \ physAddr = LAC_MEM_CAST_PTR_TO_UINT64( \ LAC_OS_VIRT_TO_PHYS_INTERNAL(pPtr)); \ var = physAddr; \ } while (0) /** ******************************************************************************* * @ingroup LacMem * This macro can be used to write an address variable that will be read by * the QAT. The macro will perform the necessary virt2phys address translation * This macro is to be used on memory allocated externally by the user. It calls * the user supplied virt2phys address translation. * * @param[in] pService The pointer to the service * @param[out] var The address variable to write. Can be a field of a struct * @param[in] pPtr The pointer variable to containing the address to be * written * * @retval none ******************************************************************************/ #define LAC_MEM_SHARED_WRITE_VIRT_TO_PHYS_PTR_EXTERNAL(pService, var, pPtr) \ do { \ Cpa64U physAddr = 0; \ physAddr = LAC_MEM_CAST_PTR_TO_UINT64( \ LAC_OS_VIRT_TO_PHYS_EXTERNAL(pService, pPtr)); \ var = physAddr; \ } while (0) /* ******************************************************************************* * OS Memory Macros ******************************************************************************* */ /** ******************************************************************************* * @ingroup LacMem * This function and associated macro allocates the memory for the given * size and stores the address of the memory allocated in the pointer. * * @param[out] ppMemAddr address of pointer where address will be stored * @param[in] sizeBytes the size of the memory to be allocated. * * @retval CPA_STATUS_RESOURCE Macro failed to allocate Memory * @retval CPA_STATUS_SUCCESS Macro executed successfully * ******************************************************************************/ static __inline CpaStatus LacMem_OsMemAlloc(void **ppMemAddr, Cpa32U sizeBytes) { *ppMemAddr = malloc(sizeBytes, M_QAT, M_WAITOK); return CPA_STATUS_SUCCESS; } /** ******************************************************************************* * @ingroup LacMem * This function and associated macro allocates the contiguous * memory for the given * size and stores the address of the memory allocated in the pointer. * * @param[out] ppMemAddr address of pointer where address will be stored * @param[in] sizeBytes the size of the memory to be allocated. * @param[in] alignmentBytes the alignment * @param[in] node node to allocate from * * @retval CPA_STATUS_RESOURCE Macro failed to allocate Memory * @retval CPA_STATUS_SUCCESS Macro executed successfully * ******************************************************************************/ static __inline CpaStatus LacMem_OsContigAlignMemAlloc(void **ppMemAddr, Cpa32U sizeBytes, Cpa32U alignmentBytes, Cpa32U node) { if ((alignmentBytes & (alignmentBytes - 1)) != 0) /* if is not power of 2 */ { *ppMemAddr = NULL; QAT_UTILS_LOG("alignmentBytes MUST be the power of 2\n"); return CPA_STATUS_INVALID_PARAM; } *ppMemAddr = qatUtilsMemAllocContiguousNUMA(sizeBytes, node, alignmentBytes); if (NULL == *ppMemAddr) { return CPA_STATUS_RESOURCE; } return CPA_STATUS_SUCCESS; } /** ******************************************************************************* * @ingroup LacMem * Macro from the malloc() function * ******************************************************************************/ #define LAC_OS_MALLOC(sizeBytes) malloc(sizeBytes, M_QAT, M_WAITOK) /** ******************************************************************************* * @ingroup LacMem * Macro from the LacMem_OsContigAlignMemAlloc function * ******************************************************************************/ #define LAC_OS_CAMALLOC(ppMemAddr, sizeBytes, alignmentBytes, node) \ LacMem_OsContigAlignMemAlloc((void *)ppMemAddr, \ sizeBytes, \ alignmentBytes, \ node) /** ******************************************************************************* * @ingroup LacMem * Macro for declaration static const unsigned int constant. One provides * the compilation time computation with the highest bit set in the * sizeof(TYPE) value. The constant is being put by the linker by default in * .rodata section * * E.g. Statement LAC_DECLARE_HIGHEST_BIT_OF(lac_mem_blk_t) * results in following entry: * static const unsigned int highest_bit_of_lac_mem_blk_t = 3 * - * CAUTION!! + * CAUTION! * Macro is prepared only for type names NOT-containing ANY * special characters. Types as amongst others: * - void * * - unsigned long * - unsigned int * are strictly forbidden and will result in compilation error. * Use typedef to provide one-word type name for MACRO's usage. ******************************************************************************/ #define LAC_DECLARE_HIGHEST_BIT_OF(TYPE) \ static const unsigned int highest_bit_of_##TYPE = \ (sizeof(TYPE) & 0x80000000 ? 31 : (sizeof(TYPE) & 0x40000000 ? 30 : (sizeof(TYPE) & 0x20000000 ? 29 : ( \ sizeof(TYPE) & 0x10000000 ? 28 : ( \ sizeof(TYPE) & 0x08000000 ? 27 : ( \ sizeof(TYPE) & 0x04000000 ? 26 : ( \ sizeof(TYPE) & 0x02000000 ? 25 : ( \ sizeof(TYPE) & 0x01000000 ? 24 : ( \ sizeof(TYPE) & 0x00800000 ? \ 23 : \ (sizeof(TYPE) & 0x00400000 ? 22 : ( \ sizeof( \ TYPE) & \ 0x00200000 ? \ 21 : \ ( \ sizeof(TYPE) & 0x00100000 ? 20 : (sizeof(TYPE) & 0x00080000 ? 19 : ( \ sizeof( \ TYPE) & \ 0x00040000 ? \ 18 : \ ( \ sizeof(TYPE) & 0x00020000 ? 17 : ( \ sizeof(TYPE) & 0x00010000 ? 16 : (sizeof(TYPE) & \ 0x00008000 ? \ 15 : \ (sizeof(TYPE) & 0x00004000 ? 14 : ( \ sizeof(TYPE) & 0x00002000 ? 13 : \ ( \ sizeof(TYPE) & 0x00001000 ? 12 : ( \ sizeof(TYPE) & 0x00000800 ? 11 : ( \ sizeof(TYPE) & 0x00000400 ? 10 : \ ( \ sizeof(TYPE) & \ 0x00000200 ? \ 9 : \ (sizeof( \ TYPE) & \ 0x00000100 ? \ 8 : \ (sizeof(TYPE) & 0x00000080 ? 7 : \ ( \ sizeof(TYPE) & 0x00000040 ? \ 6 : \ ( \ sizeof(TYPE) & 0x00000020 ? 5 : \ ( \ sizeof(TYPE) & 0x00000010 ? 4 : \ ( \ sizeof(TYPE) & 0x00000008 ? 3 : \ ( \ sizeof(TYPE) & 0x00000004 ? 2 : \ ( \ sizeof(TYPE) & 0x00000002 ? 1 : ( \ sizeof(TYPE) & 0x00000001 ? 0 : 32))))))))))))))))) /*16*/))))))))))))))) /* 31 */ /** ******************************************************************************* * @ingroup LacMem * This function and associated macro frees the memory at the given address * and resets the pointer to NULL * * @param[out] ppMemAddr address of pointer where mem address is stored. * If pointer is NULL, the function will exit silently * * @retval void * ******************************************************************************/ static __inline void LacMem_OsMemFree(void **ppMemAddr) { free(*ppMemAddr, M_QAT); *ppMemAddr = NULL; } /** ******************************************************************************* * @ingroup LacMem * This function and associated macro frees the contiguous memory at the * given address and resets the pointer to NULL * * @param[out] ppMemAddr address of pointer where mem address is stored. * If pointer is NULL, the function will exit silently * * @retval void * ******************************************************************************/ static __inline void LacMem_OsContigAlignMemFree(void **ppMemAddr) { if (NULL != *ppMemAddr) { qatUtilsMemFreeNUMA(*ppMemAddr); *ppMemAddr = NULL; } } #define LAC_OS_FREE(pMemAddr) LacMem_OsMemFree((void *)&pMemAddr) #define LAC_OS_CAFREE(pMemAddr) LacMem_OsContigAlignMemFree((void *)&pMemAddr) /** ******************************************************************************* * @ingroup LacMem * Copies user data to a working buffer of the correct size (required by * PKE services) * * @description * This function produces a correctly sized working buffer from the input * user buffer. If the original buffer is too small a new buffer shall * be allocated and memory is copied (left padded with zeros to the *required * length). * * The returned working buffer is guaranteed to be of the desired size for * QAT. * * When this function is called pInternalMem describes the user_buffer and * when the function returns pInternalMem describes the working buffer. * This is because pInternalMem describes the memory that will be sent to * QAT. * - * The caller must keep the original buffer pointer. The alllocated buffer + * The caller must keep the original buffer pointer. The allocated buffer *is * freed (as necessary) using icp_LacBufferRestore(). * * @param[in] instanceHandle Handle to crypto instance so pke_resize mem pool *can * be located * @param[in] pUserBuffer Pointer on the user buffer * @param[in] userLen length of the user buffer * @param[in] workingLen length of the working (correctly sized) buffer * @param[in/out] pInternalMem pointer to boolean if TRUE on input then * user_buffer is internally allocated memory * if false then it is externally allocated. * This value gets updated by the function * if the returned pointer references internally * allocated memory. * * @return a pointer to the working (correctly sized) buffer or NULL if the * allocation failed * * @note the working length cannot be smaller than the user buffer length * * @warning the working buffer may be the same or different from the original * user buffer; the caller should make no assumptions in this regard * * @see icp_LacBufferRestore() * ******************************************************************************/ Cpa8U *icp_LacBufferResize(CpaInstanceHandle instanceHandle, Cpa8U *pUserBuffer, Cpa32U userLen, Cpa32U workingLen, CpaBoolean *pInternalMemory); /** ******************************************************************************* * @ingroup LacMem * Restores a user buffer * * @description * This function restores a user buffer and releases its * corresponding working buffer. The working buffer, assumed to be * previously obtained using icp_LacBufferResize(), is freed as necessary. * * The contents are copied in the process. * * @note the working length cannot be smaller than the user buffer length * * @param[out] pUserBuffer Pointer on the user buffer * @param[in] userLen length of the user buffer * @param[in] pWorkingBuffer Pointer on the working buffer * @param[in] workingLen working buffer length * @param[in] copyBuf if set _TRUE the data in the workingBuffer * will be copied to the userBuffer before the * workingBuffer is freed. * * @return the status of the operation * * @see icp_LacBufferResize() * ******************************************************************************/ CpaStatus icp_LacBufferRestore(Cpa8U *pUserBuffer, Cpa32U userLen, Cpa8U *pWorkingBuffer, Cpa32U workingLen, CpaBoolean copyBuf); /** ******************************************************************************* * @ingroup LacMem * Uses an instance specific user supplied virt2phys function to convert a * virtual address to a physical address. * * @description * Uses an instance specific user supplied virt2phys function to convert a * virtual address to a physical address. A client of QA API can set the * virt2phys function for an instance by using the * cpaXxSetAddressTranslation() function. If the client does not set the * virt2phys function and the instance is in kernel space then OS specific * virt2phys function will be used. In user space the virt2phys function * MUST be set by the user. * * @param[in] pVirtAddr the virtual addr to be converted * @param[in] pServiceGen Pointer on the sal_service_t structure * so client supplied virt2phys function can be * called. * * @return the physical address * ******************************************************************************/ CpaPhysicalAddr SalMem_virt2PhysExternal(void *pVirtAddr, void *pServiceGen); #endif /* LAC_MEM_H */ diff --git a/sys/dev/qat/qat_api/common/include/lac_mem_pools.h b/sys/dev/qat/qat_api/common/include/lac_mem_pools.h index cbc3c787637a..406516509ed2 100644 --- a/sys/dev/qat/qat_api/common/include/lac_mem_pools.h +++ b/sys/dev/qat/qat_api/common/include/lac_mem_pools.h @@ -1,277 +1,277 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_mem_pools.h * * @defgroup LacMemPool Memory Pool Mgmt * * @ingroup LacCommon * * Memory Pool creation and mgmt functions * * @lld_start * @lld_overview * This component is designed as a set of utility functions for the * creation of pre-allocated memory pools. Each pool will be created using OS * memory with a user specified number of elements, element size and element - * alignment(alignmnet is at byte granularity). + * alignment(alignment is at byte granularity). * @lld_dependencies * These utilities rely on QAT Utils for locking mechanisms and memory - *allocation + * allocation * @lld_initialisation * Pool creation needs to be done by each component. There is no specific * initialisation required for this feature. * @lld_module_algorithms - * The following is a diagram of how the memory is layed out for each block + * The following is a diagram of how the memory is laid out for each block * in a pool. Each element must be aligned on the boundary requested for in the * create call. In order to hide the management of the pools from the user, * the memory block data is hidden prior to the * data pointer. This way it can be accessed easily on a free call with pointer - * arithmatic. The Padding at the start is simply there for alignment and is + * arithmetic. The Padding at the start is simply there for alignment and is * unused in the pools. * * ------------------------------------------------------- * * |Padding |lac_mem_blk_t | client memory | * * @lld_process_context * @lld_end ***************************************************************************/ /** ******************************************************************************* * @ingroup LacMemPool * * ******************************************************************************/ /***************************************************************************/ #ifndef LAC_MEM_POOLS_H #define LAC_MEM_POOLS_H #include "cpa.h" #include "lac_common.h" struct lac_mem_pool_hdr_s; /**< @ingroup LacMemPool * This is a forward declaration of the structure type lac_mem_pool_hdr_s */ typedef LAC_ARCH_UINT lac_memory_pool_id_t; /**< @ingroup LacMemPool * Pool ID type to be used by all clients */ /**< @ingroup LacMemPool * This structure is used to link each memory block in the created pool * together and contain the necessary information for deletion of the block */ typedef struct lac_mem_blk_s { CpaPhysicalAddr physDataPtr; /**< physical address of data pointer for client */ void *pMemAllocPtr; /**< virtual address of the memory block actually allocated */ CpaBoolean isInUse; /**< indicates if the pool item is in use */ struct lac_mem_blk_s *pNext; - /**< link to next blcok in the pool */ + /**< link to next block in the pool */ struct lac_mem_pool_hdr_s *pPoolID; /**< identifier of the pool that this block was allocated from */ } lac_mem_blk_t; #define LAC_MEM_POOL_VIRT_TO_PHYS(pVirtAddr) \ (((lac_mem_blk_t *)((LAC_ARCH_UINT)pVirtAddr - sizeof(lac_mem_blk_t))) \ ->physDataPtr) /**< @ingroup LacMemPool - * macro for retreiving the physical address of the memory block. */ + * macro for retrieving the physical address of the memory block. */ #define LAC_MEM_POOL_INIT_POOL_ID 0 /**< @ingroup LacMemPool * macro which defines the valid initialisation value for a pool ID. This is * used as a level of abstraction for the user of this interface */ /** ******************************************************************************* * @ingroup LacMemPool * This function creates a memory pool containing a specified number of * elements of specific size and byte alignment. This function is not reentrant * or thread safe and is only intended to be called during initialisation. * * @blocking * Yes * @reentrant * No * @threadSafe * No * @param[out] poolID on successful creation of a pool this will * be the ID used for all subsequent accesses * @param[in] poolName The name of the memory pool * @param[in] numElementsInPool number of elements to provision in the pool * @param[in] blkSizeInBytes size in bytes of each element in the pool * @param[in] blkAlignmentInBytes byte alignment required for each element * @param[in] trackMemory track the memory in use by this pool * @param[in] node node to allocate from * * @retval CPA_STATUS_INVALID_PARAM invalid input parameter * @retval CPA_STATUS_RESOURCE error in provisioning resources * @retval CPA_STATUS_SUCCESS function executed successfully * ******************************************************************************/ CpaStatus Lac_MemPoolCreate(lac_memory_pool_id_t *poolID, char *poolName, unsigned int numElementsInPool, unsigned int blkSizeInBytes, unsigned int blkAlignmentInBytes, CpaBoolean trackMemory, Cpa32U node); /** ******************************************************************************* * @ingroup LacMemPool * This function will destroy the memory pool in it's current state. All memory * blocks which have been returned to the memory pool will be de-allocated and * the pool indetifier will be freed and assigned to NULL. It is the * responsibility of the pool creators to return all memory before a destroy or * memory will be leaked. * * @blocking * Yes * @reentrant * No * @threadSafe * No * @param[in] poolID Pointer to the memory pool to destroy * ******************************************************************************/ void Lac_MemPoolDestroy(lac_memory_pool_id_t poolID); /** ******************************************************************************* * @ingroup LacMemPool * This function allocates a block from the pool which has been previously * created. It does not check the validity of the pool Id prior to accessing the * pool. It is up to the calling code to ensure the value is correct. * * @blocking * Yes * @reentrant * Yes * @threadSafe * Yes * @param[in] poolID ID of the pool to allocate memory from * * @retval pointer to the memory which has been allocated from the pool * ******************************************************************************/ void *Lac_MemPoolEntryAlloc(lac_memory_pool_id_t poolID); /** ******************************************************************************* * @ingroup LacMemPool * This function de-allocates the memory passed in back to the pool from which * it was allocated. * * @blocking * Yes * @reentrant * Yes * @threadSafe * Yes * @param[in] entry memory address of the block to be freed * ******************************************************************************/ void Lac_MemPoolEntryFree(void *entry); /** ******************************************************************************* * @ingroup LacMemPool * This function returns the number of available entries in a particular pool * * @blocking * No * @reentrant * No * @threadSafe * No * @param[in] poolID ID of the pool * * @retval number of elements left for allocation from the pool * ******************************************************************************/ unsigned int Lac_MemPoolAvailableEntries(lac_memory_pool_id_t poolID); /** ******************************************************************************* * @ingroup LacMemPool * This function displays the stats associated with the memory pools * * @blocking * No * @reentrant * No * @threadSafe * No * ******************************************************************************/ void Lac_MemPoolStatsShow(void); /** ******************************************************************************* * @ingroup LacMemPool * This function initialises the physical addresses of the symmetric cookie * * @blocking * No * @reentrant * No * @threadSafe * No * @param[in] poolID ID of the pool * * @retval CPA_STATUS_FAIL function failed * @retval CPA_STATUS_SUCCESS function executed successfully * ******************************************************************************/ CpaStatus Lac_MemPoolInitSymCookiesPhyAddr(lac_memory_pool_id_t poolID); /** ******************************************************************************* * @ingroup LacMemPool * This function populates all PKE requests with instance constant parameters * * @blocking * No * @reentrant * No * @threadSafe * No * @param[in] poolID ID of the pool * @param[in] instanceHandle instanceHandle * * @retval CPA_STATUS_FAIL function failed * @retval CPA_STATUS_SUCCESS function executed successfully * ******************************************************************************/ CpaStatus Lac_MemPoolInitAsymCookies(lac_memory_pool_id_t poolID, CpaInstanceHandle instanceHandle); /** ******************************************************************************* * @ingroup LacMemPool * This function initialises the physical addresses of the compression cookie * * @blocking * No * @reentrant * No * @threadSafe * No * @param[in] poolID ID of the pool * * @retval CPA_STATUS_FAIL function failed * @retval CPA_STATUS_SUCCESS function executed successfully * ******************************************************************************/ CpaStatus Lac_MemPoolInitDcCookiePhyAddr(lac_memory_pool_id_t poolID); #endif /*LAC_MEM_POOLS_H*/ diff --git a/sys/dev/qat/qat_api/common/include/lac_sal.h b/sys/dev/qat/qat_api/common/include/lac_sal.h index 4c2e4347a16c..dff6fa8c7265 100644 --- a/sys/dev/qat/qat_api/common/include/lac_sal.h +++ b/sys/dev/qat/qat_api/common/include/lac_sal.h @@ -1,496 +1,496 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_sal.h * * @defgroup SalCtrl Service Access Layer Controller * * @ingroup SalCtrl * * @description * These functions are the functions to be executed for each state * of the state machine for each service. * *****************************************************************************/ #ifndef LAC_SAL_H #define LAC_SAL_H #include "cpa_cy_im.h" /** ******************************************************************************* * @ingroup SalCtrl * @description * This function allocates memory for a specific instance type. * Zeros this memory and sets the generic service section of * the instance memory. * * @context * This function is called from the generic services init. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] service The type of the service to be created * (e.g. CRYPTO) * @param[in] instance_num The logical instance number which will * run the service * @param[out] pObj Pointer to specific service instance memory * @retVal CPA_STATUS_SUCCESS Instance memory successfully allocated * @retVal CPA_STATUS_RESOURCE Instance memory not successfully allocated * @retVal CPA_STATUS_FAIL Unsupported service type * *****************************************************************************/ CpaStatus SalCtrl_ServiceCreate(sal_service_type_t service, Cpa32U instance_num, sal_service_t **pObj); /****************************************************************************** * @ingroup SalCtl * @description * This macro goes through the 'list' passed in as a parameter. For each - * element found in the list, it peforms a cast to the type of the element + * element found in the list, it performs a cast to the type of the element * given by the 'type' parameter. Finally, it calls the function given by * the 'function' parameter, passing itself and the device as parameters. * * In case of error (i.e. 'function' does not return _SUCCESS or _RETRY) * processing of the 'list' elements will stop and the status_ret will be * updated. * * In case of _RETRY status_ret will be updated but the 'list' * will continue to be processed. _RETRY is only expected when * 'function' is stop. * * @context * This macro is used by both the service and qat event handlers. * * @assumptions * None * @sideEffects * None * * @param[in] list The list of services or qats as a type of list_t * @param[in] type It identifies the type of the object inside the * list: service or qat * @param[in] device The ADF accelerator handle for the device * @param[in] function The function pointer to call * @param[in/out] status_ret If an error occurred (i.e. status returned from * function is not _SUCCESS) then status_ret is * overwritten with status returned from function. * *****************************************************************************/ #define SAL_FOR_EACH(list, type, device, function, status_ret) \ do { \ sal_list_t *curr_element = list; \ CpaStatus status_temp = CPA_STATUS_SUCCESS; \ typeof(type) *process = NULL; \ while (NULL != curr_element) { \ process = \ (typeof(type) *)SalList_getObject(curr_element); \ status_temp = process->function(device, process); \ if ((CPA_STATUS_SUCCESS != status_temp) && \ (CPA_STATUS_RETRY != status_temp)) { \ status_ret = status_temp; \ break; \ } else { \ if (CPA_STATUS_RETRY == status_temp) { \ status_ret = status_temp; \ } \ } \ curr_element = SalList_next(curr_element); \ } \ } while (0) /** ******************************************************************************* * @ingroup SalCtl * @description * This macro goes through the 'list' passed in as a parameter. For each - * element found in the list, it peforms a cast to the type of the element + * element found in the list, it performs a cast to the type of the element * given by the 'type' parameter. Finally, it checks the state of the * element and if it is in state 'state_check' then it calls the * function given by the 'function' parameter, passing itself * and the device as parameters. * If the element is not in 'state_check' it returns from the macro. * * In case of error (i.e. 'function' does not return _SUCCESS) * processing of the 'list' elements will continue. * * @context * This macro is used by both the service and qat event handlers. * * @assumptions * None * @sideEffects * None * * @param[in] list The list of services or qats as a type of list_t * @param[in] type It identifies the type of the object * inside the list: service or qat * @param[in] device The ADF accelerator handle for the device * @param[in] function The function pointer to call * @param[in] state_check The state to check for * *****************************************************************************/ #define SAL_FOR_EACH_STATE(list, type, device, function, state_check) \ do { \ sal_list_t *curr_element = list; \ typeof(type) *process = NULL; \ while (NULL != curr_element) { \ process = \ (typeof(type) *)SalList_getObject(curr_element); \ if (process->state == state_check) { \ process->function(device, process); \ } else { \ break; \ } \ curr_element = SalList_next(curr_element); \ } \ } while (0) /************************************************************************* * @ingroup SalCtrl * @description * This function is used to initialize an instance of crypto service. * It creates a crypto instance's memory pools. It calls ADF to create * its required transport handles. It calls the sub crypto service init * functions. Resets the stats. * * @context * This function is called from the SalCtrl_ServiceEventInit function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A crypto instance * *************************************************************************/ CpaStatus SalCtrl_CryptoInit(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to start an instance of crypto service. * It sends the first messages to FW on its crypto instance transport * handles. For asymmetric crypto it verifies the header on the downloaded * MMP library. * * @context * This function is called from the SalCtrl_ServiceEventStart function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A crypto instance * *************************************************************************/ CpaStatus SalCtrl_CryptoStart(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to stop an instance of crypto service. - * It checks for inflight messages to the FW. If no messages are pending + * It checks for in-flight messages to the FW. If no messages are pending * it returns success. If messages are pending it returns retry. * * @context * This function is called from the SalCtrl_ServiceEventStop function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A crypto instance * *************************************************************************/ CpaStatus SalCtrl_CryptoStop(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to shutdown an instance of crypto service. * It frees resources allocated at initialisation - e.g. frees the * memory pools and ADF transport handles. * * @context * This function is called from the SalCtrl_ServiceEventShutdown function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A crypto instance * *************************************************************************/ CpaStatus SalCtrl_CryptoShutdown(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function sets the capability info of crypto instances. * * @context * This function is called from the cpaCyQueryCapabilities and * LacSymSession_ParamCheck function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] service A sal_service_t* type * @param[in] cyCapabilityInfo A CpaCyCapabilitiesInfo* type * *************************************************************************/ void SalCtrl_CyQueryCapabilities(sal_service_t *pGenericService, CpaCyCapabilitiesInfo *pCapInfo); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to initialize an instance of compression service. * It creates a compression instance's memory pools. It calls ADF to create * its required transport handles. It zeros an instances stats. * * @context * This function is called from the SalCtrl_ServiceEventInit function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A compression instance * *************************************************************************/ CpaStatus SalCtrl_CompressionInit(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to start an instance of compression service. * * @context * This function is called from the SalCtrl_ServiceEventStart function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A compression instance * *************************************************************************/ CpaStatus SalCtrl_CompressionStart(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to stop an instance of compression service. - * It checks for inflight messages to the FW. If no messages are pending + * It checks for in-flight messages to the FW. If no messages are pending * it returns success. If messages are pending it returns retry. * * @context * This function is called from the SalCtrl_ServiceEventStop function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A compression instance * *************************************************************************/ CpaStatus SalCtrl_CompressionStop(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to shutdown an instance of compression service. * It frees resources allocated at initialisation - e.g. frees the * memory pools and ADF transport handles. * * @context * This function is called from the SalCtrl_ServiceEventShutdown function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No (ADF ensures that this function doesn't need to be thread safe) * * @param[in] device An icp_accel_dev_t* type * @param[in] service A compression instance * *************************************************************************/ CpaStatus SalCtrl_CompressionShutdown(icp_accel_dev_t *device, sal_service_t *service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to get the number of services enabled * from the config table. * * @context * This function is called from the SalCtrl_QatInit * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No * * param[in] device An icp_accel_dev_t* type * param[in] pEnabledServices pointer to a variable used to store * the enabled services * *************************************************************************/ CpaStatus SalCtrl_GetEnabledServices(icp_accel_dev_t *device, Cpa32U *pEnabledServices); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to check if a service is enabled * * @context * This function is called from the SalCtrl_QatInit * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * param[in] enabled_services * param[in] service * *************************************************************************/ CpaBoolean SalCtrl_IsServiceEnabled(Cpa32U enabled_services, sal_service_type_t service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to check if a service is supported on the device * The key difference between this and SalCtrl_GetSupportedServices() is * that the latter treats it as an error if the service is unsupported. * * @context * This can be called anywhere. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * param[in] device * param[in] service service or services to check * *************************************************************************/ CpaBoolean SalCtrl_IsServiceSupported(icp_accel_dev_t *device, sal_service_type_t service); /************************************************************************* * @ingroup SalCtrl * @description * This function is used to check whether enabled services has associated * hardware capability support * * @context * This functions is called from the SalCtrl_ServiceEventInit function. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * param[in] device A pointer to an icp_accel_dev_t * param[in] enabled_services It is the bitmask for the enabled services *************************************************************************/ CpaStatus SalCtrl_GetSupportedServices(icp_accel_dev_t *device, Cpa32U enabled_services); #endif diff --git a/sys/dev/qat/qat_api/common/include/lac_sal_types.h b/sys/dev/qat/qat_api/common/include/lac_sal_types.h index 8eff818d93cc..3960c4b94d01 100644 --- a/sys/dev/qat/qat_api/common/include/lac_sal_types.h +++ b/sys/dev/qat/qat_api/common/include/lac_sal_types.h @@ -1,211 +1,211 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file lac_sal_types.h * * @ingroup SalCtrl * * Generic instance type definitions of SAL controller * ***************************************************************************/ #ifndef LAC_SAL_TYPES_H #define LAC_SAL_TYPES_H #include "lac_sync.h" #include "lac_list.h" #include "icp_accel_devices.h" #include "sal_statistics.h" #include "icp_adf_debug.h" #define SAL_CFG_BASE_DEC 10 #define SAL_CFG_BASE_HEX 16 /** ***************************************************************************** * @ingroup SalCtrl * Instance States * * @description * An enumeration containing the possible states for an instance. * *****************************************************************************/ typedef enum sal_service_state_s { SAL_SERVICE_STATE_UNINITIALIZED = 0, SAL_SERVICE_STATE_INITIALIZING, SAL_SERVICE_STATE_INITIALIZED, SAL_SERVICE_STATE_RUNNING, SAL_SERVICE_STATE_SHUTTING_DOWN, SAL_SERVICE_STATE_SHUTDOWN, SAL_SERVICE_STATE_RESTARTING, SAL_SERVICE_STATE_END } sal_service_state_t; /** ***************************************************************************** * @ingroup SalCtrl * Service Instance Types * * @description * An enumeration containing the possible types for a service. * *****************************************************************************/ typedef enum { SAL_SERVICE_TYPE_UNKNOWN = 0, /* symmetric and asymmetric crypto service */ SAL_SERVICE_TYPE_CRYPTO = 1, /* compression service */ SAL_SERVICE_TYPE_COMPRESSION = 2, /* inline service */ SAL_SERVICE_TYPE_INLINE = 4, /* asymmetric crypto only service*/ SAL_SERVICE_TYPE_CRYPTO_ASYM = 8, /* symmetric crypto only service*/ SAL_SERVICE_TYPE_CRYPTO_SYM = 16, SAL_SERVICE_TYPE_QAT = 32 } sal_service_type_t; /** ***************************************************************************** * @ingroup SalCtrl * Device generations * * @description * List in an enum all the QAT device generations. * *****************************************************************************/ typedef enum { GEN2, GEN3, GEN4 } sal_generation_t; /** ***************************************************************************** * @ingroup SalCtrl * Generic Instance Container * * @description * Contains all the common information across the different instances. * *****************************************************************************/ typedef struct sal_service_s { sal_service_type_t type; /**< Service type (e.g. SAL_SERVICE_TYPE_CRYPTO)*/ Cpa8U state; /**< Status of the service instance (e.g. SAL_SERVICE_STATE_INITIALIZED) */ Cpa32U instance; /**< Instance number */ CpaVirtualToPhysical virt2PhysClient; /**< Function pointer to client supplied virt_to_phys */ CpaStatus (*init)(icp_accel_dev_t *device, struct sal_service_s *service); /**< Function pointer for instance INIT function */ CpaStatus (*start)(icp_accel_dev_t *device, struct sal_service_s *service); /**< Function pointer for instance START function */ CpaStatus (*stop)(icp_accel_dev_t *device, struct sal_service_s *service); /**< Function pointer for instance STOP function */ CpaStatus (*shutdown)(icp_accel_dev_t *device, struct sal_service_s *service); /**< Function pointer for instance SHUTDOWN function */ CpaCyInstanceNotificationCbFunc notification_cb; /**< Function pointer for instance restarting handler */ void *cb_tag; /**< Restarting handler priv data */ sal_statistics_collection_t *stats; /**< Pointer to device statistics configuration */ void *debug_parent_dir; /**< Pointer to parent proc dir entry */ CpaBoolean is_dyn; Cpa32U capabilitiesMask; /**< Capabilities mask of the device */ Cpa32U dcExtendedFeatures; /**< Bit field of features. I.e. Compress And Verify */ CpaBoolean isInstanceStarted; /**< True if user called StartInstance on this instance */ CpaBoolean integrityCrcCheck; /** < True if the device supports end to end data integrity checks */ sal_generation_t gen; /** Generation of devices */ } sal_service_t; /** ***************************************************************************** * @ingroup SalCtrl * SAL structure * * @description * Contains lists to crypto and compression instances. * *****************************************************************************/ typedef struct sal_s { sal_list_t *crypto_services; /**< Container of sal_crypto_service_t */ sal_list_t *asym_services; /**< Container of sal_asym_service_t */ sal_list_t *sym_services; /**< Container of sal_sym_service_t */ sal_list_t *compression_services; /**< Container of sal_compression_service_t */ debug_dir_info_t *cy_dir; /**< Container for crypto proc debug */ debug_dir_info_t *asym_dir; /**< Container for asym proc debug */ debug_dir_info_t *sym_dir; /**< Container for sym proc debug */ debug_dir_info_t *dc_dir; /**< Container for compression proc debug */ debug_file_info_t *ver_file; /**< Container for version debug file */ } sal_t; /** ***************************************************************************** * @ingroup SalCtrl * SAL debug structure * * @description * Service debug handler * *****************************************************************************/ typedef struct sal_service_debug_s { icp_accel_dev_t *accel_dev; debug_file_info_t debug_file; } sal_service_debug_t; /** ******************************************************************************* * @ingroup SalCtrl * This macro verifies that the right service type has been passed in. * * @param[in] pService pointer to service instance * @param[in] service_type service type to check againstx. * - * @return CPA_STATUS_FAIL Parameter is incorrect type - * + * @return CPA_STATUS_FAIL Parameter is incorrect type + * ******************************************************************************/ #define SAL_CHECK_INSTANCE_TYPE(pService, service_type) \ do { \ sal_service_t *pGenericService = NULL; \ pGenericService = (sal_service_t *)pService; \ if (!(service_type & pGenericService->type)) { \ QAT_UTILS_LOG("Instance handle type is incorrect.\n"); \ return CPA_STATUS_FAIL; \ } \ } while (0) #endif diff --git a/sys/dev/qat/qat_api/common/include/sal_qat_cmn_msg.h b/sys/dev/qat/qat_api/common/include/sal_qat_cmn_msg.h index 127ef6039197..7837d3c61240 100644 --- a/sys/dev/qat/qat_api/common/include/sal_qat_cmn_msg.h +++ b/sys/dev/qat/qat_api/common/include/sal_qat_cmn_msg.h @@ -1,208 +1,208 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file sal_qat_cmn_msg.c * * @ingroup SalQatCmnMessage * * @description * Implementation for populating the common (across services) QAT structures. * *****************************************************************************/ #ifndef SAL_QAT_CMN_MSG_H #define SAL_QAT_CMN_MSG_H /* ******************************************************************************* * Include public/global header files ******************************************************************************* */ #include "cpa.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "lac_common.h" #include "icp_accel_devices.h" #include "qat_utils.h" #include "cpa_cy_sym.h" #include "lac_mem.h" #include "lac_mem_pools.h" #include "lac_list.h" #include "icp_adf_transport.h" #include "icp_adf_transport_dp.h" #include "icp_qat_hw.h" #include "icp_qat_fw.h" #include "icp_qat_fw_la.h" /** ****************************************************************************** * @ingroup SalQatCmnMessage * content descriptor info structure * * @description * This structure contains generic information on the content descriptor * *****************************************************************************/ typedef struct sal_qat_content_desc_info_s { CpaPhysicalAddr hardwareSetupBlockPhys; /**< Physical address of hardware setup block of the content descriptor */ void *pData; /**< Virtual Pointer to the hardware setup block of the content * descriptor */ Cpa8U hwBlkSzQuadWords; /**< Hardware Setup Block size in quad words */ } sal_qat_content_desc_info_t; /** ******************************************************************************* * @ingroup SalQatCmnMessage * Lookaside response handler function type * * @description * This type definition specifies the function prototype for handling the * response messages for a specific symmetric operation * * @param[in] lacCmdId Look Aside Command ID * * @param[in] pOpaqueData Pointer to Opaque Data * * @param[in] cmnRespFlags Common Response flags * * @return void * *****************************************************************************/ typedef void (*sal_qat_resp_handler_func_t)(icp_qat_fw_la_cmd_id_t lacCmdId, void *pOpaqueData, icp_qat_fw_comn_flags cmnRespFlags); /******************************************************************** * @ingroup SalQatMsg_CmnHdrWrite * * @description * This function fills in all fields in the icp_qat_fw_comn_req_hdr_t * section of the Request Msg. Build LW0 + LW1 - * service part of the request * * @param[in] pMsg Pointer to 128B Request Msg buffer * @param[in] serviceType type of service request * @param[in] serviceCmdId id for the type of service request * @param[in] cmnFlags common request flags * @param[in] serviceCmdFlags service command flahgs * * @return * None * *****************************************/ void SalQatMsg_CmnHdrWrite(icp_qat_fw_comn_req_t *pMsg, icp_qat_fw_comn_request_id_t serviceType, uint8_t serviceCmdId, icp_qat_fw_comn_flags cmnFlags, icp_qat_fw_serv_specif_flags serviceCmdFlags); /******************************************************************** * @ingroup SalQatMsg_CmnMidWrite * * @description * This function fills in all fields in the icp_qat_fw_comn_req_mid_t * section of the Request Msg and the corresponding SGL/Flat flag * in the Hdr. * * @param[in] pReq Pointer to 128B Request Msg buffer * @param[in] pOpaqueData Pointer to opaque data used by callback * @param[in] bufferFormat src and dst Buffers are either SGL or Flat format * @param[in] pSrcBuffer Address of source buffer * @param[in] pDstBuffer Address of destination buffer * @param[in] pSrcLength Length of source buffer * @param[in] pDstLength Length of destination buffer * * @assumptions * All fields in mid section are zero before fn is called * @return * None * *****************************************/ void SalQatMsg_CmnMidWrite(icp_qat_fw_la_bulk_req_t *pReq, const void *pOpaqueData, Cpa8U bufferFormat, Cpa64U srcBuffer, Cpa64U dstBuffer, Cpa32U srcLength, Cpa32U dstLength); /******************************************************************** * @ingroup SalQatMsg_ContentDescHdrWrite * * @description * This function fills in all fields in the *icp_qat_fw_comn_req_hdr_cd_pars_t * section of the Request Msg. * * @param[in] pMsg Pointer to 128B Request Msg buffer. - * @param[in] pContentDescInfo content descripter info. + * @param[in] pContentDescInfo content descriptor info. * * @return * none * *****************************************/ void SalQatMsg_ContentDescHdrWrite( icp_qat_fw_comn_req_t *pMsg, const sal_qat_content_desc_info_t *pContentDescInfo); /******************************************************************** * @ingroup SalQatMsg_CtrlBlkSetToReserved * * @description * This function set the whole contrle block to a reserved state. * * @param[in] _pMsg Pointer to 128B Request Msg buffer. * * @return * none * *****************************************/ void SalQatMsg_CtrlBlkSetToReserved(icp_qat_fw_comn_req_t *_pMsg); /******************************************************************** * @ingroup SalQatMsg_transPutMsg * * @description * * * @param[in] trans_handle * @param[in] pqat_msg * @param[in] size_in_lws * @param[in] service * * @return * CpaStatus * *****************************************/ CpaStatus SalQatMsg_transPutMsg(icp_comms_trans_handle trans_handle, void *pqat_msg, Cpa32U size_in_lws, Cpa8U service); /******************************************************************** * @ingroup SalQatMsg_updateQueueTail * * @description * * * @param[in] trans_handle * * * @return * CpaStatus * *****************************************/ void SalQatMsg_updateQueueTail(icp_comms_trans_handle trans_hnd); #endif diff --git a/sys/dev/qat/qat_api/common/qat_comms/sal_qat_cmn_msg.c b/sys/dev/qat/qat_api/common/qat_comms/sal_qat_cmn_msg.c index 8b7c5160f712..4b7ec2d0e1aa 100644 --- a/sys/dev/qat/qat_api/common/qat_comms/sal_qat_cmn_msg.c +++ b/sys/dev/qat/qat_api/common/qat_comms/sal_qat_cmn_msg.c @@ -1,218 +1,218 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file sal_qat_cmn_msg.h * * @defgroup SalQatCmnMessage * * @ingroup SalQatCmnMessage * * Interfaces for populating the common QAT structures for a lookaside * operation. * *****************************************************************************/ /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "cpa.h" /* ******************************************************************************* * Include private header files ******************************************************************************* */ #include "qat_utils.h" #include "icp_accel_devices.h" #include "icp_qat_fw_la.h" #include "icp_qat_hw.h" #include "lac_common.h" #include "lac_mem.h" #include "sal_qat_cmn_msg.h" /******************************************************************** * @ingroup SalQatMsg_CmnHdrWrite * * @description * This function fills in all fields in the icp_qat_fw_comn_req_hdr_t * section of the Request Msg. Build LW0 + LW1 - * service part of the request * * @param[in] pMsg Pointer to 128B Request Msg buffer * @param[in] serviceType type of service request * @param[in] serviceCmdId id for the type of service request * @param[in] cmnFlags common request flags * @param[in] serviceCmdFlags service command flahgs * * @return * None * *****************************************/ void SalQatMsg_CmnHdrWrite(icp_qat_fw_comn_req_t *pMsg, icp_qat_fw_comn_request_id_t serviceType, uint8_t serviceCmdId, icp_qat_fw_comn_flags cmnFlags, icp_qat_fw_serv_specif_flags serviceCmdFlags) { icp_qat_fw_comn_req_hdr_t *pHeader = &(pMsg->comn_hdr); /* LW0 */ pHeader->hdr_flags = ICP_QAT_FW_COMN_HDR_FLAGS_BUILD(ICP_QAT_FW_COMN_REQ_FLAG_SET); pHeader->service_type = (uint8_t)serviceType; pHeader->service_cmd_id = serviceCmdId; pHeader->resrvd1 = 0; /* LW1 */ pHeader->comn_req_flags = cmnFlags; pHeader->serv_specif_flags = serviceCmdFlags; } /******************************************************************** * @ingroup SalQatCmnMessage * * @description * This function fills in all fields in the icp_qat_fw_comn_req_mid_t * section of the Request Msg and the corresponding SGL/Flat flag * in the Hdr. * * @param[in] pReq Pointer to 128B Request Msg buffer * @param[in] pOpaqueData Pointer to opaque data used by callback * @param[in] bufferFormat src and dst Buffers are either SGL or Flat * format * @param[in] pSrcBuffer Address of source buffer * @param[in] pDstBuffer Address of destination buffer * @param[in] pSrcLength Length of source buffer * @param[in] pDstLength Length of destination buffer * * @assumptions * All fields in mid section are zero before fn is called * @return * None * *****************************************/ void inline SalQatMsg_CmnMidWrite(icp_qat_fw_la_bulk_req_t *pReq, const void *pOpaqueData, Cpa8U bufferFormat, Cpa64U srcBuffer, Cpa64U dstBuffer, Cpa32U srcLength, Cpa32U dstLength) { icp_qat_fw_comn_req_mid_t *pMid = &(pReq->comn_mid); LAC_MEM_SHARED_WRITE_FROM_PTR(pMid->opaque_data, pOpaqueData); pMid->src_data_addr = srcBuffer; /* In place */ if (0 == dstBuffer) { pMid->dest_data_addr = srcBuffer; } /* Out of place */ else { pMid->dest_data_addr = dstBuffer; } if (bufferFormat == QAT_COMN_PTR_TYPE_SGL) { /* Using ScatterGatherLists so set flag in header */ ICP_QAT_FW_COMN_PTR_TYPE_SET(pReq->comn_hdr.comn_req_flags, QAT_COMN_PTR_TYPE_SGL); /* Assumption: No need to set src and dest length in this case * as not * used */ } else { /* Using Flat buffers so set flag in header */ ICP_QAT_FW_COMN_PTR_TYPE_SET(pReq->comn_hdr.comn_req_flags, QAT_COMN_PTR_TYPE_FLAT); pMid->src_length = srcLength; pMid->dst_length = dstLength; } } /******************************************************************** * @ingroup SalQatMsg_ContentDescHdrWrite * * @description * This function fills in all fields in the * icp_qat_fw_comn_req_hdr_cd_pars_t section of the Request Msg. * * @param[in] pMsg Pointer to 128B Request Msg buffer. - * @param[in] pContentDescInfo content descripter info. + * @param[in] pContentDescInfo content descriptor info. * * @return * none * *****************************************/ void SalQatMsg_ContentDescHdrWrite( icp_qat_fw_comn_req_t *pMsg, const sal_qat_content_desc_info_t *pContentDescInfo) { icp_qat_fw_comn_req_hdr_cd_pars_t *pCd_pars = &(pMsg->cd_pars); pCd_pars->s.content_desc_addr = pContentDescInfo->hardwareSetupBlockPhys; pCd_pars->s.content_desc_params_sz = pContentDescInfo->hwBlkSzQuadWords; pCd_pars->s.content_desc_resrvd1 = 0; pCd_pars->s.content_desc_hdr_resrvd2 = 0; pCd_pars->s.content_desc_resrvd3 = 0; } /******************************************************************** * @ingroup SalQatMsg_CtrlBlkSetToReserved * * @description * This function sets the whole control block to a reserved state. * * @param[in] _pMsg Pointer to 128B Request Msg buffer. * * @return * none * *****************************************/ void SalQatMsg_CtrlBlkSetToReserved(icp_qat_fw_comn_req_t *pMsg) { icp_qat_fw_comn_req_cd_ctrl_t *pCd_ctrl = &(pMsg->cd_ctrl); memset(pCd_ctrl, 0, sizeof(icp_qat_fw_comn_req_cd_ctrl_t)); } /******************************************************************** * @ingroup SalQatMsg_transPutMsg * * @description * * * @param[in] trans_handle * @param[in] pqat_msg * @param[in] size_in_lws * @param[in] service * * @return * CpaStatus * *****************************************/ CpaStatus SalQatMsg_transPutMsg(icp_comms_trans_handle trans_handle, void *pqat_msg, Cpa32U size_in_lws, Cpa8U service) { return icp_adf_transPutMsg(trans_handle, pqat_msg, size_in_lws); } void SalQatMsg_updateQueueTail(icp_comms_trans_handle trans_handle) { icp_adf_updateQueueTail(trans_handle); } diff --git a/sys/dev/qat/qat_api/common/utils/lac_buffer_desc.c b/sys/dev/qat/qat_api/common/utils/lac_buffer_desc.c index 4867e4ea0f15..40b239174cf1 100644 --- a/sys/dev/qat/qat_api/common/utils/lac_buffer_desc.c +++ b/sys/dev/qat/qat_api/common/utils/lac_buffer_desc.c @@ -1,491 +1,491 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file lac_buffer_desc.c Utility functions for setting buffer descriptors * * @ingroup LacBufferDesc * *****************************************************************************/ /* ******************************************************************************* * Include header files ******************************************************************************* */ #include "qat_utils.h" #include "icp_accel_devices.h" #include "icp_adf_debug.h" #include "icp_adf_init.h" #include "lac_list.h" #include "lac_sal_types.h" #include "lac_buffer_desc.h" #include "lac_mem.h" #include "cpa_cy_common.h" /* ******************************************************************************* * Define public/global function definitions ******************************************************************************* */ /* Invalid physical address value */ #define INVALID_PHYSICAL_ADDRESS 0 -/* Indicates what type of buffer writes need to be perfomed */ +/* Indicates what type of buffer writes need to be performed */ typedef enum lac_buff_write_op_e { WRITE_NORMAL = 0, WRITE_AND_GET_SIZE, WRITE_AND_ALLOW_ZERO_BUFFER, } lac_buff_write_op_t; /* This function implements the buffer description writes for the traditional * APIs */ static CpaStatus LacBuffDesc_CommonBufferListDescWrite(const CpaBufferList *pUserBufferList, Cpa64U *pBufListAlignedPhyAddr, CpaBoolean isPhysicalAddress, Cpa64U *totalDataLenInBytes, sal_service_t *pService, lac_buff_write_op_t operationType) { Cpa32U numBuffers = 0; icp_qat_addr_width_t bufListDescPhyAddr = 0; icp_qat_addr_width_t bufListAlignedPhyAddr = 0; CpaFlatBuffer *pCurrClientFlatBuffer = NULL; icp_buffer_list_desc_t *pBufferListDesc = NULL; icp_flat_buffer_desc_t *pCurrFlatBufDesc = NULL; if (WRITE_AND_GET_SIZE == operationType) { *totalDataLenInBytes = 0; } numBuffers = pUserBufferList->numBuffers; pCurrClientFlatBuffer = pUserBufferList->pBuffers; /* * Get the physical address of this descriptor - need to offset by the * alignment restrictions on the buffer descriptors */ bufListDescPhyAddr = (icp_qat_addr_width_t)LAC_OS_VIRT_TO_PHYS_EXTERNAL( (*pService), pUserBufferList->pPrivateMetaData); if (bufListDescPhyAddr == 0) { QAT_UTILS_LOG( "Unable to get the physical address of the metadata.\n"); return CPA_STATUS_FAIL; } bufListAlignedPhyAddr = LAC_ALIGN_POW2_ROUNDUP(bufListDescPhyAddr, ICP_DESCRIPTOR_ALIGNMENT_BYTES); pBufferListDesc = (icp_buffer_list_desc_t *)(LAC_ARCH_UINT)( (LAC_ARCH_UINT)pUserBufferList->pPrivateMetaData + ((LAC_ARCH_UINT)bufListAlignedPhyAddr - (LAC_ARCH_UINT)bufListDescPhyAddr)); /* Go past the Buffer List descriptor to the list of buffer descriptors */ pCurrFlatBufDesc = (icp_flat_buffer_desc_t *)((pBufferListDesc->phyBuffers)); pBufferListDesc->numBuffers = numBuffers; if (WRITE_AND_GET_SIZE != operationType) { /* Defining zero buffers is useful for example if running zero * length * hash */ if (0 == numBuffers) { /* In the case where there are zero buffers within the * BufList * it is required by firmware that the number is set to * 1 * but the phyBuffer and dataLenInBytes are set to * NULL.*/ pBufferListDesc->numBuffers = 1; pCurrFlatBufDesc->dataLenInBytes = 0; pCurrFlatBufDesc->phyBuffer = 0; } } while (0 != numBuffers) { pCurrFlatBufDesc->dataLenInBytes = pCurrClientFlatBuffer->dataLenInBytes; if (WRITE_AND_GET_SIZE == operationType) { /* Calculate the total data length in bytes */ *totalDataLenInBytes += pCurrClientFlatBuffer->dataLenInBytes; } /* Check if providing a physical address in the function. If not * we * need to convert it to a physical one */ if (CPA_TRUE == isPhysicalAddress) { pCurrFlatBufDesc->phyBuffer = LAC_MEM_CAST_PTR_TO_UINT64( (LAC_ARCH_UINT)(pCurrClientFlatBuffer->pData)); } else { pCurrFlatBufDesc->phyBuffer = LAC_MEM_CAST_PTR_TO_UINT64( LAC_OS_VIRT_TO_PHYS_EXTERNAL( (*pService), pCurrClientFlatBuffer->pData)); if (WRITE_AND_ALLOW_ZERO_BUFFER != operationType) { if (INVALID_PHYSICAL_ADDRESS == pCurrFlatBufDesc->phyBuffer) { QAT_UTILS_LOG( "Unable to get the physical address of the client buffer.\n"); return CPA_STATUS_FAIL; } } } pCurrFlatBufDesc++; pCurrClientFlatBuffer++; numBuffers--; } *pBufListAlignedPhyAddr = bufListAlignedPhyAddr; return CPA_STATUS_SUCCESS; } /* This function implements the buffer description writes for the traditional * APIs Zero length buffers are allowed, should be used for CHA-CHA-POLY and - * GCM aglorithms */ + * GCM algorithms */ CpaStatus LacBuffDesc_BufferListDescWriteAndAllowZeroBuffer( const CpaBufferList *pUserBufferList, Cpa64U *pBufListAlignedPhyAddr, CpaBoolean isPhysicalAddress, sal_service_t *pService) { return LacBuffDesc_CommonBufferListDescWrite( pUserBufferList, pBufListAlignedPhyAddr, isPhysicalAddress, NULL, pService, WRITE_AND_ALLOW_ZERO_BUFFER); } /* This function implements the buffer description writes for the traditional * APIs */ CpaStatus LacBuffDesc_BufferListDescWrite(const CpaBufferList *pUserBufferList, Cpa64U *pBufListAlignedPhyAddr, CpaBoolean isPhysicalAddress, sal_service_t *pService) { return LacBuffDesc_CommonBufferListDescWrite(pUserBufferList, pBufListAlignedPhyAddr, isPhysicalAddress, NULL, pService, WRITE_NORMAL); } /* This function does the same processing as LacBuffDesc_BufferListDescWrite * but calculate as well the total length in bytes of the buffer list. */ CpaStatus LacBuffDesc_BufferListDescWriteAndGetSize(const CpaBufferList *pUserBufferList, Cpa64U *pBufListAlignedPhyAddr, CpaBoolean isPhysicalAddress, Cpa64U *totalDataLenInBytes, sal_service_t *pService) { Cpa32U numBuffers = 0; icp_qat_addr_width_t bufListDescPhyAddr = 0; icp_qat_addr_width_t bufListAlignedPhyAddr = 0; CpaFlatBuffer *pCurrClientFlatBuffer = NULL; icp_buffer_list_desc_t *pBufferListDesc = NULL; icp_flat_buffer_desc_t *pCurrFlatBufDesc = NULL; *totalDataLenInBytes = 0; numBuffers = pUserBufferList->numBuffers; pCurrClientFlatBuffer = pUserBufferList->pBuffers; /* * Get the physical address of this descriptor - need to offset by the * alignment restrictions on the buffer descriptors */ bufListDescPhyAddr = (icp_qat_addr_width_t)LAC_OS_VIRT_TO_PHYS_EXTERNAL( (*pService), pUserBufferList->pPrivateMetaData); if (INVALID_PHYSICAL_ADDRESS == bufListDescPhyAddr) { QAT_UTILS_LOG( "Unable to get the physical address of the metadata.\n"); return CPA_STATUS_FAIL; } bufListAlignedPhyAddr = LAC_ALIGN_POW2_ROUNDUP(bufListDescPhyAddr, ICP_DESCRIPTOR_ALIGNMENT_BYTES); pBufferListDesc = (icp_buffer_list_desc_t *)(LAC_ARCH_UINT)( (LAC_ARCH_UINT)pUserBufferList->pPrivateMetaData + ((LAC_ARCH_UINT)bufListAlignedPhyAddr - (LAC_ARCH_UINT)bufListDescPhyAddr)); /* Go past the Buffer List descriptor to the list of buffer descriptors */ pCurrFlatBufDesc = (icp_flat_buffer_desc_t *)((pBufferListDesc->phyBuffers)); pBufferListDesc->numBuffers = numBuffers; while (0 != numBuffers) { pCurrFlatBufDesc->dataLenInBytes = pCurrClientFlatBuffer->dataLenInBytes; /* Calculate the total data length in bytes */ *totalDataLenInBytes += pCurrClientFlatBuffer->dataLenInBytes; if (isPhysicalAddress == CPA_TRUE) { pCurrFlatBufDesc->phyBuffer = LAC_MEM_CAST_PTR_TO_UINT64( (LAC_ARCH_UINT)(pCurrClientFlatBuffer->pData)); } else { pCurrFlatBufDesc->phyBuffer = LAC_MEM_CAST_PTR_TO_UINT64( LAC_OS_VIRT_TO_PHYS_EXTERNAL( (*pService), pCurrClientFlatBuffer->pData)); if (pCurrFlatBufDesc->phyBuffer == 0) { QAT_UTILS_LOG( "Unable to get the physical address of the client buffer.\n"); return CPA_STATUS_FAIL; } } pCurrFlatBufDesc++; pCurrClientFlatBuffer++; numBuffers--; } *pBufListAlignedPhyAddr = bufListAlignedPhyAddr; return CPA_STATUS_SUCCESS; } CpaStatus LacBuffDesc_FlatBufferVerify(const CpaFlatBuffer *pUserFlatBuffer, Cpa64U *pPktSize, lac_aligment_shift_t alignmentShiftExpected) { LAC_CHECK_NULL_PARAM(pUserFlatBuffer); LAC_CHECK_NULL_PARAM(pUserFlatBuffer->pData); if (0 == pUserFlatBuffer->dataLenInBytes) { QAT_UTILS_LOG("FlatBuffer empty\n"); return CPA_STATUS_INVALID_PARAM; } /* Expected alignment */ if (LAC_NO_ALIGNMENT_SHIFT != alignmentShiftExpected) { if (!LAC_ADDRESS_ALIGNED(pUserFlatBuffer->pData, alignmentShiftExpected)) { QAT_UTILS_LOG( "FlatBuffer not aligned correctly - expected alignment of %u bytes.\n", 1 << alignmentShiftExpected); return CPA_STATUS_INVALID_PARAM; } } /* Update the total size of the packet. This function being called in a * loop * for an entire buffer list we need to increment the value */ *pPktSize += pUserFlatBuffer->dataLenInBytes; return CPA_STATUS_SUCCESS; } CpaStatus LacBuffDesc_FlatBufferVerifyNull(const CpaFlatBuffer *pUserFlatBuffer, Cpa64U *pPktSize, lac_aligment_shift_t alignmentShiftExpected) { LAC_CHECK_NULL_PARAM(pUserFlatBuffer); if (0 != pUserFlatBuffer->dataLenInBytes) { LAC_CHECK_NULL_PARAM(pUserFlatBuffer->pData); } /* Expected alignment */ if (LAC_NO_ALIGNMENT_SHIFT != alignmentShiftExpected) { if (!LAC_ADDRESS_ALIGNED(pUserFlatBuffer->pData, alignmentShiftExpected)) { QAT_UTILS_LOG( "FlatBuffer not aligned correctly - expected alignment of %u bytes.\n", 1 << alignmentShiftExpected); return CPA_STATUS_INVALID_PARAM; } } /* Update the total size of the packet. This function being called in a * loop * for an entire buffer list we need to increment the value */ *pPktSize += pUserFlatBuffer->dataLenInBytes; return CPA_STATUS_SUCCESS; } CpaStatus LacBuffDesc_BufferListVerify(const CpaBufferList *pUserBufferList, Cpa64U *pPktSize, lac_aligment_shift_t alignmentShiftExpected) { CpaFlatBuffer *pCurrClientFlatBuffer = NULL; Cpa32U numBuffers = 0; CpaStatus status = CPA_STATUS_SUCCESS; LAC_CHECK_NULL_PARAM(pUserBufferList); LAC_CHECK_NULL_PARAM(pUserBufferList->pBuffers); LAC_CHECK_NULL_PARAM(pUserBufferList->pPrivateMetaData); numBuffers = pUserBufferList->numBuffers; if (0 == pUserBufferList->numBuffers) { QAT_UTILS_LOG("Number of buffers is 0.\n"); return CPA_STATUS_INVALID_PARAM; } pCurrClientFlatBuffer = pUserBufferList->pBuffers; *pPktSize = 0; while (0 != numBuffers && status == CPA_STATUS_SUCCESS) { status = LacBuffDesc_FlatBufferVerify(pCurrClientFlatBuffer, pPktSize, alignmentShiftExpected); pCurrClientFlatBuffer++; numBuffers--; } return status; } CpaStatus LacBuffDesc_BufferListVerifyNull(const CpaBufferList *pUserBufferList, Cpa64U *pPktSize, lac_aligment_shift_t alignmentShiftExpected) { CpaFlatBuffer *pCurrClientFlatBuffer = NULL; Cpa32U numBuffers = 0; CpaStatus status = CPA_STATUS_SUCCESS; LAC_CHECK_NULL_PARAM(pUserBufferList); LAC_CHECK_NULL_PARAM(pUserBufferList->pBuffers); LAC_CHECK_NULL_PARAM(pUserBufferList->pPrivateMetaData); numBuffers = pUserBufferList->numBuffers; if (0 == pUserBufferList->numBuffers) { QAT_UTILS_LOG("Number of buffers is 0.\n"); return CPA_STATUS_INVALID_PARAM; } pCurrClientFlatBuffer = pUserBufferList->pBuffers; *pPktSize = 0; while (0 != numBuffers && status == CPA_STATUS_SUCCESS) { status = LacBuffDesc_FlatBufferVerifyNull(pCurrClientFlatBuffer, pPktSize, alignmentShiftExpected); pCurrClientFlatBuffer++; numBuffers--; } return status; } /** ****************************************************************************** * @ingroup LacBufferDesc *****************************************************************************/ void LacBuffDesc_BufferListTotalSizeGet(const CpaBufferList *pUserBufferList, Cpa64U *pPktSize) { CpaFlatBuffer *pCurrClientFlatBuffer = NULL; Cpa32U numBuffers = 0; pCurrClientFlatBuffer = pUserBufferList->pBuffers; numBuffers = pUserBufferList->numBuffers; *pPktSize = 0; while (0 != numBuffers) { *pPktSize += pCurrClientFlatBuffer->dataLenInBytes; pCurrClientFlatBuffer++; numBuffers--; } } void LacBuffDesc_BufferListZeroFromOffset(CpaBufferList *pBuffList, Cpa32U offset, Cpa32U lenToZero) { Cpa32U zeroLen = 0, sizeLeftToZero = 0; Cpa64U currentBufferSize = 0; CpaFlatBuffer *pBuffer = NULL; Cpa8U *pZero = NULL; pBuffer = pBuffList->pBuffers; /* Take a copy of total length to zero. */ sizeLeftToZero = lenToZero; while (sizeLeftToZero > 0) { currentBufferSize = pBuffer->dataLenInBytes; /* check where to start zeroing */ if (offset >= currentBufferSize) { /* Need to get to next buffer and reduce * offset size by data len of buffer */ offset = offset - pBuffer->dataLenInBytes; pBuffer++; } else { /* Start to Zero from this position */ pZero = (Cpa8U *)pBuffer->pData + offset; /* Need to calculate the correct number of bytes to zero * for this iteration and for this location. */ if (sizeLeftToZero >= pBuffer->dataLenInBytes) { /* The size to zero is spanning buffers, zeroLen * in * this case is from pZero (position) to end of * buffer. */ zeroLen = pBuffer->dataLenInBytes - offset; } else { /* zeroLen is set to sizeLeftToZero, then check * if zeroLen and * the offset is greater or equal to the size of * the buffer, if * yes, adjust the zeroLen to zero out the * remainder of this * buffer. */ zeroLen = sizeLeftToZero; if ((zeroLen + offset) >= pBuffer->dataLenInBytes) { zeroLen = pBuffer->dataLenInBytes - offset; } } /* end inner else */ memset((void *)pZero, 0, zeroLen); sizeLeftToZero = sizeLeftToZero - zeroLen; /* offset is no longer required as any data left to zero * is now * at the start of the next buffer. set offset to zero * and move on * the buffer pointer to the next buffer. */ offset = 0; pBuffer++; } /* end outer else */ } /* end while */ } diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw.h index b4d1f5829ba2..de743987863f 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw.h @@ -1,1424 +1,1423 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file icp_qat_fw.h * @defgroup icp_qat_fw_comn ICP QAT FW Common Processing Definitions * @ingroup icp_qat_fw * * @description * This file documents the common interfaces that the QAT FW running on * the QAT AE exports. This common layer is used by a number of services * to export content processing services. * *****************************************************************************/ #ifndef _ICP_QAT_FW_H_ #define _ICP_QAT_FW_H_ /* * ============================== * General Notes on the Interface */ /* * * ============================== * * Introduction * * Data movement and slice chaining * * Endianness * - Unless otherwise stated, all structures are defined in LITTLE ENDIAN * MODE * * Alignment * - In general all data structures provided to a request should be aligned * on the 64 byte boundary so as to allow optimal memory transfers. At the * minimum they must be aligned to the 8 byte boundary * * Sizes * Quad words = 8 bytes * * Terminology * * ============================== */ /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ #include "icp_qat_hw.h" /* Big assumptions that both bitpos and mask are constants */ #define QAT_FIELD_SET(flags, val, bitpos, mask) \ (flags) = (((flags) & (~((mask) << (bitpos)))) | \ (((val) & (mask)) << (bitpos))) #define QAT_FIELD_GET(flags, bitpos, mask) (((flags) >> (bitpos)) & (mask)) #define QAT_FLAG_SET(flags, val, bitpos) \ ((flags) = (((flags) & (~(1 << (bitpos)))) | (((val)&1) << (bitpos)))) #define QAT_FLAG_CLEAR(flags, bitpos) (flags) = ((flags) & (~(1 << (bitpos)))) #define QAT_FLAG_GET(flags, bitpos) (((flags) >> (bitpos)) & 1) /**< @ingroup icp_qat_fw_comn * Default request and response ring size in bytes */ #define ICP_QAT_FW_REQ_DEFAULT_SZ 128 #define ICP_QAT_FW_RESP_DEFAULT_SZ 32 #define ICP_QAT_FW_COMN_ONE_BYTE_SHIFT 8 #define ICP_QAT_FW_COMN_SINGLE_BYTE_MASK 0xFF /**< @ingroup icp_qat_fw_comn * Common Request - Block sizes definitions in multiples of individual long * words */ #define ICP_QAT_FW_NUM_LONGWORDS_1 1 #define ICP_QAT_FW_NUM_LONGWORDS_2 2 #define ICP_QAT_FW_NUM_LONGWORDS_3 3 #define ICP_QAT_FW_NUM_LONGWORDS_4 4 #define ICP_QAT_FW_NUM_LONGWORDS_5 5 #define ICP_QAT_FW_NUM_LONGWORDS_6 6 #define ICP_QAT_FW_NUM_LONGWORDS_7 7 #define ICP_QAT_FW_NUM_LONGWORDS_10 10 #define ICP_QAT_FW_NUM_LONGWORDS_13 13 /**< @ingroup icp_qat_fw_comn * Definition of the associated service Id for NULL service type. * Note: the response is expected to use ICP_QAT_FW_COMN_RESP_SERV_CPM_FW */ #define ICP_QAT_FW_NULL_REQ_SERV_ID 1 /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the firmware interface service users, for * responses. * @description * Enumeration which is used to indicate the ids of the services * for responses using the external firmware interfaces. * *****************************************************************************/ typedef enum { ICP_QAT_FW_COMN_RESP_SERV_NULL, /**< NULL service id type */ ICP_QAT_FW_COMN_RESP_SERV_CPM_FW, /**< CPM FW Service ID */ ICP_QAT_FW_COMN_RESP_SERV_DELIMITER /**< Delimiter service id type */ } icp_qat_fw_comn_resp_serv_id_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the request types * @description * Enumeration which is used to indicate the ids of the request * types used in each of the external firmware interfaces * *****************************************************************************/ typedef enum { ICP_QAT_FW_COMN_REQ_NULL = 0, /**< NULL request type */ ICP_QAT_FW_COMN_REQ_CPM_FW_PKE = 3, /**< CPM FW PKE Request */ ICP_QAT_FW_COMN_REQ_CPM_FW_LA = 4, /**< CPM FW Lookaside Request */ ICP_QAT_FW_COMN_REQ_CPM_FW_DMA = 7, /**< CPM FW DMA Request */ ICP_QAT_FW_COMN_REQ_CPM_FW_COMP = 9, /**< CPM FW Compression Request */ ICP_QAT_FW_COMN_REQ_DELIMITER /**< End delimiter */ } icp_qat_fw_comn_request_id_t; /* ========================================================================= */ /* QAT FW REQUEST STRUCTURES */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Common request flags type * * @description * Definition of the common request flags. * *****************************************************************************/ typedef uint8_t icp_qat_fw_comn_flags; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Common request - Service specific flags type * * @description * Definition of the common request service specific flags. * *****************************************************************************/ typedef uint16_t icp_qat_fw_serv_specif_flags; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Common request - Extended service specific flags type * * @description * Definition of the common request extended service specific flags. * *****************************************************************************/ typedef uint8_t icp_qat_fw_ext_serv_specif_flags; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common QAT FW request content descriptor field - * points to the content descriptor parameters or itself contains service- * specific data. Also specifies content descriptor parameter size. * Contains reserved fields. * @description * Common section of the request used across all of the services exposed * by the QAT FW. Each of the services inherit these common fields * *****************************************************************************/ typedef union icp_qat_fw_comn_req_hdr_cd_pars_s { /**< LWs 2-5 */ struct { uint64_t content_desc_addr; /**< Address of the content descriptor */ uint16_t content_desc_resrvd1; /**< Content descriptor reserved field */ uint8_t content_desc_params_sz; /**< Size of the content descriptor parameters in quad words. * These * parameters describe the session setup configuration info for * the * slices that this request relies upon i.e. the configuration * word and * cipher key needed by the cipher slice if there is a request * for * cipher processing. */ uint8_t content_desc_hdr_resrvd2; /**< Content descriptor reserved field */ uint32_t content_desc_resrvd3; /**< Content descriptor reserved field */ } s; struct { uint32_t serv_specif_fields[ICP_QAT_FW_NUM_LONGWORDS_4]; } s1; } icp_qat_fw_comn_req_hdr_cd_pars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common QAT FW request middle block. * @description * Common section of the request used across all of the services exposed * by the QAT FW. Each of the services inherit these common fields * *****************************************************************************/ typedef struct icp_qat_fw_comn_req_mid_s { /**< LWs 6-13 */ uint64_t opaque_data; /**< Opaque data passed unmodified from the request to response messages * by * firmware (fw) */ uint64_t src_data_addr; /**< Generic definition of the source data supplied to the QAT AE. The * common flags are used to further describe the attributes of this * field */ uint64_t dest_data_addr; /**< Generic definition of the destination data supplied to the QAT AE. * The * common flags are used to further describe the attributes of this * field */ uint32_t src_length; - /** < Length of source flat buffer incase src buffer + /** < Length of source flat buffer in case src buffer * type is flat */ uint32_t dst_length; - /** < Length of source flat buffer incase dst buffer + /** < Length of source flat buffer in case dst buffer * type is flat */ - } icp_qat_fw_comn_req_mid_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common QAT FW request content descriptor control * block. * * @description * Service specific section of the request used across all of the services * exposed by the QAT FW. Each of the services populates this block * uniquely. Refer to the service-specific header structures e.g. * 'icp_qat_fw_cipher_hdr_s' (for Cipher) etc. * *****************************************************************************/ typedef struct icp_qat_fw_comn_req_cd_ctrl_s { /**< LWs 27-31 */ uint32_t content_desc_ctrl_lw[ICP_QAT_FW_NUM_LONGWORDS_5]; } icp_qat_fw_comn_req_cd_ctrl_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common QAT FW request header. * @description * Common section of the request used across all of the services exposed * by the QAT FW. Each of the services inherit these common fields. The * reserved field of 7 bits and the service command Id field are all * service-specific fields, along with the service specific flags. * *****************************************************************************/ typedef struct icp_qat_fw_comn_req_hdr_s { /**< LW0 */ uint8_t resrvd1; /**< reserved field */ uint8_t service_cmd_id; /**< Service Command Id - this field is service-specific * Please use service-specific command Id here e.g.Crypto Command Id * or Compression Command Id etc. */ uint8_t service_type; /**< Service type */ uint8_t hdr_flags; /**< This represents a flags field for the Service Request. * The most significant bit is the 'valid' flag and the only * one used. All remaining bit positions are unused and * are therefore reserved and need to be set to 0. */ /**< LW1 */ icp_qat_fw_serv_specif_flags serv_specif_flags; /**< Common Request service-specific flags * e.g. Symmetric Crypto Command Flags */ icp_qat_fw_comn_flags comn_req_flags; /**< Common Request Flags consisting of * - 6 reserved bits, * - 1 Content Descriptor field type bit and * - 1 Source/destination pointer type bit */ icp_qat_fw_ext_serv_specif_flags extended_serv_specif_flags; /**< An extension of serv_specif_flags */ } icp_qat_fw_comn_req_hdr_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common QAT FW request parameter field. * * @description * Service specific section of the request used across all of the services * exposed by the QAT FW. Each of the services populates this block * uniquely. Refer to service-specific header structures e.g. * 'icp_qat_fw_comn_req_cipher_rqpars_s' (for Cipher) etc. * *****************************************************************************/ typedef struct icp_qat_fw_comn_req_rqpars_s { /**< LWs 14-26 */ uint32_t serv_specif_rqpars_lw[ICP_QAT_FW_NUM_LONGWORDS_13]; } icp_qat_fw_comn_req_rqpars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common request structure with service specific * fields * @description * This is a definition of the full qat request structure used by all * services. Each service is free to use the service fields in its own * way. This struct is useful as a message passing argument before the * service contained within the request is determined. * *****************************************************************************/ typedef struct icp_qat_fw_comn_req_s { /**< LWs 0-1 */ icp_qat_fw_comn_req_hdr_t comn_hdr; /**< Common request header */ /**< LWs 2-5 */ icp_qat_fw_comn_req_hdr_cd_pars_t cd_pars; /**< Common Request content descriptor field which points either to a * content descriptor * parameter block or contains the service-specific data itself. */ /**< LWs 6-13 */ icp_qat_fw_comn_req_mid_t comn_mid; /**< Common request middle section */ /**< LWs 14-26 */ icp_qat_fw_comn_req_rqpars_t serv_specif_rqpars; /**< Common request service-specific parameter field */ /**< LWs 27-31 */ icp_qat_fw_comn_req_cd_ctrl_t cd_ctrl; /**< Common request content descriptor control block - * this field is service-specific */ } icp_qat_fw_comn_req_t; /* ========================================================================= */ /* QAT FW RESPONSE STRUCTURES */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Error code field * * @description * Overloaded field with 8 bit common error field or two * 8 bit compression error fields for compression and translator slices * *****************************************************************************/ typedef union icp_qat_fw_comn_error_s { struct { uint8_t resrvd; /**< 8 bit reserved field */ uint8_t comn_err_code; /**< 8 bit common error code */ } s; /**< Structure which is used for non-compression responses */ struct { uint8_t xlat_err_code; /**< 8 bit translator error field */ uint8_t cmp_err_code; /**< 8 bit compression error field */ } s1; /** Structure which is used for compression responses */ } icp_qat_fw_comn_error_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common QAT FW response header. * @description * This section of the response is common across all of the services * that generate a firmware interface response * *****************************************************************************/ typedef struct icp_qat_fw_comn_resp_hdr_s { /**< LW0 */ uint8_t resrvd1; /**< Reserved field - this field is service-specific - * Note: The Response Destination Id has been removed * from first QWord */ uint8_t service_id; /**< Service Id returned by service block */ uint8_t response_type; /**< Response type - copied from the request to * the response message */ uint8_t hdr_flags; /**< This represents a flags field for the Response. * Bit<7> = 'valid' flag * Bit<6> = 'CNV' flag indicating that CNV was executed * on the current request * Bit<5> = 'CNVNR' flag indicating that a recovery happened * on the current request following a CNV error * All remaining bits are unused and are therefore reserved. * They must to be set to 0. */ /**< LW 1 */ icp_qat_fw_comn_error_t comn_error; /**< This field is overloaded to allow for one 8 bit common error field * or two 8 bit error fields from compression and translator */ uint8_t comn_status; /**< Status field which specifies which slice(s) report an error */ uint8_t cmd_id; /**< Command Id - passed from the request to the response message */ } icp_qat_fw_comn_resp_hdr_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Definition of the common response structure with service specific * fields * @description * This is a definition of the full qat response structure used by all * services. * *****************************************************************************/ typedef struct icp_qat_fw_comn_resp_s { /**< LWs 0-1 */ icp_qat_fw_comn_resp_hdr_t comn_hdr; /**< Common header fields */ /**< LWs 2-3 */ uint64_t opaque_data; /**< Opaque data passed from the request to the response message */ /**< LWs 4-7 */ uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_4]; /**< Reserved */ } icp_qat_fw_comn_resp_t; /* ========================================================================= */ /* MACRO DEFINITIONS */ /* ========================================================================= */ /* Common QAT FW request header - structure of LW0 * + ===== + ------- + ----------- + ----------- + ----------- + -------- + * | Bit | 31/30 | 29 - 24 | 21 - 16 | 15 - 8 | 7 - 0 | * + ===== + ------- + ----------- + ----------- + ----------- + -------- + * | Flags | V/Gen | Reserved | Serv Type | Serv Cmd Id | Rsv | * + ===== + ------- + ----------- + ----------- + ----------- + -------- + */ /**< @ingroup icp_qat_fw_comn * Definition of the setting of the header's valid flag */ #define ICP_QAT_FW_COMN_REQ_FLAG_SET 1 /**< @ingroup icp_qat_fw_comn * Definition of the setting of the header's valid flag */ #define ICP_QAT_FW_COMN_REQ_FLAG_CLR 0 /**< @ingroup icp_qat_fw_comn * Macros defining the bit position and mask of the 'valid' flag, within the * hdr_flags field of LW0 (service request and response) */ #define ICP_QAT_FW_COMN_VALID_FLAG_BITPOS 7 #define ICP_QAT_FW_COMN_VALID_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Macros defining the bit position and mask of the 'generation' flag, within * the hdr_flags field of LW0 (service request and response) */ #define ICP_QAT_FW_COMN_GEN_FLAG_BITPOS 6 #define ICP_QAT_FW_COMN_GEN_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_comn * The request is targeted for QAT2.0 */ #define ICP_QAT_FW_COMN_GEN_2 1 /**< @ingroup icp_qat_fw_comn * The request is targeted for QAT1.x. QAT2.0 FW will return 'unsupported request' if GEN1 request type is sent to QAT2.0 FW */ #define ICP_QAT_FW_COMN_GEN_1 0 #define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK 0x7F /* Common QAT FW response header - structure of LW0 * + ===== + --- + --- + ----- + ----- + --------- + ----------- + ----- + * | Bit | 31 | 30 | 29 | 28-24 | 21 - 16 | 15 - 8 | 7-0 | * + ===== + --- + ----+ ----- + ----- + --------- + ----------- + ----- + * | Flags | V | CNV | CNVNR | Rsvd | Serv Type | Serv Cmd Id | Rsvd | * + ===== + --- + --- + ----- + ----- + --------- + ----------- + ----- + */ /**< @ingroup icp_qat_fw_comn * Macros defining the bit position and mask of 'CNV' flag * within the hdr_flags field of LW0 (service response only) */ #define ICP_QAT_FW_COMN_CNV_FLAG_BITPOS 6 #define ICP_QAT_FW_COMN_CNV_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Macros defining the bit position and mask of CNVNR flag * within the hdr_flags field of LW0 (service response only) */ #define ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS 5 #define ICP_QAT_FW_COMN_CNVNR_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Macros defining the bit position and mask of Stored Blocks flag * within the hdr_flags field of LW0 (service response only) */ #define ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS 4 #define ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK 0x1 /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of Service Type Field * * @param icp_qat_fw_comn_req_hdr_t Structure 'icp_qat_fw_comn_req_hdr_t' * to extract the Service Type Field * *****************************************************************************/ #define ICP_QAT_FW_COMN_OV_SRV_TYPE_GET(icp_qat_fw_comn_req_hdr_t) \ icp_qat_fw_comn_req_hdr_t.service_type /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for setting of Service Type Field * * @param 'icp_qat_fw_comn_req_hdr_t' structure to set the Service * Type Field * @param val Value of the Service Type Field * *****************************************************************************/ #define ICP_QAT_FW_COMN_OV_SRV_TYPE_SET(icp_qat_fw_comn_req_hdr_t, val) \ icp_qat_fw_comn_req_hdr_t.service_type = val /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of Service Command Id Field * * @param icp_qat_fw_comn_req_hdr_t Structure 'icp_qat_fw_comn_req_hdr_t' * to extract the Service Command Id Field * *****************************************************************************/ #define ICP_QAT_FW_COMN_OV_SRV_CMD_ID_GET(icp_qat_fw_comn_req_hdr_t) \ icp_qat_fw_comn_req_hdr_t.service_cmd_id /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for setting of Service Command Id Field * * @param 'icp_qat_fw_comn_req_hdr_t' structure to set the * Service Command Id Field * @param val Value of the Service Command Id Field * *****************************************************************************/ #define ICP_QAT_FW_COMN_OV_SRV_CMD_ID_SET(icp_qat_fw_comn_req_hdr_t, val) \ icp_qat_fw_comn_req_hdr_t.service_cmd_id = val /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Extract the valid flag from the request or response's header flags. * * @param hdr_t Request or Response 'hdr_t' structure to extract the valid bit * from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_VALID_FLAG_GET(hdr_t) \ ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_t.hdr_flags) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Extract the CNVNR flag from the header flags in the response only. * * @param hdr_t Response 'hdr_t' structure to extract the CNVNR bit * from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_GET(hdr_flags) \ QAT_FIELD_GET(hdr_flags, \ ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS, \ ICP_QAT_FW_COMN_CNVNR_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Extract the CNV flag from the header flags in the response only. * * @param hdr_t Response 'hdr_t' structure to extract the CNV bit * from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(hdr_flags) \ QAT_FIELD_GET(hdr_flags, \ ICP_QAT_FW_COMN_CNV_FLAG_BITPOS, \ ICP_QAT_FW_COMN_CNV_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Set the valid bit in the request's header flags. * * @param hdr_t Request or Response 'hdr_t' structure to set the valid bit * @param val Value of the valid bit flag. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_VALID_FLAG_SET(hdr_t, val) \ ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Common macro to extract the valid flag from the header flags field * within the header structure (request or response). * * @param hdr_t Structure (request or response) to extract the * valid bit from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_flags) \ QAT_FIELD_GET(hdr_flags, \ ICP_QAT_FW_COMN_VALID_FLAG_BITPOS, \ ICP_QAT_FW_COMN_VALID_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Extract the Stored Block flag from the header flags in the * response only. * * @param hdr_flags Response 'hdr' structure to extract the * Stored Block bit from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_GET(hdr_flags) \ QAT_FIELD_GET(hdr_flags, \ ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS, \ ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Set the Stored Block bit in the response's header flags. * * @param hdr_t Response 'hdr_t' structure to set the ST_BLK bit * @param val Value of the ST_BLK bit flag. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_SET(hdr_t, val) \ QAT_FIELD_SET((hdr_t.hdr_flags), \ (val), \ ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS, \ ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Set the generation bit in the request's header flags. * * @param hdr_t Request or Response 'hdr_t' structure to set the gen bit * @param val Value of the generation bit flag. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_GENERATION_FLAG_SET(hdr_t, val) \ ICP_QAT_FW_COMN_GENERATION_FLAG_SET(hdr_t, val) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Common macro to set the generation bit in the common header * * @param hdr_t Structure (request or response) containing the header * flags field, to allow the generation bit to be set. * @param val Value of the generation bit flag. * *****************************************************************************/ #define ICP_QAT_FW_COMN_GENERATION_FLAG_SET(hdr_t, val) \ QAT_FIELD_SET((hdr_t.hdr_flags), \ (val), \ ICP_QAT_FW_COMN_GEN_FLAG_BITPOS, \ ICP_QAT_FW_COMN_GEN_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Common macro to extract the generation flag from the header flags field * within the header structure (request or response). * * @param hdr_t Structure (request or response) to extract the * generation bit from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_GENERATION_FLAG_GET(hdr_flags) \ QAT_FIELD_GET(hdr_flags, \ ICP_QAT_FW_COMN_GEN_FLAG_BITPOS, \ ICP_QAT_FW_COMN_GEN_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Common macro to extract the remaining reserved flags from the header flags field within the header structure (request or response). * * @param hdr_t Structure (request or response) to extract the * remaining bits from the 'hdr_flags' field (excluding the * valid flag). * *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_GET(hdr_flags) \ (hdr_flags & ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Common macro to set the valid bit in the header flags field within * the header structure (request or response). * * @param hdr_t Structure (request or response) containing the header * flags field, to allow the valid bit to be set. * @param val Value of the valid bit flag. * *****************************************************************************/ #define ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val) \ QAT_FIELD_SET((hdr_t.hdr_flags), \ (val), \ ICP_QAT_FW_COMN_VALID_FLAG_BITPOS, \ ICP_QAT_FW_COMN_VALID_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro that must be used when building the common header flags. * Note that all bits reserved field bits 0-6 (LW0) need to be forced to 0. * * @param ptr Value of the valid flag *****************************************************************************/ #define ICP_QAT_FW_COMN_HDR_FLAGS_BUILD(valid) \ (((valid)&ICP_QAT_FW_COMN_VALID_FLAG_MASK) \ << ICP_QAT_FW_COMN_VALID_FLAG_BITPOS) /* * < @ingroup icp_qat_fw_comn * Common Request Flags Definition * The bit offsets below are within the flags field. These are NOT relative to * the memory word. Unused fields e.g. reserved bits, must be zeroed. * * + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- + * | Bits [15:8] | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | * + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- + * | Flags[15:8] | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | * + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- + * | Bits [7:0] | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- + * | Flags [7:0] | Rsv | Rsv | Rsv | Rsv | Rsv | BnP | Cdt | Ptr | * + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- + */ #define QAT_COMN_PTR_TYPE_BITPOS 0 /**< @ingroup icp_qat_fw_comn * Common Request Flags - Starting bit position indicating * Src&Dst Buffer Pointer type */ #define QAT_COMN_PTR_TYPE_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Common Request Flags - One bit mask used to determine * Src&Dst Buffer Pointer type */ #define QAT_COMN_CD_FLD_TYPE_BITPOS 1 /**< @ingroup icp_qat_fw_comn * Common Request Flags - Starting bit position indicating * CD Field type */ #define QAT_COMN_CD_FLD_TYPE_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Common Request Flags - One bit mask used to determine * CD Field type */ #define QAT_COMN_BNP_ENABLED_BITPOS 2 /**< @ingroup icp_qat_fw_comn * Common Request Flags - Starting bit position indicating * the source buffer contains batch of requests. if this * bit is set, source buffer is type of Batch And Pack OpData List * and the Ptr Type Bit only applies to Destination buffer. */ #define QAT_COMN_BNP_ENABLED_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Batch And Pack Enabled Flag Mask - One bit mask used to determine * the source buffer is in Batch and Pack OpData Link List Mode. */ /* ========================================================================= */ /* Pointer Type Flag definitions */ /* ========================================================================= */ #define QAT_COMN_PTR_TYPE_FLAT 0x0 /**< @ingroup icp_qat_fw_comn * Constant value indicating Src&Dst Buffer Pointer type is flat * If Batch and Pack mode is enabled, only applies to Destination buffer.*/ #define QAT_COMN_PTR_TYPE_SGL 0x1 /**< @ingroup icp_qat_fw_comn * Constant value indicating Src&Dst Buffer Pointer type is SGL type * If Batch and Pack mode is enabled, only applies to Destination buffer.*/ #define QAT_COMN_PTR_TYPE_BATCH 0x2 /**< @ingroup icp_qat_fw_comn * Constant value indicating Src is a batch request * and Dst Buffer Pointer type is SGL type */ /* ========================================================================= */ /* CD Field Flag definitions */ /* ========================================================================= */ #define QAT_COMN_CD_FLD_TYPE_64BIT_ADR 0x0 /**< @ingroup icp_qat_fw_comn * Constant value indicating CD Field contains 64-bit address */ #define QAT_COMN_CD_FLD_TYPE_16BYTE_DATA 0x1 /**< @ingroup icp_qat_fw_comn * Constant value indicating CD Field contains 16 bytes of setup data */ /* ========================================================================= */ /* Batch And Pack Enable/Disable Definitions */ /* ========================================================================= */ #define QAT_COMN_BNP_ENABLED 0x1 /**< @ingroup icp_qat_fw_comn * Constant value indicating Source buffer will point to Batch And Pack OpData * List */ #define QAT_COMN_BNP_DISABLED 0x0 /**< @ingroup icp_qat_fw_comn * Constant value indicating Source buffer will point to Batch And Pack OpData * List */ /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro that must be used when building the common request flags (for all * requests but comp BnP). * Note that all bits reserved field bits 2-15 (LW1) need to be forced to 0. * * @param ptr Value of the pointer type flag * @param cdt Value of the cd field type flag *****************************************************************************/ #define ICP_QAT_FW_COMN_FLAGS_BUILD(cdt, ptr) \ ((((cdt)&QAT_COMN_CD_FLD_TYPE_MASK) << QAT_COMN_CD_FLD_TYPE_BITPOS) | \ (((ptr)&QAT_COMN_PTR_TYPE_MASK) << QAT_COMN_PTR_TYPE_BITPOS)) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro that must be used when building the common request flags for comp * BnP service. * Note that all bits reserved field bits 3-15 (LW1) need to be forced to 0. * * @param ptr Value of the pointer type flag * @param cdt Value of the cd field type flag * @param bnp Value of the bnp enabled flag *****************************************************************************/ #define ICP_QAT_FW_COMN_FLAGS_BUILD_BNP(cdt, ptr, bnp) \ ((((cdt)&QAT_COMN_CD_FLD_TYPE_MASK) << QAT_COMN_CD_FLD_TYPE_BITPOS) | \ (((ptr)&QAT_COMN_PTR_TYPE_MASK) << QAT_COMN_PTR_TYPE_BITPOS) | \ (((bnp)&QAT_COMN_BNP_ENABLED_MASK) << QAT_COMN_BNP_ENABLED_BITPOS)) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the pointer type bit from the common flags * * @param flags Flags to extract the pointer type bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_PTR_TYPE_GET(flags) \ QAT_FIELD_GET(flags, QAT_COMN_PTR_TYPE_BITPOS, QAT_COMN_PTR_TYPE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the cd field type bit from the common flags * * @param flags Flags to extract the cd field type type bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_CD_FLD_TYPE_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_COMN_CD_FLD_TYPE_BITPOS, \ QAT_COMN_CD_FLD_TYPE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the bnp field type bit from the common flags * * @param flags Flags to extract the bnp field type type bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_BNP_ENABLED_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_COMN_BNP_ENABLED_BITPOS, \ QAT_COMN_BNP_ENABLED_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for setting the pointer type bit in the common flags * * @param flags Flags in which Pointer Type bit will be set * @param val Value of the bit to be set in flags * *****************************************************************************/ #define ICP_QAT_FW_COMN_PTR_TYPE_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_COMN_PTR_TYPE_BITPOS, \ QAT_COMN_PTR_TYPE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for setting the cd field type bit in the common flags * * @param flags Flags in which Cd Field Type bit will be set * @param val Value of the bit to be set in flags * *****************************************************************************/ #define ICP_QAT_FW_COMN_CD_FLD_TYPE_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_COMN_CD_FLD_TYPE_BITPOS, \ QAT_COMN_CD_FLD_TYPE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for setting the bnp field type bit in the common flags * * @param flags Flags in which Bnp Field Type bit will be set * @param val Value of the bit to be set in flags * *****************************************************************************/ #define ICP_QAT_FW_COMN_BNP_ENABLE_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_COMN_BNP_ENABLED_BITPOS, \ QAT_COMN_BNP_ENABLED_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macros using the bit position and mask to set/extract the next * and current id nibbles within the next_curr_id field of the * content descriptor header block. Note that these are defined * in the common header file, as they are used by compression, cipher * and authentication. * * @param cd_ctrl_hdr_t Content descriptor control block header pointer. * @param val Value of the field being set. * *****************************************************************************/ #define ICP_QAT_FW_COMN_NEXT_ID_BITPOS 4 #define ICP_QAT_FW_COMN_NEXT_ID_MASK 0xF0 #define ICP_QAT_FW_COMN_CURR_ID_BITPOS 0 #define ICP_QAT_FW_COMN_CURR_ID_MASK 0x0F #define ICP_QAT_FW_COMN_NEXT_ID_GET(cd_ctrl_hdr_t) \ ((((cd_ctrl_hdr_t)->next_curr_id) & ICP_QAT_FW_COMN_NEXT_ID_MASK) >> \ (ICP_QAT_FW_COMN_NEXT_ID_BITPOS)) #define ICP_QAT_FW_COMN_NEXT_ID_SET(cd_ctrl_hdr_t, val) \ ((cd_ctrl_hdr_t)->next_curr_id) = \ ((((cd_ctrl_hdr_t)->next_curr_id) & \ ICP_QAT_FW_COMN_CURR_ID_MASK) | \ ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK)) #define ICP_QAT_FW_COMN_CURR_ID_GET(cd_ctrl_hdr_t) \ (((cd_ctrl_hdr_t)->next_curr_id) & ICP_QAT_FW_COMN_CURR_ID_MASK) #define ICP_QAT_FW_COMN_CURR_ID_SET(cd_ctrl_hdr_t, val) \ ((cd_ctrl_hdr_t)->next_curr_id) = \ ((((cd_ctrl_hdr_t)->next_curr_id) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK) | \ ((val)&ICP_QAT_FW_COMN_CURR_ID_MASK)) /* * < @ingroup icp_qat_fw_comn * Common Status Field Definition The bit offsets below are within the COMMON * RESPONSE status field, assumed to be 8 bits wide. In the case of the PKE * response (which follows the CPM 1.5 message format), the status field is 16 * bits wide. * The status flags are contained within the most significant byte and align * with the diagram below. Please therefore refer to the service-specific PKE * header file for the appropriate macro definition to extract the PKE status * flag from the PKE response, which assumes that a word is passed to the * macro. * + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- + * | Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- + * | Flags | Crypto | Pke | Cmp | Xlat | EOLB | UnSupReq | Rsvd | XltWaApply | * + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- + * Note: * For the service specific status bit definitions refer to service header files * Eg. Crypto Status bit refers to Symmetric Crypto, Key Generation, and NRBG * Requests' Status. Unused bits e.g. reserved bits need to have been forced to * 0. */ #define QAT_COMN_RESP_CRYPTO_STATUS_BITPOS 7 /**< @ingroup icp_qat_fw_comn * Starting bit position indicating Response for Crypto service Flag */ #define QAT_COMN_RESP_CRYPTO_STATUS_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask used to determine Crypto status mask */ #define QAT_COMN_RESP_PKE_STATUS_BITPOS 6 /**< @ingroup icp_qat_fw_comn * Starting bit position indicating Response for PKE service Flag */ #define QAT_COMN_RESP_PKE_STATUS_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask used to determine PKE status mask */ #define QAT_COMN_RESP_CMP_STATUS_BITPOS 5 /**< @ingroup icp_qat_fw_comn * Starting bit position indicating Response for Compression service Flag */ #define QAT_COMN_RESP_CMP_STATUS_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask used to determine Compression status mask */ #define QAT_COMN_RESP_XLAT_STATUS_BITPOS 4 /**< @ingroup icp_qat_fw_comn * Starting bit position indicating Response for Xlat service Flag */ #define QAT_COMN_RESP_XLAT_STATUS_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask used to determine Translator status mask */ #define QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS 3 /**< @ingroup icp_qat_fw_comn * Starting bit position indicating the last block in a deflate stream for the compression service Flag */ #define QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask used to determine the last block in a deflate stream status mask */ #define QAT_COMN_RESP_UNSUPPORTED_REQUEST_BITPOS 2 /**< @ingroup icp_qat_fw_comn * Starting bit position indicating when an unsupported service request Flag */ #define QAT_COMN_RESP_UNSUPPORTED_REQUEST_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask used to determine the unsupported service request status mask */ #define QAT_COMN_RESP_XLT_INV_APPLIED_BITPOS 0 /**< @ingroup icp_qat_fw_comn * Bit position indicating that firmware detected an invalid translation during * dynamic compression and took measures to overcome this * */ #define QAT_COMN_RESP_XLT_INV_APPLIED_MASK 0x1 /**< @ingroup icp_qat_fw_comn * One bit mask */ /** ****************************************************************************** * @description * Macro that must be used when building the status * for the common response * * @param crypto Value of the Crypto Service status flag * @param comp Value of the Compression Service Status flag * @param xlat Value of the Xlator Status flag * @param eolb Value of the Compression End of Last Block Status flag * @param unsupp Value of the Unsupported Request flag * @param xlt_inv Value of the Invalid Translation flag *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_STATUS_BUILD( \ crypto, pke, comp, xlat, eolb, unsupp, xlt_inv) \ ((((crypto)&QAT_COMN_RESP_CRYPTO_STATUS_MASK) \ << QAT_COMN_RESP_CRYPTO_STATUS_BITPOS) | \ (((pke)&QAT_COMN_RESP_PKE_STATUS_MASK) \ << QAT_COMN_RESP_PKE_STATUS_BITPOS) | \ (((xlt_inv)&QAT_COMN_RESP_XLT_INV_APPLIED_MASK) \ << QAT_COMN_RESP_XLT_INV_APPLIED_BITPOS) | \ (((comp)&QAT_COMN_RESP_CMP_STATUS_MASK) \ << QAT_COMN_RESP_CMP_STATUS_BITPOS) | \ (((xlat)&QAT_COMN_RESP_XLAT_STATUS_MASK) \ << QAT_COMN_RESP_XLAT_STATUS_BITPOS) | \ (((eolb)&QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK) \ << QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS) | \ (((unsupp)&QAT_COMN_RESP_UNSUPPORTED_REQUEST_BITPOS) \ << QAT_COMN_RESP_UNSUPPORTED_REQUEST_MASK)) /* ========================================================================= */ /* GETTERS */ /* ========================================================================= */ /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the Crypto bit from the status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_CRYPTO_STATUS_BITPOS, \ QAT_COMN_RESP_CRYPTO_STATUS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the PKE bit from the status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_PKE_STAT_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_PKE_STATUS_BITPOS, \ QAT_COMN_RESP_PKE_STATUS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the Compression bit from the status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_CMP_STATUS_BITPOS, \ QAT_COMN_RESP_CMP_STATUS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the Translator bit from the status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_XLAT_STATUS_BITPOS, \ QAT_COMN_RESP_XLAT_STATUS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the Translation Invalid bit * from the status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_XLT_INV_APPLIED_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_XLT_INV_APPLIED_BITPOS, \ QAT_COMN_RESP_XLT_INV_APPLIED_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the end of compression block bit from the * status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS, \ QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Macro for extraction of the Unsupported request from the status * * @param status * Status to extract the status bit from * *****************************************************************************/ #define ICP_QAT_FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET(status) \ QAT_FIELD_GET(status, \ QAT_COMN_RESP_UNSUPPORTED_REQUEST_BITPOS, \ QAT_COMN_RESP_UNSUPPORTED_REQUEST_MASK) /* ========================================================================= */ /* Status Flag definitions */ /* ========================================================================= */ #define ICP_QAT_FW_COMN_STATUS_FLAG_OK 0 /**< @ingroup icp_qat_fw_comn * Definition of successful processing of a request */ #define ICP_QAT_FW_COMN_STATUS_FLAG_ERROR 1 /**< @ingroup icp_qat_fw_comn * Definition of erroneous processing of a request */ #define ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_CLR 0 /**< @ingroup icp_qat_fw_comn * Final Deflate block of a compression request not completed */ #define ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET 1 /**< @ingroup icp_qat_fw_comn * Final Deflate block of a compression request completed */ #define ERR_CODE_NO_ERROR 0 /**< Error Code constant value for no error */ #define ERR_CODE_INVALID_BLOCK_TYPE -1 /* Invalid block type (type == 3)*/ #define ERR_CODE_NO_MATCH_ONES_COMP -2 /* Stored block length does not match one's complement */ #define ERR_CODE_TOO_MANY_LEN_OR_DIS -3 /* Too many length or distance codes */ #define ERR_CODE_INCOMPLETE_LEN -4 /* Code lengths codes incomplete */ #define ERR_CODE_RPT_LEN_NO_FIRST_LEN -5 /* Repeat lengths with no first length */ #define ERR_CODE_RPT_GT_SPEC_LEN -6 /* Repeat more than specified lengths */ #define ERR_CODE_INV_LIT_LEN_CODE_LEN -7 /* Invalid lit/len code lengths */ #define ERR_CODE_INV_DIS_CODE_LEN -8 /* Invalid distance code lengths */ #define ERR_CODE_INV_LIT_LEN_DIS_IN_BLK -9 /* Invalid lit/len or distance code in fixed/dynamic block */ #define ERR_CODE_DIS_TOO_FAR_BACK -10 /* Distance too far back in fixed or dynamic block */ /* Common Error code definitions */ #define ERR_CODE_OVERFLOW_ERROR -11 /**< Error Code constant value for overflow error */ #define ERR_CODE_SOFT_ERROR -12 /**< Error Code constant value for soft error */ #define ERR_CODE_FATAL_ERROR -13 /**< Error Code constant value for hard/fatal error */ #define ERR_CODE_COMP_OUTPUT_CORRUPTION -14 /**< Error Code constant for compression output corruption */ #define ERR_CODE_HW_INCOMPLETE_FILE -15 /**< Error Code constant value for incomplete file hardware error */ #define ERR_CODE_SSM_ERROR -16 /**< Error Code constant value for error detected by SSM e.g. slice hang */ #define ERR_CODE_ENDPOINT_ERROR -17 /**< Error Code constant value for error detected by PCIe Endpoint, e.g. push * data error */ #define ERR_CODE_CNV_ERROR -18 /**< Error Code constant value for cnv failure */ #define ERR_CODE_EMPTY_DYM_BLOCK -19 /**< Error Code constant value for submission of empty dynamic stored block to * slice */ #define ERR_CODE_REGION_OUT_OF_BOUNDS -21 /**< Error returned when decompression ends before the specified partial * decompression region was produced */ #define ERR_CODE_MISC_ERROR -50 /**< Error Code constant for error detected but the source * of error is not recognized */ /** ***************************************************************************** * @ingroup icp_qat_fw_comn * Slice types for building of the processing chain within the content * descriptor * * @description * Enumeration used to indicate the ids of the slice types through which * data will pass. * * A logical slice is not a hardware slice but is a software FSM * performing the actions of a slice * *****************************************************************************/ typedef enum { ICP_QAT_FW_SLICE_NULL = 0, /**< NULL slice type */ ICP_QAT_FW_SLICE_CIPHER = 1, /**< CIPHER slice type */ ICP_QAT_FW_SLICE_AUTH = 2, /**< AUTH slice type */ ICP_QAT_FW_SLICE_DRAM_RD = 3, /**< DRAM_RD Logical slice type */ ICP_QAT_FW_SLICE_DRAM_WR = 4, /**< DRAM_WR Logical slice type */ ICP_QAT_FW_SLICE_COMP = 5, /**< Compression slice type */ ICP_QAT_FW_SLICE_XLAT = 6, /**< Translator slice type */ ICP_QAT_FW_SLICE_DELIMITER /**< End delimiter */ } icp_qat_fw_slice_t; #endif /* _ICP_QAT_FW_H_ */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_comp.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_comp.h index fe1b7ad55de8..834359c66c03 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_comp.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_comp.h @@ -1,1146 +1,1141 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file icp_qat_fw_comp.h * @defgroup icp_qat_fw_comp ICP QAT FW Compression Service * Interface Definitions * @ingroup icp_qat_fw * @description * This file documents structs used to provide the interface to the * Compression QAT FW service * *****************************************************************************/ #ifndef _ICP_QAT_FW_COMP_H_ #define _ICP_QAT_FW_COMP_H_ /* ****************************************************************************** * Include local header files ****************************************************************************** */ #include "icp_qat_fw.h" /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the Compression command types * @description * Enumeration which is used to indicate the ids of functions * that are exposed by the Compression QAT FW service * *****************************************************************************/ typedef enum { ICP_QAT_FW_COMP_CMD_STATIC = 0, /*!< Static Compress Request */ ICP_QAT_FW_COMP_CMD_DYNAMIC = 1, /*!< Dynamic Compress Request */ ICP_QAT_FW_COMP_CMD_DECOMPRESS = 2, /*!< Decompress Request */ ICP_QAT_FW_COMP_CMD_DELIMITER /**< Delimiter type */ } icp_qat_fw_comp_cmd_id_t; - /* * REQUEST FLAGS IN COMMON COMPRESSION * In common message it is named as SERVICE SPECIFIC FLAGS. * * + ===== + ------ + ------ + --- + ----- + ----- + ----- + -- + ---- + --- + * | Bit | 15 - 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * + ===== + ------ + ----- + --- + ----- + ----- + ----- + -- + ---- + --- + * | Flags | Rsvd | Dis. |Resvd| Dis. | Enh. |Auto |Sess| Rsvd | Rsvd| * | | Bits | secure | =0 | Type0 | ASB |Select |Type| = 0 | = 0 | * | | = 0 |RAM use | | Header | |Best | | | | * | | |as intmd| | | | | | | | * | | | buf | | | | | | | | * + ===== + ------ + ----- + --- + ------ + ----- + ----- + -- + ---- + --- + * Note: For QAT 2.0 Disable Secure Ram, DisType0 Header and Enhanced ASB bits * are don't care. i.e., these features are removed from QAT 2.0. */ - /**< Flag usage */ #define ICP_QAT_FW_COMP_STATELESS_SESSION 0 /**< @ingroup icp_qat_fw_comp * Flag representing that session is stateless */ #define ICP_QAT_FW_COMP_STATEFUL_SESSION 1 /**< @ingroup icp_qat_fw_comp * Flag representing that session is stateful */ #define ICP_QAT_FW_COMP_NOT_AUTO_SELECT_BEST 0 /**< @ingroup icp_qat_fw_comp * Flag representing that autoselectbest is NOT used */ #define ICP_QAT_FW_COMP_AUTO_SELECT_BEST 1 /**< @ingroup icp_qat_fw_comp * Flag representing that autoselectbest is used */ #define ICP_QAT_FW_COMP_NOT_ENH_AUTO_SELECT_BEST 0 /**< @ingroup icp_qat_fw_comp * Flag representing that enhanced autoselectbest is NOT used */ #define ICP_QAT_FW_COMP_ENH_AUTO_SELECT_BEST 1 /**< @ingroup icp_qat_fw_comp * Flag representing that enhanced autoselectbest is used */ #define ICP_QAT_FW_COMP_NOT_DISABLE_TYPE0_ENH_AUTO_SELECT_BEST 0 /**< @ingroup icp_qat_fw_comp * Flag representing that enhanced autoselectbest is NOT used */ #define ICP_QAT_FW_COMP_DISABLE_TYPE0_ENH_AUTO_SELECT_BEST 1 /**< @ingroup icp_qat_fw_comp * Flag representing that enhanced autoselectbest is used */ #define ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_USED_AS_INTMD_BUF 1 /**< @ingroup icp_qat_fw_comp * Flag representing secure RAM from being used as * an intermediate buffer is DISABLED. */ #define ICP_QAT_FW_COMP_ENABLE_SECURE_RAM_USED_AS_INTMD_BUF 0 /**< @ingroup icp_qat_fw_comp * Flag representing secure RAM from being used as * an intermediate buffer is ENABLED. */ /**< Flag mask & bit position */ #define ICP_QAT_FW_COMP_SESSION_TYPE_BITPOS 2 /**< @ingroup icp_qat_fw_comp * Starting bit position for the session type */ #define ICP_QAT_FW_COMP_SESSION_TYPE_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask used to determine the session type */ #define ICP_QAT_FW_COMP_AUTO_SELECT_BEST_BITPOS 3 /**< @ingroup icp_qat_fw_comp * Starting bit position for auto select best */ #define ICP_QAT_FW_COMP_AUTO_SELECT_BEST_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for auto select best */ #define ICP_QAT_FW_COMP_ENHANCED_AUTO_SELECT_BEST_BITPOS 4 /**< @ingroup icp_qat_fw_comp * Starting bit position for enhanced auto select best */ #define ICP_QAT_FW_COMP_ENHANCED_AUTO_SELECT_BEST_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for enhanced auto select best */ #define ICP_QAT_FW_COMP_RET_DISABLE_TYPE0_HEADER_DATA_BITPOS 5 /**< @ingroup icp_qat_fw_comp * Starting bit position for disabling type zero header write back when Enhanced autoselect best is enabled. If set firmware does not return type0 store block header, only copies src to dest. (if best output is Type0) */ #define ICP_QAT_FW_COMP_RET_DISABLE_TYPE0_HEADER_DATA_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for auto select best */ #define ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_AS_INTMD_BUF_BITPOS 7 /**< @ingroup icp_qat_fw_comp * Starting bit position for flag used to disable secure ram from being used as an intermediate buffer. */ #define ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_AS_INTMD_BUF_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for disable secure ram for use as an intermediate buffer. */ /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro used for the generation of the command flags for Compression Request. * This should always be used for the generation of the flags. No direct sets or * masks should be performed on the flags data * * @param sesstype Session Type * @param autoselect AutoSelectBest * @enhanced_asb Enhanced AutoSelectBest * @ret_uncomp RetUnCompressed * @secure_ram Secure Ram usage * ******************************************************************************/ #define ICP_QAT_FW_COMP_FLAGS_BUILD( \ sesstype, autoselect, enhanced_asb, ret_uncomp, secure_ram) \ (((sesstype & ICP_QAT_FW_COMP_SESSION_TYPE_MASK) \ << ICP_QAT_FW_COMP_SESSION_TYPE_BITPOS) | \ ((autoselect & ICP_QAT_FW_COMP_AUTO_SELECT_BEST_MASK) \ << ICP_QAT_FW_COMP_AUTO_SELECT_BEST_BITPOS) | \ ((enhanced_asb & ICP_QAT_FW_COMP_ENHANCED_AUTO_SELECT_BEST_MASK) \ << ICP_QAT_FW_COMP_ENHANCED_AUTO_SELECT_BEST_BITPOS) | \ ((ret_uncomp & ICP_QAT_FW_COMP_RET_DISABLE_TYPE0_HEADER_DATA_MASK) \ << ICP_QAT_FW_COMP_RET_DISABLE_TYPE0_HEADER_DATA_BITPOS) | \ ((secure_ram & ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_AS_INTMD_BUF_MASK) \ << ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_AS_INTMD_BUF_BITPOS)) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro used for the generation of the command flags for Compression Request. * This should always be used for the generation of the flags. No direct sets or * masks should be performed on the flags data * * @param sesstype Session Type * @param autoselect AutoSelectBest * Selects between compressed and uncompressed output. * No distinction made between static and dynamic * compressed data. * *********************************************************************************/ #define ICP_QAT_FW_COMP_20_FLAGS_BUILD(sesstype, autoselect) \ (((sesstype & ICP_QAT_FW_COMP_SESSION_TYPE_MASK) \ << ICP_QAT_FW_COMP_SESSION_TYPE_BITPOS) | \ ((autoselect & ICP_QAT_FW_COMP_AUTO_SELECT_BEST_MASK) \ << ICP_QAT_FW_COMP_AUTO_SELECT_BEST_BITPOS)) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the session type bit * * @param flags Flags to extract the session type bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_SESSION_TYPE_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_SESSION_TYPE_BITPOS, \ ICP_QAT_FW_COMP_SESSION_TYPE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the autoSelectBest bit * * @param flags Flags to extract the autoSelectBest bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_AUTO_SELECT_BEST_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_AUTO_SELECT_BEST_BITPOS, \ ICP_QAT_FW_COMP_AUTO_SELECT_BEST_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the enhanced asb bit * * @param flags Flags to extract the enhanced asb bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_EN_ASB_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_ENHANCED_AUTO_SELECT_BEST_BITPOS, \ ICP_QAT_FW_COMP_ENHANCED_AUTO_SELECT_BEST_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the RetUncomp bit * * @param flags Flags to extract the Ret Uncomp bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_RET_UNCOMP_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_RET_DISABLE_TYPE0_HEADER_DATA_BITPOS, \ ICP_QAT_FW_COMP_RET_DISABLE_TYPE0_HEADER_DATA_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the Secure Ram usage bit * * @param flags Flags to extract the Secure Ram usage from * *****************************************************************************/ #define ICP_QAT_FW_COMP_SECURE_RAM_USE_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_AS_INTMD_BUF_BITPOS, \ ICP_QAT_FW_COMP_DISABLE_SECURE_RAM_AS_INTMD_BUF_MASK) /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the compression header cd pars block * @description * Definition of the compression processing cd pars block. * The structure is a service-specific implementation of the common * structure. *****************************************************************************/ typedef union icp_qat_fw_comp_req_hdr_cd_pars_s { /**< LWs 2-5 */ struct { uint64_t content_desc_addr; /**< Address of the content descriptor */ uint16_t content_desc_resrvd1; /**< Content descriptor reserved field */ uint8_t content_desc_params_sz; /**< Size of the content descriptor parameters in quad words. * These parameters describe the session setup configuration * info for the slices that this request relies upon i.e. the * configuration word and cipher key needed by the cipher slice * if there is a request for cipher processing. */ uint8_t content_desc_hdr_resrvd2; /**< Content descriptor reserved field */ uint32_t content_desc_resrvd3; /**< Content descriptor reserved field */ } s; struct { uint32_t comp_slice_cfg_word[ICP_QAT_FW_NUM_LONGWORDS_2]; /* Compression Slice Config Word */ uint32_t content_desc_resrvd4; /**< Content descriptor reserved field */ } sl; } icp_qat_fw_comp_req_hdr_cd_pars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the compression request parameters block * @description * Definition of the compression processing request parameters block. * The structure below forms part of the Compression + Translation * Parameters block spanning LWs 14-23, thus differing from the common * base Parameters block structure. Unused fields must be set to 0. * *****************************************************************************/ typedef struct icp_qat_fw_comp_req_params_s { /**< LW 14 */ uint32_t comp_len; /**< Size of input to process in bytes Note: Only EOP requests can be * odd for decompression. IA must set LSB to zero for odd sized * intermediate inputs */ /**< LW 15 */ uint32_t out_buffer_sz; /**< Size of output buffer in bytes */ /**< LW 16 */ union { struct { /** LW 16 */ uint32_t initial_crc32; /**< CRC for processed bytes (input byte count) */ /** LW 17 */ uint32_t initial_adler; /**< Adler for processed bytes (input byte count) */ } legacy; /** LW 16-17 */ uint64_t crc_data_addr; /**< CRC data structure pointer */ } crc; /**< LW 18 */ uint32_t req_par_flags; /**< LW 19 */ uint32_t rsrvd; } icp_qat_fw_comp_req_params_t; /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro used for the generation of the request parameter flags. * This should always be used for the generation of the flags. No direct sets or * masks should be performed on the flags data * * @param sop SOP Flag, 0 restore, 1 don't restore * @param eop EOP Flag, 0 restore, 1 don't restore * @param bfinal Set bfinal in this block or not * @param cnv Whether internal CNV check is to be performed * * ICP_QAT_FW_COMP_NO_CNV * * ICP_QAT_FW_COMP_CNV * @param cnvnr Whether internal CNV recovery is to be performed * * ICP_QAT_FW_COMP_NO_CNV_RECOVERY * * ICP_QAT_FW_COMP_CNV_RECOVERY * @param cnvdfx Whether CNV error injection is to be performed * * ICP_QAT_FW_COMP_NO_CNV_DFX * * ICP_QAT_FW_COMP_CNV_DFX * @param crc CRC Mode Flag - 0 legacy, 1 crc data struct *****************************************************************************/ #define ICP_QAT_FW_COMP_REQ_PARAM_FLAGS_BUILD( \ sop, eop, bfinal, cnv, cnvnr, cnvdfx, crc) \ (((sop & ICP_QAT_FW_COMP_SOP_MASK) << ICP_QAT_FW_COMP_SOP_BITPOS) | \ ((eop & ICP_QAT_FW_COMP_EOP_MASK) << ICP_QAT_FW_COMP_EOP_BITPOS) | \ ((bfinal & ICP_QAT_FW_COMP_BFINAL_MASK) \ << ICP_QAT_FW_COMP_BFINAL_BITPOS) | \ ((cnv & ICP_QAT_FW_COMP_CNV_MASK) << ICP_QAT_FW_COMP_CNV_BITPOS) | \ ((cnvnr & ICP_QAT_FW_COMP_CNVNR_MASK) \ << ICP_QAT_FW_COMP_CNVNR_BITPOS) | \ ((cnvdfx & ICP_QAT_FW_COMP_CNV_DFX_MASK) \ << ICP_QAT_FW_COMP_CNV_DFX_BITPOS) | \ ((crc & ICP_QAT_FW_COMP_CRC_MODE_MASK) \ << ICP_QAT_FW_COMP_CRC_MODE_BITPOS)) - /* * REQUEST FLAGS IN REQUEST PARAMETERS COMPRESSION * * +=====+-----+----- + --- + --- +-----+ --- + ----- + --- + ---- + -- + -- + * | Bit |31-24| 20 | 19 | 18 | 17 | 16 | 15-7 | 6 | 5-2 | 1 | 0 | * +=====+-----+----- + --- + ----+-----+ --- + ----- + --- + ---- + -- + -- + * |Flags|Resvd|xxHash| CRC | CNV |CNVNR| CNV | Resvd |BFin | Resvd|EOP |SOP | * | |=0 |acc | MODE| DFX | | | =0 | | =0 | | | * | | | | | | | | | | | | | * +=====+-----+----- + --- + ----+-----+ --- + ----- + --- + ---- + -- + -- + */ - /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the additional QAT2.0 Compression command types * @description * Enumeration which is used to indicate the ids of functions * that are exposed by the Compression QAT FW service * *****************************************************************************/ typedef enum { ICP_QAT_FW_COMP_20_CMD_LZ4_COMPRESS = 3, /*!< LZ4 Compress Request */ ICP_QAT_FW_COMP_20_CMD_LZ4_DECOMPRESS = 4, /*!< LZ4 Decompress Request */ ICP_QAT_FW_COMP_20_CMD_LZ4S_COMPRESS = 5, /*!< LZ4S Compress Request */ ICP_QAT_FW_COMP_20_CMD_LZ4S_DECOMPRESS = 6, /*!< LZ4S Decompress Request */ - ICP_QAT_FW_COMP_20_CMD_XP10_COMPRESS = 7, - /*!< XP10 Compress Request -- Placeholder */ + ICP_QAT_FW_COMP_20_CMD_RESERVED_1 = 7, + /*!< Placeholder */ - ICP_QAT_FW_COMP_20_CMD_XP10_DECOMPRESS = 8, - /*!< XP10 Decompress Request -- Placeholder */ + ICP_QAT_FW_COMP_20_CMD_RESERVED_2 = 8, + /*!< Placeholder */ ICP_QAT_FW_COMP_20_CMD_DELIMITER /**< Delimiter type */ } icp_qat_fw_comp_20_cmd_id_t; - /* * REQUEST FLAGS IN REQUEST PARAMETERS COMPRESSION * * + ===== + ----- + --- +-----+-------+ --- + ---------+ --- + ---- + --- + --- + * | Bit | 31-20 | 19 | 18 | 17 | 16 | 15 - 7 | 6 | 5-2 | 1 | 0 | * + ===== + ----- + --- +-----+-------+ --- + ---------+ --- | ---- + --- + --- + * | Flags | Resvd | CRC | CNV | CNVNR | CNV |Resvd Bits|BFin |Resvd | EOP | SOP | * | | =0 | Mode| DFX | | | =0 | | =0 | | | * | | | | | | | | | | | | * + ===== + ----- + --- +-----+-------+ --- + ---------+ --- | ---- + --- + --- + */ #define ICP_QAT_FW_COMP_NOT_SOP 0 /**< @ingroup icp_qat_fw_comp * Flag representing that a request is NOT Start of Packet */ #define ICP_QAT_FW_COMP_SOP 1 /**< @ingroup icp_qat_fw_comp * * Flag representing that a request IS Start of Packet */ #define ICP_QAT_FW_COMP_NOT_EOP 0 /**< @ingroup icp_qat_fw_comp * Flag representing that a request is NOT Start of Packet */ #define ICP_QAT_FW_COMP_EOP 1 /**< @ingroup icp_qat_fw_comp * Flag representing that a request IS End of Packet */ #define ICP_QAT_FW_COMP_NOT_BFINAL 0 /**< @ingroup icp_qat_fw_comp * Flag representing to indicate firmware this is not the last block */ #define ICP_QAT_FW_COMP_BFINAL 1 /**< @ingroup icp_qat_fw_comp * Flag representing to indicate firmware this is the last block */ #define ICP_QAT_FW_COMP_NO_CNV 0 /**< @ingroup icp_qat_fw_comp * Flag indicating that NO cnv check is to be performed on the request */ #define ICP_QAT_FW_COMP_CNV 1 /**< @ingroup icp_qat_fw_comp * Flag indicating that a cnv check IS to be performed on the request */ #define ICP_QAT_FW_COMP_NO_CNV_RECOVERY 0 /**< @ingroup icp_qat_fw_comp * Flag indicating that NO cnv recovery is to be performed on the request */ #define ICP_QAT_FW_COMP_CNV_RECOVERY 1 /**< @ingroup icp_qat_fw_comp * Flag indicating that a cnv recovery is to be performed on the request */ #define ICP_QAT_FW_COMP_NO_CNV_DFX 0 /**< @ingroup icp_qat_fw_comp * Flag indicating that NO CNV inject error is to be performed on the request */ #define ICP_QAT_FW_COMP_CNV_DFX 1 /**< @ingroup icp_qat_fw_comp * Flag indicating that CNV inject error is to be performed on the request */ #define ICP_QAT_FW_COMP_CRC_MODE_LEGACY 0 /**< @ingroup icp_qat_fw_comp * Flag representing to use the legacy CRC mode */ #define ICP_QAT_FW_COMP_CRC_MODE_E2E 1 /**< @ingroup icp_qat_fw_comp * Flag representing to use the external CRC data struct */ #define ICP_QAT_FW_COMP_NO_XXHASH_ACC 0 /**< @ingroup icp_qat_fw_comp * * Flag indicating that xxHash will NOT be accumulated across requests */ #define ICP_QAT_FW_COMP_XXHASH_ACC 1 /**< @ingroup icp_qat_fw_comp * * Flag indicating that xxHash WILL be accumulated across requests */ #define ICP_QAT_FW_COMP_PART_DECOMP 1 /**< @ingroup icp_qat_fw_comp * * Flag indicating to perform partial de-compressing */ #define ICP_QAT_FW_COMP_NO_PART_DECOMP 1 /**< @ingroup icp_qat_fw_comp * * Flag indicating to not perform partial de-compressing */ #define ICP_QAT_FW_COMP_ZEROPAD 1 /**< @ingroup icp_qat_fw_comp * * Flag indicating to perform zero-padding in compression request */ #define ICP_QAT_FW_COMP_NO_ZEROPAD 0 /**< @ingroup icp_qat_fw_comp * * Flag indicating to not perform zero-padding in compression request */ #define ICP_QAT_FW_COMP_SOP_BITPOS 0 /**< @ingroup icp_qat_fw_comp * Starting bit position for SOP */ #define ICP_QAT_FW_COMP_SOP_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask used to determine SOP */ #define ICP_QAT_FW_COMP_EOP_BITPOS 1 /**< @ingroup icp_qat_fw_comp * Starting bit position for EOP */ #define ICP_QAT_FW_COMP_EOP_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask used to determine EOP */ #define ICP_QAT_FW_COMP_BFINAL_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for the bfinal bit */ #define ICP_QAT_FW_COMP_BFINAL_BITPOS 6 /**< @ingroup icp_qat_fw_comp * Starting bit position for the bfinal bit */ #define ICP_QAT_FW_COMP_CNV_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for the CNV bit */ #define ICP_QAT_FW_COMP_CNV_BITPOS 16 /**< @ingroup icp_qat_fw_comp * Starting bit position for the CNV bit */ #define ICP_QAT_FW_COMP_CNVNR_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for the CNV Recovery bit */ #define ICP_QAT_FW_COMP_CNVNR_BITPOS 17 /**< @ingroup icp_qat_fw_comp * Starting bit position for the CNV Recovery bit */ #define ICP_QAT_FW_COMP_CNV_DFX_BITPOS 18 /**< @ingroup icp_qat_fw_comp * Starting bit position for the CNV DFX bit */ #define ICP_QAT_FW_COMP_CNV_DFX_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask for the CNV DFX bit */ #define ICP_QAT_FW_COMP_CRC_MODE_BITPOS 19 /**< @ingroup icp_qat_fw_comp * Starting bit position for CRC mode */ #define ICP_QAT_FW_COMP_CRC_MODE_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask used to determine CRC mode */ #define ICP_QAT_FW_COMP_XXHASH_ACC_MODE_BITPOS 20 /**< @ingroup icp_qat_fw_comp * Starting bit position for xxHash accumulate mode */ #define ICP_QAT_FW_COMP_XXHASH_ACC_MODE_MASK 0x1 /**< @ingroup icp_qat_fw_comp * One bit mask used to determine xxHash accumulate mode */ #define ICP_QAT_FW_COMP_PART_DECOMP_BITPOS 27 /**< @ingroup icp_qat_fw_comp * Starting bit position for the partial de-compress bit */ #define ICP_QAT_FW_COMP_PART_DECOMP_MASK 0x1 /**< @ingroup icp_qat_fw_comp * Starting bit position for the partial de-compress mask */ #define ICP_QAT_FW_COMP_ZEROPAD_BITPOS 26 /**< @ingroup icp_qat_fw_comp * Starting bit position for the partial zero-pad bit */ #define ICP_QAT_FW_COMP_ZEROPAD_MASK 0x1 /**< @ingroup icp_qat_fw_comp * Starting bit position for the partial zero-pad mask */ /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the SOP bit * * @param flags Flags to extract the SOP bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_SOP_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_SOP_BITPOS, \ ICP_QAT_FW_COMP_SOP_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the EOP bit * * @param flags Flags to extract the EOP bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_EOP_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_EOP_BITPOS, \ ICP_QAT_FW_COMP_EOP_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the bfinal bit * * @param flags Flags to extract the bfinal bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_BFINAL_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_BFINAL_BITPOS, \ ICP_QAT_FW_COMP_BFINAL_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the CNV bit * * @param flags Flag set containing the CNV flag * *****************************************************************************/ #define ICP_QAT_FW_COMP_CNV_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_CNV_BITPOS, \ ICP_QAT_FW_COMP_CNV_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the crc mode bit * * @param flags Flags to extract the crc mode bit from * ******************************************************************************/ #define ICP_QAT_FW_COMP_CRC_MODE_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_CRC_MODE_BITPOS, \ ICP_QAT_FW_COMP_CRC_MODE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the xxHash accumulate mode bit * * @param flags Flags to extract the xxHash accumulate mode bit from * *****************************************************************************/ #define ICP_QAT_FW_COMP_XXHASH_ACC_MODE_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_XXHASH_ACC_MODE_BITPOS, \ ICP_QAT_FW_COMP_XXHASH_ACC_MODE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for setting of the xxHash accumulate mode bit * * @param flags Flags to set the xxHash accumulate mode bit to * @param val xxHash accumulate mode to set * *****************************************************************************/ #define ICP_QAT_FW_COMP_XXHASH_ACC_MODE_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ ICP_QAT_FW_COMP_XXHASH_ACC_MODE_BITPOS, \ ICP_QAT_FW_COMP_XXHASH_ACC_MODE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the partial de-compress on/off bit * * @param flags Flags to extract the partial de-compress on/off bit from * ******************************************************************************/ #define ICP_QAT_FW_COMP_PART_DECOMP_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_PART_DECOMP_BITPOS, \ ICP_QAT_FW_COMP_PART_DECOMP_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for setting of the partial de-compress on/off bit * * @param flags Flags to set the partial de-compress on/off bit to * @param val partial de-compress on/off bit * *****************************************************************************/ #define ICP_QAT_FW_COMP_PART_DECOMP_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ ICP_QAT_FW_COMP_PART_DECOMP_BITPOS, \ ICP_QAT_FW_COMP_PART_DECOMP_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for extraction of the zero padding on/off bit * * @param flags Flags to extract the zero padding on/off bit from * ******************************************************************************/ #define ICP_QAT_FW_COMP_ZEROPAD_GET(flags) \ QAT_FIELD_GET(flags, \ ICP_QAT_FW_COMP_ZEROPAD_BITPOS, \ ICP_QAT_FW_COMP_ZEROPAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Macro for setting of the zero-padding on/off bit * * @param flags Flags to set the zero-padding on/off bit to * @param val zero-padding on/off bit * *****************************************************************************/ #define ICP_QAT_FW_COMP_ZEROPAD_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ ICP_QAT_FW_COMP_ZEROPAD_BITPOS, \ ICP_QAT_FW_COMP_ZEROPAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the translator request parameters block * @description * Definition of the translator processing request parameters block * The structure below forms part of the Compression + Translation * Parameters block spanning LWs 14-23, thus differing from the common * base Parameters block structure. Unused fields must be set to 0. * *****************************************************************************/ typedef struct icp_qat_fw_xlt_req_params_s { /**< LWs 20-21 */ uint64_t inter_buff_ptr; /**< This field specifies the physical address of an intermediate * buffer SGL array. The array contains a pair of 64-bit * intermediate buffer pointers to SGL buffer descriptors, one pair * per CPM. Please refer to the CPM1.6 Firmware Interface HLD * specification for more details. */ } icp_qat_fw_xlt_req_params_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Compression header of the content descriptor block * @description * Definition of the service-specific compression control block header * structure. The compression parameters are defined per algorithm * and are located in the icp_qat_hw.h file. This compression * cd block spans LWs 24-29, forming part of the compression + translation * cd block, thus differing from the common base content descriptor * structure. * *****************************************************************************/ typedef struct icp_qat_fw_comp_cd_hdr_s { /**< LW 24 */ uint16_t ram_bank_flags; /**< Flags to show which ram banks to access */ uint8_t comp_cfg_offset; /**< Quad word offset from the content descriptor parameters address to * the parameters for the compression processing */ uint8_t next_curr_id; /**< This field combines the next and current id (each four bits) - * the next id is the most significant nibble. * Next Id: Set to the next slice to pass the compressed data through. * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through * anymore slices after compression * Current Id: Initialised with the compression slice type */ /**< LW 25 */ uint32_t resrvd; /**< LWs 26-27 */ uint64_t comp_state_addr; /**< Pointer to compression state */ /**< LWs 28-29 */ uint64_t ram_banks_addr; /**< Pointer to banks */ } icp_qat_fw_comp_cd_hdr_t; #define COMP_CPR_INITIAL_CRC 0 #define COMP_CPR_INITIAL_ADLER 1 /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Translator content descriptor header block * @description * Definition of the structure used to describe the translation processing * to perform on data. The translator parameters are defined per algorithm * and are located in the icp_qat_hw.h file. This translation cd block * spans LWs 30-31, forming part of the compression + translation cd block, * thus differing from the common base content descriptor structure. * *****************************************************************************/ typedef struct icp_qat_fw_xlt_cd_hdr_s { /**< LW 30 */ uint16_t resrvd1; /**< Reserved field and assumed set to 0 */ uint8_t resrvd2; /**< Reserved field and assumed set to 0 */ uint8_t next_curr_id; /**< This field combines the next and current id (each four bits) - * the next id is the most significant nibble. * Next Id: Set to the next slice to pass the translated data through. * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through * any more slices after compression * Current Id: Initialised with the translation slice type */ /**< LW 31 */ uint32_t resrvd3; /**< Reserved and should be set to zero, needed for quadword alignment */ } icp_qat_fw_xlt_cd_hdr_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the common Compression QAT FW request * @description * This is a definition of the full request structure for * compression and translation. * *****************************************************************************/ typedef struct icp_qat_fw_comp_req_s { /**< LWs 0-1 */ icp_qat_fw_comn_req_hdr_t comn_hdr; /**< Common request header - for Service Command Id, * use service-specific Compression Command Id. * Service Specific Flags - use Compression Command Flags */ /**< LWs 2-5 */ icp_qat_fw_comp_req_hdr_cd_pars_t cd_pars; /**< Compression service-specific content descriptor field which points * either to a content descriptor parameter block or contains the * compression slice config word. */ /**< LWs 6-13 */ icp_qat_fw_comn_req_mid_t comn_mid; /**< Common request middle section */ /**< LWs 14-19 */ icp_qat_fw_comp_req_params_t comp_pars; /**< Compression request Parameters block */ /**< LWs 20-21 */ union { icp_qat_fw_xlt_req_params_t xlt_pars; /**< Translation request Parameters block */ uint32_t resrvd1[ICP_QAT_FW_NUM_LONGWORDS_2]; /**< Reserved if not used for translation */ struct { uint32_t partial_decompress_length; /**< LW 20 \n Length of the decompressed data to return */ uint32_t partial_decompress_offset; /**< LW 21 \n Offset of the decompressed data at which * to return */ } partial_decompress; } u1; /**< LWs 22-23 */ union { uint32_t resrvd2[ICP_QAT_FW_NUM_LONGWORDS_2]; /**< Reserved - not used if Batch and Pack is disabled.*/ uint64_t resrvd3; /**< Reserved - not used if Batch and Pack is disabled.*/ } u3; /**< LWs 24-29 */ icp_qat_fw_comp_cd_hdr_t comp_cd_ctrl; /**< Compression request content descriptor control * block header */ /**< LWs 30-31 */ union { icp_qat_fw_xlt_cd_hdr_t xlt_cd_ctrl; /**< Translation request content descriptor * control block header */ uint32_t resrvd3[ICP_QAT_FW_NUM_LONGWORDS_2]; /**< Reserved if not used for translation */ } u2; } icp_qat_fw_comp_req_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the compression QAT FW response descriptor parameters * @description * This part of the response is specific to the compression response. * *****************************************************************************/ typedef struct icp_qat_fw_resp_comp_pars_s { /**< LW 4 */ uint32_t input_byte_counter; /**< Input byte counter */ /**< LW 5 */ uint32_t output_byte_counter; /**< Output byte counter */ /** LW 6-7 */ union { struct { /** LW 6 */ uint32_t curr_crc32; /**< Current CRC32 */ /** LW 7 */ uint32_t curr_adler_32; /**< Current Adler32 */ } legacy; uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_2]; /**< Reserved if not in legacy mode */ } crc; } icp_qat_fw_resp_comp_pars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the Compression Eagle Tail Response * @description * This is the response delivered to the ET rings by the Compression * QAT FW service for all commands * *****************************************************************************/ typedef struct icp_qat_fw_comp_resp_s { /**< LWs 0-1 */ icp_qat_fw_comn_resp_hdr_t comn_resp; /**< Common interface response format see icp_qat_fw.h */ /**< LWs 2-3 */ uint64_t opaque_data; /**< Opaque data passed from the request to the response message */ /**< LWs 4-7 */ icp_qat_fw_resp_comp_pars_t comp_resp_pars; /**< Common response params (checksums and byte counts) */ } icp_qat_fw_comp_resp_t; /* RAM Bank defines */ #define QAT_FW_COMP_BANK_FLAG_MASK 0x1 #define QAT_FW_COMP_BANK_I_BITPOS 8 #define QAT_FW_COMP_BANK_H_BITPOS 7 #define QAT_FW_COMP_BANK_G_BITPOS 6 #define QAT_FW_COMP_BANK_F_BITPOS 5 #define QAT_FW_COMP_BANK_E_BITPOS 4 #define QAT_FW_COMP_BANK_D_BITPOS 3 #define QAT_FW_COMP_BANK_C_BITPOS 2 #define QAT_FW_COMP_BANK_B_BITPOS 1 #define QAT_FW_COMP_BANK_A_BITPOS 0 /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the ram bank enabled values * @description * Enumeration used to define whether a ram bank is enabled or not * *****************************************************************************/ typedef enum { ICP_QAT_FW_COMP_BANK_DISABLED = 0, /*!< BANK DISABLED */ ICP_QAT_FW_COMP_BANK_ENABLED = 1, /*!< BANK ENABLED */ ICP_QAT_FW_COMP_BANK_DELIMITER = 2 /**< Delimiter type */ } icp_qat_fw_comp_bank_enabled_t; /** ****************************************************************************** * @ingroup icp_qat_fw_comp * * @description * Build the ram bank flags in the compression content descriptor * which specify which banks are used to save history * * @param bank_i_enable * @param bank_h_enable * @param bank_g_enable * @param bank_f_enable * @param bank_e_enable * @param bank_d_enable * @param bank_c_enable * @param bank_b_enable * @param bank_a_enable *****************************************************************************/ #define ICP_QAT_FW_COMP_RAM_FLAGS_BUILD(bank_i_enable, \ bank_h_enable, \ bank_g_enable, \ bank_f_enable, \ bank_e_enable, \ bank_d_enable, \ bank_c_enable, \ bank_b_enable, \ bank_a_enable) \ ((((bank_i_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_I_BITPOS) | \ (((bank_h_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_H_BITPOS) | \ (((bank_g_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_G_BITPOS) | \ (((bank_f_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_F_BITPOS) | \ (((bank_e_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_E_BITPOS) | \ (((bank_d_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_D_BITPOS) | \ (((bank_c_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_C_BITPOS) | \ (((bank_b_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_B_BITPOS) | \ (((bank_a_enable)&QAT_FW_COMP_BANK_FLAG_MASK) \ << QAT_FW_COMP_BANK_A_BITPOS)) /** ***************************************************************************** * @ingroup icp_qat_fw_comp * Definition of the xxhash32 acc state buffer * @description * This is data structure used in stateful lite for xxhash32 * *****************************************************************************/ typedef struct xxhash_acc_state_buff_s { /**< LW 0 */ uint32_t in_counter; /**< Accumulated (total) consumed bytes. As oppose to the per request * IBC in the response.*/ /**< LW 1 */ uint32_t out_counter; /**< OBC as in the response.*/ /**< LW 2-5 */ uint32_t xxhash_state[4]; /**< Initial value is set by IA to the values stated in HAS.*/ /**< LW 6-9 */ uint32_t clear_txt[4]; /**< Set to 0 for the first request.*/ } xxhash_acc_state_buff_t; #endif /* _ICP_QAT_FW_COMP_H_ */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_la.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_la.h index b0942d206aa1..76b8eca98ece 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_la.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_la.h @@ -1,2505 +1,2505 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file icp_qat_fw_la.h * @defgroup icp_qat_fw_la ICP QAT FW Lookaside Service Interface Definitions * @ingroup icp_qat_fw * @description * This file documents structs used to provided the interface to the * LookAside (LA) QAT FW service * *****************************************************************************/ #ifndef _ICP_QAT_FW_LA_H_ #define _ICP_QAT_FW_LA_H_ /* ****************************************************************************** * Include local header files ****************************************************************************** */ #include "icp_qat_fw.h" /* ========================================================================= */ /* QAT FW REQUEST STRUCTURES */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the LookAside (LA) command types * @description * Enumeration which is used to indicate the ids of functions * that are exposed by the LA QAT FW service * *****************************************************************************/ typedef enum { ICP_QAT_FW_LA_CMD_CIPHER = 0, /*!< Cipher Request */ ICP_QAT_FW_LA_CMD_AUTH = 1, /*!< Auth Request */ ICP_QAT_FW_LA_CMD_CIPHER_HASH = 2, /*!< Cipher-Hash Request */ ICP_QAT_FW_LA_CMD_HASH_CIPHER = 3, /*!< Hash-Cipher Request */ ICP_QAT_FW_LA_CMD_TRNG_GET_RANDOM = 4, /*!< TRNG Get Random Request */ ICP_QAT_FW_LA_CMD_TRNG_TEST = 5, /*!< TRNG Test Request */ ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE = 6, /*!< SSL3 Key Derivation Request */ ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE = 7, /*!< TLS Key Derivation Request */ ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE = 8, /*!< TLS Key Derivation Request */ ICP_QAT_FW_LA_CMD_MGF1 = 9, /*!< MGF1 Request */ ICP_QAT_FW_LA_CMD_AUTH_PRE_COMP = 10, /*!< Auth Pre-Compute Request */ ICP_QAT_FW_LA_CMD_CIPHER_PRE_COMP = 11, /*!< Auth Pre-Compute Request */ ICP_QAT_FW_LA_CMD_HKDF_EXTRACT = 12, /*!< HKDF Extract Request */ ICP_QAT_FW_LA_CMD_HKDF_EXPAND = 13, /*!< HKDF Expand Request */ ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND = 14, /*!< HKDF Extract and Expand Request */ ICP_QAT_FW_LA_CMD_HKDF_EXPAND_LABEL = 15, /*!< HKDF Expand Label Request */ ICP_QAT_FW_LA_CMD_HKDF_EXTRACT_AND_EXPAND_LABEL = 16, /*!< HKDF Extract and Expand Label Request */ ICP_QAT_FW_LA_CMD_DELIMITER = 17 /**< Delimiter type */ } icp_qat_fw_la_cmd_id_t; typedef struct icp_qat_fw_la_cipher_20_req_params_s { /**< LW 14 */ uint32_t cipher_offset; /**< Cipher offset long word. */ /**< LW 15 */ uint32_t cipher_length; /**< Cipher length long word. */ /**< LWs 16-19 */ union { uint32_t cipher_IV_array[ICP_QAT_FW_NUM_LONGWORDS_4]; /**< Cipher IV array */ struct { uint64_t cipher_IV_ptr; /**< Cipher IV pointer or Partial State Pointer */ uint64_t resrvd1; /**< reserved */ } s; } u; /**< LW 20 */ uint32_t spc_aad_offset; /**< LW 21 */ uint32_t spc_aad_sz; /**< LW 22 - 23 */ uint64_t spc_aad_addr; /**< LW 24 - 25 */ uint64_t spc_auth_res_addr; /**< LW 26 */ uint8_t reserved[3]; uint8_t spc_auth_res_sz; } icp_qat_fw_la_cipher_20_req_params_t; /* For the definitions of the bits in the status field of the common * response, refer to icp_qat_fw.h. * The return values specific to Lookaside service are given below. */ #define ICP_QAT_FW_LA_ICV_VER_STATUS_PASS ICP_QAT_FW_COMN_STATUS_FLAG_OK /**< @ingroup icp_qat_fw_la * Status flag indicating that the ICV verification passed */ #define ICP_QAT_FW_LA_ICV_VER_STATUS_FAIL ICP_QAT_FW_COMN_STATUS_FLAG_ERROR /**< @ingroup icp_qat_fw_la * Status flag indicating that the ICV verification failed */ #define ICP_QAT_FW_LA_TRNG_STATUS_PASS ICP_QAT_FW_COMN_STATUS_FLAG_OK /**< @ingroup icp_qat_fw_la * Status flag indicating that the TRNG returned valid entropy data */ #define ICP_QAT_FW_LA_TRNG_STATUS_FAIL ICP_QAT_FW_COMN_STATUS_FLAG_ERROR /**< @ingroup icp_qat_fw_la * Status flag indicating that the TRNG Command Failed. */ /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the common LA QAT FW bulk request * @description * Definition of the full bulk processing request structure. * Used for hash, cipher, hash-cipher and authentication-encryption * requests etc. * *****************************************************************************/ typedef struct icp_qat_fw_la_bulk_req_s { /**< LWs 0-1 */ icp_qat_fw_comn_req_hdr_t comn_hdr; /**< Common request header - for Service Command Id, * use service-specific Crypto Command Id. * Service Specific Flags - use Symmetric Crypto Command Flags * (all of cipher, auth, SSL3, TLS and MGF, * excluding TRNG - field unused) */ /**< LWs 2-5 */ icp_qat_fw_comn_req_hdr_cd_pars_t cd_pars; /**< Common Request content descriptor field which points either to a * content descriptor * parameter block or contains the service-specific data itself. */ /**< LWs 6-13 */ icp_qat_fw_comn_req_mid_t comn_mid; /**< Common request middle section */ /**< LWs 14-26 */ icp_qat_fw_comn_req_rqpars_t serv_specif_rqpars; /**< Common request service-specific parameter field */ /**< LWs 27-31 */ icp_qat_fw_comn_req_cd_ctrl_t cd_ctrl; /**< Common request content descriptor control block - * this field is service-specific */ } icp_qat_fw_la_bulk_req_t; /* * LA BULK (SYMMETRIC CRYPTO) COMMAND FLAGS * * + ===== + ---------- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + * | Bit | [15:13] | 12 | 11 | 10 | 7-9 | 6 | 5 | 4 | 3 | 2 | 1-0 | * + ===== + ---------- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ------+ ----- + * | Flags | Resvd Bits | ZUC | GcmIV |Digest | Prot | Cmp | Rtn | Upd | Ciph/ | CiphIV| Part- | * | | =0 | Prot | Len | In Buf| flgs | Auth | Auth | State | Auth | Field | ial | * + ===== + ---------- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ------+ ----- + */ /* Private defines */ /* bits 15:14 */ #define ICP_QAT_FW_LA_USE_WIRELESS_SLICE_TYPE 2 /**< @ingroup icp_qat_fw_la * FW Selects Wireless Cipher Slice * Cipher Algorithms: AES-{F8}, Snow3G, ZUC * Auth Algorithms : Snow3G, ZUC */ #define ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE 1 /**< @ingroup icp_qat_fw_la * FW Selects UCS Cipher Slice * Cipher Algorithms: AES-{CTR/XTS}, Single Pass AES-GCM * Auth Algorithms : SHA1/ SHA{2/3}-{224/256/384/512} */ #define ICP_QAT_FW_LA_USE_LEGACY_SLICE_TYPE 0 /**< @ingroup icp_qat_fw_la * FW Selects Legacy Cipher/Auth Slice * Cipher Algorithms: AES-{CBC/ECB}, SM4, Single Pass AES-CCM * Auth Algorithms : SHA1/ SHA{2/3}-{224/256/384/512} */ #define QAT_LA_SLICE_TYPE_BITPOS 14 /**< @ingroup icp_qat_fw_la * Starting bit position for the slice type selection. * Refer to HAS for Slice type assignment details on QAT2.0 */ #define QAT_LA_SLICE_TYPE_MASK 0x3 /**< @ingroup icp_qat_fw_la * Two bit mask used to determine the Slice type */ /* bit 11 */ #define ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS 1 /**< @ingroup icp_qat_fw_la * Indicates the IV Length for GCM protocol is 96 Bits (12 Octets) * If set FW does the padding to compute CTR0 */ #define ICP_QAT_FW_LA_GCM_IV_LEN_NOT_12_OCTETS 0 /**< @ingroup icp_qat_fw_la * Indicates the IV Length for GCM protocol is not 96 Bits (12 Octets) * If IA computes CTR0 */ #define QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS 12 /**< @ingroup icp_cpm_fw_la * Bit position defining ZUC processing for a encrypt command */ #define ICP_QAT_FW_LA_ZUC_3G_PROTO 1 /**< @ingroup icp_cpm_fw_la * Value indicating ZUC processing for a encrypt command */ #define QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the ZUC 3G protocol bit. * Must be set for Cipher-only, Cipher + Auth and Auth-only */ #define QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_BITPOS 13 /**< @ingroup icp_cpm_fw_la * Bit position defining SINGLE PASS processing for a encrypt command */ #define ICP_QAT_FW_LA_SINGLE_PASS_PROTO 1 /**< @ingroup icp_cpm_fw_la * Value indicating SINGLE PASS processing for a encrypt command */ #define QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the SINGLE PASS protocol bit. * Must be set for Cipher-only */ #define QAT_LA_GCM_IV_LEN_FLAG_BITPOS 11 /**< @ingroup icp_qat_fw_la * Starting bit position for GCM IV Length indication. If set * the IV Length is 96 Bits, clear for other IV lengths */ #define QAT_LA_GCM_IV_LEN_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the GCM IV Length indication bit. * If set the IV Length is 96 Bits, clear for other IV lengths */ /* bit 10 */ #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER 1 /**< @ingroup icp_qat_fw_la * Flag representing that authentication digest is stored or is extracted * from the source buffer. Auth Result Pointer will be ignored in this case. */ #define ICP_QAT_FW_LA_NO_DIGEST_IN_BUFFER 0 /**< @ingroup icp_qat_fw_la * Flag representing that authentication digest is NOT stored or is NOT * extracted from the source buffer. Auth result will get stored or extracted * from the Auth Result Pointer. Please not that in this case digest CANNOT be * encrypted. */ #define QAT_LA_DIGEST_IN_BUFFER_BITPOS 10 /**< @ingroup icp_qat_fw_la * Starting bit position for Digest in Buffer flag */ #define QAT_LA_DIGEST_IN_BUFFER_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the Digest in Buffer flag */ /* bits 7-9 */ #define ICP_QAT_FW_LA_SNOW_3G_PROTO 4 /**< @ingroup icp_cpm_fw_la * Indicates SNOW_3G processing for a encrypt command */ #define ICP_QAT_FW_LA_GCM_PROTO 2 /**< @ingroup icp_qat_fw_la * Indicates GCM processing for a auth_encrypt command */ #define ICP_QAT_FW_LA_CCM_PROTO 1 /**< @ingroup icp_qat_fw_la * Indicates CCM processing for a auth_encrypt command */ #define ICP_QAT_FW_LA_NO_PROTO 0 /**< @ingroup icp_qat_fw_la * Indicates no specific protocol processing for the command */ #define QAT_LA_PROTO_BITPOS 7 /**< @ingroup icp_qat_fw_la * Starting bit position for the Lookaside Protocols */ #define QAT_LA_PROTO_MASK 0x7 /**< @ingroup icp_qat_fw_la * Three bit mask used to determine the Lookaside Protocol */ /* bit 6 */ #define ICP_QAT_FW_LA_CMP_AUTH_RES 1 /**< @ingroup icp_qat_fw_la * Flag representing the need to compare the auth result data to the expected * value in DRAM at the auth_address. */ #define ICP_QAT_FW_LA_NO_CMP_AUTH_RES 0 /**< @ingroup icp_qat_fw_la * Flag representing that there is no need to do a compare of the auth data * to the expected value */ #define QAT_LA_CMP_AUTH_RES_BITPOS 6 /**< @ingroup icp_qat_fw_la * Starting bit position for Auth compare digest result */ #define QAT_LA_CMP_AUTH_RES_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the Auth compare digest result */ /* bit 5 */ #define ICP_QAT_FW_LA_RET_AUTH_RES 1 /**< @ingroup icp_qat_fw_la * Flag representing the need to return the auth result data to dram after the * request processing is complete */ #define ICP_QAT_FW_LA_NO_RET_AUTH_RES 0 /**< @ingroup icp_qat_fw_la * Flag representing that there is no need to return the auth result data */ #define QAT_LA_RET_AUTH_RES_BITPOS 5 /**< @ingroup icp_qat_fw_la * Starting bit position for Auth return digest result */ #define QAT_LA_RET_AUTH_RES_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the Auth return digest result */ /* bit 4 */ #define ICP_QAT_FW_LA_UPDATE_STATE 1 /**< @ingroup icp_qat_fw_la * Flag representing the need to update the state data in dram after the * request processing is complete */ #define ICP_QAT_FW_LA_NO_UPDATE_STATE 0 /**< @ingroup icp_qat_fw_la * Flag representing that there is no need to update the state data */ #define QAT_LA_UPDATE_STATE_BITPOS 4 /**< @ingroup icp_qat_fw_la * Starting bit position for Update State. */ #define QAT_LA_UPDATE_STATE_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the Update State */ /* bit 3 */ #define ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_CD_SETUP 0 /**< @ingroup icp_qat_fw_la * Flag representing Cipher/Auth Config Offset Type, where the offset * is contained in CD Setup. When the SHRAM constants page * is not used for cipher/auth configuration, then the Content Descriptor * pointer field must be a pointer (as opposed to a 16-byte key), since * the block pointed to must contain both the slice config and the key */ #define ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_SHRAM_CP 1 /**< @ingroup icp_qat_fw_la * Flag representing Cipher/Auth Config Offset Type, where the offset * is contained in SHRAM constants page. */ #define QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS 3 /**< @ingroup icp_qat_fw_la * Starting bit position indicating Cipher/Auth Config * offset type */ #define QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine Cipher/Auth Config * offset type */ /* bit 2 */ #define ICP_QAT_FW_CIPH_IV_64BIT_PTR 0 /**< @ingroup icp_qat_fw_la * Flag representing Cipher IV field contents via 64-bit pointer */ #define ICP_QAT_FW_CIPH_IV_16BYTE_DATA 1 /**< @ingroup icp_qat_fw_la * Flag representing Cipher IV field contents as 16-byte data array */ #define QAT_LA_CIPH_IV_FLD_BITPOS 2 /**< @ingroup icp_qat_fw_la * Starting bit position indicating Cipher IV field * contents */ #define QAT_LA_CIPH_IV_FLD_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the Cipher IV field * contents */ /* bits 0-1 */ #define ICP_QAT_FW_LA_PARTIAL_NONE 0 /**< @ingroup icp_qat_fw_la * Flag representing no need for partial processing condition i.e. * entire packet processed in the current command */ #define ICP_QAT_FW_LA_PARTIAL_START 1 /**< @ingroup icp_qat_fw_la * Flag representing the first chunk of the partial packet */ #define ICP_QAT_FW_LA_PARTIAL_MID 3 /**< @ingroup icp_qat_fw_la * Flag representing a middle chunk of the partial packet */ #define ICP_QAT_FW_LA_PARTIAL_END 2 /**< @ingroup icp_qat_fw_la * Flag representing the final/end chunk of the partial packet */ #define QAT_LA_PARTIAL_BITPOS 0 /**< @ingroup icp_qat_fw_la * Starting bit position indicating partial state */ #define QAT_LA_PARTIAL_MASK 0x3 /**< @ingroup icp_qat_fw_la * Two bit mask used to determine the partial state */ /* The table below defines the meaning of the prefix_addr & hash_state_sz in * the case of partial processing. See the HLD for further details * * + ====== + ------------------------- + ----------------------- + - * | Parial | Prefix Addr | Hash State Sz | + * | Partial| Prefix Addr | Hash State Sz | * | State | | | * + ====== + ------------------------- + ----------------------- + * | FULL | Points to the prefix data | Prefix size as below. | * | | | No update of state | * + ====== + ------------------------- + ----------------------- + * | SOP | Points to the prefix | = inner prefix rounded | * | | data. State is updated | to qwrds + outer prefix | * | | at prefix_addr - state_sz | rounded to qwrds. The | * | | - 8 (counter size) | writeback state sz | * | | | comes from the CD | * + ====== + ------------------------- + ----------------------- + * | MOP | Points to the state data | State size rounded to | * | | Updated state written to | num qwrds + 8 (for the | * | | same location | counter) + inner prefix | * | | | rounded to qwrds + | * | | | outer prefix rounded to | * | | | qwrds. | * + ====== + ------------------------- + ----------------------- + * | EOP | Points to the state data | State size rounded to | * | | | num qwrds + 8 (for the | * | | | counter) + inner prefix | * | | | rounded to qwrds + | * | | | outer prefix rounded to | * | | | qwrds. | * + ====== + ------------------------- + ----------------------- + * * Notes: * * - If the EOP is set it is assumed that no state update is to be performed. * However it is the clients responsibility to set the update_state flag * correctly i.e. not set for EOP or Full packet cases. Only set for SOP and * MOP with no EOP flag * - The SOP take precedence over the MOP and EOP i.e. in the calculation of * the address to writeback the state. * - The prefix address must be on at least the 8 byte boundary */ /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro used for the generation of the Lookaside flags for a request. This * should always be used for the generation of the flags field. No direct sets * or masks should be performed on the flags data * * @param gcm_iv_len GCM IV Length indication bit * @param auth_rslt Authentication result - Digest is stored/extracted * in/from the source buffer * straight after the authenticated region * @param proto Protocol handled by a command * @param cmp_auth Compare auth result with the expected value * @param ret_auth Return auth result to the client via DRAM * @param update_state Indicate update of the crypto state information * is required * @param ciphIV Cipher IV field contents * @param ciphcfg Cipher/Auth Config offset type - * @param partial Inidicate if the packet is a partial part + * @param partial Indicate if the packet is a partial part * *****************************************************************************/ #define ICP_QAT_FW_LA_FLAGS_BUILD(zuc_proto, \ gcm_iv_len, \ auth_rslt, \ proto, \ cmp_auth, \ ret_auth, \ update_state, \ ciphIV, \ ciphcfg, \ partial) \ (((zuc_proto & QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) \ << QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS) | \ ((gcm_iv_len & QAT_LA_GCM_IV_LEN_FLAG_MASK) \ << QAT_LA_GCM_IV_LEN_FLAG_BITPOS) | \ ((auth_rslt & QAT_LA_DIGEST_IN_BUFFER_MASK) \ << QAT_LA_DIGEST_IN_BUFFER_BITPOS) | \ ((proto & QAT_LA_PROTO_MASK) << QAT_LA_PROTO_BITPOS) | \ ((cmp_auth & QAT_LA_CMP_AUTH_RES_MASK) \ << QAT_LA_CMP_AUTH_RES_BITPOS) | \ ((ret_auth & QAT_LA_RET_AUTH_RES_MASK) \ << QAT_LA_RET_AUTH_RES_BITPOS) | \ ((update_state & QAT_LA_UPDATE_STATE_MASK) \ << QAT_LA_UPDATE_STATE_BITPOS) | \ ((ciphIV & QAT_LA_CIPH_IV_FLD_MASK) << QAT_LA_CIPH_IV_FLD_BITPOS) | \ ((ciphcfg & QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) \ << QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS) | \ ((partial & QAT_LA_PARTIAL_MASK) << QAT_LA_PARTIAL_BITPOS)) /* Macros for extracting field bits */ /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the Cipher IV field contents (bit 2) * * @param flags Flags to extract the Cipher IV field contents * *****************************************************************************/ #define ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_GET(flags) \ QAT_FIELD_GET(flags, QAT_LA_CIPH_IV_FLD_BITPOS, QAT_LA_CIPH_IV_FLD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the Cipher/Auth Config * offset type (bit 3) * * @param flags Flags to extract the Cipher/Auth Config * offset type * *****************************************************************************/ #define ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS, \ QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the ZUC protocol bit * information (bit 11) * * @param flags Flags to extract the ZUC protocol bit * *****************************************************************************/ #define ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS, \ QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the GCM IV Len is 12 Octets / 96 Bits * information (bit 11) * * @param flags Flags to extract the GCM IV length * *****************************************************************************/ #define ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_GCM_IV_LEN_FLAG_BITPOS, \ QAT_LA_GCM_IV_LEN_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the LA protocol state (bits 9-7) * * @param flags Flags to extract the protocol state * *****************************************************************************/ #define ICP_QAT_FW_LA_PROTO_GET(flags) \ QAT_FIELD_GET(flags, QAT_LA_PROTO_BITPOS, QAT_LA_PROTO_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "compare auth" state (bit 6) * * @param flags Flags to extract the compare auth result state * *****************************************************************************/ #define ICP_QAT_FW_LA_CMP_AUTH_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_CMP_AUTH_RES_BITPOS, \ QAT_LA_CMP_AUTH_RES_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "return auth" state (bit 5) * * @param flags Flags to extract the return auth result state * *****************************************************************************/ #define ICP_QAT_FW_LA_RET_AUTH_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_RET_AUTH_RES_BITPOS, \ QAT_LA_RET_AUTH_RES_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "digest in buffer" state (bit 10) * * @param flags Flags to extract the digest in buffer state * *****************************************************************************/ #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_DIGEST_IN_BUFFER_BITPOS, \ QAT_LA_DIGEST_IN_BUFFER_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the update content state value. (bit 4) * * @param flags Flags to extract the update content state bit * *****************************************************************************/ #define ICP_QAT_FW_LA_UPDATE_STATE_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_UPDATE_STATE_BITPOS, \ QAT_LA_UPDATE_STATE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "partial" packet state (bits 1-0) * * @param flags Flags to extract the partial state * *****************************************************************************/ #define ICP_QAT_FW_LA_PARTIAL_GET(flags) \ QAT_FIELD_GET(flags, QAT_LA_PARTIAL_BITPOS, QAT_LA_PARTIAL_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "Use Extended Protocol Flags" flag value * * @param flags Extended Command Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_USE_EXTENDED_PROTOCOL_FLAGS_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_LA_USE_EXTENDED_PROTOCOL_FLAGS_BITPOS, \ QAT_LA_USE_EXTENDED_PROTOCOL_FLAGS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the slice type information from the flags. * * @param flags Flags to extract the protocol state * *****************************************************************************/ #define ICP_QAT_FW_LA_SLICE_TYPE_GET(flags) \ QAT_FIELD_GET(flags, QAT_LA_SLICE_TYPE_BITPOS, QAT_LA_SLICE_TYPE_MASK) /* Macros for setting field bits */ /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the Cipher IV field contents * * @param flags Flags to set with the Cipher IV field contents * @param val Field contents indicator value * *****************************************************************************/ #define ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_CIPH_IV_FLD_BITPOS, \ QAT_LA_CIPH_IV_FLD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the Cipher/Auth Config * offset type * * @param flags Flags to set the Cipher/Auth Config offset type * @param val Offset type value * *****************************************************************************/ #define ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS, \ QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the ZUC protocol flag * * @param flags Flags to set the ZUC protocol flag * @param val Protocol value * *****************************************************************************/ #define ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS, \ QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the SINGLE PASSprotocol flag * * @param flags Flags to set the SINGLE PASS protocol flag * @param val Protocol value * *****************************************************************************/ #define ICP_QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_BITPOS, \ QAT_FW_LA_SINGLE_PASS_PROTO_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the GCM IV length flag state * * @param flags Flags to set the GCM IV length flag state * @param val Protocol value * *****************************************************************************/ #define ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_GCM_IV_LEN_FLAG_BITPOS, \ QAT_LA_GCM_IV_LEN_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the LA protocol flag state * * @param flags Flags to set the protocol state * @param val Protocol value * *****************************************************************************/ #define ICP_QAT_FW_LA_PROTO_SET(flags, val) \ QAT_FIELD_SET(flags, val, QAT_LA_PROTO_BITPOS, QAT_LA_PROTO_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "compare auth" flag state * * @param flags Flags to set the compare auth result state * @param val Compare Auth value * *****************************************************************************/ #define ICP_QAT_FW_LA_CMP_AUTH_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_CMP_AUTH_RES_BITPOS, \ QAT_LA_CMP_AUTH_RES_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "return auth" flag state * * @param flags Flags to set the return auth result state * @param val Return Auth value * *****************************************************************************/ #define ICP_QAT_FW_LA_RET_AUTH_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_RET_AUTH_RES_BITPOS, \ QAT_LA_RET_AUTH_RES_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "digest in buffer" flag state * * @param flags Flags to set the digest in buffer state * @param val Digest in buffer value * *****************************************************************************/ #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_DIGEST_IN_BUFFER_BITPOS, \ QAT_LA_DIGEST_IN_BUFFER_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "update state" flag value * * @param flags Flags to set the update content state * @param val Update Content State flag value * *****************************************************************************/ #define ICP_QAT_FW_LA_UPDATE_STATE_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_UPDATE_STATE_BITPOS, \ QAT_LA_UPDATE_STATE_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "partial" packet flag state * * @param flags Flags to set the partial state * @param val Partial state value * *****************************************************************************/ #define ICP_QAT_FW_LA_PARTIAL_SET(flags, val) \ QAT_FIELD_SET(flags, val, QAT_LA_PARTIAL_BITPOS, QAT_LA_PARTIAL_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Use Extended Protocol Flags" flag value * * @param flags Extended Command Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_USE_EXTENDED_PROTOCOL_FLAGS_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_USE_EXTENDED_PROTOCOL_FLAGS_BITPOS, \ QAT_LA_USE_EXTENDED_PROTOCOL_FLAGS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "slice type" field in la flags * * @param flags Flags to set the slice type * @param val Value of the slice type to be set. * *****************************************************************************/ #define ICP_QAT_FW_LA_SLICE_TYPE_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_LA_SLICE_TYPE_BITPOS, \ QAT_LA_SLICE_TYPE_MASK) /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Cipher header Content Descriptor pars block * @description * Definition of the cipher processing header cd pars block. * The structure is a service-specific implementation of the common * 'icp_qat_fw_comn_req_hdr_cd_pars_s' structure. *****************************************************************************/ typedef union icp_qat_fw_cipher_req_hdr_cd_pars_s { /**< LWs 2-5 */ struct { uint64_t content_desc_addr; /**< Address of the content descriptor */ uint16_t content_desc_resrvd1; /**< Content descriptor reserved field */ uint8_t content_desc_params_sz; /**< Size of the content descriptor parameters in quad words. * These parameters describe the session setup configuration * info for the slices that this request relies upon i.e. the * configuration word and cipher key needed by the cipher slice * if there is a request for cipher processing. */ uint8_t content_desc_hdr_resrvd2; /**< Content descriptor reserved field */ uint32_t content_desc_resrvd3; /**< Content descriptor reserved field */ } s; struct { uint32_t cipher_key_array[ICP_QAT_FW_NUM_LONGWORDS_4]; /* Cipher Key Array */ } s1; } icp_qat_fw_cipher_req_hdr_cd_pars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Authentication header Content Descriptor pars block * @description * Definition of the authentication processing header cd pars block. *****************************************************************************/ /* Note: Authentication uses the common 'icp_qat_fw_comn_req_hdr_cd_pars_s' * structure - similarly, it is also used by SSL3, TLS and MGF. Only cipher * and cipher + authentication require service-specific implementations of * the structure */ /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Cipher + Auth header Content Descriptor pars block * @description * Definition of the cipher + auth processing header cd pars block. * The structure is a service-specific implementation of the common * 'icp_qat_fw_comn_req_hdr_cd_pars_s' structure. *****************************************************************************/ typedef union icp_qat_fw_cipher_auth_req_hdr_cd_pars_s { /**< LWs 2-5 */ struct { uint64_t content_desc_addr; /**< Address of the content descriptor */ uint16_t content_desc_resrvd1; /**< Content descriptor reserved field */ uint8_t content_desc_params_sz; /**< Size of the content descriptor parameters in quad words. * These parameters describe the session setup configuration * info for the slices that this request relies upon i.e. the * configuration word and cipher key needed by the cipher slice * if there is a request for cipher processing. */ uint8_t content_desc_hdr_resrvd2; /**< Content descriptor reserved field */ uint32_t content_desc_resrvd3; /**< Content descriptor reserved field */ } s; struct { uint32_t cipher_key_array[ICP_QAT_FW_NUM_LONGWORDS_4]; /* Cipher Key Array */ } sl; } icp_qat_fw_cipher_auth_req_hdr_cd_pars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Cipher content descriptor control block (header) * @description * Definition of the service-specific cipher control block header * structure. This header forms part of the content descriptor * block incorporating LWs 27-31, as defined by the common base * parameters structure. * *****************************************************************************/ typedef struct icp_qat_fw_cipher_cd_ctrl_hdr_s { /**< LW 27 */ uint8_t cipher_state_sz; /**< State size in quad words of the cipher algorithm used in this - * session. Set to zero if the algorithm doesnt provide any state */ + * session. Set to zero if the algorithm doesn't provide any state */ uint8_t cipher_key_sz; /**< Key size in quad words of the cipher algorithm used in this session */ uint8_t cipher_cfg_offset; /**< Quad word offset from the content descriptor parameters address * i.e. (content_address + (cd_hdr_sz << 3)) to the parameters for the * cipher processing */ uint8_t next_curr_id; /**< This field combines the next and current id (each four bits) - * the next id is the most significant nibble. * Next Id: Set to the next slice to pass the ciphered data through. * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through * any more slices after cipher. * Current Id: Initialised with the cipher slice type */ /**< LW 28 */ uint8_t cipher_padding_sz; /**< State padding size in quad words. Set to 0 if no padding is * required. */ uint8_t resrvd1; uint16_t resrvd2; /**< Reserved bytes to bring the struct to the word boundary, used by * authentication. MUST be set to 0 */ /**< LWs 29-31 */ uint32_t resrvd3[ICP_QAT_FW_NUM_LONGWORDS_3]; /**< Reserved bytes used by authentication. MUST be set to 0 */ } icp_qat_fw_cipher_cd_ctrl_hdr_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Authentication content descriptor control block (header) * @description * Definition of the service-specific authentication control block * header structure. This header forms part of the content descriptor * block incorporating LWs 27-31, as defined by the common base * parameters structure, the first portion of which is reserved for * cipher. * *****************************************************************************/ typedef struct icp_qat_fw_auth_cd_ctrl_hdr_s { /**< LW 27 */ uint32_t resrvd1; /**< Reserved bytes, used by cipher only. MUST be set to 0 */ /**< LW 28 */ uint8_t resrvd2; /**< Reserved byte, used by cipher only. MUST be set to 0 */ uint8_t hash_flags; /**< General flags defining the processing to perform. 0 is normal * processing * and 1 means there is a nested hash processing loop to go through */ uint8_t hash_cfg_offset; /**< Quad word offset from the content descriptor parameters address to * the parameters for the auth processing */ uint8_t next_curr_id; /**< This field combines the next and current id (each four bits) - * the next id is the most significant nibble. * Next Id: Set to the next slice to pass the authentication data * through. Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go * through any more slices after authentication. * Current Id: Initialised with the authentication slice type */ /**< LW 29 */ uint8_t resrvd3; /**< Now a reserved field. MUST be set to 0 */ uint8_t outer_prefix_sz; /**< Size in bytes of outer prefix data */ uint8_t final_sz; /**< Size in bytes of digest to be returned to the client if requested */ uint8_t inner_res_sz; /**< Size in bytes of the digest from the inner hash algorithm */ /**< LW 30 */ uint8_t resrvd4; /**< Now a reserved field. MUST be set to zero. */ uint8_t inner_state1_sz; /**< Size in bytes of inner hash state1 data. Must be a qword multiple */ uint8_t inner_state2_offset; /**< Quad word offset from the content descriptor parameters pointer to * the inner state2 value */ uint8_t inner_state2_sz; /**< Size in bytes of inner hash state2 data. Must be a qword multiple */ /**< LW 31 */ uint8_t outer_config_offset; /**< Quad word offset from the content descriptor parameters pointer to * the outer configuration information */ uint8_t outer_state1_sz; /**< Size in bytes of the outer state1 value */ uint8_t outer_res_sz; /**< Size in bytes of digest from the outer auth algorithm */ uint8_t outer_prefix_offset; /**< Quad word offset from the start of the inner prefix data to the * outer prefix information. Should equal the rounded inner prefix size, * converted to qwords */ } icp_qat_fw_auth_cd_ctrl_hdr_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Cipher + Authentication content descriptor control block header * @description * Definition of both service-specific cipher + authentication control * block header structures. This header forms part of the content * descriptor block incorporating LWs 27-31, as defined by the common * base parameters structure. * *****************************************************************************/ typedef struct icp_qat_fw_cipher_auth_cd_ctrl_hdr_s { /**< LW 27 */ uint8_t cipher_state_sz; /**< State size in quad words of the cipher algorithm used in this - * session. Set to zero if the algorithm doesnt provide any state */ + * session. Set to zero if the algorithm doesn't provide any state */ uint8_t cipher_key_sz; /**< Key size in quad words of the cipher algorithm used in this session */ uint8_t cipher_cfg_offset; /**< Quad word offset from the content descriptor parameters address * i.e. (content_address + (cd_hdr_sz << 3)) to the parameters for the * cipher processing */ uint8_t next_curr_id_cipher; /**< This field combines the next and current id (each four bits) - * the next id is the most significant nibble. * Next Id: Set to the next slice to pass the ciphered data through. * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through * any more slices after cipher. * Current Id: Initialised with the cipher slice type */ /**< LW 28 */ uint8_t cipher_padding_sz; /**< State padding size in quad words. Set to 0 if no padding is * required. */ uint8_t hash_flags; /**< General flags defining the processing to perform. 0 is normal * processing * and 1 means there is a nested hash processing loop to go through */ uint8_t hash_cfg_offset; /**< Quad word offset from the content descriptor parameters address to * the parameters for the auth processing */ uint8_t next_curr_id_auth; /**< This field combines the next and current id (each four bits) - * the next id is the most significant nibble. * Next Id: Set to the next slice to pass the authentication data * through. Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go * through any more slices after authentication. * Current Id: Initialised with the authentication slice type */ /**< LW 29 */ uint8_t resrvd1; /**< Reserved field. MUST be set to 0 */ uint8_t outer_prefix_sz; /**< Size in bytes of outer prefix data */ uint8_t final_sz; /**< Size in bytes of digest to be returned to the client if requested */ uint8_t inner_res_sz; /**< Size in bytes of the digest from the inner hash algorithm */ /**< LW 30 */ uint8_t resrvd2; /**< Now a reserved field. MUST be set to zero. */ uint8_t inner_state1_sz; /**< Size in bytes of inner hash state1 data. Must be a qword multiple */ uint8_t inner_state2_offset; /**< Quad word offset from the content descriptor parameters pointer to * the inner state2 value */ uint8_t inner_state2_sz; /**< Size in bytes of inner hash state2 data. Must be a qword multiple */ /**< LW 31 */ uint8_t outer_config_offset; /**< Quad word offset from the content descriptor parameters pointer to * the outer configuration information */ uint8_t outer_state1_sz; /**< Size in bytes of the outer state1 value */ uint8_t outer_res_sz; /**< Size in bytes of digest from the outer auth algorithm */ uint8_t outer_prefix_offset; /**< Quad word offset from the start of the inner prefix data to the * outer prefix information. Should equal the rounded inner prefix size, * converted to qwords */ } icp_qat_fw_cipher_auth_cd_ctrl_hdr_t; /* * HASH FLAGS * * + ===== + --- + --- + --- + --- + --- + --- + --- + ---- + * | Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * + ===== + --- + --- + --- + --- + --- + --- + --- + ---- + * | Flags | Rsv | Rsv | Rsv | ZUC |SNOW |SKIP |SKIP |NESTED| * | | | | |EIA3 | 3G |LOAD |LOAD | | * | | | | | |UIA2 |OUTER|INNER| | * + ===== + --- + --- + --- + --- + --- + --- + --- + ---- + */ /* Bit 0 */ #define QAT_FW_LA_AUTH_HDR_NESTED_BITPOS 0 /**< @ingroup icp_qat_fw_comn * Bit position of the hash_flags bit to indicate the request * requires nested hashing */ #define ICP_QAT_FW_AUTH_HDR_FLAG_DO_NESTED 1 /**< @ingroup icp_qat_fw_comn * Definition of the hash_flags bit to indicate the request * requires nested hashing */ #define ICP_QAT_FW_AUTH_HDR_FLAG_NO_NESTED 0 /**< @ingroup icp_qat_fw_comn * Definition of the hash_flags bit for no nested hashing * required */ #define QAT_FW_LA_AUTH_HDR_NESTED_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Bit mask of the hash_flags bit to indicate the request * requires nested hashing */ /* Bit 1 */ #define QAT_FW_LA_SKIP_INNER_STATE1_LOAD_BITPOS 1 /**< @ingroup icp_qat_fw_comn * Bit position of the Skipping Inner State1 Load bit */ #define QAT_FW_LA_SKIP_INNER_STATE1_LOAD 1 /**< @ingroup icp_qat_fw_comn * Value indicating the skipping of inner hash state load */ #define QAT_FW_LA_NO_SKIP_INNER_STATE1_LOAD 0 /**< @ingroup icp_qat_fw_comn * Value indicating the no skipping of inner hash state load */ #define QAT_FW_LA_SKIP_INNER_STATE1_LOAD_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Bit mask of Skipping Inner State1 Load bit */ /* Bit 2 */ #define QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_BITPOS 2 /**< @ingroup icp_qat_fw_comn * Bit position of the Skipping Outer State1 Load bit */ #define QAT_FW_LA_SKIP_OUTER_STATE1_LOAD 1 /**< @ingroup icp_qat_fw_comn * Value indicating the skipping of outer hash state load */ #define QAT_FW_LA_NO_SKIP_OUTER_STATE1_LOAD 0 /**< @ingroup icp_qat_fw_comn * Value indicating the no skipping of outer hash state load */ #define QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Bit mask of Skipping Outer State1 Load bit */ /* Bit 3 */ #define QAT_FW_LA_SNOW3G_UIA2_BITPOS 3 /**< @ingroup icp_cpm_fw_la * Bit position defining hash algorithm Snow3g-UIA2 */ #define QAT_FW_LA_SNOW3G_UIA2 1 /**< @ingroup icp_cpm_fw_la * Value indicating the use of hash algorithm Snow3g-UIA2 */ #define QAT_FW_LA_SNOW3G_UIA2_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the use of hash algorithm Snow3g-UIA2 */ /* Bit 4 */ #define QAT_FW_LA_ZUC_EIA3_BITPOS 4 /**< @ingroup icp_cpm_fw_la * Bit position defining hash algorithm ZUC-EIA3 */ #define QAT_FW_LA_ZUC_EIA3 1 /**< @ingroup icp_cpm_fw_la * Value indicating the use of hash algorithm ZUC-EIA3 */ #define QAT_FW_LA_ZUC_EIA3_MASK 0x1 /**< @ingroup icp_qat_fw_la * One bit mask used to determine the use of hash algorithm ZUC-EIA3 */ /* Bit 5 */ #define QAT_FW_LA_MODE2_BITPOS 5 /**< @ingroup icp_qat_fw_comn * Bit position of the Mode 2 bit */ #define QAT_FW_LA_MODE2 1 /**< @ingroup icp_qat_fw_comn * Value indicating the Mode 2*/ #define QAT_FW_LA_NO_MODE2 0 /**< @ingroup icp_qat_fw_comn * Value indicating the no Mode 2*/ #define QAT_FW_LA_MODE2_MASK 0x1 /**< @ingroup icp_qat_fw_comn * Bit mask of Mode 2 */ /* Macros for extracting hash flags */ /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "Nested" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_AUTH_HDR_NESTED_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_FW_LA_AUTH_HDR_NESTED_BITPOS, \ QAT_FW_LA_AUTH_HDR_NESTED_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "Skipping Inner State1 Load state" hash flag * * @param flags Hash Flags * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SKIP_INNER_STATE1_LOAD_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_FW_LA_SKIP_INNER_STATE1_LOAD_BITPOS, \ QAT_FW_LA_INNER_STATE1_LOAD_MASK) /** ****************************************************************************** * Macro for setting the "Skipping Inner State1 Load" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SKIP_INNER_STATE1_LOAD_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_SKIP_INNER_STATE1_LOAD_BITPOS, \ QAT_FW_LA_SKIP_INNER_STATE1_LOAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "Skipping Outer State1 Load state" hash flag * * @param flags Hash Flags * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SKIP_OUTER_STATE1_LOAD_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_BITPOS, \ QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Skipping Outer State1 Load" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SKIP_OUTER_STATE1_LOAD_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_BITPOS, \ QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "Snow3g-UIA2" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SNOW3G_UIA2_GET(flags) \ QAT_FIELD_GET(flags, \ QAT_FW_LA_SNOW3G_UIA2_BITPOS, \ QAT_FW_LA_SNOW3G_UIA2_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the "ZUC-EIA3" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_ZUC_EIA3_GET(flags) \ QAT_FIELD_GET(flags, QAT_FW_LA_ZUC_EIA3_BITPOS, QAT_FW_LA_ZUC_EIA3_MASK) /* Macros for setting hash flags */ /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Nested" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_AUTH_HDR_NESTED_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_AUTH_HDR_NESTED_BITPOS, \ QAT_FW_LA_AUTH_HDR_NESTED_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Skipping Inner State1 Load" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SKIP_INNER_STATE1_LOAD_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_SKIP_INNER_STATE1_LOAD_BITPOS, \ QAT_FW_LA_SKIP_INNER_STATE1_LOAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Skipping Outer State1 Load" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SKIP_OUTER_STATE1_LOAD_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_BITPOS, \ QAT_FW_LA_SKIP_OUTER_STATE1_LOAD_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Snow3g-UIA2" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_SNOW3G_UIA2_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_SNOW3G_UIA2_BITPOS, \ QAT_FW_LA_SNOW3G_UIA2_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "ZUC-EIA3" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_ZUC_EIA3_SET(flags, val) \ QAT_FIELD_SET(flags, \ val, \ QAT_FW_LA_ZUC_EIA3_BITPOS, \ QAT_FW_LA_ZUC_EIA3_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for setting the "Mode 2" hash flag * * @param flags Hash Flags * @param val Value of the flag * *****************************************************************************/ #define ICP_QAT_FW_HASH_FLAG_MODE2_SET(flags, val) \ QAT_FIELD_SET(flags, val, QAT_FW_LA_MODE2_BITPOS, QAT_FW_LA_MODE2_MASK) #define ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX 240 #define ICP_QAT_FW_SPC_AAD_SZ_MAX 0x3FFF /**< @ingroup icp_qat_fw_comn * Maximum size of AAD data allowed for CCM or GCM processing. AAD data size90 - * is stored in 8-bit field and must be multiple of hash block size. 240 is * largest value which satisfy both requirements.AAD_SZ_MAX is in byte units */ /* * request parameter #defines */ #define ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET (24) /**< @ingroup icp_qat_fw_comn * Offset in bytes from the start of the request parameters block to the hash * (auth) request parameters */ #define ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET (0) /**< @ingroup icp_qat_fw_comn * Offset in bytes from the start of the request parameters block to the cipher * request parameters */ /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the cipher request parameters block * * @description * Definition of the cipher processing request parameters block * structure, which forms part of the block incorporating LWs 14-26, * as defined by the common base parameters structure. * Unused fields must be set to 0. * *****************************************************************************/ /**< Pack compiler directive added to prevent the * compiler from padding this structure to a 64-bit boundary */ #pragma pack(push, 1) typedef struct icp_qat_fw_la_cipher_req_params_s { /**< LW 14 */ uint32_t cipher_offset; /**< Cipher offset long word. */ /**< LW 15 */ uint32_t cipher_length; /**< Cipher length long word. */ /**< LWs 16-19 */ union { uint32_t cipher_IV_array[ICP_QAT_FW_NUM_LONGWORDS_4]; /**< Cipher IV array */ struct { uint64_t cipher_IV_ptr; /**< Cipher IV pointer or Partial State Pointer */ uint64_t resrvd1; /**< reserved */ } s; } u; /* LW 20 - 21 */ uint64_t spc_aad_addr; /**< Address of the AAD info in DRAM */ /* LW 22 - 23 */ uint64_t spc_auth_res_addr; /**< Address of the authentication result information to validate or * the location to which the digest information can be written back to */ /* LW 24 */ uint16_t spc_aad_sz; /**< Size in bytes of AAD data to prefix to the packet * for ChaChaPoly or GCM processing */ uint8_t reserved; /**< reserved */ uint8_t spc_auth_res_sz; /**< Size in bytes of the authentication result */ } icp_qat_fw_la_cipher_req_params_t; #pragma pack(pop) /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the auth request parameters block * @description * Definition of the authentication processing request parameters block * structure, which forms part of the block incorporating LWs 14-26, * as defined by the common base parameters structure. Note: * This structure is used by TLS only. * *****************************************************************************/ /**< Pack compiler directive added to prevent the * compiler from padding this structure to a 64-bit boundary */ #pragma pack(push, 1) typedef struct icp_qat_fw_la_auth_req_params_s { /**< LW 20 */ uint32_t auth_off; /**< Byte offset from the start of packet to the auth data region */ /**< LW 21 */ uint32_t auth_len; /**< Byte length of the auth data region */ /**< LWs 22-23 */ union { uint64_t auth_partial_st_prefix; /**< Address of the authentication partial state prefix * information */ uint64_t aad_adr; /**< Address of the AAD info in DRAM. Used for the CCM and GCM * protocols */ } u1; /**< LWs 24-25 */ uint64_t auth_res_addr; /**< Address of the authentication result information to validate or * the location to which the digest information can be written back to */ /**< LW 26 */ union { uint8_t inner_prefix_sz; /**< Size in bytes of the inner prefix data */ uint8_t aad_sz; /**< Size in bytes of padded AAD data to prefix to the packet * for CCM or GCM processing */ } u2; uint8_t resrvd1; /**< reserved */ uint8_t hash_state_sz; /**< Number of quad words of inner and outer hash prefix data to process * Maximum size is 240 */ uint8_t auth_res_sz; /**< Size in bytes of the authentication result */ } icp_qat_fw_la_auth_req_params_t; #pragma pack(pop) /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the auth request parameters block * @description * Definition of the authentication processing request parameters block * structure, which forms part of the block incorporating LWs 14-26, * as defined by the common base parameters structure. Note: * This structure is used by SSL3 and MGF1 only. All fields other than * inner prefix/ AAD size are unused and therefore reserved. * *****************************************************************************/ typedef struct icp_qat_fw_la_auth_req_params_resrvd_flds_s { /**< LWs 20-25 */ uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_6]; /**< LW 26 */ union { uint8_t inner_prefix_sz; /**< Size in bytes of the inner prefix data */ uint8_t aad_sz; /**< Size in bytes of padded AAD data to prefix to the packet * for CCM or GCM processing */ } u2; uint8_t resrvd1; /**< reserved */ uint16_t resrvd2; /**< reserved */ } icp_qat_fw_la_auth_req_params_resrvd_flds_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the shared fields within the parameter block * containing SSL, TLS or MGF information. * @description * This structure defines the shared fields for SSL, TLS or MGF * within the parameter block incorporating LWs 14-26, as defined * by the common base parameters structure. * Unused fields must be set to 0. * *****************************************************************************/ typedef struct icp_qat_fw_la_key_gen_common_s { /**< LW 14 */ union { /**< SSL3 */ uint16_t secret_lgth_ssl; /**< Length of Secret information for SSL. In the case of TLS * the secret is supplied in the content descriptor */ /**< MGF */ uint16_t mask_length; /**< Size in bytes of the desired output mask for MGF1*/ /**< TLS */ uint16_t secret_lgth_tls; /**< TLS Secret length */ } u; union { /**< SSL3 */ struct { uint8_t output_lgth_ssl; /**< Output length */ uint8_t label_lgth_ssl; /**< Label length */ } s1; /**< MGF */ struct { uint8_t hash_length; /**< Hash length */ uint8_t seed_length; /**< Seed length */ } s2; /**< TLS */ struct { uint8_t output_lgth_tls; /**< Output length */ uint8_t label_lgth_tls; /**< Label length */ } s3; /**< HKDF */ struct { uint8_t rsrvd1; /**< Unused */ uint8_t info_length; /**< Info length. This is plain data, not wrapped in an * icp_qat_fw_hkdf_label structure. */ } hkdf; /**< HKDF Expand Label */ struct { uint8_t rsrvd1; /**< Unused */ uint8_t num_labels; /**< Number of labels */ } hkdf_label; } u1; /**< LW 15 */ union { /**< SSL3 */ uint8_t iter_count; /**< Iteration count used by the SSL key gen request */ /**< TLS */ uint8_t tls_seed_length; /**< TLS Seed length */ /**< HKDF */ uint8_t hkdf_ikm_length; /**< Input keying material (IKM) length */ uint8_t resrvd1; /**< Reserved field set to 0 for MGF1 */ } u2; union { /**< HKDF */ uint8_t hkdf_num_sublabels; /**< Number of subLabels in subLabel buffer, 0-4 */ uint8_t resrvd2; /**< Reserved space - unused */ } u3; uint16_t resrvd3; /**< Reserved space - unused */ } icp_qat_fw_la_key_gen_common_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the SSL3 request parameters block * @description * This structure contains the SSL3 processing request parameters * incorporating LWs 14-26, as defined by the common base * parameters structure. Unused fields must be set to 0. * *****************************************************************************/ typedef struct icp_qat_fw_la_ssl3_req_params_s { /**< LWs 14-15 */ icp_qat_fw_la_key_gen_common_t keygen_comn; /**< For other key gen processing these field holds ssl, tls or mgf * parameters */ /**< LW 16-25 */ uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_10]; /**< Reserved */ /**< LW 26 */ union { uint8_t inner_prefix_sz; /**< Size in bytes of the inner prefix data */ uint8_t aad_sz; /**< Size in bytes of padded AAD data to prefix to the packet * for CCM or GCM processing */ } u2; uint8_t resrvd1; /**< reserved */ uint16_t resrvd2; /**< reserved */ } icp_qat_fw_la_ssl3_req_params_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the MGF request parameters block * @description * This structure contains the MGF processing request parameters * incorporating LWs 14-26, as defined by the common base parameters * structure. Unused fields must be set to 0. * *****************************************************************************/ typedef struct icp_qat_fw_la_mgf_req_params_s { /**< LWs 14-15 */ icp_qat_fw_la_key_gen_common_t keygen_comn; /**< For other key gen processing these field holds ssl or mgf * parameters */ /**< LW 16-25 */ uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_10]; /**< Reserved */ /**< LW 26 */ union { uint8_t inner_prefix_sz; /**< Size in bytes of the inner prefix data */ uint8_t aad_sz; /**< Size in bytes of padded AAD data to prefix to the packet * for CCM or GCM processing */ } u2; uint8_t resrvd1; /**< reserved */ uint16_t resrvd2; /**< reserved */ } icp_qat_fw_la_mgf_req_params_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the TLS request parameters block * @description * This structure contains the TLS processing request parameters * incorporating LWs 14-26, as defined by the common base parameters * structure. Unused fields must be set to 0. * *****************************************************************************/ typedef struct icp_qat_fw_la_tls_req_params_s { /**< LWs 14-15 */ icp_qat_fw_la_key_gen_common_t keygen_comn; /**< For other key gen processing these field holds ssl, tls or mgf * parameters */ /**< LW 16-19 */ uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_4]; /**< Reserved */ } icp_qat_fw_la_tls_req_params_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the common QAT FW request middle block for TRNG. * @description * Common section of the request used across all of the services exposed * by the QAT FW. Each of the services inherit these common fields. TRNG * requires a specific implementation. * *****************************************************************************/ typedef struct icp_qat_fw_la_trng_req_mid_s { /**< LWs 6-13 */ uint64_t opaque_data; /**< Opaque data passed unmodified from the request to response messages * by firmware (fw) */ uint64_t resrvd1; /**< Reserved, unused for TRNG */ uint64_t dest_data_addr; /**< Generic definition of the destination data supplied to the QAT AE. * The common flags are used to further describe the attributes of this * field */ uint32_t resrvd2; /** < Reserved, unused for TRNG */ uint32_t entropy_length; /**< Size of the data in bytes to process. Used by the get_random * command. Set to 0 for commands that dont need a length parameter */ } icp_qat_fw_la_trng_req_mid_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the common LA QAT FW TRNG request * @description * Definition of the TRNG processing request type * *****************************************************************************/ typedef struct icp_qat_fw_la_trng_req_s { /**< LWs 0-1 */ icp_qat_fw_comn_req_hdr_t comn_hdr; /**< Common request header */ /**< LWs 2-5 */ icp_qat_fw_comn_req_hdr_cd_pars_t cd_pars; /**< Common Request content descriptor field which points either to a * content descriptor * parameter block or contains the service-specific data itself. */ /**< LWs 6-13 */ icp_qat_fw_la_trng_req_mid_t comn_mid; /**< TRNG request middle section - differs from the common mid-section */ /**< LWs 14-26 */ uint32_t resrvd1[ICP_QAT_FW_NUM_LONGWORDS_13]; /**< LWs 27-31 */ uint32_t resrvd2[ICP_QAT_FW_NUM_LONGWORDS_5]; } icp_qat_fw_la_trng_req_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside Eagle Tail Response * @description * This is the response delivered to the ET rings by the Lookaside * QAT FW service for all commands * *****************************************************************************/ typedef struct icp_qat_fw_la_resp_s { /**< LWs 0-1 */ icp_qat_fw_comn_resp_hdr_t comn_resp; /**< Common interface response format see icp_qat_fw.h */ /**< LWs 2-3 */ uint64_t opaque_data; /**< Opaque data passed from the request to the response message */ /**< LWs 4-7 */ uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_4]; /**< Reserved */ } icp_qat_fw_la_resp_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside TRNG Test Status Structure * @description * As an addition to ICP_QAT_FW_LA_TRNG_STATUS Pass or Fail information * in common response fields, as a response to TRNG_TEST request, Test * status, Counter for failed tests and 4 entropy counter values are * sent * Status of test status and the fail counts. * * *****************************************************************************/ typedef struct icp_qat_fw_la_trng_test_result_s { uint32_t test_status_info; /**< TRNG comparator health test status& Validity information see Test Status Bit Fields below. */ uint32_t test_status_fail_count; /**< TRNG comparator health test status, 32bit fail counter */ uint64_t r_ent_ones_cnt; /**< Raw Entropy ones counter */ uint64_t r_ent_zeros_cnt; /**< Raw Entropy zeros counter */ uint64_t c_ent_ones_cnt; /**< Conditioned Entropy ones counter */ uint64_t c_ent_zeros_cnt; /**< Conditioned Entropy zeros counter */ uint64_t resrvd; /**< Reserved field must be set to zero */ } icp_qat_fw_la_trng_test_result_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside SSL Key Material Input * @description * This struct defines the layout of input parameters for the * SSL3 key generation (source flat buffer format) * *****************************************************************************/ typedef struct icp_qat_fw_la_ssl_key_material_input_s { uint64_t seed_addr; /**< Pointer to seed */ uint64_t label_addr; /**< Pointer to label(s) */ uint64_t secret_addr; /**< Pointer to secret */ } icp_qat_fw_la_ssl_key_material_input_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside TLS Key Material Input * @description * This struct defines the layout of input parameters for the * TLS key generation (source flat buffer format) * @note * Secret state value (S split into S1 and S2 parts) is supplied via * Content Descriptor. S1 is placed in an outer prefix buffer, and S2 * inside the inner prefix buffer. * *****************************************************************************/ typedef struct icp_qat_fw_la_tls_key_material_input_s { uint64_t seed_addr; /**< Pointer to seed */ uint64_t label_addr; /**< Pointer to label(s) */ } icp_qat_fw_la_tls_key_material_input_t; /** ***************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside HKDF (TLS 1.3) Key Material Input * @description * This structure defines the source buffer for HKDF operations, which * must be provided in flat buffer format. * * The result will be returned in the destination buffer (flat format). * All generated key materials will be returned in a packed layout. Where * sublabel flags are specified, the result of the child expands will * immediately follow their parent. * * @note * TLS 1.3 / HKDF operations require only one key (either the Extract Salt * or the Expand PSK) which is placed in the inner prefix buffer. * *****************************************************************************/ typedef struct icp_qat_fw_la_hkdf_key_material_input_s { uint64_t ikm_addr; /**< Pointer to IKM (input keying material) */ uint64_t labels_addr; /**< Pointer to labels buffer. * For HKDF Expand (without Label) this buffer contains the Info. * * For TLS 1.3 / HKDF Expand-Label this buffer contains up to 4 * icp_qat_fw_hkdf_label structures, which will result in a * corresponding number of first level Expand-Label operations. * * For each of these operations, the result may become an input to child * Expand-Label operations as specified by the sublabel flags, where bit * 0 indicates a child Expand using label 0 from the sublabels buffer, * bit 1 indicates sublabel 1, and so on. In this way, up to 20 * Expand-Label operations may be performed in one request. */ uint64_t sublabels_addr; /**< Pointer to 0-4 sublabels for TLS 1.3, following the format * described for label_addr above. The buffer will typically contain * all 4 of the supported sublabels. * The sublabel flags defined for this context are as follows: * - QAT_FW_HKDF_INNER_SUBLABEL_12_BYTE_OKM_BITPOS * - QAT_FW_HKDF_INNER_SUBLABEL_16_BYTE_OKM_BITPOS * - QAT_FW_HKDF_INNER_SUBLABEL_32_BYTE_OKM_BITPOS */ } icp_qat_fw_la_hkdf_key_material_input_t; /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macros using the bit position and mask to set/extract the next * and current id nibbles within the next_curr_id field of the * content descriptor header block, ONLY FOR CIPHER + AUTH COMBINED. * Note that for cipher only or authentication only, the common macros * need to be used. These are defined in the 'icp_qat_fw.h' common header * file, as they are used by compression, cipher and authentication. * * @param cd_ctrl_hdr_t Content descriptor control block header. * @param val Value of the field being set. * *****************************************************************************/ /** Cipher fields within Cipher + Authentication structure */ #define ICP_QAT_FW_CIPHER_NEXT_ID_GET(cd_ctrl_hdr_t) \ ((((cd_ctrl_hdr_t)->next_curr_id_cipher) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK) >> \ (ICP_QAT_FW_COMN_NEXT_ID_BITPOS)) #define ICP_QAT_FW_CIPHER_NEXT_ID_SET(cd_ctrl_hdr_t, val) \ (cd_ctrl_hdr_t)->next_curr_id_cipher = \ ((((cd_ctrl_hdr_t)->next_curr_id_cipher) & \ ICP_QAT_FW_COMN_CURR_ID_MASK) | \ ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK)) #define ICP_QAT_FW_CIPHER_CURR_ID_GET(cd_ctrl_hdr_t) \ (((cd_ctrl_hdr_t)->next_curr_id_cipher) & ICP_QAT_FW_COMN_CURR_ID_MASK) #define ICP_QAT_FW_CIPHER_CURR_ID_SET(cd_ctrl_hdr_t, val) \ (cd_ctrl_hdr_t)->next_curr_id_cipher = \ ((((cd_ctrl_hdr_t)->next_curr_id_cipher) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK) | \ ((val)&ICP_QAT_FW_COMN_CURR_ID_MASK)) /** Authentication fields within Cipher + Authentication structure */ #define ICP_QAT_FW_AUTH_NEXT_ID_GET(cd_ctrl_hdr_t) \ ((((cd_ctrl_hdr_t)->next_curr_id_auth) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK) >> \ (ICP_QAT_FW_COMN_NEXT_ID_BITPOS)) #define ICP_QAT_FW_AUTH_NEXT_ID_SET(cd_ctrl_hdr_t, val) \ (cd_ctrl_hdr_t)->next_curr_id_auth = \ ((((cd_ctrl_hdr_t)->next_curr_id_auth) & \ ICP_QAT_FW_COMN_CURR_ID_MASK) | \ ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK)) #define ICP_QAT_FW_AUTH_CURR_ID_GET(cd_ctrl_hdr_t) \ (((cd_ctrl_hdr_t)->next_curr_id_auth) & ICP_QAT_FW_COMN_CURR_ID_MASK) #define ICP_QAT_FW_AUTH_CURR_ID_SET(cd_ctrl_hdr_t, val) \ (cd_ctrl_hdr_t)->next_curr_id_auth = \ ((((cd_ctrl_hdr_t)->next_curr_id_auth) & \ ICP_QAT_FW_COMN_NEXT_ID_MASK) | \ ((val)&ICP_QAT_FW_COMN_CURR_ID_MASK)) /* Definitions of the bits in the test_status_info of the TRNG_TEST response. * The values returned by the Lookaside service are given below * The Test result and Test Fail Count values are only valid if the Test * Results Valid (Tv) is set. * * TRNG Test Status Info * + ===== + ------------------------------------------------ + --- + --- + * | Bit | 31 - 2 | 1 | 0 | * + ===== + ------------------------------------------------ + --- + --- + * | Flags | RESERVED = 0 | Tv | Ts | * + ===== + ------------------------------------------------------------ + */ /****************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside TRNG Test Status Information received as * a part of icp_qat_fw_la_trng_test_result_t * *****************************************************************************/ #define QAT_FW_LA_TRNG_TEST_STATUS_TS_BITPOS 0 /**< @ingroup icp_qat_fw_la * TRNG Test Result t_status field bit pos definition.*/ #define QAT_FW_LA_TRNG_TEST_STATUS_TS_MASK 0x1 /**< @ingroup icp_qat_fw_la * TRNG Test Result t_status field mask definition.*/ #define QAT_FW_LA_TRNG_TEST_STATUS_TV_BITPOS 1 /**< @ingroup icp_qat_fw_la * TRNG Test Result test results valid field bit pos definition.*/ #define QAT_FW_LA_TRNG_TEST_STATUS_TV_MASK 0x1 /**< @ingroup icp_qat_fw_la * TRNG Test Result test results valid field mask definition.*/ /****************************************************************************** * @ingroup icp_qat_fw_la * Definition of the Lookaside TRNG test_status values. * * *****************************************************************************/ #define QAT_FW_LA_TRNG_TEST_STATUS_TV_VALID 1 /**< @ingroup icp_qat_fw_la * TRNG TEST Response Test Results Valid Value.*/ #define QAT_FW_LA_TRNG_TEST_STATUS_TV_NOT_VALID 0 /**< @ingroup icp_qat_fw_la * TRNG TEST Response Test Results are NOT Valid Value.*/ #define QAT_FW_LA_TRNG_TEST_STATUS_TS_NO_FAILS 1 /**< @ingroup icp_qat_fw_la * Value for TRNG Test status tests have NO FAILs Value.*/ #define QAT_FW_LA_TRNG_TEST_STATUS_TS_HAS_FAILS 0 /**< @ingroup icp_qat_fw_la * Value for TRNG Test status tests have one or more FAILS Value.*/ /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the Test Status Field returned in the response * to TRNG TEST command. * * @param test_status 8 bit test_status value to extract the status bit * *****************************************************************************/ #define ICP_QAT_FW_LA_TRNG_TEST_STATUS_TS_FLD_GET(test_status) \ QAT_FIELD_GET(test_status, \ QAT_FW_LA_TRNG_TEST_STATUS_TS_BITPOS, \ QAT_FW_LA_TRNG_TEST_STATUS_TS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_la * * @description * Macro for extraction of the Test Results Valid Field returned in the * response to TRNG TEST command. * * @param test_status 8 bit test_status value to extract the Tests * Results valid bit * *****************************************************************************/ #define ICP_QAT_FW_LA_TRNG_TEST_STATUS_TV_FLD_GET(test_status) \ QAT_FIELD_GET(test_status, \ QAT_FW_LA_TRNG_TEST_STATUS_TV_BITPOS, \ QAT_FW_LA_TRNG_TEST_STATUS_TV_MASK) /* ****************************************************************************** * MGF Max supported input parameters ****************************************************************************** */ #define ICP_QAT_FW_LA_MGF_SEED_LEN_MAX 255 /**< @ingroup icp_qat_fw_la * Maximum seed length for MGF1 request in bytes * Typical values may be 48, 64, 128 bytes (or any).*/ #define ICP_QAT_FW_LA_MGF_MASK_LEN_MAX 65528 /**< @ingroup icp_qat_fw_la * Maximum mask length for MGF1 request in bytes * Typical values may be 8 (64-bit), 16 (128-bit). MUST be quad word multiple */ /* ****************************************************************************** * SSL Max supported input parameters ****************************************************************************** */ #define ICP_QAT_FW_LA_SSL_SECRET_LEN_MAX 512 /**< @ingroup icp_qat_fw_la * Maximum secret length for SSL3 Key Gen request (bytes) */ #define ICP_QAT_FW_LA_SSL_ITERATES_LEN_MAX 16 /**< @ingroup icp_qat_fw_la * Maximum iterations for SSL3 Key Gen request (integer) */ #define ICP_QAT_FW_LA_SSL_LABEL_LEN_MAX 136 /**< @ingroup icp_qat_fw_la * Maximum label length for SSL3 Key Gen request (bytes) */ #define ICP_QAT_FW_LA_SSL_SEED_LEN_MAX 64 /**< @ingroup icp_qat_fw_la * Maximum seed length for SSL3 Key Gen request (bytes) */ #define ICP_QAT_FW_LA_SSL_OUTPUT_LEN_MAX 248 /**< @ingroup icp_qat_fw_la * Maximum output length for SSL3 Key Gen request (bytes) */ /* ****************************************************************************** * TLS Max supported input parameters ****************************************************************************** */ #define ICP_QAT_FW_LA_TLS_SECRET_LEN_MAX 128 /**< @ingroup icp_qat_fw_la * Maximum secret length for TLS Key Gen request (bytes) */ #define ICP_QAT_FW_LA_TLS_V1_1_SECRET_LEN_MAX 128 /**< @ingroup icp_qat_fw_la * Maximum secret length for TLS Key Gen request (bytes) */ #define ICP_QAT_FW_LA_TLS_V1_2_SECRET_LEN_MAX 64 /**< @ingroup icp_qat_fw_la * Maximum secret length for TLS Key Gen request (bytes) */ #define ICP_QAT_FW_LA_TLS_LABEL_LEN_MAX 255 /**< @ingroup icp_qat_fw_la * Maximum label length for TLS Key Gen request (bytes) */ #define ICP_QAT_FW_LA_TLS_SEED_LEN_MAX 64 /**< @ingroup icp_qat_fw_la * Maximum seed length for TLS Key Gen request (bytes) */ #define ICP_QAT_FW_LA_TLS_OUTPUT_LEN_MAX 248 /**< @ingroup icp_qat_fw_la * Maximum output length for TLS Key Gen request (bytes) */ /* ****************************************************************************** * HKDF input parameters ****************************************************************************** */ #define QAT_FW_HKDF_LABEL_BUFFER_SZ 78 #define QAT_FW_HKDF_LABEL_LEN_SZ 1 #define QAT_FW_HKDF_LABEL_FLAGS_SZ 1 #define QAT_FW_HKDF_LABEL_STRUCT_SZ \ (QAT_FW_HKDF_LABEL_BUFFER_SZ + QAT_FW_HKDF_LABEL_LEN_SZ + \ QAT_FW_HKDF_LABEL_FLAGS_SZ) /** ***************************************************************************** * @ingroup icp_qat_fw_la * * @description * Wraps an RFC 8446 HkdfLabel with metadata for use in HKDF Expand-Label * operations. * *****************************************************************************/ struct icp_qat_fw_hkdf_label { uint8_t label[QAT_FW_HKDF_LABEL_BUFFER_SZ]; /**< Buffer containing an HkdfLabel as specified in RFC 8446 */ uint8_t label_length; /**< The size of the HkdfLabel */ union { uint8_t label_flags; /**< For first-level labels: each bit in [0..3] will trigger a * child Expand-Label operation on the corresponding sublabel. * Bits [4..7] are reserved. */ uint8_t sublabel_flags; /**< For sublabels the following flags are defined: * - QAT_FW_HKDF_INNER_SUBLABEL_12_BYTE_OKM_BITPOS * - QAT_FW_HKDF_INNER_SUBLABEL_16_BYTE_OKM_BITPOS * - QAT_FW_HKDF_INNER_SUBLABEL_32_BYTE_OKM_BITPOS */ } u; }; #define ICP_QAT_FW_LA_HKDF_SECRET_LEN_MAX 64 /**< Maximum secret length for HKDF request (bytes) */ #define ICP_QAT_FW_LA_HKDF_IKM_LEN_MAX 64 /**< Maximum IKM length for HKDF request (bytes) */ #define QAT_FW_HKDF_MAX_LABELS 4 /**< Maximum number of label structures allowed in the labels buffer */ #define QAT_FW_HKDF_MAX_SUBLABELS 4 /**< Maximum number of label structures allowed in the sublabels buffer */ /* ****************************************************************************** * HKDF inner sublabel flags ****************************************************************************** */ #define QAT_FW_HKDF_INNER_SUBLABEL_12_BYTE_OKM_BITPOS 0 /**< Limit sublabel expand output to 12 bytes -- used with the "iv" sublabel */ #define QAT_FW_HKDF_INNER_SUBLABEL_16_BYTE_OKM_BITPOS 1 /**< Limit sublabel expand output to 16 bytes -- used with SHA-256 "key" */ #define QAT_FW_HKDF_INNER_SUBLABEL_32_BYTE_OKM_BITPOS 2 /**< Limit sublabel expand output to 32 bytes -- used with SHA-384 "key" */ #endif /* _ICP_QAT_FW_LA_H_ */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp.h index f9471acadba2..5abb0cbdb30e 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp.h @@ -1,7247 +1,7245 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /* --- (Automatically generated (build v. 2.7), do not modify manually) --- */ - /** * @file icp_qat_fw_mmp.h * @defgroup icp_qat_fw_mmp ICP QAT FW MMP Processing Definitions * @ingroup icp_qat_fw * $Revision: 0.1 $ * @brief * This file documents the external interfaces that the QAT FW running * on the QAT Acceleration Engine provides to clients wanting to - * accelerate crypto assymetric applications + * accelerate crypto asymmetric applications */ - #ifndef __ICP_QAT_FW_MMP__ #define __ICP_QAT_FW_MMP__ /************************************************************************** * Include local header files ************************************************************************** */ #include "icp_qat_fw.h" /************************************************************************** * Local constants ************************************************************************** */ -#define ICP_QAT_FW_PKE_INPUT_COUNT_MAX 7 +#define ICP_QAT_FW_PKE_INPUT_COUNT_MAX 7 /**< @ingroup icp_qat_fw_pke - * Maximum number of input paramaters in all PKE request */ -#define ICP_QAT_FW_PKE_OUTPUT_COUNT_MAX 5 + * Maximum number of input parameters in all PKE request */ +#define ICP_QAT_FW_PKE_OUTPUT_COUNT_MAX 5 /**< @ingroup icp_qat_fw_pke - * Maximum number of output paramaters in all PKE request */ + * Maximum number of output parameters in all PKE request */ /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P384 Variable Point Multiplication [k]P , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_EC_POINT_MULTIPLICATION_P384. */ typedef struct icp_qat_fw_mmp_ec_point_multiplication_p384_input_s { uint64_t xp; /**< xP = affine coordinate X of point P (6 qwords)*/ uint64_t yp; /**< yP = affine coordinate Y of point P (6 qwords)*/ uint64_t k; /**< k = scalar (6 qwords)*/ } icp_qat_fw_mmp_ec_point_multiplication_p384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P384 Generator Point Multiplication [k]G , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_EC_GENERATOR_MULTIPLICATION_P384. */ typedef struct icp_qat_fw_mmp_ec_generator_multiplication_p384_input_s { uint64_t k; /**< k = scalar (6 qwords)*/ } icp_qat_fw_mmp_ec_generator_multiplication_p384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P384 ECDSA Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_ECDSA_SIGN_RS_P384. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_p384_input_s { uint64_t k; /**< k = random value, > 0 and < n (order of G for P384) (6 qwords)*/ uint64_t e; /**< (6 qwords)*/ uint64_t d; /**< (6 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_p384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P256 Variable Point Multiplication [k]P , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_EC_POINT_MULTIPLICATION_P256. */ typedef struct icp_qat_fw_mmp_ec_point_multiplication_p256_input_s { uint64_t xp; /**< xP = affine coordinate X of point P (4 qwords)*/ uint64_t yp; /**< yP = affine coordinate Y of point P (4 qwords)*/ uint64_t k; /**< k = scalar (4 qwords)*/ } icp_qat_fw_mmp_ec_point_multiplication_p256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P256 Generator Point Multiplication [k]G , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_EC_GENERATOR_MULTIPLICATION_P256. */ typedef struct icp_qat_fw_mmp_ec_generator_multiplication_p256_input_s { uint64_t k; /**< k = scalar (4 qwords)*/ } icp_qat_fw_mmp_ec_generator_multiplication_p256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P256 ECDSA Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_ECDSA_SIGN_RS_P256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_p256_input_s { uint64_t k; /**< k = random value, > 0 and < n (order of G for P256) (4 qwords)*/ uint64_t e; /**< (4 qwords)*/ uint64_t d; /**< (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_p256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC SM2 point multiply [k]G , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_ECSM2_GENERATOR_MULTIPLICATION. */ typedef struct icp_qat_fw_mmp_ecsm2_generator_multiplication_input_s { uint64_t k; /**< k = multiplicand (4 qwords)*/ } icp_qat_fw_mmp_ecsm2_generator_multiplication_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Initialisation sequence , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_INIT. */ typedef struct icp_qat_fw_mmp_init_input_s { uint64_t z; /**< zeroed quadword (1 qwords)*/ } icp_qat_fw_mmp_init_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for 768-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_G2_768. */ typedef struct icp_qat_fw_mmp_dh_g2_768_input_s { uint64_t e; /**< exponent > 0 and < 2^768 (12 qwords)*/ uint64_t m; /**< modulus ≥ 2^767 and < 2^768 (12 qwords)*/ } icp_qat_fw_mmp_dh_g2_768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for 768-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_768. */ typedef struct icp_qat_fw_mmp_dh_768_input_s { uint64_t g; /**< base ≥ 0 and < 2^768 (12 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^768 (12 qwords)*/ uint64_t m; /**< modulus ≥ 2^767 and < 2^768 (12 qwords)*/ } icp_qat_fw_mmp_dh_768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for 1024-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_G2_1024. */ typedef struct icp_qat_fw_mmp_dh_g2_1024_input_s { uint64_t e; /**< exponent > 0 and < 2^1024 (16 qwords)*/ uint64_t m; /**< modulus ≥ 2^1023 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_dh_g2_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for 1024-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_1024. */ typedef struct icp_qat_fw_mmp_dh_1024_input_s { uint64_t g; /**< base ≥ 0 and < 2^1024 (16 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^1024 (16 qwords)*/ uint64_t m; /**< modulus ≥ 2^1023 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_dh_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for 1536-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_G2_1536. */ typedef struct icp_qat_fw_mmp_dh_g2_1536_input_s { uint64_t e; /**< exponent > 0 and < 2^1536 (24 qwords)*/ uint64_t m; /**< modulus ≥ 2^1535 and < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_dh_g2_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for 1536-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_1536. */ typedef struct icp_qat_fw_mmp_dh_1536_input_s { uint64_t g; /**< base ≥ 0 and < 2^1536 (24 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^1536 (24 qwords)*/ uint64_t m; /**< modulus ≥ 2^1535 and < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_dh_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for 2048-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_G2_2048. */ typedef struct icp_qat_fw_mmp_dh_g2_2048_input_s { uint64_t e; /**< exponent > 0 and < 2^2048 (32 qwords)*/ uint64_t m; /**< modulus ≥ 2^2047 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_dh_g2_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for 2048-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_2048. */ typedef struct icp_qat_fw_mmp_dh_2048_input_s { uint64_t g; /**< base ≥ 0 and < 2^2048 (32 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^2048 (32 qwords)*/ uint64_t m; /**< modulus ≥ 2^2047 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_dh_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for 3072-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_G2_3072. */ typedef struct icp_qat_fw_mmp_dh_g2_3072_input_s { uint64_t e; /**< exponent > 0 and < 2^3072 (48 qwords)*/ uint64_t m; /**< modulus ≥ 2^3071 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_dh_g2_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for 3072-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_3072. */ typedef struct icp_qat_fw_mmp_dh_3072_input_s { uint64_t g; /**< base ≥ 0 and < 2^3072 (48 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^3072 (48 qwords)*/ uint64_t m; /**< modulus ≥ 2^3071 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_dh_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for 4096-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_G2_4096. */ typedef struct icp_qat_fw_mmp_dh_g2_4096_input_s { uint64_t e; /**< exponent > 0 and < 2^4096 (64 qwords)*/ uint64_t m; /**< modulus ≥ 2^4095 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_dh_g2_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for 4096-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DH_4096. */ typedef struct icp_qat_fw_mmp_dh_4096_input_s { uint64_t g; /**< base ≥ 0 and < 2^4096 (64 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^4096 (64 qwords)*/ uint64_t m; /**< modulus ≥ 2^4095 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_dh_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation base 2 for * 8192-bit numbers , to be used when icp_qat_fw_pke_request_s::functionalityId * is #PKE_DH_G2_8192. */ typedef struct icp_qat_fw_mmp_dh_g2_8192_input_s { uint64_t e; /**< exponent > 0 and < 2^8192 (128 qwords)*/ uint64_t m; /**< modulus ≥ 2^8191 and < 2^8192 (128 qwords)*/ } icp_qat_fw_mmp_dh_g2_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Diffie-Hellman Modular exponentiation for * 8192-bit numbers , to be used when icp_qat_fw_pke_request_s::functionalityId * is #PKE_DH_8192. */ typedef struct icp_qat_fw_mmp_dh_8192_input_s { uint64_t g; /**< base ≥ 0 and < 2^8192 (128 qwords)*/ uint64_t e; /**< exponent > 0 and < 2^8192 (128 qwords)*/ uint64_t m; /**< modulus ≥ 2^8191 and < 2^8192 (128 qwords)*/ } icp_qat_fw_mmp_dh_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 512 key generation first form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP1_512. */ typedef struct icp_qat_fw_mmp_rsa_kp1_512_input_s { uint64_t p; /**< RSA parameter, prime,  2 < p < 2^256 (4 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2 < q < 2^256 (4 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (8 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 512 key generation second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP2_512. */ typedef struct icp_qat_fw_mmp_rsa_kp2_512_input_s { uint64_t p; /**< RSA parameter, prime,  2^255 < p < 2^256 (4 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^255 < q < 2^256 (4 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (8 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 512 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_EP_512. */ typedef struct icp_qat_fw_mmp_rsa_ep_512_input_s { uint64_t m; /**< message representative, < n (8 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ n-1 (8 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^256 (8 qwords)*/ } icp_qat_fw_mmp_rsa_ep_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 512 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP1_512. */ typedef struct icp_qat_fw_mmp_rsa_dp1_512_input_s { uint64_t c; /**< cipher text representative, < n (8 qwords)*/ uint64_t d; /**< RSA private key (RSADP first form) (8 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^256 (8 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP2_512. */ typedef struct icp_qat_fw_mmp_rsa_dp2_512_input_s { uint64_t c; /**< cipher text representative, < (p*q) (8 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^255 < p < 2^256 (4 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^255 < q < 2^256 (4 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (4 qwords)*/ uint64_t dq; /**< RSA private key 0 < dq < q-1 (4 qwords)*/ uint64_t qinv; /**< RSA private key 0 < qInv < p (4 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 key generation first form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP1_1024. */ typedef struct icp_qat_fw_mmp_rsa_kp1_1024_input_s { uint64_t p; /**< RSA parameter, prime,  2 < p < 2^512 (8 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2 < q < 2^512 (8 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (16 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 key generation second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP2_1024. */ typedef struct icp_qat_fw_mmp_rsa_kp2_1024_input_s { uint64_t p; /**< RSA parameter, prime,  2^511 < p < 2^512 (8 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^511 < q < 2^512 (8 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (16 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_EP_1024. */ typedef struct icp_qat_fw_mmp_rsa_ep_1024_input_s { uint64_t m; /**< message representative, < n (16 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ n-1 (16 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_rsa_ep_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP1_1024. */ typedef struct icp_qat_fw_mmp_rsa_dp1_1024_input_s { uint64_t c; /**< cipher text representative, < n (16 qwords)*/ uint64_t d; /**< RSA private key (RSADP first form) (16 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP2_1024. */ typedef struct icp_qat_fw_mmp_rsa_dp2_1024_input_s { uint64_t c; /**< cipher text representative, < (p*q) (16 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^511 < p < 2^512 (8 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^511 < q < 2^512 (8 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (8 qwords)*/ uint64_t dq; /**< RSA private key 0 < dq < q-1 (8 qwords)*/ uint64_t qinv; /**< RSA private key 0 < qInv < p (8 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1536 key generation first form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP1_1536. */ typedef struct icp_qat_fw_mmp_rsa_kp1_1536_input_s { uint64_t p; /**< RSA parameter, prime,  2 < p < 2^768 (12 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2 < q < 2^768 (12 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (24 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1536 key generation second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP2_1536. */ typedef struct icp_qat_fw_mmp_rsa_kp2_1536_input_s { uint64_t p; /**< RSA parameter, prime,  2^767 < p < 2^768 (12 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^767 < q < 2^768 (12 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (24 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1536 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_EP_1536. */ typedef struct icp_qat_fw_mmp_rsa_ep_1536_input_s { uint64_t m; /**< message representative, < n (24 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ (p*q)-1 (24 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_rsa_ep_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1536 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP1_1536. */ typedef struct icp_qat_fw_mmp_rsa_dp1_1536_input_s { uint64_t c; /**< cipher text representative, < n (24 qwords)*/ uint64_t d; /**< RSA private key (24 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1536 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP2_1536. */ typedef struct icp_qat_fw_mmp_rsa_dp2_1536_input_s { uint64_t c; /**< cipher text representative, < (p*q) (24 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^767 < p < 2^768 (12 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^767 < p < 2^768 (12 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (12 qwords)*/ uint64_t dq; /**< RSA private key, 0 < dq < q-1 (12 qwords)*/ uint64_t qinv; /**< RSA private key, 0 < qInv < p (12 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 2048 key generation first form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP1_2048. */ typedef struct icp_qat_fw_mmp_rsa_kp1_2048_input_s { uint64_t p; /**< RSA parameter, prime,  2 < p < 2^1024 (16 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2 < q < 2^1024 (16 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (32 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 2048 key generation second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP2_2048. */ typedef struct icp_qat_fw_mmp_rsa_kp2_2048_input_s { uint64_t p; /**< RSA parameter, prime,  2^1023 < p < 2^1024 (16 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^1023 < q < 2^1024 (16 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (32 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 2048 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_EP_2048. */ typedef struct icp_qat_fw_mmp_rsa_ep_2048_input_s { uint64_t m; /**< message representative, < n (32 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ n-1 (32 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_rsa_ep_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 2048 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP1_2048. */ typedef struct icp_qat_fw_mmp_rsa_dp1_2048_input_s { uint64_t c; /**< cipher text representative, < n (32 qwords)*/ uint64_t d; /**< RSA private key (32 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 2048 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP2_2048. */ typedef struct icp_qat_fw_mmp_rsa_dp2_2048_input_s { uint64_t c; /**< cipher text representative, < (p*q) (32 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^1023 < p < 2^1024 (16 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^1023 < q < 2^1024 (16 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (16 qwords)*/ uint64_t dq; /**< RSA private key, 0 < dq < q-1 (16 qwords)*/ uint64_t qinv; /**< RSA private key, 0 < qInv < p (16 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 3072 key generation first form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP1_3072. */ typedef struct icp_qat_fw_mmp_rsa_kp1_3072_input_s { uint64_t p; /**< RSA parameter, prime,  2 < p < 2^1536 (24 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2 < q < 2^1536 (24 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (48 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 3072 key generation second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP2_3072. */ typedef struct icp_qat_fw_mmp_rsa_kp2_3072_input_s { uint64_t p; /**< RSA parameter, prime,  2^1535 < p < 2^1536 (24 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^1535 < q < 2^1536 (24 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (48 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 3072 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_EP_3072. */ typedef struct icp_qat_fw_mmp_rsa_ep_3072_input_s { uint64_t m; /**< message representative, < n (48 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ n-1 (48 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_rsa_ep_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 3072 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP1_3072. */ typedef struct icp_qat_fw_mmp_rsa_dp1_3072_input_s { uint64_t c; /**< cipher text representative, < n (48 qwords)*/ uint64_t d; /**< RSA private key (48 qwords)*/ uint64_t n; /**< RSA key > 0 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 3072 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP2_3072. */ typedef struct icp_qat_fw_mmp_rsa_dp2_3072_input_s { uint64_t c; /**< cipher text representative, < (p*q) (48 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^1535 < p < 2^1536 (24 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^1535 < q < 2^1536 (24 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (24 qwords)*/ uint64_t dq; /**< RSA private key, 0 < dq < q-1 (24 qwords)*/ uint64_t qinv; /**< RSA private key, 0 < qInv < p (24 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 4096 key generation first form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP1_4096. */ typedef struct icp_qat_fw_mmp_rsa_kp1_4096_input_s { uint64_t p; /**< RSA parameter, prime,  2 < p < 2^2048 (32 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2 < q < 2^2048 (32 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (64 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 4096 key generation second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_KP2_4096. */ typedef struct icp_qat_fw_mmp_rsa_kp2_4096_input_s { uint64_t p; /**< RSA parameter, prime,  2^2047 < p < 2^2048 (32 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^2047 < q < 2^2048 (32 qwords)*/ uint64_t e; /**< RSA public key, must be odd, ≥ 3 and ≤ (p*q)-1,  with GCD(e, p-1, q-1) = 1 (64 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 4096 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_EP_4096. */ typedef struct icp_qat_fw_mmp_rsa_ep_4096_input_s { uint64_t m; /**< message representative, < n (64 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ n-1 (64 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_rsa_ep_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 4096 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP1_4096. */ typedef struct icp_qat_fw_mmp_rsa_dp1_4096_input_s { uint64_t c; /**< cipher text representative, < n (64 qwords)*/ uint64_t d; /**< RSA private key (64 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 4096 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_RSA_DP2_4096. */ typedef struct icp_qat_fw_mmp_rsa_dp2_4096_input_s { uint64_t c; /**< cipher text representative, < (p*q) (64 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^2047 < p < 2^2048 (32 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^2047 < q < 2^2048 (32 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (32 qwords)*/ uint64_t dq; /**< RSA private key, 0 < dq < q-1 (32 qwords)*/ uint64_t qinv; /**< RSA private key, 0 < qInv < p (32 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 8192 Encryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_RSA_EP_8192. */ typedef struct icp_qat_fw_mmp_rsa_ep_8192_input_s { uint64_t m; /**< message representative, < n (128 qwords)*/ uint64_t e; /**< RSA public key, ≥ 3 and ≤ n-1 (128 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^8192 (128 qwords)*/ } icp_qat_fw_mmp_rsa_ep_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 8192 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_RSA_DP1_8192. */ typedef struct icp_qat_fw_mmp_rsa_dp1_8192_input_s { uint64_t c; /**< cipher text representative, < n (128 qwords)*/ uint64_t d; /**< RSA private key (128 qwords)*/ uint64_t n; /**< RSA key, > 0 and < 2^8192 (128 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 8192 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_RSA_DP2_8192. */ typedef struct icp_qat_fw_mmp_rsa_dp2_8192_input_s { uint64_t c; /**< cipher text representative, < (p*q) (128 qwords)*/ uint64_t p; /**< RSA parameter, prime,  2^4095 < p < 2^4096 (64 qwords)*/ uint64_t q; /**< RSA parameter, prime,  2^4095 < q < 2^4096 (64 qwords)*/ uint64_t dp; /**< RSA private key, 0 < dp < p-1 (64 qwords)*/ uint64_t dq; /**< RSA private key, 0 < dq < q-1 (64 qwords)*/ uint64_t qinv; /**< RSA private key, 0 < qInv < p (64 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 192-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_192. */ typedef struct icp_qat_fw_mmp_gcd_pt_192_input_s { uint64_t m; /**< prime candidate > 1 and < 2^192 (3 qwords)*/ } icp_qat_fw_mmp_gcd_pt_192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 256-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_256. */ typedef struct icp_qat_fw_mmp_gcd_pt_256_input_s { uint64_t m; /**< prime candidate > 1 and < 2^256 (4 qwords)*/ } icp_qat_fw_mmp_gcd_pt_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 384-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_384. */ typedef struct icp_qat_fw_mmp_gcd_pt_384_input_s { uint64_t m; /**< prime candidate > 1 and < 2^384 (6 qwords)*/ } icp_qat_fw_mmp_gcd_pt_384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_512. */ typedef struct icp_qat_fw_mmp_gcd_pt_512_input_s { uint64_t m; /**< prime candidate > 1 and < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_gcd_pt_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_768. */ typedef struct icp_qat_fw_mmp_gcd_pt_768_input_s { uint64_t m; /**< prime candidate > 1 and < 2^768 (12 qwords)*/ } icp_qat_fw_mmp_gcd_pt_768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_1024. */ typedef struct icp_qat_fw_mmp_gcd_pt_1024_input_s { uint64_t m; /**< prime candidate > 1 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_gcd_pt_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_1536. */ typedef struct icp_qat_fw_mmp_gcd_pt_1536_input_s { uint64_t m; /**< (24 qwords)*/ } icp_qat_fw_mmp_gcd_pt_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_2048. */ typedef struct icp_qat_fw_mmp_gcd_pt_2048_input_s { uint64_t m; /**< prime candidate > 1 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_gcd_pt_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_3072. */ typedef struct icp_qat_fw_mmp_gcd_pt_3072_input_s { uint64_t m; /**< prime candidate > 1 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_gcd_pt_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for GCD primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_GCD_PT_4096. */ typedef struct icp_qat_fw_mmp_gcd_pt_4096_input_s { uint64_t m; /**< prime candidate > 1 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_gcd_pt_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 160-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_160. */ typedef struct icp_qat_fw_mmp_fermat_pt_160_input_s { uint64_t m; /**< prime candidate, 2^159 < m < 2^160 (3 qwords)*/ } icp_qat_fw_mmp_fermat_pt_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_512. */ typedef struct icp_qat_fw_mmp_fermat_pt_512_input_s { uint64_t m; /**< prime candidate, 2^511 < m < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_fermat_pt_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for <e; 512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_L512. */ typedef struct icp_qat_fw_mmp_fermat_pt_l512_input_s { uint64_t m; /**< prime candidate, 5 < m < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_fermat_pt_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_768. */ typedef struct icp_qat_fw_mmp_fermat_pt_768_input_s { uint64_t m; /**< prime candidate, 2^767 < m < 2^768 (12 qwords)*/ } icp_qat_fw_mmp_fermat_pt_768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_1024. */ typedef struct icp_qat_fw_mmp_fermat_pt_1024_input_s { uint64_t m; /**< prime candidate, 2^1023 < m < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_fermat_pt_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_1536. */ typedef struct icp_qat_fw_mmp_fermat_pt_1536_input_s { uint64_t m; /**< prime candidate, 2^1535 < m < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_fermat_pt_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_2048. */ typedef struct icp_qat_fw_mmp_fermat_pt_2048_input_s { uint64_t m; /**< prime candidate, 2^2047 < m < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_fermat_pt_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_3072. */ typedef struct icp_qat_fw_mmp_fermat_pt_3072_input_s { uint64_t m; /**< prime candidate, 2^3071 < m < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_fermat_pt_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Fermat primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_FERMAT_PT_4096. */ typedef struct icp_qat_fw_mmp_fermat_pt_4096_input_s { uint64_t m; /**< prime candidate, 2^4095 < m < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_fermat_pt_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 160-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_160. */ typedef struct icp_qat_fw_mmp_mr_pt_160_input_s { uint64_t x; /**< randomness > 1 and < m-1 (3 qwords)*/ uint64_t m; /**< prime candidate > 2^159 and < 2^160 (3 qwords)*/ } icp_qat_fw_mmp_mr_pt_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_512. */ typedef struct icp_qat_fw_mmp_mr_pt_512_input_s { uint64_t x; /**< randomness > 1 and < m-1 (8 qwords)*/ uint64_t m; /**< prime candidate > 2^511 and < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_mr_pt_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_768. */ typedef struct icp_qat_fw_mmp_mr_pt_768_input_s { uint64_t x; /**< randomness > 1 and < m-1 (12 qwords)*/ uint64_t m; /**< prime candidate > 2^767 and < 2^768 (12 qwords)*/ } icp_qat_fw_mmp_mr_pt_768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_1024. */ typedef struct icp_qat_fw_mmp_mr_pt_1024_input_s { uint64_t x; /**< randomness > 1 and < m-1 (16 qwords)*/ uint64_t m; /**< prime candidate > 2^1023 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_mr_pt_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_1536. */ typedef struct icp_qat_fw_mmp_mr_pt_1536_input_s { uint64_t x; /**< randomness > 1 and < m-1 (24 qwords)*/ uint64_t m; /**< prime candidate > 2^1535 and < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_mr_pt_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_2048. */ typedef struct icp_qat_fw_mmp_mr_pt_2048_input_s { uint64_t x; /**< randomness > 1 and <m-1 (32 qwords)*/ uint64_t m; /**< prime candidate > 2^2047 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_mr_pt_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_3072. */ typedef struct icp_qat_fw_mmp_mr_pt_3072_input_s { uint64_t x; /**< randomness > 1 and < m-1 (48 qwords)*/ uint64_t m; /**< prime candidate > 2^3071 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_mr_pt_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_4096. */ typedef struct icp_qat_fw_mmp_mr_pt_4096_input_s { uint64_t x; /**< randomness > 1 and < m-1 (64 qwords)*/ uint64_t m; /**< prime candidate > 2^4095 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_mr_pt_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Miller-Rabin primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_MR_PT_L512. */ typedef struct icp_qat_fw_mmp_mr_pt_l512_input_s { uint64_t x; /**< randomness > 1 and < m-1 (8 qwords)*/ uint64_t m; /**< prime candidate > 1 and < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_mr_pt_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 160-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_160. */ typedef struct icp_qat_fw_mmp_lucas_pt_160_input_s { uint64_t m; /**< odd prime candidate > 2^159 and < 2^160 (3 qwords)*/ } icp_qat_fw_mmp_lucas_pt_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_512. */ typedef struct icp_qat_fw_mmp_lucas_pt_512_input_s { uint64_t m; /**< odd prime candidate > 2^511 and < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_lucas_pt_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_768. */ typedef struct icp_qat_fw_mmp_lucas_pt_768_input_s { uint64_t m; /**< odd prime candidate > 2^767 and < 2^768 (12 qwords)*/ } icp_qat_fw_mmp_lucas_pt_768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_1024. */ typedef struct icp_qat_fw_mmp_lucas_pt_1024_input_s { uint64_t m; /**< odd prime candidate > 2^1023 and < 2^1024 (16 qwords)*/ } icp_qat_fw_mmp_lucas_pt_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_1536. */ typedef struct icp_qat_fw_mmp_lucas_pt_1536_input_s { uint64_t m; /**< odd prime candidate > 2^1535 and < 2^1536 (24 qwords)*/ } icp_qat_fw_mmp_lucas_pt_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_2048. */ typedef struct icp_qat_fw_mmp_lucas_pt_2048_input_s { uint64_t m; /**< odd prime candidate > 2^2047 and < 2^2048 (32 qwords)*/ } icp_qat_fw_mmp_lucas_pt_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_3072. */ typedef struct icp_qat_fw_mmp_lucas_pt_3072_input_s { uint64_t m; /**< odd prime candidate > 2^3071 and < 2^3072 (48 qwords)*/ } icp_qat_fw_mmp_lucas_pt_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_4096. */ typedef struct icp_qat_fw_mmp_lucas_pt_4096_input_s { uint64_t m; /**< odd prime candidate > 2^4096 and < 2^4096 (64 qwords)*/ } icp_qat_fw_mmp_lucas_pt_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Lucas primality test for L512-bit numbers , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_LUCAS_PT_L512. */ typedef struct icp_qat_fw_mmp_lucas_pt_l512_input_s { uint64_t m; /**< odd prime candidate > 5 and < 2^512 (8 qwords)*/ } icp_qat_fw_mmp_lucas_pt_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 512-bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L512. */ typedef struct icp_qat_fw_maths_modexp_l512_input_s { uint64_t g; /**< base ≥ 0 and < 2^512 (8 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^512 (8 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^512 (8 qwords)*/ } icp_qat_fw_maths_modexp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 1024-bit , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L1024. */ typedef struct icp_qat_fw_maths_modexp_l1024_input_s { uint64_t g; /**< base ≥ 0 and < 2^1024 (16 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^1024 (16 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^1024 (16 qwords)*/ } icp_qat_fw_maths_modexp_l1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 1536-bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L1536. */ typedef struct icp_qat_fw_maths_modexp_l1536_input_s { uint64_t g; /**< base ≥ 0 and < 2^1536 (24 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^1536 (24 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^1536 (24 qwords)*/ } icp_qat_fw_maths_modexp_l1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 2048-bit , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L2048. */ typedef struct icp_qat_fw_maths_modexp_l2048_input_s { uint64_t g; /**< base ≥ 0 and < 2^2048 (32 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^2048 (32 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^2048 (32 qwords)*/ } icp_qat_fw_maths_modexp_l2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 2560-bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L2560. */ typedef struct icp_qat_fw_maths_modexp_l2560_input_s { uint64_t g; /**< base ≥ 0 and < 2^2560 (40 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^2560 (40 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^2560 (40 qwords)*/ } icp_qat_fw_maths_modexp_l2560_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 3072-bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L3072. */ typedef struct icp_qat_fw_maths_modexp_l3072_input_s { uint64_t g; /**< base ≥ 0 and < 2^3072 (48 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^3072 (48 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^3072 (48 qwords)*/ } icp_qat_fw_maths_modexp_l3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 3584-bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L3584. */ typedef struct icp_qat_fw_maths_modexp_l3584_input_s { uint64_t g; /**< base ≥ 0 and < 2^3584 (56 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^3584 (56 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^3584 (56 qwords)*/ } icp_qat_fw_maths_modexp_l3584_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers less than 4096-bit , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODEXP_L4096. */ typedef struct icp_qat_fw_maths_modexp_l4096_input_s { uint64_t g; /**< base ≥ 0 and < 2^4096 (64 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^4096 (64 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^4096 (64 qwords)*/ } icp_qat_fw_maths_modexp_l4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular exponentiation for numbers up to 8192 * bits , to be used when icp_qat_fw_pke_request_s::functionalityId is * #MATHS_MODEXP_L8192. */ typedef struct icp_qat_fw_maths_modexp_l8192_input_s { uint64_t g; /**< base ≥ 0 and < 2^8192 (128 qwords)*/ uint64_t e; /**< exponent ≥ 0 and < 2^8192 (128 qwords)*/ uint64_t m; /**< modulus > 0 and < 2^8192 (128 qwords)*/ } icp_qat_fw_maths_modexp_l8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less * than 128 bits , to be used when icp_qat_fw_pke_request_s::functionalityId is * #MATHS_MODINV_ODD_L128. */ typedef struct icp_qat_fw_maths_modinv_odd_l128_input_s { uint64_t a; /**< number > 0 and < 2^128 (2 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^128, coprime to a (2 qwords)*/ } icp_qat_fw_maths_modinv_odd_l128_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 192 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L192. */ typedef struct icp_qat_fw_maths_modinv_odd_l192_input_s { uint64_t a; /**< number > 0 and < 2^192 (3 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^192, coprime to a (3 qwords)*/ } icp_qat_fw_maths_modinv_odd_l192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 256 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L256. */ typedef struct icp_qat_fw_maths_modinv_odd_l256_input_s { uint64_t a; /**< number > 0 and < 2^256 (4 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^256, coprime to a (4 qwords)*/ } icp_qat_fw_maths_modinv_odd_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 384 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L384. */ typedef struct icp_qat_fw_maths_modinv_odd_l384_input_s { uint64_t a; /**< number > 0 and < 2^384 (6 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^384, coprime to a (6 qwords)*/ } icp_qat_fw_maths_modinv_odd_l384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 512 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L512. */ typedef struct icp_qat_fw_maths_modinv_odd_l512_input_s { uint64_t a; /**< number > 0 and < 2^512 (8 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^512, coprime to a (8 qwords)*/ } icp_qat_fw_maths_modinv_odd_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 768 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L768. */ typedef struct icp_qat_fw_maths_modinv_odd_l768_input_s { uint64_t a; /**< number > 0 and < 2^768 (12 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^768 ,coprime to a (12 qwords)*/ } icp_qat_fw_maths_modinv_odd_l768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 1024 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L1024. */ typedef struct icp_qat_fw_maths_modinv_odd_l1024_input_s { uint64_t a; /**< number > 0 and < 2^1024 (16 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^1024, coprime to a (16 qwords)*/ } icp_qat_fw_maths_modinv_odd_l1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 1536 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L1536. */ typedef struct icp_qat_fw_maths_modinv_odd_l1536_input_s { uint64_t a; /**< number > 0 and < 2^1536 (24 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^1536, coprime to a (24 qwords)*/ } icp_qat_fw_maths_modinv_odd_l1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 2048 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L2048. */ typedef struct icp_qat_fw_maths_modinv_odd_l2048_input_s { uint64_t a; /**< number > 0 and < 2^2048 (32 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^2048, coprime to a (32 qwords)*/ } icp_qat_fw_maths_modinv_odd_l2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 3072 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L3072. */ typedef struct icp_qat_fw_maths_modinv_odd_l3072_input_s { uint64_t a; /**< number > 0 and < 2^3072 (48 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^3072, coprime to a (48 qwords)*/ } icp_qat_fw_maths_modinv_odd_l3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 4096 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_ODD_L4096. */ typedef struct icp_qat_fw_maths_modinv_odd_l4096_input_s { uint64_t a; /**< number > 0 and < 2^4096 (64 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^4096, coprime to a (64 qwords)*/ } icp_qat_fw_maths_modinv_odd_l4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers up to * 8192 bits , to be used when icp_qat_fw_pke_request_s::functionalityId is * #MATHS_MODINV_ODD_L8192. */ typedef struct icp_qat_fw_maths_modinv_odd_l8192_input_s { uint64_t a; /**< number > 0 and < 2^8192 (128 qwords)*/ uint64_t b; /**< odd modulus > 0 and < 2^8192, coprime to a (128 qwords)*/ } icp_qat_fw_maths_modinv_odd_l8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less * than 128 bits , to be used when icp_qat_fw_pke_request_s::functionalityId is * #MATHS_MODINV_EVEN_L128. */ typedef struct icp_qat_fw_maths_modinv_even_l128_input_s { uint64_t a; /**< odd number > 0 and < 2^128 (2 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^128, coprime with a (2 qwords)*/ } icp_qat_fw_maths_modinv_even_l128_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 192 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L192. */ typedef struct icp_qat_fw_maths_modinv_even_l192_input_s { uint64_t a; /**< odd number > 0 and < 2^192 (3 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^192, coprime with a (3 qwords)*/ } icp_qat_fw_maths_modinv_even_l192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 256 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L256. */ typedef struct icp_qat_fw_maths_modinv_even_l256_input_s { uint64_t a; /**< odd number > 0 and < 2^256 (4 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^256, coprime with a (4 qwords)*/ } icp_qat_fw_maths_modinv_even_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 384 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L384. */ typedef struct icp_qat_fw_maths_modinv_even_l384_input_s { uint64_t a; /**< odd number > 0 and < 2^384 (6 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^384, coprime with a (6 qwords)*/ } icp_qat_fw_maths_modinv_even_l384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 512 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L512. */ typedef struct icp_qat_fw_maths_modinv_even_l512_input_s { uint64_t a; /**< odd number > 0 and < 2^512 (8 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^512, coprime with a (8 qwords)*/ } icp_qat_fw_maths_modinv_even_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 768 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L768. */ typedef struct icp_qat_fw_maths_modinv_even_l768_input_s { uint64_t a; /**< odd number > 0 and < 2^768 (12 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^768, coprime with a (12 qwords)*/ } icp_qat_fw_maths_modinv_even_l768_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 1024 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L1024. */ typedef struct icp_qat_fw_maths_modinv_even_l1024_input_s { uint64_t a; /**< odd number > 0 and < 2^1024 (16 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^1024, coprime with a (16 qwords)*/ } icp_qat_fw_maths_modinv_even_l1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 1536 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L1536. */ typedef struct icp_qat_fw_maths_modinv_even_l1536_input_s { uint64_t a; /**< odd number > 0 and < 2^1536 (24 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^1536, coprime with a (24 qwords)*/ } icp_qat_fw_maths_modinv_even_l1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 2048 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L2048. */ typedef struct icp_qat_fw_maths_modinv_even_l2048_input_s { uint64_t a; /**< odd number > 0 and < 2^2048 (32 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^2048, coprime with a (32 qwords)*/ } icp_qat_fw_maths_modinv_even_l2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 3072 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L3072. */ typedef struct icp_qat_fw_maths_modinv_even_l3072_input_s { uint64_t a; /**< odd number > 0 and < 2^3072 (48 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^3072, coprime with a (48 qwords)*/ } icp_qat_fw_maths_modinv_even_l3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers less than 4096 bits , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_MODINV_EVEN_L4096. */ typedef struct icp_qat_fw_maths_modinv_even_l4096_input_s { uint64_t a; /**< odd number > 0 and < 2^4096 (64 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^4096, coprime with a (64 qwords)*/ } icp_qat_fw_maths_modinv_even_l4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for Modular multiplicative inverse for numbers up to * 8192 bits , to be used when icp_qat_fw_pke_request_s::functionalityId is * #MATHS_MODINV_EVEN_L8192. */ typedef struct icp_qat_fw_maths_modinv_even_l8192_input_s { uint64_t a; /**< odd number > 0 and < 2^8192 (128 qwords)*/ uint64_t b; /**< even modulus > 0 and < 2^8192, coprime with a (128 qwords)*/ } icp_qat_fw_maths_modinv_even_l8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_P_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_1024_160_input_s { uint64_t x; /**< DSA 1024-bit randomness (16 qwords)*/ uint64_t q; /**< DSA 160-bit parameter (3 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_1024_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA key generation G , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_G_1024. */ typedef struct icp_qat_fw_mmp_dsa_gen_g_1024_input_s { uint64_t p; /**< DSA 1024-bit parameter (16 qwords)*/ uint64_t q; /**< DSA 160-bit parameter (3 qwords)*/ uint64_t h; /**< DSA 1024-bit parameter (16 qwords)*/ } icp_qat_fw_mmp_dsa_gen_g_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA key generation Y , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_Y_1024. */ typedef struct icp_qat_fw_mmp_dsa_gen_y_1024_input_s { uint64_t p; /**< DSA 1024-bit parameter (16 qwords)*/ uint64_t g; /**< DSA parameter (16 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (160 bits), (3 qwords)*/ } icp_qat_fw_mmp_dsa_gen_y_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_1024_160_input_s { uint64_t k; /**< randomly generated DSA parameter (3 qwords)*/ uint64_t p; /**< DSA parameter, (16 qwords)*/ uint64_t q; /**< DSA parameter (3 qwords)*/ uint64_t g; /**< DSA parameter (16 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_1024_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_S_160. */ typedef struct icp_qat_fw_mmp_dsa_sign_s_160_input_s { uint64_t m; /**< digest message to be signed (3 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (3 qwords)*/ uint64_t q; /**< DSA parameter (3 qwords)*/ uint64_t r; /**< DSA parameter (3 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (3 qwords)*/ } icp_qat_fw_mmp_dsa_sign_s_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_S_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s { uint64_t m; /**< digest of the message to be signed (3 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (3 qwords)*/ uint64_t p; /**< DSA parameter (16 qwords)*/ uint64_t q; /**< DSA parameter (3 qwords)*/ uint64_t g; /**< DSA parameter (16 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (3 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_VERIFY_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_verify_1024_160_input_s { uint64_t r; /**< DSA 160-bits signature (3 qwords)*/ uint64_t s; /**< DSA 160-bits signature (3 qwords)*/ uint64_t m; /**< digest of the message (3 qwords)*/ uint64_t p; /**< DSA parameter (16 qwords)*/ uint64_t q; /**< DSA parameter (3 qwords)*/ uint64_t g; /**< DSA parameter (16 qwords)*/ uint64_t y; /**< DSA parameter (16 qwords)*/ } icp_qat_fw_mmp_dsa_verify_1024_160_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_P_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_2048_224_input_s { uint64_t x; /**< DSA 2048-bit randomness (32 qwords)*/ uint64_t q; /**< DSA 224-bit parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_2048_224_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA key generation Y , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_Y_2048. */ typedef struct icp_qat_fw_mmp_dsa_gen_y_2048_input_s { uint64_t p; /**< DSA 2048-bit parameter (32 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (224/256 bits), (4 qwords)*/ } icp_qat_fw_mmp_dsa_gen_y_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_2048_224_input_s { uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t p; /**< DSA parameter, (32 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_2048_224_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_S_224. */ typedef struct icp_qat_fw_mmp_dsa_sign_s_224_input_s { uint64_t m; /**< digest message to be signed (4 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t r; /**< DSA parameter (4 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_s_224_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_S_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s { uint64_t m; /**< digest of the message to be signed (4 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t p; /**< DSA parameter (32 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_VERIFY_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_verify_2048_224_input_s { uint64_t r; /**< DSA 224-bits signature (4 qwords)*/ uint64_t s; /**< DSA 224-bits signature (4 qwords)*/ uint64_t m; /**< digest of the message (4 qwords)*/ uint64_t p; /**< DSA parameter (32 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ uint64_t y; /**< DSA parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_verify_2048_224_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_P_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_2048_256_input_s { uint64_t x; /**< DSA 2048-bit randomness (32 qwords)*/ uint64_t q; /**< DSA 256-bit parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_2048_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA key generation G , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_G_2048. */ typedef struct icp_qat_fw_mmp_dsa_gen_g_2048_input_s { uint64_t p; /**< DSA 2048-bit parameter (32 qwords)*/ uint64_t q; /**< DSA 256-bit parameter (4 qwords)*/ uint64_t h; /**< DSA 2048-bit parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_gen_g_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_2048_256_input_s { uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t p; /**< DSA parameter, (32 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_2048_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_S_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_s_256_input_s { uint64_t m; /**< digest message to be signed (4 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t r; /**< DSA parameter (4 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_s_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_S_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s { uint64_t m; /**< digest of the message to be signed (4 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t p; /**< DSA parameter (32 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_VERIFY_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_verify_2048_256_input_s { uint64_t r; /**< DSA 256-bits signature (4 qwords)*/ uint64_t s; /**< DSA 256-bits signature (4 qwords)*/ uint64_t m; /**< digest of the message (4 qwords)*/ uint64_t p; /**< DSA parameter (32 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (32 qwords)*/ uint64_t y; /**< DSA parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_verify_2048_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_P_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_3072_256_input_s { uint64_t x; /**< DSA 3072-bit randomness (48 qwords)*/ uint64_t q; /**< DSA 256-bit parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_3072_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA key generation G , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_G_3072. */ typedef struct icp_qat_fw_mmp_dsa_gen_g_3072_input_s { uint64_t p; /**< DSA 3072-bit parameter (48 qwords)*/ uint64_t q; /**< DSA 256-bit parameter (4 qwords)*/ uint64_t h; /**< DSA 3072-bit parameter (48 qwords)*/ } icp_qat_fw_mmp_dsa_gen_g_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA key generation Y , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_GEN_Y_3072. */ typedef struct icp_qat_fw_mmp_dsa_gen_y_3072_input_s { uint64_t p; /**< DSA 3072-bit parameter (48 qwords)*/ uint64_t g; /**< DSA parameter (48 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (3072 bits), (4 qwords)*/ } icp_qat_fw_mmp_dsa_gen_y_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_3072_256_input_s { uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t p; /**< DSA parameter, (48 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (48 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_3072_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_SIGN_R_S_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s { uint64_t m; /**< digest of the message to be signed (4 qwords)*/ uint64_t k; /**< randomly generated DSA parameter (4 qwords)*/ uint64_t p; /**< DSA parameter (48 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (48 qwords)*/ uint64_t x; /**< randomly generated DSA parameter (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for DSA Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_DSA_VERIFY_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_verify_3072_256_input_s { uint64_t r; /**< DSA 256-bits signature (4 qwords)*/ uint64_t s; /**< DSA 256-bits signature (4 qwords)*/ uint64_t m; /**< digest of the message (4 qwords)*/ uint64_t p; /**< DSA parameter (48 qwords)*/ uint64_t q; /**< DSA parameter (4 qwords)*/ uint64_t g; /**< DSA parameter (48 qwords)*/ uint64_t y; /**< DSA parameter (48 qwords)*/ } icp_qat_fw_mmp_dsa_verify_3072_256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA Sign RS for curves B/K-163 and B/K-233 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_RS_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_input_s { uint64_t in; /**< concatenated input parameters (G, n, q, a, b, k, e, d) (36 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA Sign R for curves B/K-163 and B/K-233 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_R_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s { uint64_t xg; /**< x coordinate of base point G of B/K-163 of B/K-233 (4 qwords)*/ uint64_t yg; /**< y coordinate of base point G of B/K-163 or B/K-233 (4 qwords)*/ uint64_t n; /**< order of the base point of B/K-163 or B/K-233 (4 qwords)*/ uint64_t q; /**< field polynomial of B/K-163 or B/K-233 (4 qwords)*/ uint64_t a; /**< a equation coefficient of B/K-163 of B/K-233 (4 qwords)*/ uint64_t b; /**< b equation coefficient of B/K-163 or B/K-233 (4 qwords)*/ uint64_t k; /**< random value > 0 and < n (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA Sign S for curves with n < 2^256 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_S_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_s { uint64_t e; /**< hash of message (0 < e < 2^256) (4 qwords)*/ uint64_t d; /**< private key (>0 and < n) (4 qwords)*/ uint64_t r; /**< ECDSA r signature value (>0 and < n) (4 qwords)*/ uint64_t k; /**< random value > 0 and < n (4 qwords)*/ uint64_t n; /**< order of the base point G (2 < n < 2^256) (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA Verify for curves B/K-163 and B/K-233 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_VERIFY_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gf2_l256_input_s { uint64_t in; /**< concatenated curve parameter (e,s,r,n,G,Q,a,b,q) (44 qwords)*/ } icp_qat_fw_mmp_ecdsa_verify_gf2_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_RS_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_input_s { uint64_t in; /**< concatenated input parameters (G, n, q, a, b, k, e, d) (72 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_R_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s { uint64_t xg; /**< x coordinate of verified base point (> 0 and degree(x(G)) < degree(q)) (8 qwords)*/ uint64_t yg; /**< y coordinate of verified base point (> 0 and degree(y(G)) < degree(q)) (8 qwords)*/ uint64_t n; /**< order of the base point G, which must be prime and a divisor of #E and < 2^512) (8 qwords)*/ uint64_t q; /**< field polynomial of degree > 2 and < 512 (8 qwords)*/ uint64_t a; /**< a equation coefficient (degree(a) < degree(q)) (8 qwords)*/ uint64_t b; /**< b equation coefficient (degree(b) < degree(q)) (8 qwords)*/ uint64_t k; /**< random value > 0 and < n (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_S_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_s { uint64_t e; /**< hash of message (0 < e < 2^512) (8 qwords)*/ uint64_t d; /**< private key (>0 and < n) (8 qwords)*/ uint64_t r; /**< ECDSA r signature value (>0 and < n) (8 qwords)*/ uint64_t k; /**< random value > 0 and < n (8 qwords)*/ uint64_t n; /**< order of the base point G, which must be prime and a divisor of #E and < 2^512) (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_VERIFY_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gf2_l512_input_s { uint64_t in; /**< concatenated curve parameters (e, s, r, n, xG, yG, xQ, yQ, a, b, q) (88 qwords)*/ } icp_qat_fw_mmp_ecdsa_verify_gf2_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Sign RS for curves B-571/K-571 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_RS_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_input_s { uint64_t in; /**< concatenated input parameters (x(G), y(G), n, q, a, b, k, e, d) (81 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Sign S for curves with deg(q) < 576 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_S_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_s { uint64_t e; /**< hash of message < 2^576 (9 qwords)*/ uint64_t d; /**< private key (> 0 and < n) (9 qwords)*/ uint64_t r; /**< ECDSA r signature value (> 0 and < n) (9 qwords)*/ uint64_t k; /**< random value (> 0 and < n) (9 qwords)*/ uint64_t n; /**< order of the base point of the curve (n < 2^576) (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Sign R for degree 571 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_R_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s { uint64_t xg; /**< x coordinate of verified base point belonging to B/K-571 (9 qwords)*/ uint64_t yg; /**< y coordinate of verified base point belonging to B/K-571 (9 qwords)*/ uint64_t n; /**< order of the base point G (9 qwords)*/ uint64_t q; /**< irreducible field polynomial of B/K-571 (9 qwords)*/ uint64_t a; /**< a coefficient of curve B/K-571 (degree(a) < degree(q)) (9 qwords)*/ uint64_t b; /**< b coefficient of curve B/K-571 (degree(b) < degree(q)) (9 qwords)*/ uint64_t k; /**< random value > 0 and < n (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GF2 Verify for degree 571 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_VERIFY_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gf2_571_input_s { uint64_t in; /**< concatenated input (e, s, r, n, G, Q, a, b, q) (99 qwords)*/ } icp_qat_fw_mmp_ecdsa_verify_gf2_571_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for MATHS GF2 Point Multiplication , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GF2_L256. */ typedef struct icp_qat_fw_maths_point_multiplication_gf2_l256_input_s { uint64_t k; /**< scalar multiplier > 0 and < 2^256 (4 qwords)*/ uint64_t xg; /**< x coordinate of curve point (degree(xG) < 256) (4 qwords)*/ uint64_t yg; /**< y coordinate of curve point (degree(yG) < 256) (4 qwords)*/ uint64_t a; /**< a equation coefficient of B/K-163 or B/K-233 (4 qwords)*/ uint64_t b; /**< b equation coefficient of B/K-163 or B/K-233 (4 qwords)*/ uint64_t q; /**< field polynomial of B/K-163 or B/K-233 (4 qwords)*/ uint64_t h; /**< cofactor of B/K-163 or B/K-233 (4 qwords)*/ } icp_qat_fw_maths_point_multiplication_gf2_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for MATHS GF2 Point Verification , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_VERIFY_GF2_L256. */ typedef struct icp_qat_fw_maths_point_verify_gf2_l256_input_s { uint64_t xq; /**< x coordinate of input point (4 qwords)*/ uint64_t yq; /**< y coordinate of input point (4 qwords)*/ uint64_t q; /**< field polynomial of curve, degree(q) < 256 (4 qwords)*/ uint64_t a; /**< a equation coefficient of curve, degree(a) < 256 (4 qwords)*/ uint64_t b; /**< b equation coefficient of curve, degree(b) < 256 (4 qwords)*/ } icp_qat_fw_maths_point_verify_gf2_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for MATHS GF2 Point Multiplication , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GF2_L512. */ typedef struct icp_qat_fw_maths_point_multiplication_gf2_l512_input_s { uint64_t k; /**< scalar multiplier > 0 and < 2^512 (8 qwords)*/ uint64_t xg; /**< x coordinate of curve point (degree(xG) < 512) (8 qwords)*/ uint64_t yg; /**< y coordinate of curve point (degree(yG) < 512) (8 qwords)*/ uint64_t a; /**< a equation coefficient (degree(a) < 512) (8 qwords)*/ uint64_t b; /**< b equation coefficient (degree(b) < 512) (8 qwords)*/ uint64_t q; /**< field polynomial of degree > 2 and < 512 (8 qwords)*/ uint64_t h; /**< cofactor (< 2^512) (8 qwords)*/ } icp_qat_fw_maths_point_multiplication_gf2_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for MATHS GF2 Point Verification , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_VERIFY_GF2_L512. */ typedef struct icp_qat_fw_maths_point_verify_gf2_l512_input_s { uint64_t xq; /**< x coordinate of input point (8 qwords)*/ uint64_t yq; /**< y coordinate of input point (8 qwords)*/ uint64_t q; /**< field polynomial of degree > 2 and < 512 (8 qwords)*/ uint64_t a; /**< a equation coefficient (degree(a) < 512) (8 qwords)*/ uint64_t b; /**< b equation coefficient (degree(a) < 512) (8 qwords)*/ } icp_qat_fw_maths_point_verify_gf2_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GF2 Point Multiplication for curves B-571/K-571 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GF2_571. */ typedef struct icp_qat_fw_maths_point_multiplication_gf2_571_input_s { uint64_t k; /**< scalar value > 0 and < 2^576 (9 qwords)*/ uint64_t xg; /**< x coordinate of curve point (degree(xG) < degree(q)) (9 qwords)*/ uint64_t yg; /**< y coordinate of curve point (degree(xG) < degree(q)) (9 qwords)*/ uint64_t a; /**< a equation coefficient for B/K-571 (9 qwords)*/ uint64_t b; /**< b equation coefficient for B/K-571 (9 qwords)*/ uint64_t q; /**< field polynomial of B/K-571 (9 qwords)*/ uint64_t h; /**< cofactor for B/K-571 (1 qwords)*/ } icp_qat_fw_maths_point_multiplication_gf2_571_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GF2 Point Verification for degree 571 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_VERIFY_GF2_571. */ typedef struct icp_qat_fw_maths_point_verify_gf2_571_input_s { uint64_t xq; /**< x coordinate of candidate public key (9 qwords)*/ uint64_t yq; /**< y coordinate of candidate public key (9 qwords)*/ uint64_t q; /**< field polynomial of B/K-571 (9 qwords)*/ uint64_t a; /**< a equation coefficient of B/K-571 (9 qwords)*/ uint64_t b; /**< b equation coefficient of B/K-571 (9 qwords)*/ } icp_qat_fw_maths_point_verify_gf2_571_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_R_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s { uint64_t xg; /**< x coordinate of base point G, (4 qwords)*/ uint64_t yg; /**< y coordinate of base point G, (4 qwords)*/ uint64_t n; /**< order of the base point G, which shall be prime (4 qwords)*/ uint64_t q; /**< modulus (4 qwords)*/ uint64_t a; /**< a equation coefficient (4 qwords)*/ uint64_t b; /**< b equation coefficient (4 qwords)*/ uint64_t k; /**< random value (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_S_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_s { uint64_t e; /**< digest of the message to be signed (4 qwords)*/ uint64_t d; /**< private key (4 qwords)*/ uint64_t r; /**< DSA r signature value (4 qwords)*/ uint64_t k; /**< random value (4 qwords)*/ uint64_t n; /**< order of the base point G, which shall be prime (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_RS_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_input_s { uint64_t in; /**< {xG, yG, n, q, a, b, k, e, d} concatenated (36 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_VERIFY_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gfp_l256_input_s { uint64_t in; /**< in = {e, s, r, n, xG, yG, xQ, yQ, a, b ,q} concatenated (44 qwords)*/ } icp_qat_fw_mmp_ecdsa_verify_gfp_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_R_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s { uint64_t xg; /**< x coordinate of base point G, (8 qwords)*/ uint64_t yg; /**< y coordinate of base point G, (8 qwords)*/ uint64_t n; /**< order of the base point G, which shall be prime (8 qwords)*/ uint64_t q; /**< modulus (8 qwords)*/ uint64_t a; /**< a equation coefficient (8 qwords)*/ uint64_t b; /**< b equation coefficient (8 qwords)*/ uint64_t k; /**< random value (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_S_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_s { uint64_t e; /**< digest of the message to be signed (8 qwords)*/ uint64_t d; /**< private key (8 qwords)*/ uint64_t r; /**< DSA r signature value (8 qwords)*/ uint64_t k; /**< random value (8 qwords)*/ uint64_t n; /**< order of the base point G, which shall be prime (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_RS_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_input_s { uint64_t in; /**< {xG, yG, n, q, a, b, k, e, d} concatenated (72 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_VERIFY_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gfp_l512_input_s { uint64_t in; /**< in = {e, s, r, n, xG, yG, xQ, yQ, a, b ,q} concatenated (88 qwords)*/ } icp_qat_fw_mmp_ecdsa_verify_gfp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign R , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_R_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s { uint64_t xg; /**< x coordinate of base point G, (9 qwords)*/ uint64_t yg; /**< y coordinate of base point G, (9 qwords)*/ uint64_t n; /**< order of the base point G, which shall be prime (9 qwords)*/ uint64_t q; /**< modulus (9 qwords)*/ uint64_t a; /**< a equation coefficient (9 qwords)*/ uint64_t b; /**< b equation coefficient (9 qwords)*/ uint64_t k; /**< random value (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign S , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_S_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_s { uint64_t e; /**< digest of the message to be signed (9 qwords)*/ uint64_t d; /**< private key (9 qwords)*/ uint64_t r; /**< DSA r signature value (9 qwords)*/ uint64_t k; /**< random value (9 qwords)*/ uint64_t n; /**< order of the base point G, which shall be prime (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_SIGN_RS_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_input_s { uint64_t in; /**< {xG, yG, n, q, a, b, k, e, d} concatenated (81 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECDSA GFP Verify , * to be used when icp_qat_fw_pke_request_s::functionalityId is #PKE_ECDSA_VERIFY_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gfp_521_input_s { uint64_t in; /**< in = {e, s, r, n, xG, yG, xQ, yQ, a, b ,q} concatenated (99 qwords)*/ } icp_qat_fw_mmp_ecdsa_verify_gfp_521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GFP Point Multiplication , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GFP_L256. */ typedef struct icp_qat_fw_maths_point_multiplication_gfp_l256_input_s { uint64_t k; /**< scalar multiplier (4 qwords)*/ uint64_t xg; /**< x coordinate of curve point (4 qwords)*/ uint64_t yg; /**< y coordinate of curve point (4 qwords)*/ uint64_t a; /**< a equation coefficient (4 qwords)*/ uint64_t b; /**< b equation coefficient (4 qwords)*/ uint64_t q; /**< modulus (4 qwords)*/ uint64_t h; /**< cofactor (4 qwords)*/ } icp_qat_fw_maths_point_multiplication_gfp_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GFP Partial Point Verification , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_VERIFY_GFP_L256. */ typedef struct icp_qat_fw_maths_point_verify_gfp_l256_input_s { uint64_t xq; /**< x coordinate of candidate point (4 qwords)*/ uint64_t yq; /**< y coordinate of candidate point (4 qwords)*/ uint64_t q; /**< modulus (4 qwords)*/ uint64_t a; /**< a equation coefficient (4 qwords)*/ uint64_t b; /**< b equation coefficient (4 qwords)*/ } icp_qat_fw_maths_point_verify_gfp_l256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GFP Point Multiplication , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GFP_L512. */ typedef struct icp_qat_fw_maths_point_multiplication_gfp_l512_input_s { uint64_t k; /**< scalar multiplier (8 qwords)*/ uint64_t xg; /**< x coordinate of curve point (8 qwords)*/ uint64_t yg; /**< y coordinate of curve point (8 qwords)*/ uint64_t a; /**< a equation coefficient (8 qwords)*/ uint64_t b; /**< b equation coefficient (8 qwords)*/ uint64_t q; /**< modulus (8 qwords)*/ uint64_t h; /**< cofactor (8 qwords)*/ } icp_qat_fw_maths_point_multiplication_gfp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GFP Partial Point , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_VERIFY_GFP_L512. */ typedef struct icp_qat_fw_maths_point_verify_gfp_l512_input_s { uint64_t xq; /**< x coordinate of candidate point (8 qwords)*/ uint64_t yq; /**< y coordinate of candidate point (8 qwords)*/ uint64_t q; /**< modulus (8 qwords)*/ uint64_t a; /**< a equation coefficient (8 qwords)*/ uint64_t b; /**< b equation coefficient (8 qwords)*/ } icp_qat_fw_maths_point_verify_gfp_l512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GFP Point Multiplication , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GFP_521. */ typedef struct icp_qat_fw_maths_point_multiplication_gfp_521_input_s { uint64_t k; /**< scalar multiplier (9 qwords)*/ uint64_t xg; /**< x coordinate of curve point (9 qwords)*/ uint64_t yg; /**< y coordinate of curve point (9 qwords)*/ uint64_t a; /**< a equation coefficient (9 qwords)*/ uint64_t b; /**< b equation coefficient (9 qwords)*/ uint64_t q; /**< modulus (9 qwords)*/ uint64_t h; /**< cofactor (1 qwords)*/ } icp_qat_fw_maths_point_multiplication_gfp_521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC GFP Partial Point Verification , * to be used when icp_qat_fw_pke_request_s::functionalityId is #MATHS_POINT_VERIFY_GFP_521. */ typedef struct icp_qat_fw_maths_point_verify_gfp_521_input_s { uint64_t xq; /**< x coordinate of candidate point (9 qwords)*/ uint64_t yq; /**< y coordinate of candidate point (9 qwords)*/ uint64_t q; /**< modulus (9 qwords)*/ uint64_t a; /**< a equation coefficient (9 qwords)*/ uint64_t b; /**< b equation coefficient (9 qwords)*/ } icp_qat_fw_maths_point_verify_gfp_521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC curve25519 Variable Point Multiplication [k]P(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #POINT_MULTIPLICATION_C25519. */ typedef struct icp_qat_fw_point_multiplication_c25519_input_s { uint64_t xp; /**< xP = Montgomery affine coordinate X of point P (4 qwords)*/ uint64_t k; /**< k = scalar (4 qwords)*/ } icp_qat_fw_point_multiplication_c25519_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC curve25519 Generator Point Multiplication [k]G(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #GENERATOR_MULTIPLICATION_C25519. */ typedef struct icp_qat_fw_generator_multiplication_c25519_input_s { uint64_t k; /**< k = scalar (4 qwords)*/ } icp_qat_fw_generator_multiplication_c25519_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC edwards25519 Variable Point Multiplication [k]P, as specified in RFC8032 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #POINT_MULTIPLICATION_ED25519. */ typedef struct icp_qat_fw_point_multiplication_ed25519_input_s { uint64_t xp; /**< xP = Twisted Edwards affine coordinate X of point P (4 qwords)*/ uint64_t yp; /**< yP = Twisted Edwards affine coordinate Y of point P (4 qwords)*/ uint64_t k; /**< k = scalar (4 qwords)*/ } icp_qat_fw_point_multiplication_ed25519_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC edwards25519 Generator Point Multiplication [k]G, as specified in RFC8032 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #GENERATOR_MULTIPLICATION_ED25519. */ typedef struct icp_qat_fw_generator_multiplication_ed25519_input_s { uint64_t k; /**< k = scalar (4 qwords)*/ } icp_qat_fw_generator_multiplication_ed25519_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC curve448 Variable Point Multiplication [k]P(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #POINT_MULTIPLICATION_C448. */ typedef struct icp_qat_fw_point_multiplication_c448_input_s { uint64_t xp; /**< xP = Montgomery affine coordinate X of point P (8 qwords)*/ uint64_t k; /**< k = scalar (8 qwords)*/ } icp_qat_fw_point_multiplication_c448_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC curve448 Generator Point Multiplication [k]G(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #GENERATOR_MULTIPLICATION_C448. */ typedef struct icp_qat_fw_generator_multiplication_c448_input_s { uint64_t k; /**< k = scalar (8 qwords)*/ } icp_qat_fw_generator_multiplication_c448_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC edwards448 Variable Point Multiplication [k]P, as specified in RFC8032 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #POINT_MULTIPLICATION_ED448. */ typedef struct icp_qat_fw_point_multiplication_ed448_input_s { uint64_t xp; /**< xP = Edwards affine coordinate X of point P (8 qwords)*/ uint64_t yp; /**< yP = Edwards affine coordinate Y of point P (8 qwords)*/ uint64_t k; /**< k = scalar (8 qwords)*/ } icp_qat_fw_point_multiplication_ed448_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC edwards448 Generator Point Multiplication [k]P, as specified in RFC8032 , * to be used when icp_qat_fw_pke_request_s::functionalityId is #GENERATOR_MULTIPLICATION_ED448. */ typedef struct icp_qat_fw_generator_multiplication_ed448_input_s { uint64_t k; /**< k = scalar (8 qwords)*/ } icp_qat_fw_generator_multiplication_ed448_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P521 ECDSA Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_ECDSA_SIGN_RS_P521. */ typedef struct icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_input_s { uint64_t kpt_wrapped; /**< (42 qwords)*/ uint64_t kpt_wrapping_context; /**< unwrap context (8 qwords)*/ uint64_t e; /**< (6 qwords)*/ } icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC P384 ECDSA Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_ECDSA_SIGN_RS_P384. */ typedef struct icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_input_s { uint64_t kpt_wrapped; /**< (42 qwords)*/ uint64_t kpt_wrapping_context; /**< unwrap context (8 qwords)*/ uint64_t e; /**< (6 qwords)*/ } icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for ECC KPT P256 ECDSA Sign RS , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_ECDSA_SIGN_RS_P256. */ typedef struct icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_input_s { uint64_t kpt_wrapped; /**< (28 qwords)*/ uint64_t key_unwrap_context; /**< unwrap context (8 qwords)*/ uint64_t e; /**< (4 qwords)*/ } icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 512 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_512. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_512_input_s { uint64_t c; /**< cipher text representative, < n (8 qwords)*/ uint64_t kpt_wrapped; /**< (16 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 1024 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_1024. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_1024_input_s { uint64_t c; /**< cipher text representative, < n (16 qwords)*/ uint64_t kpt_wrapped; /**< (32 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 1536 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_1536. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_1536_input_s { uint64_t c; /**< cipher text representative, < n (24 qwords)*/ uint64_t kpt_wrapped; /**< (48 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 2048 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_2048. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_2048_input_s { uint64_t c; /**< cipher text representative, < n (32 qwords)*/ uint64_t kpt_wrapped; /**< (64 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 3072 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_3072. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_3072_input_s { uint64_t c; /**< cipher text representative, < n (48 qwords)*/ uint64_t kpt_wrapped; /**< (96 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 4096 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_4096. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_4096_input_s { uint64_t c; /**< cipher text representative, < n (64 qwords)*/ uint64_t kpt_wrapped; /**< (128 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 8192 Decryption , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP1_8192. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_8192_input_s { uint64_t c; /**< cipher text representative, < n (128 qwords)*/ uint64_t kpt_wrapped; /**< (256 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 512 decryption second form , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_512. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_512_input_s { uint64_t c; /**< cipher text representative, < (p*q) (8 qwords)*/ uint64_t kpt_wrapped; /**< (28 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_512_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 1024 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_1024. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_1024_input_s { uint64_t c; /**< cipher text representative, < (p*q) (16 qwords)*/ uint64_t kpt_wrapped; /**< (56 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_1024_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for KPT RSA 1536 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_1536. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_1536_input_s { uint64_t c; /**< cipher text representative, < (p*q) (24 qwords)*/ uint64_t kpt_wrapped; /**< (84 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_1536_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 2048 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_2048. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_2048_input_s { uint64_t c; /**< cipher text representative, < (p*q) (32 qwords)*/ uint64_t kpt_wrapped; /**< (112 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_2048_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_3072. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_3072_input_s { uint64_t c; /**< cipher text representative, < (p*q) (48 qwords)*/ uint64_t kpt_wrapped; /**< (168 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_3072_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 4096 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_4096. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_4096_input_s { uint64_t c; /**< cipher text representative, < (p*q) (64 qwords)*/ uint64_t kpt_wrapped; /**< (224 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_4096_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * Input parameter list for RSA 8192 Decryption with CRT , * to be used when icp_qat_fw_pke_request_s::functionalityId is * #PKE_KPT_RSA_DP2_8192. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_8192_input_s { uint64_t c; /**< cipher text representative, < (p*q) (128 qwords)*/ uint64_t kpt_wrapped; /**< (448 qwords)*/ uint64_t kpt_unwrap_context; /**< unwrap context (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_8192_input_t; /** * @ingroup icp_qat_fw_mmp * @brief * MMP input parameters */ typedef union icp_qat_fw_mmp_input_param_u { /** Generic parameter structure : All members of this wrapper structure * are pointers to large integers. */ uint64_t flat_array[ICP_QAT_FW_PKE_INPUT_COUNT_MAX]; /** ECC P384 Variable Point Multiplication [k]P */ icp_qat_fw_mmp_ec_point_multiplication_p384_input_t mmp_ec_point_multiplication_p384; /** ECC P384 Generator Point Multiplication [k]G */ icp_qat_fw_mmp_ec_generator_multiplication_p384_input_t mmp_ec_generator_multiplication_p384; /** ECC P384 ECDSA Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_p384_input_t mmp_ecdsa_sign_rs_p384; /** ECC P256 Variable Point Multiplication [k]P */ icp_qat_fw_mmp_ec_point_multiplication_p256_input_t mmp_ec_point_multiplication_p256; /** ECC P256 Generator Point Multiplication [k]G */ icp_qat_fw_mmp_ec_generator_multiplication_p256_input_t mmp_ec_generator_multiplication_p256; /** ECC P256 ECDSA Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_p256_input_t mmp_ecdsa_sign_rs_p256; /** Initialisation sequence */ icp_qat_fw_mmp_init_input_t mmp_init; /** Diffie-Hellman Modular exponentiation base 2 for 768-bit numbers */ icp_qat_fw_mmp_dh_g2_768_input_t mmp_dh_g2_768; /** Diffie-Hellman Modular exponentiation for 768-bit numbers */ icp_qat_fw_mmp_dh_768_input_t mmp_dh_768; /** Diffie-Hellman Modular exponentiation base 2 for 1024-bit numbers */ icp_qat_fw_mmp_dh_g2_1024_input_t mmp_dh_g2_1024; /** Diffie-Hellman Modular exponentiation for 1024-bit numbers */ icp_qat_fw_mmp_dh_1024_input_t mmp_dh_1024; /** Diffie-Hellman Modular exponentiation base 2 for 1536-bit numbers */ icp_qat_fw_mmp_dh_g2_1536_input_t mmp_dh_g2_1536; /** Diffie-Hellman Modular exponentiation for 1536-bit numbers */ icp_qat_fw_mmp_dh_1536_input_t mmp_dh_1536; /** Diffie-Hellman Modular exponentiation base 2 for 2048-bit numbers */ icp_qat_fw_mmp_dh_g2_2048_input_t mmp_dh_g2_2048; /** Diffie-Hellman Modular exponentiation for 2048-bit numbers */ icp_qat_fw_mmp_dh_2048_input_t mmp_dh_2048; /** Diffie-Hellman Modular exponentiation base 2 for 3072-bit numbers */ icp_qat_fw_mmp_dh_g2_3072_input_t mmp_dh_g2_3072; /** Diffie-Hellman Modular exponentiation for 3072-bit numbers */ icp_qat_fw_mmp_dh_3072_input_t mmp_dh_3072; /** Diffie-Hellman Modular exponentiation base 2 for 4096-bit numbers */ icp_qat_fw_mmp_dh_g2_4096_input_t mmp_dh_g2_4096; /** Diffie-Hellman Modular exponentiation for 4096-bit numbers */ icp_qat_fw_mmp_dh_4096_input_t mmp_dh_4096; /** Diffie-Hellman Modular exponentiation base 2 for 8192-bit numbers */ icp_qat_fw_mmp_dh_g2_8192_input_t mmp_dh_g2_8192; /** Diffie-Hellman Modular exponentiation for 8192-bit numbers */ icp_qat_fw_mmp_dh_8192_input_t mmp_dh_8192; /** RSA 512 key generation first form */ icp_qat_fw_mmp_rsa_kp1_512_input_t mmp_rsa_kp1_512; /** RSA 512 key generation second form */ icp_qat_fw_mmp_rsa_kp2_512_input_t mmp_rsa_kp2_512; /** RSA 512 Encryption */ icp_qat_fw_mmp_rsa_ep_512_input_t mmp_rsa_ep_512; /** RSA 512 Decryption */ icp_qat_fw_mmp_rsa_dp1_512_input_t mmp_rsa_dp1_512; /** RSA 1024 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_512_input_t mmp_rsa_dp2_512; /** RSA 1024 key generation first form */ icp_qat_fw_mmp_rsa_kp1_1024_input_t mmp_rsa_kp1_1024; /** RSA 1024 key generation second form */ icp_qat_fw_mmp_rsa_kp2_1024_input_t mmp_rsa_kp2_1024; /** RSA 1024 Encryption */ icp_qat_fw_mmp_rsa_ep_1024_input_t mmp_rsa_ep_1024; /** RSA 1024 Decryption */ icp_qat_fw_mmp_rsa_dp1_1024_input_t mmp_rsa_dp1_1024; /** RSA 1024 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_1024_input_t mmp_rsa_dp2_1024; /** RSA 1536 key generation first form */ icp_qat_fw_mmp_rsa_kp1_1536_input_t mmp_rsa_kp1_1536; /** RSA 1536 key generation second form */ icp_qat_fw_mmp_rsa_kp2_1536_input_t mmp_rsa_kp2_1536; /** RSA 1536 Encryption */ icp_qat_fw_mmp_rsa_ep_1536_input_t mmp_rsa_ep_1536; /** RSA 1536 Decryption */ icp_qat_fw_mmp_rsa_dp1_1536_input_t mmp_rsa_dp1_1536; /** RSA 1536 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_1536_input_t mmp_rsa_dp2_1536; /** RSA 2048 key generation first form */ icp_qat_fw_mmp_rsa_kp1_2048_input_t mmp_rsa_kp1_2048; /** RSA 2048 key generation second form */ icp_qat_fw_mmp_rsa_kp2_2048_input_t mmp_rsa_kp2_2048; /** RSA 2048 Encryption */ icp_qat_fw_mmp_rsa_ep_2048_input_t mmp_rsa_ep_2048; /** RSA 2048 Decryption */ icp_qat_fw_mmp_rsa_dp1_2048_input_t mmp_rsa_dp1_2048; /** RSA 2048 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_2048_input_t mmp_rsa_dp2_2048; /** RSA 3072 key generation first form */ icp_qat_fw_mmp_rsa_kp1_3072_input_t mmp_rsa_kp1_3072; /** RSA 3072 key generation second form */ icp_qat_fw_mmp_rsa_kp2_3072_input_t mmp_rsa_kp2_3072; /** RSA 3072 Encryption */ icp_qat_fw_mmp_rsa_ep_3072_input_t mmp_rsa_ep_3072; /** RSA 3072 Decryption */ icp_qat_fw_mmp_rsa_dp1_3072_input_t mmp_rsa_dp1_3072; /** RSA 3072 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_3072_input_t mmp_rsa_dp2_3072; /** RSA 4096 key generation first form */ icp_qat_fw_mmp_rsa_kp1_4096_input_t mmp_rsa_kp1_4096; /** RSA 4096 key generation second form */ icp_qat_fw_mmp_rsa_kp2_4096_input_t mmp_rsa_kp2_4096; /** RSA 4096 Encryption */ icp_qat_fw_mmp_rsa_ep_4096_input_t mmp_rsa_ep_4096; /** RSA 4096 Decryption */ icp_qat_fw_mmp_rsa_dp1_4096_input_t mmp_rsa_dp1_4096; /** RSA 4096 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_4096_input_t mmp_rsa_dp2_4096; /** RSA 8192 Encryption */ icp_qat_fw_mmp_rsa_ep_8192_input_t mmp_rsa_ep_8192; /** RSA 8192 Decryption */ icp_qat_fw_mmp_rsa_dp1_8192_input_t mmp_rsa_dp1_8192; /** RSA 8192 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_8192_input_t mmp_rsa_dp2_8192; /** GCD primality test for 192-bit numbers */ icp_qat_fw_mmp_gcd_pt_192_input_t mmp_gcd_pt_192; /** GCD primality test for 256-bit numbers */ icp_qat_fw_mmp_gcd_pt_256_input_t mmp_gcd_pt_256; /** GCD primality test for 384-bit numbers */ icp_qat_fw_mmp_gcd_pt_384_input_t mmp_gcd_pt_384; /** GCD primality test for 512-bit numbers */ icp_qat_fw_mmp_gcd_pt_512_input_t mmp_gcd_pt_512; /** GCD primality test for 768-bit numbers */ icp_qat_fw_mmp_gcd_pt_768_input_t mmp_gcd_pt_768; /** GCD primality test for 1024-bit numbers */ icp_qat_fw_mmp_gcd_pt_1024_input_t mmp_gcd_pt_1024; /** GCD primality test for 1536-bit numbers */ icp_qat_fw_mmp_gcd_pt_1536_input_t mmp_gcd_pt_1536; /** GCD primality test for 2048-bit numbers */ icp_qat_fw_mmp_gcd_pt_2048_input_t mmp_gcd_pt_2048; /** GCD primality test for 3072-bit numbers */ icp_qat_fw_mmp_gcd_pt_3072_input_t mmp_gcd_pt_3072; /** GCD primality test for 4096-bit numbers */ icp_qat_fw_mmp_gcd_pt_4096_input_t mmp_gcd_pt_4096; /** Fermat primality test for 160-bit numbers */ icp_qat_fw_mmp_fermat_pt_160_input_t mmp_fermat_pt_160; /** Fermat primality test for 512-bit numbers */ icp_qat_fw_mmp_fermat_pt_512_input_t mmp_fermat_pt_512; /** Fermat primality test for <e; 512-bit numbers */ icp_qat_fw_mmp_fermat_pt_l512_input_t mmp_fermat_pt_l512; /** Fermat primality test for 768-bit numbers */ icp_qat_fw_mmp_fermat_pt_768_input_t mmp_fermat_pt_768; /** Fermat primality test for 1024-bit numbers */ icp_qat_fw_mmp_fermat_pt_1024_input_t mmp_fermat_pt_1024; /** Fermat primality test for 1536-bit numbers */ icp_qat_fw_mmp_fermat_pt_1536_input_t mmp_fermat_pt_1536; /** Fermat primality test for 2048-bit numbers */ icp_qat_fw_mmp_fermat_pt_2048_input_t mmp_fermat_pt_2048; /** Fermat primality test for 3072-bit numbers */ icp_qat_fw_mmp_fermat_pt_3072_input_t mmp_fermat_pt_3072; /** Fermat primality test for 4096-bit numbers */ icp_qat_fw_mmp_fermat_pt_4096_input_t mmp_fermat_pt_4096; /** Miller-Rabin primality test for 160-bit numbers */ icp_qat_fw_mmp_mr_pt_160_input_t mmp_mr_pt_160; /** Miller-Rabin primality test for 512-bit numbers */ icp_qat_fw_mmp_mr_pt_512_input_t mmp_mr_pt_512; /** Miller-Rabin primality test for 768-bit numbers */ icp_qat_fw_mmp_mr_pt_768_input_t mmp_mr_pt_768; /** Miller-Rabin primality test for 1024-bit numbers */ icp_qat_fw_mmp_mr_pt_1024_input_t mmp_mr_pt_1024; /** Miller-Rabin primality test for 1536-bit numbers */ icp_qat_fw_mmp_mr_pt_1536_input_t mmp_mr_pt_1536; /** Miller-Rabin primality test for 2048-bit numbers */ icp_qat_fw_mmp_mr_pt_2048_input_t mmp_mr_pt_2048; /** Miller-Rabin primality test for 3072-bit numbers */ icp_qat_fw_mmp_mr_pt_3072_input_t mmp_mr_pt_3072; /** Miller-Rabin primality test for 4096-bit numbers */ icp_qat_fw_mmp_mr_pt_4096_input_t mmp_mr_pt_4096; /** Miller-Rabin primality test for 512-bit numbers */ icp_qat_fw_mmp_mr_pt_l512_input_t mmp_mr_pt_l512; /** Lucas primality test for 160-bit numbers */ icp_qat_fw_mmp_lucas_pt_160_input_t mmp_lucas_pt_160; /** Lucas primality test for 512-bit numbers */ icp_qat_fw_mmp_lucas_pt_512_input_t mmp_lucas_pt_512; /** Lucas primality test for 768-bit numbers */ icp_qat_fw_mmp_lucas_pt_768_input_t mmp_lucas_pt_768; /** Lucas primality test for 1024-bit numbers */ icp_qat_fw_mmp_lucas_pt_1024_input_t mmp_lucas_pt_1024; /** Lucas primality test for 1536-bit numbers */ icp_qat_fw_mmp_lucas_pt_1536_input_t mmp_lucas_pt_1536; /** Lucas primality test for 2048-bit numbers */ icp_qat_fw_mmp_lucas_pt_2048_input_t mmp_lucas_pt_2048; /** Lucas primality test for 3072-bit numbers */ icp_qat_fw_mmp_lucas_pt_3072_input_t mmp_lucas_pt_3072; /** Lucas primality test for 4096-bit numbers */ icp_qat_fw_mmp_lucas_pt_4096_input_t mmp_lucas_pt_4096; /** Lucas primality test for L512-bit numbers */ icp_qat_fw_mmp_lucas_pt_l512_input_t mmp_lucas_pt_l512; /** Modular exponentiation for numbers less than 512-bits */ icp_qat_fw_maths_modexp_l512_input_t maths_modexp_l512; /** Modular exponentiation for numbers less than 1024-bit */ icp_qat_fw_maths_modexp_l1024_input_t maths_modexp_l1024; /** Modular exponentiation for numbers less than 1536-bits */ icp_qat_fw_maths_modexp_l1536_input_t maths_modexp_l1536; /** Modular exponentiation for numbers less than 2048-bit */ icp_qat_fw_maths_modexp_l2048_input_t maths_modexp_l2048; /** Modular exponentiation for numbers less than 2560-bits */ icp_qat_fw_maths_modexp_l2560_input_t maths_modexp_l2560; /** Modular exponentiation for numbers less than 3072-bits */ icp_qat_fw_maths_modexp_l3072_input_t maths_modexp_l3072; /** Modular exponentiation for numbers less than 3584-bits */ icp_qat_fw_maths_modexp_l3584_input_t maths_modexp_l3584; /** Modular exponentiation for numbers less than 4096-bit */ icp_qat_fw_maths_modexp_l4096_input_t maths_modexp_l4096; /** Modular exponentiation for numbers up to 8192 bits */ icp_qat_fw_maths_modexp_l8192_input_t maths_modexp_l8192; /** Modular multiplicative inverse for numbers less than 128 bits */ icp_qat_fw_maths_modinv_odd_l128_input_t maths_modinv_odd_l128; /** Modular multiplicative inverse for numbers less than 192 bits */ icp_qat_fw_maths_modinv_odd_l192_input_t maths_modinv_odd_l192; /** Modular multiplicative inverse for numbers less than 256 bits */ icp_qat_fw_maths_modinv_odd_l256_input_t maths_modinv_odd_l256; /** Modular multiplicative inverse for numbers less than 384 bits */ icp_qat_fw_maths_modinv_odd_l384_input_t maths_modinv_odd_l384; /** Modular multiplicative inverse for numbers less than 512 bits */ icp_qat_fw_maths_modinv_odd_l512_input_t maths_modinv_odd_l512; /** Modular multiplicative inverse for numbers less than 768 bits */ icp_qat_fw_maths_modinv_odd_l768_input_t maths_modinv_odd_l768; /** Modular multiplicative inverse for numbers less than 1024 bits */ icp_qat_fw_maths_modinv_odd_l1024_input_t maths_modinv_odd_l1024; /** Modular multiplicative inverse for numbers less than 1536 bits */ icp_qat_fw_maths_modinv_odd_l1536_input_t maths_modinv_odd_l1536; /** Modular multiplicative inverse for numbers less than 2048 bits */ icp_qat_fw_maths_modinv_odd_l2048_input_t maths_modinv_odd_l2048; /** Modular multiplicative inverse for numbers less than 3072 bits */ icp_qat_fw_maths_modinv_odd_l3072_input_t maths_modinv_odd_l3072; /** Modular multiplicative inverse for numbers less than 4096 bits */ icp_qat_fw_maths_modinv_odd_l4096_input_t maths_modinv_odd_l4096; /** Modular multiplicative inverse for numbers up to 8192 bits */ icp_qat_fw_maths_modinv_odd_l8192_input_t maths_modinv_odd_l8192; /** Modular multiplicative inverse for numbers less than 128 bits */ icp_qat_fw_maths_modinv_even_l128_input_t maths_modinv_even_l128; /** Modular multiplicative inverse for numbers less than 192 bits */ icp_qat_fw_maths_modinv_even_l192_input_t maths_modinv_even_l192; /** Modular multiplicative inverse for numbers less than 256 bits */ icp_qat_fw_maths_modinv_even_l256_input_t maths_modinv_even_l256; /** Modular multiplicative inverse for numbers less than 384 bits */ icp_qat_fw_maths_modinv_even_l384_input_t maths_modinv_even_l384; /** Modular multiplicative inverse for numbers less than 512 bits */ icp_qat_fw_maths_modinv_even_l512_input_t maths_modinv_even_l512; /** Modular multiplicative inverse for numbers less than 768 bits */ icp_qat_fw_maths_modinv_even_l768_input_t maths_modinv_even_l768; /** Modular multiplicative inverse for numbers less than 1024 bits */ icp_qat_fw_maths_modinv_even_l1024_input_t maths_modinv_even_l1024; /** Modular multiplicative inverse for numbers less than 1536 bits */ icp_qat_fw_maths_modinv_even_l1536_input_t maths_modinv_even_l1536; /** Modular multiplicative inverse for numbers less than 2048 bits */ icp_qat_fw_maths_modinv_even_l2048_input_t maths_modinv_even_l2048; /** Modular multiplicative inverse for numbers less than 3072 bits */ icp_qat_fw_maths_modinv_even_l3072_input_t maths_modinv_even_l3072; /** Modular multiplicative inverse for numbers less than 4096 bits */ icp_qat_fw_maths_modinv_even_l4096_input_t maths_modinv_even_l4096; /** Modular multiplicative inverse for numbers up to 8192 bits */ icp_qat_fw_maths_modinv_even_l8192_input_t maths_modinv_even_l8192; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_1024_160_input_t mmp_dsa_gen_p_1024_160; /** DSA key generation G */ icp_qat_fw_mmp_dsa_gen_g_1024_input_t mmp_dsa_gen_g_1024; /** DSA key generation Y */ icp_qat_fw_mmp_dsa_gen_y_1024_input_t mmp_dsa_gen_y_1024; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_1024_160_input_t mmp_dsa_sign_r_1024_160; /** DSA Sign S */ icp_qat_fw_mmp_dsa_sign_s_160_input_t mmp_dsa_sign_s_160; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_t mmp_dsa_sign_r_s_1024_160; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_1024_160_input_t mmp_dsa_verify_1024_160; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_2048_224_input_t mmp_dsa_gen_p_2048_224; /** DSA key generation Y */ icp_qat_fw_mmp_dsa_gen_y_2048_input_t mmp_dsa_gen_y_2048; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_2048_224_input_t mmp_dsa_sign_r_2048_224; /** DSA Sign S */ icp_qat_fw_mmp_dsa_sign_s_224_input_t mmp_dsa_sign_s_224; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_t mmp_dsa_sign_r_s_2048_224; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_2048_224_input_t mmp_dsa_verify_2048_224; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_2048_256_input_t mmp_dsa_gen_p_2048_256; /** DSA key generation G */ icp_qat_fw_mmp_dsa_gen_g_2048_input_t mmp_dsa_gen_g_2048; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_2048_256_input_t mmp_dsa_sign_r_2048_256; /** DSA Sign S */ icp_qat_fw_mmp_dsa_sign_s_256_input_t mmp_dsa_sign_s_256; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_t mmp_dsa_sign_r_s_2048_256; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_2048_256_input_t mmp_dsa_verify_2048_256; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_3072_256_input_t mmp_dsa_gen_p_3072_256; /** DSA key generation G */ icp_qat_fw_mmp_dsa_gen_g_3072_input_t mmp_dsa_gen_g_3072; /** DSA key generation Y */ icp_qat_fw_mmp_dsa_gen_y_3072_input_t mmp_dsa_gen_y_3072; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_3072_256_input_t mmp_dsa_sign_r_3072_256; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_t mmp_dsa_sign_r_s_3072_256; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_3072_256_input_t mmp_dsa_verify_3072_256; /** ECDSA Sign RS for curves B/K-163 and B/K-233 */ icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_input_t mmp_ecdsa_sign_rs_gf2_l256; /** ECDSA Sign R for curves B/K-163 and B/K-233 */ icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_t mmp_ecdsa_sign_r_gf2_l256; /** ECDSA Sign S for curves with n < 2^256 */ icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_t mmp_ecdsa_sign_s_gf2_l256; /** ECDSA Verify for curves B/K-163 and B/K-233 */ icp_qat_fw_mmp_ecdsa_verify_gf2_l256_input_t mmp_ecdsa_verify_gf2_l256; /** ECDSA Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_input_t mmp_ecdsa_sign_rs_gf2_l512; /** ECDSA GF2 Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_t mmp_ecdsa_sign_r_gf2_l512; /** ECDSA GF2 Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_t mmp_ecdsa_sign_s_gf2_l512; /** ECDSA GF2 Verify */ icp_qat_fw_mmp_ecdsa_verify_gf2_l512_input_t mmp_ecdsa_verify_gf2_l512; /** ECDSA GF2 Sign RS for curves B-571/K-571 */ icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_input_t mmp_ecdsa_sign_rs_gf2_571; /** ECDSA GF2 Sign S for curves with deg(q) < 576 */ icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_t mmp_ecdsa_sign_s_gf2_571; /** ECDSA GF2 Sign R for degree 571 */ icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_t mmp_ecdsa_sign_r_gf2_571; /** ECDSA GF2 Verify for degree 571 */ icp_qat_fw_mmp_ecdsa_verify_gf2_571_input_t mmp_ecdsa_verify_gf2_571; /** MATHS GF2 Point Multiplication */ icp_qat_fw_maths_point_multiplication_gf2_l256_input_t maths_point_multiplication_gf2_l256; /** MATHS GF2 Point Verification */ icp_qat_fw_maths_point_verify_gf2_l256_input_t maths_point_verify_gf2_l256; /** MATHS GF2 Point Multiplication */ icp_qat_fw_maths_point_multiplication_gf2_l512_input_t maths_point_multiplication_gf2_l512; /** MATHS GF2 Point Verification */ icp_qat_fw_maths_point_verify_gf2_l512_input_t maths_point_verify_gf2_l512; /** ECC GF2 Point Multiplication for curves B-571/K-571 */ icp_qat_fw_maths_point_multiplication_gf2_571_input_t maths_point_multiplication_gf2_571; /** ECC GF2 Point Verification for degree 571 */ icp_qat_fw_maths_point_verify_gf2_571_input_t maths_point_verify_gf2_571; /** ECDSA GFP Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_t mmp_ecdsa_sign_r_gfp_l256; /** ECDSA GFP Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_t mmp_ecdsa_sign_s_gfp_l256; /** ECDSA GFP Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_input_t mmp_ecdsa_sign_rs_gfp_l256; /** ECDSA GFP Verify */ icp_qat_fw_mmp_ecdsa_verify_gfp_l256_input_t mmp_ecdsa_verify_gfp_l256; /** ECDSA GFP Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_t mmp_ecdsa_sign_r_gfp_l512; /** ECDSA GFP Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_t mmp_ecdsa_sign_s_gfp_l512; /** ECDSA GFP Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_input_t mmp_ecdsa_sign_rs_gfp_l512; /** ECDSA GFP Verify */ icp_qat_fw_mmp_ecdsa_verify_gfp_l512_input_t mmp_ecdsa_verify_gfp_l512; /** ECDSA GFP Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_t mmp_ecdsa_sign_r_gfp_521; /** ECDSA GFP Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_t mmp_ecdsa_sign_s_gfp_521; /** ECDSA GFP Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_input_t mmp_ecdsa_sign_rs_gfp_521; /** ECDSA GFP Verify */ icp_qat_fw_mmp_ecdsa_verify_gfp_521_input_t mmp_ecdsa_verify_gfp_521; /** ECC GFP Point Multiplication */ icp_qat_fw_maths_point_multiplication_gfp_l256_input_t maths_point_multiplication_gfp_l256; /** ECC GFP Partial Point Verification */ icp_qat_fw_maths_point_verify_gfp_l256_input_t maths_point_verify_gfp_l256; /** ECC GFP Point Multiplication */ icp_qat_fw_maths_point_multiplication_gfp_l512_input_t maths_point_multiplication_gfp_l512; /** ECC GFP Partial Point */ icp_qat_fw_maths_point_verify_gfp_l512_input_t maths_point_verify_gfp_l512; /** ECC GFP Point Multiplication */ icp_qat_fw_maths_point_multiplication_gfp_521_input_t maths_point_multiplication_gfp_521; /** ECC GFP Partial Point Verification */ icp_qat_fw_maths_point_verify_gfp_521_input_t maths_point_verify_gfp_521; /** ECC curve25519 Variable Point Multiplication [k]P(x), as specified in RFC7748 */ icp_qat_fw_point_multiplication_c25519_input_t point_multiplication_c25519; /** ECC curve25519 Generator Point Multiplication [k]G(x), as specified in RFC7748 */ icp_qat_fw_generator_multiplication_c25519_input_t generator_multiplication_c25519; /** ECC edwards25519 Variable Point Multiplication [k]P, as specified in RFC8032 */ icp_qat_fw_point_multiplication_ed25519_input_t point_multiplication_ed25519; /** ECC edwards25519 Generator Point Multiplication [k]G, as specified in RFC8032 */ icp_qat_fw_generator_multiplication_ed25519_input_t generator_multiplication_ed25519; /** ECC curve448 Variable Point Multiplication [k]P(x), as specified in RFC7748 */ icp_qat_fw_point_multiplication_c448_input_t point_multiplication_c448; /** ECC curve448 Generator Point Multiplication [k]G(x), as specified in RFC7748 */ icp_qat_fw_generator_multiplication_c448_input_t generator_multiplication_c448; /** ECC edwards448 Variable Point Multiplication [k]P, as specified in RFC8032 */ icp_qat_fw_point_multiplication_ed448_input_t point_multiplication_ed448; /** ECC edwards448 Generator Point Multiplication [k]P, as specified in RFC8032 */ icp_qat_fw_generator_multiplication_ed448_input_t generator_multiplication_ed448; /** ECC P521 ECDSA Sign RS */ icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_input_t mmp_kpt_ecdsa_sign_rs_p521; /** ECC P384 ECDSA Sign RS */ icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_input_t mmp_kpt_ecdsa_sign_rs_p384; /** ECC KPT P256 ECDSA Sign RS */ icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_input_t mmp_kpt_ecdsa_sign_rs_p256; /** KPT RSA 512 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_512_input_t mmp_kpt_rsa_dp1_512; /** KPT RSA 1024 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_1024_input_t mmp_kpt_rsa_dp1_1024; /** KPT RSA 1536 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_1536_input_t mmp_kpt_rsa_dp1_1536; /** KPT RSA 2048 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_2048_input_t mmp_kpt_rsa_dp1_2048; /** KPT RSA 3072 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_3072_input_t mmp_kpt_rsa_dp1_3072; /** KPT RSA 4096 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_4096_input_t mmp_kpt_rsa_dp1_4096; /** KPT RSA 8192 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_8192_input_t mmp_kpt_rsa_dp1_8192; /** RSA 512 decryption second form */ icp_qat_fw_mmp_kpt_rsa_dp2_512_input_t mmp_kpt_rsa_dp2_512; /** RSA 1024 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_1024_input_t mmp_kpt_rsa_dp2_1024; /** KPT RSA 1536 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_1536_input_t mmp_kpt_rsa_dp2_1536; /** RSA 2048 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_2048_input_t mmp_kpt_rsa_dp2_2048; /** */ icp_qat_fw_mmp_kpt_rsa_dp2_3072_input_t mmp_kpt_rsa_dp2_3072; /** RSA 4096 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_4096_input_t mmp_kpt_rsa_dp2_4096; /** RSA 8192 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_8192_input_t mmp_kpt_rsa_dp2_8192; } icp_qat_fw_mmp_input_param_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P384 Variable Point Multiplication [k]P , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_EC_POINT_MULTIPLICATION_P384. */ typedef struct icp_qat_fw_mmp_ec_point_multiplication_p384_output_s { uint64_t xr; /**< xR = affine coordinate X of point [k]P (6 qwords)*/ uint64_t yr; /**< yR = affine coordinate Y of point [k]P (6 qwords)*/ } icp_qat_fw_mmp_ec_point_multiplication_p384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P384 Generator Point Multiplication [k]G , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_EC_GENERATOR_MULTIPLICATION_P384. */ typedef struct icp_qat_fw_mmp_ec_generator_multiplication_p384_output_s { uint64_t xr; /**< xR = affine coordinate X of point [k]G (6 qwords)*/ uint64_t yr; /**< yR = affine coordinate Y of point [k]G (6 qwords)*/ } icp_qat_fw_mmp_ec_generator_multiplication_p384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P384 ECDSA Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_ECDSA_SIGN_RS_P384. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_p384_output_s { uint64_t r; /**< ECDSA signature r (6 qwords)*/ uint64_t s; /**< ECDSA signature s (6 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_p384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P256 Variable Point Multiplication [k]P , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_EC_POINT_MULTIPLICATION_P256. */ typedef struct icp_qat_fw_mmp_ec_point_multiplication_p256_output_s { uint64_t xr; /**< xR = affine coordinate X of point [k]P (4 qwords)*/ uint64_t yr; /**< yR = affine coordinate Y of point [k]P (4 qwords)*/ } icp_qat_fw_mmp_ec_point_multiplication_p256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P256 Generator Point Multiplication [k]G , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_EC_GENERATOR_MULTIPLICATION_P256. */ typedef struct icp_qat_fw_mmp_ec_generator_multiplication_p256_output_s { uint64_t xr; /**< xR = affine coordinate X of point [k]G (4 qwords)*/ uint64_t yr; /**< yR = affine coordinate Y of point [k]G (4 qwords)*/ } icp_qat_fw_mmp_ec_generator_multiplication_p256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P256 ECDSA Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_ECDSA_SIGN_RS_P256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_p256_output_s { uint64_t r; /**< ECDSA signature r (4 qwords)*/ uint64_t s; /**< ECDSA signature s (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_p256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC SM2 point multiply [k]G , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_ECSM2_GENERATOR_MULTIPLICATION. */ typedef struct icp_qat_fw_mmp_ecsm2_generator_multiplication_output_s { uint64_t xd; /**< xD = affine coordinate X of point [k]G (4 qwords)*/ uint64_t yd; /**< yD = affine coordinate Y of point [k]G (4 qwords)*/ } icp_qat_fw_mmp_ecsm2_generator_multiplication_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Initialisation sequence , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_INIT. */ typedef struct icp_qat_fw_mmp_init_output_s { uint64_t zz; /**< 1'd quadword (1 qwords)*/ } icp_qat_fw_mmp_init_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for 768-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_G2_768. */ typedef struct icp_qat_fw_mmp_dh_g2_768_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (12 qwords)*/ } icp_qat_fw_mmp_dh_g2_768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for 768-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_768. */ typedef struct icp_qat_fw_mmp_dh_768_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (12 qwords)*/ } icp_qat_fw_mmp_dh_768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for 1024-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_G2_1024. */ typedef struct icp_qat_fw_mmp_dh_g2_1024_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (16 qwords)*/ } icp_qat_fw_mmp_dh_g2_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for 1024-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_1024. */ typedef struct icp_qat_fw_mmp_dh_1024_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (16 qwords)*/ } icp_qat_fw_mmp_dh_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for 1536-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_G2_1536. */ typedef struct icp_qat_fw_mmp_dh_g2_1536_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (24 qwords)*/ } icp_qat_fw_mmp_dh_g2_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for 1536-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_1536. */ typedef struct icp_qat_fw_mmp_dh_1536_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (24 qwords)*/ } icp_qat_fw_mmp_dh_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for 2048-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_G2_2048. */ typedef struct icp_qat_fw_mmp_dh_g2_2048_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (32 qwords)*/ } icp_qat_fw_mmp_dh_g2_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for 2048-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_2048. */ typedef struct icp_qat_fw_mmp_dh_2048_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (32 qwords)*/ } icp_qat_fw_mmp_dh_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for 3072-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_G2_3072. */ typedef struct icp_qat_fw_mmp_dh_g2_3072_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (48 qwords)*/ } icp_qat_fw_mmp_dh_g2_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for 3072-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_3072. */ typedef struct icp_qat_fw_mmp_dh_3072_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (48 qwords)*/ } icp_qat_fw_mmp_dh_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for 4096-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_G2_4096. */ typedef struct icp_qat_fw_mmp_dh_g2_4096_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (64 qwords)*/ } icp_qat_fw_mmp_dh_g2_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for 4096-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DH_4096. */ typedef struct icp_qat_fw_mmp_dh_4096_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (64 qwords)*/ } icp_qat_fw_mmp_dh_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation base 2 for * 8192-bit numbers , to be used when icp_qat_fw_pke_response_s::functionalityId * is #PKE_DH_G2_8192. */ typedef struct icp_qat_fw_mmp_dh_g2_8192_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (128 qwords)*/ } icp_qat_fw_mmp_dh_g2_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Diffie-Hellman Modular exponentiation for * 8192-bit numbers , to be used when icp_qat_fw_pke_response_s::functionalityId * is #PKE_DH_8192. */ typedef struct icp_qat_fw_mmp_dh_8192_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (128 qwords)*/ } icp_qat_fw_mmp_dh_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 512 key generation first form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP1_512. */ typedef struct icp_qat_fw_mmp_rsa_kp1_512_output_s { uint64_t n; /**< RSA key (8 qwords)*/ uint64_t d; /**< RSA private key (first form) (8 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 512 key generation second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP2_512. */ typedef struct icp_qat_fw_mmp_rsa_kp2_512_output_s { uint64_t n; /**< RSA key (8 qwords)*/ uint64_t d; /**< RSA private key (second form) (8 qwords)*/ uint64_t dp; /**< RSA private key (second form) (4 qwords)*/ uint64_t dq; /**< RSA private key (second form) (4 qwords)*/ uint64_t qinv; /**< RSA private key (second form) (4 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 512 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_EP_512. */ typedef struct icp_qat_fw_mmp_rsa_ep_512_output_s { uint64_t c; /**< cipher text representative, < n (8 qwords)*/ } icp_qat_fw_mmp_rsa_ep_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 512 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP1_512. */ typedef struct icp_qat_fw_mmp_rsa_dp1_512_output_s { uint64_t m; /**< message representative, < n (8 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP2_512. */ typedef struct icp_qat_fw_mmp_rsa_dp2_512_output_s { uint64_t m; /**< message representative, < (p*q) (8 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 key generation first form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP1_1024. */ typedef struct icp_qat_fw_mmp_rsa_kp1_1024_output_s { uint64_t n; /**< RSA key (16 qwords)*/ uint64_t d; /**< RSA private key (first form) (16 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 key generation second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP2_1024. */ typedef struct icp_qat_fw_mmp_rsa_kp2_1024_output_s { uint64_t n; /**< RSA key (16 qwords)*/ uint64_t d; /**< RSA private key (second form) (16 qwords)*/ uint64_t dp; /**< RSA private key (second form) (8 qwords)*/ uint64_t dq; /**< RSA private key (second form) (8 qwords)*/ uint64_t qinv; /**< RSA private key (second form) (8 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_EP_1024. */ typedef struct icp_qat_fw_mmp_rsa_ep_1024_output_s { uint64_t c; /**< cipher text representative, < n (16 qwords)*/ } icp_qat_fw_mmp_rsa_ep_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP1_1024. */ typedef struct icp_qat_fw_mmp_rsa_dp1_1024_output_s { uint64_t m; /**< message representative, < n (16 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP2_1024. */ typedef struct icp_qat_fw_mmp_rsa_dp2_1024_output_s { uint64_t m; /**< message representative, < (p*q) (16 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1536 key generation first form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP1_1536. */ typedef struct icp_qat_fw_mmp_rsa_kp1_1536_output_s { uint64_t n; /**< RSA key (24 qwords)*/ uint64_t d; /**< RSA private key (24 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1536 key generation second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP2_1536. */ typedef struct icp_qat_fw_mmp_rsa_kp2_1536_output_s { uint64_t n; /**< RSA key (24 qwords)*/ uint64_t d; /**< RSA private key (24 qwords)*/ uint64_t dp; /**< RSA private key (12 qwords)*/ uint64_t dq; /**< RSA private key (12 qwords)*/ uint64_t qinv; /**< RSA private key (12 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1536 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_EP_1536. */ typedef struct icp_qat_fw_mmp_rsa_ep_1536_output_s { uint64_t c; /**< cipher text representative, < n (24 qwords)*/ } icp_qat_fw_mmp_rsa_ep_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1536 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP1_1536. */ typedef struct icp_qat_fw_mmp_rsa_dp1_1536_output_s { uint64_t m; /**< message representative, < n (24 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1536 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP2_1536. */ typedef struct icp_qat_fw_mmp_rsa_dp2_1536_output_s { uint64_t m; /**< message representative, < (p*q) (24 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 2048 key generation first form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP1_2048. */ typedef struct icp_qat_fw_mmp_rsa_kp1_2048_output_s { uint64_t n; /**< RSA key (32 qwords)*/ uint64_t d; /**< RSA private key (32 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 2048 key generation second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP2_2048. */ typedef struct icp_qat_fw_mmp_rsa_kp2_2048_output_s { uint64_t n; /**< RSA key (32 qwords)*/ uint64_t d; /**< RSA private key (32 qwords)*/ uint64_t dp; /**< RSA private key (16 qwords)*/ uint64_t dq; /**< RSA private key (16 qwords)*/ uint64_t qinv; /**< RSA private key (16 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 2048 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_EP_2048. */ typedef struct icp_qat_fw_mmp_rsa_ep_2048_output_s { uint64_t c; /**< cipher text representative, < n (32 qwords)*/ } icp_qat_fw_mmp_rsa_ep_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 2048 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP1_2048. */ typedef struct icp_qat_fw_mmp_rsa_dp1_2048_output_s { uint64_t m; /**< message representative, < n (32 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 2048 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP2_2048. */ typedef struct icp_qat_fw_mmp_rsa_dp2_2048_output_s { uint64_t m; /**< message representative, < (p*q) (32 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 3072 key generation first form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP1_3072. */ typedef struct icp_qat_fw_mmp_rsa_kp1_3072_output_s { uint64_t n; /**< RSA key (48 qwords)*/ uint64_t d; /**< RSA private key (48 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 3072 key generation second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP2_3072. */ typedef struct icp_qat_fw_mmp_rsa_kp2_3072_output_s { uint64_t n; /**< RSA key (48 qwords)*/ uint64_t d; /**< RSA private key (48 qwords)*/ uint64_t dp; /**< RSA private key (24 qwords)*/ uint64_t dq; /**< RSA private key (24 qwords)*/ uint64_t qinv; /**< RSA private key (24 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 3072 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_EP_3072. */ typedef struct icp_qat_fw_mmp_rsa_ep_3072_output_s { uint64_t c; /**< cipher text representative, < n (48 qwords)*/ } icp_qat_fw_mmp_rsa_ep_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 3072 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP1_3072. */ typedef struct icp_qat_fw_mmp_rsa_dp1_3072_output_s { uint64_t m; /**< message representative, < n (48 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 3072 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP2_3072. */ typedef struct icp_qat_fw_mmp_rsa_dp2_3072_output_s { uint64_t m; /**< message representative, < (p*q) (48 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 4096 key generation first form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP1_4096. */ typedef struct icp_qat_fw_mmp_rsa_kp1_4096_output_s { uint64_t n; /**< RSA key (64 qwords)*/ uint64_t d; /**< RSA private key (64 qwords)*/ } icp_qat_fw_mmp_rsa_kp1_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 4096 key generation second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_KP2_4096. */ typedef struct icp_qat_fw_mmp_rsa_kp2_4096_output_s { uint64_t n; /**< RSA key (64 qwords)*/ uint64_t d; /**< RSA private key (64 qwords)*/ uint64_t dp; /**< RSA private key (32 qwords)*/ uint64_t dq; /**< RSA private key (32 qwords)*/ uint64_t qinv; /**< RSA private key (32 qwords)*/ } icp_qat_fw_mmp_rsa_kp2_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 4096 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_EP_4096. */ typedef struct icp_qat_fw_mmp_rsa_ep_4096_output_s { uint64_t c; /**< cipher text representative, < n (64 qwords)*/ } icp_qat_fw_mmp_rsa_ep_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 4096 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP1_4096. */ typedef struct icp_qat_fw_mmp_rsa_dp1_4096_output_s { uint64_t m; /**< message representative, < n (64 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 4096 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_RSA_DP2_4096. */ typedef struct icp_qat_fw_mmp_rsa_dp2_4096_output_s { uint64_t m; /**< message representative, < (p*q) (64 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 8192 Encryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_RSA_EP_8192. */ typedef struct icp_qat_fw_mmp_rsa_ep_8192_output_s { uint64_t c; /**< cipher text representative, < n (128 qwords)*/ } icp_qat_fw_mmp_rsa_ep_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 8192 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_RSA_DP1_8192. */ typedef struct icp_qat_fw_mmp_rsa_dp1_8192_output_s { uint64_t m; /**< message representative, < n (128 qwords)*/ } icp_qat_fw_mmp_rsa_dp1_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 8192 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_RSA_DP2_8192. */ typedef struct icp_qat_fw_mmp_rsa_dp2_8192_output_s { uint64_t m; /**< message representative, < (p*q) (128 qwords)*/ } icp_qat_fw_mmp_rsa_dp2_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 192-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_192. */ typedef struct icp_qat_fw_mmp_gcd_pt_192_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 256-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_256. */ typedef struct icp_qat_fw_mmp_gcd_pt_256_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 384-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_384. */ typedef struct icp_qat_fw_mmp_gcd_pt_384_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_512. */ typedef struct icp_qat_fw_mmp_gcd_pt_512_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_768. */ typedef struct icp_qat_fw_mmp_gcd_pt_768_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_1024. */ typedef struct icp_qat_fw_mmp_gcd_pt_1024_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_1536. */ typedef struct icp_qat_fw_mmp_gcd_pt_1536_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_2048. */ typedef struct icp_qat_fw_mmp_gcd_pt_2048_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_3072. */ typedef struct icp_qat_fw_mmp_gcd_pt_3072_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for GCD primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_GCD_PT_4096. */ typedef struct icp_qat_fw_mmp_gcd_pt_4096_output_s { /* no output parameters */ } icp_qat_fw_mmp_gcd_pt_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 160-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_160. */ typedef struct icp_qat_fw_mmp_fermat_pt_160_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_512. */ typedef struct icp_qat_fw_mmp_fermat_pt_512_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for <e; 512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_L512. */ typedef struct icp_qat_fw_mmp_fermat_pt_l512_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_768. */ typedef struct icp_qat_fw_mmp_fermat_pt_768_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_1024. */ typedef struct icp_qat_fw_mmp_fermat_pt_1024_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_1536. */ typedef struct icp_qat_fw_mmp_fermat_pt_1536_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_2048. */ typedef struct icp_qat_fw_mmp_fermat_pt_2048_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_3072. */ typedef struct icp_qat_fw_mmp_fermat_pt_3072_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Fermat primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_FERMAT_PT_4096. */ typedef struct icp_qat_fw_mmp_fermat_pt_4096_output_s { /* no output parameters */ } icp_qat_fw_mmp_fermat_pt_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 160-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_160. */ typedef struct icp_qat_fw_mmp_mr_pt_160_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_512. */ typedef struct icp_qat_fw_mmp_mr_pt_512_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_768. */ typedef struct icp_qat_fw_mmp_mr_pt_768_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_1024. */ typedef struct icp_qat_fw_mmp_mr_pt_1024_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_1536. */ typedef struct icp_qat_fw_mmp_mr_pt_1536_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_2048. */ typedef struct icp_qat_fw_mmp_mr_pt_2048_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_3072. */ typedef struct icp_qat_fw_mmp_mr_pt_3072_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_4096. */ typedef struct icp_qat_fw_mmp_mr_pt_4096_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Miller-Rabin primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_MR_PT_L512. */ typedef struct icp_qat_fw_mmp_mr_pt_l512_output_s { /* no output parameters */ } icp_qat_fw_mmp_mr_pt_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 160-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_160. */ typedef struct icp_qat_fw_mmp_lucas_pt_160_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_512. */ typedef struct icp_qat_fw_mmp_lucas_pt_512_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 768-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_768. */ typedef struct icp_qat_fw_mmp_lucas_pt_768_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 1024-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_1024. */ typedef struct icp_qat_fw_mmp_lucas_pt_1024_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 1536-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_1536. */ typedef struct icp_qat_fw_mmp_lucas_pt_1536_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 2048-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_2048. */ typedef struct icp_qat_fw_mmp_lucas_pt_2048_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 3072-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_3072. */ typedef struct icp_qat_fw_mmp_lucas_pt_3072_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for 4096-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_4096. */ typedef struct icp_qat_fw_mmp_lucas_pt_4096_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Lucas primality test for L512-bit numbers , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_LUCAS_PT_L512. */ typedef struct icp_qat_fw_mmp_lucas_pt_l512_output_s { /* no output parameters */ } icp_qat_fw_mmp_lucas_pt_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 512-bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L512. */ typedef struct icp_qat_fw_maths_modexp_l512_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (8 qwords)*/ } icp_qat_fw_maths_modexp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 1024-bit , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L1024. */ typedef struct icp_qat_fw_maths_modexp_l1024_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (16 qwords)*/ } icp_qat_fw_maths_modexp_l1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 1536-bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L1536. */ typedef struct icp_qat_fw_maths_modexp_l1536_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (24 qwords)*/ } icp_qat_fw_maths_modexp_l1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 2048-bit , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L2048. */ typedef struct icp_qat_fw_maths_modexp_l2048_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (32 qwords)*/ } icp_qat_fw_maths_modexp_l2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 2560-bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L2560. */ typedef struct icp_qat_fw_maths_modexp_l2560_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (40 qwords)*/ } icp_qat_fw_maths_modexp_l2560_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 3072-bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L3072. */ typedef struct icp_qat_fw_maths_modexp_l3072_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (48 qwords)*/ } icp_qat_fw_maths_modexp_l3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 3584-bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L3584. */ typedef struct icp_qat_fw_maths_modexp_l3584_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (56 qwords)*/ } icp_qat_fw_maths_modexp_l3584_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers less than 4096-bit , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODEXP_L4096. */ typedef struct icp_qat_fw_maths_modexp_l4096_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (64 qwords)*/ } icp_qat_fw_maths_modexp_l4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular exponentiation for numbers up to 8192 * bits , to be used when icp_qat_fw_pke_response_s::functionalityId is * #MATHS_MODEXP_L8192. */ typedef struct icp_qat_fw_maths_modexp_l8192_output_s { uint64_t r; /**< modular exponentiation result ≥ 0 and < m (128 qwords)*/ } icp_qat_fw_maths_modexp_l8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less * than 128 bits , to be used when icp_qat_fw_pke_response_s::functionalityId is * #MATHS_MODINV_ODD_L128. */ typedef struct icp_qat_fw_maths_modinv_odd_l128_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (2 qwords)*/ } icp_qat_fw_maths_modinv_odd_l128_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 192 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L192. */ typedef struct icp_qat_fw_maths_modinv_odd_l192_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (3 qwords)*/ } icp_qat_fw_maths_modinv_odd_l192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 256 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L256. */ typedef struct icp_qat_fw_maths_modinv_odd_l256_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (4 qwords)*/ } icp_qat_fw_maths_modinv_odd_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 384 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L384. */ typedef struct icp_qat_fw_maths_modinv_odd_l384_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (6 qwords)*/ } icp_qat_fw_maths_modinv_odd_l384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 512 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L512. */ typedef struct icp_qat_fw_maths_modinv_odd_l512_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (8 qwords)*/ } icp_qat_fw_maths_modinv_odd_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 768 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L768. */ typedef struct icp_qat_fw_maths_modinv_odd_l768_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (12 qwords)*/ } icp_qat_fw_maths_modinv_odd_l768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 1024 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L1024. */ typedef struct icp_qat_fw_maths_modinv_odd_l1024_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (16 qwords)*/ } icp_qat_fw_maths_modinv_odd_l1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 1536 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L1536. */ typedef struct icp_qat_fw_maths_modinv_odd_l1536_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (24 qwords)*/ } icp_qat_fw_maths_modinv_odd_l1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 2048 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L2048. */ typedef struct icp_qat_fw_maths_modinv_odd_l2048_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (32 qwords)*/ } icp_qat_fw_maths_modinv_odd_l2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 3072 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L3072. */ typedef struct icp_qat_fw_maths_modinv_odd_l3072_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (48 qwords)*/ } icp_qat_fw_maths_modinv_odd_l3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 4096 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_ODD_L4096. */ typedef struct icp_qat_fw_maths_modinv_odd_l4096_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (64 qwords)*/ } icp_qat_fw_maths_modinv_odd_l4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers up to * 8192 bits , to be used when icp_qat_fw_pke_response_s::functionalityId is * #MATHS_MODINV_ODD_L8192. */ typedef struct icp_qat_fw_maths_modinv_odd_l8192_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (128 qwords)*/ } icp_qat_fw_maths_modinv_odd_l8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less * than 128 bits , to be used when icp_qat_fw_pke_response_s::functionalityId is * #MATHS_MODINV_EVEN_L128. */ typedef struct icp_qat_fw_maths_modinv_even_l128_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (2 qwords)*/ } icp_qat_fw_maths_modinv_even_l128_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 192 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L192. */ typedef struct icp_qat_fw_maths_modinv_even_l192_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (3 qwords)*/ } icp_qat_fw_maths_modinv_even_l192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 256 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L256. */ typedef struct icp_qat_fw_maths_modinv_even_l256_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (4 qwords)*/ } icp_qat_fw_maths_modinv_even_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 384 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L384. */ typedef struct icp_qat_fw_maths_modinv_even_l384_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (6 qwords)*/ } icp_qat_fw_maths_modinv_even_l384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 512 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L512. */ typedef struct icp_qat_fw_maths_modinv_even_l512_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (8 qwords)*/ } icp_qat_fw_maths_modinv_even_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 768 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L768. */ typedef struct icp_qat_fw_maths_modinv_even_l768_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (12 qwords)*/ } icp_qat_fw_maths_modinv_even_l768_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 1024 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L1024. */ typedef struct icp_qat_fw_maths_modinv_even_l1024_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (16 qwords)*/ } icp_qat_fw_maths_modinv_even_l1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 1536 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L1536. */ typedef struct icp_qat_fw_maths_modinv_even_l1536_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (24 qwords)*/ } icp_qat_fw_maths_modinv_even_l1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 2048 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L2048. */ typedef struct icp_qat_fw_maths_modinv_even_l2048_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (32 qwords)*/ } icp_qat_fw_maths_modinv_even_l2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 3072 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L3072. */ typedef struct icp_qat_fw_maths_modinv_even_l3072_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (48 qwords)*/ } icp_qat_fw_maths_modinv_even_l3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers less than 4096 bits , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_MODINV_EVEN_L4096. */ typedef struct icp_qat_fw_maths_modinv_even_l4096_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (64 qwords)*/ } icp_qat_fw_maths_modinv_even_l4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for Modular multiplicative inverse for numbers up to * 8192 bits , to be used when icp_qat_fw_pke_response_s::functionalityId is * #MATHS_MODINV_EVEN_L8192. */ typedef struct icp_qat_fw_maths_modinv_even_l8192_output_s { uint64_t c; /**< modular multiplicative inverse of a, > 0 and < b (128 qwords)*/ } icp_qat_fw_maths_modinv_even_l8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_P_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_1024_160_output_s { uint64_t p; /**< candidate for DSA parameter p (16 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_1024_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA key generation G , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_G_1024. */ typedef struct icp_qat_fw_mmp_dsa_gen_g_1024_output_s { uint64_t g; /**< DSA parameter (16 qwords)*/ } icp_qat_fw_mmp_dsa_gen_g_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA key generation Y , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_Y_1024. */ typedef struct icp_qat_fw_mmp_dsa_gen_y_1024_output_s { uint64_t y; /**< DSA parameter (16 qwords)*/ } icp_qat_fw_mmp_dsa_gen_y_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_1024_160_output_s { uint64_t r; /**< DSA 160-bits signature (3 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_1024_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_S_160. */ typedef struct icp_qat_fw_mmp_dsa_sign_s_160_output_s { uint64_t s; /**< s DSA 160-bits signature (3 qwords)*/ } icp_qat_fw_mmp_dsa_sign_s_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_S_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_1024_160_output_s { uint64_t r; /**< DSA 160-bits signature (3 qwords)*/ uint64_t s; /**< DSA 160-bits signature (3 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_1024_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_VERIFY_1024_160. */ typedef struct icp_qat_fw_mmp_dsa_verify_1024_160_output_s { /* no output parameters */ } icp_qat_fw_mmp_dsa_verify_1024_160_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_P_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_2048_224_output_s { uint64_t p; /**< candidate for DSA parameter p (32 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_2048_224_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA key generation Y , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_Y_2048. */ typedef struct icp_qat_fw_mmp_dsa_gen_y_2048_output_s { uint64_t y; /**< DSA parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_gen_y_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_2048_224_output_s { uint64_t r; /**< DSA 224-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_2048_224_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_S_224. */ typedef struct icp_qat_fw_mmp_dsa_sign_s_224_output_s { uint64_t s; /**< s DSA 224-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_s_224_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_S_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_2048_224_output_s { uint64_t r; /**< DSA 224-bits signature (4 qwords)*/ uint64_t s; /**< DSA 224-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_2048_224_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_VERIFY_2048_224. */ typedef struct icp_qat_fw_mmp_dsa_verify_2048_224_output_s { /* no output parameters */ } icp_qat_fw_mmp_dsa_verify_2048_224_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_P_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_2048_256_output_s { uint64_t p; /**< candidate for DSA parameter p (32 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_2048_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA key generation G , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_G_2048. */ typedef struct icp_qat_fw_mmp_dsa_gen_g_2048_output_s { uint64_t g; /**< DSA parameter (32 qwords)*/ } icp_qat_fw_mmp_dsa_gen_g_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_2048_256_output_s { uint64_t r; /**< DSA 256-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_2048_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_S_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_s_256_output_s { uint64_t s; /**< s DSA 256-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_s_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_S_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_2048_256_output_s { uint64_t r; /**< DSA 256-bits signature (4 qwords)*/ uint64_t s; /**< DSA 256-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_2048_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_VERIFY_2048_256. */ typedef struct icp_qat_fw_mmp_dsa_verify_2048_256_output_s { /* no output parameters */ } icp_qat_fw_mmp_dsa_verify_2048_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA parameter generation P , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_P_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_gen_p_3072_256_output_s { uint64_t p; /**< candidate for DSA parameter p (48 qwords)*/ } icp_qat_fw_mmp_dsa_gen_p_3072_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA key generation G , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_G_3072. */ typedef struct icp_qat_fw_mmp_dsa_gen_g_3072_output_s { uint64_t g; /**< DSA parameter (48 qwords)*/ } icp_qat_fw_mmp_dsa_gen_g_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA key generation Y , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_GEN_Y_3072. */ typedef struct icp_qat_fw_mmp_dsa_gen_y_3072_output_s { uint64_t y; /**< DSA parameter (48 qwords)*/ } icp_qat_fw_mmp_dsa_gen_y_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_3072_256_output_s { uint64_t r; /**< DSA 256-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_3072_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Sign R S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_SIGN_R_S_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_sign_r_s_3072_256_output_s { uint64_t r; /**< DSA 256-bits signature (4 qwords)*/ uint64_t s; /**< DSA 256-bits signature (4 qwords)*/ } icp_qat_fw_mmp_dsa_sign_r_s_3072_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for DSA Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_DSA_VERIFY_3072_256. */ typedef struct icp_qat_fw_mmp_dsa_verify_3072_256_output_s { /* no output parameters */ } icp_qat_fw_mmp_dsa_verify_3072_256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA Sign RS for curves B/K-163 and B/K-233 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_RS_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_output_s { uint64_t r; /**< ECDSA signature r > 0 and < n (4 qwords)*/ uint64_t s; /**< ECDSA signature s > 0 and < n (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA Sign R for curves B/K-163 and B/K-233 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_R_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_output_s { uint64_t r; /**< ECDSA signature r > 0 and < n (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA Sign S for curves with n < 2^256 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_S_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_output_s { uint64_t s; /**< ECDSA signature s > 0 and < n (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA Verify for curves B/K-163 and B/K-233 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_VERIFY_GF2_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gf2_l256_output_s { /* no output parameters */ } icp_qat_fw_mmp_ecdsa_verify_gf2_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_RS_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_output_s { uint64_t r; /**< (8 qwords)*/ uint64_t s; /**< ECDSA signature r > 0 and < n ECDSA signature s > 0 and < n (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_R_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_output_s { uint64_t r; /**< ECDSA signature r > 0 and < n (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_S_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_output_s { uint64_t s; /**< ECDSA signature s > 0 and < n (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_VERIFY_GF2_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gf2_l512_output_s { /* no output parameters */ } icp_qat_fw_mmp_ecdsa_verify_gf2_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Sign RS for curves B-571/K-571 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_RS_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_output_s { uint64_t r; /**< (9 qwords)*/ uint64_t s; /**< ECDSA signature r > 0 and < n ECDSA signature s > 0 and < n (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Sign S for curves with deg(q) < 576 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_S_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_output_s { uint64_t s; /**< ECDSA signature s > 0 and < n (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Sign R for degree 571 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_R_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_output_s { uint64_t r; /**< ECDSA signature r > 0 and < n (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GF2 Verify for degree 571 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_VERIFY_GF2_571. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gf2_571_output_s { /* no output parameters */ } icp_qat_fw_mmp_ecdsa_verify_gf2_571_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for MATHS GF2 Point Multiplication , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GF2_L256. */ typedef struct icp_qat_fw_maths_point_multiplication_gf2_l256_output_s { uint64_t xk; /**< x coordinate of resultant point (< degree(q)) (4 qwords)*/ uint64_t yk; /**< y coordinate of resultant point (< degree(q)) (4 qwords)*/ } icp_qat_fw_maths_point_multiplication_gf2_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for MATHS GF2 Point Verification , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_VERIFY_GF2_L256. */ typedef struct icp_qat_fw_maths_point_verify_gf2_l256_output_s { /* no output parameters */ } icp_qat_fw_maths_point_verify_gf2_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for MATHS GF2 Point Multiplication , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GF2_L512. */ typedef struct icp_qat_fw_maths_point_multiplication_gf2_l512_output_s { uint64_t xk; /**< x coordinate of resultant point (< q) (8 qwords)*/ uint64_t yk; /**< y coordinate of resultant point (< q) (8 qwords)*/ } icp_qat_fw_maths_point_multiplication_gf2_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for MATHS GF2 Point Verification , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_VERIFY_GF2_L512. */ typedef struct icp_qat_fw_maths_point_verify_gf2_l512_output_s { /* no output parameters */ } icp_qat_fw_maths_point_verify_gf2_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GF2 Point Multiplication for curves B-571/K-571 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GF2_571. */ typedef struct icp_qat_fw_maths_point_multiplication_gf2_571_output_s { uint64_t xk; /**< x coordinate of resultant point (degree < degree(q)) (9 qwords)*/ uint64_t yk; /**< y coordinate of resultant point (degree < degree(q)) (9 qwords)*/ } icp_qat_fw_maths_point_multiplication_gf2_571_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GF2 Point Verification for degree 571 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_VERIFY_GF2_571. */ typedef struct icp_qat_fw_maths_point_verify_gf2_571_output_s { /* no output parameters */ } icp_qat_fw_maths_point_verify_gf2_571_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_R_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_output_s { uint64_t r; /**< ECDSA signature (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_S_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_output_s { uint64_t s; /**< ECDSA signature s (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_RS_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_output_s { uint64_t r; /**< ECDSA signature r (4 qwords)*/ uint64_t s; /**< ECDSA signature s (4 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_VERIFY_GFP_L256. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gfp_l256_output_s { /* no output parameters */ } icp_qat_fw_mmp_ecdsa_verify_gfp_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_R_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_output_s { uint64_t r; /**< ECDSA signature (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_S_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_output_s { uint64_t s; /**< ECDSA signature s (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_RS_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_output_s { uint64_t r; /**< ECDSA signature r (8 qwords)*/ uint64_t s; /**< ECDSA signature s (8 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_VERIFY_GFP_L512. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gfp_l512_output_s { /* no output parameters */ } icp_qat_fw_mmp_ecdsa_verify_gfp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign R , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_R_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_output_s { uint64_t r; /**< ECDSA signature (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign S , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_S_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_output_s { uint64_t s; /**< ECDSA signature s (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_SIGN_RS_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_output_s { uint64_t r; /**< ECDSA signature r (9 qwords)*/ uint64_t s; /**< ECDSA signature s (9 qwords)*/ } icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECDSA GFP Verify , * to be used when icp_qat_fw_pke_response_s::functionalityId is #PKE_ECDSA_VERIFY_GFP_521. */ typedef struct icp_qat_fw_mmp_ecdsa_verify_gfp_521_output_s { /* no output parameters */ } icp_qat_fw_mmp_ecdsa_verify_gfp_521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GFP Point Multiplication , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GFP_L256. */ typedef struct icp_qat_fw_maths_point_multiplication_gfp_l256_output_s { uint64_t xk; /**< x coordinate of resultant EC point (4 qwords)*/ uint64_t yk; /**< y coordinate of resultant EC point (4 qwords)*/ } icp_qat_fw_maths_point_multiplication_gfp_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GFP Partial Point Verification , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_VERIFY_GFP_L256. */ typedef struct icp_qat_fw_maths_point_verify_gfp_l256_output_s { /* no output parameters */ } icp_qat_fw_maths_point_verify_gfp_l256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GFP Point Multiplication , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GFP_L512. */ typedef struct icp_qat_fw_maths_point_multiplication_gfp_l512_output_s { uint64_t xk; /**< x coordinate of resultant EC point (8 qwords)*/ uint64_t yk; /**< y coordinate of resultant EC point (8 qwords)*/ } icp_qat_fw_maths_point_multiplication_gfp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GFP Partial Point , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_VERIFY_GFP_L512. */ typedef struct icp_qat_fw_maths_point_verify_gfp_l512_output_s { /* no output parameters */ } icp_qat_fw_maths_point_verify_gfp_l512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GFP Point Multiplication , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_MULTIPLICATION_GFP_521. */ typedef struct icp_qat_fw_maths_point_multiplication_gfp_521_output_s { uint64_t xk; /**< x coordinate of resultant EC point (9 qwords)*/ uint64_t yk; /**< y coordinate of resultant EC point (9 qwords)*/ } icp_qat_fw_maths_point_multiplication_gfp_521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC GFP Partial Point Verification , * to be used when icp_qat_fw_pke_response_s::functionalityId is #MATHS_POINT_VERIFY_GFP_521. */ typedef struct icp_qat_fw_maths_point_verify_gfp_521_output_s { /* no output parameters */ } icp_qat_fw_maths_point_verify_gfp_521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC curve25519 Variable Point Multiplication [k]P(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #POINT_MULTIPLICATION_C25519. */ typedef struct icp_qat_fw_point_multiplication_c25519_output_s { uint64_t xr; /**< xR = Montgomery affine coordinate X of point [k]P (4 qwords)*/ } icp_qat_fw_point_multiplication_c25519_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC curve25519 Generator Point Multiplication [k]G(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #GENERATOR_MULTIPLICATION_C25519. */ typedef struct icp_qat_fw_generator_multiplication_c25519_output_s { uint64_t xr; /**< xR = Montgomery affine coordinate X of point [k]G (4 qwords)*/ } icp_qat_fw_generator_multiplication_c25519_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC edwards25519 Variable Point Multiplication [k]P, as specified in RFC8032 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #POINT_MULTIPLICATION_ED25519. */ typedef struct icp_qat_fw_point_multiplication_ed25519_output_s { uint64_t xr; /**< xR = Twisted Edwards affine coordinate X of point [k]P (4 qwords)*/ uint64_t yr; /**< yR = Twisted Edwards affine coordinate Y of point [k]P (4 qwords)*/ } icp_qat_fw_point_multiplication_ed25519_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC edwards25519 Generator Point Multiplication [k]G, as specified in RFC8032 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #GENERATOR_MULTIPLICATION_ED25519. */ typedef struct icp_qat_fw_generator_multiplication_ed25519_output_s { uint64_t xr; /**< xR = Twisted Edwards affine coordinate X of point [k]G (4 qwords)*/ uint64_t yr; /**< yR = Twisted Edwards affine coordinate Y of point [k]G (4 qwords)*/ } icp_qat_fw_generator_multiplication_ed25519_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC curve448 Variable Point Multiplication [k]P(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #POINT_MULTIPLICATION_C448. */ typedef struct icp_qat_fw_point_multiplication_c448_output_s { uint64_t xr; /**< xR = Montgomery affine coordinate X of point [k]P (8 qwords)*/ } icp_qat_fw_point_multiplication_c448_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC curve448 Generator Point Multiplication [k]G(x), as specified in RFC7748 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #GENERATOR_MULTIPLICATION_C448. */ typedef struct icp_qat_fw_generator_multiplication_c448_output_s { uint64_t xr; /**< xR = Montgomery affine coordinate X of point [k]G (8 qwords)*/ } icp_qat_fw_generator_multiplication_c448_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC edwards448 Variable Point Multiplication [k]P, as specified in RFC8032 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #POINT_MULTIPLICATION_ED448. */ typedef struct icp_qat_fw_point_multiplication_ed448_output_s { uint64_t xr; /**< xR = Edwards affine coordinate X of point [k]P (8 qwords)*/ uint64_t yr; /**< yR = Edwards affine coordinate Y of point [k]P (8 qwords)*/ } icp_qat_fw_point_multiplication_ed448_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC edwards448 Generator Point Multiplication [k]P, as specified in RFC8032 , * to be used when icp_qat_fw_pke_response_s::functionalityId is #GENERATOR_MULTIPLICATION_ED448. */ typedef struct icp_qat_fw_generator_multiplication_ed448_output_s { uint64_t xr; /**< xR = Edwards affine coordinate X of point [k]G (8 qwords)*/ uint64_t yr; /**< yR = Edwards affine coordinate Y of point [k]G (8 qwords)*/ } icp_qat_fw_generator_multiplication_ed448_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P521 ECDSA Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_ECDSA_SIGN_RS_P521. */ typedef struct icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_output_s { uint64_t r; /**< ECDSA signature r (6 qwords)*/ uint64_t s; /**< ECDSA signature s (6 qwords)*/ } icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC P384 ECDSA Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_ECDSA_SIGN_RS_P384. */ typedef struct icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_output_s { uint64_t r; /**< ECDSA signature r (6 qwords)*/ uint64_t s; /**< ECDSA signature s (6 qwords)*/ } icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for ECC KPT P256 ECDSA Sign RS , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_ECDSA_SIGN_RS_P256. */ typedef struct icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_output_s { uint64_t r; /**< ECDSA signature r (4 qwords)*/ uint64_t s; /**< ECDSA signature s (4 qwords)*/ } icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 512 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_512. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_512_output_s { uint64_t m; /**< message representative, < n (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 1024 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_1024. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_1024_output_s { uint64_t m; /**< message representative, < n (16 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 1536 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_1536. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_1536_output_s { uint64_t m; /**< message representative, < n (24 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 2048 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_2048. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_2048_output_s { uint64_t m; /**< message representative, < n (32 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 3072 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_3072. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_3072_output_s { uint64_t m; /**< message representative, < n (48 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 4096 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_4096. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_4096_output_s { uint64_t m; /**< message representative, < n (64 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 8192 Decryption , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP1_8192. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp1_8192_output_s { uint64_t m; /**< message representative, < n (128 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp1_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 512 decryption second form , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_512. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_512_output_s { uint64_t m; /**< message representative, < (p*q) (8 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_512_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 1024 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_1024. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_1024_output_s { uint64_t m; /**< message representative, < (p*q) (16 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_1024_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for KPT RSA 1536 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_1536. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_1536_output_s { uint64_t m; /**< message representative, < (p*q) (24 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_1536_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 2048 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_2048. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_2048_output_s { uint64_t m; /**< message representative, < (p*q) (32 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_2048_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_3072. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_3072_output_s { uint64_t m; /**< message representative, < (p*q) (48 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_3072_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 4096 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_4096. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_4096_output_s { uint64_t m; /**< message representative, < (p*q) (64 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_4096_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * Output parameter list for RSA 8192 Decryption with CRT , * to be used when icp_qat_fw_pke_response_s::functionalityId is * #PKE_KPT_RSA_DP2_8192. */ typedef struct icp_qat_fw_mmp_kpt_rsa_dp2_8192_output_s { uint64_t m; /**< message representative, < (p*q) (128 qwords)*/ } icp_qat_fw_mmp_kpt_rsa_dp2_8192_output_t; /** * @ingroup icp_qat_fw_mmp * @brief * MMP output parameters */ typedef union icp_qat_fw_mmp_output_param_u { /** Generic parameter structure : All members of this wrapper structure * are pointers to large integers. */ uint64_t flat_array[ICP_QAT_FW_PKE_OUTPUT_COUNT_MAX]; /** ECC P384 Variable Point Multiplication [k]P */ icp_qat_fw_mmp_ec_point_multiplication_p384_output_t mmp_ec_point_multiplication_p384; /** ECC P384 Generator Point Multiplication [k]G */ icp_qat_fw_mmp_ec_generator_multiplication_p384_output_t mmp_ec_generator_multiplication_p384; /** ECC P384 ECDSA Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_p384_output_t mmp_ecdsa_sign_rs_p384; /** ECC P256 Variable Point Multiplication [k]P */ icp_qat_fw_mmp_ec_point_multiplication_p256_output_t mmp_ec_point_multiplication_p256; /** ECC P256 Generator Point Multiplication [k]G */ icp_qat_fw_mmp_ec_generator_multiplication_p256_output_t mmp_ec_generator_multiplication_p256; /** ECC P256 ECDSA Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_p256_output_t mmp_ecdsa_sign_rs_p256; /** ECC SM2 point multiply [k]G */ icp_qat_fw_mmp_ecsm2_generator_multiplication_output_t mmp_ecsm2_generator_multiplication; /** ECC curve25519 Variable Point Multiplication [k]P(x), as specified in * RFC7748 */ icp_qat_fw_point_multiplication_c25519_output_t point_multiplication_c25519; /** ECC curve25519 Generator Point Multiplication [k]G(x), as specified in * RFC7748 */ icp_qat_fw_generator_multiplication_c25519_output_t generator_multiplication_c25519; /** ECC edwards25519 Variable Point Multiplication [k]P, as specified in * RFC8032 */ icp_qat_fw_point_multiplication_ed25519_output_t point_multiplication_ed25519; /** ECC edwards25519 Generator Point Multiplication [k]G, as specified in * RFC8032 */ icp_qat_fw_generator_multiplication_ed25519_output_t generator_multiplication_ed25519; /** ECC curve448 Variable Point Multiplication [k]P(x), as specified in * RFC7748 */ icp_qat_fw_point_multiplication_c448_output_t point_multiplication_c448; /** ECC curve448 Generator Point Multiplication [k]G(x), as specified in * RFC7748 */ icp_qat_fw_generator_multiplication_c448_output_t generator_multiplication_c448; /** ECC edwards448 Variable Point Multiplication [k]P, as specified in * RFC8032 */ icp_qat_fw_point_multiplication_ed448_output_t point_multiplication_ed448; /** ECC edwards448 Generator Point Multiplication [k]G, as specified in * RFC8032 */ icp_qat_fw_generator_multiplication_ed448_output_t generator_multiplication_ed448; /** Initialisation sequence */ icp_qat_fw_mmp_init_output_t mmp_init; /** Diffie-Hellman Modular exponentiation base 2 for 768-bit numbers */ icp_qat_fw_mmp_dh_g2_768_output_t mmp_dh_g2_768; /** Diffie-Hellman Modular exponentiation for 768-bit numbers */ icp_qat_fw_mmp_dh_768_output_t mmp_dh_768; /** Diffie-Hellman Modular exponentiation base 2 for 1024-bit numbers */ icp_qat_fw_mmp_dh_g2_1024_output_t mmp_dh_g2_1024; /** Diffie-Hellman Modular exponentiation for 1024-bit numbers */ icp_qat_fw_mmp_dh_1024_output_t mmp_dh_1024; /** Diffie-Hellman Modular exponentiation base 2 for 1536-bit numbers */ icp_qat_fw_mmp_dh_g2_1536_output_t mmp_dh_g2_1536; /** Diffie-Hellman Modular exponentiation for 1536-bit numbers */ icp_qat_fw_mmp_dh_1536_output_t mmp_dh_1536; /** Diffie-Hellman Modular exponentiation base 2 for 2048-bit numbers */ icp_qat_fw_mmp_dh_g2_2048_output_t mmp_dh_g2_2048; /** Diffie-Hellman Modular exponentiation for 2048-bit numbers */ icp_qat_fw_mmp_dh_2048_output_t mmp_dh_2048; /** Diffie-Hellman Modular exponentiation base 2 for 3072-bit numbers */ icp_qat_fw_mmp_dh_g2_3072_output_t mmp_dh_g2_3072; /** Diffie-Hellman Modular exponentiation for 3072-bit numbers */ icp_qat_fw_mmp_dh_3072_output_t mmp_dh_3072; /** Diffie-Hellman Modular exponentiation base 2 for 4096-bit numbers */ icp_qat_fw_mmp_dh_g2_4096_output_t mmp_dh_g2_4096; /** Diffie-Hellman Modular exponentiation for 4096-bit numbers */ icp_qat_fw_mmp_dh_4096_output_t mmp_dh_4096; /** Diffie-Hellman Modular exponentiation base 2 for 8192-bit numbers */ icp_qat_fw_mmp_dh_g2_8192_output_t mmp_dh_g2_8192; /** Diffie-Hellman Modular exponentiation for 8192-bit numbers */ icp_qat_fw_mmp_dh_8192_output_t mmp_dh_8192; /** RSA 512 key generation first form */ icp_qat_fw_mmp_rsa_kp1_512_output_t mmp_rsa_kp1_512; /** RSA 512 key generation second form */ icp_qat_fw_mmp_rsa_kp2_512_output_t mmp_rsa_kp2_512; /** RSA 512 Encryption */ icp_qat_fw_mmp_rsa_ep_512_output_t mmp_rsa_ep_512; /** RSA 512 Decryption */ icp_qat_fw_mmp_rsa_dp1_512_output_t mmp_rsa_dp1_512; /** RSA 1024 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_512_output_t mmp_rsa_dp2_512; /** RSA 1024 key generation first form */ icp_qat_fw_mmp_rsa_kp1_1024_output_t mmp_rsa_kp1_1024; /** RSA 1024 key generation second form */ icp_qat_fw_mmp_rsa_kp2_1024_output_t mmp_rsa_kp2_1024; /** RSA 1024 Encryption */ icp_qat_fw_mmp_rsa_ep_1024_output_t mmp_rsa_ep_1024; /** RSA 1024 Decryption */ icp_qat_fw_mmp_rsa_dp1_1024_output_t mmp_rsa_dp1_1024; /** RSA 1024 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_1024_output_t mmp_rsa_dp2_1024; /** RSA 1536 key generation first form */ icp_qat_fw_mmp_rsa_kp1_1536_output_t mmp_rsa_kp1_1536; /** RSA 1536 key generation second form */ icp_qat_fw_mmp_rsa_kp2_1536_output_t mmp_rsa_kp2_1536; /** RSA 1536 Encryption */ icp_qat_fw_mmp_rsa_ep_1536_output_t mmp_rsa_ep_1536; /** RSA 1536 Decryption */ icp_qat_fw_mmp_rsa_dp1_1536_output_t mmp_rsa_dp1_1536; /** RSA 1536 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_1536_output_t mmp_rsa_dp2_1536; /** RSA 2048 key generation first form */ icp_qat_fw_mmp_rsa_kp1_2048_output_t mmp_rsa_kp1_2048; /** RSA 2048 key generation second form */ icp_qat_fw_mmp_rsa_kp2_2048_output_t mmp_rsa_kp2_2048; /** RSA 2048 Encryption */ icp_qat_fw_mmp_rsa_ep_2048_output_t mmp_rsa_ep_2048; /** RSA 2048 Decryption */ icp_qat_fw_mmp_rsa_dp1_2048_output_t mmp_rsa_dp1_2048; /** RSA 2048 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_2048_output_t mmp_rsa_dp2_2048; /** RSA 3072 key generation first form */ icp_qat_fw_mmp_rsa_kp1_3072_output_t mmp_rsa_kp1_3072; /** RSA 3072 key generation second form */ icp_qat_fw_mmp_rsa_kp2_3072_output_t mmp_rsa_kp2_3072; /** RSA 3072 Encryption */ icp_qat_fw_mmp_rsa_ep_3072_output_t mmp_rsa_ep_3072; /** RSA 3072 Decryption */ icp_qat_fw_mmp_rsa_dp1_3072_output_t mmp_rsa_dp1_3072; /** RSA 3072 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_3072_output_t mmp_rsa_dp2_3072; /** RSA 4096 key generation first form */ icp_qat_fw_mmp_rsa_kp1_4096_output_t mmp_rsa_kp1_4096; /** RSA 4096 key generation second form */ icp_qat_fw_mmp_rsa_kp2_4096_output_t mmp_rsa_kp2_4096; /** RSA 4096 Encryption */ icp_qat_fw_mmp_rsa_ep_4096_output_t mmp_rsa_ep_4096; /** RSA 4096 Decryption */ icp_qat_fw_mmp_rsa_dp1_4096_output_t mmp_rsa_dp1_4096; /** RSA 4096 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_4096_output_t mmp_rsa_dp2_4096; /** RSA 8192 Encryption */ icp_qat_fw_mmp_rsa_ep_8192_output_t mmp_rsa_ep_8192; /** RSA 8192 Decryption */ icp_qat_fw_mmp_rsa_dp1_8192_output_t mmp_rsa_dp1_8192; /** RSA 8192 Decryption with CRT */ icp_qat_fw_mmp_rsa_dp2_8192_output_t mmp_rsa_dp2_8192; /** GCD primality test for 192-bit numbers */ icp_qat_fw_mmp_gcd_pt_192_output_t mmp_gcd_pt_192; /** GCD primality test for 256-bit numbers */ icp_qat_fw_mmp_gcd_pt_256_output_t mmp_gcd_pt_256; /** GCD primality test for 384-bit numbers */ icp_qat_fw_mmp_gcd_pt_384_output_t mmp_gcd_pt_384; /** GCD primality test for 512-bit numbers */ icp_qat_fw_mmp_gcd_pt_512_output_t mmp_gcd_pt_512; /** GCD primality test for 768-bit numbers */ icp_qat_fw_mmp_gcd_pt_768_output_t mmp_gcd_pt_768; /** GCD primality test for 1024-bit numbers */ icp_qat_fw_mmp_gcd_pt_1024_output_t mmp_gcd_pt_1024; /** GCD primality test for 1536-bit numbers */ icp_qat_fw_mmp_gcd_pt_1536_output_t mmp_gcd_pt_1536; /** GCD primality test for 2048-bit numbers */ icp_qat_fw_mmp_gcd_pt_2048_output_t mmp_gcd_pt_2048; /** GCD primality test for 3072-bit numbers */ icp_qat_fw_mmp_gcd_pt_3072_output_t mmp_gcd_pt_3072; /** GCD primality test for 4096-bit numbers */ icp_qat_fw_mmp_gcd_pt_4096_output_t mmp_gcd_pt_4096; /** Fermat primality test for 160-bit numbers */ icp_qat_fw_mmp_fermat_pt_160_output_t mmp_fermat_pt_160; /** Fermat primality test for 512-bit numbers */ icp_qat_fw_mmp_fermat_pt_512_output_t mmp_fermat_pt_512; /** Fermat primality test for <e; 512-bit numbers */ icp_qat_fw_mmp_fermat_pt_l512_output_t mmp_fermat_pt_l512; /** Fermat primality test for 768-bit numbers */ icp_qat_fw_mmp_fermat_pt_768_output_t mmp_fermat_pt_768; /** Fermat primality test for 1024-bit numbers */ icp_qat_fw_mmp_fermat_pt_1024_output_t mmp_fermat_pt_1024; /** Fermat primality test for 1536-bit numbers */ icp_qat_fw_mmp_fermat_pt_1536_output_t mmp_fermat_pt_1536; /** Fermat primality test for 2048-bit numbers */ icp_qat_fw_mmp_fermat_pt_2048_output_t mmp_fermat_pt_2048; /** Fermat primality test for 3072-bit numbers */ icp_qat_fw_mmp_fermat_pt_3072_output_t mmp_fermat_pt_3072; /** Fermat primality test for 4096-bit numbers */ icp_qat_fw_mmp_fermat_pt_4096_output_t mmp_fermat_pt_4096; /** Miller-Rabin primality test for 160-bit numbers */ icp_qat_fw_mmp_mr_pt_160_output_t mmp_mr_pt_160; /** Miller-Rabin primality test for 512-bit numbers */ icp_qat_fw_mmp_mr_pt_512_output_t mmp_mr_pt_512; /** Miller-Rabin primality test for 768-bit numbers */ icp_qat_fw_mmp_mr_pt_768_output_t mmp_mr_pt_768; /** Miller-Rabin primality test for 1024-bit numbers */ icp_qat_fw_mmp_mr_pt_1024_output_t mmp_mr_pt_1024; /** Miller-Rabin primality test for 1536-bit numbers */ icp_qat_fw_mmp_mr_pt_1536_output_t mmp_mr_pt_1536; /** Miller-Rabin primality test for 2048-bit numbers */ icp_qat_fw_mmp_mr_pt_2048_output_t mmp_mr_pt_2048; /** Miller-Rabin primality test for 3072-bit numbers */ icp_qat_fw_mmp_mr_pt_3072_output_t mmp_mr_pt_3072; /** Miller-Rabin primality test for 4096-bit numbers */ icp_qat_fw_mmp_mr_pt_4096_output_t mmp_mr_pt_4096; /** Miller-Rabin primality test for 512-bit numbers */ icp_qat_fw_mmp_mr_pt_l512_output_t mmp_mr_pt_l512; /** Lucas primality test for 160-bit numbers */ icp_qat_fw_mmp_lucas_pt_160_output_t mmp_lucas_pt_160; /** Lucas primality test for 512-bit numbers */ icp_qat_fw_mmp_lucas_pt_512_output_t mmp_lucas_pt_512; /** Lucas primality test for 768-bit numbers */ icp_qat_fw_mmp_lucas_pt_768_output_t mmp_lucas_pt_768; /** Lucas primality test for 1024-bit numbers */ icp_qat_fw_mmp_lucas_pt_1024_output_t mmp_lucas_pt_1024; /** Lucas primality test for 1536-bit numbers */ icp_qat_fw_mmp_lucas_pt_1536_output_t mmp_lucas_pt_1536; /** Lucas primality test for 2048-bit numbers */ icp_qat_fw_mmp_lucas_pt_2048_output_t mmp_lucas_pt_2048; /** Lucas primality test for 3072-bit numbers */ icp_qat_fw_mmp_lucas_pt_3072_output_t mmp_lucas_pt_3072; /** Lucas primality test for 4096-bit numbers */ icp_qat_fw_mmp_lucas_pt_4096_output_t mmp_lucas_pt_4096; /** Lucas primality test for L512-bit numbers */ icp_qat_fw_mmp_lucas_pt_l512_output_t mmp_lucas_pt_l512; /** Modular exponentiation for numbers less than 512-bits */ icp_qat_fw_maths_modexp_l512_output_t maths_modexp_l512; /** Modular exponentiation for numbers less than 1024-bit */ icp_qat_fw_maths_modexp_l1024_output_t maths_modexp_l1024; /** Modular exponentiation for numbers less than 1536-bits */ icp_qat_fw_maths_modexp_l1536_output_t maths_modexp_l1536; /** Modular exponentiation for numbers less than 2048-bit */ icp_qat_fw_maths_modexp_l2048_output_t maths_modexp_l2048; /** Modular exponentiation for numbers less than 2560-bits */ icp_qat_fw_maths_modexp_l2560_output_t maths_modexp_l2560; /** Modular exponentiation for numbers less than 3072-bits */ icp_qat_fw_maths_modexp_l3072_output_t maths_modexp_l3072; /** Modular exponentiation for numbers less than 3584-bits */ icp_qat_fw_maths_modexp_l3584_output_t maths_modexp_l3584; /** Modular exponentiation for numbers less than 4096-bit */ icp_qat_fw_maths_modexp_l4096_output_t maths_modexp_l4096; /** Modular exponentiation for numbers up to 8192 bits */ icp_qat_fw_maths_modexp_l8192_output_t maths_modexp_l8192; /** Modular multiplicative inverse for numbers less than 128 bits */ icp_qat_fw_maths_modinv_odd_l128_output_t maths_modinv_odd_l128; /** Modular multiplicative inverse for numbers less than 192 bits */ icp_qat_fw_maths_modinv_odd_l192_output_t maths_modinv_odd_l192; /** Modular multiplicative inverse for numbers less than 256 bits */ icp_qat_fw_maths_modinv_odd_l256_output_t maths_modinv_odd_l256; /** Modular multiplicative inverse for numbers less than 384 bits */ icp_qat_fw_maths_modinv_odd_l384_output_t maths_modinv_odd_l384; /** Modular multiplicative inverse for numbers less than 512 bits */ icp_qat_fw_maths_modinv_odd_l512_output_t maths_modinv_odd_l512; /** Modular multiplicative inverse for numbers less than 768 bits */ icp_qat_fw_maths_modinv_odd_l768_output_t maths_modinv_odd_l768; /** Modular multiplicative inverse for numbers less than 1024 bits */ icp_qat_fw_maths_modinv_odd_l1024_output_t maths_modinv_odd_l1024; /** Modular multiplicative inverse for numbers less than 1536 bits */ icp_qat_fw_maths_modinv_odd_l1536_output_t maths_modinv_odd_l1536; /** Modular multiplicative inverse for numbers less than 2048 bits */ icp_qat_fw_maths_modinv_odd_l2048_output_t maths_modinv_odd_l2048; /** Modular multiplicative inverse for numbers less than 3072 bits */ icp_qat_fw_maths_modinv_odd_l3072_output_t maths_modinv_odd_l3072; /** Modular multiplicative inverse for numbers less than 4096 bits */ icp_qat_fw_maths_modinv_odd_l4096_output_t maths_modinv_odd_l4096; /** Modular multiplicative inverse for numbers up to 8192 bits */ icp_qat_fw_maths_modinv_odd_l8192_output_t maths_modinv_odd_l8192; /** Modular multiplicative inverse for numbers less than 128 bits */ icp_qat_fw_maths_modinv_even_l128_output_t maths_modinv_even_l128; /** Modular multiplicative inverse for numbers less than 192 bits */ icp_qat_fw_maths_modinv_even_l192_output_t maths_modinv_even_l192; /** Modular multiplicative inverse for numbers less than 256 bits */ icp_qat_fw_maths_modinv_even_l256_output_t maths_modinv_even_l256; /** Modular multiplicative inverse for numbers less than 384 bits */ icp_qat_fw_maths_modinv_even_l384_output_t maths_modinv_even_l384; /** Modular multiplicative inverse for numbers less than 512 bits */ icp_qat_fw_maths_modinv_even_l512_output_t maths_modinv_even_l512; /** Modular multiplicative inverse for numbers less than 768 bits */ icp_qat_fw_maths_modinv_even_l768_output_t maths_modinv_even_l768; /** Modular multiplicative inverse for numbers less than 1024 bits */ icp_qat_fw_maths_modinv_even_l1024_output_t maths_modinv_even_l1024; /** Modular multiplicative inverse for numbers less than 1536 bits */ icp_qat_fw_maths_modinv_even_l1536_output_t maths_modinv_even_l1536; /** Modular multiplicative inverse for numbers less than 2048 bits */ icp_qat_fw_maths_modinv_even_l2048_output_t maths_modinv_even_l2048; /** Modular multiplicative inverse for numbers less than 3072 bits */ icp_qat_fw_maths_modinv_even_l3072_output_t maths_modinv_even_l3072; /** Modular multiplicative inverse for numbers less than 4096 bits */ icp_qat_fw_maths_modinv_even_l4096_output_t maths_modinv_even_l4096; /** Modular multiplicative inverse for numbers up to 8192 bits */ icp_qat_fw_maths_modinv_even_l8192_output_t maths_modinv_even_l8192; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_1024_160_output_t mmp_dsa_gen_p_1024_160; /** DSA key generation G */ icp_qat_fw_mmp_dsa_gen_g_1024_output_t mmp_dsa_gen_g_1024; /** DSA key generation Y */ icp_qat_fw_mmp_dsa_gen_y_1024_output_t mmp_dsa_gen_y_1024; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_1024_160_output_t mmp_dsa_sign_r_1024_160; /** DSA Sign S */ icp_qat_fw_mmp_dsa_sign_s_160_output_t mmp_dsa_sign_s_160; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_1024_160_output_t mmp_dsa_sign_r_s_1024_160; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_1024_160_output_t mmp_dsa_verify_1024_160; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_2048_224_output_t mmp_dsa_gen_p_2048_224; /** DSA key generation Y */ icp_qat_fw_mmp_dsa_gen_y_2048_output_t mmp_dsa_gen_y_2048; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_2048_224_output_t mmp_dsa_sign_r_2048_224; /** DSA Sign S */ icp_qat_fw_mmp_dsa_sign_s_224_output_t mmp_dsa_sign_s_224; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_2048_224_output_t mmp_dsa_sign_r_s_2048_224; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_2048_224_output_t mmp_dsa_verify_2048_224; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_2048_256_output_t mmp_dsa_gen_p_2048_256; /** DSA key generation G */ icp_qat_fw_mmp_dsa_gen_g_2048_output_t mmp_dsa_gen_g_2048; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_2048_256_output_t mmp_dsa_sign_r_2048_256; /** DSA Sign S */ icp_qat_fw_mmp_dsa_sign_s_256_output_t mmp_dsa_sign_s_256; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_2048_256_output_t mmp_dsa_sign_r_s_2048_256; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_2048_256_output_t mmp_dsa_verify_2048_256; /** DSA parameter generation P */ icp_qat_fw_mmp_dsa_gen_p_3072_256_output_t mmp_dsa_gen_p_3072_256; /** DSA key generation G */ icp_qat_fw_mmp_dsa_gen_g_3072_output_t mmp_dsa_gen_g_3072; /** DSA key generation Y */ icp_qat_fw_mmp_dsa_gen_y_3072_output_t mmp_dsa_gen_y_3072; /** DSA Sign R */ icp_qat_fw_mmp_dsa_sign_r_3072_256_output_t mmp_dsa_sign_r_3072_256; /** DSA Sign R S */ icp_qat_fw_mmp_dsa_sign_r_s_3072_256_output_t mmp_dsa_sign_r_s_3072_256; /** DSA Verify */ icp_qat_fw_mmp_dsa_verify_3072_256_output_t mmp_dsa_verify_3072_256; /** ECDSA Sign RS for curves B/K-163 and B/K-233 */ icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_output_t mmp_ecdsa_sign_rs_gf2_l256; /** ECDSA Sign R for curves B/K-163 and B/K-233 */ icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_output_t mmp_ecdsa_sign_r_gf2_l256; /** ECDSA Sign S for curves with n < 2^256 */ icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_output_t mmp_ecdsa_sign_s_gf2_l256; /** ECDSA Verify for curves B/K-163 and B/K-233 */ icp_qat_fw_mmp_ecdsa_verify_gf2_l256_output_t mmp_ecdsa_verify_gf2_l256; /** ECDSA Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_output_t mmp_ecdsa_sign_rs_gf2_l512; /** ECDSA GF2 Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_output_t mmp_ecdsa_sign_r_gf2_l512; /** ECDSA GF2 Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_output_t mmp_ecdsa_sign_s_gf2_l512; /** ECDSA GF2 Verify */ icp_qat_fw_mmp_ecdsa_verify_gf2_l512_output_t mmp_ecdsa_verify_gf2_l512; /** ECDSA GF2 Sign RS for curves B-571/K-571 */ icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_output_t mmp_ecdsa_sign_rs_gf2_571; /** ECDSA GF2 Sign S for curves with deg(q) < 576 */ icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_output_t mmp_ecdsa_sign_s_gf2_571; /** ECDSA GF2 Sign R for degree 571 */ icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_output_t mmp_ecdsa_sign_r_gf2_571; /** ECDSA GF2 Verify for degree 571 */ icp_qat_fw_mmp_ecdsa_verify_gf2_571_output_t mmp_ecdsa_verify_gf2_571; /** MATHS GF2 Point Multiplication */ icp_qat_fw_maths_point_multiplication_gf2_l256_output_t maths_point_multiplication_gf2_l256; /** MATHS GF2 Point Verification */ icp_qat_fw_maths_point_verify_gf2_l256_output_t maths_point_verify_gf2_l256; /** MATHS GF2 Point Multiplication */ icp_qat_fw_maths_point_multiplication_gf2_l512_output_t maths_point_multiplication_gf2_l512; /** MATHS GF2 Point Verification */ icp_qat_fw_maths_point_verify_gf2_l512_output_t maths_point_verify_gf2_l512; /** ECC GF2 Point Multiplication for curves B-571/K-571 */ icp_qat_fw_maths_point_multiplication_gf2_571_output_t maths_point_multiplication_gf2_571; /** ECC GF2 Point Verification for degree 571 */ icp_qat_fw_maths_point_verify_gf2_571_output_t maths_point_verify_gf2_571; /** ECDSA GFP Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_output_t mmp_ecdsa_sign_r_gfp_l256; /** ECDSA GFP Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_output_t mmp_ecdsa_sign_s_gfp_l256; /** ECDSA GFP Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_output_t mmp_ecdsa_sign_rs_gfp_l256; /** ECDSA GFP Verify */ icp_qat_fw_mmp_ecdsa_verify_gfp_l256_output_t mmp_ecdsa_verify_gfp_l256; /** ECDSA GFP Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_output_t mmp_ecdsa_sign_r_gfp_l512; /** ECDSA GFP Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_output_t mmp_ecdsa_sign_s_gfp_l512; /** ECDSA GFP Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_output_t mmp_ecdsa_sign_rs_gfp_l512; /** ECDSA GFP Verify */ icp_qat_fw_mmp_ecdsa_verify_gfp_l512_output_t mmp_ecdsa_verify_gfp_l512; /** ECDSA GFP Sign R */ icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_output_t mmp_ecdsa_sign_r_gfp_521; /** ECDSA GFP Sign S */ icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_output_t mmp_ecdsa_sign_s_gfp_521; /** ECDSA GFP Sign RS */ icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_output_t mmp_ecdsa_sign_rs_gfp_521; /** ECDSA GFP Verify */ icp_qat_fw_mmp_ecdsa_verify_gfp_521_output_t mmp_ecdsa_verify_gfp_521; /** ECC GFP Point Multiplication */ icp_qat_fw_maths_point_multiplication_gfp_l256_output_t maths_point_multiplication_gfp_l256; /** ECC GFP Partial Point Verification */ icp_qat_fw_maths_point_verify_gfp_l256_output_t maths_point_verify_gfp_l256; /** ECC GFP Point Multiplication */ icp_qat_fw_maths_point_multiplication_gfp_l512_output_t maths_point_multiplication_gfp_l512; /** ECC GFP Partial Point */ icp_qat_fw_maths_point_verify_gfp_l512_output_t maths_point_verify_gfp_l512; /** ECC GFP Point Multiplication */ icp_qat_fw_maths_point_multiplication_gfp_521_output_t maths_point_multiplication_gfp_521; /** ECC GFP Partial Point Verification */ icp_qat_fw_maths_point_verify_gfp_521_output_t maths_point_verify_gfp_521; /** ECC P521 ECDSA Sign RS */ icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_output_t mmp_kpt_ecdsa_sign_rs_p521; /** ECC P384 ECDSA Sign RS */ icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_output_t mmp_kpt_ecdsa_sign_rs_p384; /** ECC KPT P256 ECDSA Sign RS */ icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_output_t mmp_kpt_ecdsa_sign_rs_p256; /** KPT RSA 512 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_512_output_t mmp_kpt_rsa_dp1_512; /** KPT RSA 1024 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_1024_output_t mmp_kpt_rsa_dp1_1024; /** KPT RSA 1536 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_1536_output_t mmp_kpt_rsa_dp1_1536; /** KPT RSA 2048 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_2048_output_t mmp_kpt_rsa_dp1_2048; /** KPT RSA 3072 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_3072_output_t mmp_kpt_rsa_dp1_3072; /** KPT RSA 4096 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_4096_output_t mmp_kpt_rsa_dp1_4096; /** KPT RSA 8192 Decryption */ icp_qat_fw_mmp_kpt_rsa_dp1_8192_output_t mmp_kpt_rsa_dp1_8192; /** RSA 512 decryption second form */ icp_qat_fw_mmp_kpt_rsa_dp2_512_output_t mmp_kpt_rsa_dp2_512; /** RSA 1024 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_1024_output_t mmp_kpt_rsa_dp2_1024; /** KPT RSA 1536 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_1536_output_t mmp_kpt_rsa_dp2_1536; /** RSA 2048 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_2048_output_t mmp_kpt_rsa_dp2_2048; /** */ icp_qat_fw_mmp_kpt_rsa_dp2_3072_output_t mmp_kpt_rsa_dp2_3072; /** RSA 4096 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_4096_output_t mmp_kpt_rsa_dp2_4096; /** RSA 8192 Decryption with CRT */ icp_qat_fw_mmp_kpt_rsa_dp2_8192_output_t mmp_kpt_rsa_dp2_8192; } icp_qat_fw_mmp_output_param_t; #endif /* __ICP_QAT_FW_MMP__ */ /* --- (Automatically generated (build v. 2.7), do not modify manually) --- */ /* --- end of file --- */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp_ids.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp_ids.h index a57de52a9f10..c68d6dbd0157 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp_ids.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_mmp_ids.h @@ -1,1930 +1,1929 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ - +/* Copyright(c) 2007-2025 Intel Corporation */ /* --- (Automatically generated (relocation v. 1.3), do not modify manually) --- */ /** * @file icp_qat_fw_mmp_ids.h * @ingroup icp_qat_fw_mmp * $Revision: 0.1 $ * @brief * This file documents the external interfaces that the QAT FW running * on the QAT Acceleration Engine provides to clients wanting to - * accelerate crypto assymetric applications + * accelerate crypto asymmetric applications */ #ifndef __ICP_QAT_FW_MMP_IDS__ #define __ICP_QAT_FW_MMP_IDS__ #define PKE_ECSM2_GENERATOR_MULTIPLICATION 0x220f16ae /**< Functionality ID for ECC SM2 point multiply [k]G * @li 1 input parameters : @link * icp_qat_fw_mmp_ecsm2_generator_multiplication_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecsm2_generator_multiplication_output_s::xd xd @endlink @link * icp_qat_fw_mmp_ecsm2_generator_multiplication_output_s::yd yd @endlink */ #define PKE_ECSM2_POINT_MULTIPLICATION 0x211716ce /**< Functionality ID for ECC SM2 point multiply [k]P * @li 3 input parameters : @link * icp_qat_fw_mmp_ecsm2_point_multiplication_input_s::k k @endlink @link * icp_qat_fw_mmp_ecsm2_point_multiplication_input_s::x x @endlink @link * icp_qat_fw_mmp_ecsm2_point_multiplication_input_s::y y @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecsm2_point_multiplication_output_s::xd xd @endlink @link * icp_qat_fw_mmp_ecsm2_point_multiplication_output_s::yd yd @endlink */ #define PKE_ECSM2_POINT_VERIFY 0x1b0716a6 /**< Functionality ID for ECC SM2 point verify * @li 2 input parameters : @link icp_qat_fw_mmp_ecsm2_point_verify_input_s::x x * @endlink @link icp_qat_fw_mmp_ecsm2_point_verify_input_s::y y @endlink * @li no output parameters */ #define PKE_ECSM2_SIGN_RS 0x222116fe /**< Functionality ID for ECC SM2 Sign RS * @li 3 input parameters : @link icp_qat_fw_mmp_ecsm2_sign_rs_input_s::k k * @endlink @link icp_qat_fw_mmp_ecsm2_sign_rs_input_s::e e @endlink @link * icp_qat_fw_mmp_ecsm2_sign_rs_input_s::d d @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_ecsm2_sign_rs_output_s::r r * @endlink @link icp_qat_fw_mmp_ecsm2_sign_rs_output_s::s s @endlink */ #define PKE_ECSM2_VERIFY 0x29241743 /**< Functionality ID for ECC SM2 Signature Verify * @li 5 input parameters : @link icp_qat_fw_mmp_ecsm2_verify_input_s::e e * @endlink @link icp_qat_fw_mmp_ecsm2_verify_input_s::r r @endlink @link * icp_qat_fw_mmp_ecsm2_verify_input_s::s s @endlink @link * icp_qat_fw_mmp_ecsm2_verify_input_s::xp xp @endlink @link * icp_qat_fw_mmp_ecsm2_verify_input_s::yp yp @endlink * @li no output parameters */ #define PKE_ECSM2_ENCRYPTION 0x25221720 /**< Functionality ID for ECC SM2 encryption * @li 3 input parameters : @link icp_qat_fw_mmp_ecsm2_encryption_input_s::k k * @endlink @link icp_qat_fw_mmp_ecsm2_encryption_input_s::xp xp @endlink @link * icp_qat_fw_mmp_ecsm2_encryption_input_s::yp yp @endlink * @li 4 output parameters : @link icp_qat_fw_mmp_ecsm2_encryption_output_s::xc * xc @endlink @link icp_qat_fw_mmp_ecsm2_encryption_output_s::yc yc @endlink * @link icp_qat_fw_mmp_ecsm2_encryption_output_s::xpb xpb @endlink @link * icp_qat_fw_mmp_ecsm2_encryption_output_s::ypb ypb @endlink */ #define PKE_ECSM2_DECRYPTION 0x201716e6 /**< Functionality ID for ECC SM2 decryption * @li 3 input parameters : @link icp_qat_fw_mmp_ecsm2_decryption_input_s::d d * @endlink @link icp_qat_fw_mmp_ecsm2_decryption_input_s::xpb xpb @endlink * @link icp_qat_fw_mmp_ecsm2_decryption_input_s::ypb ypb @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_ecsm2_decryption_output_s::xd * xd @endlink @link icp_qat_fw_mmp_ecsm2_decryption_output_s::yd yd @endlink */ #define PKE_ECSM2_KEYEX_P1 0x220f16be /**< Functionality ID for ECC SM2 key exchange phase1 * @li 1 input parameters : @link icp_qat_fw_mmp_ecsm2_keyex_p1_input_s::k k * @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_ecsm2_keyex_p1_output_s::xd xd * @endlink @link icp_qat_fw_mmp_ecsm2_keyex_p1_output_s::yd yd @endlink */ #define PKE_ECSM2_KEYEX_P2 0x22361768 /**< Functionality ID for ECC SM2 key exchange phase2 * @li 7 input parameters : @link icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::r r * @endlink @link icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::d d @endlink @link * icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::x1 x1 @endlink @link * icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::x2 x2 @endlink @link * icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::y2 y2 @endlink @link * icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::xp xp @endlink @link * icp_qat_fw_mmp_ecsm2_keyex_p2_input_s::yp yp @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_ecsm2_keyex_p2_output_s::xus * xus @endlink @link icp_qat_fw_mmp_ecsm2_keyex_p2_output_s::yus yus @endlink */ #define POINT_MULTIPLICATION_C25519 0x0a0634c6 /**< Functionality ID for ECC curve25519 Variable Point Multiplication [k]P(x), * as specified in RFC7748 * @li 2 input parameters : @link * icp_qat_fw_point_multiplication_c25519_input_s::xp xp @endlink @link * icp_qat_fw_point_multiplication_c25519_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_point_multiplication_c25519_output_s::xr xr @endlink */ #define GENERATOR_MULTIPLICATION_C25519 0x0a0634d6 /**< Functionality ID for ECC curve25519 Generator Point Multiplication [k]G(x), * as specified in RFC7748 * @li 1 input parameters : @link * icp_qat_fw_generator_multiplication_c25519_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_generator_multiplication_c25519_output_s::xr xr @endlink */ #define POINT_MULTIPLICATION_ED25519 0x100b34e6 /**< Functionality ID for ECC edwards25519 Variable Point Multiplication [k]P, * as specified in RFC8032 * @li 3 input parameters : @link * icp_qat_fw_point_multiplication_ed25519_input_s::xp xp @endlink @link * icp_qat_fw_point_multiplication_ed25519_input_s::yp yp @endlink @link * icp_qat_fw_point_multiplication_ed25519_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_point_multiplication_ed25519_output_s::xr xr @endlink @link * icp_qat_fw_point_multiplication_ed25519_output_s::yr yr @endlink */ #define GENERATOR_MULTIPLICATION_ED25519 0x100a34f6 /**< Functionality ID for ECC edwards25519 Generator Point Multiplication [k]G, * as specified in RFC8032 * @li 1 input parameters : @link * icp_qat_fw_generator_multiplication_ed25519_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_generator_multiplication_ed25519_output_s::xr xr @endlink @link * icp_qat_fw_generator_multiplication_ed25519_output_s::yr yr @endlink */ #define POINT_MULTIPLICATION_C448 0x0c063506 /**< Functionality ID for ECC curve448 Variable Point Multiplication [k]P(x), as * specified in RFC7748 * @li 2 input parameters : @link * icp_qat_fw_point_multiplication_c448_input_s::xp xp @endlink @link * icp_qat_fw_point_multiplication_c448_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_point_multiplication_c448_output_s::xr xr @endlink */ #define GENERATOR_MULTIPLICATION_C448 0x0c063516 /**< Functionality ID for ECC curve448 Generator Point Multiplication [k]G(x), * as specified in RFC7748 * @li 1 input parameters : @link * icp_qat_fw_generator_multiplication_c448_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_generator_multiplication_c448_output_s::xr xr @endlink */ #define POINT_MULTIPLICATION_ED448 0x1a0b3526 /**< Functionality ID for ECC edwards448 Variable Point Multiplication [k]P, as * specified in RFC8032 * @li 3 input parameters : @link * icp_qat_fw_point_multiplication_ed448_input_s::xp xp @endlink @link * icp_qat_fw_point_multiplication_ed448_input_s::yp yp @endlink @link * icp_qat_fw_point_multiplication_ed448_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_point_multiplication_ed448_output_s::xr xr @endlink @link * icp_qat_fw_point_multiplication_ed448_output_s::yr yr @endlink */ #define GENERATOR_MULTIPLICATION_ED448 0x1a0a3536 /**< Functionality ID for ECC edwards448 Generator Point Multiplication [k]P, as * specified in RFC8032 * @li 1 input parameters : @link * icp_qat_fw_generator_multiplication_ed448_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_generator_multiplication_ed448_output_s::xr xr @endlink @link * icp_qat_fw_generator_multiplication_ed448_output_s::yr yr @endlink */ #define PKE_INIT 0x0806169f /**< Functionality ID for Initialisation sequence * @li 1 input parameters : @link icp_qat_fw_mmp_init_input_s::z z @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_init_output_s::zz zz @endlink */ #define PKE_DH_G2_768 0x1c0b1a10 /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 768-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_768_input_s::e e @endlink * @link icp_qat_fw_mmp_dh_g2_768_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_768_output_s::r r * @endlink */ #define PKE_DH_768 0x210c1a1b /**< Functionality ID for Diffie-Hellman Modular exponentiation for 768-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_768_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_768_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_768_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_768_output_s::r r @endlink */ #define PKE_DH_G2_1024 0x220b1a27 /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 1024-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_1024_input_s::e e * @endlink @link icp_qat_fw_mmp_dh_g2_1024_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_1024_output_s::r r * @endlink */ #define PKE_DH_1024 0x290c1a32 /**< Functionality ID for Diffie-Hellman Modular exponentiation for 1024-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_1024_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_1024_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_1024_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_1024_output_s::r r @endlink */ #define PKE_DH_G2_1536 0x2e0b1a3e /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 1536-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_1536_input_s::e e * @endlink @link icp_qat_fw_mmp_dh_g2_1536_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_1536_output_s::r r * @endlink */ #define PKE_DH_1536 0x390c1a49 /**< Functionality ID for Diffie-Hellman Modular exponentiation for 1536-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_1536_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_1536_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_1536_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_1536_output_s::r r @endlink */ #define PKE_DH_G2_2048 0x3e0b1a55 /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 2048-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_2048_input_s::e e * @endlink @link icp_qat_fw_mmp_dh_g2_2048_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_2048_output_s::r r * @endlink */ #define PKE_DH_2048 0x4d0c1a60 /**< Functionality ID for Diffie-Hellman Modular exponentiation for 2048-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_2048_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_2048_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_2048_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_2048_output_s::r r @endlink */ #define PKE_DH_G2_3072 0x3a0b1a6c /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 3072-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_3072_input_s::e e * @endlink @link icp_qat_fw_mmp_dh_g2_3072_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_3072_output_s::r r * @endlink */ #define PKE_DH_3072 0x510c1a77 /**< Functionality ID for Diffie-Hellman Modular exponentiation for 3072-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_3072_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_3072_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_3072_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_3072_output_s::r r @endlink */ #define PKE_DH_G2_4096 0x4a0b1a83 /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 4096-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_4096_input_s::e e * @endlink @link icp_qat_fw_mmp_dh_g2_4096_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_4096_output_s::r r * @endlink */ #define PKE_DH_4096 0x690c1a8e /**< Functionality ID for Diffie-Hellman Modular exponentiation for 4096-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_4096_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_4096_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_4096_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_4096_output_s::r r @endlink */ #define PKE_DH_G2_8192 0x8d0b3626 /**< Functionality ID for Diffie-Hellman Modular exponentiation base 2 for * 8192-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_dh_g2_8192_input_s::e e * @endlink @link icp_qat_fw_mmp_dh_g2_8192_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_g2_8192_output_s::r r * @endlink */ #define PKE_DH_8192 0xcd0d3636 /**< Functionality ID for Diffie-Hellman Modular exponentiation for 8192-bit * numbers * @li 3 input parameters : @link icp_qat_fw_mmp_dh_8192_input_s::g g @endlink * @link icp_qat_fw_mmp_dh_8192_input_s::e e @endlink @link * icp_qat_fw_mmp_dh_8192_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dh_8192_output_s::r r @endlink */ #define PKE_RSA_KP1_512 0x191d1a9a /**< Functionality ID for RSA 512 key generation first form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp1_512_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp1_512_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp1_512_input_s::e e @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_rsa_kp1_512_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp1_512_output_s::d d @endlink */ #define PKE_RSA_KP2_512 0x19401acc /**< Functionality ID for RSA 512 key generation second form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp2_512_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp2_512_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp2_512_input_s::e e @endlink * @li 5 output parameters : @link icp_qat_fw_mmp_rsa_kp2_512_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp2_512_output_s::d d @endlink @link * icp_qat_fw_mmp_rsa_kp2_512_output_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_kp2_512_output_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_kp2_512_output_s::qinv qinv @endlink */ #define PKE_RSA_EP_512 0x1c161b21 /**< Functionality ID for RSA 512 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_512_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_512_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_512_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_512_output_s::c c * @endlink */ #define PKE_RSA_DP1_512 0x1c161b3c /**< Functionality ID for RSA 512 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_512_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_512_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_512_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_512_output_s::m m * @endlink */ #define PKE_RSA_DP2_512 0x1c131b57 /**< Functionality ID for RSA 1024 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_512_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_512_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_512_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_512_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_512_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_512_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_512_output_s::m m * @endlink */ #define PKE_RSA_KP1_1024 0x36181b71 /**< Functionality ID for RSA 1024 key generation first form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp1_1024_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp1_1024_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp1_1024_input_s::e e @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_rsa_kp1_1024_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp1_1024_output_s::d d @endlink */ #define PKE_RSA_KP2_1024 0x40451b9e /**< Functionality ID for RSA 1024 key generation second form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp2_1024_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp2_1024_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp2_1024_input_s::e e @endlink * @li 5 output parameters : @link icp_qat_fw_mmp_rsa_kp2_1024_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp2_1024_output_s::d d @endlink @link * icp_qat_fw_mmp_rsa_kp2_1024_output_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_kp2_1024_output_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_kp2_1024_output_s::qinv qinv @endlink */ #define PKE_RSA_EP_1024 0x35111bf7 /**< Functionality ID for RSA 1024 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_1024_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_1024_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_1024_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_1024_output_s::c c * @endlink */ #define PKE_RSA_DP1_1024 0x35111c12 /**< Functionality ID for RSA 1024 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_1024_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_1024_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_1024_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_1024_output_s::m m * @endlink */ #define PKE_RSA_DP2_1024 0x26131c2d /**< Functionality ID for RSA 1024 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_1024_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_1024_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_1024_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_1024_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_1024_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_1024_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_1024_output_s::m m * @endlink */ #define PKE_RSA_KP1_1536 0x531d1c46 /**< Functionality ID for RSA 1536 key generation first form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp1_1536_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp1_1536_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp1_1536_input_s::e e @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_rsa_kp1_1536_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp1_1536_output_s::d d @endlink */ #define PKE_RSA_KP2_1536 0x32391c78 /**< Functionality ID for RSA 1536 key generation second form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp2_1536_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp2_1536_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp2_1536_input_s::e e @endlink * @li 5 output parameters : @link icp_qat_fw_mmp_rsa_kp2_1536_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp2_1536_output_s::d d @endlink @link * icp_qat_fw_mmp_rsa_kp2_1536_output_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_kp2_1536_output_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_kp2_1536_output_s::qinv qinv @endlink */ #define PKE_RSA_EP_1536 0x4d111cdc /**< Functionality ID for RSA 1536 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_1536_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_1536_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_1536_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_1536_output_s::c c * @endlink */ #define PKE_RSA_DP1_1536 0x4d111cf7 /**< Functionality ID for RSA 1536 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_1536_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_1536_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_1536_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_1536_output_s::m m * @endlink */ #define PKE_RSA_DP2_1536 0x45111d12 /**< Functionality ID for RSA 1536 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_1536_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_1536_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_1536_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_1536_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_1536_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_1536_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_1536_output_s::m m * @endlink */ #define PKE_RSA_KP1_2048 0x72181d2e /**< Functionality ID for RSA 2048 key generation first form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp1_2048_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp1_2048_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp1_2048_input_s::e e @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_rsa_kp1_2048_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp1_2048_output_s::d d @endlink */ #define PKE_RSA_KP2_2048 0x42341d5b /**< Functionality ID for RSA 2048 key generation second form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp2_2048_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp2_2048_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp2_2048_input_s::e e @endlink * @li 5 output parameters : @link icp_qat_fw_mmp_rsa_kp2_2048_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp2_2048_output_s::d d @endlink @link * icp_qat_fw_mmp_rsa_kp2_2048_output_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_kp2_2048_output_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_kp2_2048_output_s::qinv qinv @endlink */ #define PKE_RSA_EP_2048 0x6e111dba /**< Functionality ID for RSA 2048 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_2048_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_2048_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_2048_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_2048_output_s::c c * @endlink */ #define PKE_RSA_DP1_2048 0x6e111dda /**< Functionality ID for RSA 2048 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_2048_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_2048_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_2048_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_2048_output_s::m m * @endlink */ #define PKE_RSA_DP2_2048 0x59121dfa /**< Functionality ID for RSA 2048 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_2048_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_2048_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_2048_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_2048_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_2048_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_2048_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_2048_output_s::m m * @endlink */ #define PKE_RSA_KP1_3072 0x60191e16 /**< Functionality ID for RSA 3072 key generation first form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp1_3072_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp1_3072_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp1_3072_input_s::e e @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_rsa_kp1_3072_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp1_3072_output_s::d d @endlink */ #define PKE_RSA_KP2_3072 0x68331e45 /**< Functionality ID for RSA 3072 key generation second form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp2_3072_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp2_3072_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp2_3072_input_s::e e @endlink * @li 5 output parameters : @link icp_qat_fw_mmp_rsa_kp2_3072_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp2_3072_output_s::d d @endlink @link * icp_qat_fw_mmp_rsa_kp2_3072_output_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_kp2_3072_output_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_kp2_3072_output_s::qinv qinv @endlink */ #define PKE_RSA_EP_3072 0x7d111ea3 /**< Functionality ID for RSA 3072 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_3072_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_3072_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_3072_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_3072_output_s::c c * @endlink */ #define PKE_RSA_DP1_3072 0x7d111ebe /**< Functionality ID for RSA 3072 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_3072_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_3072_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_3072_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_3072_output_s::m m * @endlink */ #define PKE_RSA_DP2_3072 0x81121ed9 /**< Functionality ID for RSA 3072 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_3072_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_3072_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_3072_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_3072_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_3072_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_3072_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_3072_output_s::m m * @endlink */ #define PKE_RSA_KP1_4096 0x7d1f1ef6 /**< Functionality ID for RSA 4096 key generation first form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp1_4096_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp1_4096_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp1_4096_input_s::e e @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_rsa_kp1_4096_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp1_4096_output_s::d d @endlink */ #define PKE_RSA_KP2_4096 0x91251f27 /**< Functionality ID for RSA 4096 key generation second form * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_kp2_4096_input_s::p p * @endlink @link icp_qat_fw_mmp_rsa_kp2_4096_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_kp2_4096_input_s::e e @endlink * @li 5 output parameters : @link icp_qat_fw_mmp_rsa_kp2_4096_output_s::n n * @endlink @link icp_qat_fw_mmp_rsa_kp2_4096_output_s::d d @endlink @link * icp_qat_fw_mmp_rsa_kp2_4096_output_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_kp2_4096_output_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_kp2_4096_output_s::qinv qinv @endlink */ #define PKE_RSA_EP_4096 0xa5101f7e /**< Functionality ID for RSA 4096 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_4096_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_4096_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_4096_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_4096_output_s::c c * @endlink */ #define PKE_RSA_DP1_4096 0xa5101f98 /**< Functionality ID for RSA 4096 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_4096_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_4096_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_4096_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_4096_output_s::m m * @endlink */ #define PKE_RSA_DP2_4096 0xb1111fb2 /**< Functionality ID for RSA 4096 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_4096_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_4096_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_4096_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_4096_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_4096_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_4096_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_4096_output_s::m m * @endlink */ #define PKE_RSA_EP_8192 0xc31335c6 /**< Functionality ID for RSA 8192 Encryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_ep_8192_input_s::m m * @endlink @link icp_qat_fw_mmp_rsa_ep_8192_input_s::e e @endlink @link * icp_qat_fw_mmp_rsa_ep_8192_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_ep_8192_output_s::c c * @endlink */ #define PKE_RSA_DP1_8192 0xc31335e6 /**< Functionality ID for RSA 8192 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_rsa_dp1_8192_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp1_8192_input_s::d d @endlink @link * icp_qat_fw_mmp_rsa_dp1_8192_input_s::n n @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp1_8192_output_s::m m * @endlink */ #define PKE_RSA_DP2_8192 0xc9133606 /**< Functionality ID for RSA 8192 Decryption with CRT * @li 6 input parameters : @link icp_qat_fw_mmp_rsa_dp2_8192_input_s::c c * @endlink @link icp_qat_fw_mmp_rsa_dp2_8192_input_s::p p @endlink @link * icp_qat_fw_mmp_rsa_dp2_8192_input_s::q q @endlink @link * icp_qat_fw_mmp_rsa_dp2_8192_input_s::dp dp @endlink @link * icp_qat_fw_mmp_rsa_dp2_8192_input_s::dq dq @endlink @link * icp_qat_fw_mmp_rsa_dp2_8192_input_s::qinv qinv @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_rsa_dp2_8192_output_s::m m * @endlink */ #define PKE_GCD_PT_192 0x19201fcd /**< Functionality ID for GCD primality test for 192-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_192_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_256 0x19201ff7 /**< Functionality ID for GCD primality test for 256-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_256_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_384 0x19202021 /**< Functionality ID for GCD primality test for 384-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_384_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_512 0x1b1b204b /**< Functionality ID for GCD primality test for 512-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_512_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_768 0x170c2070 /**< Functionality ID for GCD primality test for 768-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_768_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_1024 0x130f2085 /**< Functionality ID for GCD primality test for 1024-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_1024_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_1536 0x1d0c2094 /**< Functionality ID for GCD primality test for 1536-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_1536_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_2048 0x210c20a5 /**< Functionality ID for GCD primality test for 2048-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_2048_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_3072 0x290c20b6 /**< Functionality ID for GCD primality test for 3072-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_3072_input_s::m m * @endlink * @li no output parameters */ #define PKE_GCD_PT_4096 0x310c20c7 /**< Functionality ID for GCD primality test for 4096-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_gcd_pt_4096_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_160 0x0e1120d8 /**< Functionality ID for Fermat primality test for 160-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_160_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_512 0x121120ee /**< Functionality ID for Fermat primality test for 512-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_512_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_L512 0x19162104 /**< Functionality ID for Fermat primality test for <e; 512-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_l512_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_768 0x19112124 /**< Functionality ID for Fermat primality test for 768-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_768_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_1024 0x1f11213a /**< Functionality ID for Fermat primality test for 1024-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_1024_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_1536 0x2b112150 /**< Functionality ID for Fermat primality test for 1536-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_1536_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_2048 0x3b112166 /**< Functionality ID for Fermat primality test for 2048-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_2048_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_3072 0x3a11217c /**< Functionality ID for Fermat primality test for 3072-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_3072_input_s::m m * @endlink * @li no output parameters */ #define PKE_FERMAT_PT_4096 0x4a112192 /**< Functionality ID for Fermat primality test for 4096-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_fermat_pt_4096_input_s::m m * @endlink * @li no output parameters */ #define PKE_MR_PT_160 0x0e1221a8 /**< Functionality ID for Miller-Rabin primality test for 160-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_160_input_s::x x @endlink * @link icp_qat_fw_mmp_mr_pt_160_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_512 0x111221bf /**< Functionality ID for Miller-Rabin primality test for 512-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_512_input_s::x x @endlink * @link icp_qat_fw_mmp_mr_pt_512_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_768 0x1d0d21d6 /**< Functionality ID for Miller-Rabin primality test for 768-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_768_input_s::x x @endlink * @link icp_qat_fw_mmp_mr_pt_768_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_1024 0x250d21ed /**< Functionality ID for Miller-Rabin primality test for 1024-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_1024_input_s::x x * @endlink @link icp_qat_fw_mmp_mr_pt_1024_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_1536 0x350d2204 /**< Functionality ID for Miller-Rabin primality test for 1536-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_1536_input_s::x x * @endlink @link icp_qat_fw_mmp_mr_pt_1536_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_2048 0x490d221b /**< Functionality ID for Miller-Rabin primality test for 2048-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_2048_input_s::x x * @endlink @link icp_qat_fw_mmp_mr_pt_2048_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_3072 0x4d0d2232 /**< Functionality ID for Miller-Rabin primality test for 3072-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_3072_input_s::x x * @endlink @link icp_qat_fw_mmp_mr_pt_3072_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_4096 0x650d2249 /**< Functionality ID for Miller-Rabin primality test for 4096-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_4096_input_s::x x * @endlink @link icp_qat_fw_mmp_mr_pt_4096_input_s::m m @endlink * @li no output parameters */ #define PKE_MR_PT_L512 0x18182260 /**< Functionality ID for Miller-Rabin primality test for 512-bit numbers * @li 2 input parameters : @link icp_qat_fw_mmp_mr_pt_l512_input_s::x x * @endlink @link icp_qat_fw_mmp_mr_pt_l512_input_s::m m @endlink * @li no output parameters */ #define PKE_LUCAS_PT_160 0x0e0c227e /**< Functionality ID for Lucas primality test for 160-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_160_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_512 0x110c228f /**< Functionality ID for Lucas primality test for 512-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_512_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_768 0x130c22a0 /**< Functionality ID for Lucas primality test for 768-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_768_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_1024 0x150c22b1 /**< Functionality ID for Lucas primality test for 1024-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_1024_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_1536 0x190c22c2 /**< Functionality ID for Lucas primality test for 1536-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_1536_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_2048 0x1d0c22d3 /**< Functionality ID for Lucas primality test for 2048-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_2048_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_3072 0x250c22e4 /**< Functionality ID for Lucas primality test for 3072-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_3072_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_4096 0x661522f5 /**< Functionality ID for Lucas primality test for 4096-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_4096_input_s::m m * @endlink * @li no output parameters */ #define PKE_LUCAS_PT_L512 0x1617230a /**< Functionality ID for Lucas primality test for L512-bit numbers * @li 1 input parameters : @link icp_qat_fw_mmp_lucas_pt_l512_input_s::m m * @endlink * @li no output parameters */ #define MATHS_MODEXP_L512 0x150c2327 /**< Functionality ID for Modular exponentiation for numbers less than 512-bits * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l512_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l512_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l512_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l512_output_s::r r * @endlink */ #define MATHS_MODEXP_L1024 0x2d0c233e /**< Functionality ID for Modular exponentiation for numbers less than 1024-bit * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l1024_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l1024_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l1024_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l1024_output_s::r r * @endlink */ #define MATHS_MODEXP_L1536 0x410c2355 /**< Functionality ID for Modular exponentiation for numbers less than 1536-bits * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l1536_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l1536_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l1536_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l1536_output_s::r r * @endlink */ #define MATHS_MODEXP_L2048 0x5e12236c /**< Functionality ID for Modular exponentiation for numbers less than 2048-bit * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l2048_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l2048_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l2048_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l2048_output_s::r r * @endlink */ #define MATHS_MODEXP_L2560 0x60162388 /**< Functionality ID for Modular exponentiation for numbers less than 2560-bits * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l2560_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l2560_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l2560_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l2560_output_s::r r * @endlink */ #define MATHS_MODEXP_L3072 0x650c23a9 /**< Functionality ID for Modular exponentiation for numbers less than 3072-bits * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l3072_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l3072_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l3072_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l3072_output_s::r r * @endlink */ #define MATHS_MODEXP_L3584 0x801623c0 /**< Functionality ID for Modular exponentiation for numbers less than 3584-bits * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l3584_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l3584_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l3584_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l3584_output_s::r r * @endlink */ #define MATHS_MODEXP_L4096 0x850c23e1 /**< Functionality ID for Modular exponentiation for numbers less than 4096-bit * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l4096_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l4096_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l4096_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l4096_output_s::r r * @endlink */ #define MATHS_MODEXP_L8192 0xc50c3646 /**< Functionality ID for Modular exponentiation for numbers up to 8192 bits * @li 3 input parameters : @link icp_qat_fw_maths_modexp_l8192_input_s::g g * @endlink @link icp_qat_fw_maths_modexp_l8192_input_s::e e @endlink @link * icp_qat_fw_maths_modexp_l8192_input_s::m m @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modexp_l8192_output_s::r r * @endlink */ #define MATHS_MODINV_ODD_L128 0x090623f8 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 128 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l128_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l128_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l128_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L192 0x0a0623fe /**< Functionality ID for Modular multiplicative inverse for numbers less than * 192 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l192_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l192_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l192_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L256 0x0a062404 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 256 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l256_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l256_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l256_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L384 0x0b06240a /**< Functionality ID for Modular multiplicative inverse for numbers less than * 384 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l384_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l384_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l384_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L512 0x0c062410 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 512 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l512_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l512_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l512_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L768 0x0e062416 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 768 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l768_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l768_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l768_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L1024 0x1006241c /**< Functionality ID for Modular multiplicative inverse for numbers less than * 1024 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l1024_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l1024_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l1024_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L1536 0x18062422 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 1536 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l1536_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l1536_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l1536_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L2048 0x20062428 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 2048 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l2048_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l2048_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l2048_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L3072 0x3006242e /**< Functionality ID for Modular multiplicative inverse for numbers less than * 3072 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l3072_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l3072_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l3072_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L4096 0x40062434 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 4096 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l4096_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l4096_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l4096_output_s::c * c @endlink */ #define MATHS_MODINV_ODD_L8192 0x88073656 /**< Functionality ID for Modular multiplicative inverse for numbers up to 8192 * bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_odd_l8192_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_odd_l8192_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_odd_l8192_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L128 0x0906243a /**< Functionality ID for Modular multiplicative inverse for numbers less than * 128 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l128_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_even_l128_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_even_l128_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L192 0x0a062440 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 192 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l192_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_even_l192_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_even_l192_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L256 0x0a062446 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 256 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l256_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_even_l256_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_even_l256_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L384 0x0e0b244c /**< Functionality ID for Modular multiplicative inverse for numbers less than * 384 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l384_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_even_l384_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_even_l384_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L512 0x110b2457 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 512 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l512_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_even_l512_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_even_l512_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L768 0x170b2462 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 768 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l768_input_s::a a * @endlink @link icp_qat_fw_maths_modinv_even_l768_input_s::b b @endlink * @li 1 output parameters : @link icp_qat_fw_maths_modinv_even_l768_output_s::c * c @endlink */ #define MATHS_MODINV_EVEN_L1024 0x1d0b246d /**< Functionality ID for Modular multiplicative inverse for numbers less than * 1024 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l1024_input_s::a * a @endlink @link icp_qat_fw_maths_modinv_even_l1024_input_s::b b @endlink * @li 1 output parameters : @link * icp_qat_fw_maths_modinv_even_l1024_output_s::c c @endlink */ #define MATHS_MODINV_EVEN_L1536 0x290b2478 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 1536 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l1536_input_s::a * a @endlink @link icp_qat_fw_maths_modinv_even_l1536_input_s::b b @endlink * @li 1 output parameters : @link * icp_qat_fw_maths_modinv_even_l1536_output_s::c c @endlink */ #define MATHS_MODINV_EVEN_L2048 0x350b2483 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 2048 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l2048_input_s::a * a @endlink @link icp_qat_fw_maths_modinv_even_l2048_input_s::b b @endlink * @li 1 output parameters : @link * icp_qat_fw_maths_modinv_even_l2048_output_s::c c @endlink */ #define MATHS_MODINV_EVEN_L3072 0x4d0b248e /**< Functionality ID for Modular multiplicative inverse for numbers less than * 3072 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l3072_input_s::a * a @endlink @link icp_qat_fw_maths_modinv_even_l3072_input_s::b b @endlink * @li 1 output parameters : @link * icp_qat_fw_maths_modinv_even_l3072_output_s::c c @endlink */ #define MATHS_MODINV_EVEN_L4096 0x650b2499 /**< Functionality ID for Modular multiplicative inverse for numbers less than * 4096 bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l4096_input_s::a * a @endlink @link icp_qat_fw_maths_modinv_even_l4096_input_s::b b @endlink * @li 1 output parameters : @link * icp_qat_fw_maths_modinv_even_l4096_output_s::c c @endlink */ #define MATHS_MODINV_EVEN_L8192 0xc80d3666 /**< Functionality ID for Modular multiplicative inverse for numbers up to 8192 * bits * @li 2 input parameters : @link icp_qat_fw_maths_modinv_even_l8192_input_s::a * a @endlink @link icp_qat_fw_maths_modinv_even_l8192_input_s::b b @endlink * @li 1 output parameters : @link * icp_qat_fw_maths_modinv_even_l8192_output_s::c c @endlink */ #define PKE_DSA_GEN_P_1024_160 0x381824a4 /**< Functionality ID for DSA parameter generation P * @li 2 input parameters : @link icp_qat_fw_mmp_dsa_gen_p_1024_160_input_s::x x * @endlink @link icp_qat_fw_mmp_dsa_gen_p_1024_160_input_s::q q @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_p_1024_160_output_s::p * p @endlink */ #define PKE_DSA_GEN_G_1024 0x261424d4 /**< Functionality ID for DSA key generation G * @li 3 input parameters : @link icp_qat_fw_mmp_dsa_gen_g_1024_input_s::p p * @endlink @link icp_qat_fw_mmp_dsa_gen_g_1024_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_gen_g_1024_input_s::h h @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_g_1024_output_s::g g * @endlink */ #define PKE_DSA_GEN_Y_1024 0x291224ed /**< Functionality ID for DSA key generation Y * @li 3 input parameters : @link icp_qat_fw_mmp_dsa_gen_y_1024_input_s::p p * @endlink @link icp_qat_fw_mmp_dsa_gen_y_1024_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_gen_y_1024_input_s::x x @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_y_1024_output_s::y y * @endlink */ #define PKE_DSA_SIGN_R_1024_160 0x2c1c2504 /**< Functionality ID for DSA Sign R * @li 4 input parameters : @link icp_qat_fw_mmp_dsa_sign_r_1024_160_input_s::k * k @endlink @link icp_qat_fw_mmp_dsa_sign_r_1024_160_input_s::p p @endlink * @link icp_qat_fw_mmp_dsa_sign_r_1024_160_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_1024_160_input_s::g g @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_1024_160_output_s::r r @endlink */ #define PKE_DSA_SIGN_S_160 0x12142526 /**< Functionality ID for DSA Sign S * @li 5 input parameters : @link icp_qat_fw_mmp_dsa_sign_s_160_input_s::m m * @endlink @link icp_qat_fw_mmp_dsa_sign_s_160_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_s_160_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_s_160_input_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_s_160_input_s::x x @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_sign_s_160_output_s::s s * @endlink */ #define PKE_DSA_SIGN_R_S_1024_160 0x301e2540 /**< Functionality ID for DSA Sign R S * @li 6 input parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_input_s::x x @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_output_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_1024_160_output_s::s s @endlink */ #define PKE_DSA_VERIFY_1024_160 0x323a2570 /**< Functionality ID for DSA Verify * @li 7 input parameters : @link icp_qat_fw_mmp_dsa_verify_1024_160_input_s::r * r @endlink @link icp_qat_fw_mmp_dsa_verify_1024_160_input_s::s s @endlink * @link icp_qat_fw_mmp_dsa_verify_1024_160_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_verify_1024_160_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_verify_1024_160_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_verify_1024_160_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_verify_1024_160_input_s::y y @endlink * @li no output parameters */ #define PKE_DSA_GEN_P_2048_224 0x341d25be /**< Functionality ID for DSA parameter generation P * @li 2 input parameters : @link icp_qat_fw_mmp_dsa_gen_p_2048_224_input_s::x x * @endlink @link icp_qat_fw_mmp_dsa_gen_p_2048_224_input_s::q q @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_p_2048_224_output_s::p * p @endlink */ #define PKE_DSA_GEN_Y_2048 0x4d1225ea /**< Functionality ID for DSA key generation Y * @li 3 input parameters : @link icp_qat_fw_mmp_dsa_gen_y_2048_input_s::p p * @endlink @link icp_qat_fw_mmp_dsa_gen_y_2048_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_gen_y_2048_input_s::x x @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_y_2048_output_s::y y * @endlink */ #define PKE_DSA_SIGN_R_2048_224 0x511c2601 /**< Functionality ID for DSA Sign R * @li 4 input parameters : @link icp_qat_fw_mmp_dsa_sign_r_2048_224_input_s::k * k @endlink @link icp_qat_fw_mmp_dsa_sign_r_2048_224_input_s::p p @endlink * @link icp_qat_fw_mmp_dsa_sign_r_2048_224_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_2048_224_input_s::g g @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_2048_224_output_s::r r @endlink */ #define PKE_DSA_SIGN_S_224 0x15142623 /**< Functionality ID for DSA Sign S * @li 5 input parameters : @link icp_qat_fw_mmp_dsa_sign_s_224_input_s::m m * @endlink @link icp_qat_fw_mmp_dsa_sign_s_224_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_s_224_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_s_224_input_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_s_224_input_s::x x @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_sign_s_224_output_s::s s * @endlink */ #define PKE_DSA_SIGN_R_S_2048_224 0x571e263d /**< Functionality ID for DSA Sign R S * @li 6 input parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_input_s::x x @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_output_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_224_output_s::s s @endlink */ #define PKE_DSA_VERIFY_2048_224 0x6930266d /**< Functionality ID for DSA Verify * @li 7 input parameters : @link icp_qat_fw_mmp_dsa_verify_2048_224_input_s::r * r @endlink @link icp_qat_fw_mmp_dsa_verify_2048_224_input_s::s s @endlink * @link icp_qat_fw_mmp_dsa_verify_2048_224_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_224_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_224_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_224_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_224_input_s::y y @endlink * @li no output parameters */ #define PKE_DSA_GEN_P_2048_256 0x431126b7 /**< Functionality ID for DSA parameter generation P * @li 2 input parameters : @link icp_qat_fw_mmp_dsa_gen_p_2048_256_input_s::x x * @endlink @link icp_qat_fw_mmp_dsa_gen_p_2048_256_input_s::q q @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_p_2048_256_output_s::p * p @endlink */ #define PKE_DSA_GEN_G_2048 0x4b1426ed /**< Functionality ID for DSA key generation G * @li 3 input parameters : @link icp_qat_fw_mmp_dsa_gen_g_2048_input_s::p p * @endlink @link icp_qat_fw_mmp_dsa_gen_g_2048_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_gen_g_2048_input_s::h h @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_g_2048_output_s::g g * @endlink */ #define PKE_DSA_SIGN_R_2048_256 0x5b182706 /**< Functionality ID for DSA Sign R * @li 4 input parameters : @link icp_qat_fw_mmp_dsa_sign_r_2048_256_input_s::k * k @endlink @link icp_qat_fw_mmp_dsa_sign_r_2048_256_input_s::p p @endlink * @link icp_qat_fw_mmp_dsa_sign_r_2048_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_2048_256_input_s::g g @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_2048_256_output_s::r r @endlink */ #define PKE_DSA_SIGN_S_256 0x15142733 /**< Functionality ID for DSA Sign S * @li 5 input parameters : @link icp_qat_fw_mmp_dsa_sign_s_256_input_s::m m * @endlink @link icp_qat_fw_mmp_dsa_sign_s_256_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_s_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_s_256_input_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_s_256_input_s::x x @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_sign_s_256_output_s::s s * @endlink */ #define PKE_DSA_SIGN_R_S_2048_256 0x5a2a274d /**< Functionality ID for DSA Sign R S * @li 6 input parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_input_s::x x @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_output_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_2048_256_output_s::s s @endlink */ #define PKE_DSA_VERIFY_2048_256 0x723a2789 /**< Functionality ID for DSA Verify * @li 7 input parameters : @link icp_qat_fw_mmp_dsa_verify_2048_256_input_s::r * r @endlink @link icp_qat_fw_mmp_dsa_verify_2048_256_input_s::s s @endlink * @link icp_qat_fw_mmp_dsa_verify_2048_256_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_256_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_256_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_verify_2048_256_input_s::y y @endlink * @li no output parameters */ #define PKE_DSA_GEN_P_3072_256 0x4b1127e0 /**< Functionality ID for DSA parameter generation P * @li 2 input parameters : @link icp_qat_fw_mmp_dsa_gen_p_3072_256_input_s::x x * @endlink @link icp_qat_fw_mmp_dsa_gen_p_3072_256_input_s::q q @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_p_3072_256_output_s::p * p @endlink */ #define PKE_DSA_GEN_G_3072 0x4f142816 /**< Functionality ID for DSA key generation G * @li 3 input parameters : @link icp_qat_fw_mmp_dsa_gen_g_3072_input_s::p p * @endlink @link icp_qat_fw_mmp_dsa_gen_g_3072_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_gen_g_3072_input_s::h h @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_g_3072_output_s::g g * @endlink */ #define PKE_DSA_GEN_Y_3072 0x5112282f /**< Functionality ID for DSA key generation Y * @li 3 input parameters : @link icp_qat_fw_mmp_dsa_gen_y_3072_input_s::p p * @endlink @link icp_qat_fw_mmp_dsa_gen_y_3072_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_gen_y_3072_input_s::x x @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_dsa_gen_y_3072_output_s::y y * @endlink */ #define PKE_DSA_SIGN_R_3072_256 0x59282846 /**< Functionality ID for DSA Sign R * @li 4 input parameters : @link icp_qat_fw_mmp_dsa_sign_r_3072_256_input_s::k * k @endlink @link icp_qat_fw_mmp_dsa_sign_r_3072_256_input_s::p p @endlink * @link icp_qat_fw_mmp_dsa_sign_r_3072_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_3072_256_input_s::g g @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_3072_256_output_s::r r @endlink */ #define PKE_DSA_SIGN_R_S_3072_256 0x61292874 /**< Functionality ID for DSA Sign R S * @li 6 input parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s::k k @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_input_s::x x @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_output_s::r r @endlink @link * icp_qat_fw_mmp_dsa_sign_r_s_3072_256_output_s::s s @endlink */ #define PKE_DSA_VERIFY_3072_256 0x7f4328ae /**< Functionality ID for DSA Verify * @li 7 input parameters : @link icp_qat_fw_mmp_dsa_verify_3072_256_input_s::r * r @endlink @link icp_qat_fw_mmp_dsa_verify_3072_256_input_s::s s @endlink * @link icp_qat_fw_mmp_dsa_verify_3072_256_input_s::m m @endlink @link * icp_qat_fw_mmp_dsa_verify_3072_256_input_s::p p @endlink @link * icp_qat_fw_mmp_dsa_verify_3072_256_input_s::q q @endlink @link * icp_qat_fw_mmp_dsa_verify_3072_256_input_s::g g @endlink @link * icp_qat_fw_mmp_dsa_verify_3072_256_input_s::y y @endlink * @li no output parameters */ #define PKE_ECDSA_SIGN_RS_GF2_L256 0x46512907 /**< Functionality ID for ECDSA Sign RS for curves B/K-163 and B/K-233 * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_input_s::in in @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_output_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l256_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_R_GF2_L256 0x323a298f /**< Functionality ID for ECDSA Sign R for curves B/K-163 and B/K-233 * @li 7 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::xg xg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::yg yg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::n n @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::q q @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::a a @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::b b @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l256_output_s::r r @endlink */ #define PKE_ECDSA_SIGN_S_GF2_L256 0x2b2229e6 /**< Functionality ID for ECDSA Sign S for curves with n < 2^256 * @li 5 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_s::e e @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_s::d d @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_s::k k @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_input_s::n n @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l256_output_s::s s @endlink */ #define PKE_ECDSA_VERIFY_GF2_L256 0x337e2a27 /**< Functionality ID for ECDSA Verify for curves B/K-163 and B/K-233 * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_verify_gf2_l256_input_s::in in @endlink * @li no output parameters */ #define PKE_ECDSA_SIGN_RS_GF2_L512 0x5e5f2ad7 /**< Functionality ID for ECDSA Sign RS * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_input_s::in in @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_output_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_l512_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_R_GF2_L512 0x84312b6a /**< Functionality ID for ECDSA GF2 Sign R * @li 7 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::xg xg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::yg yg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::n n @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::q q @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::a a @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::b b @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_l512_output_s::r r @endlink */ #define PKE_ECDSA_SIGN_S_GF2_L512 0x26182bbe /**< Functionality ID for ECDSA GF2 Sign S * @li 5 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_s::e e @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_s::d d @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_s::k k @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_input_s::n n @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_l512_output_s::s s @endlink */ #define PKE_ECDSA_VERIFY_GF2_L512 0x58892bea /**< Functionality ID for ECDSA GF2 Verify * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_verify_gf2_l512_input_s::in in @endlink * @li no output parameters */ #define PKE_ECDSA_SIGN_RS_GF2_571 0x554a2c93 /**< Functionality ID for ECDSA GF2 Sign RS for curves B-571/K-571 * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_input_s::in in @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_output_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_gf2_571_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_S_GF2_571 0x52332d09 /**< Functionality ID for ECDSA GF2 Sign S for curves with deg(q) < 576 * @li 5 input parameters : @link icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_s::e * e @endlink @link icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_s::d d @endlink * @link icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_s::k k @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_input_s::n n @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gf2_571_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_R_GF2_571 0x731a2d51 /**< Functionality ID for ECDSA GF2 Sign R for degree 571 * @li 7 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::xg xg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::yg yg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::n n @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::q q @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::a a @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::b b @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gf2_571_output_s::r r @endlink */ #define PKE_ECDSA_VERIFY_GF2_571 0x4f6c2d91 /**< Functionality ID for ECDSA GF2 Verify for degree 571 * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_verify_gf2_571_input_s::in in @endlink * @li no output parameters */ #define MATHS_POINT_MULTIPLICATION_GF2_L256 0x3b242e38 /**< Functionality ID for MATHS GF2 Point Multiplication * @li 7 input parameters : @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::k k @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::xg xg @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::yg yg @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::a a @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::b b @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::q q @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_input_s::h h @endlink * @li 2 output parameters : @link * icp_qat_fw_maths_point_multiplication_gf2_l256_output_s::xk xk @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l256_output_s::yk yk @endlink */ #define MATHS_POINT_VERIFY_GF2_L256 0x231a2e7c /**< Functionality ID for MATHS GF2 Point Verification * @li 5 input parameters : @link * icp_qat_fw_maths_point_verify_gf2_l256_input_s::xq xq @endlink @link * icp_qat_fw_maths_point_verify_gf2_l256_input_s::yq yq @endlink @link * icp_qat_fw_maths_point_verify_gf2_l256_input_s::q q @endlink @link * icp_qat_fw_maths_point_verify_gf2_l256_input_s::a a @endlink @link * icp_qat_fw_maths_point_verify_gf2_l256_input_s::b b @endlink * @li no output parameters */ #define MATHS_POINT_MULTIPLICATION_GF2_L512 0x722c2e96 /**< Functionality ID for MATHS GF2 Point Multiplication * @li 7 input parameters : @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::k k @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::xg xg @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::yg yg @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::a a @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::b b @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::q q @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_input_s::h h @endlink * @li 2 output parameters : @link * icp_qat_fw_maths_point_multiplication_gf2_l512_output_s::xk xk @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_l512_output_s::yk yk @endlink */ #define MATHS_POINT_VERIFY_GF2_L512 0x25132ee2 /**< Functionality ID for MATHS GF2 Point Verification * @li 5 input parameters : @link * icp_qat_fw_maths_point_verify_gf2_l512_input_s::xq xq @endlink @link * icp_qat_fw_maths_point_verify_gf2_l512_input_s::yq yq @endlink @link * icp_qat_fw_maths_point_verify_gf2_l512_input_s::q q @endlink @link * icp_qat_fw_maths_point_verify_gf2_l512_input_s::a a @endlink @link * icp_qat_fw_maths_point_verify_gf2_l512_input_s::b b @endlink * @li no output parameters */ #define MATHS_POINT_MULTIPLICATION_GF2_571 0x44152ef5 /**< Functionality ID for ECC GF2 Point Multiplication for curves B-571/K-571 * @li 7 input parameters : @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::k k @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::xg xg @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::yg yg @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::a a @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::b b @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::q q @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_input_s::h h @endlink * @li 2 output parameters : @link * icp_qat_fw_maths_point_multiplication_gf2_571_output_s::xk xk @endlink @link * icp_qat_fw_maths_point_multiplication_gf2_571_output_s::yk yk @endlink */ #define MATHS_POINT_VERIFY_GF2_571 0x12072f1b /**< Functionality ID for ECC GF2 Point Verification for degree 571 * @li 5 input parameters : @link * icp_qat_fw_maths_point_verify_gf2_571_input_s::xq xq @endlink @link * icp_qat_fw_maths_point_verify_gf2_571_input_s::yq yq @endlink @link * icp_qat_fw_maths_point_verify_gf2_571_input_s::q q @endlink @link * icp_qat_fw_maths_point_verify_gf2_571_input_s::a a @endlink @link * icp_qat_fw_maths_point_verify_gf2_571_input_s::b b @endlink * @li no output parameters */ #define PKE_ECDSA_SIGN_R_GFP_L256 0x431b2f22 /**< Functionality ID for ECDSA GFP Sign R * @li 7 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::xg xg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::yg yg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::n n @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::q q @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::a a @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::b b @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l256_output_s::r r @endlink */ #define PKE_ECDSA_SIGN_S_GFP_L256 0x2b252f6d /**< Functionality ID for ECDSA GFP Sign S * @li 5 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_s::e e @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_s::d d @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_s::k k @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_input_s::n n @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l256_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_RS_GFP_L256 0x6a3c2fa6 /**< Functionality ID for ECDSA GFP Sign RS * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_input_s::in in @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_output_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l256_output_s::s s @endlink */ #define PKE_ECDSA_VERIFY_GFP_L256 0x325b3023 /**< Functionality ID for ECDSA GFP Verify * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_verify_gfp_l256_input_s::in in @endlink * @li no output parameters */ #define PKE_ECDSA_SIGN_R_GFP_L512 0x4e2530b3 /**< Functionality ID for ECDSA GFP Sign R * @li 7 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::xg xg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::yg yg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::n n @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::q q @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::a a @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::b b @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_l512_output_s::r r @endlink */ #define PKE_ECDSA_SIGN_S_GFP_L512 0x251830fa /**< Functionality ID for ECDSA GFP Sign S * @li 5 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_s::e e @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_s::d d @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_s::k k @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_input_s::n n @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_l512_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_RS_GFP_L512 0x5a2b3127 /**< Functionality ID for ECDSA GFP Sign RS * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_input_s::in in @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_output_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_l512_output_s::s s @endlink */ #define PKE_ECDSA_VERIFY_GFP_L512 0x3553318a /**< Functionality ID for ECDSA GFP Verify * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_verify_gfp_l512_input_s::in in @endlink * @li no output parameters */ #define PKE_ECDSA_SIGN_R_GFP_521 0x772c31fe /**< Functionality ID for ECDSA GFP Sign R * @li 7 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::xg xg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::yg yg @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::n n @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::q q @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::a a @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::b b @endlink @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_input_s::k k @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_r_gfp_521_output_s::r r @endlink */ #define PKE_ECDSA_SIGN_S_GFP_521 0x52343251 /**< Functionality ID for ECDSA GFP Sign S * @li 5 input parameters : @link icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_s::e * e @endlink @link icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_s::d d @endlink * @link icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_s::k k @endlink @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_input_s::n n @endlink * @li 1 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_s_gfp_521_output_s::s s @endlink */ #define PKE_ECDSA_SIGN_RS_GFP_521 0x494a329b /**< Functionality ID for ECDSA GFP Sign RS * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_input_s::in in @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_output_s::r r @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_gfp_521_output_s::s s @endlink */ #define PKE_ECDSA_VERIFY_GFP_521 0x554c331f /**< Functionality ID for ECDSA GFP Verify * @li 1 input parameters : @link * icp_qat_fw_mmp_ecdsa_verify_gfp_521_input_s::in in @endlink * @li no output parameters */ #define MATHS_POINT_MULTIPLICATION_GFP_L256 0x432033a6 /**< Functionality ID for ECC GFP Point Multiplication * @li 7 input parameters : @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::k k @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::xg xg @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::yg yg @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::a a @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::b b @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::q q @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_input_s::h h @endlink * @li 2 output parameters : @link * icp_qat_fw_maths_point_multiplication_gfp_l256_output_s::xk xk @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l256_output_s::yk yk @endlink */ #define MATHS_POINT_VERIFY_GFP_L256 0x1f0c33fc /**< Functionality ID for ECC GFP Partial Point Verification * @li 5 input parameters : @link * icp_qat_fw_maths_point_verify_gfp_l256_input_s::xq xq @endlink @link * icp_qat_fw_maths_point_verify_gfp_l256_input_s::yq yq @endlink @link * icp_qat_fw_maths_point_verify_gfp_l256_input_s::q q @endlink @link * icp_qat_fw_maths_point_verify_gfp_l256_input_s::a a @endlink @link * icp_qat_fw_maths_point_verify_gfp_l256_input_s::b b @endlink * @li no output parameters */ #define MATHS_POINT_MULTIPLICATION_GFP_L512 0x41253419 /**< Functionality ID for ECC GFP Point Multiplication * @li 7 input parameters : @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::k k @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::xg xg @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::yg yg @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::a a @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::b b @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::q q @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_input_s::h h @endlink * @li 2 output parameters : @link * icp_qat_fw_maths_point_multiplication_gfp_l512_output_s::xk xk @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_l512_output_s::yk yk @endlink */ #define MATHS_POINT_VERIFY_GFP_L512 0x2612345c /**< Functionality ID for ECC GFP Partial Point * @li 5 input parameters : @link * icp_qat_fw_maths_point_verify_gfp_l512_input_s::xq xq @endlink @link * icp_qat_fw_maths_point_verify_gfp_l512_input_s::yq yq @endlink @link * icp_qat_fw_maths_point_verify_gfp_l512_input_s::q q @endlink @link * icp_qat_fw_maths_point_verify_gfp_l512_input_s::a a @endlink @link * icp_qat_fw_maths_point_verify_gfp_l512_input_s::b b @endlink * @li no output parameters */ #define MATHS_POINT_MULTIPLICATION_GFP_521 0x5511346e /**< Functionality ID for ECC GFP Point Multiplication * @li 7 input parameters : @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::k k @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::xg xg @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::yg yg @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::a a @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::b b @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::q q @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_input_s::h h @endlink * @li 2 output parameters : @link * icp_qat_fw_maths_point_multiplication_gfp_521_output_s::xk xk @endlink @link * icp_qat_fw_maths_point_multiplication_gfp_521_output_s::yk yk @endlink */ #define MATHS_POINT_VERIFY_GFP_521 0x0e0734be /**< Functionality ID for ECC GFP Partial Point Verification * @li 5 input parameters : @link * icp_qat_fw_maths_point_verify_gfp_521_input_s::xq xq @endlink @link * icp_qat_fw_maths_point_verify_gfp_521_input_s::yq yq @endlink @link * icp_qat_fw_maths_point_verify_gfp_521_input_s::q q @endlink @link * icp_qat_fw_maths_point_verify_gfp_521_input_s::a a @endlink @link * icp_qat_fw_maths_point_verify_gfp_521_input_s::b b @endlink * @li no output parameters */ #define PKE_EC_POINT_MULTIPLICATION_P256 0x0a083546 /**< Functionality ID for ECC P256 Variable Point Multiplication [k]P(x) * @li 3 input parameters : @link * icp_qat_fw_mmp_ec_p256_point_multiplication_input_s::xp xp @endlink @link * icp_qat_fw_mmp_ec_p256_point_multiplication_input_s::yp yp @endlink @link * icp_qat_fw_mmp_ec_p256_point_multiplication_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ec_p256_point_multiplication_output_s::xr xr @endlink @link * icp_qat_fw_mmp_ec_p256_point_multiplication_output_s::yr yr @endlink */ #define PKE_EC_GENERATOR_MULTIPLICATION_P256 0x12073556 /**< Functionality ID for ECC P256 Generator Point Multiplication [k]G(x) * @li 1 input parameters : @link * icp_qat_fw_mmp_ec_p256_generator_multiplication_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ec_p256_generator_multiplication_output_s::xr xr @endlink * @link icp_qat_fw_mmp_ec_p256_generator_multiplication_output_s::yr yr * @endlink */ #define PKE_ECDSA_SIGN_RS_P256 0x18133566 /**< Functionality ID for ECC P256 ECDSA Sign RS * @li 3 input parameters : @link icp_qat_fw_mmp_ecdsa_sign_rs_p256_input_s::k k * @endlink @link icp_qat_fw_mmp_ecdsa_sign_rs_p256_input_s::e e @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_p256_input_s::d d @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_ecdsa_sign_rs_p256_output_s::r * r @endlink @link icp_qat_fw_mmp_ecdsa_sign_rs_p256_output_s::s s @endlink */ #define PKE_EC_POINT_MULTIPLICATION_P384 0x0b083586 /**< Functionality ID for ECC P384 Variable Point Multiplication [k]P(x) * @li 3 input parameters : @link * icp_qat_fw_mmp_ec_p384_point_multiplication_input_s::xp xp @endlink @link * icp_qat_fw_mmp_ec_p384_point_multiplication_input_s::yp yp @endlink @link * icp_qat_fw_mmp_ec_p384_point_multiplication_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ec_p384_point_multiplication_output_s::xr xr @endlink @link * icp_qat_fw_mmp_ec_p384_point_multiplication_output_s::yr yr @endlink */ #define PKE_EC_GENERATOR_MULTIPLICATION_P384 0x0b073596 /**< Functionality ID for ECC P384 Generator Point Multiplication [k]G(x) * @li 1 input parameters : @link * icp_qat_fw_mmp_ec_p384_generator_multiplication_input_s::k k @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_ec_p384_generator_multiplication_output_s::xr xr @endlink * @link icp_qat_fw_mmp_ec_p384_generator_multiplication_output_s::yr yr * @endlink */ #define PKE_ECDSA_SIGN_RS_P384 0x1a1335a6 /**< Functionality ID for ECC P384 ECDSA Sign RS * @li 3 input parameters : @link icp_qat_fw_mmp_ecdsa_sign_rs_p384_input_s::k k * @endlink @link icp_qat_fw_mmp_ecdsa_sign_rs_p384_input_s::e e @endlink @link * icp_qat_fw_mmp_ecdsa_sign_rs_p384_input_s::d d @endlink * @li 2 output parameters : @link icp_qat_fw_mmp_ecdsa_sign_rs_p384_output_s::r * r @endlink @link icp_qat_fw_mmp_ecdsa_sign_rs_p384_output_s::s s @endlink */ #define PKE_LIVENESS 0x00000001 /**< Functionality ID for PKE_LIVENESS * @li 0 input parameter(s) * @li 1 output parameter(s) (8 qwords) */ #define PKE_INTERFACE_SIGNATURE 0x972ded54 /**< Encoded signature of the interface specifications */ #define PKE_INVALID_FUNC_ID 0xffffffff #define PKE_KPT_ECDSA_SIGN_RS_P521 0xb6563896 /**< Functionality ID for ECC P521 ECDSA Sign RS * @li 3 input parameters : @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_input_s::kpt_wrapped kpt_wrapped * @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_input_s::kpt_wrapping_context * kpt_wrapping_context @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_input_s::e e @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_output_s::r r @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p521_output_s::s s @endlink */ #define PKE_KPT_ECDSA_SIGN_RS_P384 0x22143876 /**< Functionality ID for ECC P384 ECDSA Sign RS * @li 3 input parameters : @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_input_s::kpt_wrapped kpt_wrapped * @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_input_s::kpt_wrapping_context * kpt_wrapping_context @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_input_s::e e @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_output_s::r r @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p384_output_s::s s @endlink */ #define PKE_KPT_ECDSA_SIGN_RS_P256 0x8d153856 /**< Functionality ID for ECC KPT P256 ECDSA Sign RS * @li 3 input parameters : @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_input_s::kpt_wrapped kpt_wrapped * @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_input_s::key_unwrap_context * key_unwrap_context @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_input_s::e e @endlink * @li 2 output parameters : @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_output_s::r r @endlink @link * icp_qat_fw_mmp_kpt_ecdsa_sign_rs_p256_output_s::s s @endlink */ #define PKE_KPT_RSA_DP1_512 0x1b1c3696 /**< Functionality ID for KPT RSA 512 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_512_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_512_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_512_input_s::kpt_unwrap_context kpt_unwrap_context * @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_512_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP1_1024 0x2d1d36b6 /**< Functionality ID for KPT RSA 1024 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_1024_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_1024_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_1024_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_1024_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP1_1536 0x451d36d6 /**< Functionality ID for KPT RSA 1536 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_1536_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_1536_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_1536_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_1536_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP1_2048 0x661936f6 /**< Functionality ID for KPT RSA 2048 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_2048_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_2048_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_2048_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_2048_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP1_3072 0x751d3716 /**< Functionality ID for KPT RSA 3072 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_3072_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_3072_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_3072_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_3072_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP1_4096 0x9d1d3736 /**< Functionality ID for KPT RSA 4096 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_4096_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_4096_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_4096_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_4096_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP1_8192 0xbe203756 /**< Functionality ID for KPT RSA 8192 Decryption * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_8192_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp1_8192_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp1_8192_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp1_8192_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_512 0x241d3776 /**< Functionality ID for RSA 512 decryption second form * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_512_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_512_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_512_input_s::kpt_unwrap_context kpt_unwrap_context * @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_512_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_1024 0x4e1d3796 /**< Functionality ID for RSA 1024 Decryption with CRT * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_1024_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_1024_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_1024_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_1024_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_1536 0x762b37b6 /**< Functionality ID for KPT RSA 1536 Decryption with CRT * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_1536_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_1536_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_1536_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_1536_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_2048 0xa41a37d6 /**< Functionality ID for RSA 2048 Decryption with CRT * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_2048_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_2048_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_2048_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_2048_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_3072 0xd41a37f6 /**< Functionality ID for * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_3072_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_3072_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_3072_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_3072_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_4096 0xd22a3816 /**< Functionality ID for RSA 4096 Decryption with CRT * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_4096_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_4096_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_4096_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_4096_output_s::m m * @endlink */ #define PKE_KPT_RSA_DP2_8192 0xae383836 /**< Functionality ID for RSA 8192 Decryption with CRT * @li 3 input parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_8192_input_s::c c * @endlink @link icp_qat_fw_mmp_kpt_rsa_dp2_8192_input_s::kpt_wrapped * kpt_wrapped @endlink @link * icp_qat_fw_mmp_kpt_rsa_dp2_8192_input_s::kpt_unwrap_context * kpt_unwrap_context @endlink * @li 1 output parameters : @link icp_qat_fw_mmp_kpt_rsa_dp2_8192_output_s::m m * @endlink */ #endif /* __ICP_QAT_FW_MMP_IDS__ */ /* --- (Automatically generated (relocation v. 1.3), do not modify manually) --- */ /* --- end of file --- */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_pke.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_pke.h index 1ba7e81c52a9..aa642cc23a57 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_pke.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_fw_pke.h @@ -1,417 +1,417 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** * @file icp_qat_fw_pke.h * @defgroup icp_qat_fw_pke ICP QAT FW PKE Processing Definitions * @ingroup icp_qat_fw * $Revision: 0.1 $ * @brief * This file documents the external interfaces that the QAT FW running * on the QAT Acceleration Engine provides to clients wanting to - * accelerate crypto assymetric applications + * accelerate crypto asymmetric applications */ #ifndef _ICP_QAT_FW_PKE_ #define _ICP_QAT_FW_PKE_ /* **************************************************************************** * Include local header files **************************************************************************** */ #include "icp_qat_fw.h" /** ***************************************************************************** * * @ingroup icp_qat_fw_pke * * @brief * PKE response status field structure contained * within LW1, comprising the common error codes and * the response flags. * *****************************************************************************/ typedef struct icp_qat_fw_pke_resp_status_s { uint8_t comn_err_code; /**< 8 bit common error code */ uint8_t pke_resp_flags; /**< 8-bit PKE response flags */ } icp_qat_fw_pke_resp_status_t; /** ***************************************************************************** * @ingroup icp_qat_fw_pke * Definition of the QAT FW PKE request header pars field. * Structure differs from the DH895xxCC common base header structure, hence * redefined here. * @description * PKE request message header pars structure * *****************************************************************************/ typedef struct icp_qat_fw_req_hdr_pke_cd_pars_s { /**< LWs 2-3 */ uint64_t content_desc_addr; /**< Content descriptor pointer */ /**< LW 4 */ uint32_t content_desc_resrvd; /**< Content descriptor reserved field */ /**< LW 5 */ uint32_t func_id; /**< MMP functionality Id */ } icp_qat_fw_req_hdr_pke_cd_pars_t; /** ***************************************************************************** * @ingroup icp_qat_fw_pke * Definition of the QAT FW PKE request header mid section. * Structure differs from the DH895xxCC common base header structure, * instead following the DH89xxCC format, hence redefined here. * @description * PKE request message header middle structure * *****************************************************************************/ typedef struct icp_qat_fw_req_pke_mid_s { /**< LWs 6-11 */ uint64_t opaque_data; /**< Opaque data passed unmodified from the request to response messages * by * firmware (fw) */ uint64_t src_data_addr; /**< Generic definition of the source data supplied to the QAT AE. The * common flags are used to further describe the attributes of this * field */ uint64_t dest_data_addr; /**< Generic definition of the destination data supplied to the QAT AE. * The * common flags are used to further describe the attributes of this * field */ /**< Following DH89xxCC structure format - footer is excluded */ } icp_qat_fw_req_pke_mid_t; /** ***************************************************************************** * @ingroup icp_qat_fw_pke * Definition of the QAT FW PKE request header. * Structure differs from the DH895xxCC common base header structure, * instead following the DH89xxCC format, hence redefined here. * @description * PKE request message header structure * *****************************************************************************/ typedef struct icp_qat_fw_req_pke_hdr_s { /**< LW0 */ uint8_t resrvd1; /**< reserved field */ uint8_t resrvd2; /**< reserved field */ uint8_t service_type; /**< Service type */ uint8_t hdr_flags; /**< This represents a flags field for the Service Request. * The most significant bit is the 'valid' flag and the only * one used. All remaining bit positions are unused and * are therefore reserved and need to be set to 0. */ /**< LW1 */ icp_qat_fw_comn_flags comn_req_flags; /**< Common Request flags must indicate flat buffer (as per DH89xxCC) * Common Request flags - PKE slice flags no longer used - slice * allocated to a threadstrand.*/ uint16_t resrvd4; /**< (DH89xxCC) CD Header Size and CD Params Size unused. Set to zero. */ /**< LWs 2-5 */ icp_qat_fw_req_hdr_pke_cd_pars_t cd_pars; /**< PKE request message header pars structure - this differs * from the DH895xxCC common base structure */ } icp_qat_fw_req_pke_hdr_t; /** *************************************************************************** * * @ingroup icp_qat_fw_pke * * @brief * PKE request message structure (64 bytes) * *****************************************************************************/ typedef struct icp_qat_fw_pke_request_s { /**< LWs 0-5 */ icp_qat_fw_req_pke_hdr_t pke_hdr; /**< Request header for PKE - CD Header/Param size * must be zero */ /**< LWs 6-11 (same as DH89xxCC) */ icp_qat_fw_req_pke_mid_t pke_mid; /**< Request middle section for PKE */ /**< LW 12 */ uint8_t output_param_count; /**< Number of output large integers * for request */ uint8_t input_param_count; /**< Number of input large integers * for request */ uint16_t resrvd1; /** Reserved **/ /**< LW 13 */ uint32_t resrvd2; /**< Reserved */ /**< LWs 14-15 */ uint64_t next_req_adr; /** < PKE - next request address */ } icp_qat_fw_pke_request_t; /** ***************************************************************************** * * @ingroup icp_qat_fw_pke * * @brief * PKE response message header structure * *****************************************************************************/ typedef struct icp_qat_fw_resp_pke_hdr_s { /**< LW0 */ uint8_t resrvd1; /**< The Response Destination Id has been removed * from first QWord */ uint8_t resrvd2; /**< Response Pipe Id field is unused (reserved) * - Functionality within DH895xxCC uses arbiter instead */ uint8_t response_type; /**< Response type - copied from the request to * the response message */ uint8_t hdr_flags; /**< This represents a flags field for the Response. * The most significant bit is the 'valid' flag and the only * one used. All remaining bit positions are unused and * are therefore reserved */ /**< LW1 */ icp_qat_fw_pke_resp_status_t resp_status; uint16_t resrvd4; /**< (DH89xxCC) CD Header Size and CD Params Size fields unused. * Set to zero. */ } icp_qat_fw_resp_pke_hdr_t; /** ***************************************************************************** * * @ingroup icp_qat_fw_pke * * @brief * PKE response message structure (32 bytes) * *****************************************************************************/ typedef struct icp_qat_fw_pke_resp_s { /**< LWs 0-1 */ icp_qat_fw_resp_pke_hdr_t pke_resp_hdr; /**< Response header for PKE */ /**< LWs 2-3 */ uint64_t opaque_data; /**< Opaque data passed from the request to the response message */ /**< LWs 4-5 */ uint64_t src_data_addr; /**< Generic definition of the source data supplied to the QAT AE. The * common flags are used to further describe the attributes of this * field */ /**< LWs 6-7 */ uint64_t dest_data_addr; /**< Generic definition of the destination data supplied to the QAT AE. * The * common flags are used to further describe the attributes of this * field */ } icp_qat_fw_pke_resp_t; /* ========================================================================= */ /* MACRO DEFINITIONS */ /* ========================================================================= */ /**< @ingroup icp_qat_fw_pke * Macro defining the bit position and mask of the 'valid' flag, within the * hdr_flags field of LW0 (service request and response) of the PKE request */ #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_BITPOS 7 #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_MASK 0x1 /**< @ingroup icp_qat_fw_pke * Macro defining the bit position and mask of the PKE status flag, within the * status field LW1 of a PKE response message */ #define QAT_COMN_RESP_PKE_STATUS_BITPOS 6 /**< @ingroup icp_qat_fw_pke * Starting bit position indicating the PKE status flag within the PKE response * pke_resp_flags byte. */ #define QAT_COMN_RESP_PKE_STATUS_MASK 0x1 /**< @ingroup icp_qat_fw_pke * One bit mask used to determine PKE status mask */ /* * < @ingroup icp_qat_fw_pke * *** PKE Response Status Field Definition *** * The PKE response follows the CPM 1.5 message format. The status field is 16 bits * wide, where the status flags are contained within the most significant byte of the * icp_qat_fw_pke_resp_status_t structure. The lower 8 bits of this word now contain * the common error codes, which are defined in the common header file(*). */ /* + ===== + ----- + ---- + ----- + ----- + ----- + ----- + ----- + ----- + ----------------------- + * | Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | [7....0] | * + ===== + ----- + ---- + ----- + ----- + ----- + ----- + ----- + ----- + ----------------------- + * | Flags | Rsrvd | Pke | Rsrvd | Rsrvd | Rsrvd | Rsrvd | Rsrvd | Rsrvd | Common error codes(*) | * + ===== + ----- + ---- + ----- + ----- + ----- + ----- + ----- + ----- + ----------------------- + */ /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Macro for extraction of the PKE bit from the 16-bit status field * particular to a PKE response. The status flags are contained within * the most significant byte of the word. The lower 8 bits of this status * word now contain the common error codes, which are defined in the common * header file. The appropriate macro definition to extract the PKE status * flag from the PKE response assumes that a single byte i.e. *pke_resp_flags * is passed to the macro. * * @param status * Status to extract the PKE status bit * *****************************************************************************/ #define ICP_QAT_FW_PKE_RESP_PKE_STAT_GET(flags) \ QAT_FIELD_GET((flags), \ QAT_COMN_RESP_PKE_STATUS_BITPOS, \ QAT_COMN_RESP_PKE_STATUS_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Extract the valid flag from the PKE Request's header flags. Note that * this invokes the common macro which may be used by either the request * or the response. * * @param icp_qat_fw_req_pke_hdr_t Structure passed to extract the valid bit * from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_PKE_RQ_VALID_FLAG_GET(icp_qat_fw_req_pke_hdr_t) \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_GET(icp_qat_fw_req_pke_hdr_t) /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Set the valid bit in the PKE Request's header flags. Note that * this invokes the common macro which may be used by either the request * or the response. * * @param icp_qat_fw_req_pke_hdr_t Structure passed to set the valid bit. * @param val Value of the valid bit flag. * *****************************************************************************/ #define ICP_QAT_FW_PKE_RQ_VALID_FLAG_SET(icp_qat_fw_req_pke_hdr_t, val) \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(icp_qat_fw_req_pke_hdr_t, val) /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Extract the valid flag from the PKE Response's header flags. Note that * invokes the common macro which may be used by either the request * or the response. * * @param icp_qat_fw_resp_pke_hdr_t Structure to extract the valid bit * from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_PKE_RESP_VALID_FLAG_GET(icp_qat_fw_resp_pke_hdr_t) \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_GET(icp_qat_fw_resp_pke_hdr_t) /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Set the valid bit in the PKE Response's header flags. Note that * this invokes the common macro which may be used by either the * request or the response. * * @param icp_qat_fw_resp_pke_hdr_t Structure to set the valid bit * @param val Value of the valid bit flag. * *****************************************************************************/ #define ICP_QAT_FW_PKE_RESP_VALID_FLAG_SET(icp_qat_fw_resp_pke_hdr_t, val) \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(icp_qat_fw_resp_pke_hdr_t, val) /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Common macro to extract the valid flag from the header flags field * within the header structure (request or response). * * @param hdr_t Structure (request or response) to extract the * valid bit from the 'hdr_flags' field. * *****************************************************************************/ #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_GET(hdr_t) \ QAT_FIELD_GET(hdr_t.hdr_flags, \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_BITPOS, \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_fw_pke * * @description * Common macro to set the valid bit in the header flags field within * the header structure (request or response). * * @param hdr_t Structure (request or response) containing the header * flags field, to allow the valid bit to be set. * @param val Value of the valid bit flag. * *****************************************************************************/ #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(hdr_t, val) \ QAT_FIELD_SET((hdr_t.hdr_flags), \ (val), \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_BITPOS, \ ICP_QAT_FW_PKE_HDR_VALID_FLAG_MASK) #endif /* _ICP_QAT_FW_PKE_ */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_hw.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_hw.h index 2af0684206ab..5882199cf1a9 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_hw.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_hw.h @@ -1,1618 +1,1618 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file icp_qat_hw.h * @defgroup icp_qat_hw_defs ICP QAT HW definitions * @ingroup icp_qat_hw * @description * This file documents definitions for the QAT HW * *****************************************************************************/ #ifndef _ICP_QAT_HW_H_ #define _ICP_QAT_HW_H_ /* ****************************************************************************** * Include public/global header files ****************************************************************************** */ /* ========================================================================= */ /* AccelerationEngine */ /* ========================================================================= */ typedef enum { ICP_QAT_HW_AE_0 = 0, /*!< ID of AE0 */ ICP_QAT_HW_AE_1 = 1, /*!< ID of AE1 */ ICP_QAT_HW_AE_2 = 2, /*!< ID of AE2 */ ICP_QAT_HW_AE_3 = 3, /*!< ID of AE3 */ ICP_QAT_HW_AE_4 = 4, /*!< ID of AE4 */ ICP_QAT_HW_AE_5 = 5, /*!< ID of AE5 */ ICP_QAT_HW_AE_6 = 6, /*!< ID of AE6 */ ICP_QAT_HW_AE_7 = 7, /*!< ID of AE7 */ ICP_QAT_HW_AE_8 = 8, /*!< ID of AE8 */ ICP_QAT_HW_AE_9 = 9, /*!< ID of AE9 */ ICP_QAT_HW_AE_10 = 10, /*!< ID of AE10 */ ICP_QAT_HW_AE_11 = 11, /*!< ID of AE11 */ ICP_QAT_HW_AE_12 = 12, /*!< ID of AE12 */ ICP_QAT_HW_AE_13 = 13, /*!< ID of AE13 */ ICP_QAT_HW_AE_14 = 14, /*!< ID of AE14 */ ICP_QAT_HW_AE_15 = 15, /*!< ID of AE15 */ ICP_QAT_HW_AE_DELIMITER = 16 /**< Delimiter type */ } icp_qat_hw_ae_id_t; /* ========================================================================= */ /* QAT */ /* ========================================================================= */ typedef enum { ICP_QAT_HW_QAT_0 = 0, /*!< ID of QAT0 */ ICP_QAT_HW_QAT_1 = 1, /*!< ID of QAT1 */ ICP_QAT_HW_QAT_2 = 2, /*!< ID of QAT2 */ ICP_QAT_HW_QAT_3 = 3, /*!< ID of QAT3 */ ICP_QAT_HW_QAT_4 = 4, /*!< ID of QAT4 */ ICP_QAT_HW_QAT_5 = 5, /*!< ID of QAT5 */ ICP_QAT_HW_QAT_DELIMITER = 6 /**< Delimiter type */ } icp_qat_hw_qat_id_t; /* ========================================================================= */ /* AUTH SLICE */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Supported Authentication Algorithm types * @description * Enumeration which is used to define the authenticate algorithms * *****************************************************************************/ typedef enum { ICP_QAT_HW_AUTH_ALGO_NULL = 0, /*!< Null hashing */ ICP_QAT_HW_AUTH_ALGO_SHA1 = 1, /*!< SHA1 hashing */ ICP_QAT_HW_AUTH_ALGO_MD5 = 2, /*!< MD5 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA224 = 3, /*!< SHA-224 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA256 = 4, /*!< SHA-256 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA384 = 5, /*!< SHA-384 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA512 = 6, /*!< SHA-512 hashing */ ICP_QAT_HW_AUTH_ALGO_AES_XCBC_MAC = 7, /*!< AES-XCBC-MAC hashing */ ICP_QAT_HW_AUTH_ALGO_AES_CBC_MAC = 8, /*!< AES-CBC-MAC hashing */ ICP_QAT_HW_AUTH_ALGO_AES_F9 = 9, /*!< AES F9 hashing */ ICP_QAT_HW_AUTH_ALGO_GALOIS_128 = 10, /*!< Galois 128 bit hashing */ ICP_QAT_HW_AUTH_ALGO_GALOIS_64 = 11, /*!< Galois 64 hashing */ ICP_QAT_HW_AUTH_ALGO_KASUMI_F9 = 12, /*!< Kasumi F9 hashing */ ICP_QAT_HW_AUTH_ALGO_SNOW_3G_UIA2 = 13, /*!< UIA2/SNOW_3G F9 hashing */ ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3 = 14, /*!< 128_EIA3/ZUC_3G hashing */ ICP_QAT_HW_AUTH_ALGO_SM3 = 15, /*!< SM3 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA3_224 = 16, /*!< SHA3-224 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA3_256 = 17, /*!< SHA3-256 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA3_384 = 18, /*!< SHA3-384 hashing */ ICP_QAT_HW_AUTH_ALGO_SHA3_512 = 19, /*!< SHA3-512 hashing */ ICP_QAT_HW_AUTH_RESERVED_4 = 20, /*!< Reserved */ ICP_QAT_HW_AUTH_RESERVED_5 = 21, /*!< Reserved */ ICP_QAT_HW_AUTH_ALGO_POLY = 22, /*!< POLY hashing */ ICP_QAT_HW_AUTH_ALGO_DELIMITER = 23 /**< Delimiter type */ } icp_qat_hw_auth_algo_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported Authentication modes * @description * Enumeration which is used to define the authentication slice modes. * The concept of modes is very specific to the QAT implementation. Its * main use is differentiate how the algorithms are used i.e. mode0 SHA1 * will configure the QAT Auth Slice to do plain SHA1 hashing while mode1 * configures it to do SHA1 HMAC with precomputes and mode2 sets up the * slice to do SHA1 HMAC with no precomputes (uses key directly) * * @Note * Only some algorithms are valid in some of the modes. If you dont know * what you are doing then refer back to the HW documentation * *****************************************************************************/ typedef enum { ICP_QAT_HW_AUTH_MODE0 = 0, /*!< QAT Auth Mode0 configuration */ ICP_QAT_HW_AUTH_MODE1 = 1, /*!< QAT Auth Mode1 configuration */ ICP_QAT_HW_AUTH_MODE2 = 2, /*!< QAT AuthMode2 configuration */ ICP_QAT_HW_AUTH_MODE_DELIMITER = 3 /**< Delimiter type */ } icp_qat_hw_auth_mode_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Auth configuration structure * * @description * Definition of the format of the authentication slice configuration * *****************************************************************************/ typedef struct icp_qat_hw_auth_config_s { uint32_t config; /**< Configuration used for setting up the slice */ uint32_t reserved; /**< Reserved */ } icp_qat_hw_auth_config_t; /* Private defines */ /* Note: Bit positions have been defined for little endian ordering */ /* * AUTH CONFIG WORD BITMAP * + ===== + ------ + ------ + ------- + ------ + ------ + ----- + ----- + ------ + ------ + ---- + ----- + ----- + ----- + * | Bit | 63:56 | 55:52 | 51:48 | 47:32 | 31:24 | 23:22 | 21:18 | 17 | 16 | 15 | 14:8 | 7:4 | 3:0 | * + ===== + ------ + ------ + ------- + ------ + ------ + ----- + ----- + ------ + ------ + ---- + ----- + ------+ ----- + * | Usage | Prog | Resvd | Prog | Resvd | Resvd | Algo | Rsvrd | SHA3 | SHA3 |Rsvrd | Cmp | Mode | Algo | * | |padding | Bits=0 | padding | Bits=0 | Bits=0 | SHA3 | |Padding |Padding | | | | | * | | SHA3 | | SHA3 | | | | |Override|Disable | | | | | * | |(prefix)| |(postfix)| | | | | | | | | | | * + ===== + ------ + ------ + ------- + ------ + ------ + ----- + ----- + ------ + ------ + ---- + ----- + ----- + ------+ */ /**< Flag mask & bit position */ #define QAT_AUTH_MODE_BITPOS 4 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the Auth mode */ #define QAT_AUTH_MODE_MASK 0xF /**< @ingroup icp_qat_hw_defs - * Four bit mask used for determing the Auth mode */ + * Four bit mask used for determining the Auth mode */ #define QAT_AUTH_ALGO_BITPOS 0 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the Auth Algo */ #define QAT_AUTH_ALGO_MASK 0xF /**< @ingroup icp_qat_hw_defs * Four bit mask used for determining the Auth algo */ #define QAT_AUTH_CMP_BITPOS 8 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the Auth Compare */ #define QAT_AUTH_CMP_MASK 0x7F /**< @ingroup icp_qat_hw_defs * Seven bit mask used to determine the Auth Compare */ #define QAT_AUTH_SHA3_PADDING_DISABLE_BITPOS 16 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the Auth h/w * padding disable for SHA3. * Flag set to 0 => h/w is required to pad (default) * Flag set to 1 => No padding in h/w */ #define QAT_AUTH_SHA3_PADDING_DISABLE_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Single bit mask used to determine the Auth h/w * padding disable for SHA3. */ #define QAT_AUTH_SHA3_PADDING_OVERRIDE_BITPOS 17 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the Auth h/w * padding override for SHA3. * Flag set to 0 => default padding behaviour * implemented in SHA3-256 slice will take effect * (default hardware setting upon h/w reset) * Flag set to 1 => SHA3-core will not use the padding * sequence built into the SHA3 core. Instead, the * padding sequence specified in bits 48-51 and 56-63 * of the 64-bit auth config word will apply * (corresponds with EAS bits 32-43). */ #define QAT_AUTH_SHA3_PADDING_OVERRIDE_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Single bit mask used to determine the Auth h/w * padding override for SHA3. */ #define QAT_AUTH_ALGO_SHA3_BITPOS 22 /**< @ingroup icp_qat_hw_defs * Starting bit position for indicating the * SHA3 Auth Algo */ #define QAT_AUTH_ALGO_SHA3_MASK 0x3 /**< @ingroup icp_qat_hw_defs * Two bit mask used for determining the * SHA3 Auth algo */ /**< Flag mask & bit position */ #define QAT_AUTH_SHA3_PROG_PADDING_POSTFIX_BITPOS 16 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the SHA3 * flexible programmable padding postfix. * Note that these bits are set using macro * ICP_QAT_HW_AUTH_CONFIG_BUILD_UPPER and are * defined relative to the 32-bit value that * this macro returns. In effect, therefore, this * defines starting bit position 48 within the * 64-bit auth config word. */ #define QAT_AUTH_SHA3_PROG_PADDING_POSTFIX_MASK 0xF /**< @ingroup icp_qat_hw_defs * Four-bit mask used to determine the SHA3 * flexible programmable padding postfix */ #define QAT_AUTH_SHA3_PROG_PADDING_PREFIX_BITPOS 24 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the SHA3 * flexible programmable padding prefix * Note that these bits are set using macro * ICP_QAT_HW_AUTH_CONFIG_BUILD_UPPER and are * defined relative to the 32-bit value that * this macro returns. In effect, therefore, this * defines starting bit position 56 within the * 64-bit auth config word. */ #define QAT_AUTH_SHA3_PROG_PADDING_PREFIX_MASK 0xFF /**< @ingroup icp_qat_hw_defs * Eight-bit mask used to determine the SHA3 * flexible programmable padding prefix */ /**< Flag usage - see additional notes @description for * ICP_QAT_HW_AUTH_CONFIG_BUILD and * ICP_QAT_HW_AUTH_CONFIG_BUILD_UPPER macros. */ #define QAT_AUTH_SHA3_HW_PADDING_ENABLE 0 /**< @ingroup icp_qat_hw_defs * This setting enables h/w padding for SHA3. */ #define QAT_AUTH_SHA3_HW_PADDING_DISABLE 1 /**< @ingroup icp_qat_hw_defs * This setting disables h/w padding for SHA3. */ #define QAT_AUTH_SHA3_PADDING_DISABLE_USE_DEFAULT 0 /**< @ingroup icp_qat_hw_defs * Default value for the Auth h/w padding disable. * If set to 0 for SHA3-256, h/w padding is enabled. * Padding_Disable is undefined for all non-SHA3-256 * algos and is consequently set to the default of 0. */ #define QAT_AUTH_SHA3_PADDING_OVERRIDE_USE_DEFAULT 0 /**< @ingroup icp_qat_hw_defs * Value for the Auth h/w padding override for SHA3. * Flag set to 0 => default padding behaviour * implemented in SHA3-256 slice will take effect * (default hardware setting upon h/w reset) * For this setting of the override flag, all the * bits of the padding sequence specified * in bits 48-51 and 56-63 of the 64-bit * auth config word are set to 0 (reserved). */ #define QAT_AUTH_SHA3_PADDING_OVERRIDE_PROGRAMMABLE 1 /**< @ingroup icp_qat_hw_defs * Value for the Auth h/w padding override for SHA3. * Flag set to 1 => SHA3-core will not use the padding * sequence built into the SHA3 core. Instead, the * padding sequence specified in bits 48-51 and 56-63 * of the 64-bit auth config word will apply * (corresponds with EAS bits 32-43). */ #define QAT_AUTH_SHA3_PROG_PADDING_POSTFIX_RESERVED 0 /**< @ingroup icp_qat_hw_defs * All the bits of the padding sequence specified in * bits 48-51 of the 64-bit auth config word are set * to 0 (reserved) if the padding override bit is set * to 0, indicating default padding. */ #define QAT_AUTH_SHA3_PROG_PADDING_PREFIX_RESERVED 0 /**< @ingroup icp_qat_hw_defs * All the bits of the padding sequence specified in * bits 56-63 of the 64-bit auth config word are set * to 0 (reserved) if the padding override bit is set * to 0, indicating default padding. */ /** *************************************************************************************** * @ingroup icp_qat_hw_defs * * @description * The derived configuration word for the auth slice is based on the inputs * of mode, algorithm type and compare length. The total size of the auth * config word in the setup block is 64 bits however the size of the value * returned by this macro is assumed to be only 32 bits (for now) and sets * the lower 32 bits of the auth config word. Unfortunately, changing the * size of the returned value to 64 bits will also require changes to the * shared RAM constants table so the macro size will remain at 32 bits. * This means that the padding sequence bits specified in bits 48-51 and * 56-63 of the 64-bit auth config word are NOT included in the * ICP_QAT_HW_AUTH_CONFIG_BUILD macro and are defined in a * separate macro, namely, ICP_QAT_HW_AUTH_CONFIG_BUILD_UPPER. * * For the digest generation case the compare length is a don't care value. * Furthermore, if the client will be doing the digest validation, the * compare_length will not be used. * The padding and padding override bits for SHA3 are set internally * by the macro. * Padding_Disable is set it to 0 for SHA3-256 algo only i.e. we want to * enable this to provide the ability to test with h/w padding enabled. * Padding_Disable has no meaning for all non-SHA3-256 algos and is * consequently set the default of 0. * Padding Override is set to 0, implying that the padding behaviour * implemented in the SHA3-256 slice will take effect (default hardware * setting upon h/w reset). * This flag has no meaning for other algos, so is also set to the default * for non-SHA3-256 algos. * * @param mode Authentication mode to use * @param algo Auth Algorithm to use * @param cmp_len The length of the digest if the QAT is to the check * ****************************************************************************************/ #define ICP_QAT_HW_AUTH_CONFIG_BUILD(mode, algo, cmp_len) \ ((((mode)&QAT_AUTH_MODE_MASK) << QAT_AUTH_MODE_BITPOS) | \ (((algo)&QAT_AUTH_ALGO_MASK) << QAT_AUTH_ALGO_BITPOS) | \ (((algo >> 4) & QAT_AUTH_ALGO_SHA3_MASK) \ << QAT_AUTH_ALGO_SHA3_BITPOS) | \ (((QAT_AUTH_SHA3_PADDING_DISABLE_USE_DEFAULT)&QAT_AUTH_SHA3_PADDING_DISABLE_MASK) \ << QAT_AUTH_SHA3_PADDING_DISABLE_BITPOS) | \ (((QAT_AUTH_SHA3_PADDING_OVERRIDE_USE_DEFAULT)&QAT_AUTH_SHA3_PADDING_OVERRIDE_MASK) \ << QAT_AUTH_SHA3_PADDING_OVERRIDE_BITPOS) | \ (((cmp_len)&QAT_AUTH_CMP_MASK) << QAT_AUTH_CMP_BITPOS)) /** *************************************************************************************** * @ingroup icp_qat_hw_defs * * @description * This macro sets the upper 32 bits of the 64-bit auth config word. * The sequence bits specified in bits 48-51 and 56-63 of the 64-bit auth * config word are included in this macro, which is therefore assumed to * return a 32-bit value. * Note that the Padding Override bit is set in macro * ICP_QAT_HW_AUTH_CONFIG_BUILD. * Since the Padding Override is set to 0 regardless, for now, all the bits * of the padding sequence specified in bits 48-51 and 56-63 of the 64-bit * auth config word are set to 0 (reserved). Note that the bit positions of * the padding sequence bits are defined relative to the 32-bit value that * this macro returns. * ****************************************************************************************/ #define ICP_QAT_HW_AUTH_CONFIG_BUILD_UPPER \ ((((QAT_AUTH_SHA3_PROG_PADDING_POSTFIX_RESERVED)&QAT_AUTH_SHA3_PROG_PADDING_POSTFIX_MASK) \ << QAT_AUTH_SHA3_PROG_PADDING_POSTFIX_BITPOS) | \ (((QAT_AUTH_SHA3_PROG_PADDING_PREFIX_RESERVED)&QAT_AUTH_SHA3_PROG_PADDING_PREFIX_MASK) \ << QAT_AUTH_SHA3_PROG_PADDING_PREFIX_BITPOS)) /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Auth Counter structure * * @description * 32 bit counter that tracks the number of data bytes passed through * the slice. This is used by the padding logic for some algorithms. Note * only the upper 32 bits are set. * *****************************************************************************/ typedef struct icp_qat_hw_auth_counter_s { uint32_t counter; /**< Counter value */ uint32_t reserved; /**< Reserved */ } icp_qat_hw_auth_counter_t; /* Private defines */ #define QAT_AUTH_COUNT_MASK 0xFFFFFFFF /**< @ingroup icp_qat_hw_defs * Thirty two bit mask used for determining the Auth count */ #define QAT_AUTH_COUNT_BITPOS 0 /**< @ingroup icp_qat_hw_defs * Starting bit position indicating the Auth count. */ /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Macro to build the auth counter quad word * * @param val Counter value to set * *****************************************************************************/ #define ICP_QAT_HW_AUTH_COUNT_BUILD(val) \ (((val)&QAT_AUTH_COUNT_MASK) << QAT_AUTH_COUNT_BITPOS) /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the common auth parameters * @description * This part of the configuration is constant for each service * *****************************************************************************/ typedef struct icp_qat_hw_auth_setup_s { icp_qat_hw_auth_config_t auth_config; /**< Configuration word for the auth slice */ icp_qat_hw_auth_counter_t auth_counter; /**< Auth counter value for this request */ } icp_qat_hw_auth_setup_t; /* ************************************************************************* */ /* ************************************************************************* */ #define QAT_HW_DEFAULT_ALIGNMENT 8 #define QAT_HW_ROUND_UP(val, n) (((val) + ((n)-1)) & (~(n - 1))) /* State1 */ #define ICP_QAT_HW_NULL_STATE1_SZ 32 /**< @ingroup icp_qat_hw_defs * State1 block size for NULL hashing */ #define ICP_QAT_HW_MD5_STATE1_SZ 16 /**< @ingroup icp_qat_hw_defs * State1 block size for MD5 */ #define ICP_QAT_HW_SHA1_STATE1_SZ 20 /**< @ingroup icp_qat_hw_defs * Define the state1 block size for SHA1 - Note that for the QAT HW the state * is rounded to the nearest 8 byte multiple */ #define ICP_QAT_HW_SHA224_STATE1_SZ 32 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA24 */ #define ICP_QAT_HW_SHA3_224_STATE1_SZ 28 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA3_224 */ #define ICP_QAT_HW_SHA256_STATE1_SZ 32 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA256 */ #define ICP_QAT_HW_SHA3_256_STATE1_SZ 32 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA3_256 */ #define ICP_QAT_HW_SHA384_STATE1_SZ 64 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA384 */ #define ICP_QAT_HW_SHA3_384_STATE1_SZ 48 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA3_384 */ #define ICP_QAT_HW_SHA512_STATE1_SZ 64 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA512 */ #define ICP_QAT_HW_SHA3_512_STATE1_SZ 64 /**< @ingroup icp_qat_hw_defs * State1 block size for SHA3_512 */ #define ICP_QAT_HW_AES_XCBC_MAC_STATE1_SZ 16 /**< @ingroup icp_qat_hw_defs * State1 block size for XCBC */ #define ICP_QAT_HW_AES_CBC_MAC_STATE1_SZ 16 /**< @ingroup icp_qat_hw_defs * State1 block size for CBC */ #define ICP_QAT_HW_AES_F9_STATE1_SZ 32 /**< @ingroup icp_qat_hw_defs * State1 block size for AES F9 */ #define ICP_QAT_HW_KASUMI_F9_STATE1_SZ 16 /**< @ingroup icp_qat_hw_defs * State1 block size for Kasumi F9 */ #define ICP_QAT_HW_GALOIS_128_STATE1_SZ 16 /**< @ingroup icp_qat_hw_defs * State1 block size for Galois128 */ #define ICP_QAT_HW_SNOW_3G_UIA2_STATE1_SZ 8 /**< @ingroup icp_cpm_hw_defs * State1 block size for UIA2 */ #define ICP_QAT_HW_ZUC_3G_EIA3_STATE1_SZ 8 /**< @ingroup icp_cpm_hw_defs * State1 block size for EIA3 */ #define ICP_QAT_HW_SM3_STATE1_SZ 32 /**< @ingroup icp_qat_hw_defs * State1 block size for SM3 */ #define ICP_QAT_HW_SHA3_STATEFUL_STATE1_SZ 200 /** <@ingroup icp_cpm_hw_defs * State1 block size for stateful SHA3 processing*/ /* State2 */ #define ICP_QAT_HW_NULL_STATE2_SZ 32 /**< @ingroup icp_qat_hw_defs * State2 block size for NULL hashing */ #define ICP_QAT_HW_MD5_STATE2_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for MD5 */ #define ICP_QAT_HW_SHA1_STATE2_SZ 20 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA1 - Note that for the QAT HW the state is rounded * to the nearest 8 byte multiple */ #define ICP_QAT_HW_SHA224_STATE2_SZ 32 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA224 */ #define ICP_QAT_HW_SHA3_224_STATE2_SZ 0 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA3_224 */ #define ICP_QAT_HW_SHA256_STATE2_SZ 32 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA256 */ #define ICP_QAT_HW_SHA3_256_STATE2_SZ 0 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA3_256 */ #define ICP_QAT_HW_SHA384_STATE2_SZ 64 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA384 */ #define ICP_QAT_HW_SHA3_384_STATE2_SZ 0 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA3_384 */ #define ICP_QAT_HW_SHA512_STATE2_SZ 64 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA512 */ #define ICP_QAT_HW_SHA3_512_STATE2_SZ 0 /**< @ingroup icp_qat_hw_defs * State2 block size for SHA3_512 */ #define ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for XCBC */ #define ICP_QAT_HW_AES_CBC_MAC_KEY_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for CBC */ #define ICP_QAT_HW_AES_CCM_CBC_E_CTR0_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for AES Encrypted Counter 0 */ #define ICP_QAT_HW_F9_IK_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for F9 IK */ #define ICP_QAT_HW_F9_FK_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for F9 FK */ #define ICP_QAT_HW_KASUMI_F9_STATE2_SZ \ (ICP_QAT_HW_F9_IK_SZ + ICP_QAT_HW_F9_FK_SZ) /**< @ingroup icp_qat_hw_defs * State2 complete size for Kasumi F9 */ #define ICP_QAT_HW_AES_F9_STATE2_SZ ICP_QAT_HW_KASUMI_F9_STATE2_SZ /**< @ingroup icp_qat_hw_defs * State2 complete size for AES F9 */ #define ICP_QAT_HW_SNOW_3G_UIA2_STATE2_SZ 24 /**< @ingroup icp_cpm_hw_defs * State2 block size for UIA2 */ #define ICP_QAT_HW_ZUC_3G_EIA3_STATE2_SZ 32 /**< @ingroup icp_cpm_hw_defs * State2 block size for EIA3 */ #define ICP_QAT_HW_GALOIS_H_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for Galois Multiplier H */ #define ICP_QAT_HW_GALOIS_LEN_A_SZ 8 /**< @ingroup icp_qat_hw_defs * State2 block size for Galois AAD length */ #define ICP_QAT_HW_GALOIS_E_CTR0_SZ 16 /**< @ingroup icp_qat_hw_defs * State2 block size for Galois Encrypted Counter 0 */ #define ICP_QAT_HW_SM3_STATE2_SZ 32 /**< @ingroup icp_qat_hw_defs * State2 block size for SM3 */ #define ICP_QAT_HW_SHA3_STATEFUL_STATE2_SZ 208 /** <@ingroup icp_cpm_hw_defs * State2 block size for stateful SHA3 processing*/ /* ************************************************************************* */ /* ************************************************************************* */ /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of SHA512 auth algorithm processing struct * @description * This structs described the parameters to pass to the slice for * configuring it for SHA512 processing. This is the largest possible * setup block for authentication * *****************************************************************************/ typedef struct icp_qat_hw_auth_sha512_s { icp_qat_hw_auth_setup_t inner_setup; /**< Inner loop configuration word for the slice */ uint8_t state1[ICP_QAT_HW_SHA512_STATE1_SZ]; /**< Slice state1 variable */ icp_qat_hw_auth_setup_t outer_setup; /**< Outer configuration word for the slice */ uint8_t state2[ICP_QAT_HW_SHA512_STATE2_SZ]; /**< Slice state2 variable */ } icp_qat_hw_auth_sha512_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of SHA3_512 auth algorithm processing struct * @description * This structs described the parameters to pass to the slice for * configuring it for SHA3_512 processing. This is the largest possible * setup block for authentication * *****************************************************************************/ typedef struct icp_qat_hw_auth_sha3_512_s { icp_qat_hw_auth_setup_t inner_setup; /**< Inner loop configuration word for the slice */ uint8_t state1[ICP_QAT_HW_SHA3_512_STATE1_SZ]; /**< Slice state1 variable */ icp_qat_hw_auth_setup_t outer_setup; /**< Outer configuration word for the slice */ } icp_qat_hw_auth_sha3_512_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of stateful SHA3 auth algorithm processing struct * @description * This structs described the parameters to pass to the slice for * configuring it for stateful SHA3 processing. This is the largest * possible setup block for authentication * *****************************************************************************/ typedef struct icp_qat_hw_auth_sha3_stateful_s { icp_qat_hw_auth_setup_t inner_setup; /**< Inner loop configuration word for the slice */ uint8_t inner_state1[ICP_QAT_HW_SHA3_STATEFUL_STATE1_SZ]; /**< Inner hash block */ icp_qat_hw_auth_setup_t outer_setup; /**< Outer configuration word for the slice */ uint8_t outer_state1[ICP_QAT_HW_SHA3_STATEFUL_STATE1_SZ]; /**< Outer hash block */ } icp_qat_hw_auth_sha3_stateful_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Supported hardware authentication algorithms * @description * Common grouping of the auth algorithm types supported by the QAT * *****************************************************************************/ typedef union icp_qat_hw_auth_algo_blk_u { icp_qat_hw_auth_sha512_t sha512; /**< SHA512 Hashing */ icp_qat_hw_auth_sha3_stateful_t sha3_stateful; /**< Stateful SHA3 Hashing */ } icp_qat_hw_auth_algo_blk_t; #define ICP_QAT_HW_GALOIS_LEN_A_BITPOS 0 /**< @ingroup icp_qat_hw_defs * Bit position of the 32 bit A value in the 64 bit A configuration sent to * the QAT */ #define ICP_QAT_HW_GALOIS_LEN_A_MASK 0xFFFFFFFF /**< @ingroup icp_qat_hw_defs * Mask value for A value */ /* ========================================================================= */ /* CIPHER SLICE */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported Cipher Algorithm types * @description * Enumeration used to define the cipher algorithms * *****************************************************************************/ typedef enum { ICP_QAT_HW_CIPHER_ALGO_NULL = 0, /*!< Null ciphering */ ICP_QAT_HW_CIPHER_ALGO_DES = 1, /*!< DES ciphering */ ICP_QAT_HW_CIPHER_ALGO_3DES = 2, /*!< 3DES ciphering */ ICP_QAT_HW_CIPHER_ALGO_AES128 = 3, /*!< AES-128 ciphering */ ICP_QAT_HW_CIPHER_ALGO_AES192 = 4, /*!< AES-192 ciphering */ ICP_QAT_HW_CIPHER_ALGO_AES256 = 5, /*!< AES-256 ciphering */ ICP_QAT_HW_CIPHER_ALGO_ARC4 = 6, /*!< ARC4 ciphering */ ICP_QAT_HW_CIPHER_ALGO_KASUMI = 7, /*!< Kasumi */ ICP_QAT_HW_CIPHER_ALGO_SNOW_3G_UEA2 = 8, /*!< Snow_3G */ ICP_QAT_HW_CIPHER_ALGO_ZUC_3G_128_EEA3 = 9, /*!< ZUC_3G */ ICP_QAT_HW_CIPHER_ALGO_SM4 = 10, /*!< SM4 ciphering */ ICP_QAT_HW_CIPHER_ALGO_CHACHA20_POLY1305 = 11, /*!< CHACHA POLY SPC AEAD */ ICP_QAT_HW_CIPHER_DELIMITER = 12 /**< Delimiter type */ } icp_qat_hw_cipher_algo_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported cipher modes of operation * @description * Enumeration used to define the cipher slice modes. * * @Note * Only some algorithms are valid in some of the modes. If you dont know * what you are doing then refer back to the EAS * *****************************************************************************/ typedef enum { ICP_QAT_HW_CIPHER_ECB_MODE = 0, /*!< ECB mode */ ICP_QAT_HW_CIPHER_CBC_MODE = 1, /*!< CBC more */ ICP_QAT_HW_CIPHER_CTR_MODE = 2, /*!< CTR mode */ ICP_QAT_HW_CIPHER_F8_MODE = 3, /*!< F8 mode */ ICP_QAT_HW_CIPHER_AEAD_MODE = 4, /*!< AES-GCM SPC AEAD mode */ ICP_QAT_HW_CIPHER_CCM_MODE = 5, /*!< AES-CCM SPC AEAD mode */ ICP_QAT_HW_CIPHER_XTS_MODE = 6, /*!< XTS mode */ ICP_QAT_HW_CIPHER_MODE_DELIMITER = 7 /**< Delimiter type */ } icp_qat_hw_cipher_mode_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Cipher Configuration Struct * * @description * Configuration data used for setting up the QAT Cipher Slice * *****************************************************************************/ typedef struct icp_qat_hw_cipher_config_s { uint32_t val; /**< Cipher slice configuration */ uint32_t reserved; /**< Reserved */ } icp_qat_hw_cipher_config_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Cipher Configuration Struct * * @description * Configuration data used for setting up the QAT UCS Cipher Slice * *****************************************************************************/ typedef struct icp_qat_hw_ucs_cipher_config_s { uint32_t val; /**< Cipher slice configuration */ uint32_t reserved[3]; /**< Reserved */ } icp_qat_hw_ucs_cipher_config_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the cipher direction * @description * Enumeration which is used to define the cipher direction to apply * *****************************************************************************/ typedef enum { /*!< Flag to indicate that encryption is required */ ICP_QAT_HW_CIPHER_ENCRYPT = 0, /*!< Flag to indicate that decryption is required */ ICP_QAT_HW_CIPHER_DECRYPT = 1, } icp_qat_hw_cipher_dir_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the cipher key conversion modes * @description * Enumeration which is used to define if cipher key conversion is needed * *****************************************************************************/ typedef enum { /*!< Flag to indicate that no key convert is required */ ICP_QAT_HW_CIPHER_NO_CONVERT = 0, /*!< Flag to indicate that key conversion is required */ ICP_QAT_HW_CIPHER_KEY_CONVERT = 1, } icp_qat_hw_cipher_convert_t; /* Private defines */ /* Note: Bit positions have been arranged for little endian ordering */ #define QAT_CIPHER_MODE_BITPOS 4 /**< @ingroup icp_qat_hw_defs * Define for the cipher mode bit position */ #define QAT_CIPHER_MODE_MASK 0xF /**< @ingroup icp_qat_hw_defs * Define for the cipher mode mask (four bits) */ #define QAT_CIPHER_ALGO_BITPOS 0 /**< @ingroup icp_qat_hw_defs * Define for the cipher algo bit position */ #define QAT_CIPHER_ALGO_MASK 0xF /**< @ingroup icp_qat_hw_defs * Define for the cipher algo mask (four bits) */ #define QAT_CIPHER_CONVERT_BITPOS 9 /**< @ingroup icp_qat_hw_defs * Define the cipher convert key bit position */ #define QAT_CIPHER_CONVERT_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Define for the cipher convert key mask (one bit)*/ #define QAT_CIPHER_DIR_BITPOS 8 /**< @ingroup icp_qat_hw_defs * Define for the cipher direction bit position */ #define QAT_CIPHER_DIR_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Define for the cipher direction mask (one bit) */ #define QAT_CIPHER_AEAD_HASH_CMP_LEN_MASK 0x1F /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD Hash compare length mask (5 bits)*/ #define QAT_CIPHER_AEAD_HASH_CMP_LEN_BITPOS 10 /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD Hash compare length (5 bits)*/ #define QAT_CIPHER_AEAD_AAD_SIZE_LOWER_MASK 0xFF /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD AAD size lower byte mask */ #define QAT_CIPHER_AEAD_AAD_SIZE_UPPER_MASK 0x3F /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD AAD size upper 6 bits mask */ #define QAT_CIPHER_AEAD_AAD_UPPER_SHIFT 8 /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD AAD size Upper byte shift */ #define QAT_CIPHER_AEAD_AAD_LOWER_SHIFT 24 /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD AAD size Lower byte shift */ #define QAT_CIPHER_AEAD_AAD_SIZE_BITPOS 16 /**< @ingroup icp_qat_hw_defs * Define for the cipher AEAD AAD size (14 bits)*/ #define QAT_CIPHER_MODE_F8_KEY_SZ_MULT 2 /**< @ingroup icp_qat_hw_defs * Define for the cipher mode F8 key size */ #define QAT_CIPHER_MODE_XTS_KEY_SZ_MULT 2 /**< @ingroup icp_qat_hw_defs * Define for the cipher XTS mode key size */ #define QAT_CIPHER_MODE_UCS_XTS_KEY_SZ_MULT 1 /**< @ingroup icp_qat_hw_defs * Define for the UCS cipher XTS mode key size */ /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Build the cipher configuration field * * @param mode Cipher Mode to use * @param algo Cipher Algorithm to use * @param convert Specify if the key is to be converted * @param dir Specify the cipher direction either encrypt or decrypt * *****************************************************************************/ #define ICP_QAT_HW_CIPHER_CONFIG_BUILD( \ mode, algo, convert, dir, aead_hash_cmp_len) \ ((((mode)&QAT_CIPHER_MODE_MASK) << QAT_CIPHER_MODE_BITPOS) | \ (((algo)&QAT_CIPHER_ALGO_MASK) << QAT_CIPHER_ALGO_BITPOS) | \ (((convert)&QAT_CIPHER_CONVERT_MASK) << QAT_CIPHER_CONVERT_BITPOS) | \ (((dir)&QAT_CIPHER_DIR_MASK) << QAT_CIPHER_DIR_BITPOS) | \ (((aead_hash_cmp_len)&QAT_CIPHER_AEAD_HASH_CMP_LEN_MASK) \ << QAT_CIPHER_AEAD_HASH_CMP_LEN_BITPOS)) /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Build the second QW of cipher slice config * * @param aad_size Specify the size of associated authentication data * for AEAD processing * ******************************************************************************/ #define ICP_QAT_HW_CIPHER_CONFIG_BUILD_UPPER(aad_size) \ (((((aad_size) >> QAT_CIPHER_AEAD_AAD_UPPER_SHIFT) & \ QAT_CIPHER_AEAD_AAD_SIZE_UPPER_MASK) \ << QAT_CIPHER_AEAD_AAD_SIZE_BITPOS) | \ (((aad_size)&QAT_CIPHER_AEAD_AAD_SIZE_LOWER_MASK) \ << QAT_CIPHER_AEAD_AAD_LOWER_SHIFT)) #define ICP_QAT_HW_DES_BLK_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the block size for DES. * This used as either the size of the IV or CTR input value */ #define ICP_QAT_HW_3DES_BLK_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the processing block size for 3DES */ #define ICP_QAT_HW_NULL_BLK_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the processing block size for NULL */ #define ICP_QAT_HW_AES_BLK_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the processing block size for AES 128, 192 and 256 */ #define ICP_QAT_HW_KASUMI_BLK_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the processing block size for KASUMI */ #define ICP_QAT_HW_SNOW_3G_BLK_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the processing block size for SNOW_3G */ #define ICP_QAT_HW_ZUC_3G_BLK_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the processing block size for ZUC_3G */ #define ICP_QAT_HW_NULL_KEY_SZ 256 /**< @ingroup icp_qat_hw_defs * Define the key size for NULL */ #define ICP_QAT_HW_DES_KEY_SZ 8 /**< @ingroup icp_qat_hw_defs * Define the key size for DES */ #define ICP_QAT_HW_3DES_KEY_SZ 24 /**< @ingroup icp_qat_hw_defs * Define the key size for 3DES */ #define ICP_QAT_HW_AES_128_KEY_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the key size for AES128 */ #define ICP_QAT_HW_AES_192_KEY_SZ 24 /**< @ingroup icp_qat_hw_defs * Define the key size for AES192 */ #define ICP_QAT_HW_AES_256_KEY_SZ 32 /**< @ingroup icp_qat_hw_defs * Define the key size for AES256 */ /* AES UCS */ #define ICP_QAT_HW_UCS_AES_128_KEY_SZ ICP_QAT_HW_AES_128_KEY_SZ /**< @ingroup icp_qat_hw_defs * Define the key size for AES128 for UCS slice*/ #define ICP_QAT_HW_UCS_AES_192_KEY_SZ 32 /**< @ingroup icp_qat_hw_defs * Define the key size for AES192 for UCS slice*/ #define ICP_QAT_HW_UCS_AES_256_KEY_SZ ICP_QAT_HW_AES_256_KEY_SZ /**< @ingroup icp_qat_hw_defs * Define the key size for AES256 for UCS slice*/ #define ICP_QAT_HW_AES_128_F8_KEY_SZ \ (ICP_QAT_HW_AES_128_KEY_SZ * QAT_CIPHER_MODE_F8_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES128 F8 */ #define ICP_QAT_HW_AES_192_F8_KEY_SZ \ (ICP_QAT_HW_AES_192_KEY_SZ * QAT_CIPHER_MODE_F8_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES192 F8 */ #define ICP_QAT_HW_AES_256_F8_KEY_SZ \ (ICP_QAT_HW_AES_256_KEY_SZ * QAT_CIPHER_MODE_F8_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES256 F8 */ #define ICP_QAT_HW_AES_128_XTS_KEY_SZ \ (ICP_QAT_HW_AES_128_KEY_SZ * QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES128 XTS */ #define ICP_QAT_HW_AES_256_XTS_KEY_SZ \ (ICP_QAT_HW_AES_256_KEY_SZ * QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES256 XTS */ #define ICP_QAT_HW_UCS_AES_128_XTS_KEY_SZ \ (ICP_QAT_HW_UCS_AES_128_KEY_SZ * QAT_CIPHER_MODE_UCS_XTS_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES128 XTS for the UCS Slice*/ #define ICP_QAT_HW_UCS_AES_256_XTS_KEY_SZ \ (ICP_QAT_HW_UCS_AES_256_KEY_SZ * QAT_CIPHER_MODE_UCS_XTS_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES256 XTS for the UCS Slice*/ #define ICP_QAT_HW_KASUMI_KEY_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the key size for Kasumi */ #define ICP_QAT_HW_KASUMI_F8_KEY_SZ \ (ICP_QAT_HW_KASUMI_KEY_SZ * QAT_CIPHER_MODE_F8_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for Kasumi F8 */ #define ICP_QAT_HW_AES_128_XTS_KEY_SZ \ (ICP_QAT_HW_AES_128_KEY_SZ * QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES128 XTS */ #define ICP_QAT_HW_AES_256_XTS_KEY_SZ \ (ICP_QAT_HW_AES_256_KEY_SZ * QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) /**< @ingroup icp_qat_hw_defs * Define the key size for AES256 XTS */ #define ICP_QAT_HW_ARC4_KEY_SZ 256 /**< @ingroup icp_qat_hw_defs * Define the key size for ARC4 */ #define ICP_QAT_HW_SNOW_3G_UEA2_KEY_SZ 16 /**< @ingroup icp_cpm_hw_defs * Define the key size for SNOW_3G_UEA2 */ #define ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ 16 /**< @ingroup icp_cpm_hw_defs * Define the iv size for SNOW_3G_UEA2 */ #define ICP_QAT_HW_ZUC_3G_EEA3_KEY_SZ 16 /**< @ingroup icp_cpm_hw_defs * Define the key size for ZUC_3G_EEA3 */ #define ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ 16 /**< @ingroup icp_cpm_hw_defs * Define the iv size for ZUC_3G_EEA3 */ #define ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR 2 /**< @ingroup icp_cpm_hw_defs * Number of the HW register to clear in F8 mode */ /**< @ingroup icp_qat_hw_defs * Define the State/ Initialization Vector size for CHACHAPOLY */ #define ICP_QAT_HW_CHACHAPOLY_KEY_SZ 32 /**< @ingroup icp_qat_hw_defs * Define the key size for CHACHA20-Poly1305*/ #define ICP_QAT_HW_CHACHAPOLY_IV_SZ 12 /**< @ingroup icp_qat_hw_defs * Define the block size for CHACHA20-Poly1305*/ #define ICP_QAT_HW_CHACHAPOLY_BLK_SZ 64 /**< @ingroup icp_qat_hw_defs * Define the State/ Initialization Vector size for CHACHA20-Poly1305 */ #define ICP_QAT_HW_CHACHAPOLY_CTR_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the key size for CHACHA20-Poly1305*/ #define ICP_QAT_HW_SPC_CTR_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the Single Pass tag size*/ #define ICP_QAT_HW_CHACHAPOLY_ICV__SZ 16 /**< @ingroup icp_qat_hw_defs * Define the key size for CHACHA20-Poly1305*/ #define ICP_QAT_HW_CHACHAPOLY_AAD_MAX_LOG 14 /**< @ingroup icp_qat_hw_defs * Define the key size for CHACHA20-Poly1305*/ #define ICP_QAT_HW_SM4_BLK_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the processing block size for SM4 */ #define ICP_QAT_HW_SM4_KEY_SZ 16 /**< @ingroup icp_qat_hw_defs * Number of the HW register to clear in F8 mode */ #define ICP_QAT_HW_SM4_IV_SZ 16 /**< @ingroup icp_qat_hw_defs * Define the key size for SM4 */ /* * SHRAM constants definitions */ #define INIT_SHRAM_CONSTANTS_TABLE_SZ (1024) #define SHRAM_CONSTANTS_TABLE_SIZE_QWS (INIT_SHRAM_CONSTANTS_TABLE_SZ / 4 / 2) /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of AES-256 F8 cipher algorithm processing struct * @description * This structs described the parameters to pass to the slice for * configuring it for AES-256 F8 processing * *****************************************************************************/ typedef struct icp_qat_hw_cipher_aes256_f8_s { icp_qat_hw_cipher_config_t cipher_config; /**< Cipher configuration word for the slice set to * AES-256 and the F8 mode */ uint8_t key[ICP_QAT_HW_AES_256_F8_KEY_SZ]; /**< Cipher key */ } icp_qat_hw_cipher_aes256_f8_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Supported hardware cipher algorithms * @description * Common grouping of the cipher algorithm types supported by the QAT. * This is the largest possible cipher setup block size * *****************************************************************************/ typedef union icp_qat_hw_cipher_algo_blk_u { icp_qat_hw_cipher_aes256_f8_t aes256_f8; /**< AES-256 F8 Cipher */ } icp_qat_hw_cipher_algo_blk_t; /* ========================================================================= */ /* TRNG SLICE */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported TRNG configuration modes * @description * Enumeration used to define the TRNG modes. Used by clients when * configuring the TRNG for use * *****************************************************************************/ typedef enum { ICP_QAT_HW_TRNG_DBL = 0, /*!< TRNG Disabled mode */ ICP_QAT_HW_TRNG_NHT = 1, /*!< TRNG Normal Health Test mode */ ICP_QAT_HW_TRNG_KAT = 4, /*!< TRNG Known Answer Test mode */ ICP_QAT_HW_TRNG_DELIMITER = 8 /**< Delimiter type */ } icp_qat_hw_trng_cfg_mode_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported TRNG KAT (known answer test) modes * @description * Enumeration which is used to define the TRNG KAT modes. Used by clients * when configuring the TRNG for testing * *****************************************************************************/ typedef enum { ICP_QAT_HW_TRNG_NEG_0 = 0, /*!< TRNG Neg Zero Test */ ICP_QAT_HW_TRNG_NEG_1 = 1, /*!< TRNG Neg One Test */ ICP_QAT_HW_TRNG_POS = 2, /*!< TRNG POS Test */ ICP_QAT_HW_TRNG_POS_VNC = 3, /*!< TRNG POS VNC Test */ ICP_QAT_HW_TRNG_KAT_DELIMITER = 4 /**< Delimiter type */ } icp_qat_hw_trng_kat_mode_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * TRNG mode configuration structure. * * @description * Definition of the format of the TRNG slice configuration. Used * internally by the QAT FW for configuration of the KAT unit or the * TRNG depending on the slice command i.e. either a set_slice_config or * slice_wr_KAT_type * *****************************************************************************/ typedef struct icp_qat_hw_trng_config_s { uint32_t val; /**< Configuration used for setting up the TRNG slice */ uint32_t reserved; /**< Reserved */ } icp_qat_hw_trng_config_t; /* Private Defines */ /* Note: Bit positions have been arranged for little endian ordering */ #define QAT_TRNG_CONFIG_MODE_MASK 0x7 /**< @ingroup icp_qat_hw_defs * Mask for the TRNG configuration mode. (Three bits) */ #define QAT_TRNG_CONFIG_MODE_BITPOS 5 /**< @ingroup icp_qat_hw_defs * TRNG configuration mode bit positions start */ #define QAT_TRNG_KAT_MODE_MASK 0x3 /**< @ingroup icp_qat_hw_defs * Mask of two bits for the TRNG known answer test mode */ #define QAT_TRNG_KAT_MODE_BITPOS 6 /**< @ingroup icp_qat_hw_defs * TRNG known answer test mode bit positions start */ /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Build the configuration byte for the TRNG slice based on the mode * * @param mode Configuration mode parameter * *****************************************************************************/ #define ICP_QAT_HW_TRNG_CONFIG_MODE_BUILD(mode) \ (((mode)&QAT_TRNG_CONFIG_MODE_MASK) << QAT_TRNG_CONFIG_MODE_BITPOS) /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Build the configuration byte for the TRNG KAT based on the mode * * @param mode Configuration mode parameter * *****************************************************************************/ #define ICP_QAT_HW_TRNG_KAT_MODE_BUILD(mode) \ ((((mode)&QAT_TRNG_KAT_MODE_MASK) << QAT_TRNG_KAT_MODE_BITPOS)) /** ***************************************************************************** * @ingroup icp_qat_hw_defs * TRNG test status structure. * * @description * Definition of the format of the TRNG slice test status structure. Used * internally by the QAT FW. * *****************************************************************************/ typedef struct icp_qat_hw_trng_test_status_s { uint32_t status; /**< Status used for setting up the TRNG slice */ uint32_t fail_count; /**< Comparator fail count */ } icp_qat_hw_trng_test_status_t; #define ICP_QAT_HW_TRNG_TEST_NO_FAILURES 1 /**< @ingroup icp_qat_hw_defs * Flag to indicate that there were no Test Failures */ #define ICP_QAT_HW_TRNG_TEST_FAILURES_FOUND 0 /**< @ingroup icp_qat_hw_defs * Flag to indicate that there were Test Failures */ #define ICP_QAT_HW_TRNG_TEST_STATUS_VALID 1 /**< @ingroup icp_qat_hw_defs * Flag to indicate that there is no valid Test output */ #define ICP_QAT_HW_TRNG_TEST_STATUS_INVALID 0 /**< @ingroup icp_qat_hw_defs * Flag to indicate that the Test output is still invalid */ /* Private defines */ #define QAT_TRNG_TEST_FAILURE_FLAG_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Mask of one bit used to determine the TRNG Test pass/fail */ #define QAT_TRNG_TEST_FAILURE_FLAG_BITPOS 4 /**< @ingroup icp_qat_hw_defs * Flag position to indicate that the TRNG Test status is pass of fail */ #define QAT_TRNG_TEST_STATUS_MASK 0x1 /**< @ingroup icp_qat_hw_defs - * Mask of one bit used to determine the TRNG Test staus */ + * Mask of one bit used to determine the TRNG Test status */ #define QAT_TRNG_TEST_STATUS_BITPOS 1 /**< @ingroup icp_qat_hw_defs * Flag position to indicate the TRNG Test status */ /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Extract the fail bit for the TRNG slice * * @param status TRNG status value * *****************************************************************************/ #define ICP_QAT_HW_TRNG_FAIL_FLAG_GET(status) \ (((status) >> QAT_TRNG_TEST_FAILURE_FLAG_BITPOS) & \ QAT_TRNG_TEST_FAILURE_FLAG_MASK) /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Extract the status valid bit for the TRNG slice * * @param status TRNG status value * *****************************************************************************/ #define ICP_QAT_HW_TRNG_STATUS_VALID_GET(status) \ (((status) >> QAT_TRNG_TEST_STATUS_BITPOS) & QAT_TRNG_TEST_STATUS_MASK) /** ***************************************************************************** * @ingroup icp_qat_hw_defs * TRNG entropy counters * * @description * Definition of the format of the TRNG entropy counters. Used internally * by the QAT FW. * *****************************************************************************/ typedef struct icp_qat_hw_trng_entropy_counts_s { uint64_t raw_ones_count; /**< Count of raw ones of entropy */ uint64_t raw_zeros_count; /**< Count of raw zeros of entropy */ uint64_t cond_ones_count; /**< Count of conditioned ones entropy */ uint64_t cond_zeros_count; /**< Count of conditioned zeros entropy */ } icp_qat_hw_trng_entropy_counts_t; /* Private defines */ #define QAT_HW_TRNG_ENTROPY_STS_RSVD_SZ 4 /**< @ingroup icp_qat_hw_defs * TRNG entropy status reserved size in bytes */ /** ***************************************************************************** * @ingroup icp_qat_hw_defs * TRNG entropy available status. * * @description * Definition of the format of the TRNG slice entropy status available. * struct. Used internally by the QAT FW. * *****************************************************************************/ typedef struct icp_qat_hw_trng_entropy_status_s { uint32_t status; /**< Entropy status in the TRNG */ uint8_t reserved[QAT_HW_TRNG_ENTROPY_STS_RSVD_SZ]; /**< Reserved */ } icp_qat_hw_trng_entropy_status_t; #define ICP_QAT_HW_TRNG_ENTROPY_AVAIL 1 /**< @ingroup icp_qat_hw_defs * Flag indicating that entropy data is available in the QAT TRNG slice */ #define ICP_QAT_HW_TRNG_ENTROPY_NOT_AVAIL 0 /**< @ingroup icp_qat_hw_defs * Flag indicating that no entropy data is available in the QAT TRNG slice */ /* Private defines */ #define QAT_TRNG_ENTROPY_STATUS_MASK 1 /**< @ingroup icp_qat_hw_defs * Mask of one bit used to determine the TRNG Entropy status */ #define QAT_TRNG_ENTROPY_STATUS_BITPOS 0 /**< @ingroup icp_qat_hw_defs * Starting bit position for TRNG Entropy status. */ /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Extract the entropy available status bit * * @param status TRNG status value * *****************************************************************************/ #define ICP_QAT_HW_TRNG_ENTROPY_STATUS_GET(status) \ (((status) >> QAT_TRNG_ENTROPY_STATUS_BITPOS) & \ QAT_TRNG_ENTROPY_STATUS_MASK) /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Entropy seed data * * @description * This type is used for the definition of the entropy generated by a read * of the TRNG slice * *****************************************************************************/ typedef uint64_t icp_qat_hw_trng_entropy; /* ========================================================================= */ /* COMPRESSION SLICE */ /* ========================================================================= */ /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported compression directions * @description * Enumeration used to define the compression directions * *****************************************************************************/ typedef enum { ICP_QAT_HW_COMPRESSION_DIR_COMPRESS = 0, /*!< Compression */ ICP_QAT_HW_COMPRESSION_DIR_DECOMPRESS = 1, /*!< Decompression */ ICP_QAT_HW_COMPRESSION_DIR_DELIMITER = 2 /**< Delimiter type */ } icp_qat_hw_compression_direction_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported delayed match modes * @description * Enumeration used to define whether delayed match is enabled * *****************************************************************************/ typedef enum { ICP_QAT_HW_COMPRESSION_DELAYED_MATCH_DISABLED = 0, /*!< Delayed match disabled */ ICP_QAT_HW_COMPRESSION_DELAYED_MATCH_ENABLED = 1, /*!< Delayed match enabled Note: This is the only valid mode - refer to CPM1.6 SAS */ ICP_QAT_HW_COMPRESSION_DELAYED_MATCH_DELIMITER = 2 /**< Delimiter type */ } icp_qat_hw_compression_delayed_match_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported compression algorithms * @description * Enumeration used to define the compression algorithms * *****************************************************************************/ typedef enum { ICP_QAT_HW_COMPRESSION_ALGO_DEFLATE = 0, /*!< Deflate compression */ ICP_QAT_HW_COMPRESSION_DEPRECATED = 1, /*!< Deprecated */ ICP_QAT_HW_COMPRESSION_ALGO_DELIMITER = 2 /**< Delimiter type */ } icp_qat_hw_compression_algo_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported compression depths * @description * Enumeration used to define the compression slice depths. * *****************************************************************************/ typedef enum { ICP_QAT_HW_COMPRESSION_DEPTH_1 = 0, /*!< Search depth 1 (Fastest least exhaustive) */ ICP_QAT_HW_COMPRESSION_DEPTH_4 = 1, /*!< Search depth 4 */ ICP_QAT_HW_COMPRESSION_DEPTH_8 = 2, /*!< Search depth 8 */ ICP_QAT_HW_COMPRESSION_DEPTH_16 = 3, /*!< Search depth 16 */ ICP_QAT_HW_COMPRESSION_DEPTH_128 = 4, /*!< Search depth 128 (Slowest, most exhaustive) */ ICP_QAT_HW_COMPRESSION_DEPTH_DELIMITER = 5 /**< Delimiter type */ } icp_qat_hw_compression_depth_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Definition of the supported file types * @description * Enumeration used to define the compression file types. * *****************************************************************************/ typedef enum { ICP_QAT_HW_COMPRESSION_FILE_TYPE_0 = 0, /*!< Use Static Trees */ ICP_QAT_HW_COMPRESSION_FILE_TYPE_1 = 1, /*!< Use Semi-Dynamic Trees at offset 0 */ ICP_QAT_HW_COMPRESSION_FILE_TYPE_2 = 2, /*!< Use Semi-Dynamic Trees at offset 320 */ ICP_QAT_HW_COMPRESSION_FILE_TYPE_3 = 3, /*!< Use Semi-Dynamic Trees at offset 640 */ ICP_QAT_HW_COMPRESSION_FILE_TYPE_4 = 4, /*!< Use Semi-Dynamic Trees at offset 960 */ ICP_QAT_HW_COMPRESSION_FILE_TYPE_DELIMITER = 5 /**< Delimiter type */ } icp_qat_hw_compression_file_type_t; typedef enum { BNP_SKIP_MODE_DISABLED = 0, BNP_SKIP_MODE_AT_START = 1, BNP_SKIP_MODE_AT_END = 2, BNP_SKIP_MODE_STRIDE = 3 } icp_qat_bnp_skip_mode_t; /** ***************************************************************************** * @ingroup icp_qat_hw_defs * Compression Configuration Struct * * @description * Configuration data used for setting up the QAT Compression Slice * *****************************************************************************/ typedef struct icp_qat_hw_compression_config_s { uint32_t lower_val; /**< Compression slice configuration lower LW */ uint32_t upper_val; /**< Compression slice configuration upper LW */ } icp_qat_hw_compression_config_t; /* Private defines */ #define QAT_COMPRESSION_DIR_BITPOS 4 /**< @ingroup icp_qat_hw_defs * Define for the compression direction bit position */ #define QAT_COMPRESSION_DIR_MASK 0x7 /**< @ingroup icp_qat_hw_defs * Define for the compression direction mask (three bits) */ #define QAT_COMPRESSION_DELAYED_MATCH_BITPOS 16 /**< @ingroup icp_qat_hw_defs * Define for the compression delayed match bit position */ #define QAT_COMPRESSION_DELAYED_MATCH_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Define for the delayed match mask (one bit) */ #define QAT_COMPRESSION_ALGO_BITPOS 31 /**< @ingroup icp_qat_hw_defs * Define for the compression algorithm bit position */ #define QAT_COMPRESSION_ALGO_MASK 0x1 /**< @ingroup icp_qat_hw_defs * Define for the compression algorithm mask (one bit) */ #define QAT_COMPRESSION_DEPTH_BITPOS 28 /**< @ingroup icp_qat_hw_defs * Define for the compression depth bit position */ #define QAT_COMPRESSION_DEPTH_MASK 0x7 /**< @ingroup icp_qat_hw_defs * Define for the compression depth mask (three bits) */ #define QAT_COMPRESSION_FILE_TYPE_BITPOS 24 /**< @ingroup icp_qat_hw_defs * Define for the compression file type bit position */ #define QAT_COMPRESSION_FILE_TYPE_MASK 0xF /**< @ingroup icp_qat_hw_defs * Define for the compression file type mask (four bits) */ /** ****************************************************************************** * @ingroup icp_qat_hw_defs * * @description * Build the compression slice configuration field * * @param dir Compression Direction to use, compress or decompress * @param delayed Specify if delayed match should be enabled * @param algo Compression algorithm to use * @param depth Compression search depth to use * @param filetype Compression file type to use, static or semi dynamic trees * *****************************************************************************/ #define ICP_QAT_HW_COMPRESSION_CONFIG_BUILD( \ dir, delayed, algo, depth, filetype) \ ((((dir)&QAT_COMPRESSION_DIR_MASK) << QAT_COMPRESSION_DIR_BITPOS) | \ (((delayed)&QAT_COMPRESSION_DELAYED_MATCH_MASK) \ << QAT_COMPRESSION_DELAYED_MATCH_BITPOS) | \ (((algo)&QAT_COMPRESSION_ALGO_MASK) << QAT_COMPRESSION_ALGO_BITPOS) | \ (((depth)&QAT_COMPRESSION_DEPTH_MASK) \ << QAT_COMPRESSION_DEPTH_BITPOS) | \ (((filetype)&QAT_COMPRESSION_FILE_TYPE_MASK) \ << QAT_COMPRESSION_FILE_TYPE_BITPOS)) /* ========================================================================= */ /* TRANSLATOR SLICE */ /* ========================================================================= */ /**< Translator slice configuration is set internally by the firmware */ #endif /* _ICP_QAT_HW_H_ */ diff --git a/sys/dev/qat/qat_api/firmware/include/icp_qat_hw_20_comp.h b/sys/dev/qat/qat_api/firmware/include/icp_qat_hw_20_comp.h index 8a149edd8d59..df1de387ce42 100644 --- a/sys/dev/qat/qat_api/firmware/include/icp_qat_hw_20_comp.h +++ b/sys/dev/qat/qat_api/firmware/include/icp_qat_hw_20_comp.h @@ -1,312 +1,311 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file icp_qat_hw_2x_comp.h * @defgroup ICP QAT HW accessors for using the for 2.x Compression Slice * definitions * @ingroup icp_qat_hw_2x_comp * @description * This file documents definitions for the QAT HW COMP SLICE * *****************************************************************************/ #ifndef _ICP_QAT_HW_20_COMP_H_ #define _ICP_QAT_HW_20_COMP_H_ #include "icp_qat_hw_20_comp_defs.h" /* For HW definitions */ #include "icp_qat_fw.h" /* For Set Field Macros. */ - #define BYTE_SWAP_32 __builtin_bswap32 /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Definition of the hw config csr. This representation has to be further * processed by the corresponding config build function. * *****************************************************************************/ typedef struct icp_qat_hw_comp_20_config_csr_lower_s { /* Fields programmable directly by the SW. */ icp_qat_hw_comp_20_extended_delay_match_mode_t edmm; icp_qat_hw_comp_20_hw_comp_format_t algo; icp_qat_hw_comp_20_search_depth_t sd; icp_qat_hw_comp_20_hbs_control_t hbs; /* Fields programmable directly by the FW. */ /* Block Drop enable. (Set by FW) */ icp_qat_hw_comp_20_abd_t abd; icp_qat_hw_comp_20_lllbd_ctrl_t lllbd; /* Advanced HW control (Set to default vals) */ icp_qat_hw_comp_20_min_match_control_t mmctrl; icp_qat_hw_comp_20_skip_hash_collision_t hash_col; icp_qat_hw_comp_20_skip_hash_update_t hash_update; icp_qat_hw_comp_20_byte_skip_t skip_ctrl; } icp_qat_hw_comp_20_config_csr_lower_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Build the longword as expected by the HW * *****************************************************************************/ static inline uint32_t ICP_QAT_FW_COMP_20_BUILD_CONFIG_LOWER(icp_qat_hw_comp_20_config_csr_lower_t csr) { uint32_t val32 = 0; /* Programmable values */ QAT_FIELD_SET(val32, csr.algo, ICP_QAT_HW_COMP_20_CONFIG_CSR_HW_COMP_FORMAT_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_HW_COMP_FORMAT_MASK); QAT_FIELD_SET(val32, csr.sd, ICP_QAT_HW_COMP_20_CONFIG_CSR_SEARCH_DEPTH_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SEARCH_DEPTH_MASK); QAT_FIELD_SET( val32, csr.edmm, ICP_QAT_HW_COMP_20_CONFIG_CSR_EXTENDED_DELAY_MATCH_MODE_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_EXTENDED_DELAY_MATCH_MODE_MASK); QAT_FIELD_SET(val32, csr.hbs, ICP_QAT_HW_COMP_20_CONFIG_CSR_HBS_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_HBS_CONTROL_MASK); QAT_FIELD_SET(val32, csr.mmctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_MIN_MATCH_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_MIN_MATCH_CONTROL_MASK); QAT_FIELD_SET(val32, csr.hash_col, ICP_QAT_HW_COMP_20_CONFIG_CSR_SKIP_HASH_COLLISION_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SKIP_HASH_COLLISION_MASK); QAT_FIELD_SET(val32, csr.hash_update, ICP_QAT_HW_COMP_20_CONFIG_CSR_SKIP_HASH_UPDATE_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SKIP_HASH_UPDATE_MASK); QAT_FIELD_SET(val32, csr.skip_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_BYTE_SKIP_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_BYTE_SKIP_MASK); /* Default values. */ QAT_FIELD_SET(val32, csr.abd, ICP_QAT_HW_COMP_20_CONFIG_CSR_ABD_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_ABD_MASK); QAT_FIELD_SET(val32, csr.lllbd, ICP_QAT_HW_COMP_20_CONFIG_CSR_LLLBD_CTRL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_LLLBD_CTRL_MASK); return BYTE_SWAP_32(val32); } /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Definition of the hw config csr. This representation has to be further * processed by the corresponding config build function. * *****************************************************************************/ typedef struct icp_qat_hw_comp_20_config_csr_upper_s { icp_qat_hw_comp_20_scb_control_t scb_ctrl; icp_qat_hw_comp_20_rmb_control_t rmb_ctrl; icp_qat_hw_comp_20_som_control_t som_ctrl; icp_qat_hw_comp_20_skip_hash_rd_control_t skip_hash_ctrl; icp_qat_hw_comp_20_scb_unload_control_t scb_unload_ctrl; icp_qat_hw_comp_20_disable_token_fusion_control_t disable_token_fusion_ctrl; icp_qat_hw_comp_20_lbms_t lbms; icp_qat_hw_comp_20_scb_mode_reset_mask_t scb_mode_reset; uint16_t lazy; uint16_t nice; } icp_qat_hw_comp_20_config_csr_upper_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Build the longword as expected by the HW * *****************************************************************************/ static inline uint32_t ICP_QAT_FW_COMP_20_BUILD_CONFIG_UPPER(icp_qat_hw_comp_20_config_csr_upper_t csr) { uint32_t val32 = 0; QAT_FIELD_SET(val32, csr.scb_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_SCB_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SCB_CONTROL_MASK); QAT_FIELD_SET(val32, csr.rmb_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_RMB_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_RMB_CONTROL_MASK); QAT_FIELD_SET(val32, csr.som_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_SOM_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SOM_CONTROL_MASK); QAT_FIELD_SET(val32, csr.skip_hash_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_SKIP_HASH_RD_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SKIP_HASH_RD_CONTROL_MASK); QAT_FIELD_SET(val32, csr.scb_unload_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_SCB_UNLOAD_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SCB_UNLOAD_CONTROL_MASK); QAT_FIELD_SET( val32, csr.disable_token_fusion_ctrl, ICP_QAT_HW_COMP_20_CONFIG_CSR_DISABLE_TOKEN_FUSION_CONTROL_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_DISABLE_TOKEN_FUSION_CONTROL_MASK); QAT_FIELD_SET(val32, csr.lbms, ICP_QAT_HW_COMP_20_CONFIG_CSR_LBMS_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_LBMS_MASK); QAT_FIELD_SET(val32, csr.scb_mode_reset, ICP_QAT_HW_COMP_20_CONFIG_CSR_SCB_MODE_RESET_MASK_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_SCB_MODE_RESET_MASK_MASK); QAT_FIELD_SET(val32, csr.lazy, ICP_QAT_HW_COMP_20_CONFIG_CSR_LAZY_PARAM_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_LAZY_PARAM_MASK); QAT_FIELD_SET(val32, csr.nice, ICP_QAT_HW_COMP_20_CONFIG_CSR_NICE_PARAM_BITPOS, ICP_QAT_HW_COMP_20_CONFIG_CSR_NICE_PARAM_MASK); return BYTE_SWAP_32(val32); } /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Definition of the hw config csr. This representation has to be further * processed by the corresponding config build function. * *****************************************************************************/ typedef struct icp_qat_hw_decomp_20_config_csr_lower_s { /* Fields programmable directly by the SW. */ icp_qat_hw_decomp_20_hbs_control_t hbs; icp_qat_hw_decomp_20_lbms_t lbms; /* Advanced HW control (Set to default vals) */ icp_qat_hw_decomp_20_hw_comp_format_t algo; icp_qat_hw_decomp_20_min_match_control_t mmctrl; icp_qat_hw_decomp_20_lz4_block_checksum_present_t lbc; } icp_qat_hw_decomp_20_config_csr_lower_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Build the longword as expected by the HW * *****************************************************************************/ static inline uint32_t ICP_QAT_FW_DECOMP_20_BUILD_CONFIG_LOWER( icp_qat_hw_decomp_20_config_csr_lower_t csr) { uint32_t val32 = 0; QAT_FIELD_SET(val32, csr.hbs, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_HBS_CONTROL_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_HBS_CONTROL_MASK); QAT_FIELD_SET(val32, csr.lbms, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_LBMS_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_LBMS_MASK); QAT_FIELD_SET(val32, csr.algo, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_HW_DECOMP_FORMAT_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_HW_DECOMP_FORMAT_MASK); QAT_FIELD_SET(val32, csr.mmctrl, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_MIN_MATCH_CONTROL_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_MIN_MATCH_CONTROL_MASK); QAT_FIELD_SET( val32, csr.lbc, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_LZ4_BLOCK_CHECKSUM_PRESENT_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_LZ4_BLOCK_CHECKSUM_PRESENT_MASK); return BYTE_SWAP_32(val32); } /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Definition of the hw config csr. This representation has to be further * processed by the corresponding config build function. * *****************************************************************************/ typedef struct icp_qat_hw_decomp_20_config_csr_upper_s { /* Advanced HW control (Set to default vals) */ icp_qat_hw_decomp_20_speculative_decoder_control_t sdc; icp_qat_hw_decomp_20_reserved4_control_t res4; } icp_qat_hw_decomp_20_config_csr_upper_t; /** ***************************************************************************** * @ingroup icp_qat_fw_comn * * @description * Build the longword as expected by the HW * *****************************************************************************/ static inline uint32_t ICP_QAT_FW_DECOMP_20_BUILD_CONFIG_UPPER( icp_qat_hw_decomp_20_config_csr_upper_t csr) { uint32_t val32 = 0; QAT_FIELD_SET( val32, csr.sdc, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_SPECULATIVE_DECODER_CONTROL_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_SPECULATIVE_DECODER_CONTROL_MASK); QAT_FIELD_SET(val32, csr.res4, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_RESERVED4_CONTROL_BITPOS, ICP_QAT_HW_DECOMP_20_CONFIG_CSR_RESERVED4_CONTROL_MASK); return BYTE_SWAP_32(val32); } #endif /* ICP_QAT_HW__2X_COMP_H_ */ diff --git a/sys/dev/qat/qat_api/include/cpa.h b/sys/dev/qat/qat_api/include/cpa.h index f4baa90c45cf..f91de67caf5a 100644 --- a/sys/dev/qat/qat_api/include/cpa.h +++ b/sys/dev/qat/qat_api/include/cpa.h @@ -1,799 +1,799 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa.h * * @defgroup cpa CPA API * * @description * This is the top level API definition for Intel(R) QuickAssist Technology. * It contains structures, data types and definitions that are common * across the interface. * *****************************************************************************/ /** ***************************************************************************** * @defgroup cpa_BaseDataTypes Base Data Types * @file cpa.h * * @ingroup cpa * * @description * The base data types for the Intel CPA API. * *****************************************************************************/ #ifndef CPA_H #define CPA_H #ifdef __cplusplus extern "C" { #endif #include "cpa_types.h" /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance handle type. * * @description * Handle used to uniquely identify an instance. * * @note * Where only a single instantiation exists this field may be set to * @ref CPA_INSTANCE_HANDLE_SINGLE. * *****************************************************************************/ typedef void * CpaInstanceHandle; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Default instantiation handle value where there is only a single instance * * @description * Used as an instance handle value where only one instance exists. * *****************************************************************************/ #define CPA_INSTANCE_HANDLE_SINGLE ((CpaInstanceHandle)0) /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Physical memory address. * @description * Type for physical memory addresses. *****************************************************************************/ typedef Cpa64U CpaPhysicalAddr; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Virtual to physical address conversion routine. * * @description * This function is used to convert virtual addresses to physical * addresses. * * @context * The function shall not be called in an interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] pVirtualAddr Virtual address to be converted. * * @return * Returns the corresponding physical address. * On error, the value NULL is returned. * * @post * None * @see * None * *****************************************************************************/ typedef CpaPhysicalAddr (*CpaVirtualToPhysical)(void * pVirtualAddr); /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Flat buffer structure containing a pointer and length member. * * @description * A flat buffer structure. The data pointer, pData, is a virtual address. * An API instance may require the actual data to be in contiguous * physical memory as determined by @ref CpaInstanceInfo2. * *****************************************************************************/ typedef struct _CpaFlatBuffer { Cpa32U dataLenInBytes; /**< Data length specified in bytes. * When used as an input parameter to a function, the length specifies * the current length of the buffer. * When used as an output parameter to a function, the length passed in * specifies the maximum length of the buffer on return (i.e. the allocated * length). The implementation will not write past this length. On return, * the length is always unchanged. */ Cpa8U *pData; /**< The data pointer is a virtual address, however the actual data pointed * to is required to be in contiguous physical memory unless the field requiresPhysicallyContiguousMemory in CpaInstanceInfo2 is false. */ } CpaFlatBuffer; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Scatter/Gather buffer list containing an array of flat buffers. * * @description * A scatter/gather buffer list structure. This buffer structure is * typically used to represent a region of memory which is not * physically contiguous, by describing it as a collection of * buffers, each of which is physically contiguous. * * @note * The memory for the pPrivateMetaData member must be allocated * by the client as physically contiguous memory. When allocating * memory for pPrivateMetaData, a call to the corresponding * BufferListGetMetaSize function (e.g. cpaCyBufferListGetMetaSize) * MUST be made to determine the size of the Meta Data Buffer. The * returned size (in bytes) may then be passed in a memory allocation * routine to allocate the pPrivateMetaData memory. *****************************************************************************/ typedef struct _CpaBufferList { Cpa32U numBuffers; /**< Number of buffers in the list */ CpaFlatBuffer *pBuffers; /**< Pointer to an unbounded array containing the number of CpaFlatBuffers * defined by numBuffers */ void *pUserData; /**< This is an opaque field that is not read or modified internally. */ void *pPrivateMetaData; /**< Private representation of this buffer list. The memory for this * buffer needs to be allocated by the client as contiguous data. * The amount of memory required is returned with a call to * the corresponding BufferListGetMetaSize function. If that function * returns a size of zero then no memory needs to be allocated, and this * parameter can be NULL. */ } CpaBufferList; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Flat buffer structure with physical address. * * @description * Functions taking this structure do not need to do any virtual to * physical address translation before writing the buffer to hardware. *****************************************************************************/ typedef struct _CpaPhysFlatBuffer { Cpa32U dataLenInBytes; /**< Data length specified in bytes. * When used as an input parameter to a function, the length specifies * the current length of the buffer. * When used as an output parameter to a function, the length passed in * specifies the maximum length of the buffer on return (i.e. the allocated * length). The implementation will not write past this length. On return, * the length is always unchanged. */ Cpa32U reserved; /**< Reserved for alignment */ CpaPhysicalAddr bufferPhysAddr; /**< The physical address at which the data resides. The data pointed * to is required to be in contiguous physical memory. */ } CpaPhysFlatBuffer; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Scatter/gather list containing an array of flat buffers with * physical addresses. * * @description * Similar to @ref CpaBufferList, this buffer structure is typically * used to represent a region of memory which is not physically * contiguous, by describing it as a collection of buffers, each of * which is physically contiguous. The difference is that, in this * case, the individual "flat" buffers are represented using * physical, rather than virtual, addresses. *****************************************************************************/ typedef struct _CpaPhysBufferList { Cpa64U reserved0; /**< Reserved for internal usage */ Cpa32U numBuffers; /**< Number of buffers in the list */ Cpa32U reserved1; /**< Reserved for alignment */ CpaPhysFlatBuffer flatBuffers[]; /**< Array of flat buffer structures, of size numBuffers */ } CpaPhysBufferList; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Special value which can be taken by length fields on some of the * "data plane" APIs to indicate that the buffer in question is of * type CpaPhysBufferList, rather than simply an array of bytes. ****************************************************************************/ #define CPA_DP_BUFLIST ((Cpa32U)0xFFFFFFFF) /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * API status value type definition * * @description * This type definition is used for the return values used in all the * API functions. Common values are defined, for example see * @ref CPA_STATUS_SUCCESS, @ref CPA_STATUS_FAIL, etc. *****************************************************************************/ typedef Cpa32S CpaStatus; #define CPA_STATUS_SUCCESS (0) /**< * @ingroup cpa_BaseDataTypes * Success status value. */ #define CPA_STATUS_FAIL (-1) /**< * @ingroup cpa_BaseDataTypes * Fail status value. */ #define CPA_STATUS_RETRY (-2) /**< * @ingroup cpa_BaseDataTypes * Retry status value. */ #define CPA_STATUS_RESOURCE (-3) /**< * @ingroup cpa_BaseDataTypes * The resource that has been requested is unavailable. Refer * to relevant sections of the API for specifics on what the suggested * course of action is. */ #define CPA_STATUS_INVALID_PARAM (-4) /**< * @ingroup cpa_BaseDataTypes * Invalid parameter has been passed in. */ #define CPA_STATUS_FATAL (-5) /**< * @ingroup cpa_BaseDataTypes * A serious error has occurred. Recommended course of action * is to shutdown and restart the component. */ #define CPA_STATUS_UNSUPPORTED (-6) /**< * @ingroup cpa_BaseDataTypes * The function is not supported, at least not with the specific * parameters supplied. This may be because a particular * capability is not supported by the current implementation. */ #define CPA_STATUS_RESTARTING (-7) /**< * @ingroup cpa_BaseDataTypes * The API implementation is restarting. This may be reported if, for example, * a hardware implementation is undergoing a reset. Recommended course of * action is to retry the request. */ /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * API status string type definition * @description * This type definition is used for the generic status text strings * provided by cpaXxGetStatusText API functions. Common values are * defined, for example see @ref CPA_STATUS_STR_SUCCESS, * @ref CPA_STATUS_FAIL, etc., as well as the maximum size * @ref CPA_STATUS_MAX_STR_LENGTH_IN_BYTES. *****************************************************************************/ #define CPA_STATUS_MAX_STR_LENGTH_IN_BYTES (255) /**< * @ingroup cpa_BaseDataTypes * Maximum length of the Overall Status String (including generic and specific * strings returned by calls to cpaXxGetStatusText) */ #define CPA_STATUS_STR_SUCCESS ("Operation was successful:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_SUCCESS. */ #define CPA_STATUS_STR_FAIL ("General or unspecified error occurred:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_FAIL. */ #define CPA_STATUS_STR_RETRY ("Recoverable error occurred:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_RETRY. */ #define CPA_STATUS_STR_RESOURCE ("Required resource unavailable:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_RESOURCE. */ #define CPA_STATUS_STR_INVALID_PARAM ("Invalid parameter supplied:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_INVALID_PARAM. */ #define CPA_STATUS_STR_FATAL ("Fatal error has occurred:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_FATAL. */ #define CPA_STATUS_STR_UNSUPPORTED ("Operation not supported:") /**< * @ingroup cpa_BaseDataTypes * Status string for @ref CPA_STATUS_UNSUPPORTED. */ /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance Types * * @deprecated * As of v1.3 of the Crypto API, this enum has been deprecated, * replaced by @ref CpaAccelerationServiceType. * * @description * Enumeration of the different instance types. * *****************************************************************************/ typedef enum _CpaInstanceType { CPA_INSTANCE_TYPE_CRYPTO = 0, /**< Cryptographic instance type */ CPA_INSTANCE_TYPE_DATA_COMPRESSION, /**< Data compression instance type */ CPA_INSTANCE_TYPE_RAID, /**< RAID instance type */ CPA_INSTANCE_TYPE_XML, /**< XML instance type */ CPA_INSTANCE_TYPE_REGEX /**< Regular Expression instance type */ } CpaInstanceType CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Service Type * @description * Enumeration of the different service types. * *****************************************************************************/ typedef enum _CpaAccelerationServiceType { CPA_ACC_SVC_TYPE_CRYPTO = CPA_INSTANCE_TYPE_CRYPTO, /**< Cryptography */ CPA_ACC_SVC_TYPE_DATA_COMPRESSION = CPA_INSTANCE_TYPE_DATA_COMPRESSION, /**< Data Compression */ CPA_ACC_SVC_TYPE_PATTERN_MATCH = CPA_INSTANCE_TYPE_REGEX, /**< Pattern Match */ CPA_ACC_SVC_TYPE_RAID = CPA_INSTANCE_TYPE_RAID, /**< RAID */ CPA_ACC_SVC_TYPE_XML = CPA_INSTANCE_TYPE_XML, /**< XML */ CPA_ACC_SVC_TYPE_VIDEO_ANALYTICS, /**< Video Analytics */ CPA_ACC_SVC_TYPE_CRYPTO_ASYM, /**< Cryptography - Asymmetric service */ CPA_ACC_SVC_TYPE_CRYPTO_SYM /**< Cryptography - Symmetric service */ } CpaAccelerationServiceType; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance State * * @deprecated * As of v1.3 of the Crypto API, this enum has been deprecated, * replaced by @ref CpaOperationalState. * * @description * Enumeration of the different instance states that are possible. * *****************************************************************************/ typedef enum _CpaInstanceState { CPA_INSTANCE_STATE_INITIALISED = 0, /**< Instance is in the initialized state and ready for use. */ CPA_INSTANCE_STATE_SHUTDOWN /**< Instance is in the shutdown state and not available for use. */ } CpaInstanceState CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance operational state * @description * Enumeration of the different operational states that are possible. * *****************************************************************************/ typedef enum _CpaOperationalState { CPA_OPER_STATE_DOWN= 0, /**< Instance is not available for use. May not yet be initialized, * or stopped. */ CPA_OPER_STATE_UP /**< Instance is available for use. Has been initialized and started. */ } CpaOperationalState; #define CPA_INSTANCE_MAX_NAME_SIZE_IN_BYTES 64 /**< * @ingroup cpa_BaseDataTypes * Maximum instance info name string length in bytes */ #define CPA_INSTANCE_MAX_ID_SIZE_IN_BYTES 128 /**< * @ingroup cpa_BaseDataTypes * Maximum instance info id string length in bytes */ #define CPA_INSTANCE_MAX_VERSION_SIZE_IN_BYTES 64 /**< * @ingroup cpa_BaseDataTypes * Maximum instance info version string length in bytes */ /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance Info Structure * * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by CpaInstanceInfo2. * * @description * Structure that contains the information to describe the instance. * *****************************************************************************/ typedef struct _CpaInstanceInfo { enum _CpaInstanceType type; /**< Type definition for this instance. */ enum _CpaInstanceState state; /**< Operational state of the instance. */ Cpa8U name[CPA_INSTANCE_MAX_NAME_SIZE_IN_BYTES]; /**< Simple text string identifier for the instance. */ Cpa8U version[CPA_INSTANCE_MAX_VERSION_SIZE_IN_BYTES]; /**< Version string. There may be multiple versions of the same type of * instance accessible through a particular library. */ } CpaInstanceInfo CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Physical Instance ID * @description * Identifies the physical instance of an accelerator execution * engine. * * Accelerators grouped into "packages". Each accelerator can in * turn contain one or more execution engines. Implementations of * this API will define the packageId, acceleratorId, * executionEngineId and busAddress as appropriate for the * implementation. For example, for hardware-based accelerators, * the packageId might identify the chip, which might contain * multiple accelerators, each of which might contain multiple * execution engines. The combination of packageId, acceleratorId * and executionEngineId uniquely identifies the instance. * * Hardware based accelerators implementing this API may also provide * information on the location of the accelerator in the busAddress * field. This field will be defined as appropriate for the * implementation. For example, for PCIe attached accelerators, * the busAddress may contain the PCIe bus, device and function * number of the accelerators. * *****************************************************************************/ typedef struct _CpaPhysicalInstanceId { Cpa16U packageId; /**< Identifies the package within which the accelerator is * contained. */ Cpa16U acceleratorId; /**< Identifies the specific accelerator within the package. */ Cpa16U executionEngineId; /**< Identifies the specific execution engine within the * accelerator. */ Cpa16U busAddress; /**< Identifies the bus address associated with the accelerator * execution engine. */ Cpa32U kptAcHandle; /**< Identifies the achandle of the accelerator. */ } CpaPhysicalInstanceId; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance Info Structure, version 2 * @description * Structure that contains the information to describe the instance. * *****************************************************************************/ typedef struct _CpaInstanceInfo2 { CpaAccelerationServiceType accelerationServiceType; /**< Type of service provided by this instance. */ #define CPA_INST_VENDOR_NAME_SIZE CPA_INSTANCE_MAX_NAME_SIZE_IN_BYTES /**< Maximum length of the vendor name. */ Cpa8U vendorName[CPA_INST_VENDOR_NAME_SIZE]; /**< String identifying the vendor of the accelerator. */ #define CPA_INST_PART_NAME_SIZE CPA_INSTANCE_MAX_NAME_SIZE_IN_BYTES /**< Maximum length of the part name. */ Cpa8U partName[CPA_INST_PART_NAME_SIZE]; /**< String identifying the part (name and/or number). */ #define CPA_INST_SW_VERSION_SIZE CPA_INSTANCE_MAX_VERSION_SIZE_IN_BYTES /**< Maximum length of the software version string. */ Cpa8U swVersion[CPA_INST_SW_VERSION_SIZE]; /**< String identifying the version of the software associated with * the instance. For hardware-based implementations of the API, * this should be the driver version. For software-based * implementations of the API, this should be the version of the * library. * * Note that this should NOT be used to store the version of the * API, nor should it be used to report the hardware revision * (which can be captured as part of the @ref partName, if required). */ #define CPA_INST_NAME_SIZE CPA_INSTANCE_MAX_NAME_SIZE_IN_BYTES /**< Maximum length of the instance name. */ Cpa8U instName[CPA_INST_NAME_SIZE]; /**< String identifying the name of the instance. */ #define CPA_INST_ID_SIZE CPA_INSTANCE_MAX_ID_SIZE_IN_BYTES Cpa8U instID[CPA_INST_ID_SIZE]; /**< String containing a unique identifier for the instance */ CpaPhysicalInstanceId physInstId; /**< Identifies the "physical instance" of the accelerator. */ #define CPA_MAX_CORES 4096 /**< Maximum number of cores to support in the coreAffinity bitmap. */ CPA_BITMAP(coreAffinity, CPA_MAX_CORES); /**< A bitmap identifying the core or cores to which the instance * is affinitized in an SMP operating system. * * The term core here is used to mean a "logical" core - for example, * in a dual-processor, quad-core system with hyperthreading (two * threads per core), there would be 16 such cores (2 processors x * 4 cores/processor x 2 threads/core). The numbering of these cores * and the corresponding bit positions is OS-specific. Note that Linux * refers to this as "processor affinity" or "CPU affinity", and refers * to the bitmap as a "cpumask". * * The term "affinity" is used to mean that this is the core on which * the callback function will be invoked when using the asynchronous * mode of the API. In a hardware-based implementation of the API, * this might be the core to which the interrupt is affinitized. * In a software-based implementation, this might be the core to which * the process running the algorithm is affinitized. Where there is * no affinity, the bitmap can be set to all zeroes. * * This bitmap should be manipulated using the macros @ref * CPA_BITMAP_BIT_SET, @ref CPA_BITMAP_BIT_CLEAR and @ref * CPA_BITMAP_BIT_TEST. */ Cpa32U nodeAffinity; /**< Identifies the processor complex, or node, to which the accelerator * is physically connected, to help identify locality in NUMA systems. * * The values taken by this attribute will typically be in the range * 0..n-1, where n is the number of nodes (processor complexes) in the * system. For example, in a dual-processor configuration, n=2. The * precise values and their interpretation are OS-specific. */ CpaOperationalState operState; /**< Operational state of the instance. */ CpaBoolean requiresPhysicallyContiguousMemory; /**< Specifies whether the data pointed to by flat buffers * (CpaFlatBuffer::pData) supplied to this instance must be in * physically contiguous memory. */ CpaBoolean isPolled; /**< Specifies whether the instance must be polled, or is event driven. * For hardware accelerators, the alternative to polling would be * interrupts. */ CpaBoolean isOffloaded; /**< Identifies whether the instance uses hardware offload, or is a * software-only implementation. */ } CpaInstanceInfo2; /** ***************************************************************************** * @ingroup cpa_BaseDataTypes * Instance Events * @description * Enumeration of the different events that will cause the registered * Instance notification callback function to be invoked. * *****************************************************************************/ typedef enum _CpaInstanceEvent { CPA_INSTANCE_EVENT_RESTARTING = 0, /**< Event type that triggers the registered instance notification callback * function when and instance is restarting. The reason why an instance is * restarting is implementation specific. For example a hardware * implementation may send this event if the hardware device is about to * be reset. */ CPA_INSTANCE_EVENT_RESTARTED, /**< Event type that triggers the registered instance notification callback * function when and instance has restarted. The reason why an instance has * restarted is implementation specific. For example a hardware * implementation may send this event after the hardware device has * been reset. */ CPA_INSTANCE_EVENT_FATAL_ERROR /**< Event type that triggers the registered instance notification callback * function when an error has been detected that requires the device * to be reset. * This event will be sent by all instances using the device, both on the * host and guests. */ } CpaInstanceEvent; /*****************************************************************************/ /* CPA Instance Management Functions */ /*****************************************************************************/ /** ***************************************************************************** * @file cpa.h * @ingroup cpa * Get the number of Acceleration Service instances that are supported by * the API implementation. * * @description * This function will get the number of instances that are supported * for the required Acceleration Service by an implementation of the CPA * API. This number is then used to determine the size of the array that * must be passed to @ref cpaGetInstances(). * * @context * This function MUST NOT be called from an interrupt context as it MAY * sleep. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] accelerationServiceType Acceleration Service required * @param[out] pNumInstances Pointer to where the number of * instances will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated * * @see * cpaGetInstances * *****************************************************************************/ CpaStatus cpaGetNumInstances( const CpaAccelerationServiceType accelerationServiceType, Cpa16U *pNumInstances); /** ***************************************************************************** * @file cpa.h * @ingroup cpa * Get the handles to the required Acceleration Service instances that are * supported by the API implementation. * * @description * This function will return handles to the required Acceleration Service * instances that are supported by an implementation of the CPA API. These * instance handles can then be used as input parameters with other * API functions. * * This function will populate an array that has been allocated by the * caller. The size of this array will have been determined by the * cpaGetNumInstances() function. * * @context * This function MUST NOT be called from an interrupt context as it MAY * sleep. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] accelerationServiceType Acceleration Service requested * @param[in] numInstances Size of the array. If the value is * greater than the number of instances * supported, then an error (@ref * CPA_STATUS_INVALID_PARAM) is returned. * @param[in,out] cpaInstances Pointer to where the instance * handles will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated * * @see * cpaGetNumInstances * *****************************************************************************/ CpaStatus cpaGetInstances( const CpaAccelerationServiceType accelerationServiceType, Cpa16U numInstances, CpaInstanceHandle *cpaInstances); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_H */ diff --git a/sys/dev/qat/qat_api/include/cpa_dev.h b/sys/dev/qat/qat_api/include/cpa_dev.h index 2d548e8a9541..bb6dd1d76f2a 100644 --- a/sys/dev/qat/qat_api/include/cpa_dev.h +++ b/sys/dev/qat/qat_api/include/cpa_dev.h @@ -1,144 +1,144 @@ -/**************************************************************************** +/*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_dev.h * * @defgroup cpaDev Device API * * @ingroup cpa * * @description * These functions specify the API for device level operation. * * @remarks * * *****************************************************************************/ #ifndef CPA_DEV_H #define CPA_DEV_H #ifdef __cplusplus extern"C" { #endif #ifndef CPA_H #include "cpa.h" #endif /***************************************************************************** * @ingroup cpaDev * Returns device information * * @description * This data structure contains the device information. The device * information are available to both Physical and Virtual Functions. * Depending on the resource partitioning configuration, the services * available may changes. This configuration will impact the size of the * Security Association Database (SADB). Other properties such device SKU * and device ID are also reported. * *****************************************************************************/ typedef struct _CpaDeviceInfo { Cpa32U sku; /**< Identifies the SKU of the device. */ Cpa16U bdf; /**< Identifies the Bus Device Function of the device. * Format is reported as follow: * - bits<2:0> represent the function number. * - bits<7:3> represent the device * - bits<15:8> represent the bus */ Cpa32U deviceId; /**< Returns the device ID. */ Cpa32U numaNode; /**< Return the local NUMA node mapped to the device. */ CpaBoolean isVf; /**< Return whether the device is currently used in a virtual function * or not. */ CpaBoolean dcEnabled; /**< Compression service enabled */ CpaBoolean cySymEnabled; - /**< Symetric crypto service enabled */ + /**< Symmetric crypto service enabled */ CpaBoolean cyAsymEnabled; - /**< Asymetric crypto service enabled */ + /**< Asymmetric crypto service enabled */ CpaBoolean inlineEnabled; /**< Inline service enabled */ Cpa32U deviceMemorySizeAvailable; /**< Return the size of the device memory available. This device memory * section could be used for the intermediate buffers in the * compression service. */ } CpaDeviceInfo; /***************************************************************************** * @ingroup cpaDev * Returns number devices. * * @description * This API returns the number of devices available to the application. * If used on the host, it will return the number of physical devices. * If used on the guest, it will return the number of function mapped * to the virtual machine. * *****************************************************************************/ CpaStatus cpaGetNumDevices (Cpa16U *numDevices); /***************************************************************************** * @ingroup cpaDev * Returns device information for a given device index. * * @description * Returns device information for a given device index. This API must * be used with cpaGetNumDevices(). *****************************************************************************/ CpaStatus cpaGetDeviceInfo (Cpa16U device, CpaDeviceInfo *deviceInfo); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_DEV_H */ diff --git a/sys/dev/qat/qat_api/include/cpa_types.h b/sys/dev/qat/qat_api/include/cpa_types.h index 00ed3c60fce6..93bed46f3730 100644 --- a/sys/dev/qat/qat_api/include/cpa_types.h +++ b/sys/dev/qat/qat_api/include/cpa_types.h @@ -1,229 +1,229 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_types.h * * @defgroup cpa_Types CPA Type Definition * * @ingroup cpa * * @description * This is the CPA Type Definitions. * *****************************************************************************/ #ifndef CPA_TYPES_H #define CPA_TYPES_H #ifdef __cplusplus extern "C" { #endif #if defined (__FreeBSD__) && defined (_KERNEL) /* FreeBSD kernel mode */ #include #include #include #else /* Linux, FreeBSD, or Windows user mode */ #include #include #include #endif #if defined (WIN32) || defined (_WIN64) /* nonstandard extension used : zero-sized array in struct/union */ #pragma warning (disable: 4200) #endif typedef uint8_t Cpa8U; /**< * @file cpa_types.h * @ingroup cpa_Types * Unsigned byte base type. */ typedef int8_t Cpa8S; /**< * @file cpa_types.h * @ingroup cpa_Types * Signed byte base type. */ typedef uint16_t Cpa16U; /**< * @file cpa_types.h * @ingroup cpa_Types * Unsigned double-byte base type. */ typedef int16_t Cpa16S; /**< * @file cpa_types.h * @ingroup cpa_Types * Signed double-byte base type. */ typedef uint32_t Cpa32U; /**< * @file cpa_types.h * @ingroup cpa_Types * Unsigned quad-byte base type. */ typedef int32_t Cpa32S; /**< * @file cpa_types.h * @ingroup cpa_Types * Signed quad-byte base type. */ typedef uint64_t Cpa64U; /**< * @file cpa_types.h * @ingroup cpa_Types * Unsigned double-quad-byte base type. */ typedef int64_t Cpa64S; /**< * @file cpa_types.h * @ingroup cpa_Types * Signed double-quad-byte base type. */ /***************************************************************************** * Generic Base Data Type definitions *****************************************************************************/ #ifndef NULL #define NULL (0) /**< * @file cpa_types.h * @ingroup cpa_Types * NULL definition. */ #endif /** ***************************************************************************** * @ingroup cpa_Types * Boolean type. * * @description * Functions in this API use this type for Boolean variables that take * true or false values. * *****************************************************************************/ typedef enum _CpaBoolean { CPA_FALSE = (0==1), /**< False value */ CPA_TRUE = (1==1) /**< True value */ } CpaBoolean; /** ***************************************************************************** * @ingroup cpa_Types * Declare a bitmap of specified size (in bits). * * @description * This macro is used to declare a bitmap of arbitrary size. * * To test whether a bit in the bitmap is set, use @ref * CPA_BITMAP_BIT_TEST. * * While most uses of bitmaps on the API are read-only, macros are also * provided to set (see @ref CPA_BITMAP_BIT_SET) and clear (see @ref * CPA_BITMAP_BIT_CLEAR) bits in the bitmap. *****************************************************************************/ #define CPA_BITMAP(name, sizeInBits) \ Cpa32U name[((sizeInBits)+31)/32] #define CPA_BITMAP_BIT_TEST(bitmask, bit) \ ((bitmask[(bit)/32]) & (0x1 << ((bit)%32))) /**< * @ingroup cpa_Types * Test a specified bit in the specified bitmap. The bitmap may have been * declared using @ref CPA_BITMAP. Returns a Boolean (true if the bit is * set, false otherwise). */ #define CPA_BITMAP_BIT_SET(bitmask, bit) \ (bitmask[(bit)/32] |= (0x1 << ((bit)%32))) /**< * @file cpa_types.h * @ingroup cpa_Types * Set a specified bit in the specified bitmap. The bitmap may have been * declared using @ref CPA_BITMAP. */ #define CPA_BITMAP_BIT_CLEAR(bitmask, bit) \ (bitmask[(bit)/32] &= ~(0x1 << ((bit)%32))) /**< * @ingroup cpa_Types * Clear a specified bit in the specified bitmap. The bitmap may have been * declared using @ref CPA_BITMAP. */ /** ********************************************************************** * * @ingroup cpa_Types * * @description * Declare a function or type and mark it as deprecated so that * usages get flagged with a warning. * ********************************************************************** */ #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(_WIN64) /* * gcc and icc support the __attribute__ ((deprecated)) syntax for marking * functions and other constructs as deprecated. */ /* * Uncomment the deprecated macro if you need to see which structs are deprecated */ #define CPA_DEPRECATED /*#define CPA_DEPRECATED __attribute__ ((deprecated)) */ #else /* * for all other compilers, define deprecated to do nothing * */ /* #define CPA_DEPRECATED_FUNC(func) func; #pragma deprecated(func) */ #pragma message("WARNING: You need to implement the CPA_DEPRECATED macro for this compiler") #define CPA_DEPRECATED #endif #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_TYPES_H */ diff --git a/sys/dev/qat/qat_api/include/dc/cpa_dc.h b/sys/dev/qat/qat_api/include/dc/cpa_dc.h index 7094747bc83e..3002c62776c5 100644 --- a/sys/dev/qat/qat_api/include/dc/cpa_dc.h +++ b/sys/dev/qat/qat_api/include/dc/cpa_dc.h @@ -1,3254 +1,3255 @@ -/**************************************************************************** +/*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_dc.h * * @defgroup cpaDc Data Compression API * * @ingroup cpa * * @description * These functions specify the API for Data Compression operations. * * The Data Compression API has the following: * 1) Session based API functions * These functions require a session to be created before performing any * DC operations. Subsequent DC API functions make use of the returned * Session Handle within their structures or function prototypes. * 2) Session-less or No-Session (Ns) based API functions. * These functions do not require a session to be initialized before * performing DC operations. They are "one-shot" API function calls * that submit DC requests directly using the supplied parameters. * * @remarks * * *****************************************************************************/ #ifndef CPA_DC_H #define CPA_DC_H #ifdef __cplusplus extern"C" { #endif #ifndef CPA_H #include "cpa.h" #endif /** ***************************************************************************** * @ingroup cpaDc * CPA Dc Major Version Number * @description * The CPA_DC API major version number. This number will be incremented * when significant churn to the API has occurred. The combination of the * major and minor number definitions represent the complete version number * for this interface. * *****************************************************************************/ #define CPA_DC_API_VERSION_NUM_MAJOR (3) /** ***************************************************************************** * @ingroup cpaDc * CPA DC Minor Version Number * @description * The CPA_DC API minor version number. This number will be incremented * when minor changes to the API has occurred. The combination of the major * and minor number definitions represent the complete version number for * this interface. * *****************************************************************************/ #define CPA_DC_API_VERSION_NUM_MINOR (2) /** ***************************************************************************** * @file cpa_dc.h * @ingroup cpaDc * CPA DC API version at least * @description * The minimal supported CPA_DC API version. Allow to check if the API * version is equal or above some version to avoid compilation issues * with an older API version. * *****************************************************************************/ #define CPA_DC_API_VERSION_AT_LEAST(major, minor) \ (CPA_DC_API_VERSION_NUM_MAJOR > major || \ (CPA_DC_API_VERSION_NUM_MAJOR == major && \ CPA_DC_API_VERSION_NUM_MINOR >= minor)) /** ***************************************************************************** * @file cpa_dc.h * @ingroup cpaDc * CPA DC API version less than * @description * The maximum supported CPA_DC API version. Allow to check if the API * version is below some version to avoid compilation issues with a newer * API version. * *****************************************************************************/ #define CPA_DC_API_VERSION_LESS_THAN(major, minor) \ (CPA_DC_API_VERSION_NUM_MAJOR < major || \ (CPA_DC_API_VERSION_NUM_MAJOR == major && \ CPA_DC_API_VERSION_NUM_MINOR < minor)) + /** ***************************************************************************** * @ingroup cpaDc * Size of bitmap needed for compression chaining capabilities. * * @description * Defines the number of bits in the bitmap to represent supported * chaining capabilities @ref dcChainCapInfo. Should be set to * at least one greater than the largest value in the enumerated type * @ref CpaDcChainOperations, so that the value of the enum constant * can also be used as the bit position in the bitmap. * * A larger value was chosen to allow for extensibility without the need * to change the size of the bitmap (to ease backwards compatibility in * future versions of the API). * *****************************************************************************/ #define CPA_DC_CHAIN_CAP_BITMAP_SIZE (32) /** ***************************************************************************** * @ingroup cpaDc * Compression API session handle type * * @description * Handle used to uniquely identify a Compression API session handle. This * handle is established upon registration with the API using * cpaDcInitSession(). * * * *****************************************************************************/ typedef void * CpaDcSessionHandle; /** ***************************************************************************** * @ingroup cpaDc * Supported flush flags * * @description * This enumerated list identifies the types of flush that can be * specified for stateful and stateless cpaDcCompressData and * cpaDcDecompressData functions. * *****************************************************************************/ typedef enum _CpaDcFlush { CPA_DC_FLUSH_NONE = 0, /**< No flush request. */ CPA_DC_FLUSH_FINAL, /**< Indicates that the input buffer contains all of the data for the compression session allowing any buffered data to be released. For Deflate, BFINAL is set in the compression header.*/ CPA_DC_FLUSH_SYNC, /**< Used for stateful deflate compression to indicate that all pending output is flushed, byte aligned, to the output buffer. The session state is not reset.*/ CPA_DC_FLUSH_FULL /**< Used for deflate compression to indicate that all pending output is flushed to the output buffer and the session state is reset.*/ } CpaDcFlush; /** ***************************************************************************** * @ingroup cpaDc * Supported Huffman Tree types * * @description * This enumeration lists support for Huffman Tree types. * Selecting Static Huffman trees generates compressed blocks with an RFC * 1951 header specifying "compressed with fixed Huffman trees". * * Selecting Full Dynamic Huffman trees generates compressed blocks with * an RFC 1951 header specifying "compressed with dynamic Huffman codes". * The headers are calculated on the data being compressed, requiring two * passes. * * Selecting Precompiled Huffman Trees generates blocks with RFC 1951 * dynamic headers. The headers are pre-calculated and are specified by * the file type. * *****************************************************************************/ typedef enum _CpaDcHuffType { CPA_DC_HT_STATIC = 0, /**< Static Huffman Trees */ CPA_DC_HT_PRECOMP, /**< Precompiled Huffman Trees */ CPA_DC_HT_FULL_DYNAMIC /**< Full Dynamic Huffman Trees */ } CpaDcHuffType; /** ***************************************************************************** * @ingroup cpaDc * Supported compression types * * @description * This enumeration lists the supported data compression algorithms. * In combination with CpaDcChecksum it is used to decide on the file * header and footer format. * *****************************************************************************/ typedef enum _CpaDcCompType { CPA_DC_DEFLATE = 3, /**< Deflate Compression */ CPA_DC_LZ4, /**< LZ4 Compression */ CPA_DC_LZ4S /**< LZ4S Compression */ } CpaDcCompType; /** ***************************************************************************** * @ingroup cpaDc * Support for defined algorithm window sizes * * @description * This enumerated list defines the valid window sizes that can be * used with the supported algorithms *****************************************************************************/ typedef enum _CpaDcCompWindowSize { CPA_DC_WINSIZE_4K = 0, /**< Window size of 4KB */ CPA_DC_WINSIZE_8K, /**< Window size of 8KB */ CPA_DC_WINSIZE_16K, /**< Window size of 16KB */ CPA_DC_WINSIZE_32K /**< Window size of 32KB */ } CpaDcCompWindowSize; /** ***************************************************************************** * @ingroup cpaDc * Min match size in bytes * @description * This is the min match size that will be used for the search algorithm. * It is only configurable for LZ4S. *****************************************************************************/ typedef enum _CpaDcCompMinMatch { CPA_DC_MIN_3_BYTE_MATCH = 0, /**< Min Match of 3 bytes */ CPA_DC_MIN_4_BYTE_MATCH /**< Min Match of 4 bytes */ } CpaDcCompMinMatch; /** ***************************************************************************** * @ingroup cpaDc * Maximum LZ4 output block size * @description * Maximum LZ4 output block size *****************************************************************************/ typedef enum _CpaDcCompLZ4BlockMaxSize { CPA_DC_LZ4_MAX_BLOCK_SIZE_64K = 0, /**< Maximum block size 64K */ CPA_DC_LZ4_MAX_BLOCK_SIZE_256K, /**< Maximum block size 256K */ CPA_DC_LZ4_MAX_BLOCK_SIZE_1M, /**< Maximum block size 1M */ CPA_DC_LZ4_MAX_BLOCK_SIZE_4M, /**< Maximum block size 4M */ } CpaDcCompLZ4BlockMaxSize; /** ***************************************************************************** * @ingroup cpaDc * Supported checksum algorithms * * @description * This enumeration lists the supported checksum algorithms * Used to decide on file header and footer specifics. * *****************************************************************************/ typedef enum _CpaDcChecksum { CPA_DC_NONE = 0, /**< No checksum required */ CPA_DC_CRC32, /**< Application requires a CRC32 checksum */ CPA_DC_ADLER32, /**< Application requires Adler-32 checksum */ CPA_DC_CRC32_ADLER32, /**< Application requires both CRC32 and Adler-32 checksums */ CPA_DC_XXHASH32, /**< Application requires xxHash-32 checksum */ } CpaDcChecksum; /** ***************************************************************************** * @ingroup cpaDc * Supported session directions * * @description * This enumerated list identifies the direction of a session. * A session can be compress, decompress or both. * *****************************************************************************/ typedef enum _CpaDcSessionDir { CPA_DC_DIR_COMPRESS = 0, /**< Session will be used for compression */ CPA_DC_DIR_DECOMPRESS, /**< Session will be used for decompression */ CPA_DC_DIR_COMBINED /**< Session will be used for both compression and decompression */ } CpaDcSessionDir; typedef CpaDcSessionDir CpaDcDir; /** ***************************************************************************** * @ingroup cpaDc * Supported session state settings * * @description * This enumerated list identifies the stateful setting of a session. * A session can be either stateful or stateless. * * Stateful sessions are limited to have only one in-flight message per * session. This means a compress or decompress request must be complete * before a new request can be started. This applies equally to sessions * that are uni-directional in nature and sessions that are combined * compress and decompress. Completion occurs when the synchronous function * returns, or when the asynchronous callback function has completed. * *****************************************************************************/ typedef enum _CpaDcSessionState { CPA_DC_STATEFUL = 0, /**< Session will be stateful, implying that state may need to be saved in some situations */ CPA_DC_STATELESS /**< Session will be stateless, implying no state will be stored*/ } CpaDcSessionState; typedef CpaDcSessionState CpaDcState; /** ***************************************************************************** * @ingroup cpaDc * Supported compression levels * * @description * This enumerated lists the supported compressed levels. * Lower values will result in less compressibility in less time. * * *****************************************************************************/ typedef enum _CpaDcCompLvl { CPA_DC_L1 = 1, /**< Compression level 1 */ CPA_DC_L2, /**< Compression level 2 */ CPA_DC_L3, /**< Compression level 3 */ CPA_DC_L4, /**< Compression level 4 */ CPA_DC_L5, /**< Compression level 5 */ CPA_DC_L6, /**< Compression level 6 */ CPA_DC_L7, /**< Compression level 7 */ CPA_DC_L8, /**< Compression level 8 */ CPA_DC_L9, /**< Compression level 9 */ CPA_DC_L10, /**< Compression level 10 */ CPA_DC_L11, /**< Compression level 11 */ CPA_DC_L12 /**< Compression level 12 */ } CpaDcCompLvl; /** ***************************************************************************** * @ingroup cpaDc * Supported additional details from accelerator * * @description * This enumeration lists the supported additional details from the * accelerator. These may be useful in determining the best way to * recover from a failure. * * *****************************************************************************/ typedef enum _CpaDcReqStatus { CPA_DC_OK = 0, /**< No error detected by compression slice */ CPA_DC_INVALID_BLOCK_TYPE = -1, /**< Invalid block type (type == 3) */ CPA_DC_BAD_STORED_BLOCK_LEN = -2, /**< Stored block length did not match one's complement */ CPA_DC_TOO_MANY_CODES = -3, /**< Too many length or distance codes */ CPA_DC_INCOMPLETE_CODE_LENS = -4, /**< Code length codes incomplete */ CPA_DC_REPEATED_LENS = -5, /**< Repeated lengths with no first length */ CPA_DC_MORE_REPEAT = -6, /**< Repeat more than specified lengths */ CPA_DC_BAD_LITLEN_CODES = -7, /**< Invalid literal/length code lengths */ CPA_DC_BAD_DIST_CODES = -8, /**< Invalid distance code lengths */ CPA_DC_INVALID_CODE = -9, /**< Invalid literal/length or distance code in fixed or dynamic block */ CPA_DC_INVALID_DIST = -10, /**< Distance is too far back in fixed or dynamic block */ CPA_DC_OVERFLOW = -11, /**< Overflow detected. This is an indication that output buffer has overflowed. * For stateful sessions, this is a warning (the input can be adjusted and * resubmitted). * For stateless sessions this is an error condition */ CPA_DC_SOFTERR = -12, /**< Other non-fatal detected */ CPA_DC_FATALERR = -13, /**< Fatal error detected */ CPA_DC_MAX_RESUBITERR = -14, /**< On an error being detected, the firmware attempted to correct and resubmitted the * request, however, the maximum resubmit value was exceeded */ CPA_DC_INCOMPLETE_FILE_ERR = -15, /**< The input file is incomplete. Note this is an indication that the request was * submitted with a CPA_DC_FLUSH_FINAL, however, a BFINAL bit was not found in the * request */ CPA_DC_WDOG_TIMER_ERR = -16, /**< The request was not completed as a watchdog timer hardware event occurred */ CPA_DC_EP_HARDWARE_ERR = -17, /**< Request was not completed as an end point hardware error occurred (for * example, a parity error) */ CPA_DC_VERIFY_ERROR = -18, /**< Error detected during "compress and verify" operation */ CPA_DC_EMPTY_DYM_BLK = -19, /**< Decompression request contained an empty dynamic stored block * (not supported) */ CPA_DC_CRC_INTEG_ERR = -20, /**< A data integrity CRC error was detected */ CPA_DC_REGION_OUT_OF_BOUNDS = -21, /**< Error returned when decompression ends before the specified partial * decompression region was produced */ CPA_DC_LZ4_MAX_BLOCK_SIZE_EXCEEDED = -93, /**< LZ4 max block size exceeded */ CPA_DC_LZ4_BLOCK_OVERFLOW_ERR = -95, /**< LZ4 Block Overflow Error */ CPA_DC_LZ4_TOKEN_IS_ZERO_ERR = -98, /**< LZ4 Decoded token offset or token length is zero */ CPA_DC_LZ4_DISTANCE_OUT_OF_RANGE_ERR = -100, /**< LZ4 Distance out of range for len/distance pair */ } CpaDcReqStatus; /** ***************************************************************************** * @ingroup cpaDc * Supported modes for automatically selecting the best compression type. * * @description * This enumeration lists the supported modes for automatically selecting * the best encoding which would lead to the best compression results. * * When CPA_DC_ASB_ENABLED is used the output will be a format compliant * block, whether the data is compressed or not. * * The following values are deprecated and should not be used. They * will be removed in a future version of this file. * - CPA_DC_ASB_STATIC_DYNAMIC * - CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_STORED_HDRS * - CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_NO_HDRS * *****************************************************************************/ typedef enum _CpaDcAutoSelectBest { CPA_DC_ASB_DISABLED = 0, /**< Auto select best mode is disabled */ CPA_DC_ASB_STATIC_DYNAMIC = 1, /**< Auto select between static and dynamic compression */ CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_STORED_HDRS = 2, /**< Auto select between uncompressed, static and dynamic compression, * using stored block deflate headers if uncompressed is selected */ CPA_DC_ASB_UNCOMP_STATIC_DYNAMIC_WITH_NO_HDRS = 3, /**< Auto select between uncompressed, static and dynamic compression, * using no deflate headers if uncompressed is selected */ CPA_DC_ASB_ENABLED = 4, /**< Auto select best mode is enabled */ } CpaDcAutoSelectBest; /** ***************************************************************************** * @ingroup cpaDc * Supported modes for skipping regions of input or output buffers. * * @description * This enumeration lists the supported modes for skipping regions of * input or output buffers. * *****************************************************************************/ typedef enum _CpaDcSkipMode { CPA_DC_SKIP_DISABLED = 0, /**< Skip mode is disabled */ CPA_DC_SKIP_AT_START = 1, /**< Skip region is at the start of the buffer. */ CPA_DC_SKIP_AT_END = 2, /**< Skip region is at the end of the buffer. */ CPA_DC_SKIP_STRIDE = 3 /**< Skip region occurs at regular intervals within the buffer. CpaDcSkipData.strideLength specifies the number of bytes between each skip region. */ } CpaDcSkipMode; /** ***************************************************************************** * @ingroup cpaDc * Service specific return codes * * @description * Compression specific return codes * * *****************************************************************************/ #define CPA_DC_BAD_DATA (-100) /**consumed arg. * -# The implementation communicates the amount of data in the * destination buffer list via pResults->produced arg. * * Source Buffer Setup Rules * -# The buffer list must have the correct number of flat buffers. This * is specified by the numBuffers element of the CpaBufferList. * -# Each flat buffer must have a pointer to contiguous memory that has * been allocated by the calling application. The * number of octets to be compressed or decompressed must be stored * in the dataLenInBytes element of the flat buffer. * -# It is permissible to have one or more flat buffers with a zero length * data store. This function will process all flat buffers until the * destination buffer is full or all source data has been processed. * If a buffer has zero length, then no data will be processed from * that buffer. * * Source Buffer Processing Rules. * -# The buffer list is processed in index order - SrcBuff->pBuffers[0] * will be completely processed before SrcBuff->pBuffers[1] begins to * be processed. * -# The application must drain the destination buffers. * If the source data was not completely consumed, the application * must resubmit the request. * -# On return, the pResults->consumed will indicate the number of bytes * consumed from the input buffers. * * Destination Buffer Setup Rules * -# The destination buffer list must have storage for processed data. * This implies at least one flat buffer must exist in the buffer list. * -# For each flat buffer in the buffer list, the dataLenInBytes element * must be set to the size of the buffer space. * -# It is permissible to have one or more flat buffers with a zero length * data store. * If a buffer has zero length, then no data will be added to * that buffer. * * Destination Buffer Processing Rules. * -# The buffer list is processed in index order - DestBuff->pBuffers[0] * will be completely processed before DestBuff->pBuffers[1] begins to * be processed. * -# On return, the pResults->produced will indicate the number of bytes * written to the output buffers. * -# If processing has not been completed, the application must drain the * destination buffers and resubmit the request. The application must * reset the dataLenInBytes for each flat buffer in the destination * buffer list. * * Checksum rules. * If a checksum is specified in the session setup data, then: * -# For the first request for a particular data segment the checksum * is initialised internally by the implementation. * -# The checksum is maintained by the implementation between calls * until the flushFlag is set to CPA_DC_FLUSH_FINAL indicating the * end of a particular data segment. * -# Intermediate checksum values are returned to the application, * via the CpaDcRqResults structure, in response to each request. * However these checksum values are not guaranteed to the valid * until the call with flushFlag set to CPA_DC_FLUSH_FINAL * completes successfully. * * The application should set flushFlag to * CPA_DC_FLUSH_FINAL to indicate processing a particular data segment * is complete. It should be noted that this function may have to be * called more than once to process data after the flushFlag parameter has * been set to CPA_DC_FLUSH_FINAL if the destination buffer fills. Refer * to buffer processing rules. * * For stateful operations, when the function is invoked with flushFlag * set to CPA_DC_FLUSH_NONE or CPA_DC_FLUSH_SYNC, indicating more data * is yet to come, the function may or may not retain data. When the * function is invoked with flushFlag set to CPA_DC_FLUSH_FULL or * CPA_DC_FLUSH_FINAL, the function will process all buffered data. * * For stateless operations, CPA_DC_FLUSH_FINAL will cause the BFINAL * bit to be set for deflate compression. The initial checksum for the * stateless operation should be set to 0. CPA_DC_FLUSH_NONE and * CPA_DC_FLUSH_SYNC should not be used for stateless operations. * * It is possible to maintain checksum and length information across * cpaDcCompressData() calls with a stateless session without maintaining * the full history state that is maintained by a stateful session. In this * mode of operation, an initial checksum value of 0 is passed into the * first cpaDcCompressData() call with the flush flag set to * CPA_DC_FLUSH_FULL. On subsequent calls to cpaDcCompressData() for this * session, the checksum passed to cpaDcCompressData should be set to the * checksum value produced by the previous call to cpaDcCompressData(). * When the last block of input data is passed to cpaDcCompressData(), the - * flush flag should be set to CP_DC_FLUSH_FINAL. This will cause the BFINAL + * flush flag should be set to CPA_DC_FLUSH_FINAL. This will cause the BFINAL * bit to be set in a deflate stream. It is the responsibility of the calling * application to maintain overall lengths across the stateless requests * and to pass the checksum produced by one request into the next request. * * When an instance supports compressAndVerifyAndRecover, it is enabled by * default when using cpaDcCompressData(). If this feature needs to be * disabled, cpaDcCompressData2() must be used. * * Synchronous or Asynchronous operation of the API is determined by * the value of the callbackFn parameter passed to cpaDcInitSession() * when the sessionHandle was setup. If a non-NULL value was specified * then the supplied callback function will be invoked asynchronously * with the response of this request. * * Response ordering: * For each session, the implementation must maintain the order of * responses. That is, if in asynchronous mode, the order of the callback * functions must match the order of jobs submitted by this function. * In a simple synchronous mode implementation, the practice of submitting * a request and blocking on its completion ensure ordering is preserved. * * This limitation does not apply if the application employs multiple * threads to service a single session. * * If this API is invoked asynchronous, the return code represents * the success or not of asynchronously scheduling the request. * The results of the operation, along with the amount of data consumed * and produced become available when the callback function is invoked. * As such, pResults->consumed and pResults->produced are available * only when the operation is complete. * * The application must not use either the source or destination buffers * until the callback has completed. * * @see * None * *****************************************************************************/ CpaStatus cpaDcCompressData( CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDc * Submit a request to compress a buffer of data. * * @description * This API consumes data from the input buffer and generates compressed * data in the output buffer. This API is very similar to * cpaDcCompressData() except it provides a CpaDcOpData structure for * passing additional input parameters not covered in cpaDcCompressData(). * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in,out] pSessionHandle Session handle. * @param[in] pSrcBuff Pointer to data buffer for compression. * @param[in] pDestBuff Pointer to buffer space for data after * compression. * @param[in,out] pOpData Additional parameters. * @param[in,out] pResults Pointer to results structure * @param[in] callbackTag User supplied value to help correlate * the callback with its associated * request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_DC_BAD_DATA The input data was not properly formed. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * * @pre * pSessionHandle has been setup using cpaDcInitSession() * @post * pSessionHandle has session related state information * @note * This function passes control to the compression service for processing * * @see * cpaDcCompressData() * *****************************************************************************/ CpaStatus cpaDcCompressData2( CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcOpData *pOpData, CpaDcRqResults *pResults, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDc * Submit a request to compress a buffer of data without requiring a * session to be created. This is a No-Session (Ns) variant of the * cpaDcCompressData function. * * @description * This API consumes data from the input buffer and generates compressed * data in the output buffer. Unlike the other compression APIs this * does not use a previously created session. This is a "one-shot" API * that requests can be directly submitted to. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in] pSetupData Configuration structure for compression. * @param[in] pSrcBuff Pointer to data buffer for compression. * @param[in] pDestBuff Pointer to buffer space for data after * compression. * @param[in] pOpData Additional input parameters. * @param[in,out] pResults Pointer to results structure * @param[in] callbackFn For synchronous operation this callback * shall be a null pointer. * @param[in] callbackTag User supplied value to help correlate * the callback with its associated * request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * * @pre * None * @post * None * @note * This function passes control to the compression service for processing * * Checksum rules. * The checksum rules are the same as those for the session based APIs * (cpaDcCompressData or cpaDcCompressData2) with the following exception. * -# If the algorithm specified is CPA_DC_LZ4 or CPA_DC_LZ4S the xxHash32 * checksum will not be maintained across calls to the API. The * implication is that the xxHash32 value will only be valid for the * output of a single request, no state will be saved. If an LZ4 frame is * required, even in recoverable error scenarios such as CPA_DC_OVERFLOW, * the checksum will not be continued. If that is required the session * based API must be used. * * @see * None * *****************************************************************************/ CpaStatus cpaDcNsCompressData( CpaInstanceHandle dcInstance, CpaDcNsSetupData *pSetupData, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcOpData *pOpData, CpaDcRqResults *pResults, CpaDcCallbackFn callbackFn, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDc * Submit a request to decompress a buffer of data. * * @description * This API consumes compressed data from the input buffer and generates * uncompressed data in the output buffer. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in,out] pSessionHandle Session handle. * @param[in] pSrcBuff Pointer to data buffer for compression. * @param[in] pDestBuff Pointer to buffer space for data * after decompression. * @param[in,out] pResults Pointer to results structure * @param[in] flushFlag When set to CPA_DC_FLUSH_FINAL, indicates * that the input buffer contains all of * the data for the compression session, * allowing the function to release * history data. * @param[in] callbackTag User supplied value to help correlate * the callback with its associated * request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_DC_BAD_DATA The input data was not properly formed. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * pSessionHandle has been setup using cpaDcInitSession() * @post * pSessionHandle has session related state information * @note * This function passes control to the compression service for * decompression. The function returns the status from the service. * * This function may be called repetitively with input until all of the * input has been provided and all the output has been consumed. * * This function has identical buffer processing rules as * cpaDcCompressData(). * * This function has identical checksum processing rules as * cpaDcCompressData(). * * The application should set flushFlag to * CPA_DC_FLUSH_FINAL to indicate processing a particular compressed * data segment is complete. It should be noted that this function may * have to be called more than once to process data after flushFlag * has been set if the destination buffer fills. Refer to * buffer processing rules in cpaDcCompressData(). * * Synchronous or Asynchronous operation of the API is determined by * the value of the callbackFn parameter passed to cpaDcInitSession() * when the sessionHandle was setup. If a non-NULL value was specified * then the supplied callback function will be invoked asynchronously * with the response of this request, along with the callbackTag * specified in the function. * * The same response ordering constraints identified in the * cpaDcCompressData API apply to this function. * * @see * cpaDcCompressData() * *****************************************************************************/ CpaStatus cpaDcDecompressData( CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, CpaDcFlush flushFlag, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDc * Submit a request to decompress a buffer of data. * * @description * This API consumes compressed data from the input buffer and generates * uncompressed data in the output buffer. This API is very similar to * cpaDcDecompressData() except it provides a CpaDcOpData structure for * passing additional input parameters not covered in cpaDcDecompressData(). * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in,out] pSessionHandle Session handle. * @param[in] pSrcBuff Pointer to data buffer for compression. * @param[in] pDestBuff Pointer to buffer space for data * after decompression. * @param[in] pOpData Additional input parameters. * @param[in,out] pResults Pointer to results structure * @param[in] callbackTag User supplied value to help correlate * the callback with its associated * request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_DC_BAD_DATA The input data was not properly formed. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * * @pre * pSessionHandle has been setup using cpaDcInitSession() * @post * pSessionHandle has session related state information * @note * This function passes control to the compression service for * decompression. The function returns the status from the service. * * @see * cpaDcDecompressData() * cpaDcCompressData2() * cpaDcCompressData() * *****************************************************************************/ CpaStatus cpaDcDecompressData2( CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcOpData *pOpData, CpaDcRqResults *pResults, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDc * Submit a request to decompress a buffer of data without requiring a * session to be created. This is a No-Session (Ns) variant of the * cpaDcDecompressData function. * * @description * This API consumes data from the input buffer and generates decompressed * data in the output buffer. Unlike the other decompression APIs this * does not use a previously created session. This is a "one-shot" API * that requests can be directly submitted to. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in] pSetupData Configuration structure for decompression.. * @param[in] pSrcBuff Pointer to data buffer for decompression. * @param[in] pDestBuff Pointer to buffer space for data * after decompression. * @param[in] pOpData Additional input parameters. * @param[in,out] pResults Pointer to results structure * @param[in] callbackFn For synchronous operation this callback * shall be a null pointer. * @param[in] callbackTag User supplied value to help correlate * the callback with its associated * request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * * @pre * None * @post * None * @note * This function passes control to the decompression service. The function * returns the status from the service. * * @see * cpaDcDecompressData() * cpaDcCompressData2() * cpaDcCompressData() * *****************************************************************************/ CpaStatus cpaDcNsDecompressData( CpaInstanceHandle dcInstance, CpaDcNsSetupData *pSetupData, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcOpData *pOpData, CpaDcRqResults *pResults, CpaDcCallbackFn callbackFn, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDc * Generate compression header. * * @description * This function generates the gzip header, zlib header or LZ4 frame * header and stores it in the destination buffer. The type of header * created is determined using the compression algorithm selected using * CpaDcSessionSetupData.compType, for the session associated with the * session handle. * * @context * This function may be call from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] pSessionHandle Session handle. * @param[in] pDestBuff Pointer to data buffer where the * compression header will go. * @param[out] count Pointer to counter filled in with * header size. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * pSessionHandle has been setup using cpaDcInitSession() * * @note * When the deflate compression algorithm is used, this function can output * a 10 byte gzip header or 2 byte zlib header to the destination buffer. * The session properties are used to determine the header type. To * output a Gzip or a Zlib header the session must have been initialized * with CpaDcCompType CPA_DC_DEFLATE. * To output a gzip header the session must have been initialized with * CpaDcChecksum CPA_DC_CRC32. To output a zlib header the session must * have been initialized with CpaDcChecksum CPA_DC_ADLER32. * For CpaDcChecksum CPA_DC_NONE no header is output. * * If the compression requires a gzip header, then this header requires * at a minimum the following fields, defined in RFC1952: * ID1: 0x1f * ID2: 0x8b * CM: Compression method = 8 for deflate * * The zlib header is defined in RFC1950 and this function must implement * as a minimum: * CM: four bit compression method - 8 is deflate with window size to * 32k * CINFO: four bit window size (see RFC1950 for details), 7 is 32k * window * FLG: defined as: * - Bits 0 - 4: check bits for CM, CINFO and FLG (see RFC1950) * - Bit 5: FDICT 0 = default, 1 is preset dictionary * - Bits 6 - 7: FLEVEL, compression level (see RFC 1950) * * When LZ4 algorithm is used, this function can output a 7 byte frame * header. This function will set the LZ4 frame header with: * - Magic number 0x184D2204 * - The LZ4 max block size defined in the CpaDcSessionSetupData * - Flag byte as: * * Version = 1 * * Block independence = 0 * * Block checksum = 0 * * Content size present = 0 * * Content checksum present = 1 * * Dictionary ID present = 0 * - Content size = 0 * - Dictionary ID = 0 * - Header checksum = 1 byte representing the second byte of the - * XXH32 of the frame decriptor field. + * XXH32 of the frame descriptor field. * * The counter parameter will be set to the number of bytes added to the * buffer. The pData will be not be changed. * * For any of the compression algorithms used, the application is * responsible to offset the pData pointer in CpaBufferList by the length * of the header before calling the CpaDcCompressData() or * CpaDcCompressData2() functions. * @see * None * *****************************************************************************/ CpaStatus cpaDcGenerateHeader( CpaDcSessionHandle pSessionHandle, CpaFlatBuffer *pDestBuff, Cpa32U *count ); /** ***************************************************************************** * @ingroup cpaDc * Generate compression footer. * * @description * This function generates the footer for gzip, zlib or LZ4. * The generated footer is stored it in the destination buffer. * The type of footer created is determined using the compression * algorithm selected for the session associated with the session handle. * * @context * This function may be call from any context. * @assumptions * None * @sideEffects * All session variables are reset * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in,out] pSessionHandle Session handle. * @param[in] pDestBuff Pointer to data buffer where the * compression footer will go. * @param[in,out] pResults Pointer to results structure filled by * CpaDcCompressData. Updated with the * results of this API call * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * pSessionHandle has been setup using cpaDcInitSession() * pResults structure has been filled by CpaDcCompressData(). * * @note * Depending on the session variables, this function can add the * alder32 footer to the zlib compressed data as defined in RFC1950. * If required, it can also add the gzip footer, which is the crc32 of the * uncompressed data and the length of the uncompressed data. * This section is defined in RFC1952. The session variables used to * determine the header type are CpaDcCompType and CpaDcChecksum, see * cpaDcGenerateHeader for more details. * * For LZ4 compression, this function adds the LZ4 frame footer * using XXH32 algorithm of the uncompressed data. The XXH32 checksum is * added after the end mark. This section is defined in the documentation * of the LZ4 frame format at: * https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md * * An artifact of invoking this function for writing the footer data is * that all opaque session specific data is re-initialized. If the * compression level and file types are consistent, the upper level * application can continue processing compression requests using the * same session handle. * * The produced element of the pResults structure will be incremented by * the numbers bytes added to the buffer. The pointer to the buffer will * not be modified. It is necessary for the application to ensure that * there is always sufficient memory in the destination buffer to append * the footer. In the event that the destination buffer would be too small * to accept the footer, overflow will not be reported. * * @see * None * *****************************************************************************/ CpaStatus cpaDcGenerateFooter( CpaDcSessionHandle pSessionHandle, CpaFlatBuffer *pDestBuff, CpaDcRqResults *pResults ); /** ***************************************************************************** * @ingroup cpaDc * Generate compression header without requiring a session to be created. * This is a No-Session (Ns) variant of the cpaDcGenerateHeader function. * * @description * This API generates the required compression format header and stores it * in the output buffer. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] pSetupData Pointer to Ns Configuration structure. * @param[in] pDestBuff Pointer to data buffer where the * compression header will go. * @param[out] count Pointer to counter filled in with * header size. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * * @note * This function outputs the required compression format header to * the destination buffer. The CpaDcNsSetupData structure fields are used to * determine the header type. * * To output an LZ4 header the structure must have been initialized with * with CpaDcCompType CPA_DC_LZ4. * To output a gzip or zlib header the structure must have been initialized * with CpaDcCompType CPA_DC_DEFLATE. * To output a gzip header the structure must have been initialized with * CpaDcChecksum CPA_DC_CRC32. * To output a zlib header the structure must have been initialized with * CpaDcChecksum CPA_DC_ADLER32. * For CpaDcChecksum CPA_DC_NONE no header is output. * * The counter parameter will be set to the number of bytes added to the * buffer. * * @see * cpaDcGenerateHeader * *****************************************************************************/ CpaStatus cpaDcNsGenerateHeader( CpaDcNsSetupData *pSetupData, CpaFlatBuffer *pDestBuff, Cpa32U *count ); /** ***************************************************************************** * @ingroup cpaDc * Generate compression footer without requiring a session to be created. * This is a No-Session (Ns) variant of the cpaDcGenerateFooter function. * * @description * This API generates the footer for the required format and stores it in * the destination buffer. * @context * This function may be call from any context. * @assumptions * None * @sideEffects * All session variables are reset * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] pSetupData Pointer to Ns Configuration structure. * @param[in] totalLength Total accumulated length of input data * processed. See description for formats * that make use of this parameter. * @param[in] pDestBuff Pointer to data buffer where the * compression footer will go. * @param[in,out] pResults Pointer to results structure filled by * CpaDcNsCompressData. Updated with the * results of this API call * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * pResults structure has been filled by CpaDcNsCompressData(). * * @note * This function outputs the required compression format footer to * the destination buffer. The CpaDcNsSetupData structure fields are used to * determine the footer type created. * * To output an LZ4 footer the structure must have been initialized with * with CpaDcCompType CPA_DC_LZ4. * To output a gzip or zlib footer the structure must have been initialized * with CpaDcCompType CPA_DC_DEFLATE. * To output a gzip footer the structure must have been initialized with * CpaDcChecksum CPA_DC_CRC32 and the totalLength parameter initialized to * the total accumulated length of data processed. * To output a zlib footer the structure must have been initialized with * CpaDcChecksum CPA_DC_ADLER32. * For CpaDcChecksum CPA_DC_NONE no footer is output. * * The produced element of the pResults structure will be incremented by the * number of bytes added to the buffer. The pointer to the buffer * will not be modified. * * @see * CpaDcNsSetupData * cpaDcNsGenerateHeader * cpaDcGenerateFooter * *****************************************************************************/ CpaStatus cpaDcNsGenerateFooter( CpaDcNsSetupData *pSetupData, Cpa64U totalLength, CpaFlatBuffer *pDestBuff, CpaDcRqResults *pResults ); /** ***************************************************************************** * @ingroup cpaDc * Retrieve statistics * * @description * This API retrieves the current statistics for a compression instance. * * @context * This function may be call from any context. * @assumptions * None * @sideEffects * None * @blocking * Yes * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Instance handle. * @param[out] pStatistics Pointer to statistics structure. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * * @see * None * *****************************************************************************/ CpaStatus cpaDcGetStats( CpaInstanceHandle dcInstance, CpaDcStats *pStatistics ); /*****************************************************************************/ /* Instance Discovery Functions */ /** ***************************************************************************** * @ingroup cpaDc * Get the number of device instances that are supported by the API * implementation. * * @description * * This function will get the number of device instances that are supported * by an implementation of the compression API. This number is then used to * determine the size of the array that must be passed to * cpaDcGetInstances(). * * @context * This function MUST NOT be called from an interrupt context as it MAY * sleep. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[out] pNumInstances Pointer to where the number of * instances will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated * * @see * cpaDcGetInstances * *****************************************************************************/ CpaStatus cpaDcGetNumInstances(Cpa16U* pNumInstances); /** ***************************************************************************** * @ingroup cpaDc * Get the handles to the device instances that are supported by the * API implementation. * * @description * * This function will return handles to the device instances that are * supported by an implementation of the compression API. These instance * handles can then be used as input parameters with other compression API * functions. * * This function will populate an array that has been allocated by the * caller. The size of this API is determined by the * cpaDcGetNumInstances() function. * * @context * This function MUST NOT be called from an interrupt context as it MAY * sleep. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] numInstances Size of the array. * @param[out] dcInstances Pointer to where the instance * handles will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated * * @see * cpaDcGetInstances * *****************************************************************************/ CpaStatus cpaDcGetInstances(Cpa16U numInstances, CpaInstanceHandle* dcInstances); /** ***************************************************************************** * @ingroup cpaDc * Compression Component utility function to determine the number of * intermediate buffers required by an implementation. * * @description * This function will determine the number of intermediate buffer lists * required by an implementation for a compression instance. These buffers * should then be allocated and provided when calling @ref cpaDcStartInstance() * to start a compression instance that will use dynamic compression. * * @context * This function may sleep, and MUST NOT be called in interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * @param[in,out] instanceHandle Handle to an instance of this API to be * initialized. * @param[out] pNumBuffers When the function returns, this will * specify the number of buffer lists that * should be used as intermediate buffers * when calling cpaDcStartInstance(). * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to shutdown and restart. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * cpaDcStartInstance() * *****************************************************************************/ CpaStatus cpaDcGetNumIntermediateBuffers(CpaInstanceHandle instanceHandle, Cpa16U *pNumBuffers); /** ***************************************************************************** * @ingroup cpaDc * Compression Component Initialization and Start function. * * @description * This function will initialize and start the compression component. * It MUST be called before any other compress function is called. This * function SHOULD be called only once (either for the very first time, * or after an cpaDcStopInstance call which succeeded) per instance. * Subsequent calls will have no effect. * * If required by an implementation, this function can be provided with * instance specific intermediate buffers. The intent is to provide an * instance specific location to store intermediate results during dynamic * instance Huffman tree compression requests. The memory should be * accessible by the compression engine. The buffers are to support * deflate compression with dynamic Huffman Trees. Each buffer list * should be similar in size to twice the destination buffer size passed * to the compress API. The number of intermediate buffer lists may vary * between implementations and so @ref cpaDcGetNumIntermediateBuffers() * should be called first to determine the number of intermediate * buffers required by the implementation. * * If not required, this parameter can be passed in as NULL. * * @context * This function may sleep, and MUST NOT be called in interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * @param[in,out] instanceHandle Handle to an instance of this API to be * initialized. * @param[in] numBuffers Number of buffer lists represented by * the pIntermediateBuffers parameter. * Note: @ref cpaDcGetNumIntermediateBuffers() * can be used to determine the number of * intermediate buffers that an implementation * requires. * @param[in] pIntermediateBuffers Optional pointer to Instance specific * DRAM buffer. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to shutdown and restart. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * cpaDcStopInstance() * cpaDcGetNumIntermediateBuffers() * *****************************************************************************/ CpaStatus cpaDcStartInstance(CpaInstanceHandle instanceHandle, Cpa16U numBuffers, CpaBufferList **pIntermediateBuffers); /** ***************************************************************************** * @ingroup cpaDc * Compress Component Stop function. * * @description * This function will stop the Compression component and free * all system resources associated with it. The client MUST ensure that * all outstanding operations have completed before calling this function. * The recommended approach to ensure this is to deregister all session or * callback handles before calling this function. If outstanding * operations still exist when this function is invoked, the callback * function for each of those operations will NOT be invoked and the * shutdown will continue. If the component is to be restarted, then a * call to cpaDcStartInstance is required. * * @context * This function may sleep, and so MUST NOT be called in interrupt * context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * @param[in] instanceHandle Handle to an instance of this API to be * shutdown. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to ensure requests are not still being * submitted and that all sessions are * deregistered. If this does not help, then * forcefully remove the component from the * system. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaDcStartInstance * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * cpaDcStartInstance() * *****************************************************************************/ CpaStatus cpaDcStopInstance(CpaInstanceHandle instanceHandle); /** ***************************************************************************** * @ingroup cpaDc * Function to get information on a particular instance. * * @description * This function will provide instance specific information through a * @ref CpaInstanceInfo2 structure. * * @context * This function will be executed in a context that requires that sleeping * MUST NOT be permitted. * @assumptions * None * @sideEffects * None * @blocking * Yes * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API to be * initialized. * @param[out] pInstanceInfo2 Pointer to the memory location allocated by * the client into which the CpaInstanceInfo2 * structure will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The client has retrieved an instanceHandle from successive calls to * @ref cpaDcGetNumInstances and @ref cpaDcGetInstances. * @post * None * @note * None * @see * cpaDcGetNumInstances, * cpaDcGetInstances, * CpaInstanceInfo2 * *****************************************************************************/ CpaStatus cpaDcInstanceGetInfo2(const CpaInstanceHandle instanceHandle, CpaInstanceInfo2 * pInstanceInfo2); /*****************************************************************************/ /* Instance Notification Functions */ /*****************************************************************************/ /** ***************************************************************************** * @ingroup cpaDc * Callback function for instance notification support. * * @description * This is the prototype for the instance notification callback function. * The callback function is passed in as a parameter to the * @ref cpaDcInstanceSetNotificationCb function. * * @context * This function will be executed in a context that requires that sleeping * MUST NOT be permitted. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCallbackTag Opaque value provided by user while making * individual function calls. * @param[in] instanceEvent The event that will trigger this function to * get invoked. * * @retval * None * @pre * Component has been initialized and the notification function has been * set via the cpaDcInstanceSetNotificationCb function. * @post * None * @note * None * @see * cpaDcInstanceSetNotificationCb(), * *****************************************************************************/ typedef void (*CpaDcInstanceNotificationCbFunc)( const CpaInstanceHandle instanceHandle, void * pCallbackTag, const CpaInstanceEvent instanceEvent); /** ***************************************************************************** * @ingroup cpaDc * Subscribe for instance notifications. * * @description * Clients of the CpaDc interface can subscribe for instance notifications * by registering a @ref CpaDcInstanceNotificationCbFunc function. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pInstanceNotificationCb Instance notification callback * function pointer. * @param[in] pCallbackTag Opaque value provided by user while * making individual function calls. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Instance has been initialized. * @post * None * @note * None * @see * CpaDcInstanceNotificationCbFunc * *****************************************************************************/ CpaStatus cpaDcInstanceSetNotificationCb( const CpaInstanceHandle instanceHandle, const CpaDcInstanceNotificationCbFunc pInstanceNotificationCb, void *pCallbackTag); /** ***************************************************************************** * @ingroup cpaDc * Get the size of the memory required to hold the session information. * * @description * * The client of the Data Compression API is responsible for * allocating sufficient memory to hold session information and the context * data. This function provides a means for determining the size of the * session information and the size of the context data. * * @context * No restrictions * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Instance handle. * @param[in] pSessionData Pointer to a user instantiated structure * containing session data. * @param[out] pSessionSize On return, this parameter will be the size * of the memory that will be * required by cpaDcInitSession() for session * data. * @param[out] pContextSize On return, this parameter will be the size * of the memory that will be required * for context data. Context data is * save/restore data including history and * any implementation specific data that is * required for a save/restore operation. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * Only a synchronous version of this function is provided. * * It is expected that context data is comprised of the history and * any data stores that are specific to the history such as linked * lists or hash tables. * For stateless sessions the context size returned from this function * will be zero. For stateful sessions the context size returned will * depend on the session setup data and may be zero. * * Session data is expected to include interim checksum values, various * counters and other session related data that needs to persist * between invocations. * For a given implementation of this API, it is safe to assume that * cpaDcGetSessionSize() will always return the same session size and * that the size will not be different for different setup data * parameters. However, it should be noted that the size may change: * (1) between different implementations of the API (e.g. between software * and hardware implementations or between different hardware * implementations) * (2) between different releases of the same API implementation. * * @see * cpaDcInitSession() * *****************************************************************************/ CpaStatus cpaDcGetSessionSize(CpaInstanceHandle dcInstance, CpaDcSessionSetupData* pSessionData, Cpa32U* pSessionSize, Cpa32U* pContextSize ); /** ***************************************************************************** * @ingroup cpaDc * Function to return the size of the memory which must be allocated for * the pPrivateMetaData member of CpaBufferList. * * @description * This function is used to obtain the size (in bytes) required to allocate * a buffer descriptor for the pPrivateMetaData member in the * CpaBufferList structure. * Should the function return zero then no meta data is required for the * buffer list. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[in] numBuffers The number of pointers in the CpaBufferList. * This is the maximum number of CpaFlatBuffers * which may be contained in this CpaBufferList. * @param[out] pSizeInBytes Pointer to the size in bytes of memory to be * allocated when the client wishes to allocate * a cpaFlatBuffer. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * None * @see * cpaDcGetInstances() * *****************************************************************************/ CpaStatus cpaDcBufferListGetMetaSize(const CpaInstanceHandle instanceHandle, Cpa32U numBuffers, Cpa32U *pSizeInBytes); /** ***************************************************************************** * @ingroup cpaDc * Function to return a string indicating the specific error that occurred * within the system. * * @description * When a function returns any error including CPA_STATUS_SUCCESS, the * client can invoke this function to get a string which describes the * general error condition, and if available additional information on * the specific error. * The Client MUST allocate CPA_STATUS_MAX_STR_LENGTH_IN_BYTES bytes for the buffer * string. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Handle to an instance of this API. * @param[in] errStatus The error condition that occurred. * @param[in,out] pStatusText Pointer to the string buffer that will * be updated with the status text. The invoking * application MUST allocate this buffer to be * exactly CPA_STATUS_MAX_STR_LENGTH_IN_BYTES. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Note, in this scenario * it is INVALID to call this function a * second time. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * None * @see * CpaStatus * *****************************************************************************/ CpaStatus cpaDcGetStatusText(const CpaInstanceHandle dcInstance, const CpaStatus errStatus, Cpa8S * pStatusText); /** ***************************************************************************** * @ingroup cpaDc * Set Address Translation function * * @description * This function is used to set the virtual to physical address * translation routine for the instance. The specified routine * is used by the instance to perform any required translation of * a virtual address to a physical address. If the application * does not invoke this function, then the instance will use its * default method, such as virt2phys, for address translation. * * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Data Compression API instance handle. * @param[in] virtual2Physical Routine that performs virtual to * physical address translation. * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus cpaDcSetAddressTranslation(const CpaInstanceHandle instanceHandle, CpaVirtualToPhysical virtual2Physical); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_DC_H */ diff --git a/sys/dev/qat/qat_api/include/dc/cpa_dc_bp.h b/sys/dev/qat/qat_api/include/dc/cpa_dc_bp.h index c9eef94e0a60..67a70c7193a7 100644 --- a/sys/dev/qat/qat_api/include/dc/cpa_dc_bp.h +++ b/sys/dev/qat/qat_api/include/dc/cpa_dc_bp.h @@ -1,320 +1,320 @@ -/**************************************************************************** +/*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_dc_bp.h * * @defgroup cpaDcBp Data Compression Batch and Pack API * * @ingroup cpaDc * * @description * These functions specify the API for Data Compression operations related * to the 'Batch and Pack' mode of operation. * * @remarks * * *****************************************************************************/ #ifndef CPA_DC_BP_H #define CPA_DC_BP_H #ifdef __cplusplus extern"C" { #endif #include "cpa_dc.h" /** ***************************************************************************** * @ingroup cpaDcBp * Batch request input parameters. * @description * This structure contains the request information for use with batched * compression operations. * * ****************************************************************************/ typedef struct _CpaDcBatchOpData { CpaDcOpData opData; /**< Compression input parameters */ CpaBufferList *pSrcBuff; /**< Input buffer list containing the data to be compressed. */ CpaBoolean resetSessionState; /**< Reset the session state at the beginning of this request within * the batch. Only applies to stateful sessions. When this flag is * set, the history from previous requests in this session will not be * used when compressing the input data for this request in the batch. * */ } CpaDcBatchOpData ; /** ***************************************************************************** * @ingroup cpaDcBp * Submit a batch of requests to compress a batch of input buffers into * a common output buffer. The same output buffer is used for each request * in the batch. This is termed 'batch and pack'. * * @description * This API consumes data from the input buffer and generates compressed * data in the output buffer. * This API compresses a batch of input buffers and concatenates the * compressed data into the output buffer. A results structure is also * generated for each request in the batch. * * @context * When called as an asynchronous funnction it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in,out] pSessionHandle Session handle. * @param[in] numRequests Number of requests in the batch. * @param[in] pBatchOpData Pointer to an array of CpaDcBatchOpData * structures which contain the input buffers * and parameters for each request in the * batch. There should be numRequests entries * in the array. * @param[in] pDestBuff Pointer to buffer space for data after * compression. * @param[in,out] pResults Pointer to an array of results structures. * There should be numRequests entries in the * array. * @param[in] callbackTag User supplied value to help correlate * the callback with its associated * request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_DC_BAD_DATA The input data was not properly formed. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * * @pre * pSessionHandle has been setup using cpaDcInitSession() * Session must be setup as a stateless sesssion. * @note * This function passes control to the compression service for processing * * In synchronous mode the function returns the error status returned from the * service. In asynchronous mode the status is returned by the callback * function. * * This function may be called repetitively with input until all of the input * has been consumed by the compression service and all the output has been * produced. * * When this function returns, it may be that all of the available buffers in * the input list has not been compressed. This situation will occur when * there is insufficient space in the output buffer. The calling application * should note the amount of buffers processed, and then submit the request * again, with a new output buffer and with the input buffer list containing * the buffers that were not previously compressed. * * Relationship between input buffers and results buffers. * -# Implementations of this API must not modify the individual * flat buffers of the input buffer list. * -# The implementation communicates the number of buffers * consumed from the source buffer list via pResults->consumed arg. * -# The implementation communicates the amount of data in the * destination buffer list via pResults->produced arg. * * Source Buffer Setup Rules * -# The buffer list must have the correct number of flat buffers. This * is specified by the numBuffers element of the CpaBufferList. * -# Each flat buffer must have a pointer to contiguous memory that has * been allocated by the calling application. The number of octets to be * compressed or decompressed must be stored in the dataLenInBytes element * of the flat buffer. * -# It is permissible to have one or more flat buffers with a zero length * data store. This function will process all flat buffers until the * destination buffer is full or all source data has been processed. * If a buffer has zero length, then no data will be processed from * that buffer. * * Source Buffer Processing Rules. * -# The buffer list is processed in index order - SrcBuff->pBuffers[0] * will be completely processed before SrcBuff->pBuffers[1] begins to * be processed. * -# The application must drain the destination buffers. * If the source data was not completely consumed, the application * must resubmit the request. * -# On return, the pResults->consumed will indicate the number of buffers * consumed from the input buffer list. * * Destination Buffer Setup Rules * -# The destination buffer list must have storage for processed data and * for the packed header information. * This means that least two flat buffer must exist in the buffer list. * The first buffer entry will be used for the header information. * Subsequent entries will be used for the compressed data. * -# For each flat buffer in the buffer list, the dataLenInBytes element * must be set to the size of the buffer space. * -# It is permissible to have one or more flat buffers with a zero length * data store. * If a buffer has zero length, then no data will be added to * that buffer. * * Destination Buffer Processing Rules. * -# The buffer list is processed in index order. * -# On return, the pResults->produced will indicate the number of bytes * of compressed data written to the output buffers. Note that this * will not include the header information buffer. * -# If processing has not been completed, the application must drain the * destination buffers and resubmit the request. The application must reset * the dataLenInBytes for each flat buffer in the destination buffer list. * * Synchronous or Asynchronous operation of the API is determined by * the value of the callbackFn parameter passed to cpaDcInitSession() * when the sessionHandle was setup. If a non-NULL value was specified * then the supplied callback function will be invoked asynchronously * with the response of this request. * * Response ordering: * For each session, the implementation must maintain the order of * responses. That is, if in asynchronous mode, the order of the callback * functions must match the order of jobs submitted by this function. * In a simple synchronous mode implementation, the practice of submitting * a request and blocking on its completion ensure ordering is preserved. * * This limitation does not apply if the application employs multiple * threads to service a single session. * * If this API is invoked asynchronous, the return code represents * the success or not of asynchronously scheduling the request. * The results of the operation, along with the amount of data consumed * and produced become available when the callback function is invoked. * As such, pResults->consumed and pResults->produced are available * only when the operation is complete. * * The application must not use either the source or destination buffers * until the callback has completed. * * @see * None * *****************************************************************************/ CpaStatus cpaDcBPCompressData( CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, const Cpa32U numRequests, CpaDcBatchOpData *pBatchOpData, CpaBufferList *pDestBuff, CpaDcRqResults *pResults, void *callbackTag ); /** ***************************************************************************** * @ingroup cpaDcBp * Function to return the size of the memory which must be allocated for * the pPrivateMetaData member of CpaBufferList contained within * CpaDcBatchOpData. * * @description * This function is used to obtain the size (in bytes) required to allocate * a buffer descriptor for the pPrivateMetaData member in the * CpaBufferList structure when Batch and Pack API are used. * Should the function return zero then no meta data is required for the * buffer list. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[in] numJobs The number of jobs defined in the CpaDcBatchOpData * table. * @param[out] pSizeInBytes Pointer to the size in bytes of memory to be * allocated when the client wishes to allocate * a cpaFlatBuffer and the Batch and Pack OP data. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * * @pre * None * @post * None * @note * None * @see * cpaDcBPCompressData() * *****************************************************************************/ CpaStatus cpaDcBnpBufferListGetMetaSize(const CpaInstanceHandle instanceHandle, Cpa32U numJobs, Cpa32U *pSizeInBytes); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_DC_BP_H */ diff --git a/sys/dev/qat/qat_api/include/dc/cpa_dc_chain.h b/sys/dev/qat/qat_api/include/dc/cpa_dc_chain.h index 0baab2547f18..8679b64fa5b5 100644 --- a/sys/dev/qat/qat_api/include/dc/cpa_dc_chain.h +++ b/sys/dev/qat/qat_api/include/dc/cpa_dc_chain.h @@ -1,659 +1,655 @@ -/**************************************************************************** +/*************************************************************************** * * BSD LICENSE * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_dc_chain.h * * @defgroup cpaDcChain Data Compression Chaining API * * @ingroup cpaDc * * @description * These functions specify the API for Data Compression Chaining operations. * * @remarks * * *****************************************************************************/ #ifndef CPA_DC_CHAIN_H #define CPA_DC_CHAIN_H #ifdef __cplusplus extern"C" { #endif #include "cpa_dc.h" #include "cpa_cy_sym.h" /** ***************************************************************************** * @ingroup cpaDcChain * Supported operations for compression chaining * * @description * This enumeration lists the supported operations for compression chaining * *****************************************************************************/ typedef enum _CpaDcChainOperations { - CPA_DC_CHAIN_COMPRESS_THEN_HASH, + CPA_DC_CHAIN_COMPRESS_THEN_HASH = 0, /**< 2 operations for chaining: * 1st operation is to perform compression on plain text * 2nd operation is to perform hash on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for compression setup data * 2nd entry is for hash setup data*/ - CPA_DC_CHAIN_COMPRESS_THEN_ENCRYPT, + CPA_DC_CHAIN_COMPRESS_THEN_ENCRYPT = 1, /**< 2 operations for chaining: * 1st operation is to perform compression on plain text * 2nd operation is to perform encryption on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for compression setup data * 2nd entry is for encryption setup data*/ - CPA_DC_CHAIN_COMPRESS_THEN_HASH_ENCRYPT, + CPA_DC_CHAIN_COMPRESS_THEN_HASH_ENCRYPT = 2, /**< 2 operations for chaining: * 1st operation is to perform compression on plain text * 2nd operation is to perform hash on compressed text and * encryption on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for compression setup data * 2nd entry is for hash and encryption setup data*/ - CPA_DC_CHAIN_COMPRESS_THEN_ENCRYPT_HASH, + CPA_DC_CHAIN_COMPRESS_THEN_ENCRYPT_HASH = 3, /**< 2 operations for chaining: * 1st operation is to perform compression on plain text * 2nd operation is to perform encryption on compressed text and * hash on compressed & encrypted text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for compression setup data * 2nd entry is for encryption and hash setup data*/ - CPA_DC_CHAIN_COMPRESS_THEN_AEAD, + CPA_DC_CHAIN_COMPRESS_THEN_AEAD = 4, /**< 2 operations for chaining: * 1st operation is to perform compression on plain text * 2nd operation is to perform AEAD encryption on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for compression setup data * 2nd entry is for AEAD encryption setup data*/ - CPA_DC_CHAIN_HASH_THEN_COMPRESS, + CPA_DC_CHAIN_HASH_THEN_COMPRESS = 5, /**< 2 operations for chaining: * 1st operation is to perform hash on plain text * 2nd operation is to perform compression on plain text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for hash setup data * 2nd entry is for compression setup data*/ - CPA_DC_CHAIN_HASH_VERIFY_THEN_DECOMPRESS, + CPA_DC_CHAIN_HASH_VERIFY_THEN_DECOMPRESS = 6, /**< 2 operations for chaining: * 1st operation is to perform hash verify on compressed text * 2nd operation is to perform decompression on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for hash setup data * 2nd entry is for decompression setup data*/ - CPA_DC_CHAIN_DECRYPT_THEN_DECOMPRESS, + CPA_DC_CHAIN_DECRYPT_THEN_DECOMPRESS = 7, /**< 2 operations for chaining: * 1st operation is to perform decryption on compressed & encrypted text * 2nd operation is to perform decompression on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for decryption setup data * 2nd entry is for decompression setup data*/ - CPA_DC_CHAIN_HASH_VERIFY_DECRYPT_THEN_DECOMPRESS, + CPA_DC_CHAIN_HASH_VERIFY_DECRYPT_THEN_DECOMPRESS = 8, /**< 2 operations for chaining: * 1st operation is to perform hash verify on compressed & encrypted text * and decryption on compressed & encrypted text * 2nd operation is to perform decompression on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for hash and decryption setup data * 2nd entry is for decompression setup data*/ - CPA_DC_CHAIN_DECRYPT_HASH_VERIFY_THEN_DECOMPRESS, + CPA_DC_CHAIN_DECRYPT_HASH_VERIFY_THEN_DECOMPRESS = 9, /**< 2 operations for chaining: * 1st operation is to perform decryption on compressed & encrypted text * and hash verify on compressed text * 2nd operation is to perform decompression on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for decryption and hash setup data * 2nd entry is for decompression setup data*/ - CPA_DC_CHAIN_AEAD_THEN_DECOMPRESS, + CPA_DC_CHAIN_AEAD_THEN_DECOMPRESS = 10, /**< 2 operations for chaining: * 1st operation is to perform AEAD decryption on compressed & encrypted text * 2nd operation is to perform decompression on compressed text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for AEAD decryption setup data * 2nd entry is for decompression setup data*/ - CPA_DC_CHAIN_DECOMPRESS_THEN_HASH_VERIFY, + CPA_DC_CHAIN_DECOMPRESS_THEN_HASH_VERIFY = 11, /**< 2 operations for chaining: * 1st operation is to perform decompression on compressed text * 2nd operation is to perform hash verify on plain text **< 2 entries in CpaDcChainSessionSetupData array: * 1st entry is for decompression setup data * 2nd entry is for hash setup data*/ - CPA_DC_CHAIN_COMPRESS_THEN_AEAD_THEN_HASH, + CPA_DC_CHAIN_COMPRESS_THEN_AEAD_THEN_HASH = 12, /**< 3 operations for chaining: * 1st operation is to perform compression on plain text - * 2nd operation is to perform AEAD encryption compressed text - * 3rd operation is to perfom hash on compressed & encrypted text + * 2nd operation is to perform AEAD encryption on compressed text + * 3rd operation is to perform hash on compressed & encrypted text **< 3 entries in CpaDcChainSessionSetupData array: * 1st entry is for compression setup data * 2nd entry is for AEAD encryption setup data * 3rd entry is for hash setup data*/ } CpaDcChainOperations; /** ***************************************************************************** * @ingroup cpaDcChain * Supported session types for data compression chaining. * * @description * This enumeration lists the supported session types * for data compression chaining. *****************************************************************************/ typedef enum _CpaDcChainSessionType { - CPA_DC_CHAIN_COMPRESS_DECOMPRESS, + CPA_DC_CHAIN_COMPRESS_DECOMPRESS = 0, /**< Indicate the session is for compression or decompression */ - CPA_DC_CHAIN_SYMMETRIC_CRYPTO, + CPA_DC_CHAIN_SYMMETRIC_CRYPTO /**< Indicate the session is for symmetric crypto */ } CpaDcChainSessionType; /** ***************************************************************************** * @ingroup cpaDcChain * Chaining Session Setup Data. * @description * This structure contains data relating to set up chaining sessions. The * client needs to complete the information in this structure in order to * setup chaining sessions. * ****************************************************************************/ typedef struct _CpaDcChainSessionSetupData { CpaDcChainSessionType sessType; /**Indicate the type for this session */ union { CpaDcSessionSetupData *pDcSetupData; /**< Pointer to compression session setup data */ CpaCySymSessionSetupData *pCySetupData; - /**< Pointer to symmectric crypto session setup data */ + /**< Pointer to symmetric crypto session setup data */ }; } CpaDcChainSessionSetupData; /** ***************************************************************************** * @ingroup cpaDcChain * Compression chaining request input parameters. * @description * This structure contains the request information to use with * compression chaining operations. * ****************************************************************************/ typedef struct _CpaDcChainOpData { CpaDcChainSessionType opType; /**< Indicate the type for this operation */ union { CpaDcOpData *pDcOp; /**< Pointer to compression operation data */ CpaCySymOpData *pCySymOp; - /**< Pointer to symmectric crypto operation data */ + /**< Pointer to symmetric crypto operation data */ }; } CpaDcChainOpData; /** ***************************************************************************** * @ingroup cpaDcChain * Chaining request results data * @description * This structure contains the request results. * ****************************************************************************/ typedef struct _CpaDcChainRqResults { CpaDcReqStatus dcStatus; /**< Additional status details from compression accelerator */ CpaStatus cyStatus; /**< Additional status details from symmetric crypto accelerator */ CpaBoolean verifyResult; /**< This parameter is valid when the verifyDigest option is set in the * CpaCySymSessionSetupData structure. A value of CPA_TRUE indicates * that the compare succeeded. A value of CPA_FALSE indicates that the * compare failed */ Cpa32U produced; /**< Octets produced to the output buffer */ Cpa32U consumed; /**< Octets consumed from the input buffer */ Cpa32U crc32; /**< crc32 checksum produced by chaining operations */ Cpa32U adler32; - /**< adler32 checksum produced by chaining operations */ + /**< Adler32 checksum produced by chaining operations */ }CpaDcChainRqResults; /** ***************************************************************************** * @ingroup cpaDcChain * Get the size of the memory required to hold the chaining sessions * information. * * @description * The client of the Data Compression API is responsible for * allocating sufficient memory to hold chaining sessions information. * This function provides a way for determining the size of chaining * sessions. * * @context * No restrictions * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Instance handle. * @param[in] operation The operation for chaining * @param[in] numSessions Number of sessions for the chaining * @param[in] pSessionData Pointer to an array of * CpaDcChainSessionSetupData structures. * There should be numSessions entries in * the array. * @param[out] pSessionSize On return, this parameter will be the size * of the memory that will be required by * cpaDcChainInitSession() for session data. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * Only a synchronous version of this function is provided. * * @see * cpaDcChainInitSession() * *****************************************************************************/ CpaStatus cpaDcChainGetSessionSize(CpaInstanceHandle dcInstance, CpaDcChainOperations operation, Cpa8U numSessions, CpaDcChainSessionSetupData *pSessionData, Cpa32U* pSessionSize); /** ***************************************************************************** * @ingroup cpaDcChain * Initialize data compression chaining session * * @description * This function is used to initialize compression/decompression chaining * sessions. * This function returns a unique session handle each time this function * is invoked. * If the session has been configured with a callback function, then * the order of the callbacks are guaranteed to be in the same order the * compression or decompression requests were submitted for each session, * so long as a single thread of execution is used for job submission. * * @context * This is a synchronous function and it cannot sleep. It can be executed * in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Instance handle derived from discovery * functions. * @param[in,out] pSessionHandle Pointer to a session handle. * @param[in] operation The operations for chaining * @param[in] numSessions Number of sessions for chaining * @param[in,out] pSessionData Pointer to an array of * CpaDcChainSessionSetupData structures. * There should be numSessions entries in * the array. * @param[in] callbackFn For synchronous operation this callback * shall be a null pointer. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. - * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit - * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * dcInstance has been started using cpaDcStartInstance. * @post * None * @note * Only a synchronous version of this function is provided. * * pSessionData Setup Rules * -# Each element in CpaDcChainSessionSetupData structure array provides * (de)compression or a symmetric crypto session setup data. * * -# The supported chaining operations are listed in CpaDcChainOperations. * This enum indicates the number of operations in a chain and the order * in which they are performed. * * -# The order of entries in pSessionData[] should be consistent with the * CpaDcChainOperations perform order. * As an example, for CPA_DC_CHAIN_COMPRESS_THEN_ENCRYPT, pSessionData[0] * holds the compression setup data and pSessionData[1] holds the * encryption setup data.. * * -# The numSessions for each chaining operation are provided in * the comments of enum CpaDcChainOperations. * * -# For a (de)compression session, the corresponding * pSessionData[]->sessType should be set to * CPA_DC_CHAIN_COMPRESS_DECOMPRESS and pSessionData[]->pDcSetupData * should point to a CpaDcSessionSetupData structure. * * -# For a symmetric crypto session, the corresponding * pSessionData[]->sessType should be set to CPA_DC_CHAIN_SYMMETRIC_CRYPTO * and pSessionData[]->pCySetupData should point to a * CpaCySymSessionSetupData structure. * * -# Combined compression sessions are not supported for chaining. * * -# Stateful compression is not supported for chaining. * * -# Both CRC32 and Adler32 over the input data are supported for chaining. * * @see * None * *****************************************************************************/ CpaStatus cpaDcChainInitSession(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaDcChainOperations operation, Cpa8U numSessions, CpaDcChainSessionSetupData *pSessionData, CpaDcCallbackFn callbackFn); /** ***************************************************************************** * @ingroup cpaDcChain * Reset a compression chaining session. * * @description * This function will reset a previously initialized session handle. * Reset will fail if outstanding calls still exist for the initialized * session handle. * The client needs to retry the reset function at a later time. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Instance handle. * @param[in,out] pSessionHandle Session handle. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaDcStartInstance function. * The session has been initialized via cpaDcChainInitSession function. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * * @see * cpaDcChainInitSession() * *****************************************************************************/ CpaStatus cpaDcChainResetSession(const CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle); /** ***************************************************************************** * @ingroup cpaDcChain * Remove a compression chaining session. * * @description * This function will remove a previously initialized session handle * and the installed callback handler function. Removal will fail if * outstanding calls still exist for the initialized session handle. * The client needs to retry the remove function at a later time. * The memory for the session handle MUST not be freed until this call * has completed successfully. * * @context * This is a synchronous function that cannot sleep. It can be executed * in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Instance handle. * @param[in,out] pSessionHandle Session handle. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaDcStartInstance function. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * * @see * cpaDcChainInitSession() * *****************************************************************************/ CpaStatus cpaDcChainRemoveSession(const CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle); /** ***************************************************************************** * @ingroup cpaDcChain * Submit a request to perform chaining operations. * * @description * This function is used to perform chaining operations over data from * the source buffer. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] dcInstance Target service instance. * @param[in,out] pSessionHandle Session handle. * @param[in] pSrcBuff Pointer to input data buffer. * @param[out] pDestBuff Pointer to output data buffer. * @param[in] operation Operation for the chaining request * @param[in] numOpDatas The entries size CpaDcChainOpData array * @param[in] pChainOpData Pointer to an array of CpaDcChainOpData * structures. There should be numOpDatas * entries in the array. - * @param[in,out] pResults Pointer to CpaDcChainRqResults structure. + * @param[in,out] pResults Pointer to CpaDcChainRqResults * @param[in] callbackTag User supplied value to help correlate * the callback with its associated request. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_DC_BAD_DATA The input data was not properly formed. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * pSessionHandle has been setup using cpaDcChainInitSession() * @post * pSessionHandle has session related state information * @note * This function passes control to the compression service for chaining * processing, the supported chaining operations are described in * CpaDcChainOperations. * * pChainOpData Setup Rules * -# Each element in CpaDcChainOpData structure array holds either a * (de)compression or a symmetric crypto operation data. * * -# The order of entries in pChainOpData[] must be consistent with the * order of operations described for the chaining operation in * CpaDcChainOperations. - * As an example, for CPA_DC_CHAIN_COMPRESS_THEN_ENCRYPT, pChainOpData[0] - * must contain the compression operation data and pChainOpData[1] must - * contain the encryption operation data. + * As an example, for CPA_DC_CHAIN_HASH_THEN_COMPRESS, pChainOpData[0] + * must contain the hash operation data and pChainOpData[1] must + * contain the compress operation data. * * -# The numOpDatas for each chaining operation are specified in the * comments for the operation in CpaDcChainOperations. * * -# For a (de)compression operation, the corresponding * pChainOpData[]->opType should be set to * CPA_DC_CHAIN_COMPRESS_DECOMPRESS and pChainOpData[]->pDcOp should * point to a CpaDcOpData structure. * * -# For a symmetric crypto operation, the corresponding * pChainOpData[]->opType should be set to * CPA_DC_CHAIN_SYMMETRIC_CRYPTO and pChainOpData[]->pCySymOp should * point to a CpaCySymOpData structure. * - * -# Stateful compression is not supported for chaining. - * * -# Partial packet processing is not supported. * * This function has identical buffer processing rules as * cpaDcCompressData(). * * This function has identical checksum processing rules as * cpaDcCompressData(), except: * -# pResults->crc32 is available to application if * CpaDcSessionSetupData->checksum is set to CPA_DC_CRC32 * * -# pResults->adler32 is available to application if * CpaDcSessionSetupData->checksum is set to CPA_DC_ADLER32 * * -# Both pResults->crc32 and pResults->adler32 are available if * CpaDcSessionSetupData->checksum is set to CPA_DC_CRC32_ADLER32 * * Synchronous or asynchronous operation of the API is determined by * the value of the callbackFn parameter passed to cpaDcChainInitSession() * when the sessionHandle was setup. If a non-NULL value was specified * then the supplied callback function will be invoked asynchronously * with the response of this request. * * This function has identical response ordering rules as * cpaDcCompressData(). * * @see * cpaDcCompressData * *****************************************************************************/ CpaStatus cpaDcChainPerformOp(CpaInstanceHandle dcInstance, CpaDcSessionHandle pSessionHandle, CpaBufferList *pSrcBuff, CpaBufferList *pDestBuff, CpaDcChainOperations operation, Cpa8U numOpDatas, CpaDcChainOpData *pChainOpData, CpaDcChainRqResults *pResults, void *callbackTag ); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_DC_CHAIN_H */ diff --git a/sys/dev/qat/qat_api/include/dc/cpa_dc_dp.h b/sys/dev/qat/qat_api/include/dc/cpa_dc_dp.h index 680e021f95d6..a0aac8037855 100644 --- a/sys/dev/qat/qat_api/include/dc/cpa_dc_dp.h +++ b/sys/dev/qat/qat_api/include/dc/cpa_dc_dp.h @@ -1,1250 +1,1250 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_dc_dp.h * * @defgroup cpaDcDp Data Compression Data Plane API * * @ingroup cpaDc * * @description * These data structures and functions specify the Data Plane API * for compression and decompression operations. * * This API is recommended for data plane applications, in which the * cost of offload - that is, the cycles consumed by the driver in * sending requests to the hardware, and processing responses - needs * to be minimized. In particular, use of this API is recommended * if the following constraints are acceptable to your application: * * - Thread safety is not guaranteed. Each software thread should * have access to its own unique instance (CpaInstanceHandle) to * avoid contention. * - Polling is used, rather than interrupts (which are expensive). * Implementations of this API will provide a function (not * defined as part of this API) to read responses from the hardware * response queue and dispatch callback functions, as specified on * this API. * - Buffers and buffer lists are passed using physical addresses, * to avoid virtual to physical address translation costs. * - The ability to enqueue one or more requests without submitting * them to the hardware allows for certain costs to be amortized * across multiple requests. * - Only asynchronous invocation is supported. * - There is no support for partial packets. * - Implementations may provide certain features as optional at * build time, such as atomic counters. * - There is no support for stateful operations. * - The "default" instance (CPA_INSTANCE_HANDLE_SINGLE) is not * supported on this API. The specific handle should be obtained * using the instance discovery functions (@ref cpaDcGetNumInstances, * @ref cpaDcGetInstances). * *****************************************************************************/ #ifndef CPA_DC_DP_H #define CPA_DC_DP_H #ifdef __cplusplus extern "C" { #endif #include "cpa_dc.h" /** ***************************************************************************** * @ingroup cpaDcDp * Decompression partial read data. * @description * This structure contains configuration related to requesting * specific chunk of decompression data. * ****************************************************************************/ typedef struct _CpaDcDpPartialReadData { Cpa32U bufferOffset; /**< Number of bytes to skip in a destination buffer (or buffers list) * before writing. At this point only zero is supported. */ Cpa32U dataOffset; /**< The offset in the decompressed data of the first byte written to * the destination buffer. The data offset length should be an integer * multiple of 4KB in order to achieve the best performance. */ Cpa32U length; /**< Size of requested decompressed data chunk. The length should be * an integer multiple of 4KB in order to achieve the best performance. */ } CpaDcDpPartialReadData; /** ***************************************************************************** * @ingroup cpaDcDp * Operation Data for compression data plane API. * * @description * This structure contains data relating to a request to perform * compression processing on one or more data buffers. * * The physical memory to which this structure points should be * at least 8-byte aligned. * * All reserved fields SHOULD NOT be written or read by the * calling code. * * @see * cpaDcDpEnqueueOp, cpaDcDpEnqueueOpBatch ****************************************************************************/ typedef struct _CpaDcDpOpData { Cpa64U reserved0; /**< Reserved for internal use. Source code should not read or write * this field. */ Cpa32U bufferLenToCompress; /**< The number of bytes from the source buffer to compress. This must be * less than, or more typically equal to, the total size of the source * buffer (or buffer list). */ Cpa32U bufferLenForData; /**< The maximum number of bytes that should be written to the destination * buffer. This must be less than, or more typically equal to, the total * size of the destination buffer (or buffer list). */ Cpa64U reserved1; /**< Reserved for internal use. Source code should not read or write */ Cpa64U reserved2; /**< Reserved for internal use. Source code should not read or write */ Cpa64U reserved3; /**< Reserved for internal use. Source code should not read or write */ CpaDcRqResults results; /**< Results of the operation. Contents are valid upon completion. */ CpaInstanceHandle dcInstance; /**< Instance to which the request is to be enqueued */ CpaDcSessionHandle pSessionHandle; /**< DC Session associated with the stream of requests. * This field is only valid when using the session based API functions. * This field must be set to NULL if the application wishes to use * the No-Session (Ns) API. */ CpaPhysicalAddr srcBuffer; /**< Physical address of the source buffer on which to operate. * This is either the location of the data, of length srcBufferLen; or, * if srcBufferLen has the special value @ref CPA_DP_BUFLIST, then * srcBuffer contains the location where a @ref CpaPhysBufferList is * stored. */ Cpa32U srcBufferLen; /**< If the source buffer is a "flat buffer", then this field * specifies the size of the buffer, in bytes. If the source buffer * is a "buffer list" (of type @ref CpaPhysBufferList), then this field * should be set to the value @ref CPA_DP_BUFLIST. */ CpaPhysicalAddr destBuffer; /**< Physical address of the destination buffer on which to operate. * This is either the location of the data, of length destBufferLen; or, * if destBufferLen has the special value @ref CPA_DP_BUFLIST, then * destBuffer contains the location where a @ref CpaPhysBufferList is * stored. */ Cpa32U destBufferLen; /**< If the destination buffer is a "flat buffer", then this field * specifies the size of the buffer, in bytes. If the destination buffer * is a "buffer list" (of type @ref CpaPhysBufferList), then this field * should be set to the value @ref CPA_DP_BUFLIST. */ CpaDcSessionDir sessDirection; /**pSessionHandle was setup using * @ref cpaDcDpInitSession OR pOpData->pSetupData data structure was * initialized for No-Session (Ns) usage. * The instance identified by pOpData->dcInstance has had a * callback function registered via @ref cpaDcDpRegCbFunc. * * @post * None * * @note * A callback of type @ref CpaDcDpCallbackFn is generated in * response to this function call. Any errors generated during * processing are reported as part of the callback status code. * * @see * @ref cpaDcDpPerformOpNow *****************************************************************************/ CpaStatus cpaDcDpEnqueueOp(CpaDcDpOpData *pOpData, const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaDcDp * Enqueue a single decompression request with partial read configuration. * See @CpaDcDpPartialReadData for more details. * * @description * This function enqueues a single request to perform a decompression * operation and allows to specify particular region of decompressed * data to be placed in to the destination buffer (or buffer list). * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaDcDpRegCbFunc) to be invoked. * Callbacks within a session are guaranteed to be in the same order * in which they were submitted. * * The following restrictions apply to the pOpData parameter: * * - The memory MUST be aligned on an 8-byte boundary. * - The reserved fields of the structure MUST NOT be written to * or read from. * - The structure MUST reside in physically contiguous memory. * * @context * This function will not sleep, and hence can be executed in a context * that does not permit sleeping. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in,out] pOpData See @ref cpaDcDpEnqueueOp pOpData description. * * @param[in] pPartReadData Pointer to a structure containing the partial * read configuration parameters. * See @CpaDcDpPartialReadData for more details. * * @param[in] performOpNow See @ref cpaDcDpEnqueueOp performOpNow input * parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The session identified by pOpData->pSessionHandle was setup using * @ref cpaDcDpInitSession. The instance identified by pOpData->dcInstance * has had a callback function registered via @ref cpaDcDpRegCbFunc. * * @post * None * * @note * A callback of type @ref CpaDcDpCallbackFn is generated in * response to this function call. Any errors generated during * processing are reported as part of the callback status code. * * @see * @ref cpaDcDpPerformOpNow *****************************************************************************/ CpaStatus cpaDcDpEnqueueOpWithPartRead(CpaDcDpOpData *pOpData, CpaDcDpPartialReadData *pPartReadData, const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaDcDp * Enqueue a single compression request with an option set to zero-fill * data after the compression output in the leftover bytes. * * @description * This function enqueues a single request to perform a compression * operation with zero-filling leftover bytes with 4KB alignment * in the destination buffer (or buffer list). * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaDcDpRegCbFunc) to be invoked. * Callbacks within a session are guaranteed to be in the same order * in which they were submitted. * * The following restrictions apply to the pOpData parameter: * * - The memory MUST be aligned on an 8-byte boundary. * - The reserved fields of the structure MUST NOT be written to * or read from. * - The structure MUST reside in physically contiguous memory. * * @context * This function will not sleep, and hence can be executed in a context * that does not permit sleeping. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in,out] pOpData See @ref cpaDcDpEnqueueOp pOpData description. * * @param[in] performOpNow See @ref cpaDcDpEnqueueOp performOpNow input * parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The session identified by pOpData->pSessionHandle was setup using * @ref cpaDcDpInitSession. The instance identified by pOpData->dcInstance * has had a callback function registered via @ref cpaDcDpRegCbFunc. * * @post * None * * @note * A callback of type @ref CpaDcDpCallbackFn is generated in * response to this function call. Any errors generated during * processing are reported as part of the callback status code. * * @see * @ref cpaDcDpPerformOpNow *****************************************************************************/ CpaStatus cpaDcDpEnqueueOpWithZeroPad(CpaDcDpOpData *pOpData, const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaDcDp * Enqueue multiple requests to the compression data plane API. * * @description * This function enqueues multiple requests to perform compression or * decompression operations. * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaDcDpRegCbFunc) to be invoked. * Separate callbacks will be invoked for each request. * Callbacks within a session and at the same priority are guaranteed * to be in the same order in which they were submitted. * * The following restrictions apply to each element of the pOpData * array: * * - The memory MUST be aligned on an 8-byte boundary. * - The reserved fields of the structure MUST be set to zero. * - The structure MUST reside in physically contiguous memory. * * @context * This function will not sleep, and hence can be executed in a context * that does not permit sleeping. * * @assumptions * Client MUST allocate the request parameters to 8 byte alignment. * Reserved elements of the CpaDcDpOpData structure MUST not used * The CpaDcDpOpData structure MUST reside in physically * contiguous memory. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] numberRequests The number of requests in the array of * CpaDcDpOpData structures. * @param[in] pOpData An array of pointers to CpaDcDpOpData * structures. Each CpaDcDpOpData * structure contains the request parameters for * that request. The client code allocates the * memory for this structure. This component takes * ownership of the memory until it is returned in * the callback, which was registered on the * instance via @ref cpaDcDpRegCbFunc. * See the above Description for some restrictions * that apply to this parameter. * @param[in] performOpNow Flag to indicate whether the operation should be * performed immediately (CPA_TRUE), or simply * enqueued to be performed later (CPA_FALSE). * In the latter case, the request is submitted * to be performed either by calling this function * again with this flag set to CPA_TRUE, or by * invoking the function @ref * cpaDcDpPerformOpNow. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The session identified by pOpData[i]->pSessionHandle was setup using * @ref cpaDcDpInitSession OR pOpData[i]->pSetupData data structure was * initialized for No-Session (Ns) usage. * The instance identified by pOpData[i]->dcInstance has had a * callback function registered via @ref cpaDcDpRegCbFunc. * * @post * None * * @note * Multiple callbacks of type @ref CpaDcDpCallbackFn are generated in * response to this function call (one per request). Any errors * generated during processing are reported as part of the callback * status code. * * @see * cpaDcDpEnqueueOp *****************************************************************************/ CpaStatus cpaDcDpEnqueueOpBatch(const Cpa32U numberRequests, CpaDcDpOpData *pOpData[], const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaDcDp * Enqueue multiple decompression request with partial read configuration. * See @CpaDcDpPartialReadData for more details. * * @description * This function enqueues multiple requests to perform decompression * operations and allows to specify particular region of decompressed * data to be placed in to the destination buffer (or buffer list) for * each individual request. * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaDcDpRegCbFunc) to be invoked. * Separate callbacks will be invoked for each request. * Callbacks within a session and at the same priority are guaranteed * to be in the same order in which they were submitted. * * The following restrictions apply to each element of the pOpData * array: * * - The memory MUST be aligned on an 8-byte boundary. * - The reserved fields of the structure MUST be set to zero. * - The structure MUST reside in physically contiguous memory. * * @context * See @ref cpaDcDpEnqueueOpBatch context. * * @assumptions * See @ref cpaDcDpEnqueueOpBatch assumptions. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] numberRequests The number of requests in the array of * CpaDcDpOpData structures. * * @param[in,out] pOpData See @ref cpaDcDpEnqueueOpBatch pOpData for more * details. * * @param[in] pPartReadData An array of pointers to a structures containing * the partial read configuration parameters. * See @CpaDcDpPartialReadData for more details. * * @param[in] performOpNow See @ref cpaDcDpEnqueueOpBatch performOpNow * input parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * * @pre * The session identified by pOpData[i]->pSessionHandle was setup using * @ref cpaDcDpInitSession. The instance identified by * pOpData[i]->dcInstance has had a callback function registered via * @ref cpaDcDpRegCbFunc. * * @post * None * * @note * Multiple callbacks of type @ref CpaDcDpCallbackFn are generated in * response to this function call (one per request). Any errors * generated during processing are reported as part of the callback * status code. * * @see * @ref cpaDcDpEnqueueOp *****************************************************************************/ CpaStatus cpaDcDpEnqueueOpWithPartReadBatch(const Cpa32U numberRequests, CpaDcDpOpData *pOpData[], CpaDcDpPartialReadData *pPartReadData[], const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaDcDp * Enqueue multiple compression requests with an option set to zero-fill * data after the compression output in the leftover bytes. * * @description * This function enqueues multiple requests to perform compression * operations with an option set to zero-fill leftover bytes in the * destination buffer (of buffer list) for each individual request. * Please note that optional zero-filling leftover output buffer bytes * is aligned to 4KB. * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaDcDpRegCbFunc) to be invoked. * Separate callbacks will be invoked for each request. * Callbacks within a session and at the same priority are guaranteed * to be in the same order in which they were submitted. * * The following restrictions apply to each element of the pOpData * array: * * - The memory MUST be aligned on an 8-byte boundary. * - The reserved fields of the structure MUST be set to zero. * - The structure MUST reside in physically contiguous memory. * * @context * See @ref cpaDcDpEnqueueOpBatch context. * * @assumptions * See @ref cpaDcDpEnqueueOpBatch assumptions. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] numberRequests The number of requests in the array of * CpaDcDpOpData structures. * * @param[in,out] pOpData See @ref cpaDcDpEnqueueOpBatch pOpData for more * details. * * @param[in] performOpNow See @ref cpaDcDpEnqueueOpBatch performOpNow * input parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * * @pre * The session identified by pOpData[i]->pSessionHandle was setup using * @ref cpaDcDpInitSession. The instance identified by * pOpData[i]->dcInstance has had a callback function registered via * @ref cpaDcDpRegCbFunc. * * @post * None * * @note * Multiple callbacks of type @ref CpaDcDpCallbackFn are generated in * response to this function call (one per request). Any errors * generated during processing are reported as part of the callback * status code. * * @see * @ref cpaDcDpEnqueueOp *****************************************************************************/ CpaStatus cpaDcDpEnqueueOpWithZeroPadBatch(const Cpa32U numberRequests, CpaDcDpOpData *pOpData[], const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaDcDp * Submit any previously enqueued requests to be performed now on the * compression data plane API. * * @description * This function triggers processing of previously enqueued requests on the * referenced instance. * * * @context * Will not sleep. It can be executed in a context that does not * permit sleeping. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] dcInstance Instance to which the requests will be * submitted. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via @ref cpaDcStartInstance function. * A compression session has been previously setup using the * @ref cpaDcDpInitSession function call. * * @post * None * * @see * cpaDcDpEnqueueOp, cpaDcDpEnqueueOpBatch *****************************************************************************/ CpaStatus cpaDcDpPerformOpNow(CpaInstanceHandle dcInstance); /** ***************************************************************************** * @ingroup cpaDc * Function to return the "partial read" feature support. * * @description * This function is used to determine if given instance supports * "partial read" feature. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[out] pFlag Pointer to boolean flag which indicates * whether a feature is supported. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * None * @see * cpaDcQueryCapabilities() * *****************************************************************************/ CpaStatus cpaDcDpIsPartReadSupported(const CpaInstanceHandle instanceHandle, CpaBoolean *pFlag); /** ***************************************************************************** * @ingroup cpaDc * Function to return the "zero pad" feature support. * * @description * This function is used to determine if given instance supports * "zero pad" feature. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[out] pFlag Pointer to boolean flag which indicates * whether a feature is supported. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * None * @see * cpaDcQueryCapabilities() * *****************************************************************************/ CpaStatus cpaDcDpIsZeroPadSupported(const CpaInstanceHandle instanceHandle, CpaBoolean *pFlag); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_DC_DP_H */ diff --git a/sys/dev/qat/qat_api/include/icp_buffer_desc.h b/sys/dev/qat/qat_api/include/icp_buffer_desc.h index 18ec7042c7e9..ef433495935d 100644 --- a/sys/dev/qat/qat_api/include/icp_buffer_desc.h +++ b/sys/dev/qat/qat_api/include/icp_buffer_desc.h @@ -1,76 +1,77 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ + /** ***************************************************************************** * @file icp_buffer_desc.h * * @defgroup icp_BufferDesc Buffer descriptor for LAC * * @ingroup LacCommon * * @description * This file contains details of the hardware buffer descriptors used to * communicate with the QAT. * *****************************************************************************/ #ifndef ICP_BUFFER_DESC_H #define ICP_BUFFER_DESC_H #include "cpa.h" typedef Cpa64U icp_qat_addr_width_t; // hi32 first, lo32 second -// Alignement constraint of the buffer list. +/* Alignment constraint of the buffer list. */ #define ICP_DESCRIPTOR_ALIGNMENT_BYTES 8 /** ***************************************************************************** * @ingroup icp_BufferDesc * Buffer descriptors for FlatBuffers - used in communications with * the QAT. * * @description * A QAT friendly buffer descriptor. - * All buffer descriptor described in this structure are physcial + * All buffer descriptor described in this structure are physical * and are 64 bit wide. * * Updates in the CpaFlatBuffer should be also reflected in this * structure * *****************************************************************************/ typedef struct icp_flat_buffer_desc_s { Cpa32U dataLenInBytes; Cpa32U reserved; icp_qat_addr_width_t phyBuffer; /**< The client will allocate memory for this using API function calls * and the access layer will fill it and the QAT will read it. */ } icp_flat_buffer_desc_t; /** ***************************************************************************** * @ingroup icp_BufferDesc * Buffer descriptors for BuffersLists - used in communications with * the QAT. * * @description * A QAT friendly buffer descriptor. - * All buffer descriptor described in this structure are physcial + * All buffer descriptor described in this structure are physical * and are 64 bit wide. * * Updates in the CpaBufferList should be also reflected in this structure * *****************************************************************************/ typedef struct icp_buffer_list_desc_s { Cpa64U resrvd; Cpa32U numBuffers; Cpa32U reserved; icp_flat_buffer_desc_t phyBuffers[]; /**< Unbounded array of physical buffer pointers, these point to the * FlatBufferDescs. The client will allocate memory for this using * API function calls and the access layer will fill it and the QAT * will read it. */ } icp_buffer_list_desc_t; #endif /* ICP_BUFFER_DESC_H */ diff --git a/sys/dev/qat/qat_api/include/icp_sal_user.h b/sys/dev/qat/qat_api/include/icp_sal_user.h index fd01fa97d344..6dd8b2a26746 100644 --- a/sys/dev/qat/qat_api/include/icp_sal_user.h +++ b/sys/dev/qat/qat_api/include/icp_sal_user.h @@ -1,907 +1,907 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** * @file icp_sal_user.h * * @ingroup SalUser * * User space process init and shutdown functions. * ***************************************************************************/ #ifndef ICP_SAL_USER_H #define ICP_SAL_USER_H /************************************************************************* * @ingroup SalUser * @description * This function initialises and starts user space service access layer * (SAL) - it registers SAL with ADF and initialises the ADF proxy. * This function must only be called once per user space process. * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pProcessName Process address space name described in * the config file for this device * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * *************************************************************************/ CpaStatus icp_sal_userStart(const char *pProcessName); /************************************************************************* * @ingroup SalUser * @description * This function is to be used with simplified config file, where user * defines many user space processes. The driver generates unique * process names based on the pProcessName provided. * For example: * If a config file in simplified format contains: * [SSL] * NumProcesses = 3 * * Then three internal sections will be generated and the three * applications can be started at a given time. Each application can call * icp_sal_userStartMultiProcess("SSL"). In this case the driver will * figure out the unique name to use for each process. * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pProcessName Process address space name described in * the new format of the config file * for this device. * * @param[in] limitDevAccess Specifies if the address space is limited * to one device (true) or if it spans - * accross multiple devices. + * across multiple devices. * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed. In this case user * can wait and retry. * *************************************************************************/ CpaStatus icp_sal_userStartMultiProcess(const char *pProcessName, CpaBoolean limitDevAccess); /************************************************************************* * @ingroup SalUser * @description * This function stops and shuts down user space SAL * - it deregisters SAL with ADF and shuts down ADF proxy * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userStop(void); /************************************************************************* * @ingroup SalUser * @description * This function gets the number of the available dynamic allocated * crypto instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyGetAvailableNumDynInstances(Cpa32U *pNumCyInstances); /************************************************************************* * @ingroup SalUser * @description * This function gets the number of the available dynamic allocated * compression instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userDcGetAvailableNumDynInstances(Cpa32U *pNumDcInstances); /************************************************************************* * @ingroup SalUser * @description * This function gets the number of the available dynamic allocated * crypto instances which are from the specific device package. * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyGetAvailableNumDynInstancesByDevPkg(Cpa32U *pNumCyInstances, Cpa32U devPkgID); /************************************************************************* * @ingroup SalUser * @description * This function gets the number of the available dynamic allocated * crypto instances which are from the specific device package and specific * accelerator. * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyGetAvailableNumDynInstancesByPkgAccel(Cpa32U *pNumCyInstances, Cpa32U devPkgID, Cpa32U accelerator_number); /************************************************************************* * @ingroup SalUser * @description * This function gets the number of the available dynamic allocated * compression instances which are from the specific device package. * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userDcGetAvailableNumDynInstancesByDevPkg(Cpa32U *pNumDcInstances, Cpa32U devPkgID); /************************************************************************* * @ingroup SalUser * @description * This function allocates crypto instances * from dynamic crypto instance pool * - it adds new allocated instances into crypto_services * - it initializes new allocated instances * - it starts new allocated instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyInstancesAlloc(Cpa32U numCyInstances, CpaInstanceHandle *pCyInstances); /************************************************************************* * @ingroup SalUser * @description * This function allocates crypto instances * from dynamic crypto instance pool * which are from the specific device package. * - it adds new allocated instances into crypto_services * - it initializes new allocated instances * - it starts new allocated instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyInstancesAllocByDevPkg(Cpa32U numCyInstances, CpaInstanceHandle *pCyInstances, Cpa32U devPkgID); /************************************************************************* * @ingroup SalUser * @description * This function allocates crypto instances * from dynamic crypto instance pool * which are from the specific device package and specific accelerator * - it adds new allocated instances into crypto_services * - it initializes new allocated instances * - it starts new allocated instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyInstancesAllocByPkgAccel(Cpa32U numCyInstances, CpaInstanceHandle *pCyInstances, Cpa32U devPkgID, Cpa32U accelerator_number); /************************************************************************* * @ingroup SalUser * @description * This function frees crypto instances allocated * from dynamic crypto instance pool * - it stops the instances * - it shutdowns the instances * - it removes the instances from crypto_services * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userCyFreeInstances(Cpa32U numCyInstances, CpaInstanceHandle *pCyInstances); /************************************************************************* * @ingroup SalUser * @description * This function allocates compression instances * from dynamic compression instance pool * - it adds new allocated instances into compression_services * - it initializes new allocated instances * - it starts new allocated instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userDcInstancesAlloc(Cpa32U numDcInstances, CpaInstanceHandle *pDcInstances); /************************************************************************* * @ingroup SalUser * @description * This function allocates compression instances * from dynamic compression instance pool * which are from the specific device package. * - it adds new allocated instances into compression_services * - it initializes new allocated instances * - it starts new allocated instances * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userDcInstancesAllocByDevPkg(Cpa32U numDcInstances, CpaInstanceHandle *pDcInstances, Cpa32U devPkgID); /************************************************************************* * @ingroup SalUser * @description * This function frees compression instances allocated * from dynamic compression instance pool * - it stops the instances * - it shutdowns the instances * - it removes the instances from compression_services * * @context * This function is called from the user process context * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_userDcFreeInstances(Cpa32U numDcInstances, CpaInstanceHandle *pDcInstances); /************************************************************************* * @ingroup SalUser * @description * This function checks if new devices have been started and if so * starts to use them. * * @context * This function is called from the user process context * in threadless mode * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_find_new_devices(void); /************************************************************************* * @ingroup SalUser * @description * This function polls device events. * * @context * This function is called from the user process context * in threadless mode * * @assumptions * None * @sideEffects - * In case a device has beed stoped or restarted the application + * In case a device has been stopped or restarted the application * will get restarting/stop/shutdown events * @reentrant * No * @threadSafe * No * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed * ************************************************************************/ CpaStatus icp_sal_poll_device_events(void); /* * icp_adf_check_device * * @description: * This function checks the status of the firmware/hardware for a given device. * This function is used as part of the heartbeat functionality. * * @context * This function is called from the user process context * @assumptions * None * @sideEffects * In case a device is unresponsive the device will * be restarted. * @reentrant * No * @threadSafe * Yes * * @param[in] accelId Device Id. * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed */ CpaStatus icp_sal_check_device(Cpa32U accelId); /* * icp_adf_check_all_devices * * @description: * This function checks the status of the firmware/hardware for all devices. * This function is used as part of the heartbeat functionality. * * @context * This function is called from the user process context * @assumptions * None * @sideEffects * In case a device is unresponsive the device will * be restarted. * @reentrant * No * @threadSafe * Yes * * @retval CPA_STATUS_SUCCESS No error * @retval CPA_STATUS_FAIL Operation failed */ CpaStatus icp_sal_check_all_devices(void); /* * @ingroup icp_sal_user * @description * This is a stub function to send messages to VF * * @context * None * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ CpaStatus icp_sal_userSendMsgToVf(Cpa32U accelId, Cpa32U vfNum, Cpa32U message); /* * @ingroup icp_sal_user * @description * This is a stub function to send messages to PF * * @context * None * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ CpaStatus icp_sal_userSendMsgToPf(Cpa32U accelId, Cpa32U message); /* * @ingroup icp_sal_user * @description * This is a stub function to get messages from VF * * @context * None * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ CpaStatus icp_sal_userGetMsgFromVf(Cpa32U accelId, Cpa32U vfNum, Cpa32U *message, Cpa32U *messageCounter); /* * @ingroup icp_sal_user * @description * This is a stub function to get messages from PF * * @context * None * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ CpaStatus icp_sal_userGetMsgFromPf(Cpa32U accelId, Cpa32U *message, Cpa32U *messageCounter); /* * @ingroup icp_sal_user * @description * This is a stub function to get pfvf comms status * * @context * None * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ CpaStatus icp_sal_userGetPfVfcommsStatus(CpaBoolean *unreadMessage); /* * @ingroup icp_sal_user * @description * This is a stub function to reset the device * * @context * None * * @assumptions * None * @sideEffects * None * @reentrant * Yes * @threadSafe * Yes * */ CpaStatus icp_sal_reset_device(Cpa32U accelId); /** ***************************************************************************** * @ingroup icp_sal_user * Retrieve number of in flight requests for a nrbg tx ring * from a crypto instance (Traditional API). * * @description * This function is a part of back-pressure mechanism. * Applications can query for inflight requests in * the appropriate service/ring on each instance * and select any instance with sufficient space or * the instance with the lowest number. * * @assumptions * None * @sideEffects * None * @blocking * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Crypto API instance handle. * @param[out] maxInflightRequests Maximal number of in flight requests. * @param[out] numInflightRequests Current number of in flight requests. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus icp_sal_NrbgGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests); /** ***************************************************************************** * @ingroup icp_sal_user * Retrieve number of in flight requests for a symmetric tx ring * from a crypto instance (Traditional API). * * @description * This function is a part of back-pressure mechanism. * Applications can query for inflight requests in * the appropriate service/ring on each instance * and select any instance with sufficient space or * the instance with the lowest number. * * @assumptions * None * @sideEffects * None * @blocking * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Crypto API instance handle. * @param[out] maxInflightRequests Maximal number of in flight requests. * @param[out] numInflightRequests Current number of in flight requests. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus icp_sal_SymGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests); /** ***************************************************************************** * @ingroup icp_sal_user * Retrieve number of in flight requests for an asymmetric tx ring * from a crypto instance (Traditional API). * * @description * This function is a part of back-pressure mechanism. * Applications can query the appropriate service/ring on each instance * and select any instance with sufficient space or * the instance with the lowest number. * * @assumptions * None * @sideEffects * None * @blocking * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Crypto API instance handle. * @param[out] maxInflightRequests Maximal number of in flight requests. * @param[out] numInflightRequests Current number of in flight requests. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus icp_sal_AsymGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests); /** ***************************************************************************** * @ingroup icp_sal_user * Retrieve number of in flight requests for a symmetric tx ring * from a crypto instancei (Data Plane API). * * @description * This function is a part of back-pressure mechanism. * Applications can query the appropriate service/ring on each instance * and select any instance with sufficient space or * the instance with the lowest number. * * @assumptions * None * @sideEffects * None * @blocking * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Crypto API instance handle. * @param[out] maxInflightRequests Maximal number of in flight requests. * @param[out] numInflightRequests Current number of in flight requests. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus icp_sal_dp_SymGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, Cpa32U *numInflightRequests); /** ***************************************************************************** * @ingroup icp_sal_user * Updates the CSR with queued requests in the asymmetric tx ring. * * @description * The function writes current shadow tail pointer of the asymmetric * TX ring into ring's CSR. Updating the CSR will notify the HW that * there are request(s) queued to be processed. The CSR is updated * always, disregarding the current value of shadow tail pointer and * the current CSR's tail value. * * @assumptions * None * @sideEffects * None * @blocking * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Crypto API instance handle. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus icp_sal_AsymPerformOpNow(CpaInstanceHandle instanceHandle); /** ***************************************************************************** * @ingroup icp_sal_setForceAEADMACVerify * Sets forceAEADMacVerify for particular instance to force HW MAC * validation. * * @description * By default HW MAC verification is set to CPA_TRUE - this utility * function allows to change default behavior. * * @assumptions * None * @sideEffects * None * @blocking * None * @reentrant * No * @threadSafe * No * * @param[in] instanceHandle Crypto API instance handle. * @param[in] forceAEADMacVerify new value * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus icp_sal_setForceAEADMACVerify(CpaInstanceHandle instanceHandle, CpaBoolean forceAEADMacVerify); #endif diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_common.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_common.h index 92c262356e95..a7cdb711e60b 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_common.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_common.h @@ -1,682 +1,682 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_common.h * * @defgroup cpaCy Cryptographic API * * @ingroup cpa * * @description * These functions specify the Cryptographic API. * *****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_common.h * @defgroup cpaCyCommon Cryptographic Common API * * @ingroup cpaCy * * @description * This file specifies items which are common for both the asymmetric * (public key cryptography) and the symmetric operations for the * Cryptographic API. * *****************************************************************************/ #ifndef CPA_CY_COMMON_H #define CPA_CY_COMMON_H #ifdef __cplusplus extern "C" { #endif #include "cpa.h" /** ***************************************************************************** * @ingroup cpa_cyCommon * CPA CY Major Version Number * @description * The CPA_CY API major version number. This number will be incremented * when significant churn to the API has occurred. The combination of the * major and minor number definitions represent the complete version number * for this interface. * *****************************************************************************/ #define CPA_CY_API_VERSION_NUM_MAJOR (3) /** ***************************************************************************** * @ingroup cpa_cyCommon * CPA CY Minor Version Number * @description * The CPA_CY API minor version number. This number will be incremented * when minor changes to the API has occurred. The combination of the major * and minor number definitions represent the complete version number for * this interface. * *****************************************************************************/ #define CPA_CY_API_VERSION_NUM_MINOR (0) /** ***************************************************************************** * @file cpa_cy_common.h * @ingroup cpa_cyCommon * CPA CY API version at least * @description * The minimal supported CPA_CY API version. Allow to check if the API * version is equal or above some version to avoid compilation issues * with an older API version. * *****************************************************************************/ #define CPA_CY_API_VERSION_AT_LEAST(major, minor) \ (CPA_CY_API_VERSION_NUM_MAJOR > major || \ (CPA_CY_API_VERSION_NUM_MAJOR == major && \ CPA_CY_API_VERSION_NUM_MINOR >= minor)) /** ***************************************************************************** * @file cpa_cy_common.h * @ingroup cpa_cyCommon * CPA CY API version less than * @description * The maximum supported CPA_CY API version. Allow to check if the API * version is below some version to avoid compilation issues with a newer * API version. * *****************************************************************************/ #define CPA_CY_API_VERSION_LESS_THAN(major, minor) \ (CPA_CY_API_VERSION_NUM_MAJOR < major || \ (CPA_CY_API_VERSION_NUM_MAJOR == major && \ CPA_CY_API_VERSION_NUM_MINOR < minor)) /** ***************************************************************************** * @file cpa_cy_common.h * @ingroup cpaCyCommon * Request priority * @description * Enumeration of priority of the request to be given to the API. * Currently two levels - HIGH and NORMAL are supported. HIGH priority * requests will be prioritized on a "best-effort" basis over requests * that are marked with a NORMAL priority. * *****************************************************************************/ typedef enum _CpaCyPriority { CPA_CY_PRIORITY_NORMAL = 1, /**< Normal priority */ CPA_CY_PRIORITY_HIGH /**< High priority */ } CpaCyPriority; /*****************************************************************************/ /* Callback Definitions */ /*****************************************************************************/ /** ***************************************************************************** * @ingroup cpaCyCommon * Definition of the crypto generic callback function * * @description * This data structure specifies the prototype for a generic callback * function * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag Opaque value provided by user while making individual * function call. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Opaque Pointer to the operation data that was * submitted in the request * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyKeyGenSsl() * *****************************************************************************/ typedef void (*CpaCyGenericCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData); /** ***************************************************************************** * @ingroup cpaCyCommon * Definition of generic callback function with an additional output * CpaFlatBuffer parameter. * * @description * This data structure specifies the prototype for a generic callback * function which provides an output buffer (of type CpaFlatBuffer). * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag Opaque value provided by user while making individual * function call. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Opaque Pointer to the operation data that was * submitted in the request * @param[in] pOut Pointer to the output buffer provided in the request * invoking this callback. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * None * *****************************************************************************/ typedef void (*CpaCyGenFlatBufCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpdata, CpaFlatBuffer *pOut); /** ***************************************************************************** * @ingroup cpaCyCommon * Function to return the size of the memory which must be allocated for * the pPrivateMetaData member of CpaBufferList. * * @description * This function is used obtain the size (in bytes) required to allocate * a buffer descriptor for the pPrivateMetaData member in the * CpaBufferList the structure. * Should the function return zero then no meta data is required for the * buffer list. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[in] numBuffers The number of pointers in the CpaBufferList. * this is the maximum number of CpaFlatBuffers * which may be contained in this CpaBufferList. * @param[out] pSizeInBytes Pointer to the size in bytes of memory to be * allocated when the client wishes to allocate * a cpaFlatBuffer * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None. * @post * None * @note * None * @see * cpaCyGetInstances() * *****************************************************************************/ CpaStatus cpaCyBufferListGetMetaSize(const CpaInstanceHandle instanceHandle, Cpa32U numBuffers, Cpa32U *pSizeInBytes); /** ***************************************************************************** * @ingroup cpaCyCommon * Function to return a string indicating the specific error that occurred * for a particular instance. * * @description * When a function invocation on a particular instance returns an error, * the client can invoke this function to query the instance for a null * terminated string which describes the general error condition, and if * available additional text on the specific error. * The Client MUST allocate CPA_STATUS_MAX_STR_LENGTH_IN_BYTES bytes for * the buffer string. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[in] errStatus The error condition that occurred * @param[out] pStatusText Pointer to the string buffer that will be * updated with a null terminated status text * string. * The invoking application MUST allocate this * buffer to be CPA_STATUS_MAX_STR_LENGTH_IN_BYTES. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Note, In this scenario it * is INVALID to call this function a further * time. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None. * @post * None * @note * None * @see * CpaStatus * *****************************************************************************/ CpaStatus cpaCyGetStatusText(const CpaInstanceHandle instanceHandle, CpaStatus errStatus, Cpa8S *pStatusText); /*****************************************************************************/ /* Instance Discovery Functions */ /*****************************************************************************/ /** ***************************************************************************** * @ingroup cpaCyCommon * Get the number of instances that are supported by the API * implementation. * * @description * This function will get the number of instances that are supported * by an implementation of the Cryptographic API. This number is then * used to determine the size of the array that must be passed to * @ref cpaCyGetInstances(). * * @context * This function MUST NOT be called from an interrupt context as it MAY * sleep. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[out] pNumInstances Pointer to where the number of * instances will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated * * @see * cpaCyGetInstances * *****************************************************************************/ CpaStatus cpaCyGetNumInstances(Cpa16U *pNumInstances); /** ***************************************************************************** * @ingroup cpaCyCommon * Get the handles to the instances that are supported by the * API implementation. * * @description * This function will return handles to the instances that are * supported by an implementation of the Cryptographic API. These * instance handles can then be used as input parameters with other * Cryptographic API functions. * * This function will populate an array that has been allocated by the * caller. The size of this API will have been determined by the * cpaCyGetNumInstances() function. * * @context * This function MUST NOT be called from an interrupt context as it MAY * sleep. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] numInstances Size of the array. If the value is not * the same as the number of instances * supported, then an error (@ref * CPA_STATUS_INVALID_PARAM) is returned. * @param[in,out] cyInstances Pointer to where the instance * handles will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated * * @see * cpaCyGetNumInstances * *****************************************************************************/ CpaStatus cpaCyGetInstances(Cpa16U numInstances, CpaInstanceHandle *cyInstances); /** ***************************************************************************** * @ingroup cpaCyCommon * Function to get information on a particular instance. * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyInstanceGetInfo2. * * @description * This function will provide instance specific information through a * @ref CpaInstanceInfo structure. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API to be * initialized. * @param[out] pInstanceInfo Pointer to the memory location allocated by * the client into which the CpaInstanceInfo * structure will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The client has retrieved an instanceHandle from successive calls to * @ref cpaCyGetNumInstances and @ref cpaCyGetInstances. * @post * None * @note * None * @see * cpaCyGetNumInstances, * cpaCyGetInstances, * CpaInstanceInfo * *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyInstanceGetInfo(const CpaInstanceHandle instanceHandle, struct _CpaInstanceInfo * pInstanceInfo); /** ***************************************************************************** * @ingroup cpaCyCommon * Function to get information on a particular instance. * * @description * This function will provide instance specific information through a * @ref CpaInstanceInfo2 structure. * Supersedes @ref cpaCyInstanceGetInfo. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API to be * initialized. * @param[out] pInstanceInfo2 Pointer to the memory location allocated by * the client into which the CpaInstanceInfo2 * structure will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The client has retrieved an instanceHandle from successive calls to * @ref cpaCyGetNumInstances and @ref cpaCyGetInstances. * @post * None * @note * None * @see * cpaCyGetNumInstances, * cpaCyGetInstances, * CpaInstanceInfo * *****************************************************************************/ CpaStatus cpaCyInstanceGetInfo2(const CpaInstanceHandle instanceHandle, CpaInstanceInfo2 * pInstanceInfo2); /*****************************************************************************/ /* Instance Notification Functions */ /*****************************************************************************/ /** ***************************************************************************** * @ingroup cpaCyCommon * Callback function for instance notification support. * * @description * This is the prototype for the instance notification callback function. * The callback function is passed in as a parameter to the * @ref cpaCyInstanceSetNotificationCb function. * * @context * This function will be executed in a context that requires that sleeping * MUST NOT be permitted. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCallbackTag Opaque value provided by user while making * individual function calls. * @param[in] instanceEvent The event that will trigger this function to * get invoked. * * @retval * None * @pre * Component has been initialized and the notification function has been * set via the cpaCyInstanceSetNotificationCb function. * @post * None * @note * None * @see * cpaCyInstanceSetNotificationCb(), * *****************************************************************************/ typedef void (*CpaCyInstanceNotificationCbFunc)( const CpaInstanceHandle instanceHandle, void * pCallbackTag, const CpaInstanceEvent instanceEvent); /** ***************************************************************************** * @ingroup cpaCyCommon * Subscribe for instance notifications. * * @description * Clients of the CpaCy interface can subscribe for instance notifications * by registering a @ref CpaCyInstanceNotificationCbFunc function. * * @context * This function may be called from any context. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pInstanceNotificationCb Instance notification callback * function pointer. * @param[in] pCallbackTag Opaque value provided by user while * making individual function calls. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Instance has been initialized. * @post * None * @note * None * @see * CpaCyInstanceNotificationCbFunc * *****************************************************************************/ CpaStatus cpaCyInstanceSetNotificationCb( const CpaInstanceHandle instanceHandle, const CpaCyInstanceNotificationCbFunc pInstanceNotificationCb, void *pCallbackTag); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_COMMON_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_dh.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_dh.h index 57a77b8559f2..c99aa449ec06 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_dh.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_dh.h @@ -1,514 +1,514 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_dh.h * * @defgroup cpaCyDh Diffie-Hellman (DH) API * * @ingroup cpaCy * * @description * These functions specify the API for Public Key Encryption * (Cryptography) operations for use with Diffie-Hellman algorithm. * * @note * Large numbers are represented on the QuickAssist API as described * in the Large Number API (@ref cpaCyLn). *****************************************************************************/ #ifndef CPA_CY_DH_H #define CPA_CY_DH_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyDh * Diffie-Hellman Phase 1 Key Generation Data. * @description * This structure lists the different items that are required in the * cpaCyDhKeyGenPhase1 function. The client MUST allocate the memory for * this structure. When the structure is passed into the function, * ownership of the memory passes to the function. Ownership of the memory * returns to the client when this structure is returned with the * CpaCyDhPhase1KeyGenOpData structure. * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyDhKeyGenPhase1 function, and * before it has been returned in the callback, undefined behavior will * result. * All values in this structure are required to be in Most Significant Byte * first order, e.g. primeP.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyDhPhase1KeyGenOpData { CpaFlatBuffer primeP; /**< Flat buffer containing a pointer to the random odd prime number (p). * The bit-length of this number may be one of 768, 1024, 1536, 2048, * 3072, 4096 or 8192. */ CpaFlatBuffer baseG; /**< Flat buffer containing a pointer to base (g). This MUST comply with * the following: * 0 < g < p. */ CpaFlatBuffer privateValueX; /**< Flat buffer containing a pointer to the private value (x). This is a * random value which MUST satisfy the following condition: * 0 < PrivateValueX < (PrimeP - 1) * * Refer to PKCS #3: Diffie-Hellman Key-Agreement Standard for details. * The client creating this data MUST ensure the compliance of this value * with the standard. Note: This value is also needed to complete local * phase 2 Diffie-Hellman operation.*/ } CpaCyDhPhase1KeyGenOpData; /** ***************************************************************************** * @ingroup cpaCyDh * Diffie-Hellman Phase 2 Secret Key Generation Data. * @description * This structure lists the different items that required in the * cpaCyDhKeyGenPhase2Secret function. The client MUST allocate the * memory for this structure. When the structure is passed into the * function, ownership of the memory passes to the function. Ownership of * the memory returns to the client when this structure is returned with * the callback. * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyDhKeyGenPhase2Secret * function, and before it has been returned in the callback, undefined * behavior will result. * All values in this structure are required to be in Most Significant Byte * first order, e.g. primeP.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyDhPhase2SecretKeyGenOpData { CpaFlatBuffer primeP; /**< Flat buffer containing a pointer to the random odd prime number (p). * The bit-length of this number may be one of 768, 1024, 1536, 2048, * 3072, 4096 or 8192. * This SHOULD be same prime number as was used in the phase 1 key * generation operation. */ CpaFlatBuffer remoteOctetStringPV; /**< Flat buffer containing a pointer to the remote entity * octet string Public Value (PV). */ CpaFlatBuffer privateValueX; /**< Flat buffer containing a pointer to the private value (x). This * value may have been used in a call to the cpaCyDhKeyGenPhase1 function. * This is a random value which MUST satisfy the following condition: * 0 < privateValueX < (primeP - 1). */ } CpaCyDhPhase2SecretKeyGenOpData; /** ***************************************************************************** * @ingroup cpaCyDh * Diffie-Hellman Statistics. * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by @ref CpaCyDhStats64. * @description * This structure contains statistics on the Diffie-Hellman operations. * Statistics are set to zero when the component is initialized, and are * collected per instance. ****************************************************************************/ typedef struct _CpaCyDhStats { Cpa32U numDhPhase1KeyGenRequests; /**< Total number of successful Diffie-Hellman phase 1 key * generation requests. */ Cpa32U numDhPhase1KeyGenRequestErrors; /**< Total number of Diffie-Hellman phase 1 key generation requests * that had an error and could not be processed. */ Cpa32U numDhPhase1KeyGenCompleted; /**< Total number of Diffie-Hellman phase 1 key generation operations * that completed successfully. */ Cpa32U numDhPhase1KeyGenCompletedErrors; /**< Total number of Diffie-Hellman phase 1 key generation operations * that could not be completed successfully due to errors. */ Cpa32U numDhPhase2KeyGenRequests; /**< Total number of successful Diffie-Hellman phase 2 key * generation requests. */ Cpa32U numDhPhase2KeyGenRequestErrors; /**< Total number of Diffie-Hellman phase 2 key generation requests * that had an error and could not be processed. */ Cpa32U numDhPhase2KeyGenCompleted; /**< Total number of Diffie-Hellman phase 2 key generation operations * that completed successfully. */ Cpa32U numDhPhase2KeyGenCompletedErrors; /**< Total number of Diffie-Hellman phase 2 key generation operations * that could not be completed successfully due to errors. */ } CpaCyDhStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyDh * Diffie-Hellman Statistics (64-bit version). * @description * This structure contains the 64-bit version of the statistics on the * Diffie-Hellman operations. * Statistics are set to zero when the component is initialized, and are * collected per instance. ****************************************************************************/ typedef struct _CpaCyDhStats64 { Cpa64U numDhPhase1KeyGenRequests; /**< Total number of successful Diffie-Hellman phase 1 key * generation requests. */ Cpa64U numDhPhase1KeyGenRequestErrors; /**< Total number of Diffie-Hellman phase 1 key generation requests * that had an error and could not be processed. */ Cpa64U numDhPhase1KeyGenCompleted; /**< Total number of Diffie-Hellman phase 1 key generation operations * that completed successfully. */ Cpa64U numDhPhase1KeyGenCompletedErrors; /**< Total number of Diffie-Hellman phase 1 key generation operations * that could not be completed successfully due to errors. */ Cpa64U numDhPhase2KeyGenRequests; /**< Total number of successful Diffie-Hellman phase 2 key * generation requests. */ Cpa64U numDhPhase2KeyGenRequestErrors; /**< Total number of Diffie-Hellman phase 2 key generation requests * that had an error and could not be processed. */ Cpa64U numDhPhase2KeyGenCompleted; /**< Total number of Diffie-Hellman phase 2 key generation operations * that completed successfully. */ Cpa64U numDhPhase2KeyGenCompletedErrors; /**< Total number of Diffie-Hellman phase 2 key generation operations * that could not be completed successfully due to errors. */ } CpaCyDhStats64; /** ***************************************************************************** * @ingroup cpaCyDh * Function to implement Diffie-Hellman phase 1 operations. * * @description * This function may be used to implement the Diffie-Hellman phase 1 * operations as defined in the PKCS #3 standard. It may be used to * generate the (local) octet string public value (PV) key. * The prime number sizes specified in RFC 2409, 4306, and part of * RFC 3526 are supported (bit size 6144 from RFC 3536 is not * supported). * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pDhPhase1Cb Pointer to a callback function to be invoked * when the operation is complete. If the * pointer is set to a NULL value the function * will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the callback * @param[in] pPhase1KeyGenData Structure containing all the data needed * to perform the DH Phase 1 key generation * operation. The client code allocates the * memory for this structure. This component * takes ownership of the memory until it is * returned in the callback. * @param[out] pLocalOctetStringPV Pointer to memory allocated by the client * into which the (local) octet string Public * Value (PV) will be written. This value * needs to be sent to the remote entity with * which Diffie-Hellman is negotiating. * The size of this buffer in bytes (as * represented by the dataLenInBytes field) * MUST be at least big enough to store * the public value, which may have a bit * length up to that of pPrimeP. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pDhPhase1Cb is non-NULL an asynchronous callback of type * CpaCyGenFlatBufCbFunc is generated in response to this function * call. Any errors generated during processing are reported in the * structure returned in the callback. * * @see * CpaCyGenFlatBufCbFunc, * CpaCyDhPhase1KeyGenOpData * *****************************************************************************/ CpaStatus cpaCyDhKeyGenPhase1(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pDhPhase1Cb, void *pCallbackTag, const CpaCyDhPhase1KeyGenOpData *pPhase1KeyGenData, CpaFlatBuffer *pLocalOctetStringPV); /** ***************************************************************************** * @ingroup cpaCyDh * Function to implement Diffie-Hellman phase 2 operations. * * @description * This function may be used to implement the Diffie-Hellman phase 2 * operation as defined in the PKCS #3 standard. It may be used to * generate the Diffie-Hellman shared secret key. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pDhPhase2Cb Pointer to a callback function to be * invoked when the operation is complete. * If the pointer is set to a NULL value * the function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in * the callback. * @param[in] pPhase2SecretKeyGenData Structure containing all the data * needed to perform the DH Phase 2 * secret key generation operation. The * client code allocates the memory for * this structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[out] pOctetStringSecretKey Pointer to memory allocated by the * client into which the octet string * secret key will be written. * The size of this buffer in bytes (as * represented by the dataLenInBytes field) * MUST be at least big enough to store * the public value, which may have a bit * length up to that of pPrimeP. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pDhPhase2Cb is non-NULL an asynchronous callback of type * CpaCyGenFlatBufCbFunc is generated in response to this function * call. Any errors generated during processing are reported in the * structure returned in the callback. * * @see * CpaCyGenFlatBufCbFunc, * CpaCyDhPhase2SecretKeyGenOpData * *****************************************************************************/ CpaStatus cpaCyDhKeyGenPhase2Secret(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pDhPhase2Cb, void *pCallbackTag, const CpaCyDhPhase2SecretKeyGenOpData *pPhase2SecretKeyGenData, CpaFlatBuffer *pOctetStringSecretKey); /** ***************************************************************************** * @ingroup cpaCyDh * Query statistics for Diffie-Hellman operations * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyDhQueryStats64(). * * @description * This function will query a specific Instance handle for Diffie- * Hellman statistics. The user MUST allocate the CpaCyDhStats * structure and pass the reference to that structure into this function * call. This function writes the statistic results into the passed in * CpaCyDhStats structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pDhStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyDhStats *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyDhQueryStats(const CpaInstanceHandle instanceHandle, struct _CpaCyDhStats *pDhStats); /** ***************************************************************************** * @ingroup cpaCyDh * Query statistics (64-bit version) for Diffie-Hellman operations * * @description * This function will query a specific Instance handle for the 64-bit * version of the Diffie-Hellman statistics. The user MUST allocate the * CpaCyDhStats64 structure and pass the reference to that structure into * this function call. This function writes the statistic results into * the passed in CpaCyDhStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pDhStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyDhStats64 *****************************************************************************/ CpaStatus cpaCyDhQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyDhStats64 *pDhStats); /*****************************************************************************/ #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_DH_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_dsa.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_dsa.h index f7f51bf2aa7b..eea346ddadae 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_dsa.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_dsa.h @@ -1,1443 +1,1443 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_dsa.h * * @defgroup cpaCyDsa Digital Signature Algorithm (DSA) API * * @ingroup cpaCy * * @description * These functions specify the API for Public Key Encryption * (Cryptography) Digital Signature Algorithm (DSA) operations. * * Support is provided for FIPS PUB 186-2 with Change Notice 1 * specification, and optionally for FIPS PUB 186-3. If an * implementation does not support FIPS PUB 186-3, then the * corresponding functions may return a status of @ref * CPA_STATUS_FAIL. * * Support for FIPS PUB 186-2 with Change Notice 1 implies supporting * the following choice for the pair L and N: * - L = 1024, N = 160 * * Support for FIPS PUB 186-3 implies supporting the following choices * for the pair L and N: * * - L = 1024, N = 160 * - L = 2048, N = 224 * - L = 2048, N = 256 * - L = 3072, N = 256 * * Only the modular math aspects of DSA parameter generation and message * signature generation and verification are implemented here. For full * DSA support, this DSA API SHOULD be used in conjunction with other * parts of this overall Cryptographic API. In particular the Symmetric * functions (for hashing), the Random Number Generation functions, and * the Prime Number Test functions will be required. * * @note * Large numbers are represented on the QuickAssist API as described * in the Large Number API (@ref cpaCyLn). *****************************************************************************/ #ifndef CPA_CY_DSA_H #define CPA_CY_DSA_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyDsa * DSA P Parameter Generation Operation Data. * @description * This structure contains the operation data for the cpaCyDsaGenPParam * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. X.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaGenPParam * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaGenPParam() * *****************************************************************************/ typedef struct _CpaCyDsaPParamGenOpData { CpaFlatBuffer X; /**< 2^(L-1) <= X < 2^L (from FIPS 186-3) */ CpaFlatBuffer Q; /**< DSA group parameter q */ } CpaCyDsaPParamGenOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * DSA G Parameter Generation Operation Data. * @description * This structure contains the operation data for the cpaCyDsaGenGParam * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. P.pData[0] = MSB. * * All numbers MUST be stored in big-endian order. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaGenGParam * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaGenGParam() * *****************************************************************************/ typedef struct _CpaCyDsaGParamGenOpData { CpaFlatBuffer P; /**< DSA group parameter p */ CpaFlatBuffer Q; /**< DSA group parameter q */ CpaFlatBuffer H; /**< any integer with 1 < h < p - 1 */ } CpaCyDsaGParamGenOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * DSA Y Parameter Generation Operation Data. * @description * This structure contains the operation data for the cpaCyDsaGenYParam * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. P.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaGenYParam * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaGenYParam() * *****************************************************************************/ typedef struct _CpaCyDsaYParamGenOpData { CpaFlatBuffer P; /**< DSA group parameter p */ CpaFlatBuffer G; /**< DSA group parameter g */ CpaFlatBuffer X; /**< DSA private key x */ } CpaCyDsaYParamGenOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * DSA R Sign Operation Data. * @description * This structure contains the operation data for the cpaCyDsaSignR * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. P.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaSignR * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaSignR() * *****************************************************************************/ typedef struct _CpaCyDsaRSignOpData { CpaFlatBuffer P; /**< DSA group parameter p */ CpaFlatBuffer Q; /**< DSA group parameter q */ CpaFlatBuffer G; /**< DSA group parameter g */ CpaFlatBuffer K; /**< DSA secret parameter k for signing */ } CpaCyDsaRSignOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * DSA S Sign Operation Data. * @description * This structure contains the operation data for the cpaCyDsaSignS * function. The client MUST allocate the memory for this structure and * the items pointed to by this structure. When the structure is passed * into the function, ownership of the memory passes to the function. * Ownership of the memory returns to the client when this structure is * returned in the callback function. * * For optimal performance all data SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. Q.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaSignS * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaSignS() * *****************************************************************************/ typedef struct _CpaCyDsaSSignOpData { CpaFlatBuffer Q; /**< DSA group parameter q */ CpaFlatBuffer X; /**< DSA private key x */ CpaFlatBuffer K; /**< DSA secret parameter k for signing */ CpaFlatBuffer R; /**< DSA message signature r */ CpaFlatBuffer Z; /**< The leftmost min(N, outlen) bits of Hash(M), where: * - N is the bit length of q * - outlen is the bit length of the hash function output block * - M is the message to be signed */ } CpaCyDsaSSignOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * DSA R & S Sign Operation Data. * @description * This structure contains the operation data for the cpaCyDsaSignRS * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. P.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaSignRS * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaSignRS() * *****************************************************************************/ typedef struct _CpaCyDsaRSSignOpData { CpaFlatBuffer P; /**< DSA group parameter p */ CpaFlatBuffer Q; /**< DSA group parameter q */ CpaFlatBuffer G; /**< DSA group parameter g */ CpaFlatBuffer X; /**< DSA private key x */ CpaFlatBuffer K; /**< DSA secret parameter k for signing */ CpaFlatBuffer Z; /**< The leftmost min(N, outlen) bits of Hash(M), where: * - N is the bit length of q * - outlen is the bit length of the hash function output block * - M is the message to be signed */ } CpaCyDsaRSSignOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * DSA Verify Operation Data. * @description * This structure contains the operation data for the cpaCyDsaVerify * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. P.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyDsaVerify * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyDsaVerify() * *****************************************************************************/ typedef struct _CpaCyDsaVerifyOpData { CpaFlatBuffer P; /**< DSA group parameter p */ CpaFlatBuffer Q; /**< DSA group parameter q */ CpaFlatBuffer G; /**< DSA group parameter g */ CpaFlatBuffer Y; /**< DSA public key y */ CpaFlatBuffer Z; /**< The leftmost min(N, outlen) bits of Hash(M'), where: * - N is the bit length of q * - outlen is the bit length of the hash function output block * - M is the message to be signed */ CpaFlatBuffer R; /**< DSA message signature r */ CpaFlatBuffer S; /**< DSA message signature s */ } CpaCyDsaVerifyOpData; /** ***************************************************************************** * @ingroup cpaCyDsa * Cryptographic DSA Statistics. * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by @ref CpaCyDsaStats64. * @description * This structure contains statistics on the Cryptographic DSA * operations. Statistics are set to zero when the component is * initialized, and are collected per instance. ****************************************************************************/ typedef struct _CpaCyDsaStats { Cpa32U numDsaPParamGenRequests; /**< Total number of successful DSA P parameter generation requests. */ Cpa32U numDsaPParamGenRequestErrors; /**< Total number of DSA P parameter generation requests that had an * error and could not be processed. */ Cpa32U numDsaPParamGenCompleted; /**< Total number of DSA P parameter generation operations that * completed successfully. */ Cpa32U numDsaPParamGenCompletedErrors; /**< Total number of DSA P parameter generation operations that could * not be completed successfully due to errors. */ Cpa32U numDsaGParamGenRequests; /**< Total number of successful DSA G parameter generation requests. */ Cpa32U numDsaGParamGenRequestErrors; /**< Total number of DSA G parameter generation requests that had an * error and could not be processed. */ Cpa32U numDsaGParamGenCompleted; /**< Total number of DSA G parameter generation operations that * completed successfully. */ Cpa32U numDsaGParamGenCompletedErrors; /**< Total number of DSA G parameter generation operations that could * not be completed successfully due to errors. */ Cpa32U numDsaYParamGenRequests; /**< Total number of successful DSA Y parameter generation requests. */ Cpa32U numDsaYParamGenRequestErrors; /**< Total number of DSA Y parameter generation requests that had an * error and could not be processed. */ Cpa32U numDsaYParamGenCompleted; /**< Total number of DSA Y parameter generation operations that * completed successfully. */ Cpa32U numDsaYParamGenCompletedErrors; /**< Total number of DSA Y parameter generation operations that could * not be completed successfully due to errors. */ Cpa32U numDsaRSignRequests; /**< Total number of successful DSA R sign generation requests. */ Cpa32U numDsaRSignRequestErrors; /**< Total number of DSA R sign requests that had an error and could * not be processed. */ Cpa32U numDsaRSignCompleted; /**< Total number of DSA R sign operations that completed * successfully. */ Cpa32U numDsaRSignCompletedErrors; /**< Total number of DSA R sign operations that could not be completed * successfully due to errors. */ Cpa32U numDsaSSignRequests; /**< Total number of successful DSA S sign generation requests. */ Cpa32U numDsaSSignRequestErrors; /**< Total number of DSA S sign requests that had an error and could * not be processed. */ Cpa32U numDsaSSignCompleted; /**< Total number of DSA S sign operations that completed * successfully. */ Cpa32U numDsaSSignCompletedErrors; /**< Total number of DSA S sign operations that could not be completed * successfully due to errors. */ Cpa32U numDsaRSSignRequests; /**< Total number of successful DSA RS sign generation requests. */ Cpa32U numDsaRSSignRequestErrors; /**< Total number of DSA RS sign requests that had an error and could * not be processed. */ Cpa32U numDsaRSSignCompleted; /**< Total number of DSA RS sign operations that completed * successfully. */ Cpa32U numDsaRSSignCompletedErrors; /**< Total number of DSA RS sign operations that could not be completed * successfully due to errors. */ Cpa32U numDsaVerifyRequests; /**< Total number of successful DSA verify generation requests. */ Cpa32U numDsaVerifyRequestErrors; /**< Total number of DSA verify requests that had an error and could * not be processed. */ Cpa32U numDsaVerifyCompleted; /**< Total number of DSA verify operations that completed * successfully. */ Cpa32U numDsaVerifyCompletedErrors; /**< Total number of DSA verify operations that could not be completed * successfully due to errors. */ Cpa32U numDsaVerifyFailures; /**< Total number of DSA verify operations that executed successfully * but the outcome of the test was that the verification failed. * Note that this does not indicate an error. */ } CpaCyDsaStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyDsa * Cryptographic DSA Statistics (64-bit version). * @description * This structure contains 64-bit version of the statistics on the * Cryptographic DSA operations. * Statistics are set to zero when the component is * initialized, and are collected per instance. ****************************************************************************/ typedef struct _CpaCyDsaStats64 { Cpa64U numDsaPParamGenRequests; /**< Total number of successful DSA P parameter generation requests. */ Cpa64U numDsaPParamGenRequestErrors; /**< Total number of DSA P parameter generation requests that had an * error and could not be processed. */ Cpa64U numDsaPParamGenCompleted; /**< Total number of DSA P parameter generation operations that * completed successfully. */ Cpa64U numDsaPParamGenCompletedErrors; /**< Total number of DSA P parameter generation operations that could * not be completed successfully due to errors. */ Cpa64U numDsaGParamGenRequests; /**< Total number of successful DSA G parameter generation requests. */ Cpa64U numDsaGParamGenRequestErrors; /**< Total number of DSA G parameter generation requests that had an * error and could not be processed. */ Cpa64U numDsaGParamGenCompleted; /**< Total number of DSA G parameter generation operations that * completed successfully. */ Cpa64U numDsaGParamGenCompletedErrors; /**< Total number of DSA G parameter generation operations that could * not be completed successfully due to errors. */ Cpa64U numDsaYParamGenRequests; /**< Total number of successful DSA Y parameter generation requests. */ Cpa64U numDsaYParamGenRequestErrors; /**< Total number of DSA Y parameter generation requests that had an * error and could not be processed. */ Cpa64U numDsaYParamGenCompleted; /**< Total number of DSA Y parameter generation operations that * completed successfully. */ Cpa64U numDsaYParamGenCompletedErrors; /**< Total number of DSA Y parameter generation operations that could * not be completed successfully due to errors. */ Cpa64U numDsaRSignRequests; /**< Total number of successful DSA R sign generation requests. */ Cpa64U numDsaRSignRequestErrors; /**< Total number of DSA R sign requests that had an error and could * not be processed. */ Cpa64U numDsaRSignCompleted; /**< Total number of DSA R sign operations that completed * successfully. */ Cpa64U numDsaRSignCompletedErrors; /**< Total number of DSA R sign operations that could not be completed * successfully due to errors. */ Cpa64U numDsaSSignRequests; /**< Total number of successful DSA S sign generation requests. */ Cpa64U numDsaSSignRequestErrors; /**< Total number of DSA S sign requests that had an error and could * not be processed. */ Cpa64U numDsaSSignCompleted; /**< Total number of DSA S sign operations that completed * successfully. */ Cpa64U numDsaSSignCompletedErrors; /**< Total number of DSA S sign operations that could not be completed * successfully due to errors. */ Cpa64U numDsaRSSignRequests; /**< Total number of successful DSA RS sign generation requests. */ Cpa64U numDsaRSSignRequestErrors; /**< Total number of DSA RS sign requests that had an error and could * not be processed. */ Cpa64U numDsaRSSignCompleted; /**< Total number of DSA RS sign operations that completed * successfully. */ Cpa64U numDsaRSSignCompletedErrors; /**< Total number of DSA RS sign operations that could not be completed * successfully due to errors. */ Cpa64U numDsaVerifyRequests; /**< Total number of successful DSA verify generation requests. */ Cpa64U numDsaVerifyRequestErrors; /**< Total number of DSA verify requests that had an error and could * not be processed. */ Cpa64U numDsaVerifyCompleted; /**< Total number of DSA verify operations that completed * successfully. */ Cpa64U numDsaVerifyCompletedErrors; /**< Total number of DSA verify operations that could not be completed * successfully due to errors. */ Cpa64U numDsaVerifyFailures; /**< Total number of DSA verify operations that executed successfully * but the outcome of the test was that the verification failed. * Note that this does not indicate an error. */ } CpaCyDsaStats64; /** ***************************************************************************** * @ingroup cpaCyDsa * Definition of a generic callback function invoked for a number of the * DSA API functions.. * * @description * This is the prototype for the cpaCyDsaGenCbFunc callback function. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Opaque pointer to Operation data supplied in * request. * @param[in] protocolStatus The result passes/fails the DSA protocol * related checks. * @param[in] pOut Output data from the request. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyDsaGenPParam() * cpaCyDsaGenGParam() * cpaCyDsaSignR() * cpaCyDsaSignS() * *****************************************************************************/ typedef void (*CpaCyDsaGenCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean protocolStatus, CpaFlatBuffer *pOut); /** ***************************************************************************** * @ingroup cpaCyDsa * Definition of callback function invoked for cpaCyDsaSignRS * requests. * * @description * This is the prototype for the cpaCyDsaSignRS callback function, which * will provide the DSA message signature r and s parameters. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Operation data pointer supplied in request. * @param[in] protocolStatus The result passes/fails the DSA protocol * related checks. * @param[in] pR DSA message signature r. * @param[in] pS DSA message signature s. * * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyDsaSignRS() * *****************************************************************************/ typedef void (*CpaCyDsaRSSignCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean protocolStatus, CpaFlatBuffer *pR, CpaFlatBuffer *pS); /** ***************************************************************************** * @ingroup cpaCyDsa * Definition of callback function invoked for cpaCyDsaVerify * requests. * * @description * This is the prototype for the cpaCyDsaVerify callback function. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Operation data pointer supplied in request. * @param[in] verifyStatus The verification passed or failed. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyDsaVerify() * *****************************************************************************/ typedef void (*CpaCyDsaVerifyCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean verifyStatus); /** ***************************************************************************** * @ingroup cpaCyDsa * Generate DSA P Parameter. * * @description * * This function performs FIPS 186-3 Appendix A.1.1.2 steps 11.4 and 11.5, * and part of step 11.7: * * 11.4. c = X mod 2q. * 11.5. p = X - (c - 1). * 11.7. Test whether or not p is prime as specified in Appendix C.3. * [Note that a GCD test against ~1400 small primes is performed * on p to eliminate ~94% of composites - this is NOT a "robust" * primality test, as specified in Appendix C.3.] * * The protocol status, returned in the callback function as parameter * protocolStatus (or, in the case of synchronous invocation, in the * parameter *pProtocolStatus) is used to indicate whether the value p is * in the right range and has passed the limited primality test. * * Specifically, (protocolStatus == CPA_TRUE) means p is in the right range * and SHOULD be subjected to a robust primality test as specified in * FIPS 186-3 Appendix C.3 (for example, 40 rounds of Miller-Rabin). * Meanwhile, (protocolStatus == CPA_FALSE) means p is either composite, * or p < 2^(L-1), in which case the value of p gets set to zero. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is * set to a NULL value the function will * operate synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pProtocolStatus The result passes/fails the DSA protocol * related checks. * @param[out] pP Candidate for DSA parameter p, p odd and * 2^(L-1) < p < X * On invocation the callback function will * contain this parameter in the pOut parameter. * * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaPParamGenCbFunc is generated in response to this * function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaPParamGenOpData, * CpaCyDsaGenCbFunc * *****************************************************************************/ CpaStatus cpaCyDsaGenPParam(const CpaInstanceHandle instanceHandle, const CpaCyDsaGenCbFunc pCb, void * pCallbackTag, const CpaCyDsaPParamGenOpData *pOpData, CpaBoolean *pProtocolStatus, CpaFlatBuffer *pP); /** ***************************************************************************** * @ingroup cpaCyDsa * Generate DSA G Parameter. * * @description * This function performs FIPS 186-3 Appendix A.2.1, steps 1 and 3, * and part of step 4: * * 1. e = (p - 1)/q. * 3. Set g = h^e mod p. * 4. If (g = 1), then go to step 2. * Here, the implementation will check for g == 1, and return * status accordingly. * * * The protocol status, returned in the callback function as parameter * protocolStatus (or, in the case of synchronous invocation, in the * parameter *pProtocolStatus) is used to indicate whether the value g is * acceptable. * * Specifically, (protocolStatus == CPA_TRUE) means g is acceptable. * Meanwhile, (protocolStatus == CPA_FALSE) means g == 1, so a * different value of h SHOULD be used to generate another value of g. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pProtocolStatus The result passes/fails the DSA protocol * related checks. * @param[out] pG g = h^((p-1)/q) mod p. * On invocation the callback function will * contain this parameter in the pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaGParamGenCbFunc is generated in response to this * function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaGParamGenOpData, * CpaCyDsaGenCbFunc * *****************************************************************************/ CpaStatus cpaCyDsaGenGParam(const CpaInstanceHandle instanceHandle, const CpaCyDsaGenCbFunc pCb, void *pCallbackTag, const CpaCyDsaGParamGenOpData *pOpData, CpaBoolean *pProtocolStatus, CpaFlatBuffer *pG); /** ***************************************************************************** * @ingroup cpaCyDsa * Generate DSA Y Parameter. * * @description * * This function performs modular exponentiation to generate y as * described in FIPS 186-3 section 4.1: * y = g^x mod p * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pProtocolStatus The result passes/fails the DSA protocol * related checks. * @param[out] pY y = g^x mod p* * On invocation the callback function will * contain this parameter in the pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaYParamGenCbFunc is generated in response to this * function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaYParamGenOpData, * CpaCyDsaGenCbFunc * *****************************************************************************/ CpaStatus cpaCyDsaGenYParam(const CpaInstanceHandle instanceHandle, const CpaCyDsaGenCbFunc pCb, void *pCallbackTag, const CpaCyDsaYParamGenOpData *pOpData, CpaBoolean *pProtocolStatus, CpaFlatBuffer *pY); /** ***************************************************************************** * @ingroup cpaCyDsa * Generate DSA R Signature. * * @description * This function generates the DSA R signature as described in FIPS 186-3 * Section 4.6: * r = (g^k mod p) mod q * * The protocol status, returned in the callback function as parameter * protocolStatus (or, in the case of synchronous invocation, in the * parameter *pProtocolStatus) is used to indicate whether the value r == 0. * * Specifically, (protocolStatus == CPA_TRUE) means r != 0, while * (protocolStatus == CPA_FALSE) means r == 0. * * Generation of signature r does not depend on the content of the message * being signed, so this operation can be done in advance for different * values of k. Then once each message becomes available only the * signature s needs to be generated. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pProtocolStatus The result passes/fails the DSA protocol * related checks. * @param[out] pR DSA message signature r. * On invocation the callback function will * contain this parameter in the pOut parameter. * * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaRSignCbFunc is generated in response to this function * call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaRSignOpData, * CpaCyDsaGenCbFunc, * cpaCyDsaSignS(), * cpaCyDsaSignRS() * *****************************************************************************/ CpaStatus cpaCyDsaSignR(const CpaInstanceHandle instanceHandle, const CpaCyDsaGenCbFunc pCb, void *pCallbackTag, const CpaCyDsaRSignOpData *pOpData, CpaBoolean *pProtocolStatus, CpaFlatBuffer *pR); /** ***************************************************************************** * @ingroup cpaCyDsa * Generate DSA S Signature. * * @description * This function generates the DSA S signature as described in FIPS 186-3 * Section 4.6: * s = (k^-1(z + xr)) mod q * * Here, z = the leftmost min(N, outlen) bits of Hash(M). This function * does not perform the SHA digest; z is computed by the caller and * passed as a parameter in the pOpData field. * * The protocol status, returned in the callback function as parameter * protocolStatus (or, in the case of synchronous invocation, in the * parameter *pProtocolStatus) is used to indicate whether the value s == 0. * * Specifically, (protocolStatus == CPA_TRUE) means s != 0, while * (protocolStatus == CPA_FALSE) means s == 0. * * If signature r has been generated in advance, then this function can be * used to generate the signature s once the message becomes available. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pProtocolStatus The result passes/fails the DSA protocol * related checks. * @param[out] pS DSA message signature s. * On invocation the callback function will * contain this parameter in the pOut parameter. * * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaSSignCbFunc is generated in response to this function * call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaSSignOpData, * CpaCyDsaGenCbFunc, * cpaCyDsaSignR(), * cpaCyDsaSignRS() * *****************************************************************************/ CpaStatus cpaCyDsaSignS(const CpaInstanceHandle instanceHandle, const CpaCyDsaGenCbFunc pCb, void *pCallbackTag, const CpaCyDsaSSignOpData *pOpData, CpaBoolean *pProtocolStatus, CpaFlatBuffer *pS); /** ***************************************************************************** * @ingroup cpaCyDsa * Generate DSA R and S Signatures. * * @description * This function generates the DSA R and S signatures as described in * FIPS 186-3 Section 4.6: * * r = (g^k mod p) mod q * s = (k^-1(z + xr)) mod q * * Here, z = the leftmost min(N, outlen) bits of Hash(M). This function * does not perform the SHA digest; z is computed by the caller and * passed as a parameter in the pOpData field. * * The protocol status, returned in the callback function as parameter * protocolStatus (or, in the case of synchronous invocation, in the * parameter *pProtocolStatus) is used to indicate whether either of * the values r or s are zero. * * Specifically, (protocolStatus == CPA_TRUE) means neither is zero (i.e. * (r != 0) && (s != 0)), while (protocolStatus == CPA_FALSE) means that at * least one of r or s is zero (i.e. (r == 0) || (s == 0)). * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to * a NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pProtocolStatus The result passes/fails the DSA protocol * related checks. * @param[out] pR DSA message signature r. * @param[out] pS DSA message signature s. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaRSSignCbFunc is generated in response to this function * call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaRSSignOpData, * CpaCyDsaRSSignCbFunc, * cpaCyDsaSignR(), * cpaCyDsaSignS() * *****************************************************************************/ CpaStatus cpaCyDsaSignRS(const CpaInstanceHandle instanceHandle, const CpaCyDsaRSSignCbFunc pCb, void *pCallbackTag, const CpaCyDsaRSSignOpData *pOpData, CpaBoolean *pProtocolStatus, CpaFlatBuffer *pR, CpaFlatBuffer *pS); /** ***************************************************************************** * @ingroup cpaCyDsa * Verify DSA R and S signatures. * * @description * This function performs FIPS 186-3 Section 4.7: * w = (s')^-1 mod q * u1 = (zw) mod q * u2 = ((r')w) mod q * v = (((g)^u1 (y)^u2) mod p) mod q * * Here, z = the leftmost min(N, outlen) bits of Hash(M'). This function * does not perform the SHA digest; z is computed by the caller and * passed as a parameter in the pOpData field. * * A response status of ok (verifyStatus == CPA_TRUE) means v = r'. * A response status of not ok (verifyStatus == CPA_FALSE) means v != r'. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to * a NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pVerifyStatus The verification passed or failed. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyDsaVerifyCbFunc is generated in response to this function * call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyDsaVerifyOpData, * CpaCyDsaVerifyCbFunc * *****************************************************************************/ CpaStatus cpaCyDsaVerify(const CpaInstanceHandle instanceHandle, const CpaCyDsaVerifyCbFunc pCb, void *pCallbackTag, const CpaCyDsaVerifyOpData *pOpData, CpaBoolean *pVerifyStatus); /** ***************************************************************************** * @ingroup cpaCyDsa * Query statistics for a specific DSA instance. * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyDsaQueryStats64(). * * @description * This function will query a specific instance of the DSA implementation * for statistics. The user MUST allocate the CpaCyDsaStats structure * and pass the reference to that structure into this function call. This * function writes the statistic results into the passed in * CpaCyDsaStats structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pDsaStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyDsaStats *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyDsaQueryStats(const CpaInstanceHandle instanceHandle, struct _CpaCyDsaStats *pDsaStats); /** ***************************************************************************** * @ingroup cpaCyDsa * Query 64-bit statistics for a specific DSA instance. * * @description * This function will query a specific instance of the DSA implementation * for 64-bit statistics. The user MUST allocate the CpaCyDsaStats64 * structure and pass the reference to that structure into this function. * This function writes the statistic results into the passed in * CpaCyDsaStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pDsaStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyDsaStats *****************************************************************************/ CpaStatus cpaCyDsaQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyDsaStats64 *pDsaStats); /*****************************************************************************/ #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_DSA_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_ec.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_ec.h index 8f72bd669229..e6466ab7476a 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_ec.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_ec.h @@ -1,1124 +1,1124 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_ec.h * * @defgroup cpaCyEc Elliptic Curve (EC) API * * @ingroup cpaCy * * @description * These functions specify the API for Public Key Encryption * (Cryptography) Elliptic Curve (EC) operations. * * All implementations will support at least the following: * * - "NIST RECOMMENDED ELLIPTIC CURVES FOR FEDERAL GOVERNMENT USE" * as defined by * http://csrc.nist.gov/groups/ST/toolkit/documents/dss/NISTReCur.pdf * * - Random curves where the max(log2(q), log2(n) + log2(h)) <= 512 * where q is the modulus, n is the order of the curve and h is the * cofactor * * For Montgomery and Edwards 25519 and 448 elliptic curves, * the following operations are supported: * 1. Montgomery 25519 Curve | scalar point Multiplication * Input: Montgomery affine coordinate X of point P * Scalar k * Output: Montgomery affine coordinate X of point [k]P * Decode: Scalar k always decoded by implementation * * 2. Montgomery 25519 Curve | generator point Multiplication * Input: Scalar k * Output: Montgomery affine coordinate X of point [k]G * Decode: Scalar k always decoded by implementation * * 3. Twisted Edwards 25519 Curve | scalar point Multiplication * Input: Twisted Edwards affine coordinate X of point P * Twisted Edwards affine coordinate Y of point P * Scalar k * Output: Twisted Edwards affine coordinate X of point [k]P * Twisted Edwards affine coordinate Y of point [k]P * Decode: Caller must supply parameters in MSB order, the * implementation will not explicitly decode according * to RFC#7748 Section 5 * * 4. Twisted Edwards 25519 Curve | generator point Multiplication * Input: Scalar k * Output: Twisted Edwards affine coordinate X of point [k]G * Twisted Edwards affine coordinate Y of point [k]G * Decode: Caller must supply parameters in MSB order, the * implementation will not explicitly decode according * to RFC#7748 Section 5 * * 5. Montgomery 448 Curve | scalar point Multiplication * Input: Montgomery affine coordinate X of point P * Scalar k * Output: Montgomery affine coordinate X of point [k]P * Decode: Scalar k always decoded by implementation * * 6. Montgomery 448 Curve | generator point Multiplication * Input: Scalar k * Output: Montgomery affine coordinate X of point [k]G * Decode: Scalar k always decoded by implementation * * 7. Edwards 448 Curve | scalar point Multiplication * Input: Edwards affine coordinate X of point P * Edwards affine coordinate Y of point P * Scalar k * Output: Edwards affine coordinate X of point [k]P * Edwards affine coordinate Y of point [k]P * Decode: Caller must supply parameters in MSB order, the * implementation will not explicitly decode according * to RFC#7748 Section 5 * * 8. Edwards 448 Curve | generator point Multiplication * Input: Scalar k * Output: Edwards affine coordinate X of point [k]G * Edwards affine coordinate Y of point [k]G * Decode: Caller must supply parameters in MSB order, the * implementation will not explicitly decode according * to RFC#7748 Section 5 * * @note * Large numbers are represented on the QuickAssist API as described * in the Large Number API (@ref cpaCyLn). * * In addition, the bit length of large numbers passed to the API * MUST NOT exceed 576 bits for Elliptic Curve operations. *****************************************************************************/ #ifndef CPA_CY_EC_H_ #define CPA_CY_EC_H_ #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyEc * Field types for Elliptic Curve * @description * As defined by FIPS-186-3, for each cryptovariable length, there are * two kinds of fields. *
    *
  • A prime field is the field GF(p) which contains a prime number * p of elements. The elements of this field are the integers modulo * p, and the field arithmetic is implemented in terms of the * arithmetic of integers modulo p.
  • * *
  • A binary field is the field GF(2^m) which contains 2^m elements * for some m (called the degree of the field). The elements of * this field are the bit strings of length m, and the field * arithmetic is implemented in terms of operations on the bits.
  • *
*****************************************************************************/ typedef enum _CpaCyEcFieldType { CPA_CY_EC_FIELD_TYPE_PRIME = 1, /**< A prime field, GF(p) */ CPA_CY_EC_FIELD_TYPE_BINARY, /**< A binary field, GF(2^m) */ } CpaCyEcFieldType; /** ***************************************************************************** * @ingroup cpaCyEc * Enumeration listing curve types to use with generic multiplication * and verification routines. * * @description * This structure contains a list of different elliptic curve types. * EC Point multiplication and other operations depend on the type of * the curve. * * @see * cpaCyEcGenericPointMultiply() * cpaCyEcGenericPointVerify() * *****************************************************************************/ typedef enum _CpaCyEcCurveType { CPA_CY_EC_CURVE_TYPE_WEIERSTRASS_PRIME = 1, /**< A Weierstrass curve with arithmetic in terms of the * arithmetic of integers modulo p over a prime field. */ CPA_CY_EC_CURVE_TYPE_WEIERSTRASS_BINARY, /**< A Weierstrass curve with arithmetic in terms of operations on bits * over a binary field. */ CPA_CY_EC_CURVE_TYPE_WEIERSTRASS_KOBLITZ_BINARY, /**< A Weierstrass-koblitz curve with arithmetic in terms of operations on * the bits over a binary field. */ } CpaCyEcCurveType; /** ***************************************************************************** * @ingroup cpaCyEc * Curve types for Elliptic Curves defined in RFC#7748 * @description * As defined by RFC 7748, there are four elliptic curves in this * group. The Montgomery curves are denoted curve25519 and curve448, * and the birationally equivalent Twisted Edwards curves are denoted * edwards25519 and edwards448 * *****************************************************************************/ typedef enum _CpaCyEcMontEdwdsCurveType { CPA_CY_EC_MONTEDWDS_CURVE25519_TYPE = 1, /**< Montgomery 25519 curve */ CPA_CY_EC_MONTEDWDS_ED25519_TYPE, /**< Edwards 25519 curve */ CPA_CY_EC_MONTEDWDS_CURVE448_TYPE, /**< Montgomery 448 curve */ CPA_CY_EC_MONTEDWDS_ED448_TYPE, /**< Edwards 448 curve */ } CpaCyEcMontEdwdsCurveType; /** ***************************************************************************** * @ingroup cpaCyEc * Curve parameters for a Weierstrass type curve. * * @description * This structure contains curve parameters for Weierstrass type * curve: y^2 = x^3 + ax + b * The client MUST allocate the memory for this structure * When the structure is passed into the function, ownership of the memory * passes to the function. Ownership of the memory returns to the client * when this structure is returned in the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * The legend used in this structure is borrowed from RFC7748 * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the function, and before it * has been returned in the callback, undefined behavior will result. * * @see * CpaCyEcCurveParameters * CpaCyEcFieldType * *****************************************************************************/ typedef struct _CpaCyEcCurveParametersWeierstrass { CpaCyEcFieldType fieldType; /**< Prime or Binary */ CpaFlatBuffer p; /**< Prime modulus or irreducible polynomial over GF(2^m) */ CpaFlatBuffer a; /**< a coefficient */ CpaFlatBuffer b; /**< b coefficient */ CpaFlatBuffer h; /**< Cofactor */ } CpaCyEcCurveParametersWeierstrass; /** ***************************************************************************** * @ingroup cpaCyEc * Union characterised by a specific curve. * * @description * This union allows for the characterisation of different curve types - * encapsulted in one data type. The intention is that new curve types + * encapsulated in one data type. The intention is that new curve types * will be added in the future. * * @note * * @see * CpaCyEcCurveParametersWeierstrass * *****************************************************************************/ typedef union _CpaCyEcCurveParameters { CpaCyEcCurveParametersWeierstrass weierstrassParameters; } CpaCyEcCurveParameters; /** ***************************************************************************** * @ingroup cpaCyEc * Unified curve parameters. * * @description * This structure provides a single data type that can describe a number * of different curve types. The intention is to add further * curve types in the future, thus the union field will allow for that * expansion. * * The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the function, and before it * has been returned in the callback, undefined behavior will result. * * @see * CpaCyEcCurveParameters * cpaCyEcGenericPointMultiply * cpaCyEcGenericPointVerify * *****************************************************************************/ typedef struct _CpaCyEcCurve { CpaCyEcCurveType curveType; CpaCyEcCurveParameters parameters; } CpaCyEcCurve; /** ***************************************************************************** * @ingroup cpaCyEc * EC Point Multiplication Operation Data. * * @description * This structure contains the operation data for the cpaCyEcPointMultiply * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcPointMultiply * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcPointMultiply() * *****************************************************************************/ typedef struct _CpaCyEcPointMultiplyOpData { CpaFlatBuffer k; /**< scalar multiplier (k > 0 and k < n) */ CpaFlatBuffer xg; /**< x coordinate of curve point */ CpaFlatBuffer yg; /**< y coordinate of curve point */ CpaFlatBuffer a; /**< a elliptic curve coefficient */ CpaFlatBuffer b; /**< b elliptic curve coefficient */ CpaFlatBuffer q; /**< prime modulus or irreducible polynomial over GF(2^m)*/ CpaFlatBuffer h; /**< cofactor of the operation. * If the cofactor is NOT required then set the cofactor to 1 or the * data pointer of the Flat Buffer to NULL. */ CpaCyEcFieldType fieldType; /**< field type for the operation */ } CpaCyEcPointMultiplyOpData CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyEc * Generic EC Point Multiplication Operation Data. * * @description * This structure contains a generic EC point and a multiplier for use with * cpaCyEcGenericPointMultiply. This is common for representing all EC * points, irrespective of curve type: Weierstrass, Montgomery and Twisted * Edwards (at this time only Weierstrass are supported). The same * point + multiplier format can be used when performing generator * multiplication, in which case the xP, yP supplied in this structure will * be ignored by QAT API library & a generator point will be inserted in * their place. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcGenericPointMultiply * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcGenericPointMultiply() * *****************************************************************************/ typedef struct _CpaCyEcGenericPointMultiplyOpData { CpaFlatBuffer k; /** 0 and k < n) */ CpaFlatBuffer xP; /** pair specified in the structure * lies on the curve indicated in the cpaCyEcGenericPointVerify API. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcGenericPointVerify * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcGenericPointVerify() * *****************************************************************************/ typedef struct _CpaCyEcGenericPointVerifyOpData { CpaFlatBuffer xP; /** 0 and k < n) */ CpaFlatBuffer xg; /**< x coordinate of curve point */ CpaFlatBuffer yg; /**< y coordinate of curve point */ CpaFlatBuffer a; /**< a equation coefficient */ CpaFlatBuffer b; /**< b equation coefficient */ CpaFlatBuffer q; /**< prime modulus or irreducible polynomial over GF(2^r) */ CpaFlatBuffer h; /**< cofactor of the operation. * If the cofactor is NOT required then set the cofactor to 1 or the * data pointer of the Flat Buffer to NULL. * There are some restrictions on the value of the cofactor. * Implementations of this API will support at least the following: *
    *
  • NIST standard curves and their cofactors (1, 2 and 4)
  • * *
  • Random curves where max(log2(p), log2(n)+log2(h)) <= 512, where * p is the modulus, n is the order of the curve and h is the cofactor *
  • *
*/ CpaCyEcFieldType fieldType; /**< field type for the operation */ CpaBoolean pointVerify; /**< set to CPA_TRUE to do a verification before the multiplication */ } CpaCyEcdhPointMultiplyOpData; /** ***************************************************************************** * @ingroup cpaCyEcdh * Cryptographic ECDH Statistics. * @description * This structure contains statistics on the Cryptographic ECDH * operations. Statistics are set to zero when the component is * initialized, and are collected per instance. * ****************************************************************************/ typedef struct _CpaCyEcdhStats64 { Cpa64U numEcdhPointMultiplyRequests; /**< Total number of ECDH Point Multiplication operation requests. */ Cpa64U numEcdhPointMultiplyRequestErrors; /**< Total number of ECDH Point Multiplication operation requests that had * an error and could not be processed. */ Cpa64U numEcdhPointMultiplyCompleted; /**< Total number of ECDH Point Multiplication operation requests that * completed successfully. */ Cpa64U numEcdhPointMultiplyCompletedError; /**< Total number of ECDH Point Multiplication operation requests that could * not be completed successfully due to errors. */ Cpa64U numEcdhRequestCompletedOutputInvalid; /**< Total number of ECDH Point Multiplication or Point Verify operation * requests that could not be completed successfully due to an invalid * output. * Note that this does not indicate an error. */ } CpaCyEcdhStats64; /** ***************************************************************************** * @ingroup cpaCyEcdh * Definition of callback function invoked for cpaCyEcdhPointMultiply * requests. * * @description * This is the prototype for the CpaCyEcdhPointMultiplyCbFunc callback * function * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Opaque pointer to Operation data supplied in * request. * @param[in] pXk Output x coordinate from the request. * @param[in] pYk Output y coordinate from the request. * @param[in] multiplyStatus Status of the point multiplication and the * verification when the pointVerify bit is set * in the CpaCyEcdhPointMultiplyOpData structure. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyEcdhPointMultiply() * *****************************************************************************/ typedef void (*CpaCyEcdhPointMultiplyCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean multiplyStatus, CpaFlatBuffer *pXk, CpaFlatBuffer *pYk); /** ***************************************************************************** * @ingroup cpaCyEcdh * ECDH Point Multiplication. * * @description * This function performs ECDH Point Multiplication as defined in * ANSI X9.63 2001 section 5.4 * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to * a NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pMultiplyStatus In synchronous mode, the status of the point * multiplication and the verification when the * pointVerify bit is set in the * CpaCyEcdhPointMultiplyOpData structure. Set to * CPA_FALSE if the point is NOT on the curve or * at infinity. Set to CPA_TRUE if the point is * on the curve. * @param[out] pXk Pointer to x coordinate flat buffer. * @param[out] pYk Pointer to y coordinate flat buffer. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyEcdhPointMultiplyCbFunc is generated in response to this function * call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyEcdhPointMultiplyOpData, * CpaCyEcdhPointMultiplyCbFunc * *****************************************************************************/ CpaStatus cpaCyEcdhPointMultiply(const CpaInstanceHandle instanceHandle, const CpaCyEcdhPointMultiplyCbFunc pCb, void *pCallbackTag, const CpaCyEcdhPointMultiplyOpData *pOpData, CpaBoolean *pMultiplyStatus, CpaFlatBuffer *pXk, CpaFlatBuffer *pYk); /** ***************************************************************************** * @ingroup cpaCyEcdh * Query statistics for a specific ECDH instance. * * @description * This function will query a specific instance of the ECDH implementation * for statistics. The user MUST allocate the CpaCyEcdhStats64 structure * and pass the reference to that structure into this function call. This * function writes the statistic results into the passed in * CpaCyEcdhStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pEcdhStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyEcdhStats64 *****************************************************************************/ CpaStatus cpaCyEcdhQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyEcdhStats64 *pEcdhStats); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /*CPA_CY_ECDH_H_*/ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_ecdsa.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_ecdsa.h index a3ecbbe88026..f1bb2b0240dc 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_ecdsa.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_ecdsa.h @@ -1,852 +1,852 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_ecdsa.h * * @defgroup cpaCyEcdsa Elliptic Curve Digital Signature Algorithm (ECDSA) API * * @ingroup cpaCy * * @description * These functions specify the API for Public Key Encryption * (Cryptography) Elliptic Curve Digital Signature Algorithm (ECDSA) * operations. * * @note * Large numbers are represented on the QuickAssist API as described * in the Large Number API (@ref cpaCyLn). * * In addition, the bit length of large numbers passed to the API * MUST NOT exceed 576 bits for Elliptic Curve operations. *****************************************************************************/ #ifndef CPA_CY_ECDSA_H_ #define CPA_CY_ECDSA_H_ #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" #include "cpa_cy_ec.h" /** ***************************************************************************** * @ingroup cpaCyEcdsa * ECDSA Sign R Operation Data. * @description * This structure contains the operation data for the cpaCyEcdsaSignR * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcdsaSignR * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcdsaSignR() * *****************************************************************************/ typedef struct _CpaCyEcdsaSignROpData { CpaFlatBuffer xg; /**< x coordinate of base point G */ CpaFlatBuffer yg; /**< y coordinate of base point G */ CpaFlatBuffer n; /**< order of the base point G, which shall be prime */ CpaFlatBuffer q; /**< prime modulus or irreducible polynomial over GF(2^r) */ CpaFlatBuffer a; /**< a elliptic curve coefficient */ CpaFlatBuffer b; /**< b elliptic curve coefficient */ CpaFlatBuffer k; /**< random value (k > 0 and k < n) */ CpaCyEcFieldType fieldType; /**< field type for the operation */ } CpaCyEcdsaSignROpData; /** ***************************************************************************** * @ingroup cpaCyEcdsa * ECDSA Sign S Operation Data. * @description * This structure contains the operation data for the cpaCyEcdsaSignS * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcdsaSignS * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcdsaSignS() * *****************************************************************************/ typedef struct _CpaCyEcdsaSignSOpData { CpaFlatBuffer m; /**< digest of the message to be signed */ CpaFlatBuffer d; /**< private key */ CpaFlatBuffer r; /**< Ecdsa r signature value */ CpaFlatBuffer k; /**< random value (k > 0 and k < n) */ CpaFlatBuffer n; /**< order of the base point G, which shall be prime */ CpaCyEcFieldType fieldType; /**< field type for the operation */ } CpaCyEcdsaSignSOpData; /** ***************************************************************************** * @ingroup cpaCyEcdsa * ECDSA Sign R & S Operation Data. * @description * This structure contains the operation data for the cpaCyEcdsaSignRS * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcdsaSignRS * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcdsaSignRS() * *****************************************************************************/ typedef struct _CpaCyEcdsaSignRSOpData { CpaFlatBuffer xg; /**< x coordinate of base point G */ CpaFlatBuffer yg; /**< y coordinate of base point G */ CpaFlatBuffer n; /**< order of the base point G, which shall be prime */ CpaFlatBuffer q; /**< prime modulus or irreducible polynomial over GF(2^r) */ CpaFlatBuffer a; /**< a elliptic curve coefficient */ CpaFlatBuffer b; /**< b elliptic curve coefficient */ CpaFlatBuffer k; /**< random value (k > 0 and k < n) */ CpaFlatBuffer m; /**< digest of the message to be signed */ CpaFlatBuffer d; /**< private key */ CpaCyEcFieldType fieldType; /**< field type for the operation */ } CpaCyEcdsaSignRSOpData; /** ***************************************************************************** * @ingroup cpaCyEcdsa * ECDSA Verify Operation Data, for Public Key. * @description * This structure contains the operation data for the CpaCyEcdsaVerify * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. a.pData[0] = MSB. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyEcdsaVerify * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * CpaCyEcdsaVerify() * *****************************************************************************/ typedef struct _CpaCyEcdsaVerifyOpData { CpaFlatBuffer xg; /**< x coordinate of base point G */ CpaFlatBuffer yg; /**< y coordinate of base point G */ CpaFlatBuffer n; /**< order of the base point G, which shall be prime */ CpaFlatBuffer q; /**< prime modulus or irreducible polynomial over GF(2^r) */ CpaFlatBuffer a; /**< a elliptic curve coefficient */ CpaFlatBuffer b; /**< b elliptic curve coefficient */ CpaFlatBuffer m; /**< digest of the message to be signed */ CpaFlatBuffer r; /**< ECDSA r signature value (r > 0 and r < n) */ CpaFlatBuffer s; /**< ECDSA s signature value (s > 0 and s < n) */ CpaFlatBuffer xp; /**< x coordinate of point P (public key) */ CpaFlatBuffer yp; /**< y coordinate of point P (public key) */ CpaCyEcFieldType fieldType; /**< field type for the operation */ } CpaCyEcdsaVerifyOpData; /** ***************************************************************************** * @ingroup cpaCyEcdsa * Cryptographic ECDSA Statistics. * @description * This structure contains statistics on the Cryptographic ECDSA * operations. Statistics are set to zero when the component is * initialized, and are collected per instance. * ****************************************************************************/ typedef struct _CpaCyEcdsaStats64 { Cpa64U numEcdsaSignRRequests; /**< Total number of ECDSA Sign R operation requests. */ Cpa64U numEcdsaSignRRequestErrors; /**< Total number of ECDSA Sign R operation requests that had an error and * could not be processed. */ Cpa64U numEcdsaSignRCompleted; /**< Total number of ECDSA Sign R operation requests that completed * successfully. */ Cpa64U numEcdsaSignRCompletedErrors; /**< Total number of ECDSA Sign R operation requests that could * not be completed successfully due to errors. */ Cpa64U numEcdsaSignRCompletedOutputInvalid; /**< Total number of ECDSA Sign R operation requests could not be completed * successfully due to an invalid output. * Note that this does not indicate an error. */ Cpa64U numEcdsaSignSRequests; /**< Total number of ECDSA Sign S operation requests. */ Cpa64U numEcdsaSignSRequestErrors; /**< Total number of ECDSA Sign S operation requests that had an error and * could not be processed. */ Cpa64U numEcdsaSignSCompleted; /**< Total number of ECDSA Sign S operation requests that completed * successfully. */ Cpa64U numEcdsaSignSCompletedErrors; /**< Total number of ECDSA Sign S operation requests that could * not be completed successfully due to errors. */ Cpa64U numEcdsaSignSCompletedOutputInvalid; /**< Total number of ECDSA Sign S operation requests could not be completed * successfully due to an invalid output. * Note that this does not indicate an error. */ Cpa64U numEcdsaSignRSRequests; /**< Total number of ECDSA Sign R & S operation requests. */ Cpa64U numEcdsaSignRSRequestErrors; /**< Total number of ECDSA Sign R & S operation requests that had an * error and could not be processed. */ Cpa64U numEcdsaSignRSCompleted; /**< Total number of ECDSA Sign R & S operation requests that completed * successfully. */ Cpa64U numEcdsaSignRSCompletedErrors; /**< Total number of ECDSA Sign R & S operation requests that could * not be completed successfully due to errors. */ Cpa64U numEcdsaSignRSCompletedOutputInvalid; /**< Total number of ECDSA Sign R & S operation requests could not be * completed successfully due to an invalid output. * Note that this does not indicate an error. */ Cpa64U numEcdsaVerifyRequests; /**< Total number of ECDSA Verification operation requests. */ Cpa64U numEcdsaVerifyRequestErrors; /**< Total number of ECDSA Verification operation requests that had an * error and could not be processed. */ Cpa64U numEcdsaVerifyCompleted; /**< Total number of ECDSA Verification operation requests that completed * successfully. */ Cpa64U numEcdsaVerifyCompletedErrors; /**< Total number of ECDSA Verification operation requests that could * not be completed successfully due to errors. */ Cpa64U numEcdsaVerifyCompletedOutputInvalid; /**< Total number of ECDSA Verification operation requests that resulted * in an invalid output. * Note that this does not indicate an error. */ Cpa64U numKptEcdsaSignRSCompletedOutputInvalid; /**< Total number of KPT ECDSA Sign R & S operation requests could not be * completed successfully due to an invalid output. * Note that this does not indicate an error. */ Cpa64U numKptEcdsaSignRSCompleted; /**< Total number of KPT ECDSA Sign R & S operation requests that completed * successfully. */ Cpa64U numKptEcdsaSignRSRequests; /**< Total number of KPT ECDSA Sign R & S operation requests. */ Cpa64U numKptEcdsaSignRSRequestErrors; /**< Total number of KPT ECDSA Sign R & S operation requests that had an * error and could not be processed. */ Cpa64U numKptEcdsaSignRSCompletedErrors; /**< Total number of KPT ECDSA Sign R & S operation requests that could * not be completed successfully due to errors. */ } CpaCyEcdsaStats64; /** ***************************************************************************** * @ingroup cpaCyEcdsa * Definition of a generic callback function invoked for a number of the * ECDSA Sign API functions. * * @description * This is the prototype for the CpaCyEcdsaGenSignCbFunc callback function. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Opaque pointer to Operation data supplied in * request. * @param[in] multiplyStatus Status of the point multiplication. * @param[in] pOut Output data from the request. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyEcdsaSignR() * cpaCyEcdsaSignS() * *****************************************************************************/ typedef void (*CpaCyEcdsaGenSignCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean multiplyStatus, CpaFlatBuffer *pOut); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Definition of callback function invoked for cpaCyEcdsaSignRS * requests. * * @description * This is the prototype for the CpaCyEcdsaSignRSCbFunc callback function, * which will provide the ECDSA message signature r and s parameters. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Operation data pointer supplied in request. * @param[in] multiplyStatus Status of the point multiplication. * @param[in] pR Ecdsa message signature r. * @param[in] pS Ecdsa message signature s. * * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyEcdsaSignRS() * *****************************************************************************/ typedef void (*CpaCyEcdsaSignRSCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean multiplyStatus, CpaFlatBuffer *pR, CpaFlatBuffer *pS); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Definition of callback function invoked for cpaCyEcdsaVerify requests. * * @description * This is the prototype for the CpaCyEcdsaVerifyCbFunc callback function. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Operation data pointer supplied in request. * @param[in] verifyStatus The verification status. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyEcdsaVerify() * *****************************************************************************/ typedef void (*CpaCyEcdsaVerifyCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean verifyStatus); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Generate ECDSA Signature R. * * @description * This function generates ECDSA Signature R as per ANSI X9.62 2005 * section 7.3. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pSignStatus In synchronous mode, the multiply output is * valid (CPA_TRUE) or the output is invalid * (CPA_FALSE). * @param[out] pR ECDSA message signature r. * * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback is generated in response * to this function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * None *****************************************************************************/ CpaStatus cpaCyEcdsaSignR(const CpaInstanceHandle instanceHandle, const CpaCyEcdsaGenSignCbFunc pCb, void *pCallbackTag, const CpaCyEcdsaSignROpData *pOpData, CpaBoolean *pSignStatus, CpaFlatBuffer *pR); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Generate ECDSA Signature S. * * @description * This function generates ECDSA Signature S as per ANSI X9.62 2005 * section 7.3. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pSignStatus In synchronous mode, the multiply output is * valid (CPA_TRUE) or the output is invalid * (CPA_FALSE). * @param[out] pS ECDSA message signature s. * * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback is generated in response * to this function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * None *****************************************************************************/ CpaStatus cpaCyEcdsaSignS(const CpaInstanceHandle instanceHandle, const CpaCyEcdsaGenSignCbFunc pCb, void *pCallbackTag, const CpaCyEcdsaSignSOpData *pOpData, CpaBoolean *pSignStatus, CpaFlatBuffer *pS); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Generate ECDSA Signature R & S. * * @description * This function generates ECDSA Signature R & S as per ANSI X9.62 2005 * section 7.3. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to a * NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pSignStatus In synchronous mode, the multiply output is * valid (CPA_TRUE) or the output is invalid * (CPA_FALSE). * @param[out] pR ECDSA message signature r. * @param[out] pS ECDSA message signature s. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback is generated in response * to this function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * None *****************************************************************************/ CpaStatus cpaCyEcdsaSignRS(const CpaInstanceHandle instanceHandle, const CpaCyEcdsaSignRSCbFunc pCb, void *pCallbackTag, const CpaCyEcdsaSignRSOpData *pOpData, CpaBoolean *pSignStatus, CpaFlatBuffer *pR, CpaFlatBuffer *pS); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Verify ECDSA Public Key. * * @description * This function performs ECDSA Verify as per ANSI X9.62 2005 section 7.4. * * A response status of ok (verifyStatus == CPA_TRUE) means that the * signature was verified * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to * a NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pVerifyStatus In synchronous mode, set to CPA_FALSE if the * point is NOT on the curve or at infinity. Set * to CPA_TRUE if the point is on the curve. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyEcdsaVerifyCbFunc is generated in response to this function * call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyEcdsaVerifyOpData, * CpaCyEcdsaVerifyCbFunc * *****************************************************************************/ CpaStatus cpaCyEcdsaVerify(const CpaInstanceHandle instanceHandle, const CpaCyEcdsaVerifyCbFunc pCb, void *pCallbackTag, const CpaCyEcdsaVerifyOpData *pOpData, CpaBoolean *pVerifyStatus); /** ***************************************************************************** * @ingroup cpaCyEcdsa * Query statistics for a specific ECDSA instance. * * @description * This function will query a specific instance of the ECDSA implementation * for statistics. The user MUST allocate the CpaCyEcdsaStats64 structure * and pass the reference to that structure into this function call. This * function writes the statistic results into the passed in * CpaCyEcdsaStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pEcdsaStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyEcdsaStats64 *****************************************************************************/ CpaStatus cpaCyEcdsaQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyEcdsaStats64 *pEcdsaStats); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /*CPA_CY_ECDSA_H_*/ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_im.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_im.h index 2225e364f64a..f70e43fcf047 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_im.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_im.h @@ -1,342 +1,342 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_im.h * * @defgroup cpaCyInstMaint Cryptographic Instance Management API * * @ingroup cpaCy * * @description * These functions specify the Instance Management API for available * Cryptographic Instances. It is expected that these functions will only be * called via a single system maintenance entity, rather than individual * clients. * *****************************************************************************/ #ifndef CPA_CY_IM_H_ #define CPA_CY_IM_H_ #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyInstMaint * Cryptographic Component Initialization and Start function. * * @description * This function will initialize and start the Cryptographic component. * It MUST be called before any other crypto function is called. This * function SHOULD be called only once (either for the very first time, * or after an cpaCyStopInstance call which succeeded) per instance. * Subsequent calls will have no effect. * * @context * This function may sleep, and MUST NOT be called in interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * @param[out] instanceHandle Handle to an instance of this API to be * initialized. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to shutdown and restart. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None. * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * cpaCyStopInstance() * *****************************************************************************/ CpaStatus cpaCyStartInstance(CpaInstanceHandle instanceHandle); /** ***************************************************************************** * @ingroup cpaCyInstMaint * Cryptographic Component Stop function. * * @description * This function will stop the Cryptographic component and free * all system resources associated with it. The client MUST ensure that * all outstanding operations have completed before calling this function. * The recommended approach to ensure this is to deregister all session or * callback handles before calling this function. If outstanding * operations still exist when this function is invoked, the callback * function for each of those operations will NOT be invoked and the * shutdown will continue. If the component is to be restarted, then a * call to cpaCyStartInstance is required. * * @context * This function may sleep, and so MUST NOT be called in interrupt * context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * @param[in] instanceHandle Handle to an instance of this API to be * shutdown. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to ensure requests are not still being * submitted and that all sessions are * deregistered. If this does not help, then * forcefully remove the component from the * system. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance. * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * cpaCyStartInstance() * *****************************************************************************/ CpaStatus cpaCyStopInstance(CpaInstanceHandle instanceHandle); /** ***************************************************************************** * @ingroup cpaCyInstMaint * Cryptographic Capabilities Info * * @description * This structure contains the capabilities that vary across API * implementations. This structure is used in conjunction with * @ref cpaCyQueryCapabilities() to determine the capabilities supported * by a particular API implementation. * * The client MUST allocate memory for this structure and any members * that require memory. When the structure is passed into the function * ownership of the memory passes to the function. Ownership of the * memory returns to the client when the function returns. *****************************************************************************/ typedef struct _CpaCyCapabilitiesInfo { CpaBoolean symSupported; /**< CPA_TRUE if instance supports the symmetric cryptography API. * See @ref cpaCySym. */ CpaBoolean symDpSupported; /**< CPA_TRUE if instance supports the symmetric cryptography * data plane API. * See @ref cpaCySymDp. */ CpaBoolean dhSupported; /**< CPA_TRUE if instance supports the Diffie Hellman API. * See @ref cpaCyDh. */ CpaBoolean dsaSupported; /**< CPA_TRUE if instance supports the DSA API. * See @ref cpaCyDsa. */ CpaBoolean rsaSupported; /**< CPA_TRUE if instance supports the RSA API. * See @ref cpaCyRsa. */ CpaBoolean ecSupported; /**< CPA_TRUE if instance supports the Elliptic Curve API. * See @ref cpaCyEc. */ CpaBoolean ecdhSupported; /**< CPA_TRUE if instance supports the Elliptic Curve Diffie Hellman API. * See @ref cpaCyEcdh. */ CpaBoolean ecdsaSupported; /**< CPA_TRUE if instance supports the Elliptic Curve DSA API. * See @ref cpaCyEcdsa. */ CpaBoolean keySupported; /**< CPA_TRUE if instance supports the Key Generation API. * See @ref cpaCyKeyGen. */ CpaBoolean lnSupported; /**< CPA_TRUE if instance supports the Large Number API. * See @ref cpaCyLn. */ CpaBoolean primeSupported; /**< CPA_TRUE if instance supports the prime number testing API. * See @ref cpaCyPrime. */ CpaBoolean drbgSupported; /**< CPA_TRUE if instance supports the DRBG API. * See @ref cpaCyDrbg. */ CpaBoolean nrbgSupported; /**< CPA_TRUE if instance supports the NRBG API. * See @ref cpaCyNrbg. */ CpaBoolean randSupported; /**< CPA_TRUE if instance supports the random bit/number generation API. * See @ref cpaCyRand. */ CpaBoolean kptSupported; /**< CPA_TRUE if instance supports the Intel(R) KPT Cryptographic API. * See @ref cpaCyKpt. */ CpaBoolean hkdfSupported; /**< CPA_TRUE if instance supports the HKDF components of the KeyGen API. * See @ref cpaCyKeyGen. */ CpaBoolean extAlgchainSupported; /**< CPA_TRUE if instance supports algorithm chaining for certain * wireless algorithms. Please refer to implementation for details. * See @ref cpaCySym. */ CpaBoolean ecEdMontSupported; /**< CPA_TRUE if instance supports the Edwards and Montgomery elliptic * curves of the EC API. * See @ref cpaCyEc */ CpaBoolean ecSm2Supported; /**< CPA_TRUE if instance supports the EcSM2 API. * See @ref cpaCyEcsm2. */ } CpaCyCapabilitiesInfo; /** ***************************************************************************** * @ingroup cpaCyInstMaint * Returns capabilities of a Cryptographic API instance * * @description * This function is used to query the instance capabilities. * * @context * The function shall not be called in an interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[out] pCapInfo Pointer to capabilities info structure. * All fields in the structure * are populated by the API instance. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The instance has been initialized via the @ref cpaCyStartInstance * function. * @post * None *****************************************************************************/ CpaStatus cpaCyQueryCapabilities(const CpaInstanceHandle instanceHandle, CpaCyCapabilitiesInfo * pCapInfo); /** ***************************************************************************** * @ingroup cpaCyInstMaint * Sets the address translation function * * @description * This function is used to set the virtual to physical address * translation routine for the instance. The specified routine * is used by the instance to perform any required translation of * a virtual address to a physical address. If the application * does not invoke this function, then the instance will use its * default method, such as virt2phys, for address translation. * @context * The function shall not be called in an interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[in] virtual2Physical Routine that performs virtual to * physical address translation. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * None * @post * None * @see * None * *****************************************************************************/ CpaStatus cpaCySetAddressTranslation(const CpaInstanceHandle instanceHandle, CpaVirtualToPhysical virtual2Physical); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /*CPA_CY_IM_H_*/ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_key.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_key.h index 3d013271e80b..a0eaf35ec760 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_key.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_key.h @@ -1,1204 +1,1204 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_key.h * * @defgroup cpaCyKeyGen Cryptographic Key and Mask Generation API * * @ingroup cpaCy * * @description * These functions specify the API for key and mask generation * operations. * *****************************************************************************/ #ifndef CPA_CY_KEY_H #define CPA_CY_KEY_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" #include "cpa_cy_sym.h" /* needed for hash algorithm, for MGF */ /** ***************************************************************************** * @ingroup cpaCyKeyGen * SSL or TLS key generation random number length. * * @description * Defines the permitted SSL or TLS random number length in bytes that * may be used with the functions @ref cpaCyKeyGenSsl and @ref * cpaCyKeyGenTls. This is the length of the client or server random * number values. *****************************************************************************/ #define CPA_CY_KEY_GEN_SSL_TLS_RANDOM_LEN_IN_BYTES (32) /** ***************************************************************************** * @ingroup cpaCyKeyGen * SSL Operation Types * @description * Enumeration of the different SSL operations that can be specified in * the struct @ref CpaCyKeyGenSslOpData. It identifies the label. *****************************************************************************/ typedef enum _CpaCyKeySslOp { CPA_CY_KEY_SSL_OP_MASTER_SECRET_DERIVE = 1, /**< Derive the master secret */ CPA_CY_KEY_SSL_OP_KEY_MATERIAL_DERIVE, /**< Derive the key material */ CPA_CY_KEY_SSL_OP_USER_DEFINED /**< User Defined Operation for custom labels*/ } CpaCyKeySslOp; /** ***************************************************************************** * @ingroup cpaCyKeyGen * SSL data for key generation functions * @description * This structure contains data for use in key generation operations for * SSL. For specific SSL key generation operations, the structure fields * MUST be set as follows: * * @par SSL Master-Secret Derivation: *
sslOp = CPA_CY_KEY_SSL_OP_MASTER_SECRET_DERIVE *
secret = pre-master secret key *
seed = client_random + server_random *
userLabel = NULL * * @par SSL Key-Material Derivation: *
sslOp = CPA_CY_KEY_SSL_OP_KEY_MATERIAL_DERIVE *
secret = master secret key *
seed = server_random + client_random *
userLabel = NULL * *
Note that the client/server random order is reversed from that * used for master-secret derivation. * * @note Each of the client and server random numbers need to be of * length CPA_CY_KEY_GEN_SSL_TLS_RANDOM_LEN_IN_BYTES. * * @note In each of the above descriptions, + indicates concatenation. * * @note The label used is predetermined by the SSL operation in line * with the SSL 3.0 specification, and can be overridden by using * a user defined operation CPA_CY_KEY_SSL_OP_USER_DEFINED and * associated userLabel. * ****************************************************************************/ typedef struct _CpaCyKeyGenSslOpData { CpaCyKeySslOp sslOp; /**< Indicate the SSL operation to be performed */ CpaFlatBuffer secret; /**< Flat buffer containing a pointer to either the master or pre-master * secret key. The length field indicates the length of the secret key in * bytes. Implementation-specific limits may apply to this length. */ CpaFlatBuffer seed; /**< Flat buffer containing a pointer to the seed data. * Implementation-specific limits may apply to this length. */ CpaFlatBuffer info; /**< Flat buffer containing a pointer to the info data. * Implementation-specific limits may apply to this length. */ Cpa32U generatedKeyLenInBytes; /**< The requested length of the generated key in bytes. * Implementation-specific limits may apply to this length. */ CpaFlatBuffer userLabel; /**< Optional flat buffer containing a pointer to a user defined label. * The length field indicates the length of the label in bytes. To use this * field, the sslOp must be CPA_CY_KEY_SSL_OP_USER_DEFINED, * or otherwise it is ignored and can be set to NULL. * Implementation-specific limits may apply to this length. */ } CpaCyKeyGenSslOpData; /** ***************************************************************************** * @ingroup cpaCyKeyGen * TLS Operation Types * @description * Enumeration of the different TLS operations that can be specified in * the CpaCyKeyGenTlsOpData. It identifies the label. * * The functions @ref cpaCyKeyGenTls and @ref cpaCyKeyGenTls2 * accelerate the TLS PRF, which is defined as part of RFC2246 (TLS * v1.0), RFC4346 (TLS v1.1), and RFC5246 (TLS v1.2). * One of the inputs to each of these functions is a label. * This enumerated type defines values that correspond to some of * the required labels. * However, for some of the operations/labels required by these RFCs, * no values are specified. * * In such cases, a user-defined value must be provided. The client * should use the enum value @ref CPA_CY_KEY_TLS_OP_USER_DEFINED, and * pass the label using the userLabel field of the @ref * CpaCyKeyGenTlsOpData data structure. * *****************************************************************************/ typedef enum _CpaCyKeyTlsOp { CPA_CY_KEY_TLS_OP_MASTER_SECRET_DERIVE = 1, /**< Derive the master secret using the TLS PRF. * Corresponds to RFC2246/5246 section 8.1, operation "Computing the * master secret", label "master secret". */ CPA_CY_KEY_TLS_OP_KEY_MATERIAL_DERIVE, /**< Derive the key material using the TLS PRF. * Corresponds to RFC2246/5246 section 6.3, operation "Derive the key * material", label "key expansion". */ CPA_CY_KEY_TLS_OP_CLIENT_FINISHED_DERIVE, /**< Derive the client finished tag using the TLS PRF. * Corresponds to RFC2246/5246 section 7.4.9, operation "Client finished", * label "client finished". */ CPA_CY_KEY_TLS_OP_SERVER_FINISHED_DERIVE, /**< Derive the server finished tag using the TLS PRF. * Corresponds to RFC2246/5246 section 7.4.9, operation "Server finished", * label "server finished". */ CPA_CY_KEY_TLS_OP_USER_DEFINED /**< User Defined Operation for custom labels. */ } CpaCyKeyTlsOp; /** ***************************************************************************** * @file cpa_cy_key.h * @ingroup cpaCyKeyGen * TLS Operation Types * @description * Enumeration of the different TLS operations that can be specified in * the CpaCyKeyGenHKDFOpData. * * The function @ref cpaCyKeyGenTls3 * accelerates the TLS HKDF, which is defined as part of RFC5869 (HKDF) * and RFC8446 (TLS v1.3). * * This enumerated type defines the support HKDF operations for * extraction and expansion of keying material. * *****************************************************************************/ typedef enum _CpaCyKeyHKDFOp { CPA_CY_HKDF_KEY_EXTRACT = 12, /**< HKDF Extract operation * Corresponds to RFC5869 section 2.2, step 1 "Extract" */ CPA_CY_HKDF_KEY_EXPAND, /**< HKDF Expand operation * Corresponds to RFC5869 section 2.3, step 2 "Expand" */ CPA_CY_HKDF_KEY_EXTRACT_EXPAND, /**< HKDF operation * This performs HKDF_EXTRACT and HKDF_EXPAND in a single * API invocation. */ CPA_CY_HKDF_KEY_EXPAND_LABEL , /**< HKDF Expand label operation for TLS 1.3 * Corresponds to RFC8446 section 7.1 Key Schedule definition for * HKDF-Expand-Label, which refers to HKDF-Expand defined in RFC5869. */ CPA_CY_HKDF_KEY_EXTRACT_EXPAND_LABEL /**< HKDF Extract plus Expand label operation for TLS 1.3 * Corresponds to RFC5869 section 2.2, step 1 "Extract" followed by * RFC8446 section 7.1 Key Schedule definition for * HKDF-Expand-Label, which refers to HKDF-Expand defined in RFC5869. */ } CpaCyKeyHKDFOp; /** ***************************************************************************** * @file cpa_cy_key.h * @ingroup cpaCyKeyGen * TLS Operation Types * @description * Enumeration of the different cipher suites that may be used in a TLS * v1.3 operation. This value is used to infer the sizes of the key * and iv sublabel. * * The function @ref cpaCyKeyGenTls3 * accelerates the TLS HKDF, which is defined as part of RFC5869 (HKDF) * and RFC8446 (TLS v1.3). * * This enumerated type defines the supported cipher suites in the * TLS operation that require HKDF key operations. * *****************************************************************************/ typedef enum _CpaCyKeyHKDFCipherSuite { CPA_CY_HKDF_TLS_AES_128_GCM_SHA256 = 1, CPA_CY_HKDF_TLS_AES_256_GCM_SHA384, CPA_CY_HKDF_TLS_CHACHA20_POLY1305_SHA256 , CPA_CY_HKDF_TLS_AES_128_CCM_SHA256, CPA_CY_HKDF_TLS_AES_128_CCM_8_SHA256 } CpaCyKeyHKDFCipherSuite; /** ***************************************************************************** * @file cpa_cy_key.h * @ingroup cpaCyKeyGen * TLS Operation Types * @description * Bitwise constants for HKDF sublabels * * These definitions provide bit settings for sublabels for * HKDF-ExpandLabel operations. * *
key sublabel to generate "key" keying material *
iv sublabel to generate "iv" keying material *
resumption sublabel to generate "resumption" keying material *
finished sublabel to generate "finished" keying material * *****************************************************************************/ #define CPA_CY_HKDF_SUBLABEL_KEY ((Cpa16U)0x0001) /**< Bit for creation of key material for 'key' sublabel */ #define CPA_CY_HKDF_SUBLABEL_IV ((Cpa16U)0x0002) /**< Bit for creation of key material for 'iv' sublabel */ #define CPA_CY_HKDF_SUBLABEL_RESUMPTION ((Cpa16U)0x0004) /**< Bit for creation of key material for 'resumption' sublabel */ #define CPA_CY_HKDF_SUBLABEL_FINISHED ((Cpa16U)0x0008) /**< Bit for creation of key material for 'finished' sublabel */ #define CPA_CY_HKDF_KEY_MAX_SECRET_SZ ((Cpa8U)80) /** space in bytes PSK or (EC)DH */ #define CPA_CY_HKDF_KEY_MAX_HMAC_SZ ((Cpa8U)48) /** space in bytes of CPA_CY_SYM_HASH_SHA384 result */ #define CPA_CY_HKDF_KEY_MAX_INFO_SZ ((Cpa8U)80) /** space in bytes of largest info needed for TLS 1.3, * rounded up to multiple of 8 */ #define CPA_CY_HKDF_KEY_MAX_LABEL_SZ ((Cpa8U)78) /** space in bytes of largest label for TLS 1.3 */ #define CPA_CY_HKDF_KEY_MAX_LABEL_COUNT ((Cpa8U)4) /** Maximum number of labels in op structure */ /** ***************************************************************************** * @file cpa_cy_key.h * @ingroup cpaCyKeyGen * TLS data for key generation functions * @description * This structure contains data for describing label for the * HKDF Extract Label function * * @par Extract Label Function *
labelLen = length of the label field *
contextLen = length of the context field *
sublabelFlag = Mask of sub labels required for this label. *
label = label as defined in RFC8446 *
context = context as defined in RFC8446 * ****************************************************************************/ typedef struct _CpaCyKeyGenHKDFExpandLabel { Cpa8U label[CPA_CY_HKDF_KEY_MAX_LABEL_SZ]; /**< HKDFLabel field as defined in RFC8446 sec 7.1. */ Cpa8U labelLen; /**< The length, in bytes of the label */ Cpa8U sublabelFlag; /**< mask of sublabels to be generated. * This flag is composed of zero or more of: * CPA_CY_HKDF_SUBLABEL_KEY * CPA_CY_HKDF_SUBLABEL_IV * CPA_CY_HKDF_SUBLABEL_RESUMPTION * CPA_CY_HKDF_SUBLABEL_FINISHED */ } CpaCyKeyGenHKDFExpandLabel; /** ***************************************************************************** * @ingroup cpaCyKeyGen * TLS data for key generation functions * @description * This structure contains data for all HKDF operations: *
HKDF Extract *
HKDF Expand *
HKDF Expand Label *
HKDF Extract and Expand *
HKDF Extract and Expand Label * * @par HKDF Map Structure Elements *
secret - IKM value for extract operations or PRK for expand * or expand operations. *
seed - contains the salt for extract * operations *
info - contains the info data for extract operations *
labels - See notes above * ****************************************************************************/ typedef struct _CpaCyKeyGenHKDFOpData { CpaCyKeyHKDFOp hkdfKeyOp; /**< Keying operation to be performed. */ Cpa8U secretLen; /**< Length of secret field */ Cpa16U seedLen; /**< Length of seed field */ Cpa16U infoLen; /**< Length of info field */ Cpa16U numLabels; /**< Number of filled CpaCyKeyGenHKDFExpandLabel elements */ Cpa8U secret[CPA_CY_HKDF_KEY_MAX_SECRET_SZ]; /**< Input Key Material or PRK */ Cpa8U seed[CPA_CY_HKDF_KEY_MAX_HMAC_SZ]; /**< Input salt */ Cpa8U info[CPA_CY_HKDF_KEY_MAX_INFO_SZ]; /**< info field */ CpaCyKeyGenHKDFExpandLabel label[CPA_CY_HKDF_KEY_MAX_LABEL_COUNT]; /**< array of Expand Label structures */ } CpaCyKeyGenHKDFOpData; /** ***************************************************************************** * @ingroup cpaCyKeyGen * TLS data for key generation functions * @description * This structure contains data for use in key generation operations for * TLS. For specific TLS key generation operations, the structure fields * MUST be set as follows: * * @par TLS Master-Secret Derivation: *
tlsOp = CPA_CY_KEY_TLS_OP_MASTER_SECRET_DERIVE *
secret = pre-master secret key *
seed = client_random + server_random *
userLabel = NULL * * @par TLS Key-Material Derivation: *
tlsOp = CPA_CY_KEY_TLS_OP_KEY_MATERIAL_DERIVE *
secret = master secret key *
seed = server_random + client_random *
userLabel = NULL * *
Note that the client/server random order is reversed from * that used for Master-Secret Derivation. * * @par TLS Client finished/Server finished tag Derivation: *
tlsOp = CPA_CY_KEY_TLS_OP_CLIENT_FINISHED_DERIVE (client) *
or CPA_CY_KEY_TLS_OP_SERVER_FINISHED_DERIVE (server) *
secret = master secret key *
seed = MD5(handshake_messages) + SHA-1(handshake_messages) *
userLabel = NULL * * @note Each of the client and server random seeds need to be of * length CPA_CY_KEY_GEN_SSL_TLS_RANDOM_LEN_IN_BYTES. * @note In each of the above descriptions, + indicates concatenation. * @note The label used is predetermined by the TLS operation in line * with the TLS specifications, and can be overridden by using * a user defined operation CPA_CY_KEY_TLS_OP_USER_DEFINED * and associated userLabel. * ****************************************************************************/ typedef struct _CpaCyKeyGenTlsOpData { CpaCyKeyTlsOp tlsOp; /**< TLS operation to be performed */ CpaFlatBuffer secret; /**< Flat buffer containing a pointer to either the master or pre-master * secret key. The length field indicates the length of the secret in * bytes. */ CpaFlatBuffer seed; /**< Flat buffer containing a pointer to the seed data. * Implementation-specific limits may apply to this length. */ Cpa32U generatedKeyLenInBytes; /**< The requested length of the generated key in bytes. * Implementation-specific limits may apply to this length. */ CpaFlatBuffer userLabel; /**< Optional flat buffer containing a pointer to a user defined label. * The length field indicates the length of the label in bytes. To use this * field, the tlsOp must be CPA_CY_KEY_TLS_OP_USER_DEFINED. * Implementation-specific limits may apply to this length. */ } CpaCyKeyGenTlsOpData; /** ***************************************************************************** * @ingroup cpaCyKeyGen * Key Generation Mask Generation Function (MGF) Data * @description * This structure contains data relating to Mask Generation Function * key generation operations. * * @note The default hash algorithm used by the MGF is SHA-1. If a * different hash algorithm is preferred, then see the extended * version of this structure, @ref CpaCyKeyGenMgfOpDataExt. * @see * cpaCyKeyGenMgf ****************************************************************************/ typedef struct _CpaCyKeyGenMgfOpData { CpaFlatBuffer seedBuffer; /**< Caller MUST allocate a buffer and populate with the input seed * data. For optimal performance the start of the seed SHOULD be allocated * on an 8-byte boundary. The length field represents the seed length in * bytes. Implementation-specific limits may apply to this length. */ Cpa32U maskLenInBytes; /**< The requested length of the generated mask in bytes. * Implementation-specific limits may apply to this length. */ } CpaCyKeyGenMgfOpData; /** ***************************************************************************** * @ingroup cpaCyKeyGen * Extension to the original Key Generation Mask Generation Function * (MGF) Data * @description * This structure is an extension to the original MGF data structure. * The extension allows the hash function to be specified. * @note * This structure is separate from the base @ref CpaCyKeyGenMgfOpData * structure in order to retain backwards compatibility with the * original version of the API. * @see * cpaCyKeyGenMgfExt ****************************************************************************/ typedef struct _CpaCyKeyGenMgfOpDataExt { CpaCyKeyGenMgfOpData baseOpData; /**< "Base" operational data for MGF generation */ CpaCySymHashAlgorithm hashAlgorithm; /**< Specifies the hash algorithm to be used by the Mask Generation * Function */ } CpaCyKeyGenMgfOpDataExt; /** ***************************************************************************** * @ingroup cpaCyKeyGen * Key Generation Statistics. * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by @ref CpaCyKeyGenStats64. * @description * This structure contains statistics on the key and mask generation * operations. Statistics are set to zero when the component is * initialized, and are collected per instance. * ****************************************************************************/ typedef struct _CpaCyKeyGenStats { Cpa32U numSslKeyGenRequests; /**< Total number of successful SSL key generation requests. */ Cpa32U numSslKeyGenRequestErrors; /**< Total number of SSL key generation requests that had an error and * could not be processed. */ Cpa32U numSslKeyGenCompleted; /**< Total number of SSL key generation operations that completed * successfully. */ Cpa32U numSslKeyGenCompletedErrors; /**< Total number of SSL key generation operations that could not be * completed successfully due to errors. */ Cpa32U numTlsKeyGenRequests; /**< Total number of successful TLS key generation requests. */ Cpa32U numTlsKeyGenRequestErrors; /**< Total number of TLS key generation requests that had an error and * could not be processed. */ Cpa32U numTlsKeyGenCompleted; /**< Total number of TLS key generation operations that completed * successfully. */ Cpa32U numTlsKeyGenCompletedErrors; /**< Total number of TLS key generation operations that could not be * completed successfully due to errors. */ Cpa32U numMgfKeyGenRequests; /**< Total number of successful MGF key generation requests (including * "extended" MGF requests). */ Cpa32U numMgfKeyGenRequestErrors; /**< Total number of MGF key generation requests that had an error and * could not be processed. */ Cpa32U numMgfKeyGenCompleted; /**< Total number of MGF key generation operations that completed * successfully. */ Cpa32U numMgfKeyGenCompletedErrors; /**< Total number of MGF key generation operations that could not be * completed successfully due to errors. */ } CpaCyKeyGenStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyKeyGen * Key Generation Statistics (64-bit version). * @description * This structure contains the 64-bit version of the statistics * on the key and mask generation operations. * Statistics are set to zero when the component is * initialized, and are collected per instance. * ****************************************************************************/ typedef struct _CpaCyKeyGenStats64 { Cpa64U numSslKeyGenRequests; /**< Total number of successful SSL key generation requests. */ Cpa64U numSslKeyGenRequestErrors; /**< Total number of SSL key generation requests that had an error and * could not be processed. */ Cpa64U numSslKeyGenCompleted; /**< Total number of SSL key generation operations that completed * successfully. */ Cpa64U numSslKeyGenCompletedErrors; /**< Total number of SSL key generation operations that could not be * completed successfully due to errors. */ Cpa64U numTlsKeyGenRequests; /**< Total number of successful TLS key generation requests. */ Cpa64U numTlsKeyGenRequestErrors; /**< Total number of TLS key generation requests that had an error and * could not be processed. */ Cpa64U numTlsKeyGenCompleted; /**< Total number of TLS key generation operations that completed * successfully. */ Cpa64U numTlsKeyGenCompletedErrors; /**< Total number of TLS key generation operations that could not be * completed successfully due to errors. */ Cpa64U numMgfKeyGenRequests; /**< Total number of successful MGF key generation requests (including * "extended" MGF requests). */ Cpa64U numMgfKeyGenRequestErrors; /**< Total number of MGF key generation requests that had an error and * could not be processed. */ Cpa64U numMgfKeyGenCompleted; /**< Total number of MGF key generation operations that completed * successfully. */ Cpa64U numMgfKeyGenCompletedErrors; /**< Total number of MGF key generation operations that could not be * completed successfully due to errors. */ } CpaCyKeyGenStats64; /** ***************************************************************************** * @ingroup cpaCyKeyGen * SSL Key Generation Function. * @description * This function is used for SSL key generation. It implements the key * generation function defined in section 6.2.2 of the SSL 3.0 * specification as described in * http://www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt. * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenSslOpData Structure containing all the data * needed to perform the SSL key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @see * CpaCyKeyGenSslOpData, * CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyKeyGenSsl(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenSslOpData *pKeyGenSslOpData, CpaFlatBuffer *pGeneratedKeyBuffer); /** ***************************************************************************** * @ingroup cpaCyKeyGen * TLS Key Generation Function. * @description * This function is used for TLS key generation. It implements the * TLS PRF (Pseudo Random Function) as defined by RFC2246 (TLS v1.0) * and RFC4346 (TLS v1.1). * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenTlsOpData Structure containing all the data * needed to perform the TLS key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @see * CpaCyKeyGenTlsOpData, * CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyKeyGenTls(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenTlsOpData *pKeyGenTlsOpData, CpaFlatBuffer *pGeneratedKeyBuffer); /** ***************************************************************************** * @ingroup cpaCyKeyGen * TLS Key Generation Function version 2. * @description * This function is used for TLS key generation. It implements the * TLS PRF (Pseudo Random Function) as defined by RFC5246 (TLS v1.2). * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenTlsOpData Structure containing all the data * needed to perform the TLS key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @see * CpaCyKeyGenTlsOpData, * CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyKeyGenTls2(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenTlsOpData *pKeyGenTlsOpData, CpaCySymHashAlgorithm hashAlgorithm, CpaFlatBuffer *pGeneratedKeyBuffer); /** ***************************************************************************** * @ingroup cpaCyKeyGen * TLS Key Generation Function version 3. * @description * This function is used for TLS key generation. It implements the * TLS HKDF (HMAC Key Derivation Function) as defined by * RFC5689 (HKDF) and RFC8446 (TLS 1.3). * * The input seed is taken as a flat buffer and the generated key is * returned to caller in a flat destination data buffer. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific * call. Will be returned unchanged in the * callback. * @param[in] pKeyGenTlsOpData Structure containing all the data * needed to perform the TLS key * generation operation. The client code * allocates the memory for this * structure. This component takes * ownership of the memory until it is * returned in the callback. The memory * must be pinned and contiguous, suitable * for DMA operations. * @param[in] hashAlgorithm Specifies the hash algorithm to use. * According to RFC5246, this should be * "SHA-256 or a stronger standard hash * function." * @param[out] pGeneratedKeyBuffer Caller MUST allocate a sufficient * buffer to hold the key generation * output. The data pointer SHOULD be * aligned on an 8-byte boundary. The * length field passed in represents the * size of the buffer in bytes. The value * that is returned is the size of the * result key in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @see * CpaCyGenFlatBufCbFunc * CpaCyKeyGenHKDFOpData * *****************************************************************************/ CpaStatus cpaCyKeyGenTls3(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenHKDFOpData *pKeyGenTlsOpData, CpaCyKeyHKDFCipherSuite cipherSuite, CpaFlatBuffer *pGeneratedKeyBuffer); /** ***************************************************************************** * @ingroup cpaCyKeyGen * Mask Generation Function. * @description * This function implements the mask generation function MGF1 as * defined by PKCS#1 v2.1, and RFC3447. The input seed is taken * as a flat buffer and the generated mask is returned to caller in a * flat destination data buffer. * * @note The default hash algorithm used by the MGF is SHA-1. If a * different hash algorithm is preferred, then see the "extended" * version of this function, @ref cpaCyKeyGenMgfExt. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the * callback. * @param[in] pKeyGenMgfOpData Structure containing all the data needed * to perform the MGF key generation * operation. The client code allocates the * memory for this structure. This * component takes ownership of the memory * until it is returned in the callback. * @param[out] pGeneratedMaskBuffer Caller MUST allocate a sufficient buffer * to hold the generated mask. The data * pointer SHOULD be aligned on an 8-byte * boundary. The length field passed in * represents the size of the buffer in * bytes. The value that is returned is the * size of the generated mask in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @see * CpaCyKeyGenMgfOpData, * CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyKeyGenMgf(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenMgfOpData *pKeyGenMgfOpData, CpaFlatBuffer *pGeneratedMaskBuffer); /** ***************************************************************************** * @ingroup cpaCyKeyGen * Extended Mask Generation Function. * @description * This function is used for mask generation. It differs from the "base" * version of the function (@ref cpaCyKeyGenMgf) in that it allows * the hash function used by the Mask Generation Function to be * specified. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pKeyGenCb Pointer to callback function to be * invoked when the operation is complete. * If this is set to a NULL value the * function will operate synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the * callback. * @param[in] pKeyGenMgfOpDataExt Structure containing all the data needed * to perform the extended MGF key generation * operation. The client code allocates the * memory for this structure. This * component takes ownership of the memory * until it is returned in the callback. * @param[out] pGeneratedMaskBuffer Caller MUST allocate a sufficient buffer * to hold the generated mask. The data * pointer SHOULD be aligned on an 8-byte * boundary. The length field passed in * represents the size of the buffer in * bytes. The value that is returned is the * size of the generated mask in bytes. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * This function is only used to generate a mask keys from seed * material. * @see * CpaCyKeyGenMgfOpData, * CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyKeyGenMgfExt(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pKeyGenCb, void *pCallbackTag, const CpaCyKeyGenMgfOpDataExt *pKeyGenMgfOpDataExt, CpaFlatBuffer *pGeneratedMaskBuffer); /** ***************************************************************************** * @ingroup cpaCyKeyGen * Queries the Key and Mask generation statistics specific to * an instance. * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyKeyGenQueryStats64(). * * @description * This function will query a specific instance for key and mask * generation statistics. The user MUST allocate the CpaCyKeyGenStats * structure and pass the reference to that into this function call. This * function will write the statistic results into the passed in * CpaCyKeyGenStats structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pKeyGenStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * * @see * CpaCyKeyGenStats * *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyKeyGenQueryStats(const CpaInstanceHandle instanceHandle, struct _CpaCyKeyGenStats *pKeyGenStats); /** ***************************************************************************** * @ingroup cpaCyKeyGen * Queries the Key and Mask generation statistics (64-bit version) * specific to an instance. * * @description * This function will query a specific instance for key and mask * generation statistics. The user MUST allocate the CpaCyKeyGenStats64 * structure and pass the reference to that into this function call. This * function will write the statistic results into the passed in * CpaCyKeyGenStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pKeyGenStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * * @see * CpaCyKeyGenStats64 *****************************************************************************/ CpaStatus cpaCyKeyGenQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyKeyGenStats64 *pKeyGenStats); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_KEY_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_kpt.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_kpt.h index 612b86dbe488..dbf510cacb82 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_kpt.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_kpt.h @@ -1,853 +1,853 @@ /*************************************************************************** * * BSD LICENSE * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_kpt.h * * @defgroup cpaCyKpt Intel(R) Key Protection Technology (KPT) Cryptographic API * * @ingroup cpaCy * * @description * These functions specify the APIs for Key Protection Technology (KPT) * Cryptographic services. * * @note * These functions implement the KPT Cryptographic API. * This API is experimental and subject to change. * *****************************************************************************/ #ifndef __CPA_CY_KPT_H__ #define __CPA_CY_KPT_H__ #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" #include "cpa_cy_rsa.h" #include "cpa_cy_ecdsa.h" #include "cpa_cy_ec.h" /** ***************************************************************************** * @ingroup cpaCyKpt * KPT wrapping key handle * * @description * Handle to a unique wrapping key in wrapping key table. Application * creates it in KPT key transfer phase and maintains it for KPT Crypto * service. For each KPT Crypto service API invocation, this handle will * be used to get a SWK(Symmetric Wrapping Key) to unwrap * WPK(Wrapped Private Key) before performing the requested crypto * service. * *****************************************************************************/ typedef Cpa64U CpaCyKptHandle; /** ***************************************************************************** * @ingroup cpaCyKpt * Return Status * @description * This enumeration lists all the possible return status after completing * KPT APIs. * *****************************************************************************/ typedef enum CpaCyKptKeyManagementStatus_t { CPA_CY_KPT_SUCCESS = 0, - /**< Generic success status for all KPT wrapping key handling functions*/ + /**< Generic success status for all KPT wrapping key handling functions */ CPA_CY_KPT_LOADKEY_FAIL_QUOTA_EXCEEDED_PER_VFID, - /**< SWK count exceeds the configured maxmium value per VFID*/ + /**< SWK count exceeds the configured maximum value per VFID */ CPA_CY_KPT_LOADKEY_FAIL_QUOTA_EXCEEDED_PER_PASID, - /**< SWK count exceeds the configured maxmium value per PASID*/ + /**< SWK count exceeds the configured maximum value per PASID */ CPA_CY_KPT_LOADKEY_FAIL_QUOTA_EXCEEDED, - /**< SWK count exceeds the configured maxmium value when not scoped to - * VFID or PASID*/ + /**< SWK count exceeds the configured maximum value when not scoped to + * VFID or PASID */ CPA_CY_KPT_SWK_FAIL_NOT_FOUND, /**< Unable to find SWK entry by handle */ CPA_CY_KPT_FAILED, } CpaCyKptKeyManagementStatus; /** ***************************************************************************** * @ingroup cpaCyKpt * PKCS#1 v2.2 RSA-3K signature output length in bytes. * @see CpaCyKptValidationKey * *****************************************************************************/ #define CPA_CY_RSA3K_SIG_SIZE_INBYTES 384 /** ***************************************************************************** * @ingroup cpaCyKpt * KPT device credentials key certificate * @description * This structure defines the key format for use with KPT. * @see * cpaCyKptQueryDeviceCredentials * *****************************************************************************/ typedef struct CpaCyKptValidationKey_t { CpaCyRsaPublicKey publicKey; /**< Key */ Cpa8U signature[CPA_CY_RSA3K_SIG_SIZE_INBYTES]; /**< Signature of key */ } CpaCyKptValidationKey; /** ***************************************************************************** * @ingroup cpaCyKpt * Cipher algorithms used to generate a wrapped private key (WPK) from * the clear private key. * * @description * This enumeration lists supported cipher algorithms and modes. * *****************************************************************************/ typedef enum CpaCyKptWrappingKeyType_t { CPA_CY_KPT_WRAPPING_KEY_TYPE_AES256_GCM = 0 } CpaCyKptWrappingKeyType; /** ***************************************************************************** * @ingroup cpaCyKpt * KPT Loading key format specification. * @description * This structure defines the format of the symmetric wrapping key to be * loaded into KPT. Application sets these parameters through the * cpaCyKptLoadKey calls. * *****************************************************************************/ typedef struct CpaCyKptLoadKey_t { CpaFlatBuffer eSWK; /**< Encrypted SWK */ CpaCyKptWrappingKeyType wrappingAlgorithm; /**< Symmetric wrapping algorithm */ } CpaCyKptLoadKey; /** ***************************************************************************** * @ingroup cpaCyKpt * Max length of initialization vector * @description * Defines the permitted max iv length in bytes that may be used in * private key wrapping/unwrapping.For AEC-GCM, iv length is 12 bytes. * *@see cpaCyKptUnwrapContext * *****************************************************************************/ #define CPA_CY_KPT_MAX_IV_LENGTH (12) /** ***************************************************************************** * @ingroup cpaCyKpt * Max length of Additional Authenticated Data * @description * Defines the permitted max aad length in bytes that may be used in * private key wrapping/unwrapping. * *@see cpaCyKptUnwrapContext * *****************************************************************************/ #define CPA_CY_KPT_MAX_AAD_LENGTH (16) /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * Structure of KPT unwrapping context. * @description * This structure is a parameter of KPT crypto APIs, it contains data * relating to KPT WPK unwrapping, the application needs to fill in this * information. * *****************************************************************************/ typedef struct CpaCyKptUnwrapContext_t { CpaCyKptHandle kptHandle; /**< This is application's unique handle that identifies its * (symmetric) wrapping key*/ Cpa8U iv[CPA_CY_KPT_MAX_IV_LENGTH]; /**< Initialization Vector */ Cpa8U additionalAuthData[CPA_CY_KPT_MAX_AAD_LENGTH]; /**< A buffer holding the Additional Authenticated Data.*/ Cpa32U aadLenInBytes; /**< Number of bytes representing the size of AAD within additionalAuthData * buffer. */ } CpaCyKptUnwrapContext; /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * RSA Private Key Structure For Representation 1. * @description * This structure contains the first representation that can be used for * describing the RSA private key, represented by the tuple of the * modulus (N) and the private exponent (D). * The representation is encrypted as follows: * Encrypt - AES-256-GCM (Key, AAD, Input) * "||" - denotes concatenation * Key = SWK * AAD = DER(OID) * Input = (D || N) * Encrypt (SWK, AAD, (D || N)) * Output (AuthTag, (D || N)') * EncryptedRSAKey = (D || N)' * * privateKey = (EncryptedRSAKey || AuthTag) * * OID's that shall be supported by KPT implementation: * OID DER(OID) * 1.2.840.113549.1.1 06 08 2A 86 48 86 F7 0D 01 01 * * Permitted lengths for N and D are: * - 512 bits (64 bytes), * - 1024 bits (128 bytes), * - 1536 bits (192 bytes), * - 2048 bits (256 bytes), * - 3072 bits (384 bytes), * - 4096 bits (512 bytes), or * - 8192 bits (1024 bytes). * * AuthTag is 128 bits (16 bytes) * * @note It is important that the value D is big enough. It is STRONGLY * recommended that this value is at least half the length of the modulus * N to protect against the Wiener attack. * *****************************************************************************/ typedef struct CpaCyKptRsaPrivateKeyRep1_t { CpaFlatBuffer privateKey; /**< The EncryptedRSAKey concatenated with AuthTag */ } CpaCyKptRsaPrivateKeyRep1; /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * KPT RSA Private Key Structure For Representation 2. * @description * This structure contains the second representation that can be used for * describing the RSA private key. The quintuple of p, q, dP, dQ, and qInv * (explained below and in the spec) are required for the second * representation. For KPT the parameters are Encrypted - * with the assoicated SWK as follows: + * with the associated SWK as follows: * Encrypt - AES-256-GCM (Key, AAD, Input) * "||" - denotes concatenation * Key = SWK * AAD = DER(OID) * Input = (P || Q || dP || dQ || Qinv || publicExponentE) * Expanded Description: * Encrypt (SWK, AAD, * (P || Q || dP || dQ || Qinv || publicExponentE)) * EncryptedRSAKey = (P || Q || dP || dQ || Qinv || publicExponentE)' * Output (AuthTag, EncryptedRSAKey) * * privateKey = EncryptedRSAKey || AuthTag * * OID's that shall be supported by KPT implementation: * OID DER(OID) * 1.2.840.113549.1.1 06 08 2A 86 48 86 F7 0D 01 01 * * All of the encrypted parameters will be of equal size. The length of * each will be equal to keySize in bytes/2. * For example for a key size of 256 Bytes (2048 bits), the length of * P, Q, dP, dQ, and Qinv are all 128 Bytes, plus the * publicExponentE of 256 Bytes, giving a total size for * EncryptedRSAKey of 896 Bytes. * * AuthTag is 128 bits (16 bytes) * * Permitted Key Sizes are: * - 512 bits (64 bytes), * - 1024 bits (128 bytes), * - 1536 bits (192 bytes), * - 2048 bits (256 bytes), * - 3072 bits (384 bytes), * - 4096 bits (512 bytes), or * - 8192 bits (1024 bytes). * *****************************************************************************/ typedef struct CpaCyKptRsaPrivateKeyRep2_t { CpaFlatBuffer privateKey; /**< RSA private key representation 2 is built up from the * tuple of p, q, dP, dQ, qInv, publicExponentE and AuthTag. */ } CpaCyKptRsaPrivateKeyRep2; /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * RSA Private Key Structure. * @description * This structure contains the two representations that can be used for * describing the RSA private key. The privateKeyRepType will be used to * identify which representation is to be used. Typically, using the * second representation results in faster decryption operations. * *****************************************************************************/ typedef struct CpaCyKptRsaPrivateKey_t { CpaCyRsaVersion version; /**< Indicates the version of the PKCS #1 specification that is * supported. * Note that this applies to both representations. */ CpaCyRsaPrivateKeyRepType privateKeyRepType; /**< This value is used to identify which of the private key * representation types in this structure is relevant. * When performing key generation operations for Type 2 representations, * memory must also be allocated for the type 1 representations, and values * for both will be returned. */ CpaCyKptRsaPrivateKeyRep1 privateKeyRep1; /**< This is the first representation of the RSA private key as * defined in the PKCS #1 V2.2 specification. */ CpaCyKptRsaPrivateKeyRep2 privateKeyRep2; /**< This is the second representation of the RSA private key as * defined in the PKCS #1 V2.2 specification. */ } CpaCyKptRsaPrivateKey; /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * KPT RSA Decryption Primitive Operation Data * @description * This structure lists the different items that are required in the * cpaCyKptRsaDecrypt function. As the RSA decryption primitive and * signature primitive operations are mathematically identical this * structure may also be used to perform an RSA signature primitive * operation. * When performing an RSA decryption primitive operation, the input data * is the cipher text and the output data is the message text. * When performing an RSA signature primitive operation, the input data * is the message and the output data is the signature. * The client MUST allocate the memory for this structure. When the * structure is passed into the function, ownership of the memory passes * to he function. Ownership of the memory returns to the client when * this structure is returned in the CpaCyGenFlatBufCbFunc * callback function. * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyKptRsaDecrypt function, and * before it has been returned in the callback, undefined behavior will * result. * All values in this structure are required to be in Most Significant Byte * first order, e.g. inputData.pData[0] = MSB. * *****************************************************************************/ typedef struct CpaCyKptRsaDecryptOpData_t { CpaCyKptRsaPrivateKey *pRecipientPrivateKey; /**< Pointer to the recipient's RSA private key. */ CpaFlatBuffer inputData; /**< The input data that the RSA decryption primitive operation is * performed on. The data pointed to is an integer that MUST be in big- * endian order. The value MUST be between 0 and the modulus n - 1. */ } CpaCyKptRsaDecryptOpData; /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * KPT ECDSA Sign R & S Operation Data. * * @description * This structure contains the operation data for the cpaCyKptEcdsaSignRS * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * This key structure is encrypted when passed into cpaCyKptEcdsaSignRS * Encrypt - AES-256-GCM (Key, AAD, Input) * "||" - denotes concatenation * * Key = SWK * AAD = DER(OID) * Input = (d) * Encrypt (SWK, AAD, (d)) * Output (AuthTag, EncryptedECKey) * * privatekey == EncryptedECKey || AuthTag * * OID's that shall be supported by KPT implementation: * Curve OID DER(OID) * secp256r1 1.2.840.10045.3.1.7 06 08 2A 86 48 CE 3D 03 01 07 * secp384r1 1.3.132.0.34 06 05 2B 81 04 00 22 * secp521r1 1.3.132.0.35 06 05 2B 81 04 00 23 * * Expected private key (d) sizes: * secp256r1 256 bits * secp384r1 384 bits * secp521r1 576 bits (rounded up to a multiple of 64-bit quadword) * * AuthTag is 128 bits (16 bytes) * * For optimal performance all data buffers SHOULD be 8-byte aligned. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyKptEcdsaSignRS * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyEcdsaSignRS() * *****************************************************************************/ typedef struct CpaCyKptEcdsaSignRSOpData_t { CpaFlatBuffer privateKey; /**< Encrypted private key data of the form * EncryptECKey || AuthTag */ CpaFlatBuffer m; /**< digest of the message to be signed */ } CpaCyKptEcdsaSignRSOpData; /** ***************************************************************************** * Discovery and Provisioning APIs for KPT * *****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * Query KPT's issuing public key(R_Pu) and signature from QAT driver. * @description * This function is to query the RSA3K issuing key and its * PKCS#1 v2.2 SHA-384 signature from the QAT driver. * @context * This function may sleep, and MUST NOT be called in interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @param[in] instanceHandle Instance handle. * @param[out] pIssueCert KPT-2.0 Issuing certificate in PEM format as defined in RFC#7468 * @param[out] pKptStatus One of the status codes denoted in the * enumerate type CpaCyKptKeyManagementStatus * CPA_CY_KPT_SUCCESS Issuing key retrieved successfully * CPA_CY_KPT_FAILED Operation failed * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to shutdown and restart. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * @see * *****************************************************************************/ CpaStatus cpaCyKptQueryIssuingKeys(const CpaInstanceHandle instanceHandle, CpaFlatBuffer *pPublicX509IssueCert, CpaCyKptKeyManagementStatus *pKptStatus); /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * Query KPT's Per-Part public key(I_pu) and signature from QAT * device * @description * This function is to query RSA3K Per-Part public key and its * PKCS#1 v2.2 SHA-384 signature from the QAT device. * @context * This function may sleep, and MUST NOT be called in interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @param[in] instanceHandle Instance handle. * @param[out] pDevCredential Device Per-Part public key * @param[out] pKptStatus One of the status codes denoted in the * enumerate type CpaCyKptKeyManagementStatus * CPA_CY_KPT_SUCCESS Device credentials retrieved successfully * CPA_CY_KPT_FAILED Operation failed * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_FAIL Function failed. Suggested course of action * is to shutdown and restart. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * @see * *****************************************************************************/ CpaStatus cpaCyKptQueryDeviceCredentials(const CpaInstanceHandle instanceHandle, CpaCyKptValidationKey *pDevCredential, CpaCyKptKeyManagementStatus *pKptStatus); /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * Perform KPT key loading function. * * @description * This function is invoked by a QAT application to load an encrypted * symmetric wrapping key. * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle QAT service instance handle. * @param[in] pSWK Encrypted SWK * @param[out] keyHandle A 64-bit handle value created by KPT * @param[out] pKptStatus One of the status codes denoted in the * enumerate type CpaCyKptKeyManagementStatus * CPA_CY_KPT_SUCCESS Key Loaded successfully * CPA_CY_KPT_LOADKEY_FAIL_QUOTA_EXCEEDED_PER_VFID - * SWK count exceeds the configured maxmium value per VFID + * SWK count exceeds the configured maximum value per VFID * CPA_CY_KPT_LOADKEY_FAIL_QUOTA_EXCEEDED_PER_PASID - * SWK count exceeds the configured maxmium value per PASID + * SWK count exceeds the configured maximum value per PASID * CPA_CY_KPT_LOADKEY_FAIL_QUOTA_EXCEEDED - * SWK count exceeds the configured maxmium value when not scoped to + * SWK count exceeds the configured maximum value when not scoped to * VFID or PASID * CPA_CY_KPT_FAILED Operation failed due to unspecified reason * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * @retval CPA_STATUS_UNSUPPORTED KPT-2.0 is not supported. * * @pre * Component has been initialized. * @post * None * @note * None * @see * None *****************************************************************************/ CpaStatus cpaCyKptLoadKey(CpaInstanceHandle instanceHandle, CpaCyKptLoadKey *pSWK, CpaCyKptHandle *keyHandle, CpaCyKptKeyManagementStatus *pKptStatus); /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * Perform KPT delete keys function according to key handle * * @description * Before closing a QAT session(instance), an application that has * previously stored its wrapping key in a QAT device using the KPT * framework executes this call to delete its wrapping key in the QAT * device. * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle QAT service instance handle. * @param[in] keyHandle A 64-bit handle value * @param[out] pkptstatus One of the status codes denoted in the * enumerate type CpaCyKptKeyManagementStatus * CPA_CY_KPT_SUCCESS Key Deleted successfully * CPA_CY_KPT_SWK_FAIL_NOT_FOUND For any reason the input handle cannot be * found. * CPA_CY_KPT_FAILED Operation failed due to unspecified reason * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. * Resubmit the request. * @pre * Component has been initialized. * @post * None * @note * None * @see * None *****************************************************************************/ CpaStatus cpaCyKptDeleteKey(CpaInstanceHandle instanceHandle, CpaCyKptHandle keyHandle, CpaCyKptKeyManagementStatus *pKptStatus); /** ***************************************************************************** * Usage APIs for KPT * *****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_kpt.h * @ingroup cpaCyKpt * Perform KPT-2.0 mode RSA decrypt primitive operation on the input data. * * @description * This function is a variant of cpaCyRsaDecrypt, which will perform * an RSA decryption primitive operation on the input data using the * specified RSA private key which are encrypted. As the RSA decryption * primitive and signing primitive operations are mathematically * identical this function may also be used to perform an RSA signing * primitive operation. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pRsaDecryptCb Pointer to callback function to be invoked * when the operation is complete. If this is * set to a NULL value the function will operate * synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the callback. * @param[in] pDecryptOpData Structure containing all the data needed to * perform the RSA decrypt operation. The * client code allocates the memory for this * structure. This component takes ownership * of the memory until it is returned in the * callback. * @param[out] pOutputData Pointer to structure into which the result of * the RSA decryption primitive is written. The * client MUST allocate this memory. The data * pointed to is an integer in big-endian order. * The value will be between 0 and the modulus * n - 1. * On invocation the callback function will * contain this parameter in the pOut parameter. * @param[in] pKptUnwrapContext Pointer of structure into which the content * of KptUnwrapContext is kept. The client MUST * allocate this memory and copy structure * KptUnwrapContext into this flat buffer. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting.Resubmit * the request. * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * By virtue of invoking cpaSyKptRsaDecrypt, the implementation understands * that pDecryptOpData contains an encrypted private key that requires * unwrapping. KptUnwrapContext contains a 'KptHandle' field that points * to the unwrapping key in the WKT. * When pRsaDecryptCb is non-NULL an asynchronous callback is generated in * response to this function call. * Any errors generated during processing are reported as part of the * callback status code. For optimal performance, data pointers SHOULD be * 8-byte aligned. * In KPT release, private key field in CpaCyKptRsaDecryptOpData is a * concatenation of cipher text and hash tag. * For optimal performance, data pointers SHOULD be 8-byte aligned. * @see * CpaCyKptRsaDecryptOpData, * CpaCyGenFlatBufCbFunc, * *****************************************************************************/ CpaStatus cpaCyKptRsaDecrypt(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pRsaDecryptCb, void *pCallbackTag, const CpaCyKptRsaDecryptOpData *pDecryptOpData, CpaFlatBuffer *pOutputData, CpaCyKptUnwrapContext *pKptUnwrapContext); /** ***************************************************************************** * @ingroup cpaCyKpt * Generate ECDSA Signature R & S. * @description * This function is a variant of cpaCyEcdsaSignRS, it generates ECDSA * signature R & S as per ANSI X9.62 2005 section 7.3. * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to * a NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pSignStatus In synchronous mode, the multiply output is * valid (CPA_TRUE) or the output is invalid * (CPA_FALSE). * @param[out] pR ECDSA message signature r. * @param[out] pS ECDSA message signature s. * @param[in] pKptUnwrapContext Pointer of structure into which the content * of KptUnwrapContext is kept,The client MUST * allocate this memory and copy structure * KptUnwrapContext into this flat buffer. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * By virtue of invoking the cpaCyKptEcdsaSignRS, the implementation * understands CpaCyEcdsaSignRSOpData contains an encrypted private key that * requires unwrapping. KptUnwrapContext contains a 'KptHandle' field * that points to the unwrapping key in the WKT. * When pCb is non-NULL an asynchronous callback of type * CpaCyEcdsaSignRSCbFunc generated in response to this function * call. * In KPT release, private key field in CpaCyEcdsaSignRSOpData is a * concatenation of cipher text and hash tag. * @see * None *****************************************************************************/ CpaStatus cpaCyKptEcdsaSignRS(const CpaInstanceHandle instanceHandle, const CpaCyEcdsaSignRSCbFunc pCb, void *pCallbackTag, const CpaCyKptEcdsaSignRSOpData *pOpData, CpaBoolean *pSignStatus, CpaFlatBuffer *pR, CpaFlatBuffer *pS, CpaCyKptUnwrapContext *pKptUnwrapContext); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_ln.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_ln.h index 43550cdb0fed..6039720d3368 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_ln.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_ln.h @@ -1,519 +1,519 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_ln.h * * @defgroup cpaCyLn Cryptographic Large Number API * * @ingroup cpaCy * * @description * These functions specify the Cryptographic API for Large Number * Operations. * * @note * Large numbers are represented on the QuickAssist API using octet * strings, stored in structures of type @ref CpaFlatBuffer. These * octet strings are encoded as described by PKCS#1 v2.1, section 4, * which is consistent with ASN.1 syntax. The following text * summarizes this. Any exceptions to this encoding are specified * on the specific data structure or function to which the exception * applies. * * An n-bit number, N, has a value in the range 2^(n-1) through 2^(n)-1. * In other words, its most significant bit, bit n-1 (where bit-counting * starts from zero) MUST be set to 1. We can also state that the * bit-length n of a number N is defined by n = floor(log2(N))+1. * * The buffer, b, in which an n-bit number N is stored, must be "large * enough". In other words, b.dataLenInBytes must be at least * minLenInBytes = ceiling(n/8). * * The number is stored in a "big endian" format. This means that the * least significant byte (LSB) is b[b.dataLenInBytes-1], while the * most significant byte (MSB) is b[b.dataLenInBytes-minLenInBytes]. * In the case where the buffer is "exactly" the right size, then the * MSB is b[0]. Otherwise, all bytes from b[0] up to the MSB MUST be * set to 0x00. * * The largest bit-length we support today is 8192 bits. In other * words, we can deal with numbers up to a value of (2^8192)-1. * *****************************************************************************/ #ifndef CPA_CY_LN_H #define CPA_CY_LN_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyLn * Modular Exponentiation Function Operation Data. * @description * This structure lists the different items that are required in the * cpaCyLnModExp function. The client MUST allocate the memory for * this structure. When the structure is passed into the function, * ownership of the memory passes to the function. Ownership of the memory * returns to the client when this structure is returned in the callback. * The operation size in bits is equal to the size of whichever of the * following is largest: the modulus, the base or the exponent. * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyLnModExp function, and * before it has been returned in the callback, undefined behavior will * result. * The values of the base, the exponent and the modulus MUST all be less * than 2^8192, and the modulus must not be equal to zero. *****************************************************************************/ typedef struct _CpaCyLnModExpOpData { CpaFlatBuffer modulus; /**< Flat buffer containing a pointer to the modulus. * This number may be up to 8192 bits in length, and MUST be greater * than zero. */ CpaFlatBuffer base; /**< Flat buffer containing a pointer to the base. * This number may be up to 8192 bits in length. */ CpaFlatBuffer exponent; /**< Flat buffer containing a pointer to the exponent. * This number may be up to 8192 bits in length. */ } CpaCyLnModExpOpData; /** ***************************************************************************** * @ingroup cpaCyLn * Modular Inversion Function Operation Data. * @description * This structure lists the different items that are required in the * function @ref cpaCyLnModInv. The client MUST allocate the memory for * this structure. When the structure is passed into the function, * ownership of the memory passes to the function. Ownership of the * memory returns to the client when this structure is returned in the * callback. * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyLnModInv function, and * before it has been returned in the callback, undefined behavior will * result. * * Note that the values of A and B MUST NOT both be even numbers, and * both MUST be less than 2^8192. *****************************************************************************/ typedef struct _CpaCyLnModInvOpData { CpaFlatBuffer A; /**< Flat buffer containing a pointer to the value that will be * inverted. * This number may be up to 8192 bits in length, it MUST NOT be zero, * and it MUST be co-prime with B. */ CpaFlatBuffer B; /**< Flat buffer containing a pointer to the value that will be used as * the modulus. * This number may be up to 8192 bits in length, it MUST NOT be zero, * and it MUST be co-prime with A. */ } CpaCyLnModInvOpData; /** ***************************************************************************** * @ingroup cpaCyLn * Look Aside Cryptographic large number Statistics. * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by @ref CpaCyLnStats64. * @description * This structure contains statistics on the Look Aside Cryptographic * large number operations. Statistics are set to zero when the component * is initialized, and are collected per instance. * ****************************************************************************/ typedef struct _CpaCyLnStats { Cpa32U numLnModExpRequests; /**< Total number of successful large number modular exponentiation * requests.*/ Cpa32U numLnModExpRequestErrors; /**< Total number of large number modular exponentiation requests that * had an error and could not be processed. */ Cpa32U numLnModExpCompleted; /**< Total number of large number modular exponentiation operations * that completed successfully. */ Cpa32U numLnModExpCompletedErrors; /**< Total number of large number modular exponentiation operations * that could not be completed successfully due to errors. */ Cpa32U numLnModInvRequests; /**< Total number of successful large number modular inversion * requests.*/ Cpa32U numLnModInvRequestErrors; /**< Total number of large number modular inversion requests that * had an error and could not be processed. */ Cpa32U numLnModInvCompleted; /**< Total number of large number modular inversion operations * that completed successfully. */ Cpa32U numLnModInvCompletedErrors; /**< Total number of large number modular inversion operations * that could not be completed successfully due to errors. */ } CpaCyLnStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyLn * Look Aside Cryptographic large number Statistics. * @description * This structure contains statistics on the Look Aside Cryptographic * large number operations. Statistics are set to zero when the component * is initialized, and are collected per instance. * ****************************************************************************/ typedef struct _CpaCyLnStats64 { Cpa64U numLnModExpRequests; /**< Total number of successful large number modular exponentiation * requests.*/ Cpa64U numLnModExpRequestErrors; /**< Total number of large number modular exponentiation requests that * had an error and could not be processed. */ Cpa64U numLnModExpCompleted; /**< Total number of large number modular exponentiation operations * that completed successfully. */ Cpa64U numLnModExpCompletedErrors; /**< Total number of large number modular exponentiation operations * that could not be completed successfully due to errors. */ Cpa64U numLnModInvRequests; /**< Total number of successful large number modular inversion * requests.*/ Cpa64U numLnModInvRequestErrors; /**< Total number of large number modular inversion requests that * had an error and could not be processed. */ Cpa64U numLnModInvCompleted; /**< Total number of large number modular inversion operations * that completed successfully. */ Cpa64U numLnModInvCompletedErrors; /**< Total number of large number modular inversion operations * that could not be completed successfully due to errors. */ } CpaCyLnStats64; /** ***************************************************************************** * @ingroup cpaCyLn * Perform modular exponentiation operation. * * @description * This function performs modular exponentiation. It computes the * following result based on the inputs: * * result = (base ^ exponent) mod modulus * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pLnModExpCb Pointer to callback function to be * invoked when the operation is complete. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the callback. * @param[in] pLnModExpOpData Structure containing all the data needed * to perform the LN modular exponentiation * operation. The client code allocates * the memory for this structure. This * component takes ownership of the memory * until it is returned in the callback. * @param[out] pResult Pointer to a flat buffer containing a * pointer to memory allocated by the client * into which the result will be written. * The size of the memory required MUST be * larger than or equal to the size * required to store the modulus. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * When pLnModExpCb is non null, an asynchronous callback of type * CpaCyLnModExpCbFunc is generated in response to this function call. * Any errors generated during processing are reported in the structure * returned in the callback. * * @see * CpaCyLnModExpOpData, CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyLnModExp(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pLnModExpCb, void *pCallbackTag, const CpaCyLnModExpOpData *pLnModExpOpData, CpaFlatBuffer *pResult); /** ***************************************************************************** * @ingroup cpaCyLn * Perform modular inversion operation. * * @description * This function performs modular inversion. It computes the following * result based on the inputs: * * result = (1/A) mod B. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pLnModInvCb Pointer to callback function to be * invoked when the operation is complete. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the * callback. * @param[in] pLnModInvOpData Structure containing all the data * needed to perform the LN modular * inversion operation. The client code * allocates the memory for this structure. * This component takes ownership of the * memory until it is returned in the * callback. * @param[out] pResult Pointer to a flat buffer containing a * pointer to memory allocated by the client * into which the result will be written. * The size of the memory required MUST be * larger than or equal to the size * required to store the modulus. * On invocation the callback function * will contain this parameter in the * pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * When pLnModInvCb is non null, an asynchronous callback of type * CpaCyLnModInvCbFunc is generated in response to this function call. * Any errors generated during processing are reported in the structure * returned in the callback. * * @see * CpaCyLnModInvOpData, * CpaCyGenFlatBufCbFunc * *****************************************************************************/ CpaStatus cpaCyLnModInv(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pLnModInvCb, void *pCallbackTag, const CpaCyLnModInvOpData *pLnModInvOpData, CpaFlatBuffer *pResult); /** ***************************************************************************** * @ingroup cpaCyLn * Query statistics for large number operations * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyLnStatsQuery64(). * * @description * This function will query a specific instance handle for large number * statistics. The user MUST allocate the CpaCyLnStats structure and pass * the reference to that structure into this function call. This function * writes the statistic results into the passed in CpaCyLnStats structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pLnStats Pointer to memory into which the * statistics will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Acceleration Services unit has been initialized. * * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * * @see * CpaCyLnStats * *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyLnStatsQuery(const CpaInstanceHandle instanceHandle, struct _CpaCyLnStats *pLnStats); /** ***************************************************************************** * @ingroup cpaCyLn * Query statistics (64-bit version) for large number operations * * @description * This function will query a specific instance handle for the 64-bit * version of the large number statistics. * The user MUST allocate the CpaCyLnStats64 structure and pass * the reference to that structure into this function call. This function * writes the statistic results into the passed in CpaCyLnStats64 * structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pLnStats Pointer to memory into which the * statistics will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Acceleration Services unit has been initialized. * * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * * @see * CpaCyLnStats *****************************************************************************/ CpaStatus cpaCyLnStatsQuery64(const CpaInstanceHandle instanceHandle, CpaCyLnStats64 *pLnStats); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_LN_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_prime.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_prime.h index 7065304f69e8..11e4773a05d1 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_prime.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_prime.h @@ -1,450 +1,450 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_prime.h * * @defgroup cpaCyPrime Prime Number Test API * * @ingroup cpaCy * * @description * These functions specify the API for the prime number test operations. * * For prime number generation, this API SHOULD be used in conjunction * with the Deterministic Random Bit Generation API (@ref cpaCyDrbg). * * @note * Large numbers are represented on the QuickAssist API as described * in the Large Number API (@ref cpaCyLn). * * In addition, the bit length of large numbers passed to the API * MUST NOT exceed 576 bits for Elliptic Curve operations. *****************************************************************************/ #ifndef CPA_CY_PRIME_H #define CPA_CY_PRIME_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyPrime * Prime Test Operation Data. * @description * This structure contains the operation data for the cpaCyPrimeTest * function. The client MUST allocate the memory for this structure and the * items pointed to by this structure. When the structure is passed into * the function, ownership of the memory passes to the function. Ownership * of the memory returns to the client when this structure is returned in * the callback function. * * All values in this structure are required to be in Most Significant Byte * first order, e.g. primeCandidate.pData[0] = MSB. * * All numbers MUST be stored in big-endian order. * * @note * If the client modifies or frees the memory referenced in this * structure after it has been submitted to the cpaCyPrimeTest * function, and before it has been returned in the callback, undefined * behavior will result. * * @see * cpaCyPrimeTest() * *****************************************************************************/ typedef struct _CpaCyPrimeTestOpData { CpaFlatBuffer primeCandidate; /**< The prime number candidate to test */ CpaBoolean performGcdTest; /**< A value of CPA_TRUE means perform a GCD Primality Test */ CpaBoolean performFermatTest; /**< A value of CPA_TRUE means perform a Fermat Primality Test */ Cpa32U numMillerRabinRounds; /**< Number of Miller Rabin Primality Test rounds. Set to 0 to perform * zero Miller Rabin tests. The maximum number of rounds supported is 50. */ CpaFlatBuffer millerRabinRandomInput; /**< Flat buffer containing a pointer to an array of n random numbers * for Miller Rabin Primality Tests. The size of the buffer MUST be * * n * (MAX(64,x)) * * where: * * - n is the requested number of rounds. * - x is the minimum number of bytes required to represent the prime * candidate, i.e. x = ceiling((ceiling(log2(p)))/8). * * Each random number MUST be greater than 1 and less than the prime * candidate - 1, with leading zeroes as necessary. */ CpaBoolean performLucasTest; /**< An CPA_TRUE value means perform a Lucas Primality Test */ } CpaCyPrimeTestOpData; /** ***************************************************************************** * @ingroup cpaCyPrime * Prime Number Test Statistics. * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by @ref CpaCyPrimeStats64. * @description * This structure contains statistics on the prime number test operations. * Statistics are set to zero when the component is initialized, and are * collected per instance. * ****************************************************************************/ typedef struct _CpaCyPrimeStats { Cpa32U numPrimeTestRequests; /**< Total number of successful prime number test requests.*/ Cpa32U numPrimeTestRequestErrors; /**< Total number of prime number test requests that had an * error and could not be processed. */ Cpa32U numPrimeTestCompleted; /**< Total number of prime number test operations that completed * successfully. */ Cpa32U numPrimeTestCompletedErrors; /**< Total number of prime number test operations that could not be * completed successfully due to errors. */ Cpa32U numPrimeTestFailures; /**< Total number of prime number test operations that executed * successfully but the outcome of the test was that the number was not * prime. */ } CpaCyPrimeStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyPrime * Prime Number Test Statistics (64-bit version). * @description * This structure contains a 64-bit version of the statistics on the * prime number test operations. * Statistics are set to zero when the component is initialized, and are * collected per instance. ****************************************************************************/ typedef struct _CpaCyPrimeStats64 { Cpa64U numPrimeTestRequests; /**< Total number of successful prime number test requests.*/ Cpa64U numPrimeTestRequestErrors; /**< Total number of prime number test requests that had an * error and could not be processed. */ Cpa64U numPrimeTestCompleted; /**< Total number of prime number test operations that completed * successfully. */ Cpa64U numPrimeTestCompletedErrors; /**< Total number of prime number test operations that could not be * completed successfully due to errors. */ Cpa64U numPrimeTestFailures; /**< Total number of prime number test operations that executed * successfully but the outcome of the test was that the number was not * prime. */ } CpaCyPrimeStats64; /** ***************************************************************************** * @ingroup cpaCyPrime * Definition of callback function invoked for cpaCyPrimeTest * requests. * * @description * This is the prototype for the cpaCyPrimeTest callback function. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pOpData Opaque pointer to the Operation data pointer * supplied in request. * @param[in] testPassed A value of CPA_TRUE means the prime candidate * is probably prime. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCyPrimeTest() * *****************************************************************************/ typedef void (*CpaCyPrimeTestCbFunc)(void *pCallbackTag, CpaStatus status, void *pOpData, CpaBoolean testPassed); /** ***************************************************************************** * @ingroup cpaCyPrime * Prime Number Test Function. * * @description * This function will test probabilistically if a number is prime. Refer * to ANSI X9.80 2005 for details. The primality result will be returned * in the asynchronous callback. * * The following combination of GCD, Fermat, Miller-Rabin, and Lucas * testing is supported: * (up to 1x GCD) + (up to 1x Fermat) + (up to 50x Miller-Rabin rounds) + * (up to 1x Lucas) * For example: * (1x GCD) + (25x Miller-Rabin) + (1x Lucas); * (1x GCD) + (1x Fermat); * (50x Miller-rabin); * * Tests are always performed in order of increasing complexity, for * example GCD first, then Fermat, then Miller-Rabin, and finally Lucas. * * For all of the primality tests, the following prime number "sizes" * (length in bits) are supported: all sizes up to and including 512 * bits, as well as sizes 768, 1024, 1536, 2048, 3072 and 4096. * * Candidate prime numbers MUST match these sizes accordingly, with * leading zeroes present where necessary. * * When this prime number test is used in conjunction with combined * Miller-Rabin and Lucas tests, it may be used as a means of performing * a self test operation on the random data generator. * * A response status of ok (pass == CPA_TRUE) means all requested * primality tests passed, and the prime candidate is probably prime * (the exact probability depends on the primality tests requested). * A response status of not ok (pass == CPA_FALSE) means one of the * requested primality tests failed (the prime candidate has been found * to be composite). * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCb Callback function pointer. If this is set to * a NULL value the function will operate * synchronously. * @param[in] pCallbackTag User-supplied value to help identify request. * @param[in] pOpData Structure containing all the data needed to * perform the operation. The client code * allocates the memory for this structure. This * component takes ownership of the memory until * it is returned in the callback. * @param[out] pTestPassed A value of CPA_TRUE means the prime candidate * is probably prime. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pCb is non-NULL an asynchronous callback of type * CpaCyPrimeTestCbFunc is generated in response to this function call. * For optimal performance, data pointers SHOULD be 8-byte aligned. * * @see * CpaCyPrimeTestOpData, CpaCyPrimeTestCbFunc * *****************************************************************************/ CpaStatus cpaCyPrimeTest(const CpaInstanceHandle instanceHandle, const CpaCyPrimeTestCbFunc pCb, void *pCallbackTag, const CpaCyPrimeTestOpData *pOpData, CpaBoolean *pTestPassed); /****************************************************************************** * @ingroup cpaCyPrime * Query prime number statistics specific to an instance. * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyPrimeQueryStats64(). * * @description * This function will query a specific instance for prime number * statistics. The user MUST allocate the CpaCyPrimeStats structure * and pass the reference to that into this function call. This function * will write the statistic results into the passed in * CpaCyPrimeStats structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pPrimeStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyPrimeQueryStats(const CpaInstanceHandle instanceHandle, struct _CpaCyPrimeStats *pPrimeStats); /****************************************************************************** * @ingroup cpaCyPrime * Query prime number statistics specific to an instance. * * @description * This function will query a specific instance for the 64-bit * version of the prime number statistics. * The user MUST allocate the CpaCyPrimeStats64 structure * and pass the reference to that into this function call. This function * will write the statistic results into the passed in * CpaCyPrimeStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pPrimeStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. *****************************************************************************/ CpaStatus cpaCyPrimeQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyPrimeStats64 *pPrimeStats); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_PRIME_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_rsa.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_rsa.h index a72950ecd970..fb6c83725745 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_rsa.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_rsa.h @@ -1,919 +1,919 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_rsa.h * * @defgroup cpaCyRsa RSA API * * @ingroup cpaCy * * @description * These functions specify the API for Public Key Encryption * (Cryptography) RSA operations. The PKCS #1 V2.1 specification is * supported, however the support is limited to "two-prime" mode. RSA * multi-prime is not supported. * * @note * These functions implement RSA cryptographic primitives. RSA padding * schemes are not implemented. For padding schemes that require the mgf * function see @ref cpaCyKeyGen. * * @note * Large numbers are represented on the QuickAssist API as described * in the Large Number API (@ref cpaCyLn). *****************************************************************************/ #ifndef CPA_CY_RSA_H #define CPA_CY_RSA_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Version. * @description * This enumeration lists the version identifier for the PKCS #1 V2.1 * standard. * @note * Multi-prime (more than two primes) is not supported. * *****************************************************************************/ typedef enum _CpaCyRsaVersion { CPA_CY_RSA_VERSION_TWO_PRIME = 1 /**< The version supported is "two-prime". */ } CpaCyRsaVersion; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Public Key Structure. * @description * This structure contains the two components which comprise the RSA * public key as defined in the PKCS #1 V2.1 standard. * All values in this structure are required to be in Most Significant Byte * first order, e.g. modulusN.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyRsaPublicKey { CpaFlatBuffer modulusN; /**< The modulus (n). * For key generation operations, the client MUST allocate the memory * for this parameter; its value is generated. * For encrypt operations this parameter is an input. */ CpaFlatBuffer publicExponentE; /**< The public exponent (e). * For key generation operations, this field is unused. It is NOT * generated by the interface; it is the responsibility of the client * to set this to the same value as the corresponding parameter on * the CpaCyRsaKeyGenOpData structure before using the key for * encryption. * For encrypt operations this parameter is an input. */ } CpaCyRsaPublicKey; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Private Key Structure For Representation 1. * @description * This structure contains the first representation that can be used for * describing the RSA private key, represented by the tuple of the * modulus (n) and the private exponent (d). * All values in this structure are required to be in Most Significant Byte * first order, e.g. modulusN.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyRsaPrivateKeyRep1 { CpaFlatBuffer modulusN; /**< The modulus (n). For key generation operations the memory MUST * be allocated by the client and the value is generated. For other * operations this is an input. Permitted lengths are: * * - 512 bits (64 bytes), * - 1024 bits (128 bytes), * - 1536 bits (192 bytes), * - 2048 bits (256 bytes), * - 3072 bits (384 bytes), * - 4096 bits (512 bytes), or * - 8192 bits (1024 bytes). */ CpaFlatBuffer privateExponentD; /**< The private exponent (d). For key generation operations the * memory MUST be allocated by the client and the value is generated. For * other operations this is an input. * NOTE: It is important that the value D is big enough. It is STRONGLY * recommended that this value is at least half the length of the modulus * N to protect against the Wiener attack. */ } CpaCyRsaPrivateKeyRep1; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Private Key Structure For Representation 2. * @description * This structure contains the second representation that can be used for * describing the RSA private key. The quintuple of p, q, dP, dQ, and qInv * (explained below and in the spec) are required for the second * representation. The optional sequence of triplets are not included. * All values in this structure are required to be in Most Significant Byte * first order, e.g. prime1P.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyRsaPrivateKeyRep2 { CpaFlatBuffer prime1P; /**< The first large prime (p). * For key generation operations, this field is unused. */ CpaFlatBuffer prime2Q; /**< The second large prime (q). * For key generation operations, this field is unused. */ CpaFlatBuffer exponent1Dp; /**< The first factor CRT exponent (dP). d mod (p-1). */ CpaFlatBuffer exponent2Dq; /**< The second factor CRT exponent (dQ). d mod (q-1). */ CpaFlatBuffer coefficientQInv; /**< The (first) Chinese Remainder Theorem (CRT) coefficient (qInv). * (inverse of q) mod p. */ } CpaCyRsaPrivateKeyRep2; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA private key representation type. * @description * This enumeration lists which PKCS V2.1 representation of the private * key is being used. * *****************************************************************************/ typedef enum _CpaCyRsaPrivateKeyRepType { CPA_CY_RSA_PRIVATE_KEY_REP_TYPE_1= 1, /**< The first representation of the RSA private key. */ CPA_CY_RSA_PRIVATE_KEY_REP_TYPE_2 /**< The second representation of the RSA private key. */ } CpaCyRsaPrivateKeyRepType; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Private Key Structure. * @description * This structure contains the two representations that can be used for * describing the RSA private key. The privateKeyRepType will be used to * identify which representation is to be used. Typically, using the * second representation results in faster decryption operations. * *****************************************************************************/ typedef struct _CpaCyRsaPrivateKey { CpaCyRsaVersion version; /**< Indicates the version of the PKCS #1 specification that is * supported. * Note that this applies to both representations. */ CpaCyRsaPrivateKeyRepType privateKeyRepType; /**< This value is used to identify which of the private key * representation types in this structure is relevant. * When performing key generation operations for Type 2 representations, * memory must also be allocated for the type 1 representations, and values * for both will be returned. */ CpaCyRsaPrivateKeyRep1 privateKeyRep1; /**< This is the first representation of the RSA private key as * defined in the PKCS #1 V2.1 specification. For key generation operations * the memory for this structure is allocated by the client and the * specific values are generated. For other operations this is an input * parameter. */ CpaCyRsaPrivateKeyRep2 privateKeyRep2; /**< This is the second representation of the RSA private key as * defined in the PKCS #1 V2.1 specification. For key generation operations * the memory for this structure is allocated by the client and the * specific values are generated. For other operations this is an input * parameter. */ } CpaCyRsaPrivateKey; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Key Generation Data. * @description * This structure lists the different items that are required in the * cpaCyRsaGenKey function. The client MUST allocate the memory for this * structure. When the structure is passed into the function, ownership of * the memory passes to the function. Ownership of the memory returns to * the client when this structure is returned in the * CpaCyRsaKeyGenCbFunc callback function. * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyRsaGenKey function, and * before it has been returned in the callback, undefined behavior will * result. * All values in this structure are required to be in Most Significant Byte * first order, e.g. prime1P.pData[0] = MSB. * * The following limitations on the permutations of the supported bit * lengths of p, q and n (written as {p, q, n}) apply: * * - {256, 256, 512} or * - {512, 512, 1024} or * - {768, 768, 1536} or * - {1024, 1024, 2048} or * - {1536, 1536, 3072} or * - {2048, 2048, 4096}. * *****************************************************************************/ typedef struct _CpaCyRsaKeyGenOpData { CpaFlatBuffer prime1P; /**< A large random prime number (p). This MUST be created by the * client. Permitted bit lengths are: 256, 512, 768, 1024, 1536 or 2048. * Limitations apply - refer to the description above for details. */ CpaFlatBuffer prime2Q; /**< A large random prime number (q). This MUST be created by the * client. Permitted bit lengths are: 256, 512, 768, 1024, 1536 or 2048. * Limitations apply - refer to the description above for details. If the * private key representation type is 2, then this pointer will be assigned * to the relevant structure member of the representation 2 private key. */ Cpa32U modulusLenInBytes; /**< The bit length of the modulus (n). This is the modulus length for * both the private and public keys. The length of the modulus N parameter * for the private key representation 1 structure and the public key * structures will be assigned to this value. References to the strength of * RSA actually refer to this bit length. Recommended minimum is 1024 bits. * Permitted lengths are: * - 512 bits (64 bytes), * - 1024 bits (128 bytes), * - 1536 bits (192 bytes), * - 2048 bits (256 bytes), * - 3072 bits (384 bytes), or * - 4096 bits (512 bytes). * Limitations apply - refer to description above for details. */ CpaCyRsaVersion version; /**< Indicates the version of the PKCS #1 specification that is * supported. * Note that this applies to both representations. */ CpaCyRsaPrivateKeyRepType privateKeyRepType; /**< This value is used to identify which of the private key * representation types is required to be generated. */ CpaFlatBuffer publicExponentE; /**< The public exponent (e). */ } CpaCyRsaKeyGenOpData; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Encryption Primitive Operation Data * @description * This structure lists the different items that are required in the * cpaCyRsaEncrypt function. As the RSA encryption primitive and * verification primitive operations are mathematically identical this * structure may also be used to perform an RSA verification primitive * operation. * When performing an RSA encryption primitive operation, the input data * is the message and the output data is the cipher text. * When performing an RSA verification primitive operation, the input data * is the signature and the output data is the message. * The client MUST allocate the memory for this structure. When the * structure is passed into the function, ownership of the memory passes * to the function. Ownership of the memory returns to the client when * this structure is returned in the CpaCyRsaEncryptCbFunc * callback function. * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyRsaEncrypt function, and * before it has been returned in the callback, undefined behavior will * result. * All values in this structure are required to be in Most Significant Byte * first order, e.g. inputData.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyRsaEncryptOpData { CpaCyRsaPublicKey *pPublicKey; /**< Pointer to the public key. */ CpaFlatBuffer inputData; /**< The input data that the RSA encryption primitive operation is * performed on. The data pointed to is an integer that MUST be in big- * endian order. The value MUST be between 0 and the modulus n - 1. */ } CpaCyRsaEncryptOpData; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Decryption Primitive Operation Data * @description * This structure lists the different items that are required in the * cpaCyRsaDecrypt function. As the RSA decryption primitive and * signature primitive operations are mathematically identical this * structure may also be used to perform an RSA signature primitive * operation. * When performing an RSA decryption primitive operation, the input data * is the cipher text and the output data is the message text. * When performing an RSA signature primitive operation, the input data * is the message and the output data is the signature. * The client MUST allocate the memory for this structure. When the * structure is passed into the function, ownership of the memory passes * to he function. Ownership of the memory returns to the client when * this structure is returned in the CpaCyRsaDecryptCbFunc * callback function. * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCyRsaDecrypt function, and * before it has been returned in the callback, undefined behavior will * result. * All values in this structure are required to be in Most Significant Byte * first order, e.g. inputData.pData[0] = MSB. * *****************************************************************************/ typedef struct _CpaCyRsaDecryptOpData { CpaCyRsaPrivateKey *pRecipientPrivateKey; /**< Pointer to the recipient's RSA private key. */ CpaFlatBuffer inputData; /**< The input data that the RSA decryption primitive operation is * performed on. The data pointed to is an integer that MUST be in big- * endian order. The value MUST be between 0 and the modulus n - 1. */ } CpaCyRsaDecryptOpData; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Statistics. * @deprecated * As of v1.3 of the Crypto API, this structure has been deprecated, * replaced by @ref CpaCyRsaStats64. * @description * This structure contains statistics on the RSA operations. * Statistics are set to zero when the component is initialized, and are * collected per instance. ****************************************************************************/ typedef struct _CpaCyRsaStats { Cpa32U numRsaKeyGenRequests; /**< Total number of successful RSA key generation requests. */ Cpa32U numRsaKeyGenRequestErrors; /**< Total number of RSA key generation requests that had an error and * could not be processed. */ Cpa32U numRsaKeyGenCompleted; /**< Total number of RSA key generation operations that completed * successfully. */ Cpa32U numRsaKeyGenCompletedErrors; /**< Total number of RSA key generation operations that could not be * completed successfully due to errors. */ Cpa32U numRsaEncryptRequests; /**< Total number of successful RSA encrypt operation requests. */ Cpa32U numRsaEncryptRequestErrors; /**< Total number of RSA encrypt requests that had an error and could * not be processed. */ Cpa32U numRsaEncryptCompleted; /**< Total number of RSA encrypt operations that completed * successfully. */ Cpa32U numRsaEncryptCompletedErrors; /**< Total number of RSA encrypt operations that could not be * completed successfully due to errors. */ Cpa32U numRsaDecryptRequests; /**< Total number of successful RSA decrypt operation requests. */ Cpa32U numRsaDecryptRequestErrors; /**< Total number of RSA decrypt requests that had an error and could * not be processed. */ Cpa32U numRsaDecryptCompleted; /**< Total number of RSA decrypt operations that completed * successfully. */ Cpa32U numRsaDecryptCompletedErrors; /**< Total number of RSA decrypt operations that could not be * completed successfully due to errors. */ } CpaCyRsaStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCyRsa * RSA Statistics (64-bit version). * @description * This structure contains 64-bit version of the statistics on the RSA * operations. * Statistics are set to zero when the component is initialized, and are * collected per instance. ****************************************************************************/ typedef struct _CpaCyRsaStats64 { Cpa64U numRsaKeyGenRequests; /**< Total number of successful RSA key generation requests. */ Cpa64U numRsaKeyGenRequestErrors; /**< Total number of RSA key generation requests that had an error and * could not be processed. */ Cpa64U numRsaKeyGenCompleted; /**< Total number of RSA key generation operations that completed * successfully. */ Cpa64U numRsaKeyGenCompletedErrors; /**< Total number of RSA key generation operations that could not be * completed successfully due to errors. */ Cpa64U numRsaEncryptRequests; /**< Total number of successful RSA encrypt operation requests. */ Cpa64U numRsaEncryptRequestErrors; /**< Total number of RSA encrypt requests that had an error and could * not be processed. */ Cpa64U numRsaEncryptCompleted; /**< Total number of RSA encrypt operations that completed * successfully. */ Cpa64U numRsaEncryptCompletedErrors; /**< Total number of RSA encrypt operations that could not be * completed successfully due to errors. */ Cpa64U numRsaDecryptRequests; /**< Total number of successful RSA decrypt operation requests. */ Cpa64U numRsaDecryptRequestErrors; /**< Total number of RSA decrypt requests that had an error and could * not be processed. */ Cpa64U numRsaDecryptCompleted; /**< Total number of RSA decrypt operations that completed * successfully. */ Cpa64U numRsaDecryptCompletedErrors; /**< Total number of RSA decrypt operations that could not be * completed successfully due to errors. */ Cpa64U numKptRsaDecryptRequests; /**< Total number of successful KPT RSA decrypt operation requests. */ Cpa64U numKptRsaDecryptRequestErrors; /**< Total number of KPT RSA decrypt requests that had an error and could * not be processed. */ Cpa64U numKptRsaDecryptCompleted; /**< Total number of KPT RSA decrypt operations that completed * successfully. */ Cpa64U numKptRsaDecryptCompletedErrors; /**< Total number of KPT RSA decrypt operations that could not be * completed successfully due to errors. */ } CpaCyRsaStats64; /** ***************************************************************************** * @ingroup cpaCyRsa * Definition of the RSA key generation callback function. * * @description * This is the prototype for the RSA key generation callback function. The * callback function pointer is passed in as a parameter to the * cpaCyRsaGenKey function. It will be invoked once the request has * completed. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag Opaque value provided by user while making * individual function calls. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] pKeyGenOpData Structure with output params for callback. * @param[in] pPrivateKey Structure which contains pointers to the memory * into which the generated private key will be * written. * @param[in] pPublicKey Structure which contains pointers to the memory * into which the generated public key will be * written. The pointer to the public exponent (e) * that is returned in this structure is equal to * the input public exponent. * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * CpaCyRsaPrivateKey, * CpaCyRsaPublicKey, * cpaCyRsaGenKey() * *****************************************************************************/ typedef void (*CpaCyRsaKeyGenCbFunc)(void *pCallbackTag, CpaStatus status, void *pKeyGenOpData, CpaCyRsaPrivateKey *pPrivateKey, CpaCyRsaPublicKey *pPublicKey); /** ***************************************************************************** * @ingroup cpaCyRsa * Generate RSA keys. * * @description * This function will generate private and public keys for RSA as specified * in the PKCS #1 V2.1 standard. Both representation types of the private * key may be generated. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pRsaKeyGenCb Pointer to the callback function to be invoked * when the operation is complete. If this is * set to a NULL value the function will operate * synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. Will * be returned unchanged in the callback. * @param[in] pKeyGenOpData Structure containing all the data needed to * perform the RSA key generation operation. The * client code allocates the memory for this * structure. This component takes ownership of * the memory until it is returned in the * callback. * @param[out] pPrivateKey Structure which contains pointers to the memory * into which the generated private key will be * written. The client MUST allocate memory * for this structure, and for the pointers * within it, recursively; on return, these will * be populated. * @param[out] pPublicKey Structure which contains pointers to the memory * into which the generated public key will be * written. The memory for this structure and * for the modulusN parameter MUST be allocated * by the client, and will be populated on return * from the call. The field publicExponentE * is not modified or touched in any way; it is * the responsibility of the client to set this * to the same value as the corresponding * parameter on the CpaCyRsaKeyGenOpData * structure before using the key for encryption. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pRsaKeyGenCb is non-NULL, an asynchronous callback of type is * generated in response to this function call. * Any errors generated during processing are reported as part of the * callback status code. For optimal performance, data pointers SHOULD be * 8-byte aligned. * @see * CpaCyRsaKeyGenOpData, * CpaCyRsaKeyGenCbFunc, * cpaCyRsaEncrypt(), * cpaCyRsaDecrypt() * *****************************************************************************/ CpaStatus cpaCyRsaGenKey(const CpaInstanceHandle instanceHandle, const CpaCyRsaKeyGenCbFunc pRsaKeyGenCb, void *pCallbackTag, const CpaCyRsaKeyGenOpData *pKeyGenOpData, CpaCyRsaPrivateKey *pPrivateKey, CpaCyRsaPublicKey *pPublicKey); /** ***************************************************************************** * @ingroup cpaCyRsa * Perform the RSA encrypt (or verify) primitive operation on the input * data. * * @description * This function will perform an RSA encryption primitive operation on the * input data using the specified RSA public key. As the RSA encryption * primitive and verification primitive operations are mathematically * identical this function may also be used to perform an RSA verification * primitive operation. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pRsaEncryptCb Pointer to callback function to be invoked * when the operation is complete. If this is * set to a NULL value the function will operate * synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. Will * be returned unchanged in the callback. * @param[in] pEncryptOpData Structure containing all the data needed to * perform the RSA encryption operation. The * client code allocates the memory for this * structure. This component takes ownership of * the memory until it is returned in the * callback. * @param[out] pOutputData Pointer to structure into which the result of * the RSA encryption primitive is written. The * client MUST allocate this memory. The data * pointed to is an integer in big-endian order. * The value will be between 0 and the modulus * n - 1. * On invocation the callback function will * contain this parameter in the pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pRsaEncryptCb is non-NULL an asynchronous callback of type is * generated in response to this function call. * Any errors generated during processing are reported as part of the * callback status code. For optimal performance, data pointers SHOULD be * 8-byte aligned. * @see * CpaCyGenFlatBufCbFunc * CpaCyRsaEncryptOpData * cpaCyRsaGenKey() * cpaCyRsaDecrypt() * *****************************************************************************/ CpaStatus cpaCyRsaEncrypt(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pRsaEncryptCb, void *pCallbackTag, const CpaCyRsaEncryptOpData *pEncryptOpData, CpaFlatBuffer *pOutputData); /** ***************************************************************************** * @ingroup cpaCyRsa * Perform the RSA decrypt (or sign) primitive operation on the input * data. * * @description * This function will perform an RSA decryption primitive operation on the * input data using the specified RSA private key. As the RSA decryption * primitive and signing primitive operations are mathematically identical * this function may also be used to perform an RSA signing primitive * operation. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pRsaDecryptCb Pointer to callback function to be invoked * when the operation is complete. If this is * set to a NULL value the function will operate * synchronously. * @param[in] pCallbackTag Opaque User Data for this specific call. * Will be returned unchanged in the callback. * @param[in] pDecryptOpData Structure containing all the data needed to * perform the RSA decrypt operation. The * client code allocates the memory for this * structure. This component takes ownership * of the memory until it is returned in the * callback. * @param[out] pOutputData Pointer to structure into which the result of * the RSA decryption primitive is written. The * client MUST allocate this memory. The data * pointed to is an integer in big-endian order. * The value will be between 0 and the modulus * n - 1. * On invocation the callback function will * contain this parameter in the pOut parameter. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * When pRsaDecryptCb is non-NULL an asynchronous callback is generated in * response to this function call. * Any errors generated during processing are reported as part of the * callback status code. For optimal performance, data pointers SHOULD be * 8-byte aligned. * @see * CpaCyRsaDecryptOpData, * CpaCyGenFlatBufCbFunc, * cpaCyRsaGenKey(), * cpaCyRsaEncrypt() * *****************************************************************************/ CpaStatus cpaCyRsaDecrypt(const CpaInstanceHandle instanceHandle, const CpaCyGenFlatBufCbFunc pRsaDecryptCb, void *pCallbackTag, const CpaCyRsaDecryptOpData *pDecryptOpData, CpaFlatBuffer * pOutputData); /** ***************************************************************************** * @ingroup cpaCyRsa * Query statistics for a specific RSA instance. * * @deprecated * As of v1.3 of the Crypto API, this function has been deprecated, * replaced by @ref cpaCyRsaQueryStats64(). * * @description * This function will query a specific instance for RSA statistics. The * user MUST allocate the CpaCyRsaStats structure and pass the * reference to that into this function call. This function will write the * statistic results into the passed in CpaCyRsaStats structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pRsaStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyRsaStats * *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCyRsaQueryStats(const CpaInstanceHandle instanceHandle, struct _CpaCyRsaStats *pRsaStats); /** ***************************************************************************** * @ingroup cpaCyRsa * Query statistics (64-bit version) for a specific RSA instance. * * @description * This function will query a specific instance for RSA statistics. The * user MUST allocate the CpaCyRsaStats64 structure and pass the * reference to that into this function call. This function will write the * statistic results into the passed in CpaCyRsaStats64 structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pRsaStats Pointer to memory into which the statistics * will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner and no asynchronous * callback will be generated. * @see * CpaCyRsaStats64 *****************************************************************************/ CpaStatus cpaCyRsaQueryStats64(const CpaInstanceHandle instanceHandle, CpaCyRsaStats64 *pRsaStats); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_RSA_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_sym.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_sym.h index 370b7e2397c4..adc1671c7f57 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_sym.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_sym.h @@ -1,1847 +1,1851 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_sym.h * * @defgroup cpaCySym Symmetric Cipher and Hash Cryptographic API * * @ingroup cpaCy * * @description * These functions specify the Cryptographic API for symmetric cipher, * hash, and combined cipher and hash operations. * *****************************************************************************/ #ifndef CPA_CY_SYM_H #define CPA_CY_SYM_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" /** ***************************************************************************** * @ingroup cpaCySym * Cryptographic component symmetric session context handle. * @description * Handle to a cryptographic session context. The memory for this handle * is allocated by the client. The size of the memory that the client needs * to allocate is determined by a call to the @ref * cpaCySymSessionCtxGetSize or @ref cpaCySymSessionCtxGetDynamicSize - * functions. The session context memory is initialized with a call to + * functions. The session context memory is initialized with a call to * the @ref cpaCySymInitSession function. * This memory MUST not be freed until a call to @ref * cpaCySymRemoveSession has completed successfully. * *****************************************************************************/ typedef void * CpaCySymSessionCtx; /** ***************************************************************************** * @ingroup cpaCySym * Packet type for the cpaCySymPerformOp function * * @description * Enumeration which is used to indicate to the symmetric cryptographic * perform function on which type of packet the operation is required to * be invoked. Multi-part cipher and hash operations are useful when * processing needs to be performed on a message which is available to * the client in multiple parts (for example due to network fragmentation * of the packet). * * @note * There are some restrictions regarding the operations on which * partial packet processing is supported. For details, see the * function @ref cpaCySymPerformOp. * * @see * cpaCySymPerformOp() * *****************************************************************************/ typedef enum _CpaCySymPacketType { CPA_CY_SYM_PACKET_TYPE_FULL = 1, /**< Perform an operation on a full packet*/ CPA_CY_SYM_PACKET_TYPE_PARTIAL, /**< Perform a partial operation and maintain the state of the partial * operation within the session. This is used for either the first or * subsequent packets within a partial packet flow. */ CPA_CY_SYM_PACKET_TYPE_LAST_PARTIAL /**< Complete the last part of a multi-part operation */ } CpaCySymPacketType; /** ***************************************************************************** * @ingroup cpaCySym * Types of operations supported by the cpaCySymPerformOp function. * @description * This enumeration lists different types of operations supported by the * cpaCySymPerformOp function. The operation type is defined during * session registration and cannot be changed for a session once it has * been setup. * @see * cpaCySymPerformOp *****************************************************************************/ typedef enum _CpaCySymOp { CPA_CY_SYM_OP_NONE=0, /**< No operation */ CPA_CY_SYM_OP_CIPHER, /**< Cipher only operation on the data */ CPA_CY_SYM_OP_HASH, /**< Hash only operation on the data */ CPA_CY_SYM_OP_ALGORITHM_CHAINING /**< Chain any cipher with any hash operation. The order depends on * the value in the CpaCySymAlgChainOrder enum. * * This value is also used for authenticated ciphers (GCM and CCM), in * which case the cipherAlgorithm should take one of the values @ref * CPA_CY_SYM_CIPHER_AES_CCM or @ref CPA_CY_SYM_CIPHER_AES_GCM, while the * hashAlgorithm should take the corresponding value @ref * CPA_CY_SYM_HASH_AES_CCM or @ref CPA_CY_SYM_HASH_AES_GCM. */ } CpaCySymOp; /** ***************************************************************************** * @ingroup cpaCySym * Cipher algorithms. * @description * This enumeration lists supported cipher algorithms and modes. * *****************************************************************************/ typedef enum _CpaCySymCipherAlgorithm { CPA_CY_SYM_CIPHER_NULL = 1, /**< NULL cipher algorithm. No mode applies to the NULL algorithm. */ CPA_CY_SYM_CIPHER_ARC4, /**< (A)RC4 cipher algorithm */ CPA_CY_SYM_CIPHER_AES_ECB, /**< AES algorithm in ECB mode */ CPA_CY_SYM_CIPHER_AES_CBC, /**< AES algorithm in CBC mode */ CPA_CY_SYM_CIPHER_AES_CTR, /**< AES algorithm in Counter mode */ CPA_CY_SYM_CIPHER_AES_CCM, /**< AES algorithm in CCM mode. This authenticated cipher is only supported * when the hash mode is also set to CPA_CY_SYM_HASH_MODE_AUTH. When this * cipher algorithm is used the CPA_CY_SYM_HASH_AES_CCM element of the * CpaCySymHashAlgorithm enum MUST be used to set up the related * CpaCySymHashSetupData structure in the session context. */ CPA_CY_SYM_CIPHER_AES_GCM, /**< AES algorithm in GCM mode. This authenticated cipher is only supported * when the hash mode is also set to CPA_CY_SYM_HASH_MODE_AUTH. When this * cipher algorithm is used the CPA_CY_SYM_HASH_AES_GCM element of the * CpaCySymHashAlgorithm enum MUST be used to set up the related * CpaCySymHashSetupData structure in the session context. */ CPA_CY_SYM_CIPHER_DES_ECB, /**< DES algorithm in ECB mode */ CPA_CY_SYM_CIPHER_DES_CBC, /**< DES algorithm in CBC mode */ CPA_CY_SYM_CIPHER_3DES_ECB, /**< Triple DES algorithm in ECB mode */ CPA_CY_SYM_CIPHER_3DES_CBC, /**< Triple DES algorithm in CBC mode */ CPA_CY_SYM_CIPHER_3DES_CTR, /**< Triple DES algorithm in CTR mode */ CPA_CY_SYM_CIPHER_KASUMI_F8, /**< Kasumi algorithm in F8 mode */ CPA_CY_SYM_CIPHER_SNOW3G_UEA2, /**< SNOW3G algorithm in UEA2 mode */ CPA_CY_SYM_CIPHER_AES_F8, /**< AES algorithm in F8 mode */ CPA_CY_SYM_CIPHER_AES_XTS, /**< AES algorithm in XTS mode */ CPA_CY_SYM_CIPHER_ZUC_EEA3, /**< ZUC algorithm in EEA3 mode */ CPA_CY_SYM_CIPHER_CHACHA, /**< ChaCha20 Cipher Algorithm. This cipher is only supported for * algorithm chaining. When selected, the hash algorithm must be set to * CPA_CY_SYM_HASH_POLY and the hash mode must be set to * CPA_CY_SYM_HASH_MODE_AUTH. */ CPA_CY_SYM_CIPHER_SM4_ECB, /**< SM4 algorithm in ECB mode This cipher supports 128 bit keys only and * does not support partial processing. */ CPA_CY_SYM_CIPHER_SM4_CBC, /**< SM4 algorithm in CBC mode This cipher supports 128 bit keys only and * does not support partial processing. */ CPA_CY_SYM_CIPHER_SM4_CTR /**< SM4 algorithm in CTR mode This cipher supports 128 bit keys only and * does not support partial processing. */ } CpaCySymCipherAlgorithm; /** * @ingroup cpaCySym * Size of bitmap needed for cipher "capabilities" type. * * @description * Defines the number of bits in the bitmap to represent supported * ciphers in the type @ref CpaCySymCapabilitiesInfo. Should be set to * at least one greater than the largest value in the enumerated type * @ref CpaCySymHashAlgorithm, so that the value of the enum constant * can also be used as the bit position in the bitmap. * * A larger value was chosen to allow for extensibility without the need * to change the size of the bitmap (to ease backwards compatibility in * future versions of the API). */ #define CPA_CY_SYM_CIPHER_CAP_BITMAP_SIZE (32) /** ***************************************************************************** * @ingroup cpaCySym * Symmetric Cipher Direction * @description * This enum indicates the cipher direction (encryption or decryption). * *****************************************************************************/ typedef enum _CpaCySymCipherDirection { CPA_CY_SYM_CIPHER_DIRECTION_ENCRYPT = 1, /**< Encrypt Data */ CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT /**< Decrypt Data */ } CpaCySymCipherDirection; /** ***************************************************************************** * @ingroup cpaCySym * Symmetric Cipher Setup Data. * @description * This structure contains data relating to Cipher (Encryption and - * Decryption) to set up a session. + * Decryption) to setup a session. * *****************************************************************************/ typedef struct _CpaCySymCipherSetupData { CpaCySymCipherAlgorithm cipherAlgorithm; /**< Cipher algorithm and mode */ Cpa32U cipherKeyLenInBytes; /**< Cipher key length in bytes. For AES it can be 128 bits (16 bytes), * 192 bits (24 bytes) or 256 bits (32 bytes). * For the CCM mode of operation, the only supported key length is 128 bits * (16 bytes). * For the CPA_CY_SYM_CIPHER_AES_F8 mode of operation, cipherKeyLenInBytes * should be set to the combined length of the encryption key and the * keymask. Since the keymask and the encryption key are the same size, * cipherKeyLenInBytes should be set to 2 x the AES encryption key length. * For the AES-XTS mode of operation: * - Two keys must be provided and cipherKeyLenInBytes refers to total * length of the two keys. * - Each key can be either 128 bits (16 bytes) or 256 bits (32 bytes). - * - Both keys must have the same size. */ + * - Both keys must have the same size. + */ Cpa8U *pCipherKey; /**< Cipher key * For the CPA_CY_SYM_CIPHER_AES_F8 mode of operation, pCipherKey will * point to a concatenation of the AES encryption key followed by a * keymask. As per RFC3711, the keymask should be padded with trailing * bytes to match the length of the encryption key used. * For AES-XTS mode of operation, two keys must be provided and pCipherKey * must point to the two keys concatenated together (Key1 || Key2). - * cipherKeyLenInBytes will contain the total size of both keys. */ + * cipherKeyLenInBytes will contain the total size of both keys. + * These fields are set to NULL if key derivation will be used. + */ CpaCySymCipherDirection cipherDirection; /**< This parameter determines if the cipher operation is an encrypt or * a decrypt operation. * For the RC4 algorithm and the F8/CTR modes, only encrypt operations * are valid. */ } CpaCySymCipherSetupData; /** ***************************************************************************** * @ingroup cpaCySym * Symmetric Hash mode * @description * This enum indicates the Hash Mode. * *****************************************************************************/ typedef enum _CpaCySymHashMode { CPA_CY_SYM_HASH_MODE_PLAIN = 1, /**< Plain hash. Can be specified for MD5 and the SHA family of * hash algorithms. */ CPA_CY_SYM_HASH_MODE_AUTH, /**< Authenticated hash. This mode may be used in conjunction with the * MD5 and SHA family of algorithms to specify HMAC. It MUST also be * specified with all of the remaining algorithms, all of which are in * fact authentication algorithms. */ CPA_CY_SYM_HASH_MODE_NESTED /**< Nested hash. Can be specified for MD5 and the SHA family of * hash algorithms. */ } CpaCySymHashMode; /** ***************************************************************************** * @ingroup cpaCySym * Hash algorithms. * @description * This enumeration lists supported hash algorithms. * *****************************************************************************/ typedef enum _CpaCySymHashAlgorithm { CPA_CY_SYM_HASH_NONE = 0, /**< No hash algorithm. */ CPA_CY_SYM_HASH_MD5, /**< MD5 algorithm. Supported in all 3 hash modes */ CPA_CY_SYM_HASH_SHA1, /**< 128 bit SHA algorithm. Supported in all 3 hash modes */ CPA_CY_SYM_HASH_SHA224, /**< 224 bit SHA algorithm. Supported in all 3 hash modes */ CPA_CY_SYM_HASH_SHA256, /**< 256 bit SHA algorithm. Supported in all 3 hash modes */ CPA_CY_SYM_HASH_SHA384, /**< 384 bit SHA algorithm. Supported in all 3 hash modes */ CPA_CY_SYM_HASH_SHA512, /**< 512 bit SHA algorithm. Supported in all 3 hash modes */ CPA_CY_SYM_HASH_AES_XCBC, /**< AES XCBC algorithm. This is only supported in the hash mode * CPA_CY_SYM_HASH_MODE_AUTH. */ CPA_CY_SYM_HASH_AES_CCM, /**< AES algorithm in CCM mode. This authenticated cipher requires that the * hash mode is set to CPA_CY_SYM_HASH_MODE_AUTH. When this hash algorithm * is used, the CPA_CY_SYM_CIPHER_AES_CCM element of the * CpaCySymCipherAlgorithm enum MUST be used to set up the related * CpaCySymCipherSetupData structure in the session context. */ CPA_CY_SYM_HASH_AES_GCM, /**< AES algorithm in GCM mode. This authenticated cipher requires that the * hash mode is set to CPA_CY_SYM_HASH_MODE_AUTH. When this hash algorithm * is used, the CPA_CY_SYM_CIPHER_AES_GCM element of the * CpaCySymCipherAlgorithm enum MUST be used to set up the related * CpaCySymCipherSetupData structure in the session context. */ CPA_CY_SYM_HASH_KASUMI_F9, /**< Kasumi algorithm in F9 mode. This is only supported in the hash * mode CPA_CY_SYM_HASH_MODE_AUTH. */ CPA_CY_SYM_HASH_SNOW3G_UIA2, /**< SNOW3G algorithm in UIA2 mode. This is only supported in the hash * mode CPA_CY_SYM_HASH_MODE_AUTH. */ CPA_CY_SYM_HASH_AES_CMAC, /**< AES CMAC algorithm. This is only supported in the hash mode * CPA_CY_SYM_HASH_MODE_AUTH. */ CPA_CY_SYM_HASH_AES_GMAC, /**< AES GMAC algorithm. This is only supported in the hash mode * CPA_CY_SYM_HASH_MODE_AUTH. When this hash algorithm * is used, the CPA_CY_SYM_CIPHER_AES_GCM element of the * CpaCySymCipherAlgorithm enum MUST be used to set up the related * CpaCySymCipherSetupData structure in the session context. */ CPA_CY_SYM_HASH_AES_CBC_MAC, /**< AES-CBC-MAC algorithm. This is only supported in the hash mode * CPA_CY_SYM_HASH_MODE_AUTH. Only 128-bit keys are supported. */ CPA_CY_SYM_HASH_ZUC_EIA3, /**< ZUC algorithm in EIA3 mode */ CPA_CY_SYM_HASH_SHA3_256, /**< 256 bit SHA-3 algorithm. Only CPA_CY_SYM_HASH_MODE_PLAIN and * CPA_CY_SYM_HASH_MODE_AUTH are supported, that is, the hash * mode CPA_CY_SYM_HASH_MODE_NESTED is not supported for this algorithm. * Partial requests are not supported, that is, only requests * of CPA_CY_SYM_PACKET_TYPE_FULL are supported. */ CPA_CY_SYM_HASH_SHA3_224, /**< 224 bit SHA-3 algorithm. Only CPA_CY_SYM_HASH_MODE_PLAIN and * CPA_CY_SYM_HASH_MODE_AUTH are supported, that is, the hash * mode CPA_CY_SYM_HASH_MODE_NESTED is not supported for this algorithm. */ CPA_CY_SYM_HASH_SHA3_384, /**< 384 bit SHA-3 algorithm. Only CPA_CY_SYM_HASH_MODE_PLAIN and * CPA_CY_SYM_HASH_MODE_AUTH are supported, that is, the hash * mode CPA_CY_SYM_HASH_MODE_NESTED is not supported for this algorithm. * Partial requests are not supported, that is, only requests * of CPA_CY_SYM_PACKET_TYPE_FULL are supported. */ CPA_CY_SYM_HASH_SHA3_512, /**< 512 bit SHA-3 algorithm. Only CPA_CY_SYM_HASH_MODE_PLAIN and * CPA_CY_SYM_HASH_MODE_AUTH are supported, that is, the hash * mode CPA_CY_SYM_HASH_MODE_NESTED is not supported for this algorithm. * Partial requests are not supported, that is, only requests * of CPA_CY_SYM_PACKET_TYPE_FULL are supported. */ CPA_CY_SYM_HASH_SHAKE_128, /**< 128 bit SHAKE algorithm. This is only supported in the hash * mode CPA_CY_SYM_HASH_MODE_PLAIN. Partial requests are not * supported, that is, only requests of CPA_CY_SYM_PACKET_TYPE_FULL * are supported. */ CPA_CY_SYM_HASH_SHAKE_256, /**< 256 bit SHAKE algorithm. This is only supported in the hash * mode CPA_CY_SYM_HASH_MODE_PLAIN. Partial requests are not * supported, that is, only requests of CPA_CY_SYM_PACKET_TYPE_FULL * are supported. */ CPA_CY_SYM_HASH_POLY, /**< Poly1305 hash algorithm. This is only supported in the hash mode * CPA_CY_SYM_HASH_MODE_AUTH. This hash algorithm is only supported * as part of an algorithm chain with AES_CY_SYM_CIPHER_CHACHA to * implement the ChaCha20-Poly1305 AEAD algorithm. */ CPA_CY_SYM_HASH_SM3 /**< SM3 hash algorithm. Supported in all 3 hash modes. */ } CpaCySymHashAlgorithm; /** * @ingroup cpaCySym * Size of bitmap needed for hash "capabilities" type. * * @description * Defines the number of bits in the bitmap to represent supported * hashes in the type @ref CpaCySymCapabilitiesInfo. Should be set to * at least one greater than the largest value in the enumerated type * @ref CpaCySymHashAlgorithm, so that the value of the enum constant * can also be used as the bit position in the bitmap. * * A larger value was chosen to allow for extensibility without the need * to change the size of the bitmap (to ease backwards compatibility in * future versions of the API). */ #define CPA_CY_SYM_HASH_CAP_BITMAP_SIZE (32) /** ***************************************************************************** * @ingroup cpaCySym * Hash Mode Nested Setup Data. * @description * This structure contains data relating to a hash session in * CPA_CY_SYM_HASH_MODE_NESTED mode. * *****************************************************************************/ typedef struct _CpaCySymHashNestedModeSetupData { Cpa8U *pInnerPrefixData; /**< A pointer to a buffer holding the Inner Prefix data. For optimal * performance the prefix data SHOULD be 8-byte aligned. This data is * prepended to the data being hashed before the inner hash operation is * performed. */ Cpa32U innerPrefixLenInBytes; /**< The inner prefix length in bytes. The maximum size the prefix data * can be is 255 bytes. */ CpaCySymHashAlgorithm outerHashAlgorithm; /**< The hash algorithm used for the outer hash. Note: The inner hash * algorithm is provided in the hash context. */ Cpa8U *pOuterPrefixData; /**< A pointer to a buffer holding the Outer Prefix data. For optimal * performance the prefix data SHOULD be 8-byte aligned. This data is * prepended to the output from the inner hash operation before the outer * hash operation is performed.*/ Cpa32U outerPrefixLenInBytes; /**< The outer prefix length in bytes. The maximum size the prefix data * can be is 255 bytes. */ } CpaCySymHashNestedModeSetupData; /** ***************************************************************************** * @ingroup cpaCySym * Hash Auth Mode Setup Data. * @description * This structure contains data relating to a hash session in * CPA_CY_SYM_HASH_MODE_AUTH mode. * *****************************************************************************/ typedef struct _CpaCySymHashAuthModeSetupData { Cpa8U *authKey; /**< Authentication key pointer. * For the GCM (@ref CPA_CY_SYM_HASH_AES_GCM) and CCM (@ref * CPA_CY_SYM_HASH_AES_CCM) modes of operation, this field is ignored; * the authentication key is the same as the cipher key (see * the field pCipherKey in struct @ref CpaCySymCipherSetupData). */ Cpa32U authKeyLenInBytes; /**< Length of the authentication key in bytes. The key length MUST be * less than or equal to the block size of the algorithm. It is the client's * responsibility to ensure that the key length is compliant with the * standard being used (for example RFC 2104, FIPS 198a). * * For the GCM (@ref CPA_CY_SYM_HASH_AES_GCM) and CCM (@ref * CPA_CY_SYM_HASH_AES_CCM) modes of operation, this field is ignored; * the authentication key is the same as the cipher key, and so is its * length (see the field cipherKeyLenInBytes in struct @ref * CpaCySymCipherSetupData). */ Cpa32U aadLenInBytes; /**< The length of the additional authenticated data (AAD) in bytes. * The maximum permitted value is 240 bytes, unless otherwise * specified below. * * This field must be specified when the hash algorithm is one of the * following: * - For SNOW3G (@ref CPA_CY_SYM_HASH_SNOW3G_UIA2), this is the * length of the IV (which should be 16). * - For GCM (@ref CPA_CY_SYM_HASH_AES_GCM). In this case, this is the * length of the Additional Authenticated Data (called A, in NIST * SP800-38D). * - For CCM (@ref CPA_CY_SYM_HASH_AES_CCM). In this case, this is the * length of the associated data (called A, in NIST SP800-38C). * Note that this does NOT include the length of any padding, or the * 18 bytes reserved at the start of the above field to store the * block B0 and the encoded length. The maximum permitted value in * this case is 222 bytes. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of operation * this field is not used and should be set to 0. Instead the length * of the AAD data is specified in the messageLenToHashInBytes field of * the CpaCySymOpData structure. */ } CpaCySymHashAuthModeSetupData; /** ***************************************************************************** * @ingroup cpaCySym * Hash Setup Data. * @description * This structure contains data relating to a hash session. The fields * hashAlgorithm, hashMode and digestResultLenInBytes are common to all * three hash modes and MUST be set for each mode. * *****************************************************************************/ typedef struct _CpaCySymHashSetupData { CpaCySymHashAlgorithm hashAlgorithm; /**< Hash algorithm. For mode CPA_CY_SYM_MODE_HASH_NESTED, this is the * inner hash algorithm. */ CpaCySymHashMode hashMode; /**< Mode of the hash operation. Valid options include plain, auth or * nested hash mode. */ Cpa32U digestResultLenInBytes; /**< Length of the digest to be returned. If the verify option is set, * this specifies the length of the digest to be compared for the * session. * * For CCM (@ref CPA_CY_SYM_HASH_AES_CCM), this is the octet length * of the MAC, which can be one of 4, 6, 8, 10, 12, 14 or 16. * * For GCM (@ref CPA_CY_SYM_HASH_AES_GCM), this is the length in bytes * of the authentication tag. * * If the value is less than the maximum length allowed by the hash, * the result shall be truncated. If the value is greater than the * maximum length allowed by the hash, an error (@ref * CPA_STATUS_INVALID_PARAM) is returned from the function @ref * cpaCySymInitSession. * * In the case of nested hash, it is the outer hash which determines * the maximum length allowed. */ CpaCySymHashAuthModeSetupData authModeSetupData; /**< Authentication Mode Setup Data. * Only valid for mode CPA_CY_SYM_MODE_HASH_AUTH */ CpaCySymHashNestedModeSetupData nestedModeSetupData; /**< Nested Hash Mode Setup Data * Only valid for mode CPA_CY_SYM_MODE_HASH_NESTED */ } CpaCySymHashSetupData; /** ***************************************************************************** * @ingroup cpaCySym * Algorithm Chaining Operation Ordering * @description * This enum defines the ordering of operations for algorithm chaining. * ****************************************************************************/ typedef enum _CpaCySymAlgChainOrder { CPA_CY_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER = 1, /**< Perform the hash operation followed by the cipher operation. If it is * required that the result of the hash (i.e. the digest) is going to be * included in the data to be ciphered, then: * *
    *
  • The digest MUST be placed in the destination buffer at the * location corresponding to the end of the data region to be hashed * (hashStartSrcOffsetInBytes + messageLenToHashInBytes), * i.e. there must be no gaps between the start of the digest and the * end of the data region to be hashed.
  • *
  • The messageLenToCipherInBytes member of the CpaCySymOpData * structure must be equal to the overall length of the plain text, * the digest length and any (optional) trailing data that is to be * included.
  • *
  • The messageLenToCipherInBytes must be a multiple to the block * size if a block cipher is being used.
  • *
* * The following is an example of the layout of the buffer before the * operation, after the hash, and after the cipher: @verbatim +-------------------------+---------------+ | Plaintext | Tail | +-------------------------+---------------+ <-messageLenToHashInBytes-> +-------------------------+--------+------+ | Plaintext | Digest | Tail | +-------------------------+--------+------+ <--------messageLenToCipherInBytes--------> +-----------------------------------------+ | Cipher Text | +-----------------------------------------+ @endverbatim */ CPA_CY_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH /**< Perform the cipher operation followed by the hash operation. * The hash operation will be performed on the ciphertext resulting from * the cipher operation. * * The following is an example of the layout of the buffer before the * operation, after the cipher, and after the hash: @verbatim +--------+---------------------------+---------------+ | Head | Plaintext | Tail | +--------+---------------------------+---------------+ <-messageLenToCipherInBytes-> +--------+---------------------------+---------------+ | Head | Ciphertext | Tail | +--------+---------------------------+---------------+ <------messageLenToHashInBytes-------> +--------+---------------------------+--------+------+ | Head | Ciphertext | Digest | Tail | +--------+---------------------------+--------+------+ @endverbatim * */ } CpaCySymAlgChainOrder; /** ***************************************************************************** * @ingroup cpaCySym * Session Setup Data. * @description * This structure contains data relating to setting up a session. The * client needs to complete the information in this structure in order to * setup a session. * ****************************************************************************/ -typedef struct _CpaCySymSessionSetupData { +typedef struct _CpaCySymSessionSetupData { CpaCyPriority sessionPriority; /**< Priority of this session */ CpaCySymOp symOperation; - /**< Operation to perfom */ + /**< Operation to perform */ CpaCySymCipherSetupData cipherSetupData; /**< Cipher Setup Data for the session. This member is ignored for the * CPA_CY_SYM_OP_HASH operation. */ CpaCySymHashSetupData hashSetupData; /**< Hash Setup Data for a session. This member is ignored for the * CPA_CY_SYM_OP_CIPHER operation. */ CpaCySymAlgChainOrder algChainOrder; /**< If this operation data structure relates to an algorithm chaining * session then this parameter determines the order in which the chained - * operations are performed. If this structure does not relate to an + * operations are performed. If this structure does not relate to an * algorithm chaining session then this parameter will be ignored. * * @note In the case of authenticated ciphers (GCM and CCM), which are * also presented as "algorithm chaining", this value is also ignored. * The chaining order is defined by the authenticated cipher, in those * cases. */ CpaBoolean digestIsAppended; /**< Flag indicating whether the digest is appended immediately following - * the region over which the digest is computed. This is true for both + * the region over which the digest is computed. This is true for both * IPsec packets and SSL/TLS records. * * If this flag is set, then the value of the pDigestResult field of * the structure @ref CpaCySymOpData is ignored. * * @note The value of this field is ignored for the authenticated cipher * AES_CCM as the digest must be appended in this case. * * @note Setting digestIsAppended for hash only operations when * verifyDigest is also set is not supported. For hash only operations * when verifyDigest is set, digestIsAppended should be set to CPA_FALSE. */ CpaBoolean verifyDigest; /**< This flag is relevant only for operations which generate a message - * digest. If set to true, the computed digest will not be written back + * digest. If set to true, the computed digest will not be written back * to the buffer location specified by other parameters, but instead will * be verified (i.e. compared to the value passed in at that location). * The number of bytes to be written or compared is indicated by the * digest output length for the session. * @note This option is only valid for full packets and for final * partial packets when using partials without algorithm chaining. * @note The value of this field is ignored for the authenticated ciphers - * (AES_CCM and AES_GCM). Digest verification is always done for these + * (AES_CCM and AES_GCM). Digest verification is always done for these * (when the direction is decrypt) and unless the DP API is used, * the message buffer will be zeroed if verification fails. When using the * DP API, it is the API clients responsibility to clear the message * buffer when digest verification fails. */ CpaBoolean partialsNotRequired; /**< This flag indicates if partial packet processing is required for this * session. If set to true, partial packet processing will not be enabled * for this session and any calls to cpaCySymPerformOp() with the * packetType parameter set to a value other than * CPA_CY_SYM_PACKET_TYPE_FULL will fail. */ } CpaCySymSessionSetupData ; /** ***************************************************************************** * @ingroup cpaCySym * Session Update Data. * @description * This structure contains data relating to resetting a session. ****************************************************************************/ typedef struct _CpaCySymSessionUpdateData { Cpa32U flags; /**< Flags indicating which fields to update. * All bits should be set to 0 except those fields to be updated. */ #define CPA_CY_SYM_SESUPD_CIPHER_KEY 1 << 0 #define CPA_CY_SYM_SESUPD_CIPHER_DIR 1 << 1 #define CPA_CY_SYM_SESUPD_AUTH_KEY 1 << 2 Cpa8U *pCipherKey; /**< Cipher key. * The same restrictions apply as described in the corresponding field * of the data structure @ref CpaCySymCipherSetupData. */ CpaCySymCipherDirection cipherDirection; /**< This parameter determines if the cipher operation is an encrypt or * a decrypt operation. * The same restrictions apply as described in the corresponding field * of the data structure @ref CpaCySymCipherSetupData. */ Cpa8U *authKey; /**< Authentication key pointer. * The same restrictions apply as described in the corresponding field * of the data structure @ref CpaCySymHashAuthModeSetupData. */ } CpaCySymSessionUpdateData; /** ***************************************************************************** * @ingroup cpaCySym * Cryptographic Component Operation Data. * @description * This structure contains data relating to performing cryptographic * processing on a data buffer. This request is used with * cpaCySymPerformOp() call for performing cipher, hash, auth cipher * or a combined hash and cipher operation. * * @see * CpaCySymPacketType * * @note * If the client modifies or frees the memory referenced in this structure * after it has been submitted to the cpaCySymPerformOp function, and * before it has been returned in the callback, undefined behavior will * result. ****************************************************************************/ typedef struct _CpaCySymOpData { CpaCySymSessionCtx sessionCtx; /**< Handle for the initialized session context */ CpaCySymPacketType packetType; /**< Selects the packet type */ Cpa8U *pIv; /**< Initialization Vector or Counter. * * - For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for * SNOW3G in UEA2 mode, this is the Initialization Vector (IV) * value. * - For block ciphers in CTR mode, this is the counter. * - For GCM mode, this is either the IV (if the length is 96 bits) or J0 * (for other sizes), where J0 is as defined by NIST SP800-38D. * Regardless of the IV length, a full 16 bytes needs to be allocated. * - For CCM mode, the first byte is reserved, and the nonce should be * written starting at &pIv[1] (to allow space for the implementation * to write in the flags in the first byte). Note that a full 16 bytes * should be allocated, even though the ivLenInBytes field will have * a value less than this. * The macro @ref CPA_CY_SYM_CCM_SET_NONCE may be used here. * - For AES-XTS, this is the 128bit tweak, i, from IEEE Std 1619-2007. * * For optimum performance, the data pointed to SHOULD be 8-byte * aligned. * * The IV/Counter will be updated after every partial cryptographic * operation. */ Cpa32U ivLenInBytes; /**< Length of valid IV data pointed to by the pIv parameter. * * - For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for * SNOW3G in UEA2 mode, this is the length of the IV (which * must be the same as the block length of the cipher). * - For block ciphers in CTR mode, this is the length of the counter * (which must be the same as the block length of the cipher). * - For GCM mode, this is either 12 (for 96-bit IVs) or 16, in which * case pIv points to J0. * - For CCM mode, this is the length of the nonce, which can be in the * range 7 to 13 inclusive. */ Cpa32U cryptoStartSrcOffsetInBytes; /**< Starting point for cipher processing, specified as number of bytes * from start of data in the source buffer. The result of the cipher * operation will be written back into the output buffer starting * at this location. */ Cpa32U messageLenToCipherInBytes; /**< The message length, in bytes, of the source buffer on which the * cryptographic operation will be computed. This must be a multiple of * the block size if a block cipher is being used. This is also the same * as the result length. * * @note In the case of CCM (@ref CPA_CY_SYM_HASH_AES_CCM), this value * should not include the length of the padding or the length of the * MAC; the driver will compute the actual number of bytes over which * the encryption will occur, which will include these values. * * @note There are limitations on this length for partial * operations. Refer to the cpaCySymPerformOp function description for * details. * * @note On some implementations, this length may be limited to a 16-bit * value (65535 bytes). * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC), this field * should be set to 0. */ Cpa32U hashStartSrcOffsetInBytes; /**< Starting point for hash processing, specified as number of bytes * from start of packet in source buffer. * * @note For CCM and GCM modes of operation, this field is ignored. * The field @ref pAdditionalAuthData field should be set instead. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of * operation, this field specifies the start of the AAD data in * the source buffer. */ Cpa32U messageLenToHashInBytes; /**< The message length, in bytes, of the source buffer that the hash * will be computed on. * * @note There are limitations on this length for partial operations. * Refer to the @ref cpaCySymPerformOp function description for details. * * @note For CCM and GCM modes of operation, this field is ignored. * The field @ref pAdditionalAuthData field should be set instead. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of * operation, this field specifies the length of the AAD data in the * source buffer. The maximum length supported for AAD data for AES-GMAC * is 16383 bytes. * * @note On some implementations, this length may be limited to a 16-bit * value (65535 bytes). */ Cpa8U *pDigestResult; /**< If the digestIsAppended member of the @ref CpaCySymSessionSetupData * structure is NOT set then this is a pointer to the location where the * digest result should be inserted (in the case of digest generation) * or where the purported digest exists (in the case of digest verification). * * At session registration time, the client specified the digest result * length with the digestResultLenInBytes member of the @ref * CpaCySymHashSetupData structure. The client must allocate at least * digestResultLenInBytes of physically contiguous memory at this location. * * For partial packet processing without algorithm chaining, this pointer * will be ignored for all but the final partial operation. * * For digest generation, the digest result will overwrite any data * at this location. * * @note For GCM (@ref CPA_CY_SYM_HASH_AES_GCM), for "digest result" * read "authentication tag T". * * If the digestIsAppended member of the @ref CpaCySymSessionSetupData * structure is set then this value is ignored and the digest result * is understood to be in the destination buffer for digest generation, * and in the source buffer for digest verification. The location of the * digest result in this case is immediately following the region over * which the digest is computed. * */ Cpa8U *pAdditionalAuthData; /**< Pointer to Additional Authenticated Data (AAD) needed for * authenticated cipher mechanisms (CCM and GCM), and to the IV for * SNOW3G authentication (@ref CPA_CY_SYM_HASH_SNOW3G_UIA2). * For other authentication mechanisms this pointer is ignored. * * The length of the data pointed to by this field is set up for * the session in the @ref CpaCySymHashAuthModeSetupData structure * as part of the @ref cpaCySymInitSession function call. This length * must not exceed 240 bytes. * * Specifically for CCM (@ref CPA_CY_SYM_HASH_AES_CCM), the caller * should setup this field as follows: * * - the nonce should be written starting at an offset of one byte * into the array, leaving room for the implementation to write in * the flags to the first byte. For example, *
* memcpy(&pOpData->pAdditionalAuthData[1], pNonce, nonceLen); *
* The macro @ref CPA_CY_SYM_CCM_SET_NONCE may be used here. * * - the additional authentication data itself should be written * starting at an offset of 18 bytes into the array, leaving room for * the length encoding in the first two bytes of the second block. * For example, *
* memcpy(&pOpData->pAdditionalAuthData[18], pAad, aadLen); *
* The macro @ref CPA_CY_SYM_CCM_SET_AAD may be used here. * * - the array should be big enough to hold the above fields, plus * any padding to round this up to the nearest multiple of the * block size (16 bytes). Padding will be added by the * implementation. * * Finally, for GCM (@ref CPA_CY_SYM_HASH_AES_GCM), the caller * should setup this field as follows: * * - the AAD is written in starting at byte 0 * - the array must be big enough to hold the AAD, plus any padding * to round this up to the nearest multiple of the block size (16 * bytes). Padding will be added by the implementation. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of * operation, this field is not used and should be set to 0. Instead * the AAD data should be placed in the source buffer. */ + } CpaCySymOpData; /** ***************************************************************************** * @ingroup cpaCySym * Setup the nonce for CCM. * @description * This macro sets the nonce in the appropriate locations of the * @ref CpaCySymOpData struct for the authenticated encryption * algorithm @ref CPA_CY_SYM_HASH_AES_CCM. ****************************************************************************/ #define CPA_CY_SYM_CCM_SET_NONCE(pOpData, pNonce, nonceLen) do { \ memcpy(&pOpData->pIv[1], pNonce, nonceLen); \ memcpy(&pOpData->pAdditionalAuthData[1], pNonce, nonceLen); \ } while (0) /** ***************************************************************************** * @ingroup cpaCySym * Setup the additional authentication data for CCM. * @description * This macro sets the additional authentication data in the * appropriate location of the@ref CpaCySymOpData struct for the - * authenticated encryptionalgorithm @ref CPA_CY_SYM_HASH_AES_CCM. + * authenticated encryption algorithm @ref CPA_CY_SYM_HASH_AES_CCM. ****************************************************************************/ #define CPA_CY_SYM_CCM_SET_AAD(pOpData, pAad, aadLen) do { \ memcpy(&pOpData->pAdditionalAuthData[18], pAad, aadLen); \ } while (0) /** ***************************************************************************** * @ingroup cpaCySym * Cryptographic Component Statistics. * @deprecated * As of v1.3 of the cryptographic API, this structure has been * deprecated, replaced by @ref CpaCySymStats64. * @description * This structure contains statistics on the Symmetric Cryptographic * operations. Statistics are set to zero when the component is * initialized. ****************************************************************************/ typedef struct _CpaCySymStats { Cpa32U numSessionsInitialized; /**< Number of session initialized */ Cpa32U numSessionsRemoved; /**< Number of sessions removed */ Cpa32U numSessionErrors; /**< Number of session initialized and removed errors. */ Cpa32U numSymOpRequests; /**< Number of successful symmetric operation requests. */ Cpa32U numSymOpRequestErrors; /**< Number of operation requests that had an error and could * not be processed. */ Cpa32U numSymOpCompleted; /**< Number of operations that completed successfully. */ Cpa32U numSymOpCompletedErrors; /**< Number of operations that could not be completed * successfully due to errors. */ Cpa32U numSymOpVerifyFailures; /**< Number of operations that completed successfully, but the * result of the digest verification test was that it failed. * Note that this does not indicate an error condition. */ } CpaCySymStats CPA_DEPRECATED; /** ***************************************************************************** * @ingroup cpaCySym * Cryptographic Component Statistics (64-bit version). * @description * This structure contains a 64-bit version of the statistics on * the Symmetric Cryptographic operations. * Statistics are set to zero when the component is initialized. ****************************************************************************/ typedef struct _CpaCySymStats64 { Cpa64U numSessionsInitialized; /**< Number of session initialized */ Cpa64U numSessionsRemoved; /**< Number of sessions removed */ Cpa64U numSessionErrors; /**< Number of session initialized and removed errors. */ Cpa64U numSymOpRequests; /**< Number of successful symmetric operation requests. */ Cpa64U numSymOpRequestErrors; /**< Number of operation requests that had an error and could * not be processed. */ Cpa64U numSymOpCompleted; /**< Number of operations that completed successfully. */ Cpa64U numSymOpCompletedErrors; /**< Number of operations that could not be completed * successfully due to errors. */ Cpa64U numSymOpVerifyFailures; /**< Number of operations that completed successfully, but the * result of the digest verification test was that it failed. * Note that this does not indicate an error condition. */ } CpaCySymStats64; /** ***************************************************************************** * @ingroup cpaCySym * Definition of callback function * * @description * This is the callback function prototype. The callback function is * registered by the application using the cpaCySymInitSession() * function call. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * Yes * * @param[in] pCallbackTag Opaque value provided by user while making * individual function call. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] operationType Identifies the operation type that was * requested in the cpaCySymPerformOp function. * @param[in] pOpData Pointer to structure with input parameters. * @param[in] pDstBuffer Caller MUST allocate a sufficiently sized * destination buffer to hold the data output. For * out-of-place processing the data outside the * cryptographic regions in the source buffer are * copied into the destination buffer. To perform * "in-place" processing set the pDstBuffer * parameter in cpaCySymPerformOp function to point * at the same location as pSrcBuffer. For optimum * performance, the data pointed to SHOULD be * 8-byte aligned. * @param[in] verifyResult This parameter is valid when the verifyDigest * option is set in the CpaCySymSessionSetupData * structure. A value of CPA_TRUE indicates that * the compare succeeded. A value of CPA_FALSE * indicates that the compare failed for an * unspecified reason. * * @retval * None * @pre * Component has been initialized. * @post * None * @note * None * @see * cpaCySymInitSession(), * cpaCySymRemoveSession() * *****************************************************************************/ typedef void (*CpaCySymCbFunc)(void *pCallbackTag, CpaStatus status, const CpaCySymOp operationType, void *pOpData, CpaBufferList *pDstBuffer, CpaBoolean verifyResult); /** ***************************************************************************** * @ingroup cpaCySym * Gets the size required to store a session context. * * @description * This function is used by the client to determine the size of the memory * it must allocate in order to store the session context. This MUST be * called before the client allocates the memory for the session context * and before the client calls the @ref cpaCySymInitSession function. * * For a given implementation of this API, it is safe to assume that * cpaCySymSessionCtxGetSize() will always return the same size and that * the size will not be different for different setup data parameters. * However, it should be noted that the size may change: * (1) between different implementations of the API (e.g. between software * and hardware implementations or between different hardware * implementations) * (2) between different releases of the same API implementation. * - * The size returned by this function is the smallest size needed to + * The size returned by this function is the smallest size needed to * support all possible combinations of setup data parameters. Some - * setup data parameter combinations may fit within a smaller session - * context size. The alternate cpaCySymSessionCtxGetDynamicSize() + * setup data parameter combinations may fit within a smaller session + * context size. The alternate cpaCySymSessionCtxGetDynamicSize() * function will return the smallest size needed to fit the * provided setup data parameters. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pSessionSetupData Pointer to session setup data which * contains parameters which are static * for a given cryptographic session such * as operation type, mechanisms, and keys * for cipher and/or hash operations. * @param[out] pSessionCtxSizeInBytes The amount of memory in bytes required * to hold the Session Context. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * @see * CpaCySymSessionSetupData * cpaCySymInitSession() * cpaCySymSessionCtxGetDynamicSize() * cpaCySymPerformOp() * *****************************************************************************/ CpaStatus cpaCySymSessionCtxGetSize(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes); /** ***************************************************************************** * @ingroup cpaCySym * Gets the minimum size required to store a session context. * * @description - * This function is used by the client to determine the smallest size of - * the memory it must allocate in order to store the session context. - * This MUST be called before the client allocates the memory for the - * session context and before the client calls the @ref cpaCySymInitSession + * This function is used by the client to determine the smallest size of + * the memory it must allocate in order to store the session context. + * This MUST be called before the client allocates the memory for the + * session context and before the client calls the @ref cpaCySymInitSession * function. * * This function is an alternate to cpaCySymSessionGetSize(). - * cpaCySymSessionCtxGetSize() will return a fixed size which is the - * minimum memory size needed to support all possible setup data parameter - * combinations. cpaCySymSessionCtxGetDynamicSize() will return the - * minimum memory size needed to support the specific session setup + * cpaCySymSessionCtxGetSize() will return a fixed size which is the + * minimum memory size needed to support all possible setup data parameter + * combinations. cpaCySymSessionCtxGetDynamicSize() will return the + * minimum memory size needed to support the specific session setup * data parameters provided. This size may be different for different setup * data parameters. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pSessionSetupData Pointer to session setup data which * contains parameters which are static * for a given cryptographic session such * as operation type, mechanisms, and keys * for cipher and/or hash operations. * @param[out] pSessionCtxSizeInBytes The amount of memory in bytes required * to hold the Session Context. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * @see * CpaCySymSessionSetupData * cpaCySymInitSession() * cpaCySymSessionCtxGetSize() * cpaCySymPerformOp() * *****************************************************************************/ CpaStatus cpaCySymSessionCtxGetDynamicSize(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes); /** ***************************************************************************** * @ingroup cpaCySym * Initialize a session for symmetric cryptographic API. * * @description * This function is used by the client to initialize an asynchronous * completion callback function for the symmetric cryptographic * operations. Clients MAY register multiple callback functions using * this function. * The callback function is identified by the combination of userContext, * pSymCb and session context (sessionCtx). The session context is the * handle to the session and needs to be passed when processing calls. * Callbacks on completion of operations within a session are guaranteed * to be in the same order they were submitted in. * * @context * This is a synchronous function and it cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pSymCb Pointer to callback function to be * registered. Set to NULL if the * cpaCySymPerformOp function is required to * work in a synchronous manner. * @param[in] pSessionSetupData Pointer to session setup data which contains * parameters which are static for a given * cryptographic session such as operation * type, mechanisms, and keys for cipher and/or * hash operations. * @param[out] sessionCtx Pointer to the memory allocated by the * client to store the session context. This * will be initialized with this function. This * value needs to be passed to subsequent * processing calls. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * @see * CpaCySymSessionCtx, * CpaCySymCbFunc, * CpaCySymSessionSetupData, * cpaCySymRemoveSession(), * cpaCySymPerformOp() * *****************************************************************************/ CpaStatus cpaCySymInitSession(const CpaInstanceHandle instanceHandle, const CpaCySymCbFunc pSymCb, const CpaCySymSessionSetupData *pSessionSetupData, CpaCySymSessionCtx sessionCtx); /** ***************************************************************************** * @ingroup cpaCySym * Remove (delete) a symmetric cryptographic session. * * @description * This function will remove a previously initialized session context * and the installed callback handler function. Removal will fail if * outstanding calls still exist for the initialized session handle. * The client needs to retry the remove function at a later time. * The memory for the session context MUST not be freed until this call * has completed successfully. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in,out] pSessionCtx Session context to be removed. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * CpaCySymSessionCtx, * cpaCySymInitSession() * *****************************************************************************/ CpaStatus cpaCySymRemoveSession(const CpaInstanceHandle instanceHandle, CpaCySymSessionCtx pSessionCtx); /** ***************************************************************************** * @ingroup cpaCySym * Update a session. * * @description * This function is used to update certain parameters of a session, as * specified by the CpaCySymSessionUpdateData data structure. * * It can be used on sessions created with either the so-called * Traditional API (@ref cpaCySymInitSession) or the Data Plane API * (@ref cpaCySymDpInitSession). * * In order for this function to operate correctly, two criteria must * be met: * * - In the case of sessions created with the Traditional API, the * session must be stateless, i.e. the field partialsNotRequired of * the CpaCySymSessionSetupData data structure must be FALSE. * (Sessions created using the Data Plane API are always stateless.) * * - There must be no outstanding requests in flight for the session. * The application can call the function @ref cpaCySymSessionInUse * to test for this. * * Note that in the case of multi-threaded applications (which are * supported using the Traditional API only), this function may fail * even if a previous invocation of the function @ref * cpaCySymSessionInUse indicated that there were no outstanding * requests. * * @param[in] sessionCtx Identifies the session to be reset. * @param[in] pSessionUpdateData Pointer to session data which contains * the parameters to be updated. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. *****************************************************************************/ CpaStatus cpaCySymUpdateSession(CpaCySymSessionCtx sessionCtx, const CpaCySymSessionUpdateData *pSessionUpdateData); /** ***************************************************************************** * @ingroup cpaCySym * Indicates whether there are outstanding requests on a given * session. * * @description * This function is used to test whether there are outstanding * requests in flight for a specified session. This may be used * before resetting session parameters using the function @ref * cpaCySymResetSession. See some additional notes on * multi-threaded applications described on that function. * * @param[in] sessionCtx Identifies the session to be reset. * @param[out] pSessionInUse Returns CPA_TRUE if there are * outstanding requests on the session, * or CPA_FALSE otherwise. *****************************************************************************/ CpaStatus cpaCySymSessionInUse(CpaCySymSessionCtx sessionCtx, CpaBoolean* pSessionInUse); /** ***************************************************************************** * @ingroup cpaCySym * Perform a symmetric cryptographic operation on an existing session. * * @description * Performs a cipher, hash or combined (cipher and hash) operation on * the source data buffer using supported symmetric key algorithms and * modes. * * This function maintains cryptographic state between calls for * partial cryptographic operations. If a partial cryptographic * operation is being performed, then on a per-session basis, the next * part of the multi-part message can be submitted prior to previous * parts being completed, the only limitation being that all parts * must be performed in sequential order. * * If for any reason a client wishes to terminate the partial packet * processing on the session (for example if a packet fragment was lost) * then the client MUST remove the session. * * When using partial packet processing with algorithm chaining, only * the cipher state is maintained between calls. The hash state is * not be maintained between calls. Instead the hash digest will be * generated/verified for each call. If both the cipher state and * hash state need to be maintained between calls, algorithm chaining * cannot be used. * The following restrictions apply to the length: * * - When performing block based operations on a partial packet * (excluding the final partial packet), the data that is to be * operated on MUST be a multiple of the block size of the algorithm * being used. This restriction only applies to the cipher state * when using partial packets with algorithm chaining. * * - The final block must not be of length zero (0) if the operation * being performed is the authentication algorithm @ref * CPA_CY_SYM_HASH_AES_XCBC. This is because this algorithm requires * that the final block be XORed with another value internally. * If the length is zero, then the return code @ref * CPA_STATUS_INVALID_PARAM will be returned. * * - The length of the final block must be greater than or equal to * 16 bytes when using the @ref CPA_CY_SYM_CIPHER_AES_XTS cipher * algorithm. * * Partial packet processing is supported only when the following * conditions are true: * * - The cipher, hash or authentication operation is "in place" (that is, * pDstBuffer == pSrcBuffer) * * - The cipher or hash algorithm is NOT one of Kasumi or SNOW3G * * - The cipher mode is NOT F8 mode. * * - The hash algorithm is NOT SHAKE * * - The cipher algorithm is not SM4 * * - The cipher algorithm is not CPA_CY_SYM_CIPHER_CHACHA and the hash * algorithm is not CPA_CY_SYM_HASH_POLY. * * - The cipher algorithm is not CPA_CY_SYM_CIPHER_AES_GCM and the hash * algorithm is not CPA_CY_SYM_HASH_AES_GCM. * * - The instance/implementation supports partial packets as one of * its capabilities (see @ref CpaCySymCapabilitiesInfo). * * The term "in-place" means that the result of the cryptographic * operation is written into the source buffer. The term "out-of-place" * means that the result of the cryptographic operation is written into * the destination buffer. To perform "in-place" processing, set the * pDstBuffer parameter to point at the same location as the pSrcBuffer * parameter. * * @context * When called as an asynchronous function it cannot sleep. It can be * executed in a context that does not permit sleeping. * When called as a synchronous function it may sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes when configured to operate in synchronous mode. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pCallbackTag Opaque data that will be returned to the client * in the callback. * @param[in] pOpData Pointer to a structure containing request * parameters. The client code allocates the memory * for this structure. This component takes * ownership of the memory until it is returned in * the callback. * @param[in] pSrcBuffer The source buffer. The caller MUST allocate * the source buffer and populate it * with data. For optimum performance, the data * pointed to SHOULD be 8-byte aligned. For * block ciphers, the data passed in MUST be * a multiple of the relevant block size. * i.e. padding WILL NOT be applied to the data. * For optimum performance, the buffer should - * only contain the data region that the + * only contain the data region that the * cryptographic operation(s) must be performed on. * Any additional data in the source buffer may be * copied to the destination buffer and this copy * may degrade performance. * @param[out] pDstBuffer The destination buffer. The caller MUST * allocate a sufficiently sized destination * buffer to hold the data output (including * the authentication tag in the case of CCM). * Furthermore, the destination buffer must be the * same size as the source buffer (i.e. the sum of * lengths of the buffers in the buffer list must * be the same). This effectively means that the * source buffer must in fact be big enough to hold * the output data, too. This is because, * for out-of-place processing, the data outside the * regions in the source buffer on which * cryptographic operations are performed are copied * into the destination buffer. To perform * "in-place" processing set the pDstBuffer * parameter in cpaCySymPerformOp function to point * at the same location as pSrcBuffer. For optimum * performance, the data pointed to SHOULD be * 8-byte aligned. * @param[out] pVerifyResult In synchronous mode, this parameter is returned * when the verifyDigest option is set in the * CpaCySymSessionSetupData structure. A value of * CPA_TRUE indicates that the compare succeeded. A * value of CPA_FALSE indicates that the compare * failed for an unspecified reason. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resource. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized via cpaCyStartInstance function. * A Cryptographic session has been previously setup using the * @ref cpaCySymInitSession function call. * @post * None * * @note * When in asynchronous mode, a callback of type CpaCySymCbFunc is * generated in response to this function call. Any errors generated during * processing are reported as part of the callback status code. * * @see * CpaCySymOpData, * cpaCySymInitSession(), * cpaCySymRemoveSession() *****************************************************************************/ CpaStatus cpaCySymPerformOp(const CpaInstanceHandle instanceHandle, void *pCallbackTag, const CpaCySymOpData *pOpData, const CpaBufferList *pSrcBuffer, CpaBufferList *pDstBuffer, CpaBoolean *pVerifyResult); /** ***************************************************************************** * @ingroup cpaCySym * Query symmetric cryptographic statistics for a specific instance. * * @deprecated * As of v1.3 of the cryptographic API, this function has been * deprecated, replaced by @ref cpaCySymQueryStats64(). * * @description * This function will query a specific instance for statistics. The * user MUST allocate the CpaCySymStats structure and pass the * reference to that into this function call. This function will write * the statistic results into the passed in CpaCySymStats * structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pSymStats Pointer to memory into which the * statistics will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner, i.e. no asynchronous * callback will be generated. * @see * CpaCySymStats *****************************************************************************/ CpaStatus CPA_DEPRECATED cpaCySymQueryStats(const CpaInstanceHandle instanceHandle, struct _CpaCySymStats *pSymStats); /** ***************************************************************************** * @ingroup cpaCySym * Query symmetric cryptographic statistics (64-bit version) for a * specific instance. * * @description * This function will query a specific instance for statistics. The * user MUST allocate the CpaCySymStats64 structure and pass the * reference to that into this function call. This function will write * the statistic results into the passed in CpaCySymStats64 * structure. * * Note: statistics returned by this function do not interrupt current data * processing and as such can be slightly out of sync with operations that * are in progress during the statistics retrieval process. * * @context * This is a synchronous function and it can sleep. It MUST NOT be * executed in a context that DOES NOT permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * Yes * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[out] pSymStats Pointer to memory into which the * statistics will be written. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * This function operates in a synchronous manner, i.e. no asynchronous * callback will be generated. * @see * CpaCySymStats64 *****************************************************************************/ CpaStatus cpaCySymQueryStats64(const CpaInstanceHandle instanceHandle, CpaCySymStats64 *pSymStats); /** ***************************************************************************** * @ingroup cpaCySym * Symmetric Capabilities Info * * @description * This structure contains the capabilities that vary across * implementations of the symmetric sub-API of the cryptographic API. * This structure is used in conjunction with @ref * cpaCySymQueryCapabilities() to determine the capabilities supported * by a particular API implementation. * * For example, to see if an implementation supports cipher * @ref CPA_CY_SYM_CIPHER_AES_CBC, use the code * * @code if (CPA_BITMAP_BIT_TEST(capInfo.ciphers, CPA_CY_SYM_CIPHER_AES_CBC)) { // algo is supported } else { // algo is not supported } * @endcode * * The client MUST allocate memory for this structure and any members * that require memory. When the structure is passed into the function * ownership of the memory passes to the function. Ownership of the * memory returns to the client when the function returns. *****************************************************************************/ typedef struct _CpaCySymCapabilitiesInfo { CPA_BITMAP(ciphers, CPA_CY_SYM_CIPHER_CAP_BITMAP_SIZE); /**< Bitmap representing which cipher algorithms (and modes) are * supported by the instance. * Bits can be tested using the macro @ref CPA_BITMAP_BIT_TEST. * The bit positions are those specified in the enumerated type * @ref CpaCySymCipherAlgorithm. */ CPA_BITMAP(hashes, CPA_CY_SYM_HASH_CAP_BITMAP_SIZE); /**< Bitmap representing which hash/authentication algorithms are * supported by the instance. * Bits can be tested using the macro @ref CPA_BITMAP_BIT_TEST. * The bit positions are those specified in the enumerated type * @ref CpaCySymHashAlgorithm. */ CpaBoolean partialPacketSupported; /**< CPA_TRUE if instance supports partial packets. * See @ref CpaCySymPacketType. */ } CpaCySymCapabilitiesInfo; /** ***************************************************************************** * @ingroup cpaCySym * Returns capabilities of the symmetric API group of a Cryptographic * API instance. * * @description * This function is used to determine which specific capabilities are * supported within the symmetric sub-group of the Cryptographic API. * * @context * The function shall not be called in an interrupt context. * @assumptions * None * @sideEffects * None * @blocking * This function is synchronous and blocking. * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Handle to an instance of this API. * @param[out] pCapInfo Pointer to capabilities info structure. * All fields in the structure * are populated by the API instance. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The instance has been initialized via the @ref cpaCyStartInstance * function. * @post * None *****************************************************************************/ CpaStatus cpaCySymQueryCapabilities(const CpaInstanceHandle instanceHandle, CpaCySymCapabilitiesInfo * pCapInfo); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_SYM_H */ diff --git a/sys/dev/qat/qat_api/include/lac/cpa_cy_sym_dp.h b/sys/dev/qat/qat_api/include/lac/cpa_cy_sym_dp.h index 7f103ec98e51..a023b2e6eb6a 100644 --- a/sys/dev/qat/qat_api/include/lac/cpa_cy_sym_dp.h +++ b/sys/dev/qat/qat_api/include/lac/cpa_cy_sym_dp.h @@ -1,986 +1,986 @@ /*************************************************************************** * * BSD LICENSE - * - * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. + * + * Copyright(c) 2007-2025 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ***************************************************************************/ /* ***************************************************************************** * Doxygen group definitions ****************************************************************************/ /** ***************************************************************************** * @file cpa_cy_sym_dp.h * * @defgroup cpaCySymDp Symmetric cryptographic Data Plane API * * @ingroup cpaCySym * * @description * These data structures and functions specify the Data Plane API * for symmetric cipher, hash, and combined cipher and hash * operations. * * This API is recommended for data plane applications, in which the * cost of offload - that is, the cycles consumed by the driver in * sending requests to the hardware, and processing responses - needs * to be minimized. In particular, use of this API is recommended * if the following constraints are acceptable to your application: * * - Thread safety is not guaranteed. Each software thread should * have access to its own unique instance (CpaInstanceHandle) to * avoid contention. * - Polling is used, rather than interrupts (which are expensive). * Implementations of this API will provide a function (not * defined as part of this API) to read responses from the hardware * response queue and dispatch callback functions, as specified on * this API. * - Buffers and buffer lists are passed using physical addresses, * to avoid virtual to physical address translation costs. * - For GCM and CCM modes of AES, when performing decryption and * verification, if verification fails, then the message buffer * will NOT be zeroed. (This is a consequence of using physical * addresses for the buffers.) * - The ability to enqueue one or more requests without submitting * them to the hardware allows for certain costs to be amortized * across multiple requests. * - Only asynchronous invocation is supported. * - There is no support for partial packets. * - Implementations may provide certain features as optional at * build time, such as atomic counters. * - The "default" instance (@ref CPA_INSTANCE_HANDLE_SINGLE) is not * supported on this API. The specific handle should be obtained * using the instance discovery functions (@ref cpaCyGetNumInstances, * @ref cpaCyGetInstances). * * @note Performance Trade-Offs * Different implementations of this API may have different performance * trade-offs; please refer to the documentation for your implementation * for details. However, the following concepts informed the definition * of this API. * * The API distinguishes between enqueuing a request and actually * submitting that request to the cryptographic acceleration * engine to be performed. This allows multiple requests to be enqueued * (either individually or in batch), and then for all enqueued requests * to be submitted in a single operation. The rationale is that in some * (especially hardware-based) implementations, the submit operation * is expensive; for example, it may incur an MMIO instruction. The * API allows this cost to be amortized over a number of requests. The * precise number of such requests can be tuned for optimal * performance. * * Specifically: * * - The function @ref cpaCySymDpEnqueueOp allows one request to be * enqueued, and optionally for that request (and all previously * enqueued requests) to be submitted. * - The function @ref cpaCySymDpEnqueueOpBatch allows multiple * requests to be enqueued, and optionally for those requests (and all * previously enqueued requests) to be submitted. * - The function @ref cpaCySymDpPerformOpNow enqueues no requests, but * submits all previously enqueued requests. *****************************************************************************/ #ifndef CPA_CY_SYM_DP_H #define CPA_CY_SYM_DP_H #ifdef __cplusplus extern "C" { #endif #include "cpa_cy_common.h" #include "cpa_cy_sym.h" /** ***************************************************************************** * @ingroup cpaCySymDp * Cryptographic component symmetric session context handle for the * data plane API. * @description * Handle to a cryptographic data plane session context. The memory for * this handle is allocated by the client. The size of the memory that * the client needs to allocate is determined by a call to the @ref * cpaCySymDpSessionCtxGetSize or @ref cpaCySymDpSessionCtxGetDynamicSize * functions. The session context memory is initialized with a call to * the @ref cpaCySymInitSession function. * This memory MUST not be freed until a call to @ref * cpaCySymDpRemoveSession has completed successfully. * *****************************************************************************/ typedef void * CpaCySymDpSessionCtx; /** ***************************************************************************** * @ingroup cpaCySymDp * Operation Data for cryptographic data plane API. * * @description * This structure contains data relating to a request to perform * symmetric cryptographic processing on one or more data buffers. * * The physical memory to which this structure points needs to be * at least 8-byte aligned. * * All reserved fields SHOULD NOT be written or read by the * calling code. * * @see * cpaCySymDpEnqueueOp, cpaCySymDpEnqueueOpBatch ****************************************************************************/ typedef struct _CpaCySymDpOpData { Cpa64U reserved0; /**< Reserved for internal usage. */ Cpa32U cryptoStartSrcOffsetInBytes; /**< Starting point for cipher processing, specified as number of bytes * from start of data in the source buffer. The result of the cipher * operation will be written back into the buffer starting at this * location in the destination buffer. */ Cpa32U messageLenToCipherInBytes; /**< The message length, in bytes, of the source buffer on which the * cryptographic operation will be computed. This must be a multiple of * the block size if a block cipher is being used. This is also the * same as the result length. * * @note In the case of CCM (@ref CPA_CY_SYM_HASH_AES_CCM), this value * should not include the length of the padding or the length of the * MAC; the driver will compute the actual number of bytes over which * the encryption will occur, which will include these values. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC), this field * should be set to 0. * * @note On some implementations, this length may be limited to a 16-bit * value (65535 bytes). */ CpaPhysicalAddr iv; /**< Initialization Vector or Counter. Specifically, this is the * physical address of one of the following: * * - For block ciphers in CBC mode, or for Kasumi in F8 mode, or for * SNOW3G in UEA2 mode, this is the Initialization Vector (IV) * value. * - For ARC4, this is reserved for internal usage. * - For block ciphers in CTR mode, this is the counter. * - For GCM mode, this is either the IV (if the length is 96 bits) or J0 * (for other sizes), where J0 is as defined by NIST SP800-38D. * Regardless of the IV length, a full 16 bytes needs to be allocated. * - For CCM mode, the first byte is reserved, and the nonce should be * written starting at &pIv[1] (to allow space for the implementation * to write in the flags in the first byte). Note that a full 16 bytes * should be allocated, even though the ivLenInBytes field will have * a value less than this. * The macro @ref CPA_CY_SYM_CCM_SET_NONCE may be used here. */ Cpa64U reserved1; /**< Reserved for internal usage. */ Cpa32U hashStartSrcOffsetInBytes; /**< Starting point for hash processing, specified as number of bytes * from start of packet in source buffer. * * @note For CCM and GCM modes of operation, this value in this field * is ignored, and the field is reserved for internal usage. * The fields @ref additionalAuthData and @ref pAdditionalAuthData * should be set instead. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of * operation, this field specifies the start of the AAD data in * the source buffer. */ Cpa32U messageLenToHashInBytes; /**< The message length, in bytes, of the source buffer that the hash * will be computed on. * * @note For CCM and GCM modes of operation, this value in this field * is ignored, and the field is reserved for internal usage. * The fields @ref additionalAuthData and @ref pAdditionalAuthData * should be set instead. * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of * operation, this field specifies the length of the AAD data in the * source buffer. * * @note On some implementations, this length may be limited to a 16-bit * value (65535 bytes). */ CpaPhysicalAddr additionalAuthData; /**< Physical address of the Additional Authenticated Data (AAD), * which is needed for authenticated cipher mechanisms (CCM and * GCM), and to the IV for SNOW3G authentication (@ref * CPA_CY_SYM_HASH_SNOW3G_UIA2). For other authentication * mechanisms, this value is ignored, and the field is reserved for * internal usage. * * The length of the data pointed to by this field is set up for * the session in the @ref CpaCySymHashAuthModeSetupData structure * as part of the @ref cpaCySymDpInitSession function call. This length * must not exceed 240 bytes. * If AAD is not used, this address must be set to zero. * * Specifically for CCM (@ref CPA_CY_SYM_HASH_AES_CCM) and GCM (@ref * CPA_CY_SYM_HASH_AES_GCM), the caller should be setup as described in * the same way as the corresponding field, pAdditionalAuthData, on the * "traditional" API (see the @ref CpaCySymOpData). * * @note For AES-GMAC (@ref CPA_CY_SYM_HASH_AES_GMAC) mode of * operation, this field is not used and should be set to 0. Instead * the AAD data should be placed in the source buffer. * */ CpaPhysicalAddr digestResult; /**< If the digestIsAppended member of the @ref CpaCySymSessionSetupData * structure is NOT set then this is the physical address of the location * where the digest result should be inserted (in the case of digest * generation) or where the purported digest exists (in the case of digest * verification). * * At session registration time, the client specified the digest result * length with the digestResultLenInBytes member of the @ref * CpaCySymHashSetupData structure. The client must allocate at least * digestResultLenInBytes of physically contiguous memory at this location. * * For digest generation, the digest result will overwrite any data * at this location. * * @note For GCM (@ref CPA_CY_SYM_HASH_AES_GCM), for "digest result" * read "authentication tag T". * * If the digestIsAppended member of the @ref CpaCySymSessionSetupData * structure is set then this value is ignored and the digest result * is understood to be in the destination buffer for digest generation, * and in the source buffer for digest verification. The location of the * digest result in this case is immediately following the region over * which the digest is computed. */ CpaInstanceHandle instanceHandle; /**< Instance to which the request is to be enqueued. * @note A callback function must have been registered on the instance * using @ref cpaCySymDpRegCbFunc. */ CpaCySymDpSessionCtx sessionCtx; /**< Session context specifying the cryptographic parameters for this * request. * @note The session must have been created using @ref * cpaCySymDpInitSession. */ Cpa32U ivLenInBytes; /**< Length of valid IV data pointed to by the pIv parameter. * * - For block ciphers in CBC mode, or for Kasumi in F8 mode, or for * SNOW3G in UEA2 mode, this is the length of the IV (which * must be the same as the block length of the cipher). * - For block ciphers in CTR mode, this is the length of the counter * (which must be the same as the block length of the cipher). * - For GCM mode, this is either 12 (for 96-bit IVs) or 16, in which * case pIv points to J0. * - For CCM mode, this is the length of the nonce, which can be in the * range 7 to 13 inclusive. */ CpaPhysicalAddr srcBuffer; /**< Physical address of the source buffer on which to operate. * This is either: * * - The location of the data, of length srcBufferLen; or, * - If srcBufferLen has the special value @ref CPA_DP_BUFLIST, then * srcBuffer contains the location where a @ref CpaPhysBufferList is * stored. In this case, the CpaPhysBufferList MUST be aligned * on an 8-byte boundary. * - For optimum performance, the buffer should only contain the data * region that the cryptographic operation(s) must be performed on. * Any additional data in the source buffer may be copied to the * destination buffer and this copy may degrade performance. */ Cpa32U srcBufferLen; /**< Length of source buffer, or @ref CPA_DP_BUFLIST. */ CpaPhysicalAddr dstBuffer; /**< Physical address of the destination buffer on which to operate. * This is either: * * - The location of the data, of length srcBufferLen; or, * - If srcBufferLen has the special value @ref CPA_DP_BUFLIST, then * srcBuffer contains the location where a @ref CpaPhysBufferList is * stored. In this case, the CpaPhysBufferList MUST be aligned * on an 8-byte boundary. * * For "in-place" operation, the dstBuffer may be identical to the * srcBuffer. */ Cpa32U dstBufferLen; /**< Length of destination buffer, or @ref CPA_DP_BUFLIST. */ CpaPhysicalAddr thisPhys; /**< Physical address of this data structure */ Cpa8U* pIv; /**< Pointer to (and therefore, the virtual address of) the IV field * above. * Needed here because the driver in some cases writes to this field, * in addition to sending it to the accelerator. */ Cpa8U *pAdditionalAuthData; /**< Pointer to (and therefore, the virtual address of) the * additionalAuthData field above. * Needed here because the driver in some cases writes to this field, * in addition to sending it to the accelerator. */ void* pCallbackTag; /**< Opaque data that will be returned to the client in the function * completion callback. * * This opaque data is not used by the implementation of the API, * but is simply returned as part of the asynchronous response. * It may be used to store information that might be useful when * processing the response later. */ } CpaCySymDpOpData; /** ***************************************************************************** * @ingroup cpaCySymDp * Definition of callback function for cryptographic data plane API. * * @description * This is the callback function prototype. The callback function is * registered by the application using the @ref cpaCySymDpRegCbFunc - * function call, and called back on completion of asycnhronous + * function call, and called back on completion of asynchronous * requests made via calls to @ref cpaCySymDpEnqueueOp or @ref * cpaCySymDpEnqueueOpBatch. * * @context * This callback function can be executed in a context that DOES NOT * permit sleeping to occur. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No * * @param[in] pOpData Pointer to the CpaCySymDpOpData object which * was supplied as part of the original request. * @param[in] status Status of the operation. Valid values are * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and * CPA_STATUS_UNSUPPORTED. * @param[in] verifyResult This parameter is valid when the verifyDigest * option is set in the CpaCySymSessionSetupData * structure. A value of CPA_TRUE indicates that * the compare succeeded. A value of CPA_FALSE * indicates that the compare failed. * * @return * None * @pre * Component has been initialized. * Callback has been registered with @ref cpaCySymDpRegCbFunc. * @post * None * @note * None * @see * cpaCySymDpRegCbFunc *****************************************************************************/ typedef void (*CpaCySymDpCbFunc)(CpaCySymDpOpData *pOpData, CpaStatus status, CpaBoolean verifyResult); /** ***************************************************************************** * @ingroup cpaCySymDp * Registration of the operation completion callback function. * * @description * This function allows a completion callback function to be registered. * The registered callback function is invoked on completion of - * asycnhronous requests made via calls to @ref cpaCySymDpEnqueueOp + * asynchronous requests made via calls to @ref cpaCySymDpEnqueueOp * or @ref cpaCySymDpEnqueueOpBatch. * * If a callback function was previously registered, it is overwritten. * * @context * This is a synchronous function and it cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @reentrant * No * @threadSafe * No * * @param[in] instanceHandle Instance on which the callback function is to be * registered. * @param[in] pSymNewCb Callback function for this instance. * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * Component has been initialized. * @post * None * @note * None * @see * CpaCySymDpCbFunc *****************************************************************************/ CpaStatus cpaCySymDpRegCbFunc(const CpaInstanceHandle instanceHandle, const CpaCySymDpCbFunc pSymNewCb); /** ***************************************************************************** * @ingroup cpaCySymDp * Gets the size required to store a session context for the data plane * API. * * @description * This function is used by the client to determine the size of the memory * it must allocate in order to store the session context. This MUST be * called before the client allocates the memory for the session context * and before the client calls the @ref cpaCySymDpInitSession function. * * For a given implementation of this API, it is safe to assume that * cpaCySymDpSessionCtxGetSize() will always return the same size and that * the size will not be different for different setup data parameters. * However, it should be noted that the size may change: * (1) between different implementations of the API (e.g. between software * and hardware implementations or between different hardware * implementations) * (2) between different releases of the same API implementation. * * The size returned by this function is the smallest size needed to * support all possible combinations of setup data parameters. Some * setup data parameter combinations may fit within a smaller session * context size. The alternate cpaCySymDpSessionCtxGetDynamicSize() * function will return the smallest size needed to fit the * provided setup data parameters. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pSessionSetupData Pointer to session setup data which * contains parameters which are static * for a given cryptographic session such * as operation type, mechanisms, and keys * for cipher and/or hash operations. * @param[out] pSessionCtxSizeInBytes The amount of memory in bytes required * to hold the Session Context. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * @see * CpaCySymSessionSetupData * cpaCySymDpSessionCtxGetDynamicSize() * cpaCySymDpInitSession() *****************************************************************************/ CpaStatus cpaCySymDpSessionCtxGetSize(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes); /** ***************************************************************************** * @ingroup cpaCySymDp * Gets the minimum size required to store a session context for the data * plane API. * * @description * This function is used by the client to determine the smallest size of * the memory it must allocate in order to store the session context. * This MUST be called before the client allocates the memory for the * session context and before the client calls the * @ref cpaCySymDpInitSession function. * * This function is an alternate to cpaCySymDpSessionGetSize(). * cpaCySymDpSessionCtxGetSize() will return a fixed size which is the * minimum memory size needed to support all possible setup data parameter * combinations. cpaCySymDpSessionCtxGetDynamicSize() will return the * minimum memory size needed to support the specific session setup * data parameters provided. This size may be different for different setup * data parameters. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param[in] instanceHandle Instance handle. * @param[in] pSessionSetupData Pointer to session setup data which * contains parameters which are static * for a given cryptographic session such * as operation type, mechanisms, and keys * for cipher and/or hash operations. * @param[out] pSessionCtxSizeInBytes The amount of memory in bytes required * to hold the Session Context. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * @see * CpaCySymSessionSetupData * cpaCySymDpSessionCtxGetSize() * cpaCySymDpInitSession() *****************************************************************************/ CpaStatus cpaCySymDpSessionCtxGetDynamicSize(const CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, Cpa32U *pSessionCtxSizeInBytes); /** ***************************************************************************** * @ingroup cpaCySymDp * Initialize a session for the symmetric cryptographic data plane API. * * @description * This function is used by the client to initialize an asynchronous * session context for symmetric cryptographic data plane operations. * The returned session context is the handle to the session and needs to * be passed when requesting cryptographic operations to be performed. * * Only sessions created using this function may be used when * invoking functions on this API * * The session can be removed using @ref cpaCySymDpRemoveSession. * * @context * This is a synchronous function and it cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] instanceHandle Instance to which the requests will be * submitted. * @param[in] pSessionSetupData Pointer to session setup data which * contains parameters that are static * for a given cryptographic session such * as operation type, algorithm, and keys * for cipher and/or hash operations. * @param[out] sessionCtx Pointer to the memory allocated by the * client to store the session context. This * memory must be physically contiguous, and * its length (in bytes) must be at least as * big as specified by a call to @ref * cpaCySymDpSessionCtxGetSize. This memory * will be initialized with this function. This * value needs to be passed to subsequent * processing calls. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * This is a synchronous function and has no completion callback * associated with it. * @see * cpaCySymDpSessionCtxGetSize, cpaCySymDpRemoveSession *****************************************************************************/ CpaStatus cpaCySymDpInitSession(CpaInstanceHandle instanceHandle, const CpaCySymSessionSetupData *pSessionSetupData, CpaCySymDpSessionCtx sessionCtx); /** ***************************************************************************** * @ingroup cpaCySymDp * Remove (delete) a symmetric cryptographic session for the data plane * API. * * @description * This function will remove a previously initialized session context * and the installed callback handler function. Removal will fail if * outstanding calls still exist for the initialized session handle. * The client needs to retry the remove function at a later time. * The memory for the session context MUST not be freed until this call * has completed successfully. * * @context * This is a synchronous function that cannot sleep. It can be * executed in a context that does not permit sleeping. * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] instanceHandle Instance handle. * @param[in,out] sessionCtx Session context to be removed. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESOURCE Error related to system resources. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * @post * None * @note * Note that this is a synchronous function and has no completion callback * associated with it. * * @see * CpaCySymDpSessionCtx, * cpaCySymDpInitSession() * *****************************************************************************/ CpaStatus cpaCySymDpRemoveSession(const CpaInstanceHandle instanceHandle, CpaCySymDpSessionCtx sessionCtx); /** ***************************************************************************** * @ingroup cpaCySymDp * Enqueue a single symmetric cryptographic request. * * @description * This function enqueues a single request to perform a cipher, * hash or combined (cipher and hash) operation. Optionally, the * request is also submitted to the cryptographic engine to be * performed. * * See note about performance trade-offs on the @ref cpaCySymDp API. * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaCySymDpRegCbFunc) to be invoked. * Callbacks within a session are guaranteed to be in the same order * in which they were submitted. * * The following restrictions apply to the pOpData parameter: * * - The memory MUST be aligned on an 8-byte boundary. * - The structure MUST reside in physically contiguous memory. * - The reserved fields of the structure SHOULD NOT be written * or read by the calling code. * * @context * This function will not sleep, and hence can be executed in a context * that does not permit sleeping. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] pOpData Pointer to a structure containing the * request parameters. The client code allocates * the memory for this structure. This component * takes ownership of the memory until it is * returned in the callback, which was registered * on the instance via @ref cpaCySymDpRegCbFunc. * See the above Description for restrictions * that apply to this parameter. * @param[in] performOpNow Flag to specify whether the operation should be * performed immediately (CPA_TRUE), or simply * enqueued to be performed later (CPA_FALSE). * In the latter case, the request is submitted * to be performed either by calling this function * again with this flag set to CPA_TRUE, or by * invoking the function @ref * cpaCySymDpPerformOpNow. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The session identified by pOpData->sessionCtx was setup using * @ref cpaCySymDpInitSession. * The instance identified by pOpData->instanceHandle has had a * callback function registered via @ref cpaCySymDpRegCbFunc. * * @post * None * * @note * A callback of type @ref CpaCySymDpCbFunc is generated in response to * this function call. Any errors generated during processing are * reported as part of the callback status code. * * @see * cpaCySymDpInitSession, * cpaCySymDpPerformOpNow *****************************************************************************/ CpaStatus cpaCySymDpEnqueueOp(CpaCySymDpOpData *pOpData, const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaCySymDp * Enqueue multiple requests to the symmetric cryptographic data plane * API. * * @description * This function enqueues multiple requests to perform cipher, hash * or combined (cipher and hash) operations. * See note about performance trade-offs on the @ref cpaCySymDp API. * * The function is asynchronous; control is returned to the user once * the request has been submitted. On completion of the request, the * application may poll for responses, which will cause a callback * function (registered via @ref cpaCySymDpRegCbFunc) to be invoked. * Separate callbacks will be invoked for each request. * Callbacks within a session are guaranteed to be in the same order * in which they were submitted. * * The following restrictions apply to each element of the pOpData * array: * * - The memory MUST be aligned on an 8-byte boundary. * - The structure MUST reside in physically contiguous memory. * - The reserved fields of the structure SHOULD NOT be * written or read by the calling code. * * @context * This function will not sleep, and hence can be executed in a context * that does not permit sleeping. * * @assumptions * Client MUST allocate the request parameters to 8 byte alignment. * Reserved elements of the CpaCySymDpOpData structure MUST be 0. * The CpaCySymDpOpData structure MUST reside in physically * contiguous memory. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] numberRequests The number of requests in the array of * CpaCySymDpOpData structures. * @param[in] pOpData An array of pointers to CpaCySymDpOpData * structures. Each of the CpaCySymDpOpData * structure contains the request parameters for * that request. The client code allocates the * memory for this structure. This component takes * ownership of the memory until it is returned in * the callback, which was registered on the * instance via @ref cpaCySymDpRegCbFunc. * See the above Description for restrictions * that apply to this parameter. * @param[in] performOpNow Flag to specify whether the operation should be * performed immediately (CPA_TRUE), or simply * enqueued to be performed later (CPA_FALSE). * In the latter case, the request is submitted * to be performed either by calling this function * again with this flag set to CPA_TRUE, or by * invoking the function @ref * cpaCySymDpPerformOpNow. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The session identified by pOpData[i]->sessionCtx was setup using * @ref cpaCySymDpInitSession. * The instance identified by pOpData->instanceHandle[i] has had a * callback function registered via @ref cpaCySymDpRegCbFunc. * * @post * None * * @note * Multiple callbacks of type @ref CpaCySymDpCbFunc are generated in * response to this function call (one per request). Any errors * generated during processing are reported as part of the callback * status code. * * @see * cpaCySymDpInitSession, * cpaCySymDpEnqueueOp *****************************************************************************/ CpaStatus cpaCySymDpEnqueueOpBatch(const Cpa32U numberRequests, CpaCySymDpOpData *pOpData[], const CpaBoolean performOpNow); /** ***************************************************************************** * @ingroup cpaCySymDp * Submit any previously enqueued requests to be performed now on the * symmetric cryptographic data plane API. * * @description * If any requests/operations were enqueued via calls to @ref * cpaCySymDpEnqueueOp and/or @ref cpaCySymDpEnqueueOpBatch, but with * the flag performOpNow set to @ref CPA_FALSE, then these operations * will now be submitted to the accelerator to be performed. * * See note about performance trade-offs on the @ref cpaCySymDp API. * * @context * Will not sleep. It can be executed in a context that does not * permit sleeping. * * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * No * * @param[in] instanceHandle Instance to which the requests will be * submitted. * * @retval CPA_STATUS_SUCCESS Function executed successfully. * @retval CPA_STATUS_FAIL Function failed. * @retval CPA_STATUS_RETRY Resubmit the request. * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit * the request. * @retval CPA_STATUS_UNSUPPORTED Function is not supported. * * @pre * The component has been initialized. * A cryptographic session has been previously setup using the * @ref cpaCySymDpInitSession function call. * * @post * None * * @see * cpaCySymDpEnqueueOp, cpaCySymDpEnqueueOpBatch *****************************************************************************/ CpaStatus cpaCySymDpPerformOpNow(CpaInstanceHandle instanceHandle); #ifdef __cplusplus } /* close the extern "C" { */ #endif #endif /* CPA_CY_SYM_DP_H */ diff --git a/sys/dev/qat/qat_api/qat_direct/include/icp_accel_devices.h b/sys/dev/qat/qat_api/qat_direct/include/icp_accel_devices.h index abfab512193c..395d235a367e 100644 --- a/sys/dev/qat/qat_api/qat_direct/include/icp_accel_devices.h +++ b/sys/dev/qat/qat_api/qat_direct/include/icp_accel_devices.h @@ -1,160 +1,160 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /***************************************************************************** * @file icp_accel_devices.h * * @defgroup Acceleration Driver Framework * * @ingroup icp_Adf * * @description * This is the top level header file that contains the layout of the ADF * icp_accel_dev_t structure and related macros/definitions. * It can be used to dereference the icp_accel_dev_t *passed into upper * layers. * *****************************************************************************/ #ifndef ICP_ACCEL_DEVICES_H_ #define ICP_ACCEL_DEVICES_H_ #include "cpa.h" #include "qat_utils.h" #include "adf_accel_devices.h" #define ADF_CFG_NO_INSTANCE 0xFFFFFFFF #define ICP_DC_TX_RING_0 6 #define ICP_DC_TX_RING_1 7 #define ICP_RX_RINGS_OFFSET 8 #define ICP_RINGS_PER_BANK 16 /* Number of worker threads per AE */ #define ICP_ARB_WRK_THREAD_TO_SARB 12 #define MAX_ACCEL_NAME_LEN 16 #define ADF_DEVICE_NAME_LENGTH 32 #define ADF_DEVICE_TYPE_LENGTH 8 #define ADF_CTL_DEVICE_NAME "/dev/qat_adf_ctl" /** ***************************************************************************** * @ingroup icp_AdfAccelHandle * * @description * Accelerator capabilities * *****************************************************************************/ typedef enum { ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC = 0x01, ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC = 0x02, ICP_ACCEL_CAPABILITIES_CIPHER = 0x04, ICP_ACCEL_CAPABILITIES_AUTHENTICATION = 0x08, ICP_ACCEL_CAPABILITIES_RESERVED_1 = 0x10, ICP_ACCEL_CAPABILITIES_COMPRESSION = 0x20, ICP_ACCEL_CAPABILITIES_DEPRECATED = 0x40, ICP_ACCEL_CAPABILITIES_RANDOM_NUMBER = 0x80, ICP_ACCEL_CAPABILITIES_CRYPTO_ZUC = 0x100, ICP_ACCEL_CAPABILITIES_SHA3 = 0x200, ICP_ACCEL_CAPABILITIES_KPT = 0x400, ICP_ACCEL_CAPABILITIES_RL = 0x800, ICP_ACCEL_CAPABILITIES_HKDF = 0x1000, ICP_ACCEL_CAPABILITIES_ECEDMONT = 0x2000, ICP_ACCEL_CAPABILITIES_EXT_ALGCHAIN = 0x4000, ICP_ACCEL_CAPABILITIES_SHA3_EXT = 0x8000, ICP_ACCEL_CAPABILITIES_AESGCM_SPC = 0x10000, ICP_ACCEL_CAPABILITIES_CHACHA_POLY = 0x20000, ICP_ACCEL_CAPABILITIES_SM2 = 0x40000, ICP_ACCEL_CAPABILITIES_SM3 = 0x80000, ICP_ACCEL_CAPABILITIES_SM4 = 0x100000, ICP_ACCEL_CAPABILITIES_INLINE = 0x200000, ICP_ACCEL_CAPABILITIES_CNV_INTEGRITY = 0x400000, ICP_ACCEL_CAPABILITIES_CNV_INTEGRITY64 = 0x800000, ICP_ACCEL_CAPABILITIES_LZ4_COMPRESSION = 0x1000000, ICP_ACCEL_CAPABILITIES_LZ4S_COMPRESSION = 0x2000000, ICP_ACCEL_CAPABILITIES_AES_V2 = 0x4000000, ICP_ACCEL_CAPABILITIES_KPT2 = 0x8000000, } icp_accel_capabilities_t; /** ***************************************************************************** * @ingroup icp_AdfAccelHandle * * @description * Device Configuration Data Structure * *****************************************************************************/ typedef enum device_type_e { DEVICE_UNKNOWN = 0, DEVICE_DH895XCC, DEVICE_DH895XCCVF, DEVICE_C62X, DEVICE_C62XVF, DEVICE_C3XXX, DEVICE_C3XXXVF, DEVICE_200XX, DEVICE_200XXVF, DEVICE_C4XXX, DEVICE_C4XXXVF, DEVICE_D15XX, DEVICE_D15XXVF, DEVICE_4XXX, DEVICE_4XXXVF } device_type_t; /* * Enumeration on Service Type */ typedef enum adf_service_type_s { ADF_SERVICE_CRYPTO, ADF_SERVICE_COMPRESS, ADF_SERVICE_MAX /* this is always the last one */ } adf_service_type_t; typedef struct accel_dev_s { /* Some generic information */ Cpa32U accelId; Cpa8U *pAccelName; /* Name given to accelerator */ Cpa32U aeMask; /* Acceleration Engine mask */ device_type_t deviceType; /* Device Type */ /* Device name for SAL */ char deviceName[ADF_DEVICE_NAME_LENGTH + 1]; Cpa32U accelCapabilitiesMask; /* Accelerator's capabilities mask */ Cpa32U dcExtendedFeatures; /* bit field of features */ QatUtilsAtomic usageCounter; /* Usage counter. Prevents shutting down the dev if not 0*/ Cpa32U deviceMemAvail; /* Device memory for intermediate buffers */ - /* Component specific fields - cast to relevent layer */ + /* Component specific fields - cast to relevant layer */ void *pRingInflight; /* For offload optimization */ void *pSalHandle; /* For SAL*/ void *pQatStats; /* For QATAL/SAL stats */ void *ringInfoCallBack; /* Callback for user space ring enabling */ void *pShramConstants; /* Virtual address of Shram constants page */ Cpa64U pShramConstantsDma; /* Bus address of Shram constants page */ /* Status of ADF and registered subsystems */ Cpa32U adfSubsystemStatus; /* Physical processor to which the dev is connected */ Cpa8U pkg_id; enum dev_sku_info sku; Cpa32U pciDevId; Cpa8U devFileName[ADF_DEVICE_NAME_LENGTH]; Cpa32S csrFileHdl; Cpa32S ringFileHdl; void *accel; Cpa32U maxNumBanks; Cpa32U maxNumRingsPerBank; /* pointer to dynamic instance resource manager */ void *pInstMgr; void *banks; /* banks information */ struct adf_accel_dev *accel_dev; struct accel_dev_s *pPrev; struct accel_dev_s *pNext; } icp_accel_dev_t; #endif /* ICP_ACCEL_HANDLE_H */ diff --git a/sys/dev/qat/qat_api/qat_direct/include/icp_adf_init.h b/sys/dev/qat/qat_api/qat_direct/include/icp_adf_init.h index 8c494d9445e0..67b3bdc5718f 100644 --- a/sys/dev/qat/qat_api/qat_direct/include/icp_adf_init.h +++ b/sys/dev/qat/qat_api/qat_direct/include/icp_adf_init.h @@ -1,214 +1,214 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /***************************************************************************** * @file icp_adf_init.h * * @description * This file contains the function prototype used to register a subsystem * into the Acceleration Driver Framework (ADF). * *****************************************************************************/ #ifndef ICP_ADF_INIT_H #define ICP_ADF_INIT_H #include "icp_accel_devices.h" #include "adf_kernel_types.h" #include "adf_cfg_common.h" /* * Events that will be sending to subsystem. The order of the enum * declaration matters. It should be defined so that the messages can be * sent in loop. */ typedef enum icp_adf_subsystemEvent_s { ICP_ADF_EVENT_INIT = 0, ICP_ADF_EVENT_START, ICP_ADF_EVENT_STOP, ICP_ADF_EVENT_SHUTDOWN, ICP_ADF_EVENT_RESTARING, ICP_ADF_EVENT_RESTARTED, ICP_ADF_EVENT_ERROR, ICP_ADF_EVENT_END } icp_adf_subsystemEvent_t; /* * Ring info operation used to enable or disable ring polling by ME */ typedef enum icp_adf_ringInfoOperation_e { ICP_ADF_RING_ENABLE = 0, ICP_ADF_RING_DISABLE } icp_adf_ringInfoOperation_t; /* - * Ring generic serivce info private data + * Ring generic service info private data */ typedef enum icp_adf_ringInfoService_e { ICP_ADF_RING_SERVICE_0 = 0, ICP_ADF_RING_SERVICE_1, ICP_ADF_RING_SERVICE_2, ICP_ADF_RING_SERVICE_3, ICP_ADF_RING_SERVICE_4, ICP_ADF_RING_SERVICE_5, ICP_ADF_RING_SERVICE_6, ICP_ADF_RING_SERVICE_7, ICP_ADF_RING_SERVICE_8, ICP_ADF_RING_SERVICE_9, ICP_ADF_RING_SERVICE_10, } icp_adf_ringInfoService_t; /* * Ring info callback. Function is used to send operation and ring info * to enable or disable ring polling by ME */ typedef CpaStatus (*ringInfoCb)(icp_accel_dev_t *accel_dev, Cpa32U ringNumber, icp_adf_ringInfoOperation_t operation, icp_adf_ringInfoService_t info); /* * Registration handle structure * Each subservice has to have an instance of it. */ typedef struct subservice_registation_handle_s { CpaStatus (*subserviceEventHandler)(icp_accel_dev_t *accel_dev, icp_adf_subsystemEvent_t event, void *param); struct { Cpa32U subsystemInitBit : 1; Cpa32U subsystemStartBit : 1; Cpa32U subsystemFailedBit : 1; } subsystemStatus[ADF_MAX_DEVICES]; char *subsystem_name; struct subservice_registation_handle_s *pNext; struct subservice_registation_handle_s *pPrev; } subservice_registation_handle_t; /* * icp_adf_subsystemRegister * * Description: * Function used by subsystem to register within ADF * Should be called during insertion of a subsystem * * Returns: * CPA_STATUS_SUCCESS on success * CPA_STATUS_FAIL on failure */ CpaStatus icp_adf_subsystemRegister(subservice_registation_handle_t *handle); /* * icp_adf_subsystemUnregister * * Description: * Function used by subsystem to unregister from ADF * Should be called while subsystem in removed * If the subsystem is initialised and/or started * it will be stopped and shutdown by this function * * Returns: * CPA_STATUS_SUCCESS on success * CPA_STATUS_FAIL on failure */ CpaStatus icp_adf_subsystemUnregister(subservice_registation_handle_t *handle); /* * icp_adf_accesLayerRingInfoCbRegister * * Description: * Function register access layer callback, which sends ring info message * * Returns: * CPA_STATUS_SUCCESS on success * CPA_STATUS_FAIL on failure */ CpaStatus icp_adf_accesLayerRingInfoCbRegister(icp_accel_dev_t *accel_dev, ringInfoCb); /* * icp_adf_accesLayerRingInfoCbUnregister * * Description: * Function unregister access layer callback for ring info message * * Returns: * CPA_STATUS_SUCCESS on success * CPA_STATUS_FAIL on failure */ void icp_adf_accesLayerRingInfoCbUnregister(icp_accel_dev_t *accel_dev); /* * icp_adf_isSubsystemStarted * * Description: * Function returns true if the service is started on a device * * Returns: * CPA_TRUE if subsystem is started * CPA_FALSE if subsystem is not started */ CpaBoolean icp_adf_isSubsystemStarted(subservice_registation_handle_t *subsystem_hdl); /* * icp_adf_isDevStarted * * Description: * Function returns true if the device is started * Returns: * CPA_TRUE if dev is started * CPA_FALSE if dev is not started */ CpaBoolean icp_adf_isDevStarted(icp_accel_dev_t *accel_dev); /* * adf_subsystemRestarting * * Description: * Function sends restarting event to all subsystems. * This function should be used by error handling function only * * Returns: * CPA_TRUE on success * CPA_FALSE on failure */ CpaStatus adf_subsystemRestarting(icp_accel_dev_t *accel_dev); /* * adf_subsystemRestarted * * Description: * Function sends restarted event to all subsystems. * This function should be used by error handling function only * * Returns: * CPA_TRUE on success * CPA_FALSE on failure */ CpaStatus adf_subsystemRestarted(icp_accel_dev_t *accel_dev); /* * adf_subsystemError * * Description: * Function sends error event to all subsystems. * This function should be used by error handling funct. only * * Returns: * CPA_STATUS_SUCCESS on success * CPA_STATUS_FAIL on failure */ CpaStatus adf_subsystemError(icp_accel_dev_t *accel_dev); /* * reset_adf_subsystemTable * * Description: * Function to reset subsystem table head, the pointer * to the head of the list and lock. * * Returns: void */ void reset_adf_subsystemTable(void); #endif /* ICP_ADF_INIT_H */ diff --git a/sys/dev/qat/qat_api/qat_kernel/src/lac_adf_interface_freebsd.c b/sys/dev/qat/qat_api/qat_kernel/src/lac_adf_interface_freebsd.c index b869a8eb934b..12cce62d7806 100644 --- a/sys/dev/qat/qat_api/qat_kernel/src/lac_adf_interface_freebsd.c +++ b/sys/dev/qat/qat_api/qat_kernel/src/lac_adf_interface_freebsd.c @@ -1,425 +1,425 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "adf_cfg.h" #include "cpa.h" #include "icp_accel_devices.h" #include "adf_common_drv.h" #include "icp_adf_accel_mgr.h" #include "icp_adf_cfg.h" #include "icp_adf_debug.h" #include "icp_adf_init.h" #include "lac_sal_ctrl.h" static subservice_registation_handle_t *salService = NULL; static struct service_hndl adfService = { 0 }; static icp_accel_dev_t *adfDevices = NULL; static icp_accel_dev_t *adfDevicesHead = NULL; struct mtx *adfDevicesLock; /* * Need to keep track of what device is currently in reset state */ static char accel_dev_reset_stat[ADF_MAX_DEVICES] = { 0 }; /* * Need to keep track of what device is currently in error state */ static char accel_dev_error_stat[ADF_MAX_DEVICES] = { 0 }; /* * Need to preserve sal handle during restart */ static void *accel_dev_sal_hdl_ptr[ADF_MAX_DEVICES] = { 0 }; static icp_accel_dev_t * create_adf_dev_structure(struct adf_accel_dev *accel_dev) { icp_accel_dev_t *adf = NULL; struct adf_hw_device_data *hw_data = accel_dev->hw_device; adf = malloc(sizeof(*adf), M_QAT, M_WAITOK); memset(adf, 0, sizeof(*adf)); adf->accelId = accel_dev->accel_id; adf->pAccelName = (char *)hw_data->dev_class->name; adf->deviceType = (device_type_t)hw_data->dev_class->type; strlcpy(adf->deviceName, hw_data->dev_class->name, sizeof(adf->deviceName)); adf->accelCapabilitiesMask = hw_data->accel_capabilities_mask; adf->sku = hw_data->get_sku(hw_data); adf->accel_dev = accel_dev; accel_dev->lac_dev = adf; return adf; } /* * adf_event_handler * Handle device init/uninit/start/stop event */ static CpaStatus adf_event_handler(struct adf_accel_dev *accel_dev, enum adf_event event) { CpaStatus status = CPA_STATUS_FAIL; icp_accel_dev_t *adf = NULL; if (!adf_cfg_sec_find(accel_dev, ADF_KERNEL_SAL_SEC)) { return CPA_STATUS_SUCCESS; } if (event == ADF_EVENT_INIT) { adf = create_adf_dev_structure(accel_dev); if (NULL == adf) { return CPA_STATUS_FAIL; } if (accel_dev_sal_hdl_ptr[accel_dev->accel_id]) { adf->pSalHandle = accel_dev_sal_hdl_ptr[accel_dev->accel_id]; accel_dev_sal_hdl_ptr[accel_dev->accel_id] = NULL; } qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); ICP_ADD_ELEMENT_TO_END_OF_LIST(adf, adfDevices, adfDevicesHead); qatUtilsMutexUnlock(&adfDevicesLock); } else { adf = accel_dev->lac_dev; } if (event == ADF_EVENT_START) { adf->dcExtendedFeatures = accel_dev->hw_device->extended_dc_capabilities; } if (event == ADF_EVENT_RESTARTING) { accel_dev_reset_stat[accel_dev->accel_id] = 1; accel_dev_sal_hdl_ptr[accel_dev->accel_id] = adf->pSalHandle; } if (event == ADF_EVENT_RESTARTED) { accel_dev_reset_stat[accel_dev->accel_id] = 0; accel_dev_error_stat[accel_dev->accel_id] = 0; } status = salService->subserviceEventHandler(adf, (icp_adf_subsystemEvent_t)event, NULL); if (event == ADF_EVENT_ERROR) { accel_dev_error_stat[accel_dev->accel_id] = 1; } if ((status == CPA_STATUS_SUCCESS && event == ADF_EVENT_SHUTDOWN) || (status != CPA_STATUS_SUCCESS && event == ADF_EVENT_INIT)) { qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); ICP_REMOVE_ELEMENT_FROM_LIST(adf, adfDevices, adfDevicesHead); qatUtilsMutexUnlock(&adfDevicesLock); accel_dev->lac_dev = NULL; free(adf, M_QAT); } if (status == CPA_STATUS_SUCCESS && event == ADF_EVENT_START) { qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); adf->adfSubsystemStatus = 1; qatUtilsMutexUnlock(&adfDevicesLock); } if ((status == CPA_STATUS_SUCCESS && event == ADF_EVENT_STOP) || (status == CPA_STATUS_RETRY && event == ADF_EVENT_STOP)) { qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); adf->adfSubsystemStatus = 0; qatUtilsMutexUnlock(&adfDevicesLock); status = CPA_STATUS_SUCCESS; } return status; } /* * icp_adf_subsystemRegister * adapter function from SAL to adf driver * call adf_service_register from adf driver directly with same * parameters */ CpaStatus icp_adf_subsystemRegister( subservice_registation_handle_t *sal_service_reg_handle) { if (salService != NULL) return CPA_STATUS_FAIL; salService = sal_service_reg_handle; adfService.name = sal_service_reg_handle->subsystem_name; adfService.event_hld = adf_event_handler; if (adf_service_register(&adfService) == 0) { return CPA_STATUS_SUCCESS; } else { salService = NULL; return CPA_STATUS_FAIL; } } /* * icp_adf_subsystemUnegister * adapter function from SAL to adf driver */ CpaStatus icp_adf_subsystemUnregister( subservice_registation_handle_t *sal_service_reg_handle) { if (adf_service_unregister(&adfService) == 0) { salService = NULL; return CPA_STATUS_SUCCESS; } else { return CPA_STATUS_FAIL; } } /* * icp_adf_cfgGetParamValue * get parameter value from section @section with key @param */ CpaStatus icp_adf_cfgGetParamValue(icp_accel_dev_t *adf, const char *section, const char *param, char *value) { if (adf_cfg_get_param_value(adf->accel_dev, section, param, value) == 0) { return CPA_STATUS_SUCCESS; } else { return CPA_STATUS_FAIL; } } CpaBoolean icp_adf_is_dev_in_reset(icp_accel_dev_t *accel_dev) { return (CpaBoolean)accel_dev_reset_stat[accel_dev->accelId]; } CpaStatus icp_adf_debugAddDir(icp_accel_dev_t *adf, debug_dir_info_t *dir_info) { return CPA_STATUS_SUCCESS; } void icp_adf_debugRemoveDir(debug_dir_info_t *dir_info) { } CpaStatus icp_adf_debugAddFile(icp_accel_dev_t *adf, debug_file_info_t *file_info) { return CPA_STATUS_SUCCESS; } void icp_adf_debugRemoveFile(debug_file_info_t *file_info) { } /* * icp_adf_getAccelDevByAccelId * return acceleration device with id @accelId */ icp_accel_dev_t * icp_adf_getAccelDevByAccelId(Cpa32U accelId) { icp_accel_dev_t *adf = NULL; qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); adf = adfDevicesHead; while (adf != NULL && adf->accelId != accelId) adf = adf->pNext; qatUtilsMutexUnlock(&adfDevicesLock); return adf; } /* * icp_amgr_getNumInstances * Return the number of acceleration devices it the system. */ CpaStatus icp_amgr_getNumInstances(Cpa16U *pNumInstances) { icp_accel_dev_t *adf = NULL; Cpa16U count = 0; qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); for (adf = adfDevicesHead; adf != NULL; adf = adf->pNext) count++; qatUtilsMutexUnlock(&adfDevicesLock); *pNumInstances = count; return CPA_STATUS_SUCCESS; } /* * icp_amgr_getAccelDevByCapabilities * Returns a started accel device that implements * the capabilities specified in capabilitiesMask. */ CpaStatus icp_amgr_getAccelDevByCapabilities(Cpa32U capabilitiesMask, icp_accel_dev_t **pAccel_devs, Cpa16U *pNumInstances) { icp_accel_dev_t *adf = NULL; *pNumInstances = 0; qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); for (adf = adfDevicesHead; adf != NULL; adf = adf->pNext) { if (adf->accelCapabilitiesMask & capabilitiesMask) { if (adf->adfSubsystemStatus) { pAccel_devs[0] = adf; *pNumInstances = 1; qatUtilsMutexUnlock(&adfDevicesLock); return CPA_STATUS_SUCCESS; } } } qatUtilsMutexUnlock(&adfDevicesLock); return CPA_STATUS_FAIL; } /* * icp_amgr_getAllAccelDevByEachCapabilities - * Returns table of accel devices that are started and implement - * each of the capabilities specified in capabilitiesMask. + * Returns table of accel devices that are started and that implement + * at least one of the capabilities specified in capabilitiesMask. */ CpaStatus icp_amgr_getAllAccelDevByEachCapability(Cpa32U capabilitiesMask, icp_accel_dev_t **pAccel_devs, Cpa16U *pNumInstances) { icp_accel_dev_t *adf = NULL; *pNumInstances = 0; qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); for (adf = adfDevicesHead; adf != NULL; adf = adf->pNext) { Cpa32U enabled_caps = adf->accelCapabilitiesMask & capabilitiesMask; if (enabled_caps == capabilitiesMask) { if (adf->adfSubsystemStatus) { pAccel_devs[(*pNumInstances)++] = (icp_accel_dev_t *)adf; } } } qatUtilsMutexUnlock(&adfDevicesLock); return CPA_STATUS_SUCCESS; } /* * icp_amgr_getAllAccelDevByCapabilities * Fetches accel devices based on the capability * and returns the count of the device */ CpaStatus icp_amgr_getAllAccelDevByCapabilities(Cpa32U capabilitiesMask, icp_accel_dev_t **pAccel_devs, Cpa16U *pNumInstances) { icp_accel_dev_t *adf = NULL; Cpa16U i = 0; qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); for (adf = adfDevicesHead; adf != NULL; adf = adf->pNext) { if (adf->accelCapabilitiesMask & capabilitiesMask) { if (adf->adfSubsystemStatus) { pAccel_devs[i++] = adf; } } } qatUtilsMutexUnlock(&adfDevicesLock); *pNumInstances = i; return CPA_STATUS_SUCCESS; } /* * icp_amgr_getAccelDevCapabilities * Returns accel devices capabilities specified in capabilitiesMask. * * Returns: * CPA_STATUS_SUCCESS on success * CPA_STATUS_FAIL on failure */ CpaStatus icp_amgr_getAccelDevCapabilities(icp_accel_dev_t *accel_dev, Cpa32U *pCapabilitiesMask) { ICP_CHECK_FOR_NULL_PARAM(accel_dev); ICP_CHECK_FOR_NULL_PARAM(pCapabilitiesMask); *pCapabilitiesMask = accel_dev->accelCapabilitiesMask; return CPA_STATUS_SUCCESS; } /* * icp_qa_dev_get * * Description: * Function increments the device usage counter. * * Returns: void */ void icp_qa_dev_get(icp_accel_dev_t *pDev) { ICP_CHECK_FOR_NULL_PARAM_VOID(pDev); adf_dev_get(pDev->accel_dev); } /* * icp_qa_dev_put * * Description: * Function decrements the device usage counter. * * Returns: void */ void icp_qa_dev_put(icp_accel_dev_t *pDev) { ICP_CHECK_FOR_NULL_PARAM_VOID(pDev); adf_dev_put(pDev->accel_dev); } Cpa16U icp_adf_get_busAddress(Cpa16U packageId) { Cpa16U busAddr = 0xFFFF; icp_accel_dev_t *adf = NULL; qatUtilsMutexLock(&adfDevicesLock, QAT_UTILS_WAIT_FOREVER); for (adf = adfDevicesHead; adf != NULL; adf = adf->pNext) { if (adf->accelId == packageId) { busAddr = pci_get_bus(accel_to_pci_dev(adf->accel_dev)) << 8 | pci_get_slot(accel_to_pci_dev(adf->accel_dev)) << 3 | pci_get_function(accel_to_pci_dev(adf->accel_dev)); break; } } qatUtilsMutexUnlock(&adfDevicesLock); return busAddr; } CpaBoolean icp_adf_isSubsystemStarted(subservice_registation_handle_t *subsystem_hdl) { if (subsystem_hdl == salService) return CPA_TRUE; else return CPA_FALSE; } CpaBoolean icp_adf_is_dev_in_error(icp_accel_dev_t *accel_dev) { return (CpaBoolean)accel_dev_error_stat[accel_dev->accelId]; } diff --git a/sys/dev/qat/qat_api/qat_utils/include/qat_utils.h b/sys/dev/qat/qat_api/qat_utils/include/qat_utils.h index 778be17e841a..a2dea054f753 100644 --- a/sys/dev/qat/qat_api/qat_utils/include/qat_utils.h +++ b/sys/dev/qat/qat_api/qat_utils/include/qat_utils.h @@ -1,871 +1,870 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #ifndef QAT_UTILS_H #define QAT_UTILS_H - #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __x86_64__ #include #else #include #endif #include #include #include #include #include #include #include #include #include #include #include "cpa.h" #define QAT_UTILS_LOG(...) printf("QAT: "__VA_ARGS__) #define QAT_UTILS_WAIT_FOREVER (-1) #define QAT_UTILS_WAIT_NONE 0 #define QAT_UTILS_HOST_TO_NW_16(uData) QAT_UTILS_OS_HOST_TO_NW_16(uData) #define QAT_UTILS_HOST_TO_NW_32(uData) QAT_UTILS_OS_HOST_TO_NW_32(uData) #define QAT_UTILS_HOST_TO_NW_64(uData) QAT_UTILS_OS_HOST_TO_NW_64(uData) #define QAT_UTILS_NW_TO_HOST_16(uData) QAT_UTILS_OS_NW_TO_HOST_16(uData) #define QAT_UTILS_NW_TO_HOST_32(uData) QAT_UTILS_OS_NW_TO_HOST_32(uData) #define QAT_UTILS_NW_TO_HOST_64(uData) QAT_UTILS_OS_NW_TO_HOST_64(uData) #define QAT_UTILS_UDIV64_32(dividend, divisor) \ QAT_UTILS_OS_UDIV64_32(dividend, divisor) #define QAT_UTILS_UMOD64_32(dividend, divisor) \ QAT_UTILS_OS_UMOD64_32(dividend, divisor) #define ICP_CHECK_FOR_NULL_PARAM(param) \ do { \ if (NULL == param) { \ QAT_UTILS_LOG("%s(): invalid param: %s\n", \ __FUNCTION__, \ #param); \ return CPA_STATUS_INVALID_PARAM; \ } \ } while (0) #define ICP_CHECK_FOR_NULL_PARAM_VOID(param) \ do { \ if (NULL == param) { \ QAT_UTILS_LOG("%s(): invalid param: %s\n", \ __FUNCTION__, \ #param); \ return; \ } \ } while (0) /*Macro for adding an element to the tail of a doubly linked list*/ /*The currentptr tracks the tail, and the headptr tracks the head.*/ #define ICP_ADD_ELEMENT_TO_END_OF_LIST(elementtoadd, currentptr, headptr) \ do { \ if (NULL == currentptr) { \ currentptr = elementtoadd; \ elementtoadd->pNext = NULL; \ elementtoadd->pPrev = NULL; \ headptr = currentptr; \ } else { \ elementtoadd->pPrev = currentptr; \ currentptr->pNext = elementtoadd; \ elementtoadd->pNext = NULL; \ currentptr = elementtoadd; \ } \ } while (0) /*currentptr is not used in this case since we don't track the tail. */ #define ICP_ADD_ELEMENT_TO_HEAD_OF_LIST(elementtoadd, currentptr, headptr) \ do { \ if (NULL == headptr) { \ elementtoadd->pNext = NULL; \ elementtoadd->pPrev = NULL; \ headptr = elementtoadd; \ } else { \ elementtoadd->pPrev = NULL; \ elementtoadd->pNext = headptr; \ headptr->pPrev = elementtoadd; \ headptr = elementtoadd; \ } \ } while (0) #define ICP_REMOVE_ELEMENT_FROM_LIST(elementtoremove, currentptr, headptr) \ do { \ /*If the previous pointer is not NULL*/ \ if (NULL != elementtoremove->pPrev) { \ elementtoremove->pPrev->pNext = \ elementtoremove->pNext; \ if (elementtoremove->pNext) { \ elementtoremove->pNext->pPrev = \ elementtoremove->pPrev; \ } else { \ /* Move the tail pointer backwards */ \ currentptr = elementtoremove->pPrev; \ } \ } else if (NULL != elementtoremove->pNext) { \ /*Remove the head pointer.*/ \ elementtoremove->pNext->pPrev = NULL; \ /*Hence move the head forward.*/ \ headptr = elementtoremove->pNext; \ } else { \ /*Remove the final entry in the list. */ \ currentptr = NULL; \ headptr = NULL; \ } \ } while (0) MALLOC_DECLARE(M_QAT); #ifdef __x86_64__ typedef atomic64_t QatUtilsAtomic; #else typedef atomic_t QatUtilsAtomic; #endif #define QAT_UTILS_OS_NW_TO_HOST_16(uData) be16toh(uData) #define QAT_UTILS_OS_NW_TO_HOST_32(uData) be32toh(uData) #define QAT_UTILS_OS_NW_TO_HOST_64(uData) be64toh(uData) #define QAT_UTILS_OS_HOST_TO_NW_16(uData) htobe16(uData) #define QAT_UTILS_OS_HOST_TO_NW_32(uData) htobe32(uData) #define QAT_UTILS_OS_HOST_TO_NW_64(uData) htobe64(uData) /** * @ingroup QatUtils * * @brief Atomically read the value of atomic variable * * @param pAtomicVar IN - atomic variable * * Atomically reads the value of pAtomicVar to the outValue * * @li Reentrant: yes * @li IRQ safe: yes * * @return pAtomicVar value */ int64_t qatUtilsAtomicGet(QatUtilsAtomic *pAtomicVar); /** * @ingroup QatUtils * * @brief Atomically set the value of atomic variable * * @param inValue IN - atomic variable to be set equal to inValue * * @param pAtomicVar OUT - atomic variable * * Atomically sets the value of pAtomicVar to the value given * * @li Reentrant: yes * @li IRQ safe: yes * * @return none */ void qatUtilsAtomicSet(int64_t inValue, QatUtilsAtomic *pAtomicVar); /** * @ingroup QatUtils * * @brief add the value to atomic variable * * @param inValue (in) - value to be added to the atomic variable * * @param pAtomicVar (in & out) - atomic variable * * Atomically adds the value of inValue to the pAtomicVar * * @li Reentrant: yes * @li IRQ safe: yes * * @return pAtomicVar value after the addition */ int64_t qatUtilsAtomicAdd(int64_t inValue, QatUtilsAtomic *pAtomicVar); /** * @ingroup QatUtils * * @brief subtract the value from atomic variable * * @param inValue IN - atomic variable value to be subtracted by value * * @param pAtomicVar IN/OUT - atomic variable * * Atomically subtracts the value of pAtomicVar by inValue * * @li Reentrant: yes * @li IRQ safe: yes * * @return pAtomicVar value after the subtraction */ int64_t qatUtilsAtomicSub(int64_t inValue, QatUtilsAtomic *pAtomicVar); /** * @ingroup QatUtils * * @brief increment value of atomic variable by 1 * * @param pAtomicVar IN/OUT - atomic variable * * Atomically increments the value of pAtomicVar by 1. * * @li Reentrant: yes * @li IRQ safe: yes * * @return pAtomicVar value after the increment */ int64_t qatUtilsAtomicInc(QatUtilsAtomic *pAtomicVar); /** * @ingroup QatUtils * * @brief decrement value of atomic variable by 1 * * @param pAtomicVar IN/OUT - atomic variable * * Atomically decrements the value of pAtomicVar by 1. * * @li Reentrant: yes * @li IRQ safe: yes * * @return pAtomic value after the decrement */ int64_t qatUtilsAtomicDec(QatUtilsAtomic *pAtomicVar); /** * @ingroup QatUtils * * @brief NUMA aware memory allocation; available on Linux OS only. * * @param size - memory size to allocate, in bytes * @param node - node * @param alignment - memory boundary alignment (alignment can not be 0) * * Allocates a memory zone of a given size on the specified node * The returned memory is guaraunteed to be physically contiguous if the * given size is less than 128KB and belonging to the node specified * * @li Reentrant: yes * @li IRQ safe: no * * @return Pointer to the allocated zone or NULL if the allocation failed */ void *qatUtilsMemAllocContiguousNUMA(uint32_t size, uint32_t node, uint32_t alignment); /** * @ingroup QatUtils * * @brief Frees memory allocated by qatUtilsMemAllocContigousNUMA. * * @param ptr - pointer to the memory zone * @param size - size of the pointer previously allocated * * Frees a previously allocated memory zone * * @li Reentrant: yes * @li IRQ safe: no * * @return - none */ void qatUtilsMemFreeNUMA(void *ptr); /** * @ingroup QatUtils * * @brief virtual to physical address translation * * @param virtAddr - virtual address * * Converts a virtual address into its equivalent MMU-mapped physical address * * @li Reentrant: yes * @li IRQ safe: yes * * @return Corresponding physical address */ #define QAT_UTILS_MMU_VIRT_TO_PHYS(virtAddr) \ ((uint64_t)((virtAddr) ? vtophys(virtAddr) : 0)) /** * @ingroup QatUtils * * @brief Initializes the SpinLock object * * @param pLock - Spinlock handle * * Initializes the SpinLock object. * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsLockInit(struct mtx *pLock); /** * @ingroup QatUtils * * @brief Acquires a spin lock * * @param pLock - Spinlock handle * * This routine acquires a spin lock so the * caller can synchronize access to shared data in a * multiprocessor-safe way by raising IRQL. * * @li Reentrant: yes * @li IRQ safe: yes * * @return - Returns CPA_STATUS_SUCCESS if the spinlock is acquired. Returns * CPA_STATUS_FAIL * if * spinlock handle is NULL. If spinlock is already acquired by any * other thread of execution then it tries in busy loop/spins till it * gets spinlock. */ CpaStatus qatUtilsLock(struct mtx *pLock); /** * @ingroup QatUtils * * @brief Releases the spin lock * * @param pLock - Spinlock handle * * This routine releases the spin lock which the thread had acquired * * @li Reentrant: yes * @li IRQ safe: yes * * @return - return CPA_STATUS_SUCCESS if the spinlock is released. Returns * CPA_STATUS_FAIL * if * spinlockhandle passed is NULL. */ CpaStatus qatUtilsUnlock(struct mtx *pLock); /** * @ingroup QatUtils * * @brief Destroy the spin lock object * * @param pLock - Spinlock handle * * @li Reentrant: yes * @li IRQ safe: yes * * @return - returns CPA_STATUS_SUCCESS if plock is destroyed. * returns CPA_STATUS_FAIL if plock is NULL. */ CpaStatus qatUtilsLockDestroy(struct mtx *pLock); /** * @ingroup QatUtils * * @brief Initializes a semaphore * * @param pSid - semaphore handle * @param start_value - initial semaphore value * * Initializes a semaphore object * Note: Semaphore initialization qatUtilsSemaphoreInit API must be called * first before using any QAT Utils Semaphore APIs * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsSemaphoreInit(struct sema **pSid, uint32_t start_value); /** * @ingroup QatUtils * * @brief Destroys a semaphore object * * @param pSid - semaphore handle * * Destroys a semaphore object; the caller should ensure that no thread is * blocked on this semaphore. If call made when thread blocked on semaphore the * behaviour is unpredictable * * @li Reentrant: yes ] * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsSemaphoreDestroy(struct sema **pSid); /** * @ingroup QatUtils * * @brief Waits on (decrements) a semaphore * * @param pSid - semaphore handle * @param timeout - timeout, in ms; QAT_UTILS_WAIT_FOREVER (-1) if the thread * is to block indefinitely or QAT_UTILS_WAIT_NONE (0) if the thread is to * return immediately even if the call fails * * Decrements a semaphore, blocking if the semaphore is * unavailable (value is 0). * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsSemaphoreWait(struct sema **pSid, int32_t timeout); /** * @ingroup QatUtils * * @brief Non-blocking wait on semaphore * * @param semaphore - semaphore handle * * Decrements a semaphore, not blocking the calling thread if the semaphore * is unavailable * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsSemaphoreTryWait(struct sema **semaphore); /** * @ingroup QatUtils * * @brief Posts to (increments) a semaphore * * @param pSid - semaphore handle * * Increments a semaphore object * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsSemaphorePost(struct sema **pSid); /** * @ingroup QatUtils * * @brief initializes a pMutex * * @param pMutex - pMutex handle * * Initializes a pMutex object * @note Mutex initialization qatUtilsMutexInit API must be called * first before using any QAT Utils Mutex APIs * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsMutexInit(struct mtx **pMutex); /** * @ingroup QatUtils * * @brief locks a pMutex * * @param pMutex - pMutex handle * @param timeout - timeout in ms; QAT_UTILS_WAIT_FOREVER (-1) to wait forever * or QAT_UTILS_WAIT_NONE to return immediately * * Locks a pMutex object * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsMutexLock(struct mtx **pMutex, int32_t timeout); /** * @ingroup QatUtils * * @brief Unlocks a pMutex * * @param pMutex - pMutex handle * * Unlocks a pMutex object * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsMutexUnlock(struct mtx **pMutex); /** * @ingroup QatUtils * * @brief Destroys a pMutex object * * @param pMutex - pMutex handle * * Destroys a pMutex object; the caller should ensure that no thread is * blocked on this pMutex. If call made when thread blocked on pMutex the * behaviour is unpredictable * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsMutexDestroy(struct mtx **pMutex); /** * @ingroup QatUtils * * @brief Non-blocking attempt to lock a pMutex * * @param pMutex - pMutex handle * * Attempts to lock a pMutex object, returning immediately with * CPA_STATUS_SUCCESS if * the lock was successful or CPA_STATUS_FAIL if the lock failed * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsMutexTryLock(struct mtx **pMutex); /** * @ingroup QatUtils * * @brief Yielding sleep for a number of milliseconds * * @param milliseconds - number of milliseconds to sleep * * The calling thread will sleep for the specified number of milliseconds. * This sleep is yielding, hence other tasks will be scheduled by the * operating system during the sleep period. Calling this function with an * argument of 0 will place the thread at the end of the current scheduling * loop. * * @li Reentrant: yes * @li IRQ safe: no * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL */ CpaStatus qatUtilsSleep(uint32_t milliseconds); /** * @ingroup QatUtils * * @brief Yields execution of current thread * * Yields the execution of the current thread * * @li Reentrant: yes * @li IRQ safe: no * * @return - none */ void qatUtilsYield(void); /** * @ingroup QatUtils * * @brief Calculate MD5 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least md5 block size long as defined in * rfc1321 (64 bytes) * out - output pointer for state data after single md5 transform * operation. * The buffer needs to be at least md5 state size long as defined in * rfc1321 (16 bytes) * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashMD5(uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Calculate MD5 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least md5 block size long as defined in * rfc1321 (64 bytes) * out - output pointer for state data after single md5 transform * operation. * The buffer needs to be at least md5 state size long as defined in * rfc1321 (16 bytes) * len - Length on the input to be processed. * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashMD5Full(uint8_t *in, uint8_t *out, uint32_t len); /** * @ingroup QatUtils * * @brief Calculate SHA1 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha1 block size long as defined in * rfc3174 (64 bytes) * out - output pointer for state data after single sha1 transform * operation. * The buffer needs to be at least sha1 state size long as defined in * rfc3174 (20 bytes) * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA1(uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Calculate SHA1 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha1 block size long as defined in * rfc3174 (64 bytes) * out - output pointer for state data after single sha1 transform * operation. * The buffer needs to be at least sha1 state size long as defined in * rfc3174 (20 bytes) * len - Length on the input to be processed. * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA1Full(uint8_t *in, uint8_t *out, uint32_t len); /** * @ingroup QatUtils * * @brief Calculate SHA224 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha224 block size long as defined in * rfc3874 and rfc4868 (64 bytes) * out - output pointer for state data after single sha224 transform * operation. * The buffer needs to be at least sha224 state size long as defined in * rfc3874 and rfc4868 (32 bytes) * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA224(uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Calculate SHA256 transform operation * * * @param in - pointer to data to be processed. * The buffer needs to be at least sha256 block size long as defined in * rfc4868 (64 bytes) * out - output pointer for state data after single sha256 transform * operation. * The buffer needs to be at least sha256 state size long as defined in * rfc4868 (32 bytes) * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA256(uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Calculate SHA256 transform operation * * * @param in - pointer to data to be processed. * The buffer needs to be at least sha256 block size long as defined in * rfc4868 (64 bytes) * out - output pointer for state data after single sha256 transform * operation. * The buffer needs to be at least sha256 state size long as defined in * rfc4868 (32 bytes) * len - Length on the input to be processed. * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA256Full(uint8_t *in, uint8_t *out, uint32_t len); /** * @ingroup QatUtils * * @brief Calculate SHA384 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha384 block size long as defined in * rfc4868 (128 bytes) * out - output pointer for state data after single sha384 transform * operation. * The buffer needs to be at least sha384 state size long as defined in * rfc4868 (64 bytes) * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA384(uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Calculate SHA384 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha384 block size long as defined in * rfc4868 (128 bytes) * out - output pointer for state data after single sha384 transform * operation. * The buffer needs to be at least sha384 state size long as defined in * rfc4868 (64 bytes) * len - Length on the input to be processed. * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA384Full(uint8_t *in, uint8_t *out, uint32_t len); /** * @ingroup QatUtils * * @brief Calculate SHA512 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha512 block size long as defined in * rfc4868 (128 bytes) * out - output pointer for state data after single sha512 transform * operation. * The buffer needs to be at least sha512 state size long as defined in * rfc4868 (64 bytes) * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA512(uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Calculate SHA512 transform operation * * @param in - pointer to data to be processed. * The buffer needs to be at least sha512 block size long as defined in * rfc4868 (128 bytes) * out - output pointer for state data after single sha512 transform * operation. * The buffer needs to be at least sha512 state size long as defined in * rfc4868 (64 bytes) * len - Length on the input to be processed. * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsHashSHA512Full(uint8_t *in, uint8_t *out, uint32_t len); /** * @ingroup QatUtils * * @brief Single block AES encrypt * - * @param key - pointer to symetric key. + * @param key - pointer to symmetric key. * keyLenInBytes - key length * in - pointer to data to encrypt * out - pointer to output buffer for encrypted text * The in and out buffers need to be at least AES block size long * as defined in rfc3686 (16 bytes) * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsAESEncrypt(uint8_t *key, uint32_t keyLenInBytes, uint8_t *in, uint8_t *out); /** * @ingroup QatUtils * * @brief Converts AES forward key to reverse key * - * @param key - pointer to symetric key. + * @param key - pointer to symmetric key. * keyLenInBytes - key length * out - pointer to output buffer for reversed key * The in and out buffers need to be at least AES block size long * as defined in rfc3686 (16 bytes) * * @li Reentrant: yes * @li IRQ safe: yes * * @return - CPA_STATUS_SUCCESS/CPA_STATUS_FAIL * */ CpaStatus qatUtilsAESKeyExpansionForward(uint8_t *key, uint32_t keyLenInBytes, uint32_t *out); #endif diff --git a/sys/dev/qat/qat_api/qat_utils/src/QatUtilsServices.c b/sys/dev/qat/qat_api/qat_utils/src/QatUtilsServices.c index 3134c2d375eb..f30b4b036f42 100644 --- a/sys/dev/qat/qat_api/qat_utils/src/QatUtilsServices.c +++ b/sys/dev/qat/qat_api/qat_utils/src/QatUtilsServices.c @@ -1,112 +1,112 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_utils.h" #include #include #include #include #include #include #include #include #include #include #include /** * * @brief Private data structure * * Data struct to store the information on the * memory allocated. This structure is stored at the beginning of - * the allocated chunck of memory + * the allocated chunk of memory * size is the no of byte passed to the memory allocation functions * mSize is the real size of the memory required to the OS * * +----------------------------+--------------------------------+ * | QatUtilsMemAllocInfoStruct | memory returned to user (size) | * +----------------------------+--------------------------------+ * ^ ^ * mAllocMemPtr Ptr returned to the caller of MemAlloc* * */ typedef struct _QatUtilsMemAllocInfoStruct { void *mAllocMemPtr; /* memory addr returned by the kernel */ uint32_t mSize; /* allocated size */ } QatUtilsMemAllocInfoStruct; /************************************** * Memory functions *************************************/ void * qatUtilsMemAllocContiguousNUMA(uint32_t size, uint32_t node, uint32_t alignment) { void *ptr = NULL; void *pRet = NULL; uint32_t alignment_offset = 0; QatUtilsMemAllocInfoStruct memInfo = { 0 }; if (size == 0 || alignment < 1) { QAT_UTILS_LOG( "QatUtilsMemAllocNUMA: size or alignment are zero.\n"); return NULL; } if (alignment & (alignment - 1)) { QAT_UTILS_LOG( "QatUtilsMemAllocNUMA: Expecting alignment of a power.\n"); return NULL; } memInfo.mSize = size + alignment + sizeof(QatUtilsMemAllocInfoStruct); ptr = contigmalloc(memInfo.mSize, M_QAT, M_WAITOK, 0, ~1UL, 64, 0); memInfo.mAllocMemPtr = ptr; pRet = (char *)memInfo.mAllocMemPtr + sizeof(QatUtilsMemAllocInfoStruct); #ifdef __x86_64__ alignment_offset = (uint64_t)pRet % alignment; #else alignment_offset = (uint32_t)pRet % alignment; #endif pRet = (char *)pRet + (alignment - alignment_offset); memcpy(((char *)pRet) - sizeof(QatUtilsMemAllocInfoStruct), &memInfo, sizeof(QatUtilsMemAllocInfoStruct)); return pRet; } void qatUtilsMemFreeNUMA(void *ptr) { QatUtilsMemAllocInfoStruct *memInfo = NULL; memInfo = (QatUtilsMemAllocInfoStruct *)((int8_t *)ptr - sizeof(QatUtilsMemAllocInfoStruct)); if (memInfo->mSize == 0 || memInfo->mAllocMemPtr == NULL) { QAT_UTILS_LOG( "QatUtilsMemAlignedFree: Detected corrupted data: memory leak!\n"); return; } contigfree(memInfo->mAllocMemPtr, memInfo->mSize, M_QAT); } CpaStatus qatUtilsSleep(uint32_t milliseconds) { if (milliseconds != 0) { pause("qatUtils sleep", milliseconds * hz / (1000)); } else { sched_relinquish(curthread); } return CPA_STATUS_SUCCESS; } void qatUtilsYield(void) { sched_relinquish(curthread); } diff --git a/sys/dev/qat/qat_common/qat_uclo.c b/sys/dev/qat/qat_common/qat_uclo.c index faf3154e80b8..2f4556fc71d5 100644 --- a/sys/dev/qat/qat_common/qat_uclo.c +++ b/sys/dev/qat/qat_common/qat_uclo.c @@ -1,2413 +1,2414 @@ /* SPDX-License-Identifier: BSD-3-Clause */ /* Copyright(c) 2007-2022 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" #include "adf_accel_devices.h" #include "icp_qat_uclo.h" #include "icp_qat_fw.h" #include "icp_qat_fw_init_admin.h" #include "adf_cfg_strings.h" #include "adf_transport_access_macros.h" #include "adf_transport_internal.h" #include #include #include #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "icp_qat_uclo.h" #include "icp_qat_hal.h" #include "icp_qat_fw_loader_handle.h" #define UWORD_CPYBUF_SIZE 1024 #define INVLD_UWORD 0xffffffffffull #define PID_MINOR_REV 0xf #define PID_MAJOR_REV (0xf << 4) #define MAX_UINT32_VAL 0xfffffffful static int qat_uclo_init_ae_data(struct icp_qat_uclo_objhandle *obj_handle, unsigned int ae, unsigned int image_num) { struct icp_qat_uclo_aedata *ae_data; struct icp_qat_uclo_encapme *encap_image; struct icp_qat_uclo_page *page = NULL; struct icp_qat_uclo_aeslice *ae_slice = NULL; ae_data = &obj_handle->ae_data[ae]; encap_image = &obj_handle->ae_uimage[image_num]; ae_slice = &ae_data->ae_slices[ae_data->slice_num]; ae_slice->encap_image = encap_image; if (encap_image->img_ptr) { ae_slice->ctx_mask_assigned = encap_image->img_ptr->ctx_assigned; ae_data->shareable_ustore = ICP_QAT_SHARED_USTORE_MODE(encap_image->img_ptr->ae_mode); if (obj_handle->prod_type == ICP_QAT_AC_4XXX_A_DEV_TYPE) ae_data->eff_ustore_size = obj_handle->ustore_phy_size; else { ae_data->eff_ustore_size = ae_data->shareable_ustore ? (obj_handle->ustore_phy_size << 1) : obj_handle->ustore_phy_size; } } else { ae_slice->ctx_mask_assigned = 0; } ae_slice->region = malloc(sizeof(*ae_slice->region), M_QAT, M_WAITOK | M_ZERO); ae_slice->page = malloc(sizeof(*ae_slice->page), M_QAT, M_WAITOK | M_ZERO); page = ae_slice->page; page->encap_page = encap_image->page; ae_slice->page->region = ae_slice->region; ae_data->slice_num++; return 0; } static int qat_uclo_free_ae_data(struct icp_qat_uclo_aedata *ae_data) { unsigned int i; if (!ae_data) { pr_err("QAT: bad argument, ae_data is NULL\n "); return EINVAL; } for (i = 0; i < ae_data->slice_num; i++) { free(ae_data->ae_slices[i].region, M_QAT); ae_data->ae_slices[i].region = NULL; free(ae_data->ae_slices[i].page, M_QAT); ae_data->ae_slices[i].page = NULL; } return 0; } static char * qat_uclo_get_string(struct icp_qat_uof_strtable *str_table, unsigned int str_offset) { if (!str_table->table_len || str_offset > str_table->table_len) return NULL; return (char *)(((uintptr_t)(str_table->strings)) + str_offset); } static int qat_uclo_check_uof_format(struct icp_qat_uof_filehdr *hdr) { int maj = hdr->maj_ver & 0xff; int min = hdr->min_ver & 0xff; if (hdr->file_id != ICP_QAT_UOF_FID) { pr_err("QAT: Invalid header 0x%x\n", hdr->file_id); return EINVAL; } if (min != ICP_QAT_UOF_MINVER || maj != ICP_QAT_UOF_MAJVER) { pr_err("QAT: bad UOF version, major 0x%x, minor 0x%x\n", maj, min); return EINVAL; } return 0; } static int qat_uclo_check_suof_format(const struct icp_qat_suof_filehdr *suof_hdr) { int maj = suof_hdr->maj_ver & 0xff; int min = suof_hdr->min_ver & 0xff; if (suof_hdr->file_id != ICP_QAT_SUOF_FID) { pr_err("QAT: invalid header 0x%x\n", suof_hdr->file_id); return EINVAL; } if (suof_hdr->fw_type != 0) { pr_err("QAT: unsupported firmware type\n"); return EINVAL; } if (suof_hdr->num_chunks <= 0x1) { pr_err("QAT: SUOF chunk amount is incorrect\n"); return EINVAL; } if (maj != ICP_QAT_SUOF_MAJVER || min != ICP_QAT_SUOF_MINVER) { pr_err("QAT: bad SUOF version, major 0x%x, minor 0x%x\n", maj, min); return EINVAL; } return 0; } static int qat_uclo_wr_sram_by_words(struct icp_qat_fw_loader_handle *handle, unsigned int addr, const unsigned int *val, unsigned int num_in_bytes) { unsigned int outval; const unsigned char *ptr = (const unsigned char *)val; if (num_in_bytes > handle->hal_sram_size) { pr_err("QAT: error, mmp size overflow %d\n", num_in_bytes); return EINVAL; } while (num_in_bytes) { memcpy(&outval, ptr, 4); SRAM_WRITE(handle, addr, outval); num_in_bytes -= 4; ptr += 4; addr += 4; } return 0; } static void qat_uclo_wr_umem_by_words(struct icp_qat_fw_loader_handle *handle, unsigned char ae, unsigned int addr, unsigned int *val, unsigned int num_in_bytes) { unsigned int outval; unsigned char *ptr = (unsigned char *)val; addr >>= 0x2; /* convert to uword address */ while (num_in_bytes) { memcpy(&outval, ptr, 4); qat_hal_wr_umem(handle, ae, addr++, 1, &outval); num_in_bytes -= 4; ptr += 4; } } static void qat_uclo_batch_wr_umem(struct icp_qat_fw_loader_handle *handle, unsigned char ae, struct icp_qat_uof_batch_init *umem_init_header) { struct icp_qat_uof_batch_init *umem_init; if (!umem_init_header) return; umem_init = umem_init_header->next; while (umem_init) { unsigned int addr, *value, size; ae = umem_init->ae; addr = umem_init->addr; value = umem_init->value; size = umem_init->size; qat_uclo_wr_umem_by_words(handle, ae, addr, value, size); umem_init = umem_init->next; } } static void qat_uclo_cleanup_batch_init_list(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_batch_init **base) { struct icp_qat_uof_batch_init *umem_init; umem_init = *base; while (umem_init) { struct icp_qat_uof_batch_init *pre; pre = umem_init; umem_init = umem_init->next; free(pre, M_QAT); } *base = NULL; } static int qat_uclo_parse_num(char *str, unsigned int *num) { char buf[16] = { 0 }; unsigned long ae = 0; int i; strncpy(buf, str, 15); for (i = 0; i < 16; i++) { if (!isdigit(buf[i])) { buf[i] = '\0'; break; } } if ((compat_strtoul(buf, 10, &ae))) return EFAULT; if (ae > MAX_UINT32_VAL) return EFAULT; *num = (unsigned int)ae; return 0; } static int qat_uclo_fetch_initmem_ae(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_initmem *init_mem, unsigned int size_range, unsigned int *ae) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; char *str; if ((init_mem->addr + init_mem->num_in_bytes) > (size_range << 0x2)) { pr_err("QAT: initmem is out of range"); return EINVAL; } if (init_mem->scope != ICP_QAT_UOF_LOCAL_SCOPE) { pr_err("QAT: Memory scope for init_mem error\n"); return EINVAL; } str = qat_uclo_get_string(&obj_handle->str_table, init_mem->sym_name); if (!str) { pr_err("QAT: AE name assigned in UOF init table is NULL\n"); return EINVAL; } if (qat_uclo_parse_num(str, ae)) { pr_err("QAT: Parse num for AE number failed\n"); return EINVAL; } if (*ae >= ICP_QAT_UCLO_MAX_AE) { pr_err("QAT: ae %d out of range\n", *ae); return EINVAL; } return 0; } static int qat_uclo_create_batch_init_list(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_initmem *init_mem, unsigned int ae, struct icp_qat_uof_batch_init **init_tab_base) { struct icp_qat_uof_batch_init *init_header, *tail; struct icp_qat_uof_batch_init *mem_init, *tail_old; struct icp_qat_uof_memvar_attr *mem_val_attr; unsigned int i = 0; mem_val_attr = (struct icp_qat_uof_memvar_attr *)((uintptr_t)init_mem + sizeof( struct icp_qat_uof_initmem)); init_header = *init_tab_base; if (!init_header) { init_header = malloc(sizeof(*init_header), M_QAT, M_WAITOK | M_ZERO); init_header->size = 1; *init_tab_base = init_header; } tail_old = init_header; while (tail_old->next) tail_old = tail_old->next; tail = tail_old; for (i = 0; i < init_mem->val_attr_num; i++) { mem_init = malloc(sizeof(*mem_init), M_QAT, M_WAITOK | M_ZERO); mem_init->ae = ae; mem_init->addr = init_mem->addr + mem_val_attr->offset_in_byte; mem_init->value = &mem_val_attr->value; mem_init->size = 4; mem_init->next = NULL; tail->next = mem_init; tail = mem_init; init_header->size += qat_hal_get_ins_num(); mem_val_attr++; } return 0; } static int qat_uclo_init_lmem_seg(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_initmem *init_mem) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int ae; unsigned int lmem; lmem = IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev))) ? ICP_QAT_UCLO_MAX_LMEM_REG_2X : ICP_QAT_UCLO_MAX_LMEM_REG; if (qat_uclo_fetch_initmem_ae(handle, init_mem, lmem, &ae)) return EINVAL; if (qat_uclo_create_batch_init_list( handle, init_mem, ae, &obj_handle->lm_init_tab[ae])) return EINVAL; return 0; } static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_initmem *init_mem) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int ae, ustore_size, uaddr, i; struct icp_qat_uclo_aedata *aed; ustore_size = obj_handle->ustore_phy_size; if (qat_uclo_fetch_initmem_ae(handle, init_mem, ustore_size, &ae)) return EINVAL; if (qat_uclo_create_batch_init_list( handle, init_mem, ae, &obj_handle->umem_init_tab[ae])) return EINVAL; /* set the highest ustore address referenced */ uaddr = (init_mem->addr + init_mem->num_in_bytes) >> 0x2; aed = &obj_handle->ae_data[ae]; for (i = 0; i < aed->slice_num; i++) { if (aed->ae_slices[i].encap_image->uwords_num < uaddr) aed->ae_slices[i].encap_image->uwords_num = uaddr; } return 0; } #define ICP_DH895XCC_PESRAM_BAR_SIZE 0x80000 static int qat_uclo_init_ae_memory(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_initmem *init_mem) { switch (init_mem->region) { case ICP_QAT_UOF_LMEM_REGION: if (qat_uclo_init_lmem_seg(handle, init_mem)) return EINVAL; break; case ICP_QAT_UOF_UMEM_REGION: if (qat_uclo_init_umem_seg(handle, init_mem)) return EINVAL; break; default: pr_err("QAT: initmem region error. region type=0x%x\n", init_mem->region); return EINVAL; } return 0; } static int qat_uclo_init_ustore(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uclo_encapme *image) { unsigned int i; struct icp_qat_uclo_encap_page *page; struct icp_qat_uof_image *uof_image; unsigned char ae = 0; unsigned char neigh_ae; unsigned int ustore_size; unsigned int patt_pos; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; uint64_t *fill_data; static unsigned int init[32] = { 0 }; unsigned long ae_mask = handle->hal_handle->ae_mask; uof_image = image->img_ptr; /*if shared CS mode, the ustore size should be 2*ustore_phy_size*/ fill_data = malloc(obj_handle->ustore_phy_size * 2 * sizeof(uint64_t), M_QAT, M_WAITOK | M_ZERO); for (i = 0; i < obj_handle->ustore_phy_size * 2; i++) memcpy(&fill_data[i], &uof_image->fill_pattern, sizeof(uint64_t)); page = image->page; for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) { unsigned long cfg_ae_mask = handle->cfg_ae_mask; unsigned long ae_assigned = uof_image->ae_assigned; const bool gen4 = IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev))); if (!test_bit(ae, &cfg_ae_mask)) continue; if (!test_bit(ae, &ae_assigned)) continue; if (obj_handle->ae_data[ae].shareable_ustore && (ae & 1) && !gen4) { qat_hal_get_scs_neigh_ae(ae, &neigh_ae); if (test_bit(neigh_ae, &ae_assigned)) continue; } ustore_size = obj_handle->ae_data[ae].eff_ustore_size; patt_pos = page->beg_addr_p + page->micro_words_num; if (obj_handle->ae_data[ae].shareable_ustore && !gen4) { qat_hal_get_scs_neigh_ae(ae, &neigh_ae); if (init[ae] == 0 && page->beg_addr_p != 0) { qat_hal_wr_coalesce_uwords(handle, (unsigned char)ae, 0, page->beg_addr_p, &fill_data[0]); } qat_hal_wr_coalesce_uwords( handle, (unsigned char)ae, patt_pos, ustore_size - patt_pos, &fill_data[page->beg_addr_p]); init[ae] = 1; init[neigh_ae] = 1; } else { if (gen4 && (ae % 4 != 0)) continue; qat_hal_wr_uwords(handle, (unsigned char)ae, 0, page->beg_addr_p, &fill_data[0]); qat_hal_wr_uwords(handle, (unsigned char)ae, patt_pos, ustore_size - patt_pos + 1, &fill_data[page->beg_addr_p]); } } free(fill_data, M_QAT); return 0; } static int qat_uclo_init_memory(struct icp_qat_fw_loader_handle *handle) { int i; int ae = 0; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; struct icp_qat_uof_initmem *initmem = obj_handle->init_mem_tab.init_mem; unsigned long ae_mask = handle->hal_handle->ae_mask; for (i = 0; i < obj_handle->init_mem_tab.entry_num; i++) { if (initmem->num_in_bytes) { if (qat_uclo_init_ae_memory(handle, initmem)) return EINVAL; } initmem = (struct icp_qat_uof_initmem *)((uintptr_t)((uintptr_t)initmem + sizeof(struct icp_qat_uof_initmem)) + (sizeof(struct icp_qat_uof_memvar_attr) * initmem->val_attr_num)); } for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) { if (qat_hal_batch_wr_lm(handle, ae, obj_handle->lm_init_tab[ae])) { pr_err("QAT: fail to batch init lmem for AE %d\n", ae); return EINVAL; } qat_uclo_cleanup_batch_init_list(handle, &obj_handle->lm_init_tab[ae]); qat_uclo_batch_wr_umem(handle, ae, obj_handle->umem_init_tab[ae]); qat_uclo_cleanup_batch_init_list( handle, &obj_handle->umem_init_tab[ae]); } return 0; } static void * qat_uclo_find_chunk(struct icp_qat_uof_objhdr *obj_hdr, char *chunk_id, void *cur) { int i; struct icp_qat_uof_chunkhdr *chunk_hdr = (struct icp_qat_uof_chunkhdr *)((uintptr_t)obj_hdr + sizeof(struct icp_qat_uof_objhdr)); for (i = 0; i < obj_hdr->num_chunks; i++) { if ((cur < (void *)&chunk_hdr[i]) && !strncmp(chunk_hdr[i].chunk_id, chunk_id, ICP_QAT_UOF_OBJID_LEN)) { return &chunk_hdr[i]; } } return NULL; } static unsigned int qat_uclo_calc_checksum(unsigned int reg, int ch) { int i; unsigned int topbit = 1 << 0xF; unsigned int inbyte = (unsigned int)((reg >> 0x18) ^ ch); reg ^= inbyte << 0x8; for (i = 0; i < 0x8; i++) { if (reg & topbit) reg = (reg << 1) ^ 0x1021; else reg <<= 1; } return reg & 0xFFFF; } static unsigned int qat_uclo_calc_str_checksum(const char *ptr, int num) { unsigned int chksum = 0; if (ptr) while (num--) chksum = qat_uclo_calc_checksum(chksum, *ptr++); return chksum; } static struct icp_qat_uclo_objhdr * qat_uclo_map_chunk(char *buf, struct icp_qat_uof_filehdr *file_hdr, char *chunk_id) { struct icp_qat_uof_filechunkhdr *file_chunk; struct icp_qat_uclo_objhdr *obj_hdr; char *chunk; int i; file_chunk = (struct icp_qat_uof_filechunkhdr *)(buf + sizeof(struct icp_qat_uof_filehdr)); for (i = 0; i < file_hdr->num_chunks; i++) { if (!strncmp(file_chunk->chunk_id, chunk_id, ICP_QAT_UOF_OBJID_LEN)) { chunk = buf + file_chunk->offset; if (file_chunk->checksum != qat_uclo_calc_str_checksum(chunk, file_chunk->size)) break; obj_hdr = malloc(sizeof(*obj_hdr), M_QAT, M_WAITOK | M_ZERO); obj_hdr->file_buff = chunk; obj_hdr->checksum = file_chunk->checksum; obj_hdr->size = file_chunk->size; return obj_hdr; } file_chunk++; } return NULL; } static unsigned int qat_uclo_check_image_compat(struct icp_qat_uof_encap_obj *encap_uof_obj, struct icp_qat_uof_image *image) { struct icp_qat_uof_objtable *uc_var_tab, *imp_var_tab, *imp_expr_tab; struct icp_qat_uof_objtable *neigh_reg_tab; struct icp_qat_uof_code_page *code_page; code_page = (struct icp_qat_uof_code_page *)((char *)image + sizeof(struct icp_qat_uof_image)); uc_var_tab = (struct icp_qat_uof_objtable *)(encap_uof_obj->beg_uof + code_page->uc_var_tab_offset); imp_var_tab = (struct icp_qat_uof_objtable *)(encap_uof_obj->beg_uof + code_page->imp_var_tab_offset); imp_expr_tab = (struct icp_qat_uof_objtable *)(encap_uof_obj->beg_uof + code_page->imp_expr_tab_offset); if (uc_var_tab->entry_num || imp_var_tab->entry_num || imp_expr_tab->entry_num) { pr_err("QAT: UOF can't contain imported variable to be parsed"); return EINVAL; } neigh_reg_tab = (struct icp_qat_uof_objtable *)(encap_uof_obj->beg_uof + code_page->neigh_reg_tab_offset); if (neigh_reg_tab->entry_num) { pr_err("QAT: UOF can't contain neighbor register table\n"); return EINVAL; } if (image->numpages > 1) { pr_err("QAT: UOF can't contain multiple pages\n"); return EINVAL; } if (RELOADABLE_CTX_SHARED_MODE(image->ae_mode)) { pr_err("QAT: UOF can't use reloadable feature\n"); return EFAULT; } return 0; } static void qat_uclo_map_image_page(struct icp_qat_uof_encap_obj *encap_uof_obj, struct icp_qat_uof_image *img, struct icp_qat_uclo_encap_page *page) { struct icp_qat_uof_code_page *code_page; struct icp_qat_uof_code_area *code_area; struct icp_qat_uof_objtable *uword_block_tab; struct icp_qat_uof_uword_block *uwblock; int i; code_page = (struct icp_qat_uof_code_page *)((char *)img + sizeof(struct icp_qat_uof_image)); page->def_page = code_page->def_page; page->page_region = code_page->page_region; page->beg_addr_v = code_page->beg_addr_v; page->beg_addr_p = code_page->beg_addr_p; code_area = (struct icp_qat_uof_code_area *)(encap_uof_obj->beg_uof + code_page->code_area_offset); page->micro_words_num = code_area->micro_words_num; uword_block_tab = (struct icp_qat_uof_objtable *)(encap_uof_obj->beg_uof + code_area->uword_block_tab); page->uwblock_num = uword_block_tab->entry_num; uwblock = (struct icp_qat_uof_uword_block *)((char *)uword_block_tab + sizeof(struct icp_qat_uof_objtable)); page->uwblock = (struct icp_qat_uclo_encap_uwblock *)uwblock; for (i = 0; i < uword_block_tab->entry_num; i++) page->uwblock[i].micro_words = (uintptr_t)encap_uof_obj->beg_uof + uwblock[i].uword_offset; } static int qat_uclo_map_uimage(struct icp_qat_uclo_objhandle *obj_handle, struct icp_qat_uclo_encapme *ae_uimage, int max_image) { int i, j; struct icp_qat_uof_chunkhdr *chunk_hdr = NULL; struct icp_qat_uof_image *image; struct icp_qat_uof_objtable *ae_regtab; struct icp_qat_uof_objtable *init_reg_sym_tab; struct icp_qat_uof_objtable *sbreak_tab; struct icp_qat_uof_encap_obj *encap_uof_obj = &obj_handle->encap_uof_obj; for (j = 0; j < max_image; j++) { chunk_hdr = qat_uclo_find_chunk(encap_uof_obj->obj_hdr, ICP_QAT_UOF_IMAG, chunk_hdr); if (!chunk_hdr) break; image = (struct icp_qat_uof_image *)(encap_uof_obj->beg_uof + chunk_hdr->offset); ae_regtab = (struct icp_qat_uof_objtable *)(image->reg_tab_offset + obj_handle->obj_hdr ->file_buff); ae_uimage[j].ae_reg_num = ae_regtab->entry_num; ae_uimage[j].ae_reg = (struct icp_qat_uof_ae_reg *)(((char *)ae_regtab) + sizeof(struct icp_qat_uof_objtable)); init_reg_sym_tab = (struct icp_qat_uof_objtable *)(image->init_reg_sym_tab + obj_handle->obj_hdr ->file_buff); ae_uimage[j].init_regsym_num = init_reg_sym_tab->entry_num; ae_uimage[j].init_regsym = (struct icp_qat_uof_init_regsym *)(((char *)init_reg_sym_tab) + sizeof(struct icp_qat_uof_objtable)); sbreak_tab = (struct icp_qat_uof_objtable *)(image->sbreak_tab + obj_handle->obj_hdr ->file_buff); ae_uimage[j].sbreak_num = sbreak_tab->entry_num; ae_uimage[j].sbreak = (struct icp_qat_uof_sbreak *)(((char *)sbreak_tab) + sizeof(struct icp_qat_uof_objtable)); ae_uimage[j].img_ptr = image; if (qat_uclo_check_image_compat(encap_uof_obj, image)) goto out_err; ae_uimage[j].page = malloc(sizeof(struct icp_qat_uclo_encap_page), M_QAT, M_WAITOK | M_ZERO); qat_uclo_map_image_page(encap_uof_obj, image, ae_uimage[j].page); } return j; out_err: for (i = 0; i < j; i++) free(ae_uimage[i].page, M_QAT); return 0; } static int UcLo_checkTGroupList2X(struct icp_qat_fw_loader_handle *handle) { int i; unsigned int swAe = 0; unsigned int ii, jj; struct icp_qat_uclo_aedata *ae_data0, *ae_datax; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; for (i = 0; i < obj_handle->uimage_num; i++) { struct icp_qat_uof_image *image = obj_handle->ae_uimage[i].img_ptr; if (image->numpages > 1) { pr_err( "Only 1 page is allowed in a UOF for CPM2X; We found %d in %s\n", image->numpages, qat_uclo_get_string(&obj_handle->str_table, image->img_name)); return EINVAL; } } for (swAe = 0; (swAe < obj_handle->ae_num) && (swAe < ICP_QAT_UCLO_MAX_AE); swAe += AE_TG_NUM_CPM2X) { if (!qat_hal_check_ae_active(handle, swAe)) { continue; } for (ii = swAe; ii < (swAe + AE_TG_NUM_CPM2X); ii++) { ae_data0 = &obj_handle->ae_data[ii]; if (ae_data0->slice_num != 1) // not assigned continue; for (jj = ii + 1; jj < (swAe + AE_TG_NUM_CPM2X); jj++) { ae_datax = &obj_handle->ae_data[jj]; if (ae_datax->slice_num != 1) // not assigned continue; if (ae_data0->ae_slices[0] .encap_image->img_ptr != ae_datax->ae_slices[0] .encap_image->img_ptr) { pr_err("Only 1 list is allowed in a "); pr_err("Tgroup for CPM2X;\n"); pr_err("ME%d, %d is assigned", ii, jj); pr_err(" different list files\n"); return EINVAL; } } } } return 0; } static int qat_uclo_map_ae(struct icp_qat_fw_loader_handle *handle, int max_ae) { int i; int ae = 0; unsigned long ae_mask = handle->hal_handle->ae_mask; unsigned long cfg_ae_mask = handle->cfg_ae_mask; int mflag = 0; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; for_each_set_bit(ae, &ae_mask, max_ae) { if (!test_bit(ae, &cfg_ae_mask)) continue; for (i = 0; i < obj_handle->uimage_num; i++) { unsigned long ae_assigned = obj_handle->ae_uimage[i].img_ptr->ae_assigned; if (!test_bit(ae, &ae_assigned)) continue; mflag = 1; if (qat_uclo_init_ae_data(obj_handle, ae, i)) return EINVAL; } } if (IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { if (UcLo_checkTGroupList2X(handle)) { return EINVAL; } } if (!mflag) { pr_err("QAT: uimage uses AE not set"); return EINVAL; } return 0; } static struct icp_qat_uof_strtable * qat_uclo_map_str_table(struct icp_qat_uclo_objhdr *obj_hdr, char *tab_name, struct icp_qat_uof_strtable *str_table) { struct icp_qat_uof_chunkhdr *chunk_hdr; chunk_hdr = qat_uclo_find_chunk((struct icp_qat_uof_objhdr *)obj_hdr->file_buff, tab_name, NULL); if (chunk_hdr) { int hdr_size; memcpy(&str_table->table_len, obj_hdr->file_buff + chunk_hdr->offset, sizeof(str_table->table_len)); hdr_size = (char *)&str_table->strings - (char *)str_table; str_table->strings = (uintptr_t)obj_hdr->file_buff + chunk_hdr->offset + hdr_size; return str_table; } return NULL; } static void qat_uclo_map_initmem_table(struct icp_qat_uof_encap_obj *encap_uof_obj, struct icp_qat_uclo_init_mem_table *init_mem_tab) { struct icp_qat_uof_chunkhdr *chunk_hdr; chunk_hdr = qat_uclo_find_chunk(encap_uof_obj->obj_hdr, ICP_QAT_UOF_IMEM, NULL); if (chunk_hdr) { memmove(&init_mem_tab->entry_num, encap_uof_obj->beg_uof + chunk_hdr->offset, sizeof(unsigned int)); init_mem_tab->init_mem = (struct icp_qat_uof_initmem *)(encap_uof_obj->beg_uof + chunk_hdr->offset + sizeof(unsigned int)); } } static unsigned int qat_uclo_get_dev_type(struct icp_qat_fw_loader_handle *handle) { switch (pci_get_device(GET_DEV(handle->accel_dev))) { case ADF_DH895XCC_PCI_DEVICE_ID: return ICP_QAT_AC_895XCC_DEV_TYPE; case ADF_C62X_PCI_DEVICE_ID: return ICP_QAT_AC_C62X_DEV_TYPE; case ADF_C3XXX_PCI_DEVICE_ID: return ICP_QAT_AC_C3XXX_DEV_TYPE; case ADF_200XX_PCI_DEVICE_ID: return ICP_QAT_AC_200XX_DEV_TYPE; case ADF_C4XXX_PCI_DEVICE_ID: return ICP_QAT_AC_C4XXX_DEV_TYPE; case ADF_4XXX_PCI_DEVICE_ID: case ADF_401XX_PCI_DEVICE_ID: return ICP_QAT_AC_4XXX_A_DEV_TYPE; default: pr_err("QAT: unsupported device 0x%x\n", pci_get_device(GET_DEV(handle->accel_dev))); return 0; } } static int qat_uclo_check_uof_compat(struct icp_qat_uclo_objhandle *obj_handle) { unsigned int maj_ver, prod_type = obj_handle->prod_type; if (!(prod_type & obj_handle->encap_uof_obj.obj_hdr->ac_dev_type)) { pr_err("QAT: UOF type 0x%x doesn't match with platform 0x%x\n", obj_handle->encap_uof_obj.obj_hdr->ac_dev_type, prod_type); return EINVAL; } maj_ver = obj_handle->prod_rev & 0xff; if (obj_handle->encap_uof_obj.obj_hdr->max_cpu_ver < maj_ver || obj_handle->encap_uof_obj.obj_hdr->min_cpu_ver > maj_ver) { pr_err("QAT: UOF maj_ver 0x%x out of range\n", maj_ver); return EINVAL; } return 0; } static int qat_uclo_init_reg(struct icp_qat_fw_loader_handle *handle, unsigned char ae, unsigned char ctx_mask, enum icp_qat_uof_regtype reg_type, unsigned short reg_addr, unsigned int value) { switch (reg_type) { case ICP_GPA_ABS: case ICP_GPB_ABS: ctx_mask = 0; return qat_hal_init_gpr( handle, ae, ctx_mask, reg_type, reg_addr, value); case ICP_GPA_REL: case ICP_GPB_REL: return qat_hal_init_gpr( handle, ae, ctx_mask, reg_type, reg_addr, value); case ICP_SR_ABS: case ICP_DR_ABS: case ICP_SR_RD_ABS: case ICP_DR_RD_ABS: ctx_mask = 0; return qat_hal_init_rd_xfer( handle, ae, ctx_mask, reg_type, reg_addr, value); case ICP_SR_REL: case ICP_DR_REL: case ICP_SR_RD_REL: case ICP_DR_RD_REL: return qat_hal_init_rd_xfer( handle, ae, ctx_mask, reg_type, reg_addr, value); case ICP_SR_WR_ABS: case ICP_DR_WR_ABS: ctx_mask = 0; return qat_hal_init_wr_xfer( handle, ae, ctx_mask, reg_type, reg_addr, value); case ICP_SR_WR_REL: case ICP_DR_WR_REL: return qat_hal_init_wr_xfer( handle, ae, ctx_mask, reg_type, reg_addr, value); case ICP_NEIGH_REL: return qat_hal_init_nn(handle, ae, ctx_mask, reg_addr, value); default: pr_err("QAT: UOF uses unsupported reg type 0x%x\n", reg_type); return EFAULT; } return 0; } static int qat_uclo_init_reg_sym(struct icp_qat_fw_loader_handle *handle, unsigned int ae, struct icp_qat_uclo_encapme *encap_ae) { unsigned int i; unsigned char ctx_mask; struct icp_qat_uof_init_regsym *init_regsym; if (ICP_QAT_CTX_MODE(encap_ae->img_ptr->ae_mode) == ICP_QAT_UCLO_MAX_CTX) ctx_mask = 0xff; else ctx_mask = 0x55; for (i = 0; i < encap_ae->init_regsym_num; i++) { unsigned int exp_res; init_regsym = &encap_ae->init_regsym[i]; exp_res = init_regsym->value; switch (init_regsym->init_type) { case ICP_QAT_UOF_INIT_REG: qat_uclo_init_reg(handle, ae, ctx_mask, (enum icp_qat_uof_regtype) init_regsym->reg_type, (unsigned short)init_regsym->reg_addr, exp_res); break; case ICP_QAT_UOF_INIT_REG_CTX: /* check if ctx is appropriate for the ctxMode */ if (!((1 << init_regsym->ctx) & ctx_mask)) { pr_err("QAT: invalid ctx num = 0x%x\n", init_regsym->ctx); return EINVAL; } qat_uclo_init_reg( handle, ae, (unsigned char)(1 << init_regsym->ctx), (enum icp_qat_uof_regtype)init_regsym->reg_type, (unsigned short)init_regsym->reg_addr, exp_res); break; case ICP_QAT_UOF_INIT_EXPR: pr_err("QAT: INIT_EXPR feature not supported\n"); return EINVAL; case ICP_QAT_UOF_INIT_EXPR_ENDIAN_SWAP: pr_err("QAT: INIT_EXPR_ENDIAN_SWAP not supported\n"); return EINVAL; default: break; } } return 0; } static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int s; unsigned int ae = 0; struct icp_qat_uclo_aedata *aed; unsigned long ae_mask = handle->hal_handle->ae_mask; if (obj_handle->global_inited) return 0; if (obj_handle->init_mem_tab.entry_num) { if (qat_uclo_init_memory(handle)) { pr_err("QAT: initialize memory failed\n"); return EINVAL; } } for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) { aed = &obj_handle->ae_data[ae]; for (s = 0; s < aed->slice_num; s++) { if (!aed->ae_slices[s].encap_image) continue; if (qat_uclo_init_reg_sym( handle, ae, aed->ae_slices[s].encap_image)) return EINVAL; } } obj_handle->global_inited = 1; return 0; } static int qat_hal_set_modes(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uclo_objhandle *obj_handle, unsigned char ae, struct icp_qat_uof_image *uof_image) { unsigned char nn_mode; char ae_mode = 0; ae_mode = (char)ICP_QAT_CTX_MODE(uof_image->ae_mode); if (qat_hal_set_ae_ctx_mode(handle, ae, ae_mode)) { pr_err("QAT: qat_hal_set_ae_ctx_mode error\n"); return EFAULT; } ae_mode = (char)ICP_QAT_SHARED_USTORE_MODE(uof_image->ae_mode); qat_hal_set_ae_scs_mode(handle, ae, ae_mode); if (!IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { nn_mode = ICP_QAT_NN_MODE(uof_image->ae_mode); if (qat_hal_set_ae_nn_mode(handle, ae, nn_mode)) { pr_err("QAT: qat_hal_set_ae_nn_mode error\n"); return EFAULT; } } ae_mode = (char)ICP_QAT_LOC_MEM0_MODE(uof_image->ae_mode); if (qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM0, ae_mode)) { pr_err("QAT: qat_hal_set_ae_lm_mode LMEM0 error\n"); return EFAULT; } ae_mode = (char)ICP_QAT_LOC_MEM1_MODE(uof_image->ae_mode); if (qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM1, ae_mode)) { pr_err("QAT: qat_hal_set_ae_lm_mode LMEM1 error\n"); return EFAULT; } if (IS_QAT_GEN3_OR_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { ae_mode = (char)ICP_QAT_LOC_MEM2_MODE(uof_image->ae_mode); if (qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM2, ae_mode)) { pr_err("QAT: qat_hal_set_ae_lm_mode LMEM2 error\n"); return EFAULT; } ae_mode = (char)ICP_QAT_LOC_MEM3_MODE(uof_image->ae_mode); if (qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM3, ae_mode)) { pr_err("QAT: qat_hal_set_ae_lm_mode LMEM3 error\n"); return EFAULT; } ae_mode = (char)ICP_QAT_LOC_TINDEX_MODE(uof_image->ae_mode); qat_hal_set_ae_tindex_mode(handle, ae, ae_mode); } return 0; } static int qat_uclo_set_ae_mode(struct icp_qat_fw_loader_handle *handle) { int error; unsigned char s; unsigned char ae = 0; struct icp_qat_uof_image *uof_image; struct icp_qat_uclo_aedata *ae_data; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned long ae_mask = handle->hal_handle->ae_mask; for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) { unsigned long cfg_ae_mask = handle->cfg_ae_mask; if (!test_bit(ae, &cfg_ae_mask)) continue; ae_data = &obj_handle->ae_data[ae]; for (s = 0; s < min_t(unsigned int, ae_data->slice_num, ICP_QAT_UCLO_MAX_CTX); s++) { if (!obj_handle->ae_data[ae].ae_slices[s].encap_image) continue; uof_image = ae_data->ae_slices[s].encap_image->img_ptr; error = qat_hal_set_modes(handle, obj_handle, ae, uof_image); if (error) return error; } } return 0; } static void qat_uclo_init_uword_num(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; struct icp_qat_uclo_encapme *image; int a; for (a = 0; a < obj_handle->uimage_num; a++) { image = &obj_handle->ae_uimage[a]; image->uwords_num = image->page->beg_addr_p + image->page->micro_words_num; } } static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int ae; obj_handle->encap_uof_obj.beg_uof = obj_handle->obj_hdr->file_buff; obj_handle->encap_uof_obj.obj_hdr = (struct icp_qat_uof_objhdr *)obj_handle->obj_hdr->file_buff; obj_handle->uword_in_bytes = 6; obj_handle->prod_type = qat_uclo_get_dev_type(handle); obj_handle->prod_rev = PID_MAJOR_REV | (PID_MINOR_REV & handle->hal_handle->revision_id); if (qat_uclo_check_uof_compat(obj_handle)) { pr_err("QAT: UOF incompatible\n"); return EINVAL; } obj_handle->uword_buf = malloc(UWORD_CPYBUF_SIZE * sizeof(uint64_t), M_QAT, M_WAITOK | M_ZERO); obj_handle->ustore_phy_size = (obj_handle->prod_type == ICP_QAT_AC_C4XXX_DEV_TYPE) ? 0x2000 : 0x4000; if (!obj_handle->obj_hdr->file_buff || !qat_uclo_map_str_table(obj_handle->obj_hdr, ICP_QAT_UOF_STRT, &obj_handle->str_table)) { pr_err("QAT: UOF doesn't have effective images\n"); goto out_err; } obj_handle->uimage_num = qat_uclo_map_uimage(obj_handle, obj_handle->ae_uimage, ICP_QAT_UCLO_MAX_AE * ICP_QAT_UCLO_MAX_CTX); if (!obj_handle->uimage_num) goto out_err; if (qat_uclo_map_ae(handle, handle->hal_handle->ae_max_num)) { pr_err("QAT: Bad object\n"); goto out_check_uof_aemask_err; } qat_uclo_init_uword_num(handle); qat_uclo_map_initmem_table(&obj_handle->encap_uof_obj, &obj_handle->init_mem_tab); if (qat_uclo_set_ae_mode(handle)) goto out_check_uof_aemask_err; return 0; out_check_uof_aemask_err: for (ae = 0; ae < obj_handle->uimage_num; ae++) free(obj_handle->ae_uimage[ae].page, M_QAT); out_err: free(obj_handle->uword_buf, M_QAT); obj_handle->uword_buf = NULL; return EFAULT; } static int qat_uclo_map_suof_file_hdr(const struct icp_qat_fw_loader_handle *handle, const struct icp_qat_suof_filehdr *suof_ptr, int suof_size) { unsigned int check_sum = 0; unsigned int min_ver_offset = 0; struct icp_qat_suof_handle *suof_handle = handle->sobj_handle; suof_handle->file_id = ICP_QAT_SUOF_FID; suof_handle->suof_buf = (const char *)suof_ptr; suof_handle->suof_size = suof_size; min_ver_offset = suof_size - offsetof(struct icp_qat_suof_filehdr, min_ver); check_sum = qat_uclo_calc_str_checksum((const char *)&suof_ptr->min_ver, min_ver_offset); if (check_sum != suof_ptr->check_sum) { pr_err("QAT: incorrect SUOF checksum\n"); return EINVAL; } suof_handle->check_sum = suof_ptr->check_sum; suof_handle->min_ver = suof_ptr->min_ver; suof_handle->maj_ver = suof_ptr->maj_ver; suof_handle->fw_type = suof_ptr->fw_type; return 0; } static void qat_uclo_map_simg(struct icp_qat_fw_loader_handle *handle, struct icp_qat_suof_img_hdr *suof_img_hdr, struct icp_qat_suof_chunk_hdr *suof_chunk_hdr) { struct icp_qat_suof_handle *suof_handle = handle->sobj_handle; const struct icp_qat_simg_ae_mode *ae_mode; struct icp_qat_suof_objhdr *suof_objhdr; unsigned int device_id = pci_get_device(GET_DEV(handle->accel_dev)); suof_img_hdr->simg_buf = (suof_handle->suof_buf + suof_chunk_hdr->offset + sizeof(*suof_objhdr)); suof_img_hdr->simg_len = ((struct icp_qat_suof_objhdr *)(uintptr_t)(suof_handle->suof_buf + suof_chunk_hdr->offset)) ->img_length; suof_img_hdr->css_header = suof_img_hdr->simg_buf; suof_img_hdr->css_key = (suof_img_hdr->css_header + sizeof(struct icp_qat_css_hdr)); suof_img_hdr->css_signature = suof_img_hdr->css_key + ICP_QAT_CSS_FWSK_MODULUS_LEN(device_id) + ICP_QAT_CSS_FWSK_EXPONENT_LEN(device_id); suof_img_hdr->css_simg = suof_img_hdr->css_signature + ICP_QAT_CSS_SIGNATURE_LEN(device_id); ae_mode = (const struct icp_qat_simg_ae_mode *)(suof_img_hdr->css_simg); suof_img_hdr->ae_mask = ae_mode->ae_mask; suof_img_hdr->simg_name = (unsigned long)&ae_mode->simg_name; suof_img_hdr->appmeta_data = (unsigned long)&ae_mode->appmeta_data; suof_img_hdr->fw_type = ae_mode->fw_type; } static void qat_uclo_map_suof_symobjs(struct icp_qat_suof_handle *suof_handle, struct icp_qat_suof_chunk_hdr *suof_chunk_hdr) { char **sym_str = (char **)&suof_handle->sym_str; unsigned int *sym_size = &suof_handle->sym_size; struct icp_qat_suof_strtable *str_table_obj; *sym_size = *(unsigned int *)(uintptr_t)(suof_chunk_hdr->offset + suof_handle->suof_buf); *sym_str = (char *)(uintptr_t)(suof_handle->suof_buf + suof_chunk_hdr->offset + sizeof(str_table_obj->tab_length)); } static int qat_uclo_check_simg_compat(struct icp_qat_fw_loader_handle *handle, struct icp_qat_suof_img_hdr *img_hdr) { const struct icp_qat_simg_ae_mode *img_ae_mode = NULL; unsigned int prod_rev, maj_ver, prod_type; prod_type = qat_uclo_get_dev_type(handle); img_ae_mode = (const struct icp_qat_simg_ae_mode *)img_hdr->css_simg; prod_rev = PID_MAJOR_REV | (PID_MINOR_REV & handle->hal_handle->revision_id); if (img_ae_mode->dev_type != prod_type) { pr_err("QAT: incompatible product type %x\n", img_ae_mode->dev_type); return EINVAL; } maj_ver = prod_rev & 0xff; if (maj_ver > img_ae_mode->devmax_ver || maj_ver < img_ae_mode->devmin_ver) { pr_err("QAT: incompatible device maj_ver 0x%x\n", maj_ver); return EINVAL; } return 0; } static void qat_uclo_del_suof(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_suof_handle *sobj_handle = handle->sobj_handle; free(sobj_handle->img_table.simg_hdr, M_QAT); sobj_handle->img_table.simg_hdr = NULL; free(handle->sobj_handle, M_QAT); handle->sobj_handle = NULL; } static void qat_uclo_tail_img(struct icp_qat_suof_img_hdr *suof_img_hdr, unsigned int img_id, unsigned int num_simgs) { struct icp_qat_suof_img_hdr img_header; if ((img_id != num_simgs - 1) && img_id != ICP_QAT_UCLO_MAX_AE) { memcpy(&img_header, &suof_img_hdr[num_simgs - 1], sizeof(*suof_img_hdr)); memcpy(&suof_img_hdr[num_simgs - 1], &suof_img_hdr[img_id], sizeof(*suof_img_hdr)); memcpy(&suof_img_hdr[img_id], &img_header, sizeof(*suof_img_hdr)); } } static int qat_uclo_map_suof(struct icp_qat_fw_loader_handle *handle, const struct icp_qat_suof_filehdr *suof_ptr, int suof_size) { struct icp_qat_suof_handle *suof_handle = handle->sobj_handle; struct icp_qat_suof_chunk_hdr *suof_chunk_hdr = NULL; struct icp_qat_suof_img_hdr *suof_img_hdr = NULL; int ret = 0, ae0_img = ICP_QAT_UCLO_MAX_AE, aeMax_img = ICP_QAT_UCLO_MAX_AE; unsigned int i = 0; struct icp_qat_suof_img_hdr img_header; if (!suof_ptr || suof_size == 0) { pr_err("QAT: input parameter SUOF pointer/size is NULL\n"); return EINVAL; } if (qat_uclo_check_suof_format(suof_ptr)) return EINVAL; ret = qat_uclo_map_suof_file_hdr(handle, suof_ptr, suof_size); if (ret) return ret; suof_chunk_hdr = (struct icp_qat_suof_chunk_hdr *)((uintptr_t)suof_ptr + sizeof(*suof_ptr)); qat_uclo_map_suof_symobjs(suof_handle, suof_chunk_hdr); suof_handle->img_table.num_simgs = suof_ptr->num_chunks - 1; if (suof_handle->img_table.num_simgs != 0) { suof_img_hdr = malloc(suof_handle->img_table.num_simgs * sizeof(img_header), M_QAT, M_WAITOK | M_ZERO); suof_handle->img_table.simg_hdr = suof_img_hdr; } for (i = 0; i < suof_handle->img_table.num_simgs; i++) { qat_uclo_map_simg(handle, &suof_img_hdr[i], &suof_chunk_hdr[1 + i]); ret = qat_uclo_check_simg_compat(handle, &suof_img_hdr[i]); if (ret) return ret; suof_img_hdr[i].ae_mask &= handle->cfg_ae_mask; if ((suof_img_hdr[i].ae_mask & 0x1) != 0) ae0_img = i; } if (!IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { qat_uclo_tail_img(suof_img_hdr, ae0_img, suof_handle->img_table.num_simgs); } else { if (suof_handle->img_table.num_simgs == 1) return 0; qat_uclo_tail_img(suof_img_hdr, ae0_img, suof_handle->img_table.num_simgs - 1); for (i = 0; i < suof_handle->img_table.num_simgs; i++) { if ((suof_img_hdr[i].ae_mask & (0x1 << (handle->hal_handle->ae_max_num - 1))) != 0) { aeMax_img = i; break; } } qat_uclo_tail_img(suof_img_hdr, aeMax_img, suof_handle->img_table.num_simgs); } return 0; } #define ADD_ADDR(high, low) ((((uint64_t)high) << 32) + (low)) #define BITS_IN_DWORD 32 static int qat_uclo_auth_fw(struct icp_qat_fw_loader_handle *handle, struct icp_qat_fw_auth_desc *desc) { unsigned int fcu_sts, mem_cfg_err, retry = 0; unsigned int fcu_ctl_csr, fcu_sts_csr; unsigned int fcu_dram_hi_csr, fcu_dram_lo_csr; u64 bus_addr; bus_addr = ADD_ADDR(desc->css_hdr_high, desc->css_hdr_low) - sizeof(struct icp_qat_auth_chunk); if (IS_QAT_GEN3_OR_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { fcu_ctl_csr = FCU_CONTROL_C4XXX; fcu_sts_csr = FCU_STATUS_C4XXX; fcu_dram_hi_csr = FCU_DRAM_ADDR_HI_C4XXX; fcu_dram_lo_csr = FCU_DRAM_ADDR_LO_C4XXX; } else { fcu_ctl_csr = FCU_CONTROL; fcu_sts_csr = FCU_STATUS; fcu_dram_hi_csr = FCU_DRAM_ADDR_HI; fcu_dram_lo_csr = FCU_DRAM_ADDR_LO; } SET_FCU_CSR(handle, fcu_dram_hi_csr, (bus_addr >> BITS_IN_DWORD)); SET_FCU_CSR(handle, fcu_dram_lo_csr, bus_addr); SET_FCU_CSR(handle, fcu_ctl_csr, FCU_CTRL_CMD_AUTH); do { pause_ms("adfstop", FW_AUTH_WAIT_PERIOD); fcu_sts = GET_FCU_CSR(handle, fcu_sts_csr); if ((fcu_sts & FCU_AUTH_STS_MASK) == FCU_STS_VERI_FAIL) goto auth_fail; if (((fcu_sts >> FCU_STS_AUTHFWLD_POS) & 0x1)) if ((fcu_sts & FCU_AUTH_STS_MASK) == FCU_STS_VERI_DONE) return 0; } while (retry++ < FW_AUTH_MAX_RETRY); auth_fail: pr_err("QAT: authentication error (FCU_STATUS = 0x%x),retry = %d\n", fcu_sts & FCU_AUTH_STS_MASK, retry); if (IS_QAT_GEN3(pci_get_device(GET_DEV(handle->accel_dev)))) { mem_cfg_err = (GET_FCU_CSR(handle, FCU_STATUS1_C4XXX) & MEM_CFG_ERR_BIT); if (mem_cfg_err) pr_err("QAT: MEM_CFG_ERR\n"); } return EINVAL; } static int qat_uclo_is_broadcast(struct icp_qat_fw_loader_handle *handle, int imgid) { struct icp_qat_suof_handle *sobj_handle; if (!IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) return 0; sobj_handle = (struct icp_qat_suof_handle *)handle->sobj_handle; if (handle->hal_handle->admin_ae_mask & sobj_handle->img_table.simg_hdr[imgid].ae_mask) return 0; return 1; } static int qat_uclo_broadcast_load_fw(struct icp_qat_fw_loader_handle *handle, struct icp_qat_fw_auth_desc *desc) { unsigned int i = 0; unsigned int fcuSts = 0, fcuAeBroadcastMask = 0; unsigned int retry = 0; unsigned int fcuStsCsr = 0; unsigned int fcuCtlCsr = 0; unsigned int loadedAes = 0; unsigned int device_id = pci_get_device(GET_DEV(handle->accel_dev)); if (IS_QAT_GEN4(device_id)) { fcuCtlCsr = FCU_CONTROL_4XXX; fcuStsCsr = FCU_STATUS_4XXX; } else { pr_err("Uclo_BroadcastLoadFW only applicable for CPM20\n"); return EINVAL; } for (i = 0; i < ICP_QAT_UCLO_MAX_AE; i++) { if (!test_bit(i, (unsigned long *)&handle->hal_handle->ae_mask)) continue; if (qat_hal_check_ae_active(handle, (unsigned char)i)) { pr_err( "Uclo_BroadcastLoadFW error (invalid AE status)\n"); return EINVAL; } if ((desc->ae_mask >> i) & 0x1) { fcuAeBroadcastMask |= 1 << i; } } if (fcuAeBroadcastMask) { retry = 0; SET_FCU_CSR(handle, FCU_ME_BROADCAST_MASK_TYPE, fcuAeBroadcastMask); SET_FCU_CSR(handle, fcuCtlCsr, FCU_CTRL_CMD_LOAD); do { msleep(FW_AUTH_WAIT_PERIOD); fcuSts = GET_FCU_CSR(handle, fcuStsCsr); if ((fcuSts & FCU_AUTH_STS_MASK) == FCU_STS_LOAD_FAIL) { pr_err( "Uclo_BroadcastLoadFW fail (fcu_status = 0x%x)\n", fcuSts & FCU_AUTH_STS_MASK); return EINVAL; } else if ((fcuSts & FCU_AUTH_STS_MASK) == FCU_STS_LOAD_DONE) { if (IS_QAT_GEN4(device_id)) loadedAes = GET_FCU_CSR(handle, FCU_AE_LOADED_4XXX); else loadedAes = (fcuSts >> FCU_LOADED_AE_POS); if ((loadedAes & fcuAeBroadcastMask) == fcuAeBroadcastMask) break; } else if ((fcuSts & FCU_AUTH_STS_MASK) == FCU_STS_VERI_DONE) { SET_FCU_CSR(handle, fcuCtlCsr, FCU_CTRL_CMD_LOAD); } } while (retry++ < FW_BROADCAST_MAX_RETRY); if (retry > FW_BROADCAST_MAX_RETRY) { pr_err( "Uclo_BroadcastLoadFW fail(fcu_status = 0x%x),retry = %d\n", fcuSts & FCU_AUTH_STS_MASK, retry); return EINVAL; } } return 0; } static int qat_uclo_simg_alloc(struct icp_qat_fw_loader_handle *handle, struct icp_firml_dram_desc *dram_desc, unsigned int size) { int ret; ret = bus_dma_mem_create(&dram_desc->dram_mem, handle->accel_dev->dma_tag, 1, BUS_SPACE_MAXADDR, size, 0); if (ret != 0) return ret; dram_desc->dram_base_addr_v = dram_desc->dram_mem.dma_vaddr; dram_desc->dram_bus_addr = dram_desc->dram_mem.dma_baddr; dram_desc->dram_size = size; return 0; } static void qat_uclo_simg_free(struct icp_qat_fw_loader_handle *handle, struct icp_firml_dram_desc *dram_desc) { if (handle && dram_desc && dram_desc->dram_base_addr_v) bus_dma_mem_free(&dram_desc->dram_mem); if (dram_desc) explicit_bzero(dram_desc, sizeof(*dram_desc)); } static int qat_uclo_map_auth_fw(struct icp_qat_fw_loader_handle *handle, const char *image, unsigned int size, struct icp_firml_dram_desc *img_desc, struct icp_qat_fw_auth_desc **desc) { const struct icp_qat_css_hdr *css_hdr = (const struct icp_qat_css_hdr *)image; struct icp_qat_fw_auth_desc *auth_desc; struct icp_qat_auth_chunk *auth_chunk; u64 virt_addr, bus_addr, virt_base; unsigned int length, simg_offset = sizeof(*auth_chunk); unsigned int device_id = pci_get_device(GET_DEV(handle->accel_dev)); if (size > (ICP_QAT_AE_IMG_OFFSET(device_id) + ICP_QAT_CSS_MAX_IMAGE_LEN)) { pr_err("QAT: error, input image size overflow %d\n", size); return EINVAL; } + length = (css_hdr->fw_type == CSS_AE_FIRMWARE) ? ICP_QAT_CSS_AE_SIMG_LEN(device_id) + simg_offset : size + ICP_QAT_CSS_FWSK_PAD_LEN(device_id) + simg_offset; if (qat_uclo_simg_alloc(handle, img_desc, length)) { pr_err("QAT: error, allocate continuous dram fail\n"); return -ENOMEM; } auth_chunk = img_desc->dram_base_addr_v; auth_chunk->chunk_size = img_desc->dram_size; auth_chunk->chunk_bus_addr = img_desc->dram_bus_addr; virt_base = (uintptr_t)img_desc->dram_base_addr_v + simg_offset; bus_addr = img_desc->dram_bus_addr + simg_offset; auth_desc = img_desc->dram_base_addr_v; auth_desc->css_hdr_high = (unsigned int)(bus_addr >> BITS_IN_DWORD); auth_desc->css_hdr_low = (unsigned int)bus_addr; virt_addr = virt_base; memcpy((void *)(uintptr_t)virt_addr, image, sizeof(*css_hdr)); /* pub key */ bus_addr = ADD_ADDR(auth_desc->css_hdr_high, auth_desc->css_hdr_low) + sizeof(*css_hdr); virt_addr = virt_addr + sizeof(*css_hdr); auth_desc->fwsk_pub_high = (unsigned int)(bus_addr >> BITS_IN_DWORD); auth_desc->fwsk_pub_low = (unsigned int)bus_addr; memcpy((void *)(uintptr_t)virt_addr, (const void *)(image + sizeof(*css_hdr)), ICP_QAT_CSS_FWSK_MODULUS_LEN(device_id)); /* padding */ explicit_bzero((void *)(uintptr_t)( virt_addr + ICP_QAT_CSS_FWSK_MODULUS_LEN(device_id)), ICP_QAT_CSS_FWSK_PAD_LEN(device_id)); /* exponent */ memcpy((void *)(uintptr_t)(virt_addr + ICP_QAT_CSS_FWSK_MODULUS_LEN(device_id) + ICP_QAT_CSS_FWSK_PAD_LEN(device_id)), (const void *)(image + sizeof(*css_hdr) + ICP_QAT_CSS_FWSK_MODULUS_LEN(device_id)), sizeof(unsigned int)); /* signature */ bus_addr = ADD_ADDR(auth_desc->fwsk_pub_high, auth_desc->fwsk_pub_low) + ICP_QAT_CSS_FWSK_PUB_LEN(device_id); virt_addr = virt_addr + ICP_QAT_CSS_FWSK_PUB_LEN(device_id); auth_desc->signature_high = (unsigned int)(bus_addr >> BITS_IN_DWORD); auth_desc->signature_low = (unsigned int)bus_addr; memcpy((void *)(uintptr_t)virt_addr, (const void *)(image + sizeof(*css_hdr) + ICP_QAT_CSS_FWSK_MODULUS_LEN(device_id) + ICP_QAT_CSS_FWSK_EXPONENT_LEN(device_id)), ICP_QAT_CSS_SIGNATURE_LEN(device_id)); bus_addr = ADD_ADDR(auth_desc->signature_high, auth_desc->signature_low) + ICP_QAT_CSS_SIGNATURE_LEN(device_id); virt_addr += ICP_QAT_CSS_SIGNATURE_LEN(device_id); auth_desc->img_high = (unsigned int)(bus_addr >> BITS_IN_DWORD); auth_desc->img_low = (unsigned int)bus_addr; auth_desc->img_len = size - ICP_QAT_AE_IMG_OFFSET(device_id); memcpy((void *)(uintptr_t)virt_addr, (const void *)(image + ICP_QAT_AE_IMG_OFFSET(device_id)), auth_desc->img_len); virt_addr = virt_base; /* AE firmware */ if (((struct icp_qat_css_hdr *)(uintptr_t)virt_addr)->fw_type == CSS_AE_FIRMWARE) { auth_desc->img_ae_mode_data_high = auth_desc->img_high; auth_desc->img_ae_mode_data_low = auth_desc->img_low; bus_addr = ADD_ADDR(auth_desc->img_ae_mode_data_high, auth_desc->img_ae_mode_data_low) + sizeof(struct icp_qat_simg_ae_mode); auth_desc->img_ae_init_data_high = (unsigned int)(bus_addr >> BITS_IN_DWORD); auth_desc->img_ae_init_data_low = (unsigned int)bus_addr; bus_addr += ICP_QAT_SIMG_AE_INIT_SEQ_LEN; auth_desc->img_ae_insts_high = (unsigned int)(bus_addr >> BITS_IN_DWORD); auth_desc->img_ae_insts_low = (unsigned int)bus_addr; virt_addr += sizeof(struct icp_qat_css_hdr) + ICP_QAT_CSS_FWSK_PUB_LEN(device_id) + ICP_QAT_CSS_SIGNATURE_LEN(device_id); auth_desc->ae_mask = ((struct icp_qat_simg_ae_mode *)virt_addr)->ae_mask & handle->cfg_ae_mask; } else { auth_desc->img_ae_insts_high = auth_desc->img_high; auth_desc->img_ae_insts_low = auth_desc->img_low; } *desc = auth_desc; return 0; } static int qat_uclo_load_fw(struct icp_qat_fw_loader_handle *handle, struct icp_qat_fw_auth_desc *desc) { unsigned int i = 0; unsigned int fcu_sts; unsigned int fcu_sts_csr, fcu_ctl_csr; unsigned int loaded_aes = FCU_LOADED_AE_POS; unsigned long ae_mask = handle->hal_handle->ae_mask; if (IS_QAT_GEN3_OR_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { fcu_ctl_csr = FCU_CONTROL_C4XXX; fcu_sts_csr = FCU_STATUS_C4XXX; } else { fcu_ctl_csr = FCU_CONTROL; fcu_sts_csr = FCU_STATUS; } for_each_set_bit(i, &ae_mask, handle->hal_handle->ae_max_num) { int retry = 0; if (!((desc->ae_mask >> i) & 0x1)) continue; if (qat_hal_check_ae_active(handle, i)) { pr_err("QAT: AE %d is active\n", i); return EINVAL; } SET_FCU_CSR(handle, fcu_ctl_csr, (FCU_CTRL_CMD_LOAD | (IS_QAT_GEN4( pci_get_device(GET_DEV(handle->accel_dev))) ? (1 << FCU_CTRL_BROADCAST_POS) : 0) | (i << FCU_CTRL_AE_POS))); do { pause_ms("adfstop", FW_AUTH_WAIT_PERIOD); fcu_sts = GET_FCU_CSR(handle, fcu_sts_csr); if ((fcu_sts & FCU_AUTH_STS_MASK) == FCU_STS_LOAD_DONE) { loaded_aes = IS_QAT_GEN3_OR_GEN4(pci_get_device( GET_DEV(handle->accel_dev))) ? GET_FCU_CSR(handle, FCU_AE_LOADED_C4XXX) : (fcu_sts >> FCU_LOADED_AE_POS); if (loaded_aes & (1 << i)) break; } } while (retry++ < FW_AUTH_MAX_RETRY); if (retry > FW_AUTH_MAX_RETRY) { pr_err("QAT: firmware load failed timeout %x\n", retry); return EINVAL; } } return 0; } static int qat_uclo_map_suof_obj(struct icp_qat_fw_loader_handle *handle, const void *addr_ptr, int mem_size) { struct icp_qat_suof_handle *suof_handle; suof_handle = malloc(sizeof(*suof_handle), M_QAT, M_WAITOK | M_ZERO); handle->sobj_handle = suof_handle; if (qat_uclo_map_suof(handle, addr_ptr, mem_size)) { qat_uclo_del_suof(handle); pr_err("QAT: map SUOF failed\n"); return EINVAL; } return 0; } int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle, const void *addr_ptr, int mem_size) { struct icp_qat_fw_auth_desc *desc = NULL; struct icp_firml_dram_desc img_desc; int status = 0; if (handle->fw_auth) { status = qat_uclo_map_auth_fw( handle, addr_ptr, mem_size, &img_desc, &desc); if (!status) status = qat_uclo_auth_fw(handle, desc); qat_uclo_simg_free(handle, &img_desc); } else { if (IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) { device_printf( NULL, "QAT: PKE service is not allowed because "); device_printf(NULL, "MMP fw will not be loaded for "); device_printf(NULL, "device 0x%x", pci_get_device( GET_DEV(handle->accel_dev))); return status; } if (pci_get_device(GET_DEV(handle->accel_dev)) == ADF_C3XXX_PCI_DEVICE_ID) { pr_err("QAT: C3XXX doesn't support unsigned MMP\n"); return EINVAL; } status = qat_uclo_wr_sram_by_words(handle, handle->hal_sram_offset, addr_ptr, mem_size); } return status; } static int qat_uclo_map_uof_obj(struct icp_qat_fw_loader_handle *handle, const void *addr_ptr, int mem_size) { struct icp_qat_uof_filehdr *filehdr; struct icp_qat_uclo_objhandle *objhdl; objhdl = malloc(sizeof(*objhdl), M_QAT, M_WAITOK | M_ZERO); objhdl->obj_buf = malloc(mem_size, M_QAT, M_WAITOK); bcopy(addr_ptr, objhdl->obj_buf, mem_size); filehdr = (struct icp_qat_uof_filehdr *)objhdl->obj_buf; if (qat_uclo_check_uof_format(filehdr)) goto out_objhdr_err; objhdl->obj_hdr = qat_uclo_map_chunk((char *)objhdl->obj_buf, filehdr, ICP_QAT_UOF_OBJS); if (!objhdl->obj_hdr) { pr_err("QAT: object file chunk is null\n"); goto out_objhdr_err; } handle->obj_handle = objhdl; if (qat_uclo_parse_uof_obj(handle)) goto out_overlay_obj_err; return 0; out_overlay_obj_err: handle->obj_handle = NULL; free(objhdl->obj_hdr, M_QAT); out_objhdr_err: free(objhdl->obj_buf, M_QAT); free(objhdl, M_QAT); return ENOMEM; } static int qat_uclo_map_mof_file_hdr(struct icp_qat_fw_loader_handle *handle, const struct icp_qat_mof_file_hdr *mof_ptr, u32 mof_size) { unsigned int checksum = 0; unsigned int min_ver_offset = 0; struct icp_qat_mof_handle *mobj_handle = handle->mobj_handle; mobj_handle->file_id = ICP_QAT_MOF_FID; mobj_handle->mof_buf = (const char *)mof_ptr; mobj_handle->mof_size = mof_size; min_ver_offset = mof_size - offsetof(struct icp_qat_mof_file_hdr, min_ver); checksum = qat_uclo_calc_str_checksum((const char *)&mof_ptr->min_ver, min_ver_offset); if (checksum != mof_ptr->checksum) { pr_err("QAT: incorrect MOF checksum\n"); return EINVAL; } mobj_handle->checksum = mof_ptr->checksum; mobj_handle->min_ver = mof_ptr->min_ver; mobj_handle->maj_ver = mof_ptr->maj_ver; return 0; } void qat_uclo_del_mof(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_mof_handle *mobj_handle = handle->mobj_handle; free(mobj_handle->obj_table.obj_hdr, M_QAT); mobj_handle->obj_table.obj_hdr = NULL; free(handle->mobj_handle, M_QAT); handle->mobj_handle = NULL; } static int qat_uclo_seek_obj_inside_mof(struct icp_qat_mof_handle *mobj_handle, const char *obj_name, const char **obj_ptr, unsigned int *obj_size) { unsigned int i; struct icp_qat_mof_objhdr *obj_hdr = mobj_handle->obj_table.obj_hdr; for (i = 0; i < mobj_handle->obj_table.num_objs; i++) { if (!strncmp(obj_hdr[i].obj_name, obj_name, ICP_QAT_SUOF_OBJ_NAME_LEN)) { *obj_ptr = obj_hdr[i].obj_buf; *obj_size = obj_hdr[i].obj_size; break; } } if (i >= mobj_handle->obj_table.num_objs) { pr_err("QAT: object %s is not found inside MOF\n", obj_name); return EFAULT; } return 0; } static int qat_uclo_map_obj_from_mof(struct icp_qat_mof_handle *mobj_handle, struct icp_qat_mof_objhdr *mobj_hdr, struct icp_qat_mof_obj_chunkhdr *obj_chunkhdr) { if ((strncmp((char *)obj_chunkhdr->chunk_id, ICP_QAT_UOF_IMAG, ICP_QAT_MOF_OBJ_CHUNKID_LEN)) == 0) { mobj_hdr->obj_buf = (const char *)((unsigned long)obj_chunkhdr->offset + mobj_handle->uobjs_hdr); } else if ((strncmp((char *)(obj_chunkhdr->chunk_id), ICP_QAT_SUOF_IMAG, ICP_QAT_MOF_OBJ_CHUNKID_LEN)) == 0) { mobj_hdr->obj_buf = (const char *)((unsigned long)obj_chunkhdr->offset + mobj_handle->sobjs_hdr); } else { pr_err("QAT: unsupported chunk id\n"); return EINVAL; } mobj_hdr->obj_size = (unsigned int)obj_chunkhdr->size; mobj_hdr->obj_name = (char *)(obj_chunkhdr->name + mobj_handle->sym_str); return 0; } static int qat_uclo_map_objs_from_mof(struct icp_qat_mof_handle *mobj_handle) { struct icp_qat_mof_objhdr *mof_obj_hdr; const struct icp_qat_mof_obj_hdr *uobj_hdr; const struct icp_qat_mof_obj_hdr *sobj_hdr; struct icp_qat_mof_obj_chunkhdr *uobj_chunkhdr; struct icp_qat_mof_obj_chunkhdr *sobj_chunkhdr; unsigned int uobj_chunk_num = 0, sobj_chunk_num = 0; unsigned int *valid_chunks = 0; int ret, i; uobj_hdr = (const struct icp_qat_mof_obj_hdr *)mobj_handle->uobjs_hdr; sobj_hdr = (const struct icp_qat_mof_obj_hdr *)mobj_handle->sobjs_hdr; if (uobj_hdr) uobj_chunk_num = uobj_hdr->num_chunks; if (sobj_hdr) sobj_chunk_num = sobj_hdr->num_chunks; mof_obj_hdr = (struct icp_qat_mof_objhdr *) malloc((uobj_chunk_num + sobj_chunk_num) * sizeof(*mof_obj_hdr), M_QAT, M_WAITOK | M_ZERO); mobj_handle->obj_table.obj_hdr = mof_obj_hdr; valid_chunks = &mobj_handle->obj_table.num_objs; uobj_chunkhdr = (struct icp_qat_mof_obj_chunkhdr *)((uintptr_t)uobj_hdr + sizeof(*uobj_hdr)); sobj_chunkhdr = (struct icp_qat_mof_obj_chunkhdr *)((uintptr_t)sobj_hdr + sizeof(*sobj_hdr)); /* map uof objects */ for (i = 0; i < uobj_chunk_num; i++) { ret = qat_uclo_map_obj_from_mof(mobj_handle, &mof_obj_hdr[*valid_chunks], &uobj_chunkhdr[i]); if (ret) return ret; (*valid_chunks)++; } /* map suof objects */ for (i = 0; i < sobj_chunk_num; i++) { ret = qat_uclo_map_obj_from_mof(mobj_handle, &mof_obj_hdr[*valid_chunks], &sobj_chunkhdr[i]); if (ret) return ret; (*valid_chunks)++; } if ((uobj_chunk_num + sobj_chunk_num) != *valid_chunks) { pr_err("QAT: inconsistent UOF/SUOF chunk amount\n"); return EINVAL; } return 0; } static void qat_uclo_map_mof_symobjs(struct icp_qat_mof_handle *mobj_handle, struct icp_qat_mof_chunkhdr *mof_chunkhdr) { char **sym_str = (char **)&mobj_handle->sym_str; unsigned int *sym_size = &mobj_handle->sym_size; struct icp_qat_mof_str_table *str_table_obj; *sym_size = *(unsigned int *)(uintptr_t)(mof_chunkhdr->offset + mobj_handle->mof_buf); *sym_str = (char *)(uintptr_t)(mobj_handle->mof_buf + mof_chunkhdr->offset + sizeof(str_table_obj->tab_len)); } static void qat_uclo_map_mof_chunk(struct icp_qat_mof_handle *mobj_handle, struct icp_qat_mof_chunkhdr *mof_chunkhdr) { if (!strncmp(mof_chunkhdr->chunk_id, ICP_QAT_MOF_SYM_OBJS, ICP_QAT_MOF_OBJ_ID_LEN)) qat_uclo_map_mof_symobjs(mobj_handle, mof_chunkhdr); else if (!strncmp(mof_chunkhdr->chunk_id, ICP_QAT_UOF_OBJS, ICP_QAT_MOF_OBJ_ID_LEN)) mobj_handle->uobjs_hdr = mobj_handle->mof_buf + (unsigned long)mof_chunkhdr->offset; else if (!strncmp(mof_chunkhdr->chunk_id, ICP_QAT_SUOF_OBJS, ICP_QAT_MOF_OBJ_ID_LEN)) mobj_handle->sobjs_hdr = mobj_handle->mof_buf + (unsigned long)mof_chunkhdr->offset; } static int qat_uclo_check_mof_format(const struct icp_qat_mof_file_hdr *mof_hdr) { int maj = mof_hdr->maj_ver & 0xff; int min = mof_hdr->min_ver & 0xff; if (mof_hdr->file_id != ICP_QAT_MOF_FID) { pr_err("QAT: invalid header 0x%x\n", mof_hdr->file_id); return EINVAL; } if (mof_hdr->num_chunks <= 0x1) { pr_err("QAT: MOF chunk amount is incorrect\n"); return EINVAL; } if (maj != ICP_QAT_MOF_MAJVER || min != ICP_QAT_MOF_MINVER) { pr_err("QAT: bad MOF version, major 0x%x, minor 0x%x\n", maj, min); return EINVAL; } return 0; } static int qat_uclo_map_mof_obj(struct icp_qat_fw_loader_handle *handle, const struct icp_qat_mof_file_hdr *mof_ptr, u32 mof_size, const char *obj_name, const char **obj_ptr, unsigned int *obj_size) { struct icp_qat_mof_handle *mobj_handle; struct icp_qat_mof_chunkhdr *mof_chunkhdr; unsigned short chunks_num; int ret; unsigned int i; if (mof_ptr->file_id == ICP_QAT_UOF_FID || mof_ptr->file_id == ICP_QAT_SUOF_FID) { if (obj_ptr) *obj_ptr = (const char *)mof_ptr; if (obj_size) *obj_size = (unsigned int)mof_size; return 0; } if (qat_uclo_check_mof_format(mof_ptr)) return EINVAL; mobj_handle = malloc(sizeof(*mobj_handle), M_QAT, M_WAITOK | M_ZERO); handle->mobj_handle = mobj_handle; ret = qat_uclo_map_mof_file_hdr(handle, mof_ptr, mof_size); if (ret) return ret; mof_chunkhdr = (struct icp_qat_mof_chunkhdr *)((uintptr_t)mof_ptr + sizeof(*mof_ptr)); chunks_num = mof_ptr->num_chunks; /*Parse MOF file chunks*/ for (i = 0; i < chunks_num; i++) qat_uclo_map_mof_chunk(mobj_handle, &mof_chunkhdr[i]); /*All sym_objs uobjs and sobjs should be available*/ if (!mobj_handle->sym_str || (!mobj_handle->uobjs_hdr && !mobj_handle->sobjs_hdr)) return EINVAL; ret = qat_uclo_map_objs_from_mof(mobj_handle); if (ret) return ret; /*Seek specified uof object in MOF*/ ret = qat_uclo_seek_obj_inside_mof(mobj_handle, obj_name, obj_ptr, obj_size); if (ret) return ret; return 0; } int qat_uclo_map_obj(struct icp_qat_fw_loader_handle *handle, const void *addr_ptr, u32 mem_size, const char *obj_name) { const char *obj_addr; u32 obj_size; int ret; BUILD_BUG_ON(ICP_QAT_UCLO_MAX_AE > (sizeof(handle->hal_handle->ae_mask) * 8)); if (!handle || !addr_ptr || mem_size < 24) return EINVAL; if (obj_name) { ret = qat_uclo_map_mof_obj( handle, addr_ptr, mem_size, obj_name, &obj_addr, &obj_size); if (ret) return ret; } else { obj_addr = addr_ptr; obj_size = mem_size; } return (handle->fw_auth) ? qat_uclo_map_suof_obj(handle, obj_addr, obj_size) : qat_uclo_map_uof_obj(handle, obj_addr, obj_size); } void qat_uclo_del_obj(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int a; unsigned long ae_mask = handle->hal_handle->ae_mask; if (handle->mobj_handle) qat_uclo_del_mof(handle); if (handle->sobj_handle) qat_uclo_del_suof(handle); if (!obj_handle) return; free(obj_handle->uword_buf, M_QAT); for (a = 0; a < obj_handle->uimage_num; a++) free(obj_handle->ae_uimage[a].page, M_QAT); for_each_set_bit(a, &ae_mask, handle->hal_handle->ae_max_num) { qat_uclo_free_ae_data(&obj_handle->ae_data[a]); } free(obj_handle->obj_hdr, M_QAT); free(obj_handle->obj_buf, M_QAT); free(obj_handle, M_QAT); handle->obj_handle = NULL; } static void qat_uclo_fill_uwords(struct icp_qat_uclo_objhandle *obj_handle, struct icp_qat_uclo_encap_page *encap_page, uint64_t *uword, unsigned int addr_p, unsigned int raddr, uint64_t fill) { uint64_t uwrd = 0; unsigned int i, addr; if (!encap_page) { *uword = fill; return; } addr = (encap_page->page_region) ? raddr : addr_p; for (i = 0; i < encap_page->uwblock_num; i++) { if (addr >= encap_page->uwblock[i].start_addr && addr <= encap_page->uwblock[i].start_addr + encap_page->uwblock[i].words_num - 1) { addr -= encap_page->uwblock[i].start_addr; addr *= obj_handle->uword_in_bytes; memcpy(&uwrd, (void *)(((uintptr_t)encap_page->uwblock[i] .micro_words) + addr), obj_handle->uword_in_bytes); uwrd = uwrd & 0xbffffffffffull; } } *uword = uwrd; if (*uword == INVLD_UWORD) *uword = fill; } static void qat_uclo_wr_uimage_raw_page(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uclo_encap_page *encap_page, unsigned int ae) { unsigned int uw_physical_addr, uw_relative_addr, i, words_num, cpylen; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; uint64_t fill_pat; /* load the page starting at appropriate ustore address */ /* get fill-pattern from an image -- they are all the same */ memcpy(&fill_pat, obj_handle->ae_uimage[0].img_ptr->fill_pattern, sizeof(uint64_t)); uw_physical_addr = encap_page->beg_addr_p; uw_relative_addr = 0; words_num = encap_page->micro_words_num; while (words_num) { if (words_num < UWORD_CPYBUF_SIZE) cpylen = words_num; else cpylen = UWORD_CPYBUF_SIZE; /* load the buffer */ for (i = 0; i < cpylen; i++) qat_uclo_fill_uwords(obj_handle, encap_page, &obj_handle->uword_buf[i], uw_physical_addr + i, uw_relative_addr + i, fill_pat); if (obj_handle->ae_data[ae].shareable_ustore && !IS_QAT_GEN4(pci_get_device(GET_DEV(handle->accel_dev)))) /* copy the buffer to ustore */ qat_hal_wr_coalesce_uwords(handle, (unsigned char)ae, uw_physical_addr, cpylen, obj_handle->uword_buf); else /* copy the buffer to ustore */ qat_hal_wr_uwords(handle, (unsigned char)ae, uw_physical_addr, cpylen, obj_handle->uword_buf); uw_physical_addr += cpylen; uw_relative_addr += cpylen; words_num -= cpylen; } } static void qat_uclo_wr_uimage_page(struct icp_qat_fw_loader_handle *handle, struct icp_qat_uof_image *image) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int ctx_mask, s; struct icp_qat_uclo_page *page; unsigned char ae = 0; int ctx; struct icp_qat_uclo_aedata *aed; unsigned long ae_mask = handle->hal_handle->ae_mask; if (ICP_QAT_CTX_MODE(image->ae_mode) == ICP_QAT_UCLO_MAX_CTX) ctx_mask = 0xff; else ctx_mask = 0x55; /* load the default page and set assigned CTX PC * to the entrypoint address */ for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) { unsigned long cfg_ae_mask = handle->cfg_ae_mask; unsigned long ae_assigned = image->ae_assigned; if (!test_bit(ae, &cfg_ae_mask)) continue; if (!test_bit(ae, &ae_assigned)) continue; aed = &obj_handle->ae_data[ae]; /* find the slice to which this image is assigned */ for (s = 0; s < aed->slice_num; s++) { if (image->ctx_assigned & aed->ae_slices[s].ctx_mask_assigned) break; } if (s >= aed->slice_num) continue; page = aed->ae_slices[s].page; if (!page->encap_page->def_page) continue; qat_uclo_wr_uimage_raw_page(handle, page->encap_page, ae); page = aed->ae_slices[s].page; for (ctx = 0; ctx < ICP_QAT_UCLO_MAX_CTX; ctx++) aed->ae_slices[s].cur_page[ctx] = (ctx_mask & (1 << ctx)) ? page : NULL; qat_hal_set_live_ctx(handle, (unsigned char)ae, image->ctx_assigned); qat_hal_set_pc(handle, (unsigned char)ae, image->ctx_assigned, image->entry_address); } } static int qat_uclo_wr_suof_img(struct icp_qat_fw_loader_handle *handle) { unsigned int i; struct icp_qat_fw_auth_desc *desc = NULL; struct icp_firml_dram_desc img_desc; struct icp_qat_suof_handle *sobj_handle = handle->sobj_handle; struct icp_qat_suof_img_hdr *simg_hdr = sobj_handle->img_table.simg_hdr; for (i = 0; i < sobj_handle->img_table.num_simgs; i++) { if (qat_uclo_map_auth_fw(handle, (const char *)simg_hdr[i].simg_buf, (unsigned int)(simg_hdr[i].simg_len), &img_desc, &desc)) goto wr_err; if (qat_uclo_auth_fw(handle, desc)) goto wr_err; if (qat_uclo_is_broadcast(handle, i)) { if (qat_uclo_broadcast_load_fw(handle, desc)) goto wr_err; } else { if (qat_uclo_load_fw(handle, desc)) goto wr_err; } qat_uclo_simg_free(handle, &img_desc); } return 0; wr_err: qat_uclo_simg_free(handle, &img_desc); return -EINVAL; } static int qat_uclo_wr_uof_img(struct icp_qat_fw_loader_handle *handle) { struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; unsigned int i; if (qat_uclo_init_globals(handle)) return EINVAL; for (i = 0; i < obj_handle->uimage_num; i++) { if (!obj_handle->ae_uimage[i].img_ptr) return EINVAL; if (qat_uclo_init_ustore(handle, &obj_handle->ae_uimage[i])) return EINVAL; qat_uclo_wr_uimage_page(handle, obj_handle->ae_uimage[i].img_ptr); } return 0; } int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle) { return (handle->fw_auth) ? qat_uclo_wr_suof_img(handle) : qat_uclo_wr_uof_img(handle); } int qat_uclo_set_cfg_ae_mask(struct icp_qat_fw_loader_handle *handle, unsigned int cfg_ae_mask) { if (!cfg_ae_mask) return EINVAL; handle->cfg_ae_mask = cfg_ae_mask; return 0; }