1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /**
4  *****************************************************************************
5  * @file sal_qat_cmn_msg.c
6  *
7  * @ingroup SalQatCmnMessage
8  *
9  * @description
10  *    Implementation for populating the common (across services) QAT structures.
11  *
12  *****************************************************************************/
13 #ifndef SAL_QAT_CMN_MSG_H
14 #define SAL_QAT_CMN_MSG_H
15 /*
16  *******************************************************************************
17  * Include public/global header files
18  *******************************************************************************
19  */
20 #include "cpa.h"
21 
22 /*
23  *******************************************************************************
24  * Include private header files
25  *******************************************************************************
26  */
27 #include "lac_common.h"
28 #include "icp_accel_devices.h"
29 #include "qat_utils.h"
30 
31 #include "cpa_cy_sym.h"
32 #include "lac_mem.h"
33 #include "lac_mem_pools.h"
34 #include "lac_list.h"
35 #include "icp_adf_transport.h"
36 #include "icp_adf_transport_dp.h"
37 
38 #include "icp_qat_hw.h"
39 #include "icp_qat_fw.h"
40 #include "icp_qat_fw_la.h"
41 
42 /**
43  ******************************************************************************
44  * @ingroup SalQatCmnMessage
45  *      content descriptor info structure
46  *
47  * @description
48  *      This structure contains generic information on the content descriptor
49  *
50  *****************************************************************************/
51 typedef struct sal_qat_content_desc_info_s {
52 	CpaPhysicalAddr hardwareSetupBlockPhys;
53 	/**< Physical address of hardware setup block of the content descriptor
54 	 */
55 	void *pData;
56 	/**< Virtual Pointer to the hardware setup block of the content
57 	 * descriptor */
58 	Cpa8U hwBlkSzQuadWords;
59 	/**< Hardware Setup Block size in quad words */
60 } sal_qat_content_desc_info_t;
61 
62 /**
63  *******************************************************************************
64  * @ingroup SalQatCmnMessage
65  *      Lookaside response handler function type
66  *
67  * @description
68  *      This type definition specifies the function prototype for handling the
69  *      response messages for a specific symmetric operation
70  *
71  * @param[in] lacCmdId      Look Aside Command ID
72  *
73  * @param[in] pOpaqueData   Pointer to Opaque Data
74  *
75  * @param[in] cmnRespFlags  Common Response flags
76  *
77  * @return void
78  *
79  *****************************************************************************/
80 typedef void (*sal_qat_resp_handler_func_t)(icp_qat_fw_la_cmd_id_t lacCmdId,
81 					    void *pOpaqueData,
82 					    icp_qat_fw_comn_flags cmnRespFlags);
83 
84 /********************************************************************
85  * @ingroup SalQatMsg_CmnHdrWrite
86  *
87  * @description
88  *      This function fills in all fields in the icp_qat_fw_comn_req_hdr_t
89  *      section of the Request Msg. Build LW0 + LW1 -
90  *      service part of the request
91  *
92  * @param[in]   pMsg            Pointer to 128B Request Msg buffer
93  * @param[in]   serviceType     type of service request
94  * @param[in]   serviceCmdId    id for the type of service request
95  * @param[in]   cmnFlags        common request flags
96  * @param[in]   serviceCmdFlags service command flahgs
97  *
98  * @return
99  *      None
100  *
101  *****************************************/
102 void SalQatMsg_CmnHdrWrite(icp_qat_fw_comn_req_t *pMsg,
103 			   icp_qat_fw_comn_request_id_t serviceType,
104 			   uint8_t serviceCmdId,
105 			   icp_qat_fw_comn_flags cmnFlags,
106 			   icp_qat_fw_serv_specif_flags serviceCmdFlags);
107 
108 /********************************************************************
109  * @ingroup SalQatMsg_CmnMidWrite
110  *
111  * @description
112  *      This function fills in all fields in the icp_qat_fw_comn_req_mid_t
113  *      section of the Request Msg and the corresponding SGL/Flat flag
114  *      in the Hdr.
115  *
116  * @param[in]   pReq            Pointer to 128B Request Msg buffer
117  * @param[in]   pOpaqueData     Pointer to opaque data used by callback
118  * @param[in]   bufferFormat    src and dst Buffers are either SGL or Flat
119  format
120  * @param[in]   pSrcBuffer      Address of source buffer
121  * @param[in]   pDstBuffer      Address of destination buffer
122  * @param[in]   pSrcLength      Length of source buffer
123  * @param[in]   pDstLength      Length of destination buffer
124  *
125 
126  * @assumptions
127  *      All fields in mid section are zero before fn is called
128 
129  * @return
130  *      None
131  *
132  *****************************************/
133 void SalQatMsg_CmnMidWrite(icp_qat_fw_la_bulk_req_t *pReq,
134 			   const void *pOpaqueData,
135 			   Cpa8U bufferFormat,
136 			   Cpa64U srcBuffer,
137 			   Cpa64U dstBuffer,
138 			   Cpa32U srcLength,
139 			   Cpa32U dstLength);
140 
141 /********************************************************************
142  * @ingroup SalQatMsg_ContentDescHdrWrite
143  *
144  * @description
145  *      This function fills in all fields in the
146  *icp_qat_fw_comn_req_hdr_cd_pars_t
147  *      section of the Request Msg.
148  *
149  * @param[in]   pMsg            Pointer to 128B Request Msg buffer.
150  * @param[in]   pContentDescInfo content descripter info.
151  *
152  * @return
153  *      none
154  *
155  *****************************************/
156 void SalQatMsg_ContentDescHdrWrite(
157     icp_qat_fw_comn_req_t *pMsg,
158     const sal_qat_content_desc_info_t *pContentDescInfo);
159 
160 /********************************************************************
161  * @ingroup SalQatMsg_CtrlBlkSetToReserved
162  *
163  * @description
164  *      This function set the whole contrle block to a reserved state.
165  *
166  * @param[in]   _pMsg            Pointer to 128B Request Msg buffer.
167  *
168  * @return
169  *      none
170  *
171  *****************************************/
172 void SalQatMsg_CtrlBlkSetToReserved(icp_qat_fw_comn_req_t *_pMsg);
173 
174 /********************************************************************
175  * @ingroup SalQatMsg_transPutMsg
176  *
177  * @description
178  *
179  *
180  * @param[in]   trans_handle
181  * @param[in]   pqat_msg
182  * @param[in]   size_in_lws
183  * @param[in]   service
184  *
185  * @return
186  *      CpaStatus
187  *
188  *****************************************/
189 CpaStatus SalQatMsg_transPutMsg(icp_comms_trans_handle trans_handle,
190 				void *pqat_msg,
191 				Cpa32U size_in_lws,
192 				Cpa8U service);
193 
194 /********************************************************************
195  * @ingroup SalQatMsg_updateQueueTail
196  *
197  * @description
198  *
199  *
200  * @param[in]   trans_handle
201  *
202  *
203  * @return
204  *      CpaStatus
205  *
206  *****************************************/
207 void SalQatMsg_updateQueueTail(icp_comms_trans_handle trans_hnd);
208 #endif
209