1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 /*****************************************************************************
5 * @file icp_adf_init.h
6 *
7 * @description
8 * This file contains the function prototype used to register a subsystem
9 * into the Acceleration Driver Framework (ADF).
10 *
11 *****************************************************************************/
12 #ifndef ICP_ADF_INIT_H
13 #define ICP_ADF_INIT_H
14
15 #include "icp_accel_devices.h"
16 #include "adf_kernel_types.h"
17 #include "adf_cfg_common.h"
18
19 /*
20 * Events that will be sending to subsystem. The order of the enum
21 * declaration matters. It should be defined so that the messages can be
22 * sent in loop.
23 */
24 typedef enum icp_adf_subsystemEvent_s {
25 ICP_ADF_EVENT_INIT = 0,
26 ICP_ADF_EVENT_START,
27 ICP_ADF_EVENT_STOP,
28 ICP_ADF_EVENT_SHUTDOWN,
29 ICP_ADF_EVENT_RESTARING,
30 ICP_ADF_EVENT_RESTARTED,
31 ICP_ADF_EVENT_ERROR,
32 ICP_ADF_EVENT_END
33 } icp_adf_subsystemEvent_t;
34
35 /*
36 * Ring info operation used to enable or disable ring polling by ME
37 */
38 typedef enum icp_adf_ringInfoOperation_e {
39 ICP_ADF_RING_ENABLE = 0,
40 ICP_ADF_RING_DISABLE
41 } icp_adf_ringInfoOperation_t;
42
43 /*
44 * Ring generic serivce info private data
45 */
46 typedef enum icp_adf_ringInfoService_e {
47 ICP_ADF_RING_SERVICE_0 = 0,
48 ICP_ADF_RING_SERVICE_1,
49 ICP_ADF_RING_SERVICE_2,
50 ICP_ADF_RING_SERVICE_3,
51 ICP_ADF_RING_SERVICE_4,
52 ICP_ADF_RING_SERVICE_5,
53 ICP_ADF_RING_SERVICE_6,
54 ICP_ADF_RING_SERVICE_7,
55 ICP_ADF_RING_SERVICE_8,
56 ICP_ADF_RING_SERVICE_9,
57 ICP_ADF_RING_SERVICE_10,
58 } icp_adf_ringInfoService_t;
59
60 /*
61 * Ring info callback. Function is used to send operation and ring info
62 * to enable or disable ring polling by ME
63 */
64 typedef CpaStatus (*ringInfoCb)(icp_accel_dev_t *accel_dev,
65 Cpa32U ringNumber,
66 icp_adf_ringInfoOperation_t operation,
67 icp_adf_ringInfoService_t info);
68
69 /*
70 * Registration handle structure
71 * Each subservice has to have an instance of it.
72 */
73 typedef struct subservice_registation_handle_s {
74 CpaStatus (*subserviceEventHandler)(icp_accel_dev_t *accel_dev,
75 icp_adf_subsystemEvent_t event,
76 void *param);
77 struct {
78 Cpa32U subsystemInitBit : 1;
79 Cpa32U subsystemStartBit : 1;
80 Cpa32U subsystemFailedBit : 1;
81 } subsystemStatus[ADF_MAX_DEVICES];
82 char *subsystem_name;
83 struct subservice_registation_handle_s *pNext;
84 struct subservice_registation_handle_s *pPrev;
85 } subservice_registation_handle_t;
86
87 /*
88 * icp_adf_subsystemRegister
89 *
90 * Description:
91 * Function used by subsystem to register within ADF
92 * Should be called during insertion of a subsystem
93 *
94 * Returns:
95 * CPA_STATUS_SUCCESS on success
96 * CPA_STATUS_FAIL on failure
97 */
98 CpaStatus icp_adf_subsystemRegister(subservice_registation_handle_t *handle);
99
100 /*
101 * icp_adf_subsystemUnregister
102 *
103 * Description:
104 * Function used by subsystem to unregister from ADF
105 * Should be called while subsystem in removed
106 * If the subsystem is initialised and/or started
107 * it will be stopped and shutdown by this function
108 *
109 * Returns:
110 * CPA_STATUS_SUCCESS on success
111 * CPA_STATUS_FAIL on failure
112 */
113 CpaStatus icp_adf_subsystemUnregister(subservice_registation_handle_t *handle);
114
115 /*
116 * icp_adf_accesLayerRingInfoCbRegister
117 *
118 * Description:
119 * Function register access layer callback, which sends ring info message
120 *
121 * Returns:
122 * CPA_STATUS_SUCCESS on success
123 * CPA_STATUS_FAIL on failure
124 */
125 CpaStatus icp_adf_accesLayerRingInfoCbRegister(icp_accel_dev_t *accel_dev,
126 ringInfoCb);
127
128 /*
129 * icp_adf_accesLayerRingInfoCbUnregister
130 *
131 * Description:
132 * Function unregister access layer callback for ring info message
133 *
134 * Returns:
135 * CPA_STATUS_SUCCESS on success
136 * CPA_STATUS_FAIL on failure
137 */
138 void icp_adf_accesLayerRingInfoCbUnregister(icp_accel_dev_t *accel_dev);
139
140 /*
141 * icp_adf_isSubsystemStarted
142 *
143 * Description:
144 * Function returns true if the service is started on a device
145 *
146 * Returns:
147 * CPA_TRUE if subsystem is started
148 * CPA_FALSE if subsystem is not started
149 */
150
151 CpaBoolean
152 icp_adf_isSubsystemStarted(subservice_registation_handle_t *subsystem_hdl);
153
154 /*
155 * icp_adf_isDevStarted
156 *
157 * Description:
158 * Function returns true if the device is started
159 * Returns:
160 * CPA_TRUE if dev is started
161 * CPA_FALSE if dev is not started
162 */
163 CpaBoolean icp_adf_isDevStarted(icp_accel_dev_t *accel_dev);
164
165 /*
166 * adf_subsystemRestarting
167 *
168 * Description:
169 * Function sends restarting event to all subsystems.
170 * This function should be used by error handling function only
171 *
172 * Returns:
173 * CPA_TRUE on success
174 * CPA_FALSE on failure
175 */
176 CpaStatus adf_subsystemRestarting(icp_accel_dev_t *accel_dev);
177
178 /*
179 * adf_subsystemRestarted
180 *
181 * Description:
182 * Function sends restarted event to all subsystems.
183 * This function should be used by error handling function only
184 *
185 * Returns:
186 * CPA_TRUE on success
187 * CPA_FALSE on failure
188 */
189 CpaStatus adf_subsystemRestarted(icp_accel_dev_t *accel_dev);
190
191 /*
192 * adf_subsystemError
193 *
194 * Description:
195 * Function sends error event to all subsystems.
196 * This function should be used by error handling funct. only
197 *
198 * Returns:
199 * CPA_STATUS_SUCCESS on success
200 * CPA_STATUS_FAIL on failure
201 */
202 CpaStatus adf_subsystemError(icp_accel_dev_t *accel_dev);
203
204 /*
205 * reset_adf_subsystemTable
206 *
207 * Description:
208 * Function to reset subsystem table head, the pointer
209 * to the head of the list and lock.
210 *
211 * Returns: void
212 */
213 void reset_adf_subsystemTable(void);
214
215 #endif /* ICP_ADF_INIT_H */
Cache object: c6f63de5c6570a45d2447c957f24bae5
|