1 /*
2 * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-2024 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 * DOC: declare utility API related to the pmo component
21 * called by other components
22 */
23
24 #ifndef _WLAN_PMO_OBJ_MGMT_API_H_
25 #define _WLAN_PMO_OBJ_MGMT_API_H_
26
27 #include "wlan_pmo_common_public_struct.h"
28 #include "wlan_pmo_obj_mgmt_public_struct.h"
29
30 #ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
31 /**
32 * pmo_init() - initialize pmo_ctx context.
33 *
34 * This function initializes the power manager offloads (a.k.a pmo) context.
35 *
36 * Return: QDF_STATUS_SUCCESS - in case of success else return error
37 */
38 QDF_STATUS pmo_init(void);
39
40 /**
41 * pmo_deinit() - De initialize pmo_ctx context.
42 *
43 * This function De initializes power manager offloads (a.k.a pmo) context.
44 *
45 * Return: QDF_STATUS_SUCCESS - in case of success else return error
46 */
47 QDF_STATUS pmo_deinit(void);
48
49 /**
50 * pmo_psoc_object_created_notification(): pmo psoc create handler
51 * @psoc: psoc which is going to created by objmgr
52 * @arg: argument for vdev create handler
53 *
54 * PMO, register this api with objmgr to detect psoc is created in fwr
55 *
56 * Return QDF_STATUS status in case of success else return error
57 */
58 QDF_STATUS pmo_psoc_object_created_notification(struct wlan_objmgr_psoc *psoc,
59 void *arg);
60
61 /**
62 * pmo_psoc_object_destroyed_notification(): pmo psoc delete handler
63 * @psoc: psoc which is going to delete by objmgr
64 * @arg: argument for vdev delete handler
65 *
66 * PMO, register this api with objmgr to detect psoc is deleted in fwr
67 *
68 * Return QDF_STATUS status in case of success else return error
69 */
70 QDF_STATUS pmo_psoc_object_destroyed_notification(struct wlan_objmgr_psoc *psoc,
71 void *arg);
72
73 /**
74 * pmo_vdev_object_created_notification(): pmo vdev create handler
75 * @vdev: vdev which is going to created by objmgr
76 * @arg: argument for vdev create handler
77 *
78 * PMO, register this api with objmgr to detect vdev is created in fwr
79 *
80 * Return QDF_STATUS status in case of success else return error
81 */
82 QDF_STATUS pmo_vdev_object_created_notification(struct wlan_objmgr_vdev *vdev,
83 void *arg);
84
85 /**
86 * pmo_vdev_ready() - handles vdev ready in firmware event
87 * @vdev: vdev which is ready in firmware
88 * @bridgeaddr: Bridge MAC address
89 *
90 * Objmgr vdev_create event does not guarantee vdev creation in firmware.
91 * Any logic that would normally go in the vdev_create event, but needs to
92 * communicate with firmware, needs to go here instead.
93 *
94 * Return QDF_STATUS
95 */
96 QDF_STATUS pmo_vdev_ready(struct wlan_objmgr_vdev *vdev,
97 struct qdf_mac_addr *bridgeaddr);
98
99 /**
100 * pmo_vdev_object_destroyed_notification(): pmo vdev delete handler
101 * @vdev: vdev which is going to delete by objmgr
102 * @arg: argument for vdev delete handler
103 *
104 * PMO, register this api with objmgr to detect vdev is deleted in fwr
105 *
106 * Return QDF_STATUS status in case of success else return error
107 */
108 QDF_STATUS pmo_vdev_object_destroyed_notification(struct wlan_objmgr_vdev *vdev,
109 void *arg);
110
111 /**
112 * pmo_register_suspend_handler(): register suspend handler for components
113 * @id: component id
114 * @handler: resume handler for the mention component
115 * @arg: argument to pass while calling resume handler
116 *
117 * Return QDF_STATUS status -in case of success else return error
118 */
119 QDF_STATUS pmo_register_suspend_handler(enum wlan_umac_comp_id id,
120 pmo_psoc_suspend_handler handler,
121 void *arg);
122
123 /**
124 * pmo_unregister_suspend_handler():unregister suspend handler for components
125 * @id: component id
126 * @handler: resume handler for the mention component
127 *
128 * Return QDF_STATUS status -in case of success else return error
129 */
130 QDF_STATUS pmo_unregister_suspend_handler(enum wlan_umac_comp_id id,
131 pmo_psoc_suspend_handler handler);
132
133 /**
134 * pmo_register_resume_handler(): API to register resume handler for components
135 * @id: component id
136 * @handler: resume handler for the mention component
137 * @arg: argument to pass while calling resume handler
138 *
139 * Return QDF_STATUS status - in case of success else return error
140 */
141 QDF_STATUS pmo_register_resume_handler(enum wlan_umac_comp_id id,
142 pmo_psoc_resume_handler handler,
143 void *arg);
144
145 /**
146 * pmo_unregister_resume_handler(): unregister resume handler for components
147 * @id: component id
148 * @handler: resume handler for the mention component
149 *
150 * Return QDF_STATUS status - in case of success else return error
151 */
152 QDF_STATUS pmo_unregister_resume_handler(enum wlan_umac_comp_id id,
153 pmo_psoc_resume_handler handler);
154
155 /**
156 * pmo_suspend_all_components(): API to suspend all component
157 * @psoc:objmgr psoc
158 * @suspend_type: Tell suspend type (apps suspend / runtime suspend)
159 *
160 * Return QDF_STATUS status - in case of success else return error
161 */
162 QDF_STATUS pmo_suspend_all_components(struct wlan_objmgr_psoc *psoc,
163 enum qdf_suspend_type suspend_type);
164
165 /**
166 * pmo_resume_all_components(): API to resume all component
167 * @psoc:objmgr psoc
168 * @suspend_type: Tell suspend type from which resume is required
169 *
170 * Return QDF_STATUS status - in case of success else return error
171 */
172 QDF_STATUS pmo_resume_all_components(struct wlan_objmgr_psoc *psoc,
173 enum qdf_suspend_type suspend_type);
174
175 /**
176 * pmo_register_pause_bitmap_notifier(): API to register pause bitmap notifier
177 * @psoc: objmgr psoc handle
178 * @handler: pause bitmap updated notifier
179 *
180 * Return QDF_STATUS status - in case of success else return error
181 */
182 QDF_STATUS pmo_register_pause_bitmap_notifier(struct wlan_objmgr_psoc *psoc,
183 pmo_notify_pause_bitmap handler);
184
185 /**
186 * pmo_unregister_pause_bitmap_notifier(): API to unregister pause bitmap
187 * notifier
188 * @psoc: objmgr psoc handle
189 *
190 * Return QDF_STATUS status - in case of success else return error
191 */
192 QDF_STATUS pmo_unregister_pause_bitmap_notifier(struct wlan_objmgr_psoc *psoc);
193
194 /**
195 * pmo_register_get_pause_bitmap(): API to get register pause bitmap notifier
196 * @psoc: objmgr psoc handle
197 * @handler: pause bitmap updated notifier
198 *
199 * Return QDF_STATUS status - in case of success else return error
200 */
201 QDF_STATUS pmo_register_get_pause_bitmap(struct wlan_objmgr_psoc *psoc,
202 pmo_get_pause_bitmap handler);
203
204 /**
205 * pmo_unregister_get_pause_bitmap(): API to unregister get pause bitmap
206 * callback
207 * @psoc: objmgr psoc handle
208 *
209 * Return QDF_STATUS status - in case of success else return error
210 */
211 QDF_STATUS pmo_unregister_get_pause_bitmap(struct wlan_objmgr_psoc *psoc);
212
213 /**
214 * pmo_register_get_dtim_period_callback(): API to register callback that gets
215 * dtim period from mlme
216 * @psoc: objmgr psoc handle
217 * @handler: pointer to the callback function
218 *
219 * Return: QDF_STATUS_SUCCESS in case of success else error
220 */
221 QDF_STATUS pmo_register_get_dtim_period_callback(struct wlan_objmgr_psoc *psoc,
222 pmo_get_dtim_period handler);
223
224 /**
225 * pmo_unregister_get_dtim_period_callback(): API to unregister callback that
226 * gets dtim period from mlme
227 * @psoc: objmgr psoc handle
228 *
229 * Return: QDF_STATUS_SUCCESS in case of success else error
230 */
231 QDF_STATUS
232 pmo_unregister_get_dtim_period_callback(struct wlan_objmgr_psoc *psoc);
233
234 /**
235 * pmo_register_get_beacon_interval_callback(): API to register callback that
236 * gets beacon interval from mlme
237 * @psoc: objmgr psoc handle
238 * @handler: pointer to the callback function
239 *
240 * Return: QDF_STATUS_SUCCESS in case of success else error
241 */
242 QDF_STATUS
243 pmo_register_get_beacon_interval_callback(struct wlan_objmgr_psoc *psoc,
244 pmo_get_beacon_interval handler);
245
246 /**
247 * pmo_unregister_get_beacon_interval_callback(): API to unregister callback
248 * that gets beacon interval from mlme
249 * @psoc: objmgr psoc handle
250 *
251 * Return: QDF_STATUS_SUCCESS in case of success else error
252 */
253 QDF_STATUS
254 pmo_unregister_get_beacon_interval_callback(struct wlan_objmgr_psoc *psoc);
255
256 /**
257 * pmo_register_is_device_in_low_pwr_mode(): API to get register device power
258 * save check notifier.
259 * @psoc: objmgr psoc handle
260 * @handler: device power save check notifier
261 *
262 * Return QDF_STATUS status - in case of success else return error
263 */
264 QDF_STATUS pmo_register_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc *psoc,
265 pmo_is_device_in_low_pwr_mode handler);
266
267 /**
268 * pmo_unregister_is_device_in_low_pwr_mode(): API to unregister device power
269 * save check notifier.
270 * @psoc: objmgr psoc handle
271 *
272 * Return QDF_STATUS status - in case of success else return error
273 */
274 QDF_STATUS
275 pmo_unregister_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc *psoc);
276
277 /**
278 * wlan_pmo_get_sap_mode_bus_suspend(): API to get SAP bus suspend config
279 * @psoc: objmgr psoc handle
280 *
281 * Return true in case of peer connected SAP bus suspend is allowed
282 * else return false
283 */
284 bool
285 wlan_pmo_get_sap_mode_bus_suspend(struct wlan_objmgr_psoc *psoc);
286
287 /**
288 * wlan_pmo_get_go_mode_bus_suspend(): API to get GO bus suspend config
289 * @psoc: objmgr psoc handle
290 *
291 * Return true in case of peer connected GO bus suspend is allowed
292 * else return false
293 */
294 bool
295 wlan_pmo_get_go_mode_bus_suspend(struct wlan_objmgr_psoc *psoc);
296
297 /*
298 * wlan_pmo_no_op_on_page_fault() - Whether to ignore page fault wakeups
299 * @psoc: PSOC object manager
300 *
301 * Return: true if host has to ignore page fault wakeup events else false.
302 */
303 bool wlan_pmo_no_op_on_page_fault(struct wlan_objmgr_psoc *psoc);
304
305 /*
306 * wlan_pmo_enable_ssr_on_page_fault: Enable/disable ssr on pagefault
307 * @psoc: objmgr psoc
308 *
309 * Return: True if SSR is enabled on pagefault
310 */
311 bool wlan_pmo_enable_ssr_on_page_fault(struct wlan_objmgr_psoc *psoc);
312
313 /*
314 * wlan_pmo_get_min_pagefault_wakeups_for_action() - get min pagefault wakeups
315 * for host to initiate action
316 * @psoc: objmgr psoc
317 *
318 * Return: Min pagefault wakeups for action
319 */
320 uint8_t
321 wlan_pmo_get_min_pagefault_wakeups_for_action(struct wlan_objmgr_psoc *psoc);
322
323 /*
324 * wlan_pmo_get_interval_for_pagefault_wakeup_counts: get ssr interval for
325 * pagefault
326 * @psoc: objmgr psoc
327 *
328 * Return: SSR interval for pagefault
329 */
330 uint32_t
331 wlan_pmo_get_interval_for_pagefault_wakeup_counts(
332 struct wlan_objmgr_psoc *psoc);
333
334 QDF_STATUS wlan_pmo_get_listen_interval(struct wlan_objmgr_vdev *vdev,
335 uint32_t *listen_interval);
336
337 /**
338 * wlan_pmo_set_ps_params() - Set vdev OPM params
339 * @vdev: pointer to vdev object
340 * @ps_params: pointer to OPM params
341 *
342 * Return: None
343 */
344 void wlan_pmo_set_ps_params(struct wlan_objmgr_vdev *vdev,
345 struct pmo_ps_params *ps_params);
346
347 /**
348 * wlan_pmo_get_ps_params() - Get vdev OPM params
349 * @vdev: pointer to vdev object
350 * @ps_params: Pointer to get OPM params
351 *
352 * Return: QDF Status
353 */
354 QDF_STATUS wlan_pmo_get_ps_params(struct wlan_objmgr_vdev *vdev,
355 struct pmo_ps_params *ps_params);
356
357 #else /* WLAN_POWER_MANAGEMENT_OFFLOAD */
358
pmo_init(void)359 static inline QDF_STATUS pmo_init(void)
360 {
361 return QDF_STATUS_SUCCESS;
362 }
363
pmo_deinit(void)364 static inline QDF_STATUS pmo_deinit(void)
365 {
366 return QDF_STATUS_SUCCESS;
367 }
368
369 static inline QDF_STATUS
pmo_psoc_object_created_notification(struct wlan_objmgr_psoc * psoc,void * arg)370 pmo_psoc_object_created_notification(struct wlan_objmgr_psoc *psoc, void *arg)
371 {
372 return QDF_STATUS_SUCCESS;
373 }
374
375 static inline QDF_STATUS
pmo_psoc_object_destroyed_notification(struct wlan_objmgr_psoc * psoc,void * arg)376 pmo_psoc_object_destroyed_notification(struct wlan_objmgr_psoc *psoc, void *arg)
377 {
378 return QDF_STATUS_SUCCESS;
379 }
380
381 static inline QDF_STATUS
pmo_vdev_object_created_notification(struct wlan_objmgr_vdev * vdev,void * arg)382 pmo_vdev_object_created_notification(struct wlan_objmgr_vdev *vdev, void *arg)
383 {
384 return QDF_STATUS_SUCCESS;
385 }
386
387 static inline QDF_STATUS
pmo_vdev_ready(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * bridgeaddr)388 pmo_vdev_ready(struct wlan_objmgr_vdev *vdev, struct qdf_mac_addr *bridgeaddr)
389 {
390 return QDF_STATUS_SUCCESS;
391 }
392
393 static inline QDF_STATUS
pmo_vdev_object_destroyed_notification(struct wlan_objmgr_vdev * vdev,void * arg)394 pmo_vdev_object_destroyed_notification(struct wlan_objmgr_vdev *vdev, void *arg)
395 {
396 return QDF_STATUS_SUCCESS;
397 }
398
399 static inline QDF_STATUS
pmo_register_suspend_handler(enum wlan_umac_comp_id id,pmo_psoc_suspend_handler handler,void * arg)400 pmo_register_suspend_handler(enum wlan_umac_comp_id id,
401 pmo_psoc_suspend_handler handler,
402 void *arg)
403 {
404 return QDF_STATUS_SUCCESS;
405 }
406
407 static inline QDF_STATUS
pmo_unregister_suspend_handler(enum wlan_umac_comp_id id,pmo_psoc_suspend_handler handler)408 pmo_unregister_suspend_handler(enum wlan_umac_comp_id id,
409 pmo_psoc_suspend_handler handler)
410 {
411 return QDF_STATUS_SUCCESS;
412 }
413
414 static inline QDF_STATUS
pmo_register_resume_handler(enum wlan_umac_comp_id id,pmo_psoc_resume_handler handler,void * arg)415 pmo_register_resume_handler(enum wlan_umac_comp_id id,
416 pmo_psoc_resume_handler handler,
417 void *arg)
418 {
419 return QDF_STATUS_SUCCESS;
420 }
421
422 static inline QDF_STATUS
pmo_unregister_resume_handler(enum wlan_umac_comp_id id,pmo_psoc_resume_handler handler)423 pmo_unregister_resume_handler(enum wlan_umac_comp_id id,
424 pmo_psoc_resume_handler handler)
425 {
426 return QDF_STATUS_SUCCESS;
427 }
428
429 static inline QDF_STATUS
pmo_suspend_all_components(struct wlan_objmgr_psoc * psoc,enum qdf_suspend_type suspend_type)430 pmo_suspend_all_components(struct wlan_objmgr_psoc *psoc,
431 enum qdf_suspend_type suspend_type)
432 {
433 return QDF_STATUS_SUCCESS;
434 }
435
436 static inline QDF_STATUS
pmo_resume_all_components(struct wlan_objmgr_psoc * psoc,enum qdf_suspend_type suspend_type)437 pmo_resume_all_components(struct wlan_objmgr_psoc *psoc,
438 enum qdf_suspend_type suspend_type)
439 {
440 return QDF_STATUS_SUCCESS;
441 }
442
443 static inline QDF_STATUS
pmo_register_pause_bitmap_notifier(struct wlan_objmgr_psoc * psoc,pmo_notify_pause_bitmap handler)444 pmo_register_pause_bitmap_notifier(struct wlan_objmgr_psoc *psoc,
445 pmo_notify_pause_bitmap handler)
446 {
447 return QDF_STATUS_SUCCESS;
448 }
449
450 static inline QDF_STATUS
pmo_unregister_pause_bitmap_notifier(struct wlan_objmgr_psoc * psoc)451 pmo_unregister_pause_bitmap_notifier(struct wlan_objmgr_psoc *psoc)
452 {
453 return QDF_STATUS_SUCCESS;
454 }
455
456 static inline QDF_STATUS
pmo_register_get_pause_bitmap(struct wlan_objmgr_psoc * psoc,pmo_get_pause_bitmap handler)457 pmo_register_get_pause_bitmap(struct wlan_objmgr_psoc *psoc,
458 pmo_get_pause_bitmap handler)
459 {
460 return QDF_STATUS_SUCCESS;
461 }
462
463 static inline QDF_STATUS
pmo_unregister_get_pause_bitmap(struct wlan_objmgr_psoc * psoc)464 pmo_unregister_get_pause_bitmap(struct wlan_objmgr_psoc *psoc)
465 {
466 return QDF_STATUS_SUCCESS;
467 }
468
469 static inline QDF_STATUS
pmo_register_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc * psoc,pmo_is_device_in_low_pwr_mode handler)470 pmo_register_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc *psoc,
471 pmo_is_device_in_low_pwr_mode handler)
472 {
473 return QDF_STATUS_SUCCESS;
474 }
475
476 static inline QDF_STATUS
pmo_unregister_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc * psoc)477 pmo_unregister_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc *psoc)
478 {
479 return QDF_STATUS_SUCCESS;
480 }
481
482 static inline QDF_STATUS
pmo_register_get_dtim_period_callback(struct wlan_objmgr_psoc * psoc,pmo_get_dtim_period handler)483 pmo_register_get_dtim_period_callback(struct wlan_objmgr_psoc *psoc,
484 pmo_get_dtim_period handler)
485 {
486 return QDF_STATUS_SUCCESS;
487 }
488
489 static inline QDF_STATUS
pmo_unregister_get_dtim_period_callback(struct wlan_objmgr_psoc * psoc)490 pmo_unregister_get_dtim_period_callback(struct wlan_objmgr_psoc *psoc)
491 {
492 return QDF_STATUS_SUCCESS;
493 }
494
495 static inline QDF_STATUS
pmo_register_get_beacon_interval_callback(struct wlan_objmgr_psoc * psoc,pmo_get_beacon_interval handler)496 pmo_register_get_beacon_interval_callback(struct wlan_objmgr_psoc *psoc,
497 pmo_get_beacon_interval handler)
498 {
499 return QDF_STATUS_SUCCESS;
500 }
501
502 static inline QDF_STATUS
pmo_unregister_get_beacon_interval_callback(struct wlan_objmgr_psoc * psoc)503 pmo_unregister_get_beacon_interval_callback(struct wlan_objmgr_psoc *psoc)
504 {
505 return QDF_STATUS_SUCCESS;
506 }
507
508 static inline bool
wlan_pmo_get_sap_mode_bus_suspend(struct wlan_objmgr_psoc * psoc)509 wlan_pmo_get_sap_mode_bus_suspend(struct wlan_objmgr_psoc *psoc)
510 {
511 return false;
512 }
513
514 static inline bool
wlan_pmo_get_go_mode_bus_suspend(struct wlan_objmgr_psoc * psoc)515 wlan_pmo_get_go_mode_bus_suspend(struct wlan_objmgr_psoc *psoc)
516 {
517 return false;
518 }
519
wlan_pmo_no_op_on_page_fault(struct wlan_objmgr_psoc * psoc)520 static inline bool wlan_pmo_no_op_on_page_fault(struct wlan_objmgr_psoc *psoc)
521 {
522 return true;
523 }
524
525 static inline bool
wlan_pmo_enable_ssr_on_page_fault(struct wlan_objmgr_psoc * psoc)526 wlan_pmo_enable_ssr_on_page_fault(struct wlan_objmgr_psoc *psoc)
527 {
528 return false;
529 }
530
531 static inline uint8_t
wlan_pmo_get_min_pagefault_wakeups_for_action(struct wlan_objmgr_psoc * psoc)532 wlan_pmo_get_min_pagefault_wakeups_for_action(struct wlan_objmgr_psoc *psoc)
533 {
534 return 0;
535 }
536
537 static inline uint32_t
wlan_pmo_get_interval_for_pagefault_wakeup_counts(struct wlan_objmgr_psoc * psoc)538 wlan_pmo_get_interval_for_pagefault_wakeup_counts(struct wlan_objmgr_psoc *psoc)
539 {
540 return 0;
541 }
542
wlan_pmo_get_listen_interval(struct wlan_objmgr_vdev * vdev,uint32_t * listen_interval)543 static QDF_STATUS wlan_pmo_get_listen_interval(struct wlan_objmgr_vdev *vdev,
544 uint32_t *listen_interval)
545 {
546 return QDF_STATUS_SUCCESS;
547 }
548
549 static inline
wlan_pmo_set_ps_params(struct wlan_objmgr_vdev * vdev,struct pmo_ps_params * ps_params)550 void wlan_pmo_set_ps_params(struct wlan_objmgr_vdev *vdev,
551 struct pmo_ps_params *ps_params)
552 {
553 }
554
555 static inline QDF_STATUS
wlan_pmo_get_ps_params(struct wlan_objmgr_vdev * vdev,struct pmo_ps_params * ps_params)556 wlan_pmo_get_ps_params(struct wlan_objmgr_vdev *vdev,
557 struct pmo_ps_params *ps_params)
558 {
559 return QDF_STATUS_SUCCESS;
560 }
561 #endif /* WLAN_POWER_MANAGEMENT_OFFLOAD */
562
563 #endif /* end of _WLAN_PMO_OBJ_MGMT_API_H_ */
564