1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 /**
5  ***************************************************************************
6  * @file sal_types_compression.h
7  *
8  * @ingroup SalCtrl
9  *
10  * Generic compression instance type definition
11  *
12  ***************************************************************************/
13 #ifndef SAL_TYPES_COMPRESSION_H_
14 #define SAL_TYPES_COMPRESSION_H_
15 
16 #include "cpa_dc.h"
17 #include "cpa_dc_dp.h"
18 #include "lac_sal_types.h"
19 #include "icp_qat_hw.h"
20 #include "icp_buffer_desc.h"
21 
22 #include "lac_mem_pools.h"
23 #include "icp_adf_transport.h"
24 
25 #define DC_NUM_RX_RINGS (1)
26 #define DC_NUM_COMPRESSION_LEVELS (CPA_DC_L9)
27 
28 /**
29  *****************************************************************************
30  * @ingroup SalCtrl
31  *      Compression device specific data
32  *
33  * @description
34  *      Contains device specific information for a compression service.
35  *
36  *****************************************************************************/
37 typedef struct sal_compression_device_data {
38 	/* Device specific minimum output buffer size for static compression */
39 	Cpa32U minOutputBuffSize;
40 
41 	/* Device specific minimum output buffer size for dynamic compression */
42 	Cpa32U minOutputBuffSizeDynamic;
43 
44 	/* Enable/disable secureRam/acceleratorRam for intermediate buffers*/
45 	Cpa8U useDevRam;
46 
47 	/* When set, implies device can decompress interim odd byte length
48 	 * stateful decompression requests.
49 	 */
50 	CpaBoolean oddByteDecompInterim;
51 
52 	/* When set, implies device can decompress odd byte length
53 	 * stateful decompression requests when bFinal is absent
54 	 */
55 	CpaBoolean oddByteDecompNobFinal;
56 
57 	/* Flag to indicate if translator slice overflow is supported */
58 	CpaBoolean translatorOverflow;
59 
60 	/* Flag to enable/disable delayed match mode */
61 	icp_qat_hw_compression_delayed_match_t enableDmm;
62 
63 	Cpa32U inflateContextSize;
64 	Cpa8U highestHwCompressionDepth;
65 
66 	/* Mask that reports supported window sizes for comp/decomp */
67 	Cpa8U windowSizeMask;
68 
69 	/* List representing compression levels that are the first to have
70 	   a unique search depth. */
71 	CpaBoolean uniqueCompressionLevels[DC_NUM_COMPRESSION_LEVELS + 1];
72 	Cpa8U numCompressionLevels;
73 
74 	/* Flag to indicate CompressAndVerifyAndRecover feature support */
75 	CpaBoolean cnvnrSupported;
76 } sal_compression_device_data_t;
77 
78 /**
79  *****************************************************************************
80  * @ingroup SalCtrl
81  *      Compression specific Service Container
82  *
83  * @description
84  *      Contains information required per compression service instance.
85  *
86  *****************************************************************************/
87 typedef struct sal_compression_service_s {
88 	/* An instance of the Generic Service Container */
89 	sal_service_t generic_service_info;
90 
91 	/* Memory pool ID used for compression */
92 	lac_memory_pool_id_t compression_mem_pool;
93 
94 	/* Pointer to an array of atomic stats for compression */
95 	QatUtilsAtomic *pCompStatsArr;
96 
97 	/* Size of the DRAM intermediate buffer in bytes */
98 	Cpa64U minInterBuffSizeInBytes;
99 
100 	/* Number of DRAM intermediate buffers */
101 	Cpa16U numInterBuffs;
102 
103 	/* Address of the array of DRAM intermediate buffers*/
104 	icp_qat_addr_width_t *pInterBuffPtrsArray;
105 	CpaPhysicalAddr pInterBuffPtrsArrayPhyAddr;
106 
107 	icp_comms_trans_handle trans_handle_compression_tx;
108 	icp_comms_trans_handle trans_handle_compression_rx;
109 
110 	/* Maximum number of in flight requests */
111 	Cpa32U maxNumCompConcurrentReq;
112 
113 	/* Callback function defined for the DcDp API compression session */
114 	CpaDcDpCallbackFn pDcDpCb;
115 
116 	/* Config info */
117 	Cpa16U acceleratorNum;
118 	Cpa16U bankNum;
119 	Cpa16U pkgID;
120 	Cpa16U isPolled;
121 	Cpa32U coreAffinity;
122 	Cpa32U nodeAffinity;
123 
124 	sal_compression_device_data_t comp_device_data;
125 
126 	/* Statistics handler */
127 	debug_file_info_t *debug_file;
128 } sal_compression_service_t;
129 
130 /*************************************************************************
131  * @ingroup SalCtrl
132  * @description
133  *  This function returns a valid compression instance handle for the system
134  *  if it exists.
135  *
136  *  @performance
137  *    To avoid calling this function the user of the QA api should not use
138  *    instanceHandle = CPA_INSTANCE_HANDLE_SINGLE.
139  *
140  * @context
141  *    This function is called whenever instanceHandle =
142  *    CPA_INSTANCE_HANDLE_SINGLE at the QA Dc api.
143  *
144  * @assumptions
145  *      None
146  * @sideEffects
147  *      None
148  * @reentrant
149  *      No
150  * @threadSafe
151  *      Yes
152  *
153  * @retval   Pointer to first compression instance handle or NULL if no
154  *           compression instances in the system.
155  *
156  *************************************************************************/
157 CpaInstanceHandle dcGetFirstHandle(void);
158 
159 #endif /*SAL_TYPES_COMPRESSION_H_*/
160