diff options
Diffstat (limited to 'sys/dev/qat/qat_api/common/ctrl')
-rw-r--r-- | sys/dev/qat/qat_api/common/ctrl/sal_compression.c | 8 | ||||
-rw-r--r-- | sys/dev/qat/qat_api/common/ctrl/sal_crypto.c | 231 | ||||
-rw-r--r-- | sys/dev/qat/qat_api/common/ctrl/sal_get_instances.c | 177 |
3 files changed, 167 insertions, 249 deletions
diff --git a/sys/dev/qat/qat_api/common/ctrl/sal_compression.c b/sys/dev/qat/qat_api/common/ctrl/sal_compression.c index c0f5a411d87e..e8ae47f0f0d3 100644 --- a/sys/dev/qat/qat_api/common/ctrl/sal_compression.c +++ b/sys/dev/qat/qat_api/common/ctrl/sal_compression.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** * @file sal_compression.c @@ -371,9 +371,6 @@ SalCtrl_CompressionInit(icp_accel_dev_t *device, sal_service_t *service) SAL_SERVICE_GOOD_FOR_INIT(pCompressionService); - pCompressionService->generic_service_info.state = - SAL_SERVICE_STATE_INITIALIZING; - if (CPA_FALSE == pCompressionService->generic_service_info.is_dyn) { section = icpGetProcessName(); } @@ -1438,7 +1435,8 @@ cpaDcInstanceGetInfo2(const CpaInstanceHandle instanceHandle, pInstanceInfo2->isOffloaded = CPA_TRUE; /* Get the instance name and part name from the config file */ dev = icp_adf_getAccelDevByAccelId(pCompressionService->pkgID); - if (NULL == dev) { + if (NULL == dev || + 0 == strnlen(dev->deviceName, ADF_DEVICE_TYPE_LENGTH + 1)) { QAT_UTILS_LOG("Can not find device for the instance.\n"); LAC_OS_BZERO(pInstanceInfo2, sizeof(CpaInstanceInfo2)); return CPA_STATUS_FAIL; diff --git a/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c b/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c index cba75eb41c17..3e134f43af6e 100644 --- a/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c +++ b/sys/dev/qat/qat_api/common/ctrl/sal_crypto.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** *************************************************************************** @@ -73,6 +73,15 @@ #define NUM_CRYPTO_ASYM_RX_RINGS 1 #define NUM_CRYPTO_NRBG_RX_RINGS 1 +CpaStatus Lac_GetCyInstancesByType( + const CpaAccelerationServiceType accelerationServiceType, + Cpa16U numInstances, + CpaInstanceHandle *pInstances); + +CpaStatus Lac_GetCyNumInstancesByType( + const CpaAccelerationServiceType accelerationServiceType, + Cpa16U *pNumInstances); + static CpaInstanceHandle Lac_CryptoGetFirstHandle(void) { @@ -88,7 +97,6 @@ Lac_CryptoGetFirstHandle(void) return instHandle; } - /* Function to release the sym handles. */ static CpaStatus SalCtrl_SymReleaseTransHandle(sal_service_t *service) @@ -116,7 +124,6 @@ SalCtrl_SymReleaseTransHandle(sal_service_t *service) return ret_status; } - /* * @ingroup sal_crypto * Frees resources (memory and transhandles) if allocated @@ -153,7 +160,6 @@ SalCtrl_SymFreeResources(sal_crypto_service_t *pCryptoService) return status; } - /** *********************************************************************** * @ingroup SalCtrl @@ -175,7 +181,6 @@ SalCtrl_SymFreeResources(sal_crypto_service_t *pCryptoService) } \ } while (0) - /* Function that creates the Sym Handles. */ static CpaStatus SalCtrl_SymCreateTransHandle(icp_accel_dev_t *device, @@ -325,7 +330,6 @@ SalCtrl_CryptoDebug(void *private_data, char *data, int size, int offset) return ++offset; } - static CpaStatus SalCtrl_SymInit(icp_accel_dev_t *device, sal_service_t *service) { @@ -342,7 +346,6 @@ SalCtrl_SymInit(icp_accel_dev_t *device, sal_service_t *service) section = icpGetProcessName(); } - /* Register callbacks for the symmetric services * (Hash, Cipher, Algorithm-Chaining) (returns void)*/ LacSymCb_CallbacksRegister(); @@ -581,7 +584,6 @@ SalCtr_InstInit(icp_accel_dev_t *device, sal_service_t *service) section = icpGetProcessName(); } - /* Get Config Info: Accel Num, bank Num, packageID, coreAffinity, nodeAffinity and response mode */ @@ -847,7 +849,6 @@ SalCtrl_CryptoShutdown(icp_accel_dev_t *device, sal_service_t *service) return CPA_STATUS_FAIL; } - /* Free memory and transhandles */ switch (svc_type) { case SAL_SERVICE_TYPE_CRYPTO_ASYM: @@ -886,7 +887,6 @@ cpaCyGetStatusText(const CpaInstanceHandle instanceHandle, { CpaStatus status = CPA_STATUS_SUCCESS; - LAC_CHECK_NULL_PARAM(pStatusText); switch (errStatus) { @@ -969,7 +969,6 @@ cpaCyStartInstance(CpaInstanceHandle instanceHandle_in) CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_GetFirstHandle(SAL_SERVICE_TYPE_CRYPTO); if (!instanceHandle) { @@ -1021,7 +1020,6 @@ cpaCyStopInstance(CpaInstanceHandle instanceHandle_in) CpaStatus status = CPA_STATUS_SUCCESS; sal_crypto_service_t *pService = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { @@ -1066,7 +1064,6 @@ cpaCyInstanceSetNotificationCb( CpaStatus status = CPA_STATUS_SUCCESS; sal_service_t *gen_handle = instanceHandle; - LAC_CHECK_NULL_PARAM(gen_handle); gen_handle->notification_cb = pInstanceNotificationCb; gen_handle->cb_tag = pCallbackTag; @@ -1080,84 +1077,8 @@ cpaCyInstanceSetNotificationCb( CpaStatus cpaCyGetNumInstances(Cpa16U *pNumInstances) { - CpaStatus status = CPA_STATUS_SUCCESS; - CpaInstanceHandle cyInstanceHandle; - CpaInstanceInfo2 info; - icp_accel_dev_t **pAdfInsts = NULL; - icp_accel_dev_t *dev_addr = NULL; - sal_t *base_addr = NULL; - sal_list_t *list_temp = NULL; - Cpa16U num_accel_dev = 0; - Cpa16U num_inst = 0; - Cpa16U i = 0; - - LAC_CHECK_NULL_PARAM(pNumInstances); - - /* Get the number of accel_dev in the system */ - status = icp_amgr_getNumInstances(&num_accel_dev); - LAC_CHECK_STATUS(status); - - /* Allocate memory to store addr of accel_devs */ - pAdfInsts = - malloc(num_accel_dev * sizeof(icp_accel_dev_t *), M_QAT, M_WAITOK); - num_accel_dev = 0; - /* Get ADF to return all accel_devs that support either - * symmetric or asymmetric crypto */ - status = icp_amgr_getAllAccelDevByCapabilities( - (ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | - ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC), - pAdfInsts, - &num_accel_dev); - if (CPA_STATUS_SUCCESS != status) { - LAC_LOG_ERROR("No support for crypto\n"); - *pNumInstances = 0; - free(pAdfInsts, M_QAT); - return status; - } - - for (i = 0; i < num_accel_dev; i++) { - dev_addr = (icp_accel_dev_t *)pAdfInsts[i]; - if (NULL == dev_addr || NULL == dev_addr->pSalHandle) { - continue; - } - - base_addr = dev_addr->pSalHandle; - list_temp = base_addr->crypto_services; - while (NULL != list_temp) { - cyInstanceHandle = SalList_getObject(list_temp); - status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); - if (CPA_STATUS_SUCCESS == status && - CPA_TRUE == info.isPolled) { - num_inst++; - } - list_temp = SalList_next(list_temp); - } - list_temp = base_addr->asym_services; - while (NULL != list_temp) { - cyInstanceHandle = SalList_getObject(list_temp); - status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); - if (CPA_STATUS_SUCCESS == status && - CPA_TRUE == info.isPolled) { - num_inst++; - } - list_temp = SalList_next(list_temp); - } - list_temp = base_addr->sym_services; - while (NULL != list_temp) { - cyInstanceHandle = SalList_getObject(list_temp); - status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); - if (CPA_STATUS_SUCCESS == status && - CPA_TRUE == info.isPolled) { - num_inst++; - } - list_temp = SalList_next(list_temp); - } - } - *pNumInstances = num_inst; - free(pAdfInsts, M_QAT); - - - return status; + return Lac_GetCyNumInstancesByType(CPA_ACC_SVC_TYPE_CRYPTO, + pNumInstances); } /** @@ -1167,119 +1088,9 @@ cpaCyGetNumInstances(Cpa16U *pNumInstances) CpaStatus cpaCyGetInstances(Cpa16U numInstances, CpaInstanceHandle *pCyInstances) { - CpaStatus status = CPA_STATUS_SUCCESS; - CpaInstanceHandle cyInstanceHandle; - CpaInstanceInfo2 info; - icp_accel_dev_t **pAdfInsts = NULL; - icp_accel_dev_t *dev_addr = NULL; - sal_t *base_addr = NULL; - sal_list_t *list_temp = NULL; - Cpa16U num_accel_dev = 0; - Cpa16U num_allocated_instances = 0; - Cpa16U index = 0; - Cpa16U i = 0; - - - LAC_CHECK_NULL_PARAM(pCyInstances); - if (0 == numInstances) { - LAC_INVALID_PARAM_LOG("NumInstances is 0"); - return CPA_STATUS_INVALID_PARAM; - } - - /* Get the number of crypto instances */ - status = cpaCyGetNumInstances(&num_allocated_instances); - if (CPA_STATUS_SUCCESS != status) { - return status; - } - - if (numInstances > num_allocated_instances) { - QAT_UTILS_LOG("Only %d crypto instances available\n", - num_allocated_instances); - return CPA_STATUS_RESOURCE; - } - - /* Get the number of accel devices in the system */ - status = icp_amgr_getNumInstances(&num_accel_dev); - LAC_CHECK_STATUS(status); - - /* Allocate memory to store addr of accel_devs */ - pAdfInsts = - malloc(num_accel_dev * sizeof(icp_accel_dev_t *), M_QAT, M_WAITOK); - - num_accel_dev = 0; - /* Get ADF to return all accel_devs that support either - * symmetric or asymmetric crypto */ - status = icp_amgr_getAllAccelDevByCapabilities( - (ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | - ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC), - pAdfInsts, - &num_accel_dev); - if (CPA_STATUS_SUCCESS != status) { - LAC_LOG_ERROR("No support for crypto\n"); - free(pAdfInsts, M_QAT); - return status; - } - - for (i = 0; i < num_accel_dev; i++) { - dev_addr = (icp_accel_dev_t *)pAdfInsts[i]; - /* Note dev_addr cannot be NULL here as numInstances = 0 - * is not valid and if dev_addr = NULL then index = 0 (which - * is less than numInstances and status is set to _RESOURCE - * above - */ - base_addr = dev_addr->pSalHandle; - if (NULL == base_addr) { - continue; - } - list_temp = base_addr->crypto_services; - while (NULL != list_temp) { - if (index > (numInstances - 1)) { - break; - } - cyInstanceHandle = SalList_getObject(list_temp); - status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); - list_temp = SalList_next(list_temp); - if (CPA_STATUS_SUCCESS != status || - CPA_TRUE != info.isPolled) { - continue; - } - pCyInstances[index] = cyInstanceHandle; - index++; - } - list_temp = base_addr->asym_services; - while (NULL != list_temp) { - if (index > (numInstances - 1)) { - break; - } - cyInstanceHandle = SalList_getObject(list_temp); - status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); - list_temp = SalList_next(list_temp); - if (CPA_STATUS_SUCCESS != status || - CPA_TRUE != info.isPolled) { - continue; - } - pCyInstances[index] = cyInstanceHandle; - index++; - } - list_temp = base_addr->sym_services; - while (NULL != list_temp) { - if (index > (numInstances - 1)) { - break; - } - cyInstanceHandle = SalList_getObject(list_temp); - status = cpaCyInstanceGetInfo2(cyInstanceHandle, &info); - list_temp = SalList_next(list_temp); - if (CPA_STATUS_SUCCESS != status || - CPA_TRUE != info.isPolled) { - continue; - } - pCyInstances[index] = cyInstanceHandle; - index++; - } - } - free(pAdfInsts, M_QAT); - - return status; + return Lac_GetCyInstancesByType(CPA_ACC_SVC_TYPE_CRYPTO, + numInstances, + pCyInstances); } /** @@ -1359,7 +1170,6 @@ cpaCyInstanceGetInfo2(const CpaInstanceHandle instanceHandle_in, char valStr[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { 0 }; char *section = DYN_SEC; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { @@ -1423,9 +1233,10 @@ cpaCyInstanceGetInfo2(const CpaInstanceHandle instanceHandle_in, } pInstanceInfo2->isOffloaded = CPA_TRUE; - /* Get the instance name and part name*/ + /* Get the instance name and part name */ dev = icp_adf_getAccelDevByAccelId(pCryptoService->pkgID); - if (NULL == dev) { + if (NULL == dev || + 0 == strnlen(dev->deviceName, ADF_DEVICE_TYPE_LENGTH + 1)) { LAC_LOG_ERROR("Can not find device for the instance\n"); LAC_OS_BZERO(pInstanceInfo2, sizeof(CpaInstanceInfo2)); return CPA_STATUS_FAIL; @@ -1474,7 +1285,6 @@ cpaCyQueryCapabilities(const CpaInstanceHandle instanceHandle_in, /* Verify Instance exists */ CpaInstanceHandle instanceHandle = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { @@ -1634,7 +1444,6 @@ cpaCySetAddressTranslation(const CpaInstanceHandle instanceHandle_in, CpaInstanceHandle instanceHandle = NULL; sal_service_t *pService = NULL; - if (CPA_INSTANCE_HANDLE_SINGLE == instanceHandle_in) { instanceHandle = Lac_CryptoGetFirstHandle(); } else { @@ -1756,7 +1565,6 @@ icp_sal_CyPollSymRing(CpaInstanceHandle instanceHandle_in, return status; } - /** ****************************************************************************** * @ingroup cpaCyCommon @@ -1910,7 +1718,6 @@ Lac_GetFirstHandle(sal_service_type_t svc_type) default: LAC_LOG_ERROR("Invalid service type\n"); return NULL; - break; } /* Only need 1 dev with crypto enabled - so check all devices*/ status = icp_amgr_getAllAccelDevByEachCapability(capabilities, @@ -1978,7 +1785,6 @@ icp_sal_SymGetInflightRequests(CpaInstanceHandle instanceHandle, numInflightRequests); } - CpaStatus icp_sal_dp_SymGetInflightRequests(CpaInstanceHandle instanceHandle, Cpa32U *maxInflightRequests, @@ -1994,7 +1800,6 @@ icp_sal_dp_SymGetInflightRequests(CpaInstanceHandle instanceHandle, numInflightRequests); } - CpaStatus icp_sal_setForceAEADMACVerify(CpaInstanceHandle instanceHandle, CpaBoolean forceAEADMacVerify) diff --git a/sys/dev/qat/qat_api/common/ctrl/sal_get_instances.c b/sys/dev/qat/qat_api/common/ctrl/sal_get_instances.c index 27037e99d1ac..f68853dc43a8 100644 --- a/sys/dev/qat/qat_api/common/ctrl/sal_get_instances.c +++ b/sys/dev/qat/qat_api/common/ctrl/sal_get_instances.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ /** ***************************************************************************** @@ -10,7 +10,9 @@ * @ingroup SalCtrl * * @description - * This file contains the main function to get SAL instances. + * This file contains generic functions to get instances of a specified + * service type. Note these are complementary to the already existing + * service-specific functions. * *****************************************************************************/ @@ -34,19 +36,22 @@ #include "lac_mem.h" #include "lac_list.h" #include "lac_sal_types.h" +#include "lac_sal_types_crypto.h" /** ****************************************************************************** * @ingroup SalCtrl * @description - * Get either sym or asym instance number + * Get the total number of either sym, asym or cy instances *****************************************************************************/ -static CpaStatus -Lac_GetSingleCyNumInstances( +CpaStatus +Lac_GetCyNumInstancesByType( const CpaAccelerationServiceType accelerationServiceType, Cpa16U *pNumInstances) { CpaStatus status = CPA_STATUS_SUCCESS; + CpaInstanceHandle instanceHandle; + CpaInstanceInfo2 info; icp_accel_dev_t **pAdfInsts = NULL; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; @@ -71,6 +76,12 @@ Lac_GetSingleCyNumInstances( service = "sym"; break; + case CPA_ACC_SVC_TYPE_CRYPTO: + accel_capability = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC | + ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC; + service = "cy"; + break; + default: QAT_UTILS_LOG("Invalid service type\n"); return CPA_STATUS_INVALID_PARAM; @@ -106,14 +117,48 @@ Lac_GetSingleCyNumInstances( } base_addr = dev_addr->pSalHandle; - if (CPA_ACC_SVC_TYPE_CRYPTO_ASYM == accelerationServiceType) { + if (CPA_ACC_SVC_TYPE_CRYPTO == accelerationServiceType) { + list_temp = base_addr->crypto_services; + while (NULL != list_temp) { + instanceHandle = SalList_getObject(list_temp); + status = cpaCyInstanceGetInfo2(instanceHandle, + &info); + if (CPA_STATUS_SUCCESS == status && + CPA_TRUE == info.isPolled) { + num_inst++; + } + list_temp = SalList_next(list_temp); + } + } + + if (CPA_ACC_SVC_TYPE_CRYPTO_ASYM == accelerationServiceType || + CPA_ACC_SVC_TYPE_CRYPTO == accelerationServiceType) { list_temp = base_addr->asym_services; - } else { - list_temp = base_addr->sym_services; + while (NULL != list_temp) { + instanceHandle = SalList_getObject(list_temp); + status = cpaCyInstanceGetInfo2(instanceHandle, + &info); + if (CPA_STATUS_SUCCESS == status && + CPA_TRUE == info.isPolled) { + num_inst++; + } + list_temp = SalList_next(list_temp); + } } - while (NULL != list_temp) { - num_inst++; - list_temp = SalList_next(list_temp); + + if (CPA_ACC_SVC_TYPE_CRYPTO_SYM == accelerationServiceType || + CPA_ACC_SVC_TYPE_CRYPTO == accelerationServiceType) { + list_temp = base_addr->sym_services; + while (NULL != list_temp) { + instanceHandle = SalList_getObject(list_temp); + status = cpaCyInstanceGetInfo2(instanceHandle, + &info); + if (CPA_STATUS_SUCCESS == status && + CPA_TRUE == info.isPolled) { + num_inst++; + } + list_temp = SalList_next(list_temp); + } } } @@ -127,15 +172,17 @@ Lac_GetSingleCyNumInstances( ****************************************************************************** * @ingroup SalCtrl * @description - * Get either sym or asym instance + * Get either sym, asym or cy instance *****************************************************************************/ -static CpaStatus -Lac_GetSingleCyInstances( +CpaStatus +Lac_GetCyInstancesByType( const CpaAccelerationServiceType accelerationServiceType, Cpa16U numInstances, CpaInstanceHandle *pInstances) { CpaStatus status = CPA_STATUS_SUCCESS; + CpaInstanceHandle instanceHandle = NULL; + CpaInstanceInfo2 info; icp_accel_dev_t **pAdfInsts = NULL; icp_accel_dev_t *dev_addr = NULL; sal_t *base_addr = NULL; @@ -163,14 +210,21 @@ Lac_GetSingleCyInstances( accel_capability = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC; service = "sym"; break; + + case CPA_ACC_SVC_TYPE_CRYPTO: + accel_capability = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC | + ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC; + service = "cy"; + break; + default: QAT_UTILS_LOG("Invalid service type\n"); return CPA_STATUS_INVALID_PARAM; } /* Get the number of instances */ - status = cpaGetNumInstances(accelerationServiceType, - &num_allocated_instances); + status = Lac_GetCyNumInstancesByType(accelerationServiceType, + &num_allocated_instances); if (CPA_STATUS_SUCCESS != status) { return status; } @@ -216,17 +270,63 @@ Lac_GetSingleCyInstances( continue; } - if (CPA_ACC_SVC_TYPE_CRYPTO_ASYM == accelerationServiceType) + if (CPA_ACC_SVC_TYPE_CRYPTO == accelerationServiceType) { + list_temp = base_addr->crypto_services; + while (NULL != list_temp) { + if (index > (numInstances - 1)) + break; + + instanceHandle = SalList_getObject(list_temp); + status = cpaCyInstanceGetInfo2(instanceHandle, + &info); + list_temp = SalList_next(list_temp); + if (CPA_STATUS_SUCCESS != status || + CPA_TRUE != info.isPolled) { + continue; + } + pInstances[index] = instanceHandle; + index++; + } + } + + if (CPA_ACC_SVC_TYPE_CRYPTO_ASYM == accelerationServiceType || + CPA_ACC_SVC_TYPE_CRYPTO == accelerationServiceType) { list_temp = base_addr->asym_services; - else - list_temp = base_addr->sym_services; - while (NULL != list_temp) { - if (index > (numInstances - 1)) - break; + while (NULL != list_temp) { + if (index > (numInstances - 1)) + break; + + instanceHandle = SalList_getObject(list_temp); + status = cpaCyInstanceGetInfo2(instanceHandle, + &info); + list_temp = SalList_next(list_temp); + if (CPA_STATUS_SUCCESS != status || + CPA_TRUE != info.isPolled) { + continue; + } + pInstances[index] = instanceHandle; + index++; + } + } - pInstances[index] = SalList_getObject(list_temp); - list_temp = SalList_next(list_temp); - index++; + if (CPA_ACC_SVC_TYPE_CRYPTO_SYM == accelerationServiceType || + CPA_ACC_SVC_TYPE_CRYPTO == accelerationServiceType) { + list_temp = base_addr->sym_services; + while (NULL != list_temp) { + if (index > (numInstances - 1)) + break; + + instanceHandle = SalList_getObject(list_temp); + status = cpaCyInstanceGetInfo2(instanceHandle, + &info); + list_temp = SalList_next(list_temp); + if (CPA_STATUS_SUCCESS != status || + CPA_TRUE != info.isPolled) { + continue; + } + pInstances[index] = instanceHandle; + index++; + } } } free(pAdfInsts, M_QAT); @@ -242,16 +342,24 @@ CpaStatus cpaGetNumInstances(const CpaAccelerationServiceType accelerationServiceType, Cpa16U *pNumInstances) { + LAC_CHECK_NULL_PARAM(pNumInstances); + switch (accelerationServiceType) { case CPA_ACC_SVC_TYPE_CRYPTO_ASYM: case CPA_ACC_SVC_TYPE_CRYPTO_SYM: - return Lac_GetSingleCyNumInstances(accelerationServiceType, - pNumInstances); case CPA_ACC_SVC_TYPE_CRYPTO: - return cpaCyGetNumInstances(pNumInstances); + return Lac_GetCyNumInstancesByType(accelerationServiceType, + pNumInstances); + case CPA_ACC_SVC_TYPE_DATA_COMPRESSION: return cpaDcGetNumInstances(pNumInstances); + case CPA_ACC_SVC_TYPE_PATTERN_MATCH: + case CPA_ACC_SVC_TYPE_RAID: + case CPA_ACC_SVC_TYPE_XML: + QAT_UTILS_LOG("Unsupported service type\n"); + return CPA_STATUS_UNSUPPORTED; + default: QAT_UTILS_LOG("Invalid service type\n"); *pNumInstances = 0; @@ -268,18 +376,25 @@ cpaGetInstances(const CpaAccelerationServiceType accelerationServiceType, Cpa16U numInstances, CpaInstanceHandle *pInstances) { + LAC_CHECK_NULL_PARAM(pInstances); + switch (accelerationServiceType) { case CPA_ACC_SVC_TYPE_CRYPTO_ASYM: case CPA_ACC_SVC_TYPE_CRYPTO_SYM: - return Lac_GetSingleCyInstances(accelerationServiceType, + case CPA_ACC_SVC_TYPE_CRYPTO: + return Lac_GetCyInstancesByType(accelerationServiceType, numInstances, pInstances); - case CPA_ACC_SVC_TYPE_CRYPTO: - return cpaCyGetInstances(numInstances, pInstances); case CPA_ACC_SVC_TYPE_DATA_COMPRESSION: return cpaDcGetInstances(numInstances, pInstances); + case CPA_ACC_SVC_TYPE_PATTERN_MATCH: + case CPA_ACC_SVC_TYPE_RAID: + case CPA_ACC_SVC_TYPE_XML: + QAT_UTILS_LOG("Unsupported service type\n"); + return CPA_STATUS_UNSUPPORTED; + default: QAT_UTILS_LOG("Invalid service type\n"); return CPA_STATUS_INVALID_PARAM; |