net/mlx5: retry on link update failure
[dpdk.git] / drivers / compress / qat / qat_comp.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2019 Intel Corporation
3  */
4
5 #ifndef _QAT_COMP_H_
6 #define _QAT_COMP_H_
7
8 #ifdef RTE_LIBRTE_COMPRESSDEV
9
10 #include <rte_compressdev.h>
11 #include <rte_compressdev_pmd.h>
12
13 #include "qat_common.h"
14 #include "icp_qat_hw.h"
15 #include "icp_qat_fw_comp.h"
16 #include "icp_qat_fw_la.h"
17
18 #define QAT_64_BYTE_ALIGN_MASK (~0x3f)
19 #define QAT_64_BYTE_ALIGN (64)
20 #define QAT_NUM_BUFS_IN_IM_SGL 1
21
22 #define ERR_CODE_QAT_COMP_WRONG_FW -99
23
24 /* fallback to fixed compression threshold */
25 #define QAT_FALLBACK_THLD ((uint32_t)(RTE_PMD_QAT_COMP_IM_BUFFER_SIZE / 1.1))
26
27 #define QAT_MIN_OUT_BUF_SIZE 46
28
29 /* maximum size of the state registers */
30 #define QAT_STATE_REGISTERS_MAX_SIZE 64
31
32 /* decompressor context size */
33 #define QAT_INFLATE_CONTEXT_SIZE_GEN1 36864
34 #define QAT_INFLATE_CONTEXT_SIZE_GEN2 34032
35 #define QAT_INFLATE_CONTEXT_SIZE_GEN3 34032
36 #define QAT_INFLATE_CONTEXT_SIZE RTE_MAX(RTE_MAX(QAT_INFLATE_CONTEXT_SIZE_GEN1,\
37                 QAT_INFLATE_CONTEXT_SIZE_GEN2), QAT_INFLATE_CONTEXT_SIZE_GEN3)
38
39 enum qat_comp_request_type {
40         QAT_COMP_REQUEST_FIXED_COMP_STATELESS,
41         QAT_COMP_REQUEST_DYNAMIC_COMP_STATELESS,
42         QAT_COMP_REQUEST_DECOMPRESS,
43         REQ_COMP_END
44 };
45
46 struct array_of_ptrs {
47         phys_addr_t pointer[0];
48 };
49
50 struct qat_inter_sgl {
51         qat_sgl_hdr;
52         struct qat_flat_buf buffers[QAT_NUM_BUFS_IN_IM_SGL];
53 } __rte_packed __rte_cache_aligned;
54
55
56 struct qat_comp_op_cookie {
57         phys_addr_t qat_sgl_src_phys_addr;
58         phys_addr_t qat_sgl_dst_phys_addr;
59         /* dynamically created SGLs */
60         uint8_t error;
61         uint8_t socket_id;
62         uint16_t src_nb_elems;
63         uint16_t dst_nb_elems;
64         struct qat_sgl *qat_sgl_src_d;
65         struct qat_sgl *qat_sgl_dst_d;
66 };
67
68 struct qat_comp_xform {
69         struct icp_qat_fw_comp_req qat_comp_req_tmpl;
70         enum qat_comp_request_type qat_comp_request_type;
71         enum rte_comp_checksum_type checksum_type;
72 };
73
74 struct qat_comp_stream {
75         struct qat_comp_xform qat_xform;
76         void *state_registers_decomp;
77         phys_addr_t state_registers_decomp_phys;
78         void *inflate_context;
79         phys_addr_t inflate_context_phys;
80         const struct rte_memzone *memzone;
81         uint8_t start_of_packet;
82         volatile uint8_t op_in_progress;
83 };
84
85 int
86 qat_comp_build_request(void *in_op, uint8_t *out_msg, void *op_cookie,
87                        enum qat_device_gen qat_dev_gen __rte_unused);
88
89 int
90 qat_comp_process_response(void **op, uint8_t *resp, void *op_cookie,
91                           uint64_t *dequeue_err_count);
92
93 int
94 qat_comp_private_xform_create(struct rte_compressdev *dev,
95                               const struct rte_comp_xform *xform,
96                               void **private_xform);
97
98 int
99 qat_comp_private_xform_free(struct rte_compressdev *dev, void *private_xform);
100
101 unsigned int
102 qat_comp_xform_size(void);
103
104 unsigned int
105 qat_comp_stream_size(void);
106
107 int
108 qat_comp_stream_create(struct rte_compressdev *dev,
109                        const struct rte_comp_xform *xform,
110                        void **stream);
111
112 int
113 qat_comp_stream_free(struct rte_compressdev *dev, void *stream);
114
115 #endif
116 #endif