File Index
Files and directories
Sign in
FILE

qat_comp_req.h

File preview with syntax highlighting.

linux-6.19.14/drivers/crypto/intel/qat/qat_common/qat_comp_req.h C
  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_
  5
  6#include "icp_qat_fw_comp.h"
  7
  8#define QAT_COMP_REQ_SIZE (sizeof(struct icp_qat_fw_comp_req))
  9#define QAT_COMP_CTX_SIZE (QAT_COMP_REQ_SIZE * 2)
 10
 11static inline void qat_comp_create_req(void *ctx, void *req, u64 src, u32 slen,
 12				       u64 dst, u32 dlen, u64 opaque)
 13{
 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;
 17
 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;
 26}
 27
 28static inline void qat_comp_create_compression_req(void *ctx, void *req,
 29						   u64 src, u32 slen,
 30						   u64 dst, u32 dlen,
 31						   u64 opaque)
 32{
 33	qat_comp_create_req(ctx, req, src, slen, dst, dlen, opaque);
 34}
 35
 36static inline void qat_comp_create_decompression_req(void *ctx, void *req,
 37						     u64 src, u32 slen,
 38						     u64 dst, u32 dlen,
 39						     u64 opaque)
 40{
 41	struct icp_qat_fw_comp_req *fw_tmpl = ctx;
 42
 43	fw_tmpl++;
 44	qat_comp_create_req(fw_tmpl, req, src, slen, dst, dlen, opaque);
 45}
 46
 47static inline u32 qat_comp_get_consumed_ctr(void *resp)
 48{
 49	struct icp_qat_fw_comp_resp *qat_resp = resp;
 50
 51	return qat_resp->comp_resp_pars.input_byte_counter;
 52}
 53
 54static inline u32 qat_comp_get_produced_ctr(void *resp)
 55{
 56	struct icp_qat_fw_comp_resp *qat_resp = resp;
 57
 58	return qat_resp->comp_resp_pars.output_byte_counter;
 59}
 60
 61static inline u32 qat_comp_get_produced_adler32(void *resp)
 62{
 63	struct icp_qat_fw_comp_resp *qat_resp = resp;
 64
 65	return qat_resp->comp_resp_pars.crc.legacy.curr_adler_32;
 66}
 67
 68static inline u64 qat_comp_get_opaque(void *resp)
 69{
 70	struct icp_qat_fw_comp_resp *qat_resp = resp;
 71
 72	return qat_resp->opaque_data;
 73}
 74
 75static inline s8 qat_comp_get_cmp_err(void *resp)
 76{
 77	struct icp_qat_fw_comp_resp *qat_resp = resp;
 78
 79	return qat_resp->comn_resp.comn_error.cmp_err_code;
 80}
 81
 82static inline s8 qat_comp_get_xlt_err(void *resp)
 83{
 84	struct icp_qat_fw_comp_resp *qat_resp = resp;
 85
 86	return qat_resp->comn_resp.comn_error.xlat_err_code;
 87}
 88
 89static inline s8 qat_comp_get_cmp_status(void *resp)
 90{
 91	struct icp_qat_fw_comp_resp *qat_resp = resp;
 92	u8 stat_filed = qat_resp->comn_resp.comn_status;
 93
 94	return ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(stat_filed);
 95}
 96
 97static inline s8 qat_comp_get_xlt_status(void *resp)
 98{
 99	struct icp_qat_fw_comp_resp *qat_resp = resp;
100	u8 stat_filed = qat_resp->comn_resp.comn_status;
101
102	return ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(stat_filed);
103}
104
105static inline u8 qat_comp_get_cmp_cnv_flag(void *resp)
106{
107	struct icp_qat_fw_comp_resp *qat_resp = resp;
108	u8 flags = qat_resp->comn_resp.hdr_flags;
109
110	return ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(flags);
111}
112
113#endif
~/ Read-only file preview.