1 /*
2  * Copyright (c) 2016-2018,2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: This file provides various init/deinit trigger point for new
22  * components.
23  */
24 
25 #if !defined(__DISPATCHER_INIT_H)
26 #define __DISPATCHER_INIT_H
27 
28 #include <qdf_types.h>
29 #include <wlan_objmgr_cmn.h>
30 #include <wlan_objmgr_psoc_obj.h>
31 #include <wlan_objmgr_global_obj.h>
32 
33 /**
34  * struct dispatcher_spectral_ops - Spectral ops table
35  * @spectral_pdev_open_handler: Spectral pdev open handler
36  * @spectral_psoc_open_handler: Spectral psoc open handler
37  * @spectral_psoc_close_handler: Spectral psoc close handler
38  * @spectral_psoc_enable_handler: Spectral psoc enable handler
39  * @spectral_psoc_disable_handler: Spectral psoc disable handler
40  */
41 struct dispatcher_spectral_ops {
42 	QDF_STATUS(*spectral_pdev_open_handler)(struct wlan_objmgr_pdev *pdev);
43 	QDF_STATUS(*spectral_psoc_open_handler)(
44 					struct wlan_objmgr_psoc *psoc);
45 	QDF_STATUS(*spectral_psoc_close_handler)(
46 					struct wlan_objmgr_psoc *psoc);
47 	QDF_STATUS(*spectral_psoc_enable_handler)(
48 					struct wlan_objmgr_psoc *psoc);
49 	QDF_STATUS(*spectral_psoc_disable_handler)(
50 					struct wlan_objmgr_psoc *psoc);
51 };
52 
53 /**
54  * dispatcher_init(): API to init all new components
55  *
56  * This API calls all new components init APIs. This is invoked
57  * from HDD/OS_If layer during:
58  * 1) Driver load sequence
59  * 2) before probing the attached device.
60  * 3) FW is not ready
61  * 4) WMI channel is not established
62  *
63  * A component can't communicate with FW during init stage.
64  *
65  * Return: none
66  */
67 QDF_STATUS dispatcher_init(void);
68 
69 /**
70  * dispatcher_deinit(): API to de-init all new components
71  *
72  * This API calls all new components de-init APIs. This is invoked
73  * from HDD/OS_If layer during:
74  * 1) Driver unload sequence
75  * 2) FW is dead
76  * 3) WMI channel is destroyed
77  * 4) all PDEV and PSOC objects are destroyed
78  *
79  * A component can't communicate with FW during de-init stage.
80  *
81  * Return: none
82  */
83 QDF_STATUS dispatcher_deinit(void);
84 
85 /**
86  * dispatcher_enable(): global (above psoc) level component start
87  *
88  * Prepare components to service requests. Must only be called after
89  * dispatcher_init().
90  *
91  * Return: QDF_STATUS
92  */
93 QDF_STATUS dispatcher_enable(void);
94 
95 /**
96  * dispatcher_disable(): global (above psoc) level component stop
97  *
98  * Stop components from servicing requests. Must be called before
99  * scheduler_deinit().
100  *
101  * Return: QDF_STATUS
102  */
103 QDF_STATUS dispatcher_disable(void);
104 
105 /**
106  * dispatcher_psoc_open(): API to trigger PSOC open for all new components
107  * @psoc: psoc context
108  *
109  * This API calls all new components PSOC OPEN APIs. This is invoked from
110  * HDD/OS_If layer during:
111  * 1) Driver load sequence
112  * 2) PSOC object is created
113  * 3) FW is not yet ready
114  * 4) WMI channel is not yet established with FW
115  *
116  * PSOC open happens before FW WMI ready and hence a component can't
117  * communicate with FW during PSOC open sequence.
118  *
119  * Return: none
120  */
121 QDF_STATUS dispatcher_psoc_open(struct wlan_objmgr_psoc *psoc);
122 
123 /**
124  * dispatcher_psoc_close(): API to trigger PSOC close for all new components
125  * @psoc: psoc context
126  *
127  * This API calls all new components PSOC CLOSE APIs. This is invoked from
128  * HDD/OS_If layer during:
129  * 1) Driver unload sequence
130  * 2) PSOC object is destroyed
131  * 3) FW is already dead(PDEV suspended)
132  * 4) WMI channel is destroyed with FW
133  *
134  * A component can't communicate with FW during PSOC close.
135  *
136  * Return: none
137  */
138 QDF_STATUS dispatcher_psoc_close(struct wlan_objmgr_psoc *psoc);
139 
140 /**
141  * dispatcher_psoc_enable(): API to trigger PSOC enable(start) for all new
142  *                           components
143  * @psoc: psoc context
144  *
145  * This API calls all new components PSOC enable(start) APIs. This is invoked
146  * from HDD/OS_If layer during:
147  * 1) Driver load sequence
148  * 2) PSOC object is created
149  * 3) WMI endpoint and WMI channel is ready with FW
150  * 4) WMI FW ready event is also received from FW.
151  *
152  * FW is already ready and WMI channel is established by this time so a
153  * component can communicate with FW during PSOC enable sequence.
154  *
155  * Return: none
156  */
157 QDF_STATUS dispatcher_psoc_enable(struct wlan_objmgr_psoc *psoc);
158 
159 /**
160  * dispatcher_psoc_disable(): API to trigger PSOC disable(stop) for all new
161  *                            components
162  * @psoc: psoc context
163  *
164  * This API calls all new components PSOC disable(stop) APIs. This is invoked
165  * from HDD/OS_If layer during:
166  * 1) Driver unload sequence
167  * 2) WMI channel is still available
168  * 3) FW is still running and up
169  * 4) PSOC object is not destroyed
170  *
171  * A component should abort all its ongign transaction with FW at this stage
172  * for example scan component needs to abort all its ongoing scan in FW because
173  * is going to be stopped very soon.
174  *
175  * Return: none
176  */
177 QDF_STATUS dispatcher_psoc_disable(struct wlan_objmgr_psoc *psoc);
178 
179 /**
180  * dispatcher_pdev_open(): API to trigger PDEV open for all new components
181  * @pdev: pdev context
182  *
183  * This API calls all new components PDEV OPEN APIs. This is invoked from
184  * during PDEV object is created.
185  *
186  * Return: none
187  */
188 QDF_STATUS dispatcher_pdev_open(struct wlan_objmgr_pdev *pdev);
189 
190 /**
191  * dispatcher_pdev_close(): API to trigger PDEV close for all new components
192  * @pdev: pdev context
193  *
194  * This API calls all new components PDEV CLOSE APIs. This is invoked from
195  * during driver unload sequence.
196  *
197  * Return: none
198  */
199 QDF_STATUS dispatcher_pdev_close(struct wlan_objmgr_pdev *pdev);
200 
201 /**
202  * dispatcher_register_spectral_ops_handler(): API to register spectral
203  * operations
204  * @sops: pointer to Spectral ops table
205  *
206  * This API registers spectral pdev open handler, psoc enable handler and
207  * psoc disable handler, psoc open handler and psoc close handler.
208  *
209  * Return: QDF_STATUS
210  */
211 QDF_STATUS
212 dispatcher_register_spectral_ops_handler(struct dispatcher_spectral_ops *sops);
213 #endif /* End of  !defined(__DISPATCHER_INIT_H) */
214