1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright(c) 2022 Intel Corporation */
3 #ifndef _QAT_COMP_REQ_H_
4 #define _QAT_COMP_REQ_H_
6 #include "icp_qat_fw_comp.h"
8 #define QAT_COMP_REQ_SIZE (sizeof(struct icp_qat_fw_comp_req))
9 #define QAT_COMP_CTX_SIZE (QAT_COMP_REQ_SIZE * 2)
11 static inline void qat_comp_create_req(void *ctx, void *req, u64 src, u32 slen,
12 u64 dst, u32 dlen, u64 opaque)
14 struct icp_qat_fw_comp_req *fw_tmpl = ctx;
15 struct icp_qat_fw_comp_req *fw_req = req;
16 struct icp_qat_fw_comp_req_params *req_pars = &fw_req->comp_pars;
18 memcpy(fw_req, fw_tmpl, sizeof(*fw_req));
19 fw_req->comn_mid.src_data_addr = src;
20 fw_req->comn_mid.src_length = slen;
21 fw_req->comn_mid.dest_data_addr = dst;
22 fw_req->comn_mid.dst_length = dlen;
23 fw_req->comn_mid.opaque_data = opaque;
24 req_pars->comp_len = slen;
25 req_pars->out_buffer_sz = dlen;
28 static inline void qat_comp_override_dst(void *req, u64 dst, u32 dlen)
30 struct icp_qat_fw_comp_req *fw_req = req;
31 struct icp_qat_fw_comp_req_params *req_pars = &fw_req->comp_pars;
33 fw_req->comn_mid.dest_data_addr = dst;
34 fw_req->comn_mid.dst_length = dlen;
35 req_pars->out_buffer_sz = dlen;
38 static inline void qat_comp_create_compression_req(void *ctx, void *req,
43 qat_comp_create_req(ctx, req, src, slen, dst, dlen, opaque);
46 static inline void qat_comp_create_decompression_req(void *ctx, void *req,
51 struct icp_qat_fw_comp_req *fw_tmpl = ctx;
54 qat_comp_create_req(fw_tmpl, req, src, slen, dst, dlen, opaque);
57 static inline u32 qat_comp_get_consumed_ctr(void *resp)
59 struct icp_qat_fw_comp_resp *qat_resp = resp;
61 return qat_resp->comp_resp_pars.input_byte_counter;
64 static inline u32 qat_comp_get_produced_ctr(void *resp)
66 struct icp_qat_fw_comp_resp *qat_resp = resp;
68 return qat_resp->comp_resp_pars.output_byte_counter;
71 static inline u32 qat_comp_get_produced_adler32(void *resp)
73 struct icp_qat_fw_comp_resp *qat_resp = resp;
75 return qat_resp->comp_resp_pars.crc.legacy.curr_adler_32;
78 static inline u64 qat_comp_get_opaque(void *resp)
80 struct icp_qat_fw_comp_resp *qat_resp = resp;
82 return qat_resp->opaque_data;
85 static inline s8 qat_comp_get_cmp_err(void *resp)
87 struct icp_qat_fw_comp_resp *qat_resp = resp;
89 return qat_resp->comn_resp.comn_error.cmp_err_code;
92 static inline s8 qat_comp_get_xlt_err(void *resp)
94 struct icp_qat_fw_comp_resp *qat_resp = resp;
96 return qat_resp->comn_resp.comn_error.xlat_err_code;
99 static inline s8 qat_comp_get_cmp_status(void *resp)
101 struct icp_qat_fw_comp_resp *qat_resp = resp;
102 u8 stat_filed = qat_resp->comn_resp.comn_status;
104 return ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(stat_filed);
107 static inline s8 qat_comp_get_xlt_status(void *resp)
109 struct icp_qat_fw_comp_resp *qat_resp = resp;
110 u8 stat_filed = qat_resp->comn_resp.comn_status;
112 return ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(stat_filed);
115 static inline u8 qat_comp_get_cmp_cnv_flag(void *resp)
117 struct icp_qat_fw_comp_resp *qat_resp = resp;
118 u8 flags = qat_resp->comn_resp.hdr_flags;
120 return ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(flags);