1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 /*****************************************************************************
5 * @file icp_adf_transport.h
6 *
7 * @description
8 * File contains Public API Definitions for ADF transport.
9 *
10 *****************************************************************************/
11 #ifndef ICP_ADF_TRANSPORT_H
12 #define ICP_ADF_TRANSPORT_H
13
14 #include "cpa.h"
15
16 /*
17 * Enumeration on Transport Types exposed
18 */
19 typedef enum icp_transport_type_e {
20 ICP_TRANS_TYPE_NONE = 0,
21 ICP_TRANS_TYPE_ETR,
22 ICP_TRANS_TYPE_DP_ETR,
23 ICP_TRANS_TYPE_ADMINREG,
24 ICP_TRANS_TYPE_DELIMIT
25 } icp_transport_type;
26
27 /*
28 * Enumeration on response delivery method
29 */
30 typedef enum icp_resp_deliv_method_e {
31 ICP_RESP_TYPE_NONE = 0,
32 ICP_RESP_TYPE_IRQ,
33 ICP_RESP_TYPE_POLL,
34 ICP_RESP_TYPE_DELIMIT
35 } icp_resp_deliv_method;
36
37 /*
38 * Unique identifier of a transport handle
39 */
40 typedef Cpa32U icp_trans_identifier;
41
42 /*
43 * Opaque Transport Handle
44 */
45 typedef void *icp_comms_trans_handle;
46
47 /*
48 * Function Pointer invoked when a set of messages is received for the given
49 * transport handle
50 */
51 typedef void (*icp_trans_callback)(void *pMsg);
52
53 /*
54 * icp_adf_getDynInstance
55 *
56 * Description:
57 * Get an available instance from dynamic instance pool
58 *
59 * Returns:
60 * CPA_STATUS_SUCCESS on success
61 * CPA_STATUS_FAIL on failure
62 *
63 */
64 CpaStatus icp_adf_getDynInstance(icp_accel_dev_t *accel_dev,
65 adf_service_type_t stype,
66 Cpa32U *pinstance_id);
67
68 /*
69 * icp_adf_putDynInstance
70 *
71 * Description:
72 * Put back an instance to dynamic instance pool
73 *
74 * Returns:
75 * CPA_STATUS_SUCCESS on success
76 * CPA_STATUS_FAIL on failure
77 *
78 */
79 CpaStatus icp_adf_putDynInstance(icp_accel_dev_t *accel_dev,
80 adf_service_type_t stype,
81 Cpa32U instance_id);
82
83 /*
84 * icp_adf_getNumAvailDynInstance
85 *
86 * Description:
87 * Get the number of the available dynamic instances
88 *
89 * Returns:
90 * CPA_STATUS_SUCCESS on success
91 * CPA_STATUS_FAIL on failure
92 *
93 */
94 CpaStatus icp_adf_getNumAvailDynInstance(icp_accel_dev_t *accel_dev,
95 adf_service_type_t stype,
96 Cpa32U *num);
97
98 /*
99 * icp_adf_transGetFdForHandle
100 *
101 * Description:
102 * Get a file descriptor for a particular transaction handle.
103 * If more than one transaction handler
104 * are ever present, this will need to be refactored to
105 * return the appropriate fd of the appropriate bank.
106 *
107 * Returns:
108 * CPA_STATUS_SUCCESS on success
109 * CPA_STATUS_FAIL on failure
110 *
111 *
112 */
113 CpaStatus icp_adf_transGetFdForHandle(icp_comms_trans_handle trans_hnd,
114 int *fd);
115
116 /*
117 * icp_adf_transCreateHandle
118 *
119 * Description:
120 * Create a transport handle
121 *
122 * Returns:
123 * CPA_STATUS_SUCCESS on success
124 * CPA_STATUS_FAIL on failure
125 *
126 * The message size is variable: requests can be 64 or 128 bytes, responses
127 * can be 16, 32 or 64 bytes.
128 * Supported num_msgs:
129 * 32, 64, 128, 256, 512, 1024, 2048 number of messages.
130 *
131 */
132 CpaStatus icp_adf_transCreateHandle(icp_accel_dev_t *accel_dev,
133 icp_transport_type trans_type,
134 const char *section,
135 const Cpa32U accel_nr,
136 const Cpa32U bank_nr,
137 const char *service_name,
138 const icp_adf_ringInfoService_t info,
139 icp_trans_callback callback,
140 icp_resp_deliv_method resp,
141 const Cpa32U num_msgs,
142 const Cpa32U msg_size,
143 icp_comms_trans_handle *trans_handle);
144
145 /*
146 * icp_adf_transReinitHandle
147 *
148 * Description:
149 * Reinitialize a transport handle
150 *
151 * Returns:
152 * CPA_STATUS_SUCCESS on success
153 * CPA_STATUS_FAIL on failure
154 *
155 * The message size is variable: requests can be 64 or 128 bytes, responses
156 * can be 16, 32 or 64 bytes.
157 * Supported num_msgs:
158 * 32, 64, 128, 256, 512, 1024, 2048 number of messages.
159 *
160 */
161 CpaStatus icp_adf_transReinitHandle(icp_accel_dev_t *accel_dev,
162 icp_transport_type trans_type,
163 const char *section,
164 const Cpa32U accel_nr,
165 const Cpa32U bank_nr,
166 const char *service_name,
167 const icp_adf_ringInfoService_t info,
168 icp_trans_callback callback,
169 icp_resp_deliv_method resp,
170 const Cpa32U num_msgs,
171 const Cpa32U msg_size,
172 icp_comms_trans_handle *trans_handle);
173
174 /*
175 * icp_adf_transGetHandle
176 *
177 * Description:
178 * Gets a pointer to a previously created transport handle
179 *
180 * Returns:
181 * CPA_STATUS_SUCCESS on success
182 * CPA_STATUS_FAIL on failure
183 *
184 */
185 CpaStatus icp_adf_transGetHandle(icp_accel_dev_t *accel_dev,
186 icp_transport_type trans_type,
187 const char *section,
188 const Cpa32U accel_nr,
189 const Cpa32U bank_nr,
190 const char *service_name,
191 icp_comms_trans_handle *trans_handle);
192
193 /*
194 * icp_adf_transReleaseHandle
195 *
196 * Description:
197 * Release a transport handle
198 *
199 * Returns:
200 * CPA_STATUS_SUCCESS on success
201 * CPA_STATUS_FAIL on failure
202 */
203 CpaStatus icp_adf_transReleaseHandle(icp_comms_trans_handle trans_handle);
204
205 /*
206 * icp_adf_transResetHandle
207 *
208 * Description:
209 * Reset a transport handle
210 *
211 * Returns:
212 * CPA_STATUS_SUCCESS on success
213 * CPA_STATUS_FAIL on failure
214 */
215 CpaStatus icp_adf_transResetHandle(icp_comms_trans_handle trans_handle);
216
217 /*
218 * icp_adf_transPutMsg
219 *
220 * Description:
221 * Put Message onto the transport handle
222 *
223 * Returns:
224 * CPA_STATUS_SUCCESS on success
225 * CPA_STATUS_FAIL on failure
226 */
227 CpaStatus icp_adf_transPutMsg(icp_comms_trans_handle trans_handle,
228 Cpa32U *inBufs,
229 Cpa32U bufLen);
230
231 /*
232 * icp_adf_getInflightRequests
233 *
234 * Description:
235 * Retrieve in flight requests from the transport handle.
236 *
237 * Returns:
238 * CPA_STATUS_SUCCESS on success
239 * CPA_STATUS_FAIL on failure
240 */
241 CpaStatus icp_adf_getInflightRequests(icp_comms_trans_handle trans_handle,
242 Cpa32U *maxInflightRequests,
243 Cpa32U *numInflightRequests);
244
245 /*
246 * icp_adf_transPutMsgSync
247 *
248 * Description:
249 * Put Message onto the transport handle and waits for a response.
250 * Note: Not all transports support method.
251 *
252 * Returns:
253 * CPA_STATUS_SUCCESS on success
254 * CPA_STATUS_FAIL on failure
255 */
256 CpaStatus icp_adf_transPutMsgSync(icp_comms_trans_handle trans_handle,
257 Cpa32U *inBuf,
258 Cpa32U *outBuf,
259 Cpa32U bufsLen);
260
261 /*
262 * icp_adf_transGetRingNum
263 *
264 * Description:
265 * Function Returns ring number of the given trans_handle
266 *
267 * Returns:
268 * CPA_STATUS_SUCCESS on success
269 * CPA_STATUS_FAIL on failure
270 */
271 CpaStatus icp_adf_transGetRingNum(icp_comms_trans_handle trans_handle,
272 Cpa32U *ringNum);
273
274 /*
275 * icp_adf_flush_requests
276 *
277 * Description:
278 * Function flushes the enqueued requests on the trans_handle
279 *
280 * Returns:
281 * CPA_STATUS_SUCCESS on success
282 * CPA_STATUS_FAIL on failure
283 */
284 CpaStatus icp_adf_flush_requests(icp_comms_trans_handle trans_handle);
285
286 #endif /* ICP_ADF_TRANSPORT_H */
Cache object: 921c29fcb318508d7824d45f2106f18f
|