1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 
5 /**
6  *****************************************************************************
7  * @file lac_sym_qat_constants_table.h
8  *
9  * @ingroup  LacSymQat
10  *
11  * API to be used for the CySym constants table.
12  *
13  *****************************************************************************/
14 
15 #ifndef LAC_SYM_QAT_CONSTANTS_TABLE_H
16 #define LAC_SYM_QAT_CONSTANTS_TABLE_H
17 
18 #include "cpa.h"
19 #include "icp_qat_fw_la.h"
20 
21 typedef struct lac_sym_qat_constants_s {
22 	/* Note these arrays must match the tables in lac_sym_qat_constants.c
23 	 * icp_qat_hw_cipher_lookup_tbl and icp_qat_hw_auth_lookup_tbl */
24 	uint8_t cipher_offset[ICP_QAT_HW_CIPHER_DELIMITER]
25 			     [ICP_QAT_HW_CIPHER_MODE_DELIMITER][2][2];
26 	uint8_t auth_offset[ICP_QAT_HW_AUTH_ALGO_DELIMITER]
27 			   [ICP_QAT_HW_AUTH_MODE_DELIMITER][2];
28 } lac_sym_qat_constants_t;
29 
30 /**
31  *******************************************************************************
32  * @ingroup LacSymQat
33  *      LacSymQat_ConstantsInitLookupTables
34  *
35  *
36  * @description
37  *      The SymCy constants table is 1K of static data which is passed down
38  *      to the FW to be stored in SHRAM for use by the FW.
39  *      This function populates the associated lookup tables which the IA
40  *      driver uses.
41  *      Where there is config data available in the constants table the lookup
42  *      table stores the offset into the constants table.
43  *      Where there's no suitable config data available in the constants table
44  *      zero is stored in the lookup table.
45  *
46  * @return none
47  *
48  *****************************************************************************/
49 void LacSymQat_ConstantsInitLookupTables(CpaInstanceHandle instanceHandle);
50 
51 /**
52 *******************************************************************************
53 * @ingroup LacSymQat
54 *      LacSymQat_ConstantsGetCipherOffset
55 *
56 * @description
57 *      This function looks up the cipher constants lookup array for
58 *      a specific cipher algorithm, mode, direction and convert flag.
59 *      If the lookup table value is zero then there's no suitable config data
60 *      available in the constants table.
61 *      If the value > zero, then there is config data available in the constants
62 *      table which is stored in SHRAM for use by the FW. The value is the offset
63 *      into the constants table, it is returned to the caller in poffset.
64 *
65 *
66 * @param[in]       Cipher Algorithm
67 * @param[in]       Cipher Mode
68 * @param[in]       Direction - encrypt/decrypt
69 * @param[in]       convert / no convert
70 * @param[out]      offset into constants table
71 *
72 * @return none
73 *
74 *****************************************************************************/
75 void LacSymQat_ConstantsGetCipherOffset(CpaInstanceHandle instanceHandle,
76 					uint8_t algo,
77 					uint8_t mode,
78 					uint8_t direction,
79 					uint8_t convert,
80 					uint8_t *poffset);
81 
82 /**
83 *******************************************************************************
84 * @ingroup LacSymQat
85 *      LacSymQat_ConstantsGetAuthOffset
86 *
87 * @description
88 *      This function looks up the auth constants lookup array for
89 *      a specific auth algorithm, mode, direction and convert flag.
90 *      If the lookup table value is zero then there's no suitable config data
91 *      available in the constants table.
92 *      If the value > zero, then there is config data available in the constants
93 *      table which is stored in SHRAM for use by the FW. The value is the offset
94 *      into the constants table, it is returned to the caller in poffset.
95 *
96 *
97 * @param[in]       auth Algorithm
98 * @param[in]       auth Mode
99 * @param[in]       nested / no nested
100 * @param[out]      offset into constants table
101 *
102 * @return none
103 *
104 *****************************************************************************/
105 void LacSymQat_ConstantsGetAuthOffset(CpaInstanceHandle instanceHandle,
106 				      uint8_t algo,
107 				      uint8_t mode,
108 				      uint8_t nested,
109 				      uint8_t *poffset);
110 
111 #endif /* LAC_SYM_QAT_SHRAM_CONSTANTS_TABLE_H */
112