xref: /wlan-dirver/qca-wifi-host-cmn/target_if/mlme/psoc/inc/target_if_psoc_wake_lock.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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: 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 wlan_vdev_wakelock - vdev 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
64 				wakelocks:start,
65 				stop and delete.
66  * @psoc: pointer to psoc
67  *
68  * This also initialize the runtime lock
69  *
70  * Return: None
71  */
72 void target_if_wake_lock_init(struct wlan_objmgr_psoc *psoc);
73 
74 /**
75  * target_if_wake_lock_deinit() - API to destroy
76 			wakelocks:start, stop and delete.
77  * @psoc: pointer to psoc
78  *
79  * This also destroy the runtime lock
80  *
81  * Return: None
82  */
83 void target_if_wake_lock_deinit(struct wlan_objmgr_psoc *psoc);
84 
85 /**
86  * target_if_start_wake_lock_timeout_acquire() - acquire the
87 					vdev start wakelock
88  * @psoc: pointer to psoc
89  *
90  * This also acquires the target_if runtime pm lock.
91  *
92  * Return: Success/Failure
93  */
94 QDF_STATUS target_if_wake_lock_timeout_acquire(struct wlan_objmgr_psoc *psoc,
95 					       enum wakelock_mode mode);
96 /**
97  * target_if_start_wake_lock_timeout_release() - release the
98 						start wakelock
99  * @psoc: pointer to psoc
100  *
101  * This also release the target_if runtime pm lock.
102  *
103  * Return: Success/Failure
104  */
105 QDF_STATUS target_if_wake_lock_timeout_release(struct wlan_objmgr_psoc *psoc,
106 					       enum wakelock_mode mode);
107 
108 /**
109  * target_if_vdev_start_link_handler() - check for SAP mode and DFS freq
110 						to handle link up/down
111  * @vdev: pointer to vdev
112  * @is_restart: flag to check if it is vdev restart
113  *
114  * Return: None
115  */
116 void target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev,
117 				       bool is_restart);
118 
119 /**
120  * target_if_vdev_stop_link_handler() - check for SAP mode to handle link
121  * @vdev: pointer to vdev
122  *
123  * Return: None
124  */
125 void target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev);
126 
127 /**
128  * target_if_prevent_pm_during_roam_sync() - prevent runtime PM during roam sync
129  * @psoc: pointer to psoc
130  *
131  * Return: None
132  */
133 void
134 target_if_prevent_pm_during_roam_sync(struct wlan_objmgr_psoc *psoc);
135 
136 /**
137  * target_if_allow_pm_after_roam_sync() - allow runtime PM after roam
138  * sync complete
139  * @psoc: pointer to psoc
140  *
141  * Return: None
142  */
143 void
144 target_if_allow_pm_after_roam_sync(struct wlan_objmgr_psoc *psoc);
145 
146 #else
147 static inline void target_if_wake_lock_init(struct wlan_objmgr_psoc *psoc)
148 {
149 }
150 
151 static inline void target_if_wake_lock_deinit(struct wlan_objmgr_psoc *psoc)
152 {
153 }
154 
155 static inline QDF_STATUS target_if_wake_lock_timeout_acquire(
156 					struct wlan_objmgr_psoc *psoc,
157 					enum wakelock_mode mode)
158 {
159 	return QDF_STATUS_SUCCESS;
160 }
161 
162 static inline QDF_STATUS target_if_wake_lock_timeout_release(
163 				struct wlan_objmgr_psoc *psoc,
164 				enum wakelock_mode mode)
165 {
166 	return QDF_STATUS_SUCCESS;
167 }
168 
169 static inline void
170 target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev,
171 				  bool is_restart)
172 {
173 }
174 
175 static inline void
176 target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev)
177 {
178 }
179 
180 static inline void
181 target_if_prevent_pm_during_roam_sync(struct wlan_objmgr_psoc *psoc)
182 {
183 }
184 
185 static inline void
186 target_if_allow_pm_after_roam_sync(struct wlan_objmgr_psoc *psoc)
187 {
188 }
189 #endif
190 #endif
191