1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 Intel Corporation
8 #ifdef RTE_LIB_COMPRESSDEV
10 #include <rte_compressdev.h>
11 #include <rte_compressdev_pmd.h>
13 #include "qat_common.h"
15 #include "icp_qat_hw.h"
16 #include "icp_qat_fw_comp.h"
17 #include "icp_qat_fw_la.h"
19 #define QAT_64_BYTE_ALIGN_MASK (~0x3f)
20 #define QAT_64_BYTE_ALIGN (64)
21 #define QAT_NUM_BUFS_IN_IM_SGL 1
23 #define ERR_CODE_QAT_COMP_WRONG_FW -99
25 /* fallback to fixed compression threshold */
26 #define QAT_FALLBACK_THLD ((uint32_t)(RTE_PMD_QAT_COMP_IM_BUFFER_SIZE / 1.3))
28 #define QAT_MIN_OUT_BUF_SIZE 46
30 /* maximum size of the state registers */
31 #define QAT_STATE_REGISTERS_MAX_SIZE 64
33 /* decompressor context size */
34 #define QAT_INFLATE_CONTEXT_SIZE_GEN1 36864
35 #define QAT_INFLATE_CONTEXT_SIZE_GEN2 34032
36 #define QAT_INFLATE_CONTEXT_SIZE_GEN3 34032
37 #define QAT_INFLATE_CONTEXT_SIZE RTE_MAX(RTE_MAX(QAT_INFLATE_CONTEXT_SIZE_GEN1,\
38 QAT_INFLATE_CONTEXT_SIZE_GEN2), QAT_INFLATE_CONTEXT_SIZE_GEN3)
40 enum qat_comp_request_type {
41 QAT_COMP_REQUEST_FIXED_COMP_STATELESS,
42 QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS,
43 QAT_COMP_REQUEST_DECOMPRESS,
47 struct array_of_ptrs {
48 phys_addr_t pointer[0];
51 struct qat_inter_sgl {
53 struct qat_flat_buf buffers[QAT_NUM_BUFS_IN_IM_SGL];
54 } __rte_packed __rte_cache_aligned;
57 struct qat_comp_op_cookie {
58 phys_addr_t qat_sgl_src_phys_addr;
59 phys_addr_t qat_sgl_dst_phys_addr;
60 /* dynamically created SGLs */
63 uint16_t src_nb_elems;
64 uint16_t dst_nb_elems;
65 struct qat_sgl *qat_sgl_src_d;
66 struct qat_sgl *qat_sgl_dst_d;
68 uint32_t cookie_index;
70 /* QAT IM buffer too small handling: */
74 /* used by the parent only */
75 uint8_t nb_child_responses;
76 uint32_t total_consumed;
77 uint32_t total_produced;
78 const struct rte_memzone **dst_memzones;
79 struct rte_mbuf *dst_data;
80 uint32_t dst_data_offset;
82 /* used by the child only */
83 struct qat_comp_op_cookie *parent_cookie;
87 struct qat_comp_xform {
88 struct icp_qat_fw_comp_req qat_comp_req_tmpl;
89 enum qat_comp_request_type qat_comp_request_type;
90 enum rte_comp_checksum_type checksum_type;
93 struct qat_comp_stream {
94 struct qat_comp_xform qat_xform;
95 void *state_registers_decomp;
96 phys_addr_t state_registers_decomp_phys;
97 void *inflate_context;
98 phys_addr_t inflate_context_phys;
99 const struct rte_memzone *memzone;
100 uint8_t start_of_packet;
101 volatile uint8_t op_in_progress;
105 qat_comp_build_request(void *in_op, uint8_t *out_msg, void *op_cookie,
106 enum qat_device_gen qat_dev_gen __rte_unused);
109 qat_comp_build_multiple_requests(void *in_op, struct qat_qp *qp,
110 uint32_t parent_tail, int nb_descr);
113 qat_comp_free_split_op_memzones(struct qat_comp_op_cookie *cookie,
114 unsigned int nb_children);
117 qat_comp_process_response(void **op, uint8_t *resp, void *op_cookie,
118 uint64_t *dequeue_err_count);
121 qat_comp_private_xform_create(struct rte_compressdev *dev,
122 const struct rte_comp_xform *xform,
123 void **private_xform);
126 qat_comp_private_xform_free(struct rte_compressdev *dev, void *private_xform);
129 qat_comp_xform_size(void);
132 qat_comp_stream_size(void);
135 qat_comp_stream_create(struct rte_compressdev *dev,
136 const struct rte_comp_xform *xform,
140 qat_comp_stream_free(struct rte_compressdev *dev, void *stream);