1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 /**
5 ***************************************************************************
6 * @file sal_service_state.h
7 *
8 * @defgroup SalServiceState
9 *
10 * @ingroup SalCtrl
11 *
12 * Checks state for generic service instance
13 *
14 ***************************************************************************/
15
16 #ifndef SAL_SERVICE_STATE_H_
17 #define SAL_SERVICE_STATE_H_
18
19 /**
20 *******************************************************************************
21 * @ingroup SalServiceState
22 * Check to see if the instance is in the running state
23 *
24 * @description
25 * This function checks the state of an instance to see if it is in the
26 * running state
27 *
28 * @param[in] instance Instance handle (assumes this is valid, i.e. checked
29 * before this function is called)
30 * @retval CPA_TRUE Instance in the RUNNING state
31 * @retval CPA_FALSE Instance not in RUNNING state
32 *
33 *****************************************************************************/
34 CpaBoolean Sal_ServiceIsRunning(CpaInstanceHandle instanceHandle);
35
36 /**
37 *******************************************************************************
38 * @ingroup SalServiceState
39 * Check to see if the instance is beign restarted
40 *
41 * @description
42 * This function checks the state of an instance to see if the device it
43 * uses is being restarted because of hardware error.
44 *
45 * @param[in] instance Instance handle (assumes this is valid, i.e. checked
46 * before this function is called)
47 * @retval CPA_TRUE Device the instance is using is restarting.
48 * @retval CPA_FALSE Device the instance is running.
49 *
50 *****************************************************************************/
51 CpaBoolean Sal_ServiceIsRestarting(CpaInstanceHandle instanceHandle);
52
53 /**
54 *******************************************************************************
55 * @ingroup SalServiceState
56 * This macro checks if an instance is running. An error message is logged
57 * if it is not in a running state.
58 *
59 * @return CPA_STATUS_FAIL Instance not in RUNNING state.
60 * @return void Instance is in RUNNING state.
61 ******************************************************************************/
62 #define SAL_RUNNING_CHECK(instanceHandle) \
63 do { \
64 if (unlikely(CPA_TRUE != \
65 Sal_ServiceIsRunning(instanceHandle))) { \
66 if (CPA_TRUE == \
67 Sal_ServiceIsRestarting(instanceHandle)) { \
68 return CPA_STATUS_RESTARTING; \
69 } \
70 QAT_UTILS_LOG("Instance not in a Running state\n"); \
71 return CPA_STATUS_FAIL; \
72 } \
73 } while (0)
74
75 /**
76 *******************************************************************************
77 * @ingroup SalServiceState
78 * This macro checks if an instance is in a state to get init event.
79 *
80 * @return CPA_STATUS_FAIL Instance not in good state.
81 * @return void Instance is in good state.
82 ******************************************************************************/
83 #define SAL_SERVICE_GOOD_FOR_INIT(instanceHandle) \
84 do { \
85 sal_service_t *pService = (sal_service_t *)instanceHandle; \
86 if ((SAL_SERVICE_STATE_UNINITIALIZED != pService->state) && \
87 (SAL_SERVICE_STATE_RESTARTING != pService->state)) { \
88 QAT_UTILS_LOG( \
89 "Not in the correct state to call init\n"); \
90 return CPA_STATUS_FAIL; \
91 } \
92 } while (0)
93
94 #endif /*SAL_SERVICE_STATE_H_*/
Cache object: 0500b4c902f9c95452ad9421d5d30d10
|