1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /*****************************************************************************
4  * @file icp_adf_accel_mgr.h
5  *
6  * @description
7  *      This file contains the function prototype for accel
8  *      instances management
9  *
10  *****************************************************************************/
11 #ifndef ICP_ADF_ACCEL_MGR_H
12 #define ICP_ADF_ACCEL_MGR_H
13 
14 /*
15  * Device reset mode type.
16  * If device reset is triggered from atomic context
17  * it needs to be in ICP_ADF_DEV_RESET_ASYNC mode.
18  * Otherwise can be either.
19  */
20 typedef enum icp_adf_dev_reset_mode_e {
21 	ICP_ADF_DEV_RESET_ASYNC = 0,
22 	ICP_ADF_DEV_RESET_SYNC
23 } icp_adf_dev_reset_mode_t;
24 
25 /*
26  * icp_adf_reset_dev
27  *
28  * Description:
29  * Function resets the given device.
30  * If device reset is triggered from atomic context
31  * it needs to be in ICP_ADF_DEV_RESET_ASYNC mode.
32  *
33  * Returns:
34  *   CPA_STATUS_SUCCESS   on success
35  *   CPA_STATUS_FAIL      on failure
36  */
37 CpaStatus icp_adf_reset_dev(icp_accel_dev_t *accel_dev,
38 			    icp_adf_dev_reset_mode_t mode);
39 
40 /*
41  * icp_adf_is_dev_in_reset
42  * Check if device is in reset state.
43  *
44  * Returns:
45  *   CPA_TRUE   device is in reset state
46  *   CPA_FALSE  device is not in reset state
47  */
48 CpaBoolean icp_adf_is_dev_in_reset(icp_accel_dev_t *accel_dev);
49 
50 /*
51  * icp_adf_is_dev_in_error
52  * Check if device is in error state.
53  *
54  * Returns:
55  *   CPA_TRUE   device is in error state
56  *   CPA_FALSE  device is not in error state
57  */
58 CpaBoolean icp_adf_is_dev_in_error(icp_accel_dev_t *accel_dev);
59 
60 /*
61  * icp_amgr_getNumInstances
62  *
63  * Description:
64  * Returns number of accel instances in the system.
65  *
66  * Returns:
67  *   CPA_STATUS_SUCCESS   on success
68  *   CPA_STATUS_FAIL      on failure
69  */
70 CpaStatus icp_amgr_getNumInstances(Cpa16U *pNumInstances);
71 
72 /*
73  * icp_amgr_getInstances
74  *
75  * Description:
76  * Returns table of accel instances in the system.
77  *
78  * Returns:
79  *   CPA_STATUS_SUCCESS   on success
80  *   CPA_STATUS_FAIL      on failure
81  */
82 CpaStatus icp_amgr_getInstances(Cpa16U numInstances,
83 				icp_accel_dev_t **pAccel_devs);
84 /*
85  * icp_amgr_getAccelDevByName
86  *
87  * Description:
88  * Returns the accel instance by name.
89  *
90  * Returns:
91  *   CPA_STATUS_SUCCESS   on success
92  *   CPA_STATUS_FAIL      on failure
93  */
94 CpaStatus icp_amgr_getAccelDevByName(unsigned char *instanceName,
95 				     icp_accel_dev_t **pAccel_dev);
96 /*
97  * icp_amgr_getAccelDevByCapabilities
98  *
99  * Description:
100  * Returns a started accel device that implements the capabilities
101  * specified in capabilitiesMask.
102  *
103  * Returns:
104  *   CPA_STATUS_SUCCESS   on success
105  *   CPA_STATUS_FAIL      on failure
106  */
107 CpaStatus icp_amgr_getAccelDevByCapabilities(Cpa32U capabilitiesMask,
108 					     icp_accel_dev_t **pAccel_devs,
109 					     Cpa16U *pNumInstances);
110 /*
111  * icp_amgr_getAllAccelDevByCapabilities
112  *
113  * Description:
114  * Returns table of accel devices that are started and implement
115  * the capabilities specified in capabilitiesMask.
116  *
117  * Returns:
118  *   CPA_STATUS_SUCCESS   on success
119  *   CPA_STATUS_FAIL      on failure
120  */
121 CpaStatus icp_amgr_getAllAccelDevByCapabilities(Cpa32U capabilitiesMask,
122 						icp_accel_dev_t **pAccel_devs,
123 						Cpa16U *pNumInstances);
124 
125 /*
126  * icp_amgr_getAccelDevCapabilities
127  * Returns accel devices capabilities specified in capabilitiesMask.
128  *
129  * Returns:
130  *   CPA_STATUS_SUCCESS   on success
131  *   CPA_STATUS_FAIL      on failure
132  */
133 CpaStatus icp_amgr_getAccelDevCapabilities(icp_accel_dev_t *accel_dev,
134 					   Cpa32U *pCapabilitiesMask);
135 
136 /*
137  * icp_amgr_getAllAccelDevByEachCapability
138  *
139  * Description:
140  * Returns table of accel devices that are started and implement
141  * each of the capability specified in capabilitiesMask.
142  *
143  * Returns:
144  *   CPA_STATUS_SUCCESS   on success
145  *   CPA_STATUS_FAIL      on failure
146  */
147 CpaStatus icp_amgr_getAllAccelDevByEachCapability(Cpa32U capabilitiesMask,
148 						  icp_accel_dev_t **pAccel_devs,
149 						  Cpa16U *pNumInstances);
150 
151 /*
152  * icp_qa_dev_get
153  *
154  * Description:
155  * Function increments the device usage counter.
156  *
157  * Returns: void
158  */
159 void icp_qa_dev_get(icp_accel_dev_t *pDev);
160 
161 /*
162  * icp_qa_dev_put
163  *
164  * Description:
165  * Function decrements the device usage counter.
166  *
167  * Returns: void
168  */
169 void icp_qa_dev_put(icp_accel_dev_t *pDev);
170 
171 /*
172  * icp_adf_getAccelDevByAccelId
173  *
174  * Description:
175  * Gets the accel_dev structure based on accelId
176  *
177  * Returns: a pointer to the accelerator structure or NULL if not found.
178  */
179 icp_accel_dev_t *icp_adf_getAccelDevByAccelId(Cpa32U accelId);
180 
181 #endif /* ICP_ADF_ACCEL_MGR_H */
182