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