xref: /wlan-dirver/qca-wifi-host-cmn/target_if/mlme/psoc/inc/target_if_psoc_wake_lock.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: target_if_psoc_wake_lock.h
21  *
22  * This file provides declaration for wakelock APIs
23  */
24 
25 #ifndef __TARGET_IF_PSOC_WAKE_LOCK_H__
26 #define __TARGET_IF_PSOC_WAKE_LOCK_H__
27 
28 #include <wlan_objmgr_psoc_obj.h>
29 #include <qdf_lock.h>
30 
31 #ifdef FEATURE_VDEV_OPS_WAKELOCK
32 /**
33  *  struct wlan_vdev_wakelock - vdev wake lock sub structure
34  *  @start_wakelock: wakelock for vdev start
35  *  @stop_wakelock: wakelock for vdev stop
36  *  @delete_wakelock: wakelock for vdev delete
37  *  @wmi_cmd_rsp_runtime_lock: run time lock
38  *  @prevent_runtime_lock: run time lock
39  *  @is_link_up: flag to check link status
40  */
41 struct psoc_mlme_wakelock {
42 	qdf_wake_lock_t start_wakelock;
43 	qdf_wake_lock_t stop_wakelock;
44 	qdf_wake_lock_t delete_wakelock;
45 	qdf_runtime_lock_t wmi_cmd_rsp_runtime_lock;
46 	qdf_runtime_lock_t prevent_runtime_lock;
47 	bool is_link_up;
48 };
49 #endif
50 
51 enum wakelock_mode {
52 	START_WAKELOCK,
53 	STOP_WAKELOCK,
54 	DELETE_WAKELOCK
55 };
56 
57 #ifdef FEATURE_VDEV_OPS_WAKELOCK
58 
59 /**
60  * target_if_wake_lock_init() - API to initialize
61 				wakelocks:start,
62 				stop and delete.
63  * @psoc: pointer to psoc
64  *
65  * This also initialize the runtime lock
66  *
67  * Return: None
68  */
69 void target_if_wake_lock_init(struct wlan_objmgr_psoc *psoc);
70 
71 /**
72  * target_if_wake_lock_deinit() - API to destroy
73 			wakelocks:start, stop and delete.
74  * @psoc: pointer to psoc
75  *
76  * This also destroy the runtime lock
77  *
78  * Return: None
79  */
80 void target_if_wake_lock_deinit(struct wlan_objmgr_psoc *psoc);
81 
82 /**
83  * target_if_start_wake_lock_timeout_acquire() - acquire the
84 					vdev start wakelock
85  * @psoc: pointer to psoc
86  *
87  * This also acquires the target_if runtime pm lock.
88  *
89  * Return: Success/Failure
90  */
91 QDF_STATUS target_if_wake_lock_timeout_acquire(struct wlan_objmgr_psoc *psoc,
92 					       enum wakelock_mode mode);
93 /**
94  * target_if_start_wake_lock_timeout_release() - release the
95 						start wakelock
96  * @psoc: pointer to psoc
97  *
98  * This also release the target_if runtime pm lock.
99  *
100  * Return: Success/Failure
101  */
102 QDF_STATUS target_if_wake_lock_timeout_release(struct wlan_objmgr_psoc *psoc,
103 					       enum wakelock_mode mode);
104 
105 /**
106  * target_if_vdev_start_link_handler() - check for SAP mode and DFS freq
107 						to handle link up/down
108  * @vdev: pointer to vdev
109  * @is_dfs : is dfs freq
110  *
111  * Return: None
112  */
113 void target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev,
114 				       uint32_t is_dfs);
115 
116 /**
117  * target_if_vdev_stop_link_handler() - check for SAP mode to handle link
118  * @vdev: pointer to vdev
119  *
120  * Return: None
121  */
122 void target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev);
123 
124 #else
125 static inline void target_if_wake_lock_init(struct wlan_objmgr_psoc *psoc)
126 {
127 }
128 
129 static inline void target_if_wake_lock_deinit(struct wlan_objmgr_psoc *psoc)
130 {
131 }
132 
133 static inline QDF_STATUS target_if_wake_lock_timeout_acquire(
134 					struct wlan_objmgr_psoc *psoc,
135 					enum wakelock_mode mode)
136 {
137 	return QDF_STATUS_SUCCESS;
138 }
139 
140 static inline QDF_STATUS target_if_wake_lock_timeout_release(
141 				struct wlan_objmgr_psoc *psoc,
142 				enum wakelock_mode mode)
143 {
144 	return QDF_STATUS_SUCCESS;
145 }
146 
147 static inline void
148 target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev,
149 				  uint32_t is_dfs)
150 {
151 }
152 
153 static inline void
154 target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev)
155 {
156 }
157 
158 #endif
159 #endif
160