xref: /wlan-driver/qca-wifi-host-cmn/target_if/mlme/psoc/inc/target_if_psoc_wake_lock.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 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: target_if_psoc_wake_lock.h
22  *
23  * This file provides declaration for wakelock APIs
24  */
25 
26 #ifndef __TARGET_IF_PSOC_WAKE_LOCK_H__
27 #define __TARGET_IF_PSOC_WAKE_LOCK_H__
28 
29 #include <wlan_objmgr_psoc_obj.h>
30 #include <qdf_lock.h>
31 
32 #ifdef FEATURE_VDEV_OPS_WAKELOCK
33 /**
34  *  struct psoc_mlme_wakelock - psoc wake lock sub structure
35  *  @start_wakelock: wakelock for vdev start
36  *  @stop_wakelock: wakelock for vdev stop
37  *  @delete_wakelock: wakelock for vdev delete
38  *  @wmi_cmd_rsp_runtime_lock: run time lock
39  *  @prevent_runtime_lock: run time lock
40  *  @roam_sync_runtime_lock: roam sync runtime lock
41  *  @is_link_up: flag to check link status
42  */
43 struct psoc_mlme_wakelock {
44 	qdf_wake_lock_t start_wakelock;
45 	qdf_wake_lock_t stop_wakelock;
46 	qdf_wake_lock_t delete_wakelock;
47 	qdf_runtime_lock_t wmi_cmd_rsp_runtime_lock;
48 	qdf_runtime_lock_t prevent_runtime_lock;
49 	qdf_runtime_lock_t roam_sync_runtime_lock;
50 	bool is_link_up;
51 };
52 #endif
53 
54 enum wakelock_mode {
55 	START_WAKELOCK,
56 	STOP_WAKELOCK,
57 	DELETE_WAKELOCK
58 };
59 
60 #ifdef FEATURE_VDEV_OPS_WAKELOCK
61 
62 /**
63  * target_if_wake_lock_init() - API to initialize wakelocks:
64  *                              start, stop and delete.
65  * @psoc: pointer to psoc
66  *
67  * This also initialize the runtime lock
68  *
69  * Return: None
70  */
71 void target_if_wake_lock_init(struct wlan_objmgr_psoc *psoc);
72 
73 /**
74  * target_if_wake_lock_deinit() - API to destroy wakelocks:
75  *                                start, stop and delete.
76  * @psoc: pointer to psoc
77  *
78  * This also destroy the runtime lock
79  *
80  * Return: None
81  */
82 void target_if_wake_lock_deinit(struct wlan_objmgr_psoc *psoc);
83 
84 /**
85  * target_if_wake_lock_timeout_acquire() - acquire the start wakelock
86  * @psoc: pointer to psoc
87  * @mode: wakelock mode
88  *
89  * This also acquires the target_if runtime pm lock.
90  *
91  * Return: Success/Failure
92  */
93 QDF_STATUS target_if_wake_lock_timeout_acquire(struct wlan_objmgr_psoc *psoc,
94 					       enum wakelock_mode mode);
95 /**
96  * target_if_wake_lock_timeout_release() - release the start wakelock
97  * @psoc: pointer to psoc
98  * @mode: wakelock mode
99  *
100  * This also release the target_if runtime pm lock.
101  *
102  * Return: Success/Failure
103  */
104 QDF_STATUS target_if_wake_lock_timeout_release(struct wlan_objmgr_psoc *psoc,
105 					       enum wakelock_mode mode);
106 
107 /**
108  * target_if_vdev_start_link_handler() - check for SAP mode and DFS freq
109  *						to handle link up/down
110  * @vdev: pointer to vdev
111  * @is_restart: flag to check if it is vdev restart
112  *
113  * Return: None
114  */
115 void target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev,
116 				       bool is_restart);
117 
118 /**
119  * target_if_vdev_stop_link_handler() - check for SAP mode to handle link
120  * @vdev: pointer to vdev
121  *
122  * Return: None
123  */
124 void target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev);
125 
126 /**
127  * target_if_prevent_pm_during_roam_sync() - prevent runtime PM during roam sync
128  * @psoc: pointer to psoc
129  *
130  * Return: None
131  */
132 void
133 target_if_prevent_pm_during_roam_sync(struct wlan_objmgr_psoc *psoc);
134 
135 /**
136  * target_if_allow_pm_after_roam_sync() - allow runtime PM after roam
137  * sync complete
138  * @psoc: pointer to psoc
139  *
140  * Return: None
141  */
142 void
143 target_if_allow_pm_after_roam_sync(struct wlan_objmgr_psoc *psoc);
144 
145 #else
target_if_wake_lock_init(struct wlan_objmgr_psoc * psoc)146 static inline void target_if_wake_lock_init(struct wlan_objmgr_psoc *psoc)
147 {
148 }
149 
target_if_wake_lock_deinit(struct wlan_objmgr_psoc * psoc)150 static inline void target_if_wake_lock_deinit(struct wlan_objmgr_psoc *psoc)
151 {
152 }
153 
target_if_wake_lock_timeout_acquire(struct wlan_objmgr_psoc * psoc,enum wakelock_mode mode)154 static inline QDF_STATUS target_if_wake_lock_timeout_acquire(
155 					struct wlan_objmgr_psoc *psoc,
156 					enum wakelock_mode mode)
157 {
158 	return QDF_STATUS_SUCCESS;
159 }
160 
target_if_wake_lock_timeout_release(struct wlan_objmgr_psoc * psoc,enum wakelock_mode mode)161 static inline QDF_STATUS target_if_wake_lock_timeout_release(
162 				struct wlan_objmgr_psoc *psoc,
163 				enum wakelock_mode mode)
164 {
165 	return QDF_STATUS_SUCCESS;
166 }
167 
168 static inline void
target_if_vdev_start_link_handler(struct wlan_objmgr_vdev * vdev,bool is_restart)169 target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev,
170 				  bool is_restart)
171 {
172 }
173 
174 static inline void
target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev * vdev)175 target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev)
176 {
177 }
178 
179 static inline void
target_if_prevent_pm_during_roam_sync(struct wlan_objmgr_psoc * psoc)180 target_if_prevent_pm_during_roam_sync(struct wlan_objmgr_psoc *psoc)
181 {
182 }
183 
184 static inline void
target_if_allow_pm_after_roam_sync(struct wlan_objmgr_psoc * psoc)185 target_if_allow_pm_after_roam_sync(struct wlan_objmgr_psoc *psoc)
186 {
187 }
188 #endif
189 #endif
190