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_FALS   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_amgr_getNumInstances
53  *
54  * Description:
55  * Returns number of accel instances in the system.
56  *
57  * Returns:
58  *   CPA_STATUS_SUCCESS   on success
59  *   CPA_STATUS_FAIL      on failure
60  */
61 CpaStatus icp_amgr_getNumInstances(Cpa16U *pNumInstances);
62 
63 /*
64  * icp_amgr_getInstances
65  *
66  * Description:
67  * Returns table of accel instances in the system.
68  *
69  * Returns:
70  *   CPA_STATUS_SUCCESS   on success
71  *   CPA_STATUS_FAIL      on failure
72  */
73 CpaStatus icp_amgr_getInstances(Cpa16U numInstances,
74 				icp_accel_dev_t **pAccel_devs);
75 /*
76  * icp_amgr_getAccelDevByName
77  *
78  * Description:
79  * Returns the accel instance by name.
80  *
81  * Returns:
82  *   CPA_STATUS_SUCCESS   on success
83  *   CPA_STATUS_FAIL      on failure
84  */
85 CpaStatus icp_amgr_getAccelDevByName(unsigned char *instanceName,
86 				     icp_accel_dev_t **pAccel_dev);
87 /*
88  * icp_amgr_getAccelDevByCapabilities
89  *
90  * Description:
91  * Returns a started accel device that implements the capabilities
92  * specified in capabilitiesMask.
93  *
94  * Returns:
95  *   CPA_STATUS_SUCCESS   on success
96  *   CPA_STATUS_FAIL      on failure
97  */
98 CpaStatus icp_amgr_getAccelDevByCapabilities(Cpa32U capabilitiesMask,
99 					     icp_accel_dev_t **pAccel_devs,
100 					     Cpa16U *pNumInstances);
101 /*
102  * icp_amgr_getAllAccelDevByCapabilities
103  *
104  * Description:
105  * Returns table of accel devices that are started and implement
106  * the capabilities specified in capabilitiesMask.
107  *
108  * Returns:
109  *   CPA_STATUS_SUCCESS   on success
110  *   CPA_STATUS_FAIL      on failure
111  */
112 CpaStatus icp_amgr_getAllAccelDevByCapabilities(Cpa32U capabilitiesMask,
113 						icp_accel_dev_t **pAccel_devs,
114 						Cpa16U *pNumInstances);
115 
116 /*
117  * icp_amgr_getAccelDevCapabilities
118  * Returns accel devices capabilities specified in capabilitiesMask.
119  *
120  * Returns:
121  *   CPA_STATUS_SUCCESS   on success
122  *   CPA_STATUS_FAIL      on failure
123  */
124 CpaStatus icp_amgr_getAccelDevCapabilities(icp_accel_dev_t *accel_dev,
125 					   Cpa32U *pCapabilitiesMask);
126 
127 /*
128  * icp_amgr_getAllAccelDevByEachCapability
129  *
130  * Description:
131  * Returns table of accel devices that are started and implement
132  * each of the capability specified in capabilitiesMask.
133  *
134  * Returns:
135  *   CPA_STATUS_SUCCESS   on success
136  *   CPA_STATUS_FAIL      on failure
137  */
138 CpaStatus icp_amgr_getAllAccelDevByEachCapability(Cpa32U capabilitiesMask,
139 						  icp_accel_dev_t **pAccel_devs,
140 						  Cpa16U *pNumInstances);
141 
142 /*
143  * icp_qa_dev_get
144  *
145  * Description:
146  * Function increments the device usage counter.
147  *
148  * Returns: void
149  */
150 void icp_qa_dev_get(icp_accel_dev_t *pDev);
151 
152 /*
153  * icp_qa_dev_put
154  *
155  * Description:
156  * Function decrements the device usage counter.
157  *
158  * Returns: void
159  */
160 void icp_qa_dev_put(icp_accel_dev_t *pDev);
161 
162 /*
163  * icp_adf_getAccelDevByAccelId
164  *
165  * Description:
166  * Gets the accel_dev structure based on accelId
167  *
168  * Returns: a pointer to the accelerator structure or NULL if not found.
169  */
170 icp_accel_dev_t *icp_adf_getAccelDevByAccelId(Cpa32U accelId);
171 
172 #endif /* ICP_ADF_ACCEL_MGR_H */
173