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 *****************************************************************************/
30 void
LacSync_GenWakeupSyncCaller(void * pCallbackTag,CpaStatus status)31 LacSync_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 *****************************************************************************/
50 void
LacSync_GenVerifyWakeupSyncCaller(void * pCallbackTag,CpaStatus status,CpaBoolean opResult)51 LacSync_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 *****************************************************************************/
73 void
LacSync_GenVerifyCb(void * pCallbackTag,CpaStatus status,void * pOpData,CpaBoolean opResult)74 LacSync_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 *****************************************************************************/
86 void
LacSync_GenFlatBufCb(void * pCallbackTag,CpaStatus status,void * pOpData,CpaFlatBuffer * pOut)87 LacSync_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 *****************************************************************************/
99 void
LacSync_GenFlatBufVerifyCb(void * pCallbackTag,CpaStatus status,void * pOpData,CpaBoolean opResult,CpaFlatBuffer * pOut)100 LacSync_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 *****************************************************************************/
113 void
LacSync_GenDualFlatBufVerifyCb(void * pCallbackTag,CpaStatus status,void * pOpdata,CpaBoolean opResult,CpaFlatBuffer * pOut0,CpaFlatBuffer * pOut1)114 LacSync_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