1/* SPDX-License-Identifier: BSD-3-Clause */ 2/* Copyright(c) 2007-2022 Intel Corporation */ 3/** 4 ***************************************************************************** 5 * @file lac_sync.c Utility functions containing synchronous callback support 6 * functions 7 * 8 * @ingroup LacSync 9 * 10 *****************************************************************************/ 11 12/* 13******************************************************************************* 14* Include public/global header files 15******************************************************************************* 16*/ 17#include "lac_sync.h" 18#include "lac_common.h" 19 20/* 21******************************************************************************* 22* Define public/global function definitions 23******************************************************************************* 24*/ 25 26/** 27 ***************************************************************************** 28 * @ingroup LacSync 29 *****************************************************************************/ 30void 31LacSync_GenWakeupSyncCaller(void *pCallbackTag, CpaStatus status) 32{ 33 lac_sync_op_data_t *pSc = (lac_sync_op_data_t *)pCallbackTag; 34 if (pSc != NULL) { 35 if (pSc->canceled) { 36 QAT_UTILS_LOG("Synchronous operation cancelled.\n"); 37 return; 38 } 39 pSc->status = status; 40 if (CPA_STATUS_SUCCESS != LAC_POST_SEMAPHORE(pSc->sid)) { 41 QAT_UTILS_LOG("Failed to post semaphore.\n"); 42 } 43 } 44} 45 46/** 47 ***************************************************************************** 48 * @ingroup LacSync 49 *****************************************************************************/ 50void 51LacSync_GenVerifyWakeupSyncCaller(void *pCallbackTag, 52 CpaStatus status, 53 CpaBoolean opResult) 54{ 55 lac_sync_op_data_t *pSc = (lac_sync_op_data_t *)pCallbackTag; 56 if (pSc != NULL) { 57 if (pSc->canceled) { 58 QAT_UTILS_LOG("Synchronous operation cancelled.\n"); 59 return; 60 } 61 pSc->status = status; 62 pSc->opResult = opResult; 63 if (CPA_STATUS_SUCCESS != LAC_POST_SEMAPHORE(pSc->sid)) { 64 QAT_UTILS_LOG("Failed to post semaphore.\n"); 65 } 66 } 67} 68 69/** 70 ***************************************************************************** 71 * @ingroup LacSync 72 *****************************************************************************/ 73void 74LacSync_GenVerifyCb(void *pCallbackTag, 75 CpaStatus status, 76 void *pOpData, 77 CpaBoolean opResult) 78{ 79 LacSync_GenVerifyWakeupSyncCaller(pCallbackTag, status, opResult); 80} 81 82/** 83 ***************************************************************************** 84 * @ingroup LacSync 85 *****************************************************************************/ 86void 87LacSync_GenFlatBufCb(void *pCallbackTag, 88 CpaStatus status, 89 void *pOpData, 90 CpaFlatBuffer *pOut) 91{ 92 LacSync_GenWakeupSyncCaller(pCallbackTag, status); 93} 94 95/** 96 ***************************************************************************** 97 * @ingroup LacSync 98 *****************************************************************************/ 99void 100LacSync_GenFlatBufVerifyCb(void *pCallbackTag, 101 CpaStatus status, 102 void *pOpData, 103 CpaBoolean opResult, 104 CpaFlatBuffer *pOut) 105{ 106 LacSync_GenVerifyWakeupSyncCaller(pCallbackTag, status, opResult); 107} 108 109/** 110 ***************************************************************************** 111 * @ingroup LacSync 112 *****************************************************************************/ 113void 114LacSync_GenDualFlatBufVerifyCb(void *pCallbackTag, 115 CpaStatus status, 116 void *pOpdata, 117 CpaBoolean opResult, 118 CpaFlatBuffer *pOut0, 119 CpaFlatBuffer *pOut1) 120{ 121 LacSync_GenVerifyWakeupSyncCaller(pCallbackTag, status, opResult); 122} 123