1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 /**
5 *****************************************************************************
6 * @file dc_stats.h
7 *
8 * @ingroup Dc_DataCompression
9 *
10 * @description
11 * Definition of the Data Compression stats parameters.
12 *
13 *****************************************************************************/
14 #ifndef DC_STATS_H_
15 #define DC_STATS_H_
16
17 /* Number of Compression statistics */
18 #define COMPRESSION_NUM_STATS (sizeof(CpaDcStats) / sizeof(Cpa64U))
19
20 #define COMPRESSION_STAT_INC(statistic, pService) \
21 do { \
22 if (CPA_TRUE == \
23 pService->generic_service_info.stats->bDcStatsEnabled) { \
24 qatUtilsAtomicInc( \
25 &pService->pCompStatsArr[offsetof(CpaDcStats, \
26 statistic) / \
27 sizeof(Cpa64U)]); \
28 } \
29 } while (0)
30
31 /* Macro to get all Compression stats (from internal array of atomics) */
32 #define COMPRESSION_STATS_GET(compStats, pService) \
33 do { \
34 int i; \
35 for (i = 0; i < COMPRESSION_NUM_STATS; i++) { \
36 ((Cpa64U *)compStats)[i] = \
37 qatUtilsAtomicGet(&pService->pCompStatsArr[i]); \
38 } \
39 } while (0)
40
41 /* Macro to reset all Compression stats */
42 #define COMPRESSION_STATS_RESET(pService) \
43 do { \
44 int i; \
45 for (i = 0; i < COMPRESSION_NUM_STATS; i++) { \
46 qatUtilsAtomicSet(0, &pService->pCompStatsArr[i]); \
47 } \
48 } while (0)
49
50 /**
51 *******************************************************************************
52 * @ingroup Dc_DataCompression
53 * Initialises the compression stats
54 *
55 * @description
56 * This function allocates and initialises the stats array to 0
57 *
58 * @param[in] pService Pointer to a compression service structure
59 *
60 * @retval CPA_STATUS_SUCCESS initialisation successful
61 * @retval CPA_STATUS_RESOURCE array allocation failed
62 *
63 *****************************************************************************/
64 CpaStatus dcStatsInit(sal_compression_service_t *pService);
65
66 /**
67 *******************************************************************************
68 * @ingroup Dc_DataCompression
69 * Frees the compression stats
70 *
71 * @description
72 * This function frees the stats array
73 *
74 * @param[in] pService Pointer to a compression service structure
75 *
76 * @retval None
77 *
78 *****************************************************************************/
79 void dcStatsFree(sal_compression_service_t *pService);
80
81 #endif /* DC_STATS_H_ */
Cache object: 1e1b3bb7c0014efed7af52aa4671a244
|