1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 4 /** 5 *************************************************************************** 6 * @file lac_sal_types_crypto.h 7 * 8 * @ingroup SalCtrl 9 * 10 * Generic crypto instance type definition 11 * 12 ***************************************************************************/ 13 14 #ifndef LAC_SAL_TYPES_CRYPTO_H_ 15 #define LAC_SAL_TYPES_CRYPTO_H_ 16 17 #include "lac_sym_qat_hash_defs_lookup.h" 18 #include "lac_sym_qat_constants_table.h" 19 #include "lac_sym_key.h" 20 #include "cpa_cy_sym_dp.h" 21 22 #include "icp_adf_debug.h" 23 #include "lac_sal_types.h" 24 #include "icp_adf_transport.h" 25 #include "lac_mem_pools.h" 26 27 #define LAC_PKE_FLOW_ID_TAG 0xFFFFFFFC 28 #define LAC_PKE_ACCEL_ID_BIT_POS 1 29 #define LAC_PKE_SLICE_ID_BIT_POS 0 30 31 /** 32 ***************************************************************************** 33 * @ingroup SalCtrl 34 * Crypto specific Service Container 35 * 36 * @description 37 * Contains information required per crypto service instance. 38 * 39 *****************************************************************************/ 40 typedef struct sal_crypto_service_s { 41 sal_service_t generic_service_info; 42 /**< An instance of the Generic Service Container */ 43 44 lac_memory_pool_id_t lac_sym_cookie_pool; 45 /**< Memory pool ID used for symmetric operations */ 46 lac_memory_pool_id_t lac_ec_pool; 47 /**< Memory pool ID used for asymmetric operations */ 48 lac_memory_pool_id_t lac_prime_pool; 49 /**< Memory pool ID used for asymmetric operations */ 50 lac_memory_pool_id_t lac_pke_req_pool; 51 /**< Memory pool ID used for asymmetric operations */ 52 lac_memory_pool_id_t lac_pke_align_pool; 53 /**< Memory pool ID used for asymmetric operations */ 54 55 QatUtilsAtomic *pLacSymStatsArr; 56 /**< pointer to an array of atomic stats for symmetric */ 57 58 QatUtilsAtomic *pLacKeyStats; 59 /**< pointer to an array of atomic stats for key */ 60 61 QatUtilsAtomic *pLacDhStatsArr; 62 /**< pointer to an array of atomic stats for DH */ 63 64 QatUtilsAtomic *pLacDsaStatsArr; 65 /**< pointer to an array of atomic stats for Dsa */ 66 67 QatUtilsAtomic *pLacRsaStatsArr; 68 /**< pointer to an array of atomic stats for Rsa */ 69 70 QatUtilsAtomic *pLacEcStatsArr; 71 /**< pointer to an array of atomic stats for Ecc */ 72 73 QatUtilsAtomic *pLacEcdhStatsArr; 74 /**< pointer to an array of atomic stats for Ecc DH */ 75 76 QatUtilsAtomic *pLacEcdsaStatsArr; 77 /**< pointer to an array of atomic stats for Ecc DSA */ 78 79 QatUtilsAtomic *pLacPrimeStatsArr; 80 /**< pointer to an array of atomic stats for prime */ 81 82 QatUtilsAtomic *pLacLnStatsArr; 83 /**< pointer to an array of atomic stats for large number */ 84 85 QatUtilsAtomic *pLacDrbgStatsArr; 86 /**< pointer to an array of atomic stats for DRBG */ 87 icp_qat_hw_auth_mode_t qatHmacMode; 88 /**< Hmac Mode */ 89 90 Cpa32U pkeFlowId; 91 /**< Flow ID for all pke requests from this instance - identifies 92 accelerator 93 and execution engine to use */ 94 95 icp_comms_trans_handle trans_handle_sym_tx; 96 icp_comms_trans_handle trans_handle_sym_rx; 97 98 icp_comms_trans_handle trans_handle_asym_tx; 99 icp_comms_trans_handle trans_handle_asym_rx; 100 101 icp_comms_trans_handle trans_handle_nrbg_tx; 102 icp_comms_trans_handle trans_handle_nrbg_rx; 103 104 Cpa32U maxNumSymReqBatch; 105 /**< Maximum number of requests that can be placed on the sym tx ring 106 for any one batch request (DP api) */ 107 108 Cpa16U acceleratorNum; 109 Cpa16U bankNum; 110 Cpa16U bankNumAsym; 111 Cpa16U bankNumSym; 112 Cpa16U pkgID; 113 Cpa8U isPolled; 114 Cpa8U executionEngine; 115 Cpa32U coreAffinity; 116 Cpa32U nodeAffinity; 117 /**< Config Info */ 118 119 CpaCySymDpCbFunc pSymDpCb; 120 /**< Sym DP Callback */ 121 122 lac_sym_qat_hash_defs_t **pLacHashLookupDefs; 123 /**< table of pointers to standard defined information for all hash 124 algorithms. We support an extra hash algo that is not exported by 125 cy api which is why we need the extra +1 */ 126 127 lac_sym_qat_constants_t constantsLookupTables; 128 129 Cpa8U **ppHmacContentDesc; 130 /**< table of pointers to CD for Hmac precomputes - used at session init 131 */ 132 133 Cpa8U *pSslLabel; 134 /**< pointer to memory holding the standard SSL label ABBCCC.. */ 135 136 lac_sym_key_tls_labels_t *pTlsLabel; 137 /**< pointer to memory holding the 4 standard TLS labels */ 138 139 QatUtilsAtomic drbgErrorState; 140 /**< DRBG related variables */ 141 142 lac_sym_key_tls_hkdf_sub_labels_t *pTlsHKDFSubLabel; 143 /**< pointer to memory holding the 4 HKDFLabels sublabels */ 144 145 debug_file_info_t *debug_file; 146 /**< Statistics handler */ 147 148 CpaBoolean forceAEADMacVerify; 149 /**< internal flag to enable/disable forcing HW digest verification for 150 GCM and CCM algorithms */ 151 } sal_crypto_service_t; 152 153 /************************************************************************* 154 * @ingroup cpaCyCommon 155 * @description 156 * This function returns a valid asym/sym/crypto instance handle for the 157 * system if it exists. When requesting an instance handle of type sym or 158 * asym, if either is not found then a crypto instance handle is returned 159 * if found, since a crypto handle supports both sym and asym services. 160 * Similarly when requesting a crypto instance handle, if it is not found 161 * then an asym or sym crypto instance handle is returned. 162 * 163 * @performance 164 * To avoid calling this function the user of the QA api should not use 165 * instanceHandle = CPA_INSTANCE_HANDLE_SINGLE. 166 * 167 * @context 168 * This function is called whenever instanceHandle = 169 *CPA_INSTANCE_HANDLE_SINGLE 170 * at the QA Cy api. 171 * 172 * @assumptions 173 * None 174 * @sideEffects 175 * None 176 * @reentrant 177 * No 178 * @threadSafe 179 * Yes 180 * 181 * @param[in] svc_type Type of crypto service requested. 182 * 183 * @retval Pointer to first crypto instance handle or NULL if no crypto 184 * instances in the system. 185 * 186 *************************************************************************/ 187 188 CpaInstanceHandle Lac_GetFirstHandle(sal_service_type_t svc_type); 189 190 #endif /*LAC_SAL_TYPES_CRYPTO_H_*/ 191