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