xref: /freebsd/sys/dev/qat/include/qat_ocf_utils.h (revision 3a3af6b2a160bea72509a9d5ef84e25906b0478a)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 #ifndef _QAT_OCF_UTILS_H_
5 #define _QAT_OCF_UTILS_H_
6 /* System headers */
7 #include <sys/types.h>
8 #include <sys/mbuf.h>
9 #include <machine/bus_dma.h>
10 
11 /* Cryptodev headers */
12 #include <opencrypto/cryptodev.h>
13 #include <crypto/sha2/sha512.h>
14 
15 /* QAT specific headers */
16 #include "qat_ocf_mem_pool.h"
17 #include "cpa.h"
18 #include "cpa_cy_sym_dp.h"
19 
20 static inline CpaBoolean
21 is_gmac_exception(const struct crypto_session_params *csp)
22 {
23 	if (CSP_MODE_DIGEST == csp->csp_mode)
24 		if (CRYPTO_AES_NIST_GMAC == csp->csp_auth_alg)
25 			return CPA_TRUE;
26 
27 	return CPA_FALSE;
28 }
29 
30 static inline CpaBoolean
31 is_sep_aad_supported(const struct crypto_session_params *csp)
32 {
33 	if (CPA_TRUE == is_gmac_exception(csp))
34 		return CPA_FALSE;
35 
36 	if (CSP_MODE_AEAD == csp->csp_mode)
37 		if (CRYPTO_AES_NIST_GCM_16 == csp->csp_cipher_alg ||
38 		    CRYPTO_AES_NIST_GMAC == csp->csp_cipher_alg)
39 			return CPA_TRUE;
40 
41 	return CPA_FALSE;
42 }
43 
44 static inline CpaBoolean
45 is_use_sep_digest(const struct crypto_session_params *csp)
46 {
47 	/* Use separated digest for all digest/hash operations,
48 	 * including GMAC */
49 	if (CSP_MODE_DIGEST == csp->csp_mode || CSP_MODE_ETA == csp->csp_mode)
50 		return CPA_TRUE;
51 
52 	return CPA_FALSE;
53 }
54 
55 int qat_ocf_handle_session_update(struct qat_ocf_dsession *ocf_dsession,
56 				  struct cryptop *crp);
57 
58 CpaStatus qat_ocf_wait_for_session(CpaCySymSessionCtx sessionCtx,
59 				   Cpa32U timeoutMS);
60 
61 #endif /* _QAT_OCF_UTILS_H_ */
62