xref: /wlan-driver/qcacld-3.0/components/pmo/core/inc/wlan_pmo_static_config.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 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  * DOC: Declare static configuration on vdev attach
21  */
22 
23 #ifndef _WLAN_PMO_STATIC_CONFIG_H_
24 #define _WLAN_PMO_STATIC_CONFIG_H_
25 
26 #ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
27 
28 #include "wlan_pmo_common_public_struct.h"
29 #include "wlan_pmo_wow.h"
30 
31 /**
32  * pmo_register_wow_wakeup_events() - register vdev specific wake events with fw
33  * @vdev: objmgr vdev
34  *
35  * WoW wake up event rule is following:
36  * 1) STA mode and P2P CLI mode wake up events are same
37  * 2) SAP mode and P2P GO mode wake up events are same
38  * 3) IBSS mode wake events are same as STA mode plus WOW_BEACON_EVENT
39  *
40  * Return: none
41  */
42 void pmo_register_wow_wakeup_events(struct wlan_objmgr_vdev *vdev);
43 
44 /**
45  * pmo_register_wow_default_patterns() - register default wow patterns with fw
46  * @vdev: objmgr vdev
47  *
48  * WoW default wake up pattern rule is:
49  *  - For STA & P2P CLI mode register for same STA specific wow patterns
50  *  - For SAP/P2P GO & IBSS mode register for same SAP specific wow patterns
51  *
52  * Return: none
53  */
54 void pmo_register_wow_default_patterns(struct wlan_objmgr_vdev *vdev);
55 
56 /**
57  * pmo_register_action_frame_patterns() - register action frame map to fw
58  * @vdev: objmgr vdev
59  * @suspend_type: suspend mode runtime pm suspend or normal suspend.
60  *
61  * This is called to push action frames wow patterns from local
62  * cache to firmware.
63  *
64  * Return: QDF_STATUS
65  */
66 QDF_STATUS
67 pmo_register_action_frame_patterns(struct wlan_objmgr_vdev *vdev,
68 				   enum qdf_suspend_type suspend_type);
69 
70 /**
71  * pmo_clear_action_frame_patterns() - clear the action frame
72  * pattern bitmap in firmware
73  * @vdev: objmgr vdev
74  *
75  * Return: QDF_STATUS
76  */
77 QDF_STATUS pmo_clear_action_frame_patterns(struct wlan_objmgr_vdev *vdev);
78 
79 /**
80  * pmo_set_wow_event_bitmap() - Assign bitmask with wow event
81  * @event: wow event
82  * @wow_bitmap_size: wow bitmask size
83  * @bitmask: wow bitmask field
84  *
85  * Return: none
86  */
87 void pmo_set_wow_event_bitmap(WOW_WAKE_EVENT_TYPE event,
88 			      uint32_t wow_bitmap_size,
89 			      uint32_t *bitmask);
90 
91 /**
92  * pmo_set_sta_wow_bitmask() - set predefined STA wow wakeup events
93  * @bitmask: bitmask field
94  * @wow_bitmask_size: bitmask field size
95  *
96  * Return: none
97  */
98 void pmo_set_sta_wow_bitmask(uint32_t *bitmask, uint32_t wow_bitmask_size);
99 
100 /**
101  * pmo_set_sap_wow_bitmask() - set predefined SAP wow wakeup events
102  * @bitmask: bitmask field
103  * @wow_bitmask_size: bitmask field size
104  *
105  * Return: none
106  */
107 void pmo_set_sap_wow_bitmask(uint32_t *bitmask, uint32_t wow_bitmask_size);
108 
109 /**
110  * pmo_core_vdev_set_ps_params() - set vdev ps_params
111  * @vdev: objmgr vdev handle
112  * @ps_params: vdev OPM parameters
113  *
114  * Return: None
115  */
116 static inline
pmo_core_vdev_set_ps_params(struct wlan_objmgr_vdev * vdev,struct pmo_ps_params * ps_params)117 void pmo_core_vdev_set_ps_params(struct wlan_objmgr_vdev *vdev,
118 				 struct pmo_ps_params *ps_params)
119 {
120 	struct pmo_vdev_priv_obj *vdev_ctx;
121 
122 	vdev_ctx = pmo_vdev_get_priv(vdev);
123 	qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock);
124 	vdev_ctx->ps_params = *ps_params;
125 	qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock);
126 }
127 
128 /**
129  * pmo_core_vdev_get_ps_params() - get vdev ps_params
130  * @vdev: objmgr vdev handle
131  * @ps_params: pointer to get vdev ps_params
132  *
133  * Return: QDF_STATUS
134  */
135 static inline
pmo_core_vdev_get_ps_params(struct wlan_objmgr_vdev * vdev,struct pmo_ps_params * ps_params)136 QDF_STATUS pmo_core_vdev_get_ps_params(struct wlan_objmgr_vdev *vdev,
137 				       struct pmo_ps_params *ps_params)
138 {
139 	struct pmo_vdev_priv_obj *vdev_ctx;
140 
141 	vdev_ctx = pmo_vdev_get_priv(vdev);
142 	if (!vdev_ctx)
143 		return QDF_STATUS_E_NULL_VALUE;
144 
145 	qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock);
146 	*ps_params = vdev_ctx->ps_params;
147 	qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock);
148 	return QDF_STATUS_SUCCESS;
149 }
150 
151 /**
152  * pmo_vdev_set_ps_opm_mode() - set OPM mode
153  * @vdev: objmgr vdev handle
154  * @opm_mode: OPM mode
155  *
156  * Return: QDF_STATUS
157  */
158 static inline
pmo_vdev_set_ps_opm_mode(struct wlan_objmgr_vdev * vdev,enum powersave_mode opm_mode)159 QDF_STATUS pmo_vdev_set_ps_opm_mode(struct wlan_objmgr_vdev *vdev,
160 					 enum powersave_mode opm_mode)
161 {
162 	struct pmo_vdev_priv_obj *vdev_ctx;
163 
164 	vdev_ctx = pmo_vdev_get_priv(vdev);
165 	if (!vdev_ctx) {
166 		pmo_err("vdev ctx is null");
167 		return QDF_STATUS_E_NULL_VALUE;
168 	}
169 
170 	qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock);
171 	vdev_ctx->ps_params.opm_mode = opm_mode;
172 	qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock);
173 
174 	return QDF_STATUS_SUCCESS;
175 }
176 
177 /**
178  * pmo_vdev_get_ps_opm_mode() - get OPM mode
179  * @vdev: objmgr vdev handle
180  * @opm_mode: OPM mode
181  *
182  * Return: QDF_STATUS
183  */
184 static inline
pmo_vdev_get_ps_opm_mode(struct wlan_objmgr_vdev * vdev,enum powersave_mode * opm_mode)185 QDF_STATUS pmo_vdev_get_ps_opm_mode(struct wlan_objmgr_vdev *vdev,
186 					 enum powersave_mode *opm_mode)
187 {
188 	struct pmo_vdev_priv_obj *vdev_ctx;
189 
190 	vdev_ctx = pmo_vdev_get_priv(vdev);
191 	if (!vdev_ctx)
192 		return QDF_STATUS_E_NULL_VALUE;
193 
194 	qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock);
195 	*opm_mode = vdev_ctx->ps_params.opm_mode;
196 	qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock);
197 	return QDF_STATUS_SUCCESS;
198 }
199 
200 #ifdef WLAN_FEATURE_NAN
201 /**
202  * pmo_set_ndp_wow_bitmask() - set predefined NDP wow wakeup events
203  * @bitmask: bitmask field
204  * @wow_bitmask_size: bitmask field size
205  *
206  * Return: none
207  */
208 void pmo_set_ndp_wow_bitmask(uint32_t *bitmask, uint32_t wow_bitmask_size);
209 #else
210 static inline
pmo_set_ndp_wow_bitmask(uint32_t * bitmask,uint32_t wow_bitmask_size)211 void pmo_set_ndp_wow_bitmask(uint32_t *bitmask, uint32_t wow_bitmask_size)
212 {
213 }
214 #endif
215 
216 #endif /* WLAN_POWER_MANAGEMENT_OFFLOAD */
217 
218 #endif /* end  of _WLAN_PMO_STATIC_CONFIG_H_ */
219