1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
6 * @file icp_qat_fw_pke.h
7 * @defgroup icp_qat_fw_pke ICP QAT FW PKE Processing Definitions
11 * This file documents the external interfaces that the QAT FW running
12 * on the QAT Acceleration Engine provides to clients wanting to
13 * accelerate crypto asymmetric applications
16 #ifndef _ICP_QAT_FW_PKE_H_
17 #define _ICP_QAT_FW_PKE_H_
20 * Keep all dpdk-specific changes in this section
30 /* End of DPDK-specific section
31 * Don't modify below this.
35 ****************************************************************************
36 * Include local header files
37 ****************************************************************************
39 #include "icp_qat_fw.h"
42 *****************************************************************************
44 * @ingroup icp_qat_fw_pke
47 * PKE response status field structure contained
48 * within LW1, comprising the common error codes and
51 *****************************************************************************/
52 struct icp_qat_fw_pke_resp_status {
54 /**< 8 bit common error code */
57 /**< 8-bit PKE response flags */
61 *****************************************************************************
62 * @ingroup icp_qat_fw_pke
63 * Definition of the QAT FW PKE request header pars field.
66 * PKE request message header pars structure
68 *****************************************************************************/
69 struct icp_qat_fw_req_hdr_pke_cd_pars {
71 u64 content_desc_addr;
72 /**< Content descriptor pointer */
75 u32 content_desc_resrvd;
76 /**< Content descriptor reserved field */
80 /**< MMP functionality Id */
84 *****************************************************************************
85 * @ingroup icp_qat_fw_pke
86 * Definition of the QAT FW PKE request header mid section.
89 * PKE request message header middle structure
91 *****************************************************************************/
92 struct icp_qat_fw_req_pke_mid {
95 /**< Opaque data passed unmodified from the request to response messages
100 /**< Generic definition of the source data supplied to the QAT AE. The
101 * common flags are used to further describe the attributes of this
106 /**< Generic definition of the destination data supplied to the QAT AE.
107 * The common flags are used to further describe the attributes of this
113 *****************************************************************************
114 * @ingroup icp_qat_fw_pke
115 * Definition of the QAT FW PKE request header.
118 * PKE request message header structure
120 *****************************************************************************/
121 struct icp_qat_fw_req_pke_hdr {
124 /**< reserved field */
127 /**< reserved field */
133 /**< This represents a flags field for the Service Request.
134 * The most significant bit is the 'valid' flag and the only
135 * one used. All remaining bit positions are unused and
136 * are therefore reserved and need to be set to 0.
141 /**< Common Request flags must indicate flat buffer
142 * Common Request flags - PKE slice flags no longer used - slice
143 * allocated to a threadstrand.
147 /** < KPT input parameters array mask, indicate which node in array is
152 /**< KPT random node(RN) mask - indicate which node is RN that QAT
153 * should generate itself.
157 struct icp_qat_fw_req_hdr_pke_cd_pars cd_pars;
158 /**< PKE request message header pars structure */
162 ***************************************************************************
164 * @ingroup icp_qat_fw_pke
167 * PKE request message structure (64 bytes)
169 *****************************************************************************/
170 struct icp_qat_fw_pke_request {
172 struct icp_qat_fw_req_pke_hdr pke_hdr;
173 /**< Request header for PKE - CD Header/Param size must be zero */
176 struct icp_qat_fw_req_pke_mid pke_mid;
177 /**< Request middle section for PKE */
180 u8 output_param_count;
181 /**< Number of output large integers for request */
183 u8 input_param_count;
184 /**< Number of input large integers for request */
195 /** < PKE - next request address */
199 *****************************************************************************
201 * @ingroup icp_qat_fw_pke
204 * PKE response message header structure
206 *****************************************************************************/
207 struct icp_qat_fw_resp_pke_hdr {
216 /**< Response type - copied from the request to the response message */
219 /**< This represents a flags field for the Response.
220 * The most significant bit is the 'valid' flag and the only
221 * one used. All remaining bit positions are unused and
222 * are therefore reserved
226 struct icp_qat_fw_pke_resp_status resp_status;
233 *****************************************************************************
235 * @ingroup icp_qat_fw_pke
238 * PKE response message structure (32 bytes)
240 *****************************************************************************/
241 struct icp_qat_fw_pke_resp {
243 struct icp_qat_fw_resp_pke_hdr pke_resp_hdr;
244 /**< Response header for PKE */
248 /**< Opaque data passed from the request to the response message */
252 /**< Generic definition of the source data supplied to the QAT AE. The
253 * common flags are used to further describe the attributes of this
259 /**< Generic definition of the destination data supplied to the QAT AE.
260 * The common flags are used to further describe the attributes of this
265 /* ========================================================================= */
266 /* MACRO DEFINITIONS */
267 /* ========================================================================= */
269 /**< @ingroup icp_qat_fw_pke
270 * Macro defining the bit position and mask of the 'valid' flag, within the
271 * hdr_flags field of LW0 (service request and response) of the PKE request
273 #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_BITPOS 7
274 #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_MASK 0x1
276 /**< @ingroup icp_qat_fw_pke
277 * Macro defining the bit position and mask of the PKE status flag, within the
278 * status field LW1 of a PKE response message
280 #define QAT_COMN_RESP_PKE_STATUS_BITPOS 6
281 /**< @ingroup icp_qat_fw_pke
282 * Starting bit position indicating the PKE status flag within the PKE response
283 * pke_resp_flags byte.
286 #define QAT_COMN_RESP_PKE_STATUS_MASK 0x1
287 /**< @ingroup icp_qat_fw_pke
288 * One bit mask used to determine PKE status mask
292 * < @ingroup icp_qat_fw_pke
293 * *** PKE Response Status Field Definition ***
294 * The PKE response follows the CPM 1.5 message format. The status field is
295 * 16 bits wide, where the status flags are contained within the most
296 * significant byte of the icp_qat_fw_pke_resp_status structure.
297 * The lower 8 bits of this word now contain the common error codes,
298 * which are defined in the common header file(*).
300 /* +=====+-----+----+-----+-----+-----+-----+-----+-----+---------------------+
301 * | Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | [7....0] |
302 * +=====+-----+----+-----+-----+-----+-----+-----+-----+---------------------+
303 * |Flags|Rsrvd|Pke |Rsrvd|Rsrvd|Rsrvd|Rsrvd|Rsrvd|Rsrvd|Common error codes(*)|
304 * +=====+-----+----+-----+-----+-----+-----+-----+-----+---------------------+
308 ******************************************************************************
309 * @ingroup icp_qat_fw_pke
312 * Macro for extraction of the PKE bit from the 16-bit status field
313 * particular to a PKE response. The status flags are contained within
314 * the most significant byte of the word. The lower 8 bits of this status
315 * word now contain the common error codes, which are defined in the common
316 * header file. The appropriate macro definition to extract the PKE status
317 * lag from the PKE response assumes that a single byte i.e. pke_resp_flags
318 * is passed to the macro.
321 * Status to extract the PKE status bit
323 *****************************************************************************/
324 #define ICP_QAT_FW_PKE_RESP_PKE_STAT_GET(flags) \
325 QAT_FIELD_GET((flags), QAT_COMN_RESP_PKE_STATUS_BITPOS, \
326 QAT_COMN_RESP_PKE_STATUS_MASK)
329 ******************************************************************************
330 * @ingroup icp_qat_fw_pke
333 * Extract the valid flag from the PKE Request's header flags. Note that
334 * this invokes the common macro which may be used by either the request
337 * @param icp_qat_fw_req_pke_hdr Structure passed to extract the valid bit
338 * from the 'hdr_flags' field.
340 *****************************************************************************/
341 #define ICP_QAT_FW_PKE_RQ_VALID_FLAG_GET(icp_qat_fw_req_pke_hdr) \
342 ICP_QAT_FW_PKE_HDR_VALID_FLAG_GET(icp_qat_fw_req_pke_hdr)
345 ******************************************************************************
346 * @ingroup icp_qat_fw_pke
349 * Set the valid bit in the PKE Request's header flags. Note that
350 * this invokes the common macro which may be used by either the request
353 * @param icp_qat_fw_req_pke_hdr Structure passed to set the valid bit.
354 * @param val Value of the valid bit flag.
356 *****************************************************************************/
357 #define ICP_QAT_FW_PKE_RQ_VALID_FLAG_SET(icp_qat_fw_req_pke_hdr, val) \
358 ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(icp_qat_fw_req_pke_hdr, val)
361 ******************************************************************************
362 * @ingroup icp_qat_fw_pke
365 * Extract the valid flag from the PKE Response's header flags. Note that
366 * invokes the common macro which may be used by either the request
369 * @param icp_qat_fw_resp_pke_hdr Structure to extract the valid bit
370 * from the 'hdr_flags' field.
372 *****************************************************************************/
373 #define ICP_QAT_FW_PKE_RESP_VALID_FLAG_GET(icp_qat_fw_resp_pke_hdr) \
374 ICP_QAT_FW_PKE_HDR_VALID_FLAG_GET(icp_qat_fw_resp_pke_hdr)
377 ******************************************************************************
378 * @ingroup icp_qat_fw_pke
381 * Set the valid bit in the PKE Response's header flags. Note that
382 * this invokes the common macro which may be used by either the
383 * request or the response.
385 * @param icp_qat_fw_resp_pke_hdr Structure to set the valid bit
386 * @param val Value of the valid bit flag.
388 *****************************************************************************/
389 #define ICP_QAT_FW_PKE_RESP_VALID_FLAG_SET(icp_qat_fw_resp_pke_hdr, val) \
390 ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(icp_qat_fw_resp_pke_hdr, val)
393 ******************************************************************************
394 * @ingroup icp_qat_fw_pke
397 * Common macro to extract the valid flag from the header flags field
398 * within the header structure (request or response).
400 * @param hdr Structure (request or response) to extract the
401 * valid bit from the 'hdr_flags' field.
403 *****************************************************************************/
404 #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_GET(hdr) \
405 QAT_FIELD_GET(hdr.hdr_flags, ICP_QAT_FW_PKE_HDR_VALID_FLAG_BITPOS, \
406 ICP_QAT_FW_PKE_HDR_VALID_FLAG_MASK)
409 ******************************************************************************
410 * @ingroup icp_qat_fw_pke
413 * Common macro to set the valid bit in the header flags field within
414 * the header structure (request or response).
416 * @param hdr Structure (request or response) containing the header
417 * flags field, to allow the valid bit to be set.
418 * @param val Value of the valid bit flag.
420 *****************************************************************************/
421 #define ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(hdr, val) \
422 QAT_FIELD_SET((hdr.hdr_flags), (val), \
423 ICP_QAT_FW_PKE_HDR_VALID_FLAG_BITPOS, \
424 ICP_QAT_FW_PKE_HDR_VALID_FLAG_MASK)
426 #endif /* _ICP_QAT_FW_PKE_H_ */