1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /**
4 *****************************************************************************
5 * @file sal_qat_cmn_msg.h
6 *
7 * @defgroup SalQatCmnMessage
8 *
9 * @ingroup SalQatCmnMessage
10 *
11 * Interfaces for populating the common QAT structures for a lookaside
12 * operation.
13 *
14 *****************************************************************************/
15
16 /*
17 ******************************************************************************
18 * Include public/global header files
19 ******************************************************************************
20 */
21 #include "cpa.h"
22
23 /*
24 *******************************************************************************
25 * Include private header files
26 *******************************************************************************
27 */
28 #include "qat_utils.h"
29 #include "icp_accel_devices.h"
30 #include "icp_qat_fw_la.h"
31 #include "icp_qat_hw.h"
32 #include "lac_common.h"
33 #include "lac_mem.h"
34 #include "sal_qat_cmn_msg.h"
35
36 /********************************************************************
37 * @ingroup SalQatMsg_CmnHdrWrite
38 *
39 * @description
40 * This function fills in all fields in the icp_qat_fw_comn_req_hdr_t
41 * section of the Request Msg. Build LW0 + LW1 -
42 * service part of the request
43 *
44 * @param[in] pMsg Pointer to 128B Request Msg buffer
45 * @param[in] serviceType type of service request
46 * @param[in] serviceCmdId id for the type of service request
47 * @param[in] cmnFlags common request flags
48 * @param[in] serviceCmdFlags service command flahgs
49 *
50 * @return
51 * None
52 *
53 *****************************************/
54 void
SalQatMsg_CmnHdrWrite(icp_qat_fw_comn_req_t * pMsg,icp_qat_fw_comn_request_id_t serviceType,uint8_t serviceCmdId,icp_qat_fw_comn_flags cmnFlags,icp_qat_fw_serv_specif_flags serviceCmdFlags)55 SalQatMsg_CmnHdrWrite(icp_qat_fw_comn_req_t *pMsg,
56 icp_qat_fw_comn_request_id_t serviceType,
57 uint8_t serviceCmdId,
58 icp_qat_fw_comn_flags cmnFlags,
59 icp_qat_fw_serv_specif_flags serviceCmdFlags)
60 {
61 icp_qat_fw_comn_req_hdr_t *pHeader = &(pMsg->comn_hdr);
62
63 /* LW0 */
64 pHeader->hdr_flags =
65 ICP_QAT_FW_COMN_HDR_FLAGS_BUILD(ICP_QAT_FW_COMN_REQ_FLAG_SET);
66 pHeader->service_type = (uint8_t)serviceType;
67 pHeader->service_cmd_id = serviceCmdId;
68 pHeader->resrvd1 = 0;
69 /* LW1 */
70 pHeader->comn_req_flags = cmnFlags;
71 pHeader->serv_specif_flags = serviceCmdFlags;
72 }
73
74 /********************************************************************
75 * @ingroup SalQatCmnMessage
76 *
77 * @description
78 * This function fills in all fields in the icp_qat_fw_comn_req_mid_t
79 * section of the Request Msg and the corresponding SGL/Flat flag
80 * in the Hdr.
81 *
82 * @param[in] pReq Pointer to 128B Request Msg buffer
83 * @param[in] pOpaqueData Pointer to opaque data used by callback
84 * @param[in] bufferFormat src and dst Buffers are either SGL or Flat
85 * format
86 * @param[in] pSrcBuffer Address of source buffer
87 * @param[in] pDstBuffer Address of destination buffer
88 * @param[in] pSrcLength Length of source buffer
89 * @param[in] pDstLength Length of destination buffer
90 *
91
92 * @assumptions
93 * All fields in mid section are zero before fn is called
94
95 * @return
96 * None
97 *
98 *****************************************/
SalQatMsg_CmnMidWrite(icp_qat_fw_la_bulk_req_t * pReq,const void * pOpaqueData,Cpa8U bufferFormat,Cpa64U srcBuffer,Cpa64U dstBuffer,Cpa32U srcLength,Cpa32U dstLength)99 void inline SalQatMsg_CmnMidWrite(icp_qat_fw_la_bulk_req_t *pReq,
100 const void *pOpaqueData,
101 Cpa8U bufferFormat,
102 Cpa64U srcBuffer,
103 Cpa64U dstBuffer,
104 Cpa32U srcLength,
105 Cpa32U dstLength)
106 {
107 icp_qat_fw_comn_req_mid_t *pMid = &(pReq->comn_mid);
108
109 LAC_MEM_SHARED_WRITE_FROM_PTR(pMid->opaque_data, pOpaqueData);
110 pMid->src_data_addr = srcBuffer;
111
112 /* In place */
113 if (0 == dstBuffer) {
114 pMid->dest_data_addr = srcBuffer;
115 }
116 /* Out of place */
117 else {
118 pMid->dest_data_addr = dstBuffer;
119 }
120
121 if (bufferFormat == QAT_COMN_PTR_TYPE_SGL) {
122 /* Using ScatterGatherLists so set flag in header */
123 ICP_QAT_FW_COMN_PTR_TYPE_SET(pReq->comn_hdr.comn_req_flags,
124 QAT_COMN_PTR_TYPE_SGL);
125
126 /* Assumption: No need to set src and dest length in this case
127 * as not
128 * used */
129
130 } else {
131 /* Using Flat buffers so set flag in header */
132 ICP_QAT_FW_COMN_PTR_TYPE_SET(pReq->comn_hdr.comn_req_flags,
133 QAT_COMN_PTR_TYPE_FLAT);
134
135 pMid->src_length = srcLength;
136 pMid->dst_length = dstLength;
137 }
138 }
139
140 /********************************************************************
141 * @ingroup SalQatMsg_ContentDescHdrWrite
142 *
143 * @description
144 * This function fills in all fields in the
145 * icp_qat_fw_comn_req_hdr_cd_pars_t section of the Request Msg.
146 *
147 * @param[in] pMsg Pointer to 128B Request Msg buffer.
148 * @param[in] pContentDescInfo content descripter info.
149 *
150 * @return
151 * none
152 *
153 *****************************************/
154 void
SalQatMsg_ContentDescHdrWrite(icp_qat_fw_comn_req_t * pMsg,const sal_qat_content_desc_info_t * pContentDescInfo)155 SalQatMsg_ContentDescHdrWrite(
156 icp_qat_fw_comn_req_t *pMsg,
157 const sal_qat_content_desc_info_t *pContentDescInfo)
158 {
159 icp_qat_fw_comn_req_hdr_cd_pars_t *pCd_pars = &(pMsg->cd_pars);
160
161 pCd_pars->s.content_desc_addr =
162 pContentDescInfo->hardwareSetupBlockPhys;
163 pCd_pars->s.content_desc_params_sz = pContentDescInfo->hwBlkSzQuadWords;
164 pCd_pars->s.content_desc_resrvd1 = 0;
165 pCd_pars->s.content_desc_hdr_resrvd2 = 0;
166 pCd_pars->s.content_desc_resrvd3 = 0;
167 }
168
169 /********************************************************************
170 * @ingroup SalQatMsg_CtrlBlkSetToReserved
171 *
172 * @description
173 * This function sets the whole control block to a reserved state.
174 *
175 * @param[in] _pMsg Pointer to 128B Request Msg buffer.
176 *
177 * @return
178 * none
179 *
180 *****************************************/
181 void
SalQatMsg_CtrlBlkSetToReserved(icp_qat_fw_comn_req_t * pMsg)182 SalQatMsg_CtrlBlkSetToReserved(icp_qat_fw_comn_req_t *pMsg)
183 {
184
185 icp_qat_fw_comn_req_cd_ctrl_t *pCd_ctrl = &(pMsg->cd_ctrl);
186
187 memset(pCd_ctrl, 0, sizeof(icp_qat_fw_comn_req_cd_ctrl_t));
188 }
189
190 /********************************************************************
191 * @ingroup SalQatMsg_transPutMsg
192 *
193 * @description
194 *
195 *
196 * @param[in] trans_handle
197 * @param[in] pqat_msg
198 * @param[in] size_in_lws
199 * @param[in] service
200 *
201 * @return
202 * CpaStatus
203 *
204 *****************************************/
205 CpaStatus
SalQatMsg_transPutMsg(icp_comms_trans_handle trans_handle,void * pqat_msg,Cpa32U size_in_lws,Cpa8U service)206 SalQatMsg_transPutMsg(icp_comms_trans_handle trans_handle,
207 void *pqat_msg,
208 Cpa32U size_in_lws,
209 Cpa8U service)
210 {
211 return icp_adf_transPutMsg(trans_handle, pqat_msg, size_in_lws);
212 }
213
214 void
SalQatMsg_updateQueueTail(icp_comms_trans_handle trans_handle)215 SalQatMsg_updateQueueTail(icp_comms_trans_handle trans_handle)
216 {
217 icp_adf_updateQueueTail(trans_handle);
218 }
219