Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/qat/qat_api/common/compression/dc_datapath.c
Show All 36 Lines | |||||
#include "sal_types_compression.h" | #include "sal_types_compression.h" | ||||
#include "dc_stats.h" | #include "dc_stats.h" | ||||
#include "lac_buffer_desc.h" | #include "lac_buffer_desc.h" | ||||
#include "lac_sal.h" | #include "lac_sal.h" | ||||
#include "lac_log.h" | #include "lac_log.h" | ||||
#include "lac_sync.h" | #include "lac_sync.h" | ||||
#include "sal_service_state.h" | #include "sal_service_state.h" | ||||
#include "sal_qat_cmn_msg.h" | #include "sal_qat_cmn_msg.h" | ||||
#include "sal_hw_gen.h" | |||||
#include "dc_error_counter.h" | #include "dc_error_counter.h" | ||||
#define DC_COMP_MAX_BUFF_SIZE (1024 * 64) | #define DC_COMP_MAX_BUFF_SIZE (1024 * 64) | ||||
static QatUtilsAtomic dcErrorCount[MAX_DC_ERROR_TYPE]; | static QatUtilsAtomic dcErrorCount[MAX_DC_ERROR_TYPE]; | ||||
void | void | ||||
dcErrorLog(CpaDcReqStatus dcError) | dcErrorLog(CpaDcReqStatus dcError) | ||||
{ | { | ||||
Show All 13 Lines | getDcErrorCounter(CpaDcReqStatus dcError) | ||||
absError = abs(dcError); | absError = abs(dcError); | ||||
if (!(dcError >= CPA_DC_OK || dcError < CPA_DC_EMPTY_DYM_BLK)) { | if (!(dcError >= CPA_DC_OK || dcError < CPA_DC_EMPTY_DYM_BLK)) { | ||||
return (Cpa64U)qatUtilsAtomicGet(&dcErrorCount[absError]); | return (Cpa64U)qatUtilsAtomicGet(&dcErrorCount[absError]); | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
static inline void | |||||
dcUpdateXltOverflowChecksumsGen4(const dc_compression_cookie_t *pCookie, | |||||
const icp_qat_fw_resp_comp_pars_t *pRespPars, | |||||
CpaDcRqResults *pDcResults) | |||||
{ | |||||
dc_session_desc_t *pSessionDesc = | |||||
DC_SESSION_DESC_FROM_CTX_GET(pCookie->pSessionHandle); | |||||
/* Recompute CRC checksum when either the checksum type | |||||
* is CPA_DC_CRC32 or when the integrity CRCs are enabled. | |||||
*/ | |||||
if (CPA_DC_CRC32 == pSessionDesc->checksumType) { | |||||
pDcResults->checksum = pRespPars->crc.legacy.curr_crc32; | |||||
/* No need to recalculate the swCrc64I here as this will get | |||||
* handled later in dcHandleIntegrityChecksumsGen4. | |||||
*/ | |||||
} else if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { | |||||
pDcResults->checksum = pRespPars->crc.legacy.curr_adler_32; | |||||
} | |||||
} | |||||
void | void | ||||
dcCompression_ProcessCallback(void *pRespMsg) | dcCompression_ProcessCallback(void *pRespMsg) | ||||
{ | { | ||||
CpaStatus status = CPA_STATUS_SUCCESS; | CpaStatus status = CPA_STATUS_SUCCESS; | ||||
icp_qat_fw_comp_resp_t *pCompRespMsg = NULL; | icp_qat_fw_comp_resp_t *pCompRespMsg = NULL; | ||||
void *callbackTag = NULL; | void *callbackTag = NULL; | ||||
Cpa64U *pReqData = NULL; | Cpa64U *pReqData = NULL; | ||||
CpaDcDpOpData *pResponse = NULL; | CpaDcDpOpData *pResponse = NULL; | ||||
CpaDcRqResults *pResults = NULL; | CpaDcRqResults *pResults = NULL; | ||||
CpaDcCallbackFn pCbFunc = NULL; | CpaDcCallbackFn pCbFunc = NULL; | ||||
dc_session_desc_t *pSessionDesc = NULL; | dc_session_desc_t *pSessionDesc = NULL; | ||||
sal_compression_service_t *pService = NULL; | sal_compression_service_t *pService = NULL; | ||||
dc_compression_cookie_t *pCookie = NULL; | dc_compression_cookie_t *pCookie = NULL; | ||||
CpaDcOpData *pOpData = NULL; | CpaDcOpData *pOpData = NULL; | ||||
CpaBoolean cmpPass = CPA_TRUE, xlatPass = CPA_TRUE; | CpaBoolean cmpPass = CPA_TRUE, xlatPass = CPA_TRUE; | ||||
CpaBoolean isDcDp = CPA_FALSE; | |||||
CpaBoolean integrityCrcCheck = CPA_FALSE; | |||||
CpaBoolean verifyHwIntegrityCrcs = CPA_FALSE; | CpaBoolean verifyHwIntegrityCrcs = CPA_FALSE; | ||||
Cpa8U cmpErr = ERR_CODE_NO_ERROR, xlatErr = ERR_CODE_NO_ERROR; | Cpa8U cmpErr = ERR_CODE_NO_ERROR, xlatErr = ERR_CODE_NO_ERROR; | ||||
dc_request_dir_t compDecomp = DC_COMPRESSION_REQUEST; | dc_request_dir_t compDecomp = DC_COMPRESSION_REQUEST; | ||||
Cpa8U opStatus = ICP_QAT_FW_COMN_STATUS_FLAG_OK; | Cpa8U opStatus = ICP_QAT_FW_COMN_STATUS_FLAG_OK; | ||||
Cpa8U hdrFlags = 0; | Cpa8U hdrFlags = 0; | ||||
/* Cast response message to compression response message type */ | /* Cast response message to compression response message type */ | ||||
pCompRespMsg = (icp_qat_fw_comp_resp_t *)pRespMsg; | pCompRespMsg = (icp_qat_fw_comp_resp_t *)pRespMsg; | ||||
/* Extract request data pointer from the opaque data */ | /* Extract request data pointer from the opaque data */ | ||||
LAC_MEM_SHARED_READ_TO_PTR(pCompRespMsg->opaque_data, pReqData); | LAC_MEM_SHARED_READ_TO_PTR(pCompRespMsg->opaque_data, pReqData); | ||||
/* Extract fields from the request data structure */ | /* Extract fields from the request data structure */ | ||||
pCookie = (dc_compression_cookie_t *)pReqData; | pCookie = (dc_compression_cookie_t *)pReqData; | ||||
if (!pCookie) | if (!pCookie) | ||||
return; | return; | ||||
pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pCookie->pSessionHandle); | pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pCookie->pSessionHandle); | ||||
pService = (sal_compression_service_t *)(pCookie->dcInstance); | |||||
if (CPA_TRUE == pSessionDesc->isDcDp) { | isDcDp = pSessionDesc->isDcDp; | ||||
if (CPA_TRUE == isDcDp) { | |||||
pResponse = (CpaDcDpOpData *)pReqData; | pResponse = (CpaDcDpOpData *)pReqData; | ||||
pResults = &(pResponse->results); | pResults = &(pResponse->results); | ||||
if (CPA_DC_DIR_DECOMPRESS == pSessionDesc->sessDirection) { | if (CPA_DC_DIR_DECOMPRESS == pSessionDesc->sessDirection) { | ||||
compDecomp = DC_DECOMPRESSION_REQUEST; | compDecomp = DC_DECOMPRESSION_REQUEST; | ||||
} | } | ||||
pCookie = NULL; | |||||
} else { | } else { | ||||
pSessionDesc = pCookie->pSessionDesc; | |||||
pResults = pCookie->pResults; | pResults = pCookie->pResults; | ||||
callbackTag = pCookie->callbackTag; | callbackTag = pCookie->callbackTag; | ||||
pCbFunc = pCookie->pSessionDesc->pCompressionCb; | pCbFunc = pCookie->pSessionDesc->pCompressionCb; | ||||
compDecomp = pCookie->compDecomp; | compDecomp = pCookie->compDecomp; | ||||
pOpData = pCookie->pDcOpData; | pOpData = pCookie->pDcOpData; | ||||
} | } | ||||
pService = (sal_compression_service_t *)(pCookie->dcInstance); | |||||
opStatus = pCompRespMsg->comn_resp.comn_status; | opStatus = pCompRespMsg->comn_resp.comn_status; | ||||
if (NULL != pOpData) { | if (NULL != pOpData) { | ||||
verifyHwIntegrityCrcs = pOpData->verifyHwIntegrityCrcs; | verifyHwIntegrityCrcs = pOpData->verifyHwIntegrityCrcs; | ||||
} | } | ||||
hdrFlags = pCompRespMsg->comn_resp.hdr_flags; | hdrFlags = pCompRespMsg->comn_resp.hdr_flags; | ||||
/* Get the cmp error code */ | /* Get the cmp error code */ | ||||
cmpErr = pCompRespMsg->comn_resp.comn_error.s1.cmp_err_code; | cmpErr = pCompRespMsg->comn_resp.comn_error.s1.cmp_err_code; | ||||
if (ICP_QAT_FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET(opStatus)) { | if (ICP_QAT_FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET(opStatus)) { | ||||
/* Compression not supported by firmware, set produced/consumed | /* Compression not supported by firmware, set produced/consumed | ||||
to zero | to zero | ||||
and call the cb function with status CPA_STATUS_UNSUPPORTED | and call the cb function with status CPA_STATUS_UNSUPPORTED | ||||
*/ | */ | ||||
QAT_UTILS_LOG("Compression feature not supported\n"); | QAT_UTILS_LOG("Compression feature not supported\n"); | ||||
status = CPA_STATUS_UNSUPPORTED; | status = CPA_STATUS_UNSUPPORTED; | ||||
pResults->status = (Cpa8S)cmpErr; | pResults->status = (Cpa8S)cmpErr; | ||||
pResults->consumed = 0; | pResults->consumed = 0; | ||||
pResults->produced = 0; | pResults->produced = 0; | ||||
if (CPA_TRUE == pSessionDesc->isDcDp) { | if (CPA_TRUE == isDcDp) { | ||||
if (pResponse) | if (pResponse) | ||||
pResponse->responseStatus = | pResponse->responseStatus = | ||||
CPA_STATUS_UNSUPPORTED; | CPA_STATUS_UNSUPPORTED; | ||||
(pService->pDcDpCb)(pResponse); | (pService->pDcDpCb)(pResponse); | ||||
} else { | } else { | ||||
/* Free the memory pool */ | /* Free the memory pool */ | ||||
if (NULL != pCookie) { | |||||
Lac_MemPoolEntryFree(pCookie); | Lac_MemPoolEntryFree(pCookie); | ||||
pCookie = NULL; | pCookie = NULL; | ||||
} | |||||
if (NULL != pCbFunc) { | if (NULL != pCbFunc) { | ||||
pCbFunc(callbackTag, status); | pCbFunc(callbackTag, status); | ||||
} | } | ||||
} | } | ||||
if (DC_COMPRESSION_REQUEST == compDecomp) { | if (DC_COMPRESSION_REQUEST == compDecomp) { | ||||
COMPRESSION_STAT_INC(numCompCompletedErrors, pService); | COMPRESSION_STAT_INC(numCompCompletedErrors, pService); | ||||
} else { | } else { | ||||
COMPRESSION_STAT_INC(numDecompCompletedErrors, | COMPRESSION_STAT_INC(numDecompCompletedErrors, | ||||
pService); | pService); | ||||
} | } | ||||
return; | return; | ||||
} else { | } else { | ||||
/* Check compression response status */ | /* Check compression response status */ | ||||
cmpPass = | cmpPass = | ||||
(CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == | (CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == | ||||
ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(opStatus)); | ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(opStatus)); | ||||
} | } | ||||
if (isDcGen2x(pService)) { | |||||
/* QAT1.7 and QAT 1.8 hardware */ | |||||
if (CPA_DC_INCOMPLETE_FILE_ERR == (Cpa8S)cmpErr) { | if (CPA_DC_INCOMPLETE_FILE_ERR == (Cpa8S)cmpErr) { | ||||
cmpPass = CPA_TRUE; | cmpPass = CPA_TRUE; | ||||
cmpErr = ERR_CODE_NO_ERROR; | cmpErr = ERR_CODE_NO_ERROR; | ||||
} | } | ||||
} else { | |||||
/* QAT2.0 hardware cancels the incomplete file errors | |||||
* only for DEFLATE algorithm. | |||||
* Decompression direction is not tested in the callback as | |||||
* the request does not allow it. | |||||
*/ | |||||
if ((pSessionDesc->compType == CPA_DC_DEFLATE) && | |||||
(CPA_DC_INCOMPLETE_FILE_ERR == (Cpa8S)cmpErr)) { | |||||
cmpPass = CPA_TRUE; | |||||
cmpErr = ERR_CODE_NO_ERROR; | |||||
} | |||||
} | |||||
/* log the slice hang and endpoint push/pull error inside the response | /* log the slice hang and endpoint push/pull error inside the response | ||||
*/ | */ | ||||
if (ERR_CODE_SSM_ERROR == (Cpa8S)cmpErr) { | if (ERR_CODE_SSM_ERROR == (Cpa8S)cmpErr) { | ||||
QAT_UTILS_LOG( | QAT_UTILS_LOG( | ||||
"Slice hang detected on the compression slice.\n"); | "Slice hang detected on the compression slice.\n"); | ||||
} else if (ERR_CODE_ENDPOINT_ERROR == (Cpa8S)cmpErr) { | } else if (ERR_CODE_ENDPOINT_ERROR == (Cpa8S)cmpErr) { | ||||
QAT_UTILS_LOG( | QAT_UTILS_LOG( | ||||
"PCIe End Point Push/Pull or TI/RI Parity error detected.\n"); | "PCIe End Point Push/Pull or TI/RI Parity error detected.\n"); | ||||
Show All 10 Lines | if ((DC_COMPRESSION_REQUEST == compDecomp) && | ||||
xlatPass = | xlatPass = | ||||
(CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == | (CpaBoolean)(ICP_QAT_FW_COMN_STATUS_FLAG_OK == | ||||
ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(opStatus)); | ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(opStatus)); | ||||
/* Get the translator error code */ | /* Get the translator error code */ | ||||
xlatErr = pCompRespMsg->comn_resp.comn_error.s1.xlat_err_code; | xlatErr = pCompRespMsg->comn_resp.comn_error.s1.xlat_err_code; | ||||
/* Return a fatal error or a potential error in the translator | /* Return a fatal error or a potential error in the translator | ||||
* slice | * slice if the compression slice did not return any error */ | ||||
* if the compression slice did not return any error */ | |||||
if ((CPA_DC_OK == pResults->status) || | if ((CPA_DC_OK == pResults->status) || | ||||
(CPA_DC_FATALERR == (Cpa8S)xlatErr)) { | (CPA_DC_FATALERR == (Cpa8S)xlatErr)) { | ||||
pResults->status = (Cpa8S)xlatErr; | pResults->status = (Cpa8S)xlatErr; | ||||
} | } | ||||
} | } | ||||
/* Update dc error counter */ | /* Update dc error counter */ | ||||
dcErrorLog(pResults->status); | dcErrorLog(pResults->status); | ||||
if (CPA_FALSE == pSessionDesc->isDcDp) { | if (CPA_FALSE == isDcDp) { | ||||
/* In case of any error for an end of packet request, we need to | /* In case of any error for an end of packet request, we need to | ||||
* update | * update | ||||
* the request type for the following request */ | * the request type for the following request */ | ||||
if (CPA_DC_FLUSH_FINAL == pCookie->flushFlag && cmpPass && | if (CPA_DC_FLUSH_FINAL == pCookie->flushFlag && cmpPass && | ||||
xlatPass) { | xlatPass) { | ||||
pSessionDesc->requestType = DC_REQUEST_FIRST; | pSessionDesc->requestType = DC_REQUEST_FIRST; | ||||
} else { | } else { | ||||
pSessionDesc->requestType = DC_REQUEST_SUBSEQUENT; | pSessionDesc->requestType = DC_REQUEST_SUBSEQUENT; | ||||
} | } | ||||
if ((CPA_DC_STATEFUL == pSessionDesc->sessState) || | if ((CPA_DC_STATEFUL == pSessionDesc->sessState) || | ||||
((CPA_DC_STATELESS == pSessionDesc->sessState) && | ((CPA_DC_STATELESS == pSessionDesc->sessState) && | ||||
(DC_COMPRESSION_REQUEST == compDecomp))) { | (DC_COMPRESSION_REQUEST == compDecomp))) { | ||||
/* Overflow is a valid use case for Traditional API | /* Overflow is a valid use case for Traditional API | ||||
* only. | * only. Stateful Overflow is supported in both | ||||
* Stateful Overflow is supported in both compression | * compression and decompression direction. Stateless | ||||
* and | * Overflow is supported only in compression direction. | ||||
* decompression direction. | |||||
* Stateless Overflow is supported only in compression | |||||
* direction. | |||||
*/ | */ | ||||
if (CPA_DC_OVERFLOW == (Cpa8S)cmpErr) | if (CPA_DC_OVERFLOW == (Cpa8S)cmpErr) | ||||
cmpPass = CPA_TRUE; | cmpPass = CPA_TRUE; | ||||
if (CPA_DC_OVERFLOW == (Cpa8S)xlatErr) { | if (CPA_DC_OVERFLOW == (Cpa8S)xlatErr) { | ||||
if (isDcGen4x(pService) && | |||||
(CPA_TRUE == | |||||
pService->comp_device_data | |||||
.translatorOverflow)) { | |||||
pResults->consumed = | |||||
pCompRespMsg->comp_resp_pars | |||||
.input_byte_counter; | |||||
dcUpdateXltOverflowChecksumsGen4( | |||||
pCookie, | |||||
&pCompRespMsg->comp_resp_pars, | |||||
pResults); | |||||
} | |||||
xlatPass = CPA_TRUE; | xlatPass = CPA_TRUE; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
if (CPA_DC_OVERFLOW == (Cpa8S)cmpErr) { | if (CPA_DC_OVERFLOW == (Cpa8S)cmpErr) { | ||||
cmpPass = CPA_FALSE; | cmpPass = CPA_FALSE; | ||||
} | } | ||||
if (CPA_DC_OVERFLOW == (Cpa8S)xlatErr) { | if (CPA_DC_OVERFLOW == (Cpa8S)xlatErr) { | ||||
/* XLT overflow is not valid for Data Plane requests */ | |||||
xlatPass = CPA_FALSE; | xlatPass = CPA_FALSE; | ||||
} | } | ||||
} | } | ||||
if ((CPA_TRUE == cmpPass) && (CPA_TRUE == xlatPass)) { | if ((CPA_TRUE == cmpPass) && (CPA_TRUE == xlatPass)) { | ||||
/* Extract the response from the firmware */ | /* Extract the response from the firmware */ | ||||
pResults->consumed = | pResults->consumed = | ||||
pCompRespMsg->comp_resp_pars.input_byte_counter; | pCompRespMsg->comp_resp_pars.input_byte_counter; | ||||
pResults->produced = | pResults->produced = | ||||
pCompRespMsg->comp_resp_pars.output_byte_counter; | pCompRespMsg->comp_resp_pars.output_byte_counter; | ||||
pSessionDesc->cumulativeConsumedBytes += pResults->consumed; | pSessionDesc->cumulativeConsumedBytes += pResults->consumed; | ||||
if (CPA_DC_OVERFLOW != (Cpa8S)xlatErr) { | /* Handle Checksum for end to end data integrity. */ | ||||
if (CPA_TRUE == | |||||
pService->generic_service_info.integrityCrcCheck && | |||||
CPA_TRUE == integrityCrcCheck) { | |||||
pSessionDesc->previousChecksum = | |||||
pSessionDesc->seedSwCrc.swCrc32I; | |||||
} else if (CPA_DC_OVERFLOW != (Cpa8S)xlatErr) { | |||||
if (CPA_DC_CRC32 == pSessionDesc->checksumType) { | if (CPA_DC_CRC32 == pSessionDesc->checksumType) { | ||||
pResults->checksum = | pResults->checksum = | ||||
pCompRespMsg->comp_resp_pars.crc.legacy | pCompRespMsg->comp_resp_pars.crc.legacy | ||||
.curr_crc32; | .curr_crc32; | ||||
} else if (CPA_DC_ADLER32 == | } else if (CPA_DC_ADLER32 == | ||||
pSessionDesc->checksumType) { | pSessionDesc->checksumType) { | ||||
pResults->checksum = | pResults->checksum = | ||||
pCompRespMsg->comp_resp_pars.crc.legacy | pCompRespMsg->comp_resp_pars.crc.legacy | ||||
.curr_adler_32; | .curr_adler_32; | ||||
} | } | ||||
pSessionDesc->previousChecksum = pResults->checksum; | pSessionDesc->previousChecksum = pResults->checksum; | ||||
} | } | ||||
if (DC_DECOMPRESSION_REQUEST == compDecomp) { | if (DC_DECOMPRESSION_REQUEST == compDecomp) { | ||||
pResults->endOfLastBlock = | pResults->endOfLastBlock = | ||||
(ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET == | (ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET == | ||||
ICP_QAT_FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET( | ICP_QAT_FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET( | ||||
opStatus)); | opStatus)); | ||||
} | } | ||||
/* Save the checksum for the next request */ | /* Save the checksum for the next request */ | ||||
if ((CPA_DC_OVERFLOW != (Cpa8S)xlatErr) && | if ((CPA_DC_OVERFLOW != (Cpa8S)xlatErr) && | ||||
(CPA_TRUE == verifyHwIntegrityCrcs)) { | (CPA_TRUE == verifyHwIntegrityCrcs)) { | ||||
pSessionDesc->previousChecksum = | pSessionDesc->previousChecksum = | ||||
pSessionDesc->seedSwCrc.swCrcI; | pSessionDesc->seedSwCrc.swCrc32I; | ||||
} | } | ||||
/* Check if a CNV recovery happened and | /* Check if a CNV recovery happened and | ||||
* increase stats counter | * increase stats counter | ||||
*/ | */ | ||||
if ((DC_COMPRESSION_REQUEST == compDecomp) && | if ((DC_COMPRESSION_REQUEST == compDecomp) && | ||||
ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(hdrFlags) && | ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(hdrFlags) && | ||||
ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_GET(hdrFlags)) { | ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_GET(hdrFlags)) { | ||||
COMPRESSION_STAT_INC(numCompCnvErrorsRecovered, | COMPRESSION_STAT_INC(numCompCnvErrorsRecovered, | ||||
pService); | pService); | ||||
} | } | ||||
if (CPA_TRUE == pSessionDesc->isDcDp) { | if (CPA_TRUE == isDcDp) { | ||||
if (pResponse) | if (pResponse) | ||||
pResponse->responseStatus = CPA_STATUS_SUCCESS; | pResponse->responseStatus = CPA_STATUS_SUCCESS; | ||||
} else { | } else { | ||||
if (DC_COMPRESSION_REQUEST == compDecomp) { | if (DC_COMPRESSION_REQUEST == compDecomp) { | ||||
COMPRESSION_STAT_INC(numCompCompleted, | COMPRESSION_STAT_INC(numCompCompleted, | ||||
pService); | pService); | ||||
} else { | } else { | ||||
COMPRESSION_STAT_INC(numDecompCompleted, | COMPRESSION_STAT_INC(numDecompCompleted, | ||||
pService); | pService); | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
#ifdef ICP_DC_RETURN_COUNTERS_ON_ERROR | |||||
/* Extract the response from the firmware */ | |||||
pResults->consumed = | |||||
pCompRespMsg->comp_resp_pars.input_byte_counter; | |||||
pResults->produced = | |||||
pCompRespMsg->comp_resp_pars.output_byte_counter; | |||||
if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | |||||
pSessionDesc->cumulativeConsumedBytes += | |||||
pResults->consumed; | |||||
} else { | |||||
/* In the stateless case all requests have both SOP and | |||||
* EOP set */ | |||||
pSessionDesc->cumulativeConsumedBytes = | |||||
pResults->consumed; | |||||
} | |||||
#else | |||||
pResults->consumed = 0; | pResults->consumed = 0; | ||||
pResults->produced = 0; | pResults->produced = 0; | ||||
#endif | |||||
if (CPA_DC_OVERFLOW == pResults->status && | if (CPA_DC_OVERFLOW == pResults->status && | ||||
CPA_DC_STATELESS == pSessionDesc->sessState) { | CPA_DC_STATELESS == pSessionDesc->sessState) { | ||||
/* This error message will be returned by Data Plane API | /* This error message will be returned by Data Plane API | ||||
* in both | * in both | ||||
* compression and decompression direction. With | * compression and decompression direction. With | ||||
* Traditional API | * Traditional API | ||||
* this error message will be returned only in stateless | * this error message will be returned only in stateless | ||||
* decompression direction */ | * decompression direction */ | ||||
QAT_UTILS_LOG( | QAT_UTILS_LOG( | ||||
"Unrecoverable error: stateless overflow. You may need to increase the size of your destination buffer.\n"); | "Unrecoverable error: stateless overflow. You may need to increase the size of your destination buffer.\n"); | ||||
} | } | ||||
if (CPA_TRUE == pSessionDesc->isDcDp) { | if (CPA_TRUE == isDcDp) { | ||||
if (pResponse) | if (pResponse) | ||||
pResponse->responseStatus = CPA_STATUS_FAIL; | pResponse->responseStatus = CPA_STATUS_FAIL; | ||||
} else { | } else { | ||||
if (CPA_DC_OK != pResults->status && | if (CPA_DC_OK != pResults->status && | ||||
CPA_DC_INCOMPLETE_FILE_ERR != pResults->status) { | CPA_DC_INCOMPLETE_FILE_ERR != pResults->status) { | ||||
status = CPA_STATUS_FAIL; | status = CPA_STATUS_FAIL; | ||||
} | } | ||||
if (DC_COMPRESSION_REQUEST == compDecomp) { | if (DC_COMPRESSION_REQUEST == compDecomp) { | ||||
COMPRESSION_STAT_INC(numCompCompletedErrors, | COMPRESSION_STAT_INC(numCompCompletedErrors, | ||||
pService); | pService); | ||||
} else { | } else { | ||||
COMPRESSION_STAT_INC(numDecompCompletedErrors, | COMPRESSION_STAT_INC(numDecompCompletedErrors, | ||||
pService); | pService); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (CPA_TRUE == pSessionDesc->isDcDp) { | if (CPA_TRUE == isDcDp) { | ||||
/* Decrement number of stateless pending callbacks for session | /* Decrement number of stateless pending callbacks for session | ||||
*/ | */ | ||||
pSessionDesc->pendingDpStatelessCbCount--; | pSessionDesc->pendingDpStatelessCbCount--; | ||||
(pService->pDcDpCb)(pResponse); | (pService->pDcDpCb)(pResponse); | ||||
} else { | } else { | ||||
/* Decrement number of pending callbacks for session */ | /* Decrement number of pending callbacks for session */ | ||||
if (CPA_DC_STATELESS == pSessionDesc->sessState) { | if (CPA_DC_STATELESS == pSessionDesc->sessState) { | ||||
qatUtilsAtomicDec( | qatUtilsAtomicDec( | ||||
Show All 28 Lines | |||||
* @param[in] pService Pointer to the compression service | * @param[in] pService Pointer to the compression service | ||||
* @param[in] pOpData Pointer to request information structure | * @param[in] pOpData Pointer to request information structure | ||||
* holding parameters for cpaDcCompress2 and | * holding parameters for cpaDcCompress2 and | ||||
* CpaDcDecompressData2 | * CpaDcDecompressData2 | ||||
* @retval CPA_STATUS_SUCCESS Function executed successfully | * @retval CPA_STATUS_SUCCESS Function executed successfully | ||||
* @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in | * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in | ||||
* | * | ||||
*****************************************************************************/ | *****************************************************************************/ | ||||
static CpaStatus | CpaStatus | ||||
dcCheckOpData(sal_compression_service_t *pService, CpaDcOpData *pOpData) | dcCheckOpData(sal_compression_service_t *pService, CpaDcOpData *pOpData) | ||||
{ | { | ||||
CpaDcSkipMode skipMode = 0; | CpaDcSkipMode skipMode = 0; | ||||
if ((pOpData->flushFlag < CPA_DC_FLUSH_NONE) || | if ((pOpData->flushFlag < CPA_DC_FLUSH_NONE) || | ||||
(pOpData->flushFlag > CPA_DC_FLUSH_FULL)) { | (pOpData->flushFlag > CPA_DC_FLUSH_FULL)) { | ||||
LAC_INVALID_PARAM_LOG("Invalid flushFlag value"); | LAC_INVALID_PARAM_LOG("Invalid flushFlag value"); | ||||
return CPA_STATUS_INVALID_PARAM; | return CPA_STATUS_INVALID_PARAM; | ||||
Show All 40 Lines | dcCheckOpData(sal_compression_service_t *pService, CpaDcOpData *pOpData) | ||||
} | } | ||||
if (CPA_TRUE == pOpData->integrityCrcCheck && | if (CPA_TRUE == pOpData->integrityCrcCheck && | ||||
CPA_FALSE == pService->generic_service_info.integrityCrcCheck) { | CPA_FALSE == pService->generic_service_info.integrityCrcCheck) { | ||||
LAC_INVALID_PARAM_LOG("Integrity CRC check is not " | LAC_INVALID_PARAM_LOG("Integrity CRC check is not " | ||||
"supported on this device"); | "supported on this device"); | ||||
return CPA_STATUS_INVALID_PARAM; | return CPA_STATUS_INVALID_PARAM; | ||||
} | } | ||||
if (CPA_TRUE == pOpData->integrityCrcCheck && | |||||
NULL == pOpData->pCrcData) { | |||||
LAC_INVALID_PARAM_LOG("Integrity CRC data structure " | |||||
"not intialized in CpaDcOpData"); | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
return CPA_STATUS_SUCCESS; | return CPA_STATUS_SUCCESS; | ||||
} | } | ||||
/** | /** | ||||
***************************************************************************** | ***************************************************************************** | ||||
* @ingroup Dc_DataCompression | * @ingroup Dc_DataCompression | ||||
* Check the compression source buffer for Batch and Pack API. | * Check the compression source buffer for Batch and Pack API. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | LAC_INVALID_PARAM_LOG( | ||||
"The session type should not be data plane"); | "The session type should not be data plane"); | ||||
return CPA_STATUS_INVALID_PARAM; | return CPA_STATUS_INVALID_PARAM; | ||||
} | } | ||||
if (DC_COMPRESSION_REQUEST == compDecomp) { | if (DC_COMPRESSION_REQUEST == compDecomp) { | ||||
if (CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType) { | if (CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType) { | ||||
/* Check if intermediate buffers are supported */ | /* Check if intermediate buffers are supported */ | ||||
if ((0 == pService->pInterBuffPtrsArrayPhyAddr) || | if ((isDcGen2x(pService)) && | ||||
(NULL == pService->pInterBuffPtrsArray)) { | ((0 == pService->pInterBuffPtrsArrayPhyAddr) || | ||||
(NULL == pService->pInterBuffPtrsArray))) { | |||||
LAC_LOG_ERROR( | LAC_LOG_ERROR( | ||||
"No intermediate buffer defined for this instance " | "No intermediate buffer defined for this instance " | ||||
"- see cpaDcStartInstance"); | "- see cpaDcStartInstance"); | ||||
return CPA_STATUS_INVALID_PARAM; | return CPA_STATUS_INVALID_PARAM; | ||||
} | } | ||||
/* Ensure that the destination buffer size is greater or | /* Ensure that the destination buffer size is greater or | ||||
* equal to 128B */ | * equal to 128B */ | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | dcCreateRequest(dc_compression_cookie_t *pCookie, | ||||
Cpa32U rpCmdFlags = 0; | Cpa32U rpCmdFlags = 0; | ||||
Cpa8U sop = ICP_QAT_FW_COMP_SOP; | Cpa8U sop = ICP_QAT_FW_COMP_SOP; | ||||
Cpa8U eop = ICP_QAT_FW_COMP_EOP; | Cpa8U eop = ICP_QAT_FW_COMP_EOP; | ||||
Cpa8U bFinal = ICP_QAT_FW_COMP_NOT_BFINAL; | Cpa8U bFinal = ICP_QAT_FW_COMP_NOT_BFINAL; | ||||
Cpa8U crcMode = ICP_QAT_FW_COMP_CRC_MODE_LEGACY; | Cpa8U crcMode = ICP_QAT_FW_COMP_CRC_MODE_LEGACY; | ||||
Cpa8U cnvDecompReq = ICP_QAT_FW_COMP_NO_CNV; | Cpa8U cnvDecompReq = ICP_QAT_FW_COMP_NO_CNV; | ||||
Cpa8U cnvRecovery = ICP_QAT_FW_COMP_NO_CNV_RECOVERY; | Cpa8U cnvRecovery = ICP_QAT_FW_COMP_NO_CNV_RECOVERY; | ||||
CpaBoolean cnvErrorInjection = ICP_QAT_FW_COMP_NO_CNV_DFX; | |||||
CpaBoolean integrityCrcCheck = CPA_FALSE; | CpaBoolean integrityCrcCheck = CPA_FALSE; | ||||
CpaStatus status = CPA_STATUS_SUCCESS; | CpaStatus status = CPA_STATUS_SUCCESS; | ||||
CpaDcFlush flush = CPA_DC_FLUSH_NONE; | CpaDcFlush flush = CPA_DC_FLUSH_NONE; | ||||
Cpa32U initial_adler = 1; | Cpa32U initial_adler = 1; | ||||
Cpa32U initial_crc32 = 0; | Cpa32U initial_crc32 = 0; | ||||
icp_qat_fw_comp_req_t *pReqCache = NULL; | icp_qat_fw_comp_req_t *pReqCache = NULL; | ||||
/* Write the buffer descriptors */ | /* Write the buffer descriptors */ | ||||
Show All 39 Lines | dcCreateRequest(dc_compression_cookie_t *pCookie, | ||||
} | } | ||||
pCookie->flushFlag = flush; | pCookie->flushFlag = flush; | ||||
/* The firmware expects the length in bytes for source and destination | /* The firmware expects the length in bytes for source and destination | ||||
* to be Cpa32U parameters. However the total data length could be | * to be Cpa32U parameters. However the total data length could be | ||||
* bigger as allocated by the user. We ensure that this is not the case | * bigger as allocated by the user. We ensure that this is not the case | ||||
* in dcCheckSourceData and cast the values to Cpa32U here */ | * in dcCheckSourceData and cast the values to Cpa32U here */ | ||||
pCookie->srcTotalDataLenInBytes = (Cpa32U)srcTotalDataLenInBytes; | pCookie->srcTotalDataLenInBytes = (Cpa32U)srcTotalDataLenInBytes; | ||||
if ((DC_COMPRESSION_REQUEST == compDecomp) && | if ((isDcGen2x(pService)) && (DC_COMPRESSION_REQUEST == compDecomp) && | ||||
(CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType)) { | (CPA_DC_HT_FULL_DYNAMIC == pSessionDesc->huffType)) { | ||||
if (pService->minInterBuffSizeInBytes < | if (pService->minInterBuffSizeInBytes < | ||||
(Cpa32U)dstTotalDataLenInBytes) { | (Cpa32U)dstTotalDataLenInBytes) { | ||||
pCookie->dstTotalDataLenInBytes = | pCookie->dstTotalDataLenInBytes = | ||||
(Cpa32U)(pService->minInterBuffSizeInBytes); | (Cpa32U)(pService->minInterBuffSizeInBytes); | ||||
} else { | } else { | ||||
pCookie->dstTotalDataLenInBytes = | pCookie->dstTotalDataLenInBytes = | ||||
(Cpa32U)dstTotalDataLenInBytes; | (Cpa32U)dstTotalDataLenInBytes; | ||||
Show All 39 Lines | memcpy((void *)pMsg, | ||||
(void *)(pReqCache), | (void *)(pReqCache), | ||||
LAC_QAT_DC_REQ_SZ_LW * LAC_LONG_WORD_IN_BYTES); | LAC_QAT_DC_REQ_SZ_LW * LAC_LONG_WORD_IN_BYTES); | ||||
if (DC_REQUEST_FIRST == pSessionDesc->requestType) { | if (DC_REQUEST_FIRST == pSessionDesc->requestType) { | ||||
initial_adler = 1; | initial_adler = 1; | ||||
initial_crc32 = 0; | initial_crc32 = 0; | ||||
if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { | if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { | ||||
pSessionDesc->previousChecksum = 1; | pSessionDesc->previousChecksum = initial_adler; | ||||
} else { | } else { | ||||
pSessionDesc->previousChecksum = 0; | pSessionDesc->previousChecksum = initial_crc32; | ||||
} | } | ||||
} else if (CPA_DC_STATELESS == pSessionDesc->sessState) { | } else if (CPA_DC_STATELESS == pSessionDesc->sessState) { | ||||
pSessionDesc->previousChecksum = pResults->checksum; | pSessionDesc->previousChecksum = pResults->checksum; | ||||
if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { | if (CPA_DC_ADLER32 == pSessionDesc->checksumType) { | ||||
initial_adler = pSessionDesc->previousChecksum; | initial_adler = pSessionDesc->previousChecksum; | ||||
} else { | } else { | ||||
initial_crc32 = pSessionDesc->previousChecksum; | initial_crc32 = pSessionDesc->previousChecksum; | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | ||||
if ((CPA_DC_FLUSH_FINAL == flush) || | if ((CPA_DC_FLUSH_FINAL == flush) || | ||||
(CPA_DC_FLUSH_FULL == flush)) { | (CPA_DC_FLUSH_FULL == flush)) { | ||||
/* Update the request type for following requests */ | /* Update the request type for following requests */ | ||||
pSessionDesc->requestType = DC_REQUEST_FIRST; | pSessionDesc->requestType = DC_REQUEST_FIRST; | ||||
} else { | } else { | ||||
eop = ICP_QAT_FW_COMP_NOT_EOP; | eop = ICP_QAT_FW_COMP_NOT_EOP; | ||||
} | } | ||||
} else { | } else { | ||||
if (DC_REQUEST_FIRST == pSessionDesc->requestType) { | if (DC_REQUEST_FIRST == pSessionDesc->requestType) { | ||||
/* Reinitialise the cumulative amount of consumed bytes | /* Reinitialise the cumulative amount of consumed bytes | ||||
*/ | */ | ||||
pSessionDesc->cumulativeConsumedBytes = 0; | pSessionDesc->cumulativeConsumedBytes = 0; | ||||
} | } | ||||
} | } | ||||
/* (LW 14 - 15) */ | /* (LW 14 - 15) */ | ||||
pCompReqParams = &(pMsg->comp_pars); | pCompReqParams = &(pMsg->comp_pars); | ||||
dcCompRequestParamsPopulate(pCompReqParams, pCookie); | dcCompRequestParamsPopulate(pCompReqParams, pCookie); | ||||
if (CPA_DC_FLUSH_FINAL == flush) { | if (CPA_DC_FLUSH_FINAL == flush) { | ||||
bFinal = ICP_QAT_FW_COMP_BFINAL; | bFinal = ICP_QAT_FW_COMP_BFINAL; | ||||
} | } | ||||
switch (cnvMode) { | switch (cnvMode) { | ||||
case DC_CNVNR: | case DC_CNVNR: | ||||
cnvRecovery = ICP_QAT_FW_COMP_CNV_RECOVERY; | cnvRecovery = ICP_QAT_FW_COMP_CNV_RECOVERY; | ||||
/* Fall through is intended here, because for CNVNR | /* Fall through is intended here, because for CNVNR | ||||
* cnvDecompReq also needs to be set */ | * cnvDecompReq also needs to be set */ | ||||
case DC_CNV: | case DC_CNV: | ||||
cnvDecompReq = ICP_QAT_FW_COMP_CNV; | cnvDecompReq = ICP_QAT_FW_COMP_CNV; | ||||
if (isDcGen4x(pService)) { | |||||
cnvErrorInjection = pSessionDesc->cnvErrorInjection; | |||||
} | |||||
break; | break; | ||||
case DC_NO_CNV: | case DC_NO_CNV: | ||||
cnvDecompReq = ICP_QAT_FW_COMP_NO_CNV; | cnvDecompReq = ICP_QAT_FW_COMP_NO_CNV; | ||||
cnvRecovery = ICP_QAT_FW_COMP_NO_CNV_RECOVERY; | cnvRecovery = ICP_QAT_FW_COMP_NO_CNV_RECOVERY; | ||||
break; | break; | ||||
} | } | ||||
/* LW 18 */ | /* LW 18 */ | ||||
rpCmdFlags = ICP_QAT_FW_COMP_REQ_PARAM_FLAGS_BUILD( | rpCmdFlags = ICP_QAT_FW_COMP_REQ_PARAM_FLAGS_BUILD(sop, | ||||
sop, eop, bFinal, cnvDecompReq, cnvRecovery, crcMode); | eop, | ||||
bFinal, | |||||
cnvDecompReq, | |||||
cnvRecovery, | |||||
cnvErrorInjection, | |||||
crcMode); | |||||
pMsg->comp_pars.req_par_flags = rpCmdFlags; | pMsg->comp_pars.req_par_flags = rpCmdFlags; | ||||
/* Populates the QAT common request middle part of the message | /* Populates the QAT common request middle part of the message | ||||
* (LW 6 to 11) */ | * (LW 6 to 11) */ | ||||
SalQatMsg_CmnMidWrite((icp_qat_fw_la_bulk_req_t *)pMsg, | SalQatMsg_CmnMidWrite((icp_qat_fw_la_bulk_req_t *)pMsg, | ||||
pCookie, | pCookie, | ||||
DC_DEFAULT_QAT_PTR_TYPE, | DC_DEFAULT_QAT_PTR_TYPE, | ||||
srcAddrPhys, | srcAddrPhys, | ||||
▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | if (CPA_TRUE == status) { | ||||
if (DC_COMPRESSION_REQUEST == compDecomp) { | if (DC_COMPRESSION_REQUEST == compDecomp) { | ||||
COMPRESSION_STAT_INC(numCompRequests, pService); | COMPRESSION_STAT_INC(numCompRequests, pService); | ||||
COMPRESSION_STAT_INC(numCompCompleted, pService); | COMPRESSION_STAT_INC(numCompCompleted, pService); | ||||
} else { | } else { | ||||
COMPRESSION_STAT_INC(numDecompRequests, pService); | COMPRESSION_STAT_INC(numDecompRequests, pService); | ||||
COMPRESSION_STAT_INC(numDecompCompleted, pService); | COMPRESSION_STAT_INC(numDecompCompleted, pService); | ||||
} | } | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot unlock session lock"); | |||||
} | |||||
if ((NULL != pCbFunc) && | if ((NULL != pCbFunc) && | ||||
(LacSync_GenWakeupSyncCaller != pCbFunc)) { | (LacSync_GenWakeupSyncCaller != pCbFunc)) { | ||||
pCbFunc(callbackTag, CPA_STATUS_SUCCESS); | pCbFunc(callbackTag, CPA_STATUS_SUCCESS); | ||||
} | } | ||||
return CPA_TRUE; | return CPA_TRUE; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | if (!(pService->generic_service_info.dcExtendedFeatures & | ||||
DC_CNVNR_EXTENDED_CAPABILITY)) { | DC_CNVNR_EXTENDED_CAPABILITY)) { | ||||
LAC_INVALID_PARAM_LOG( | LAC_INVALID_PARAM_LOG( | ||||
"CompressAndVerifyAndRecovery feature not supported"); | "CompressAndVerifyAndRecovery feature not supported"); | ||||
return CPA_STATUS_UNSUPPORTED; | return CPA_STATUS_UNSUPPORTED; | ||||
} | } | ||||
return dcCompDecompData(pService, | return dcCompDecompData(pService, | ||||
pSessionDesc, | pSessionDesc, | ||||
dcInstance, | insHandle, | ||||
pSessionHandle, | pSessionHandle, | ||||
pSrcBuff, | pSrcBuff, | ||||
pDestBuff, | pDestBuff, | ||||
pResults, | pResults, | ||||
flushFlag, | flushFlag, | ||||
NULL, | NULL, | ||||
callbackTag, | callbackTag, | ||||
DC_COMPRESSION_REQUEST, | DC_COMPRESSION_REQUEST, | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | if (srcBuffSize > DC_COMP_MAX_BUFF_SIZE) { | ||||
"unsupported, when CnV is disabled\n"); | "unsupported, when CnV is disabled\n"); | ||||
return CPA_STATUS_UNSUPPORTED; | return CPA_STATUS_UNSUPPORTED; | ||||
} | } | ||||
} | } | ||||
if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | ||||
/* Lock the session to check if there are in-flight stateful | /* Lock the session to check if there are in-flight stateful | ||||
* requests */ | * requests */ | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot unlock session lock"); | |||||
} | |||||
/* Check if there is already one in-flight stateful request */ | /* Check if there is already one in-flight stateful request */ | ||||
if (0 != | if (0 != | ||||
qatUtilsAtomicGet( | qatUtilsAtomicGet( | ||||
&(pSessionDesc->pendingStatefulCbCount))) { | &(pSessionDesc->pendingStatefulCbCount))) { | ||||
LAC_LOG_ERROR( | LAC_LOG_ERROR( | ||||
"Only one in-flight stateful request supported"); | "Only one in-flight stateful request supported"); | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot unlock session lock"); | |||||
} | |||||
return CPA_STATUS_RETRY; | return CPA_STATUS_RETRY; | ||||
} | } | ||||
if (0 == srcBuffSize) { | if (0 == srcBuffSize) { | ||||
if (CPA_TRUE == | if (CPA_TRUE == | ||||
dcZeroLengthRequests(pService, | dcZeroLengthRequests(pService, | ||||
pSessionDesc, | pSessionDesc, | ||||
pResults, | pResults, | ||||
pOpData->flushFlag, | pOpData->flushFlag, | ||||
callbackTag, | callbackTag, | ||||
DC_COMPRESSION_REQUEST)) { | DC_COMPRESSION_REQUEST)) { | ||||
return CPA_STATUS_SUCCESS; | return CPA_STATUS_SUCCESS; | ||||
} | } | ||||
} | } | ||||
qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); | qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot unlock session lock"); | |||||
} | } | ||||
} | |||||
if (CPA_TRUE == pOpData->compressAndVerify) { | if (CPA_TRUE == pOpData->compressAndVerify) { | ||||
cnvMode = DC_CNV; | cnvMode = DC_CNV; | ||||
} | } | ||||
return dcCompDecompData(pService, | return dcCompDecompData(pService, | ||||
pSessionDesc, | pSessionDesc, | ||||
dcInstance, | insHandle, | ||||
pSessionHandle, | pSessionHandle, | ||||
pSrcBuff, | pSrcBuff, | ||||
pDestBuff, | pDestBuff, | ||||
pResults, | pResults, | ||||
pOpData->flushFlag, | pOpData->flushFlag, | ||||
pOpData, | pOpData, | ||||
callbackTag, | callbackTag, | ||||
DC_COMPRESSION_REQUEST, | DC_COMPRESSION_REQUEST, | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | status = dcDecompressDataCheck(insHandle, | ||||
flushFlag, | flushFlag, | ||||
&srcBuffSize); | &srcBuffSize); | ||||
if (CPA_STATUS_SUCCESS != status) { | if (CPA_STATUS_SUCCESS != status) { | ||||
return status; | return status; | ||||
} | } | ||||
pService = (sal_compression_service_t *)insHandle; | pService = (sal_compression_service_t *)insHandle; | ||||
/* Check if SAL is initialised otherwise return an error */ | |||||
SAL_RUNNING_CHECK(insHandle); | |||||
/* This check is outside the parameter checking as it is needed to | |||||
* manage zero length requests */ | |||||
if (CPA_STATUS_SUCCESS != | |||||
LacBuffDesc_BufferListVerifyNull(pSrcBuff, | |||||
&srcBuffSize, | |||||
LAC_NO_ALIGNMENT_SHIFT)) { | |||||
QAT_UTILS_LOG("Invalid source buffer list parameter"); | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
/* Ensure this is a compression instance */ | |||||
SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); | |||||
if (dcCheckSourceData(pSessionHandle, | |||||
pSrcBuff, | |||||
pDestBuff, | |||||
pResults, | |||||
flushFlag, | |||||
srcBuffSize, | |||||
NULL) != CPA_STATUS_SUCCESS) { | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
if (dcCheckDestinationData(pService, | |||||
pSessionHandle, | |||||
pDestBuff, | |||||
DC_DECOMPRESSION_REQUEST) != | |||||
CPA_STATUS_SUCCESS) { | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); | pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); | ||||
if (CPA_DC_DIR_COMPRESS == pSessionDesc->sessDirection) { | |||||
QAT_UTILS_LOG("Invalid sessDirection value"); | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | ||||
/* Lock the session to check if there are in-flight stateful | /* Lock the session to check if there are in-flight stateful | ||||
* requests */ | * requests */ | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot lock session lock"); | |||||
return CPA_STATUS_RESOURCE; | |||||
} | |||||
/* Check if there is already one in-flight stateful request */ | /* Check if there is already one in-flight stateful request */ | ||||
if (0 != | if (0 != | ||||
qatUtilsAtomicGet( | qatUtilsAtomicGet( | ||||
&(pSessionDesc->pendingStatefulCbCount))) { | &(pSessionDesc->pendingStatefulCbCount))) { | ||||
LAC_LOG_ERROR( | LAC_LOG_ERROR( | ||||
"Only one in-flight stateful request supported"); | "Only one in-flight stateful request supported"); | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot unlock session lock"); | |||||
} | |||||
return CPA_STATUS_RETRY; | return CPA_STATUS_RETRY; | ||||
} | } | ||||
/* Gen 4 handle 0 len requests in FW */ | |||||
if (isDcGen2x(pService)) { | |||||
if ((0 == srcBuffSize) || | if ((0 == srcBuffSize) || | ||||
((1 == srcBuffSize) && (CPA_DC_FLUSH_FINAL != flushFlag) && | ((1 == srcBuffSize) && | ||||
(CPA_DC_FLUSH_FINAL != flushFlag) && | |||||
(CPA_DC_FLUSH_FULL != flushFlag))) { | (CPA_DC_FLUSH_FULL != flushFlag))) { | ||||
if (CPA_TRUE == | if (CPA_TRUE == | ||||
dcZeroLengthRequests(pService, | dcZeroLengthRequests( | ||||
pService, | |||||
pSessionDesc, | pSessionDesc, | ||||
pResults, | pResults, | ||||
flushFlag, | flushFlag, | ||||
callbackTag, | callbackTag, | ||||
DC_DECOMPRESSION_REQUEST)) { | DC_DECOMPRESSION_REQUEST)) { | ||||
return CPA_STATUS_SUCCESS; | return CPA_STATUS_SUCCESS; | ||||
} | } | ||||
} | } | ||||
} | |||||
qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); | qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); | ||||
if (CPA_STATUS_SUCCESS != | LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | ||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock))) { | |||||
LAC_LOG_ERROR("Cannot unlock session lock"); | |||||
} | } | ||||
} | |||||
return dcCompDecompData(pService, | return dcCompDecompData(pService, | ||||
pSessionDesc, | pSessionDesc, | ||||
dcInstance, | insHandle, | ||||
pSessionHandle, | pSessionHandle, | ||||
pSrcBuff, | pSrcBuff, | ||||
pDestBuff, | pDestBuff, | ||||
pResults, | pResults, | ||||
flushFlag, | flushFlag, | ||||
NULL, | NULL, | ||||
callbackTag, | callbackTag, | ||||
DC_DECOMPRESSION_REQUEST, | DC_DECOMPRESSION_REQUEST, | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | cpaDcDecompressData2(CpaInstanceHandle dcInstance, | ||||
if (CPA_STATUS_SUCCESS != status) { | if (CPA_STATUS_SUCCESS != status) { | ||||
return status; | return status; | ||||
} | } | ||||
pService = (sal_compression_service_t *)insHandle; | pService = (sal_compression_service_t *)insHandle; | ||||
pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); | pSessionDesc = DC_SESSION_DESC_FROM_CTX_GET(pSessionHandle); | ||||
if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | LAC_CHECK_NULL_PARAM(insHandle); | ||||
LAC_INVALID_PARAM_LOG("Invalid session: Stateful session is " | |||||
"not supported"); | /* Check if SAL is initialised otherwise return an error */ | ||||
SAL_RUNNING_CHECK(insHandle); | |||||
/* This check is outside the parameter checking as it is needed to | |||||
* manage zero length requests */ | |||||
if (CPA_STATUS_SUCCESS != | |||||
LacBuffDesc_BufferListVerifyNull(pSrcBuff, | |||||
&srcBuffSize, | |||||
LAC_NO_ALIGNMENT_SHIFT)) { | |||||
QAT_UTILS_LOG("Invalid source buffer list parameter"); | |||||
return CPA_STATUS_INVALID_PARAM; | return CPA_STATUS_INVALID_PARAM; | ||||
} | |||||
/* Ensure this is a compression instance */ | |||||
SAL_CHECK_INSTANCE_TYPE(insHandle, SAL_SERVICE_TYPE_COMPRESSION); | |||||
if (CPA_STATUS_SUCCESS != | |||||
dcCheckSourceData(pSessionHandle, | |||||
pSrcBuff, | |||||
pDestBuff, | |||||
pResults, | |||||
CPA_DC_FLUSH_NONE, | |||||
srcBuffSize, | |||||
NULL)) { | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
if (CPA_STATUS_SUCCESS != | |||||
dcCheckDestinationData(pService, | |||||
pSessionHandle, | |||||
pDestBuff, | |||||
DC_DECOMPRESSION_REQUEST)) { | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
if (CPA_STATUS_SUCCESS != dcCheckOpData(pService, pOpData)) { | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
if (CPA_DC_DIR_COMPRESS == pSessionDesc->sessDirection) { | |||||
QAT_UTILS_LOG("Invalid sessDirection value"); | |||||
return CPA_STATUS_INVALID_PARAM; | |||||
} | |||||
if (CPA_DC_STATEFUL == pSessionDesc->sessState) { | |||||
/* Lock the session to check if there are in-flight stateful | |||||
* requests */ | |||||
LAC_SPINLOCK(&(pSessionDesc->sessionLock)); | |||||
/* Check if there is already one in-flight stateful request */ | |||||
if (0 != | |||||
qatUtilsAtomicGet( | |||||
&(pSessionDesc->pendingStatefulCbCount))) { | |||||
LAC_LOG_ERROR( | |||||
"Only one in-flight stateful request supported"); | |||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | |||||
return CPA_STATUS_RETRY; | |||||
} | |||||
/* Gen 4 handle 0 len requests in FW */ | |||||
if (isDcGen2x(pService)) { | |||||
if ((0 == srcBuffSize) || | |||||
((1 == srcBuffSize) && | |||||
(CPA_DC_FLUSH_FINAL != pOpData->flushFlag) && | |||||
(CPA_DC_FLUSH_FULL != pOpData->flushFlag))) { | |||||
if (CPA_TRUE == | |||||
dcZeroLengthRequests( | |||||
pService, | |||||
pSessionDesc, | |||||
pResults, | |||||
pOpData->flushFlag, | |||||
callbackTag, | |||||
DC_DECOMPRESSION_REQUEST)) { | |||||
return CPA_STATUS_SUCCESS; | |||||
} | |||||
} | |||||
} | |||||
qatUtilsAtomicInc(&(pSessionDesc->pendingStatefulCbCount)); | |||||
LAC_SPINUNLOCK(&(pSessionDesc->sessionLock)); | |||||
} | } | ||||
return dcCompDecompData(pService, | return dcCompDecompData(pService, | ||||
pSessionDesc, | pSessionDesc, | ||||
insHandle, | insHandle, | ||||
pSessionHandle, | pSessionHandle, | ||||
pSrcBuff, | pSrcBuff, | ||||
pDestBuff, | pDestBuff, | ||||
pResults, | pResults, | ||||
pOpData->flushFlag, | pOpData->flushFlag, | ||||
pOpData, | pOpData, | ||||
callbackTag, | callbackTag, | ||||
DC_DECOMPRESSION_REQUEST, | DC_DECOMPRESSION_REQUEST, | ||||
CPA_TRUE, | CPA_TRUE, | ||||
DC_NO_CNV); | DC_NO_CNV); | ||||
} | } |