1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 /** 4 ***************************************************************************** 5 * @file dc_stats.c 6 * 7 * @ingroup Dc_DataCompression 8 * 9 * @description 10 * Implementation of the Data Compression stats operations. 11 * 12 *****************************************************************************/ 13 14 /* 15 ******************************************************************************* 16 * Include public/global header files 17 ******************************************************************************* 18 */ 19 #include "cpa.h" 20 #include "cpa_dc.h" 21 #include "icp_accel_devices.h" 22 #include "icp_adf_debug.h" 23 /* 24 ******************************************************************************* 25 * Include private header files 26 ******************************************************************************* 27 */ 28 #include "lac_common.h" 29 #include "icp_accel_devices.h" 30 #include "sal_statistics.h" 31 #include "dc_session.h" 32 #include "dc_datapath.h" 33 #include "lac_mem_pools.h" 34 #include "sal_service_state.h" 35 #include "sal_types_compression.h" 36 #include "dc_stats.h" 37 38 CpaStatus 39 dcStatsInit(sal_compression_service_t *pService) 40 { 41 CpaStatus status = CPA_STATUS_SUCCESS; 42 43 pService->pCompStatsArr = 44 LAC_OS_MALLOC(COMPRESSION_NUM_STATS * sizeof(QatUtilsAtomic)); 45 46 if (pService->pCompStatsArr == NULL) { 47 status = CPA_STATUS_RESOURCE; 48 } 49 50 if (CPA_STATUS_SUCCESS == status) { 51 COMPRESSION_STATS_RESET(pService); 52 } 53 54 return status; 55 } 56 57 void 58 dcStatsFree(sal_compression_service_t *pService) 59 { 60 if (NULL != pService->pCompStatsArr) { 61 LAC_OS_FREE(pService->pCompStatsArr); 62 } 63 } 64 65 CpaStatus 66 cpaDcGetStats(CpaInstanceHandle dcInstance, CpaDcStats *pStatistics) 67 { 68 sal_compression_service_t *pService = NULL; 69 CpaInstanceHandle insHandle = NULL; 70 71 if (CPA_INSTANCE_HANDLE_SINGLE == dcInstance) { 72 insHandle = dcGetFirstHandle(); 73 } else { 74 insHandle = dcInstance; 75 } 76 77 pService = (sal_compression_service_t *)insHandle; 78 79 LAC_CHECK_NULL_PARAM(insHandle); 80 LAC_CHECK_NULL_PARAM(pStatistics); 81 SAL_RUNNING_CHECK(insHandle); 82 83 SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); 84 85 /* Retrieves the statistics for compression */ 86 COMPRESSION_STATS_GET(pStatistics, pService); 87 88 return CPA_STATUS_SUCCESS; 89 } 90