blob: 98e56998acc0ab8ca3d5866269165205630acf0b [file] [log] [blame]
Mukul Sharmad75a6672017-06-22 15:40:53 +05301/*
Dustin Brownfbe4e7d2018-02-28 12:49:28 -08002 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
Jeff Johnsonb4c29962017-10-07 19:35:14 -07003 *
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 */
Mukul Sharmad75a6672017-06-22 15:40:53 +053018/**
19 * DOC: declare various api which shall be used by
20 * pmo user configuration and target interface
21 */
22
23#ifndef _WLAN_PMO_MAIN_H_
24#define _WLAN_PMO_MAIN_H_
25
Wu Gao5395a2e2018-05-30 14:38:27 +080026#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
27
Mukul Sharmad75a6672017-06-22 15:40:53 +053028#include "wlan_pmo_common_public_struct.h"
29#include "wlan_pmo_obj_mgmt_public_struct.h"
30#include "wlan_pmo_priv.h"
31#include "wlan_pmo_objmgr.h"
32
Dustin Brown89ccc392018-03-15 12:09:06 -070033#define pmo_fatal(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_PMO, params)
34#define pmo_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_PMO, params)
35#define pmo_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_PMO, params)
36#define pmo_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_PMO, params)
37#define pmo_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_PMO, params)
Mukul Sharmad75a6672017-06-22 15:40:53 +053038
Nirav Shahd6fa0f82018-07-06 15:52:25 +053039#define pmo_enter() QDF_TRACE_ENTER(QDF_MODULE_ID_PMO, "enter")
40#define pmo_exit() QDF_TRACE_EXIT(QDF_MODULE_ID_PMO, "exit")
Mukul Sharmad75a6672017-06-22 15:40:53 +053041
42#define PMO_VDEV_IN_STA_MODE(mode) \
43 ((mode) == QDF_STA_MODE || (mode) == QDF_P2P_CLIENT_MODE ? 1 : 0)
44
Dustin Brownb9987af2018-03-01 17:15:11 -080045static inline enum QDF_OPMODE pmo_get_vdev_opmode(struct wlan_objmgr_vdev *vdev)
Mukul Sharmad75a6672017-06-22 15:40:53 +053046{
Dustin Brownb9987af2018-03-01 17:15:11 -080047 return wlan_vdev_mlme_get_opmode(vdev);
Mukul Sharmad75a6672017-06-22 15:40:53 +053048}
49
50/**
51 * pmo_allocate_ctx() - Api to allocate pmo ctx
52 *
53 * Helper function to allocate pmo ctx
54 *
55 * Return: Success or failure.
56 */
57QDF_STATUS pmo_allocate_ctx(void);
58
59/**
60 * pmo_free_ctx() - to free pmo context
61 *
62 * Helper function to free pmo context
63 *
64 * Return: None.
65 */
66void pmo_free_ctx(void);
67
68/**
69 * pmo_get_context() - to get pmo context
70 *
71 * Helper function to get pmo context
72 *
73 * Return: pmo context.
74 */
75struct wlan_pmo_ctx *pmo_get_context(void);
76
77/**
78 * pmo_get_vdev_bss_peer_mac_addr() - API to get bss peer mac address
79 * @vdev: objmgr vdev
80 * @bss_peer_mac_address: bss peer mac address
81 *.
82 * Helper function to get bss peer mac address
83 *
84 * Return: if success pmo vdev ctx else NULL
85 */
86QDF_STATUS pmo_get_vdev_bss_peer_mac_addr(struct wlan_objmgr_vdev *vdev,
87 struct qdf_mac_addr *bss_peer_mac_address);
88
89/**
90 * pmo_is_vdev_in_beaconning_mode() - check if vdev is in a beaconning mode
91 * @vdev_opmode: vdev opmode
92 *
93 * Helper function to know whether given vdev
94 * is in a beaconning mode or not.
95 *
96 * Return: True if vdev needs to beacon.
97 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080098bool pmo_is_vdev_in_beaconning_mode(enum QDF_OPMODE vdev_opmode);
Mukul Sharmad75a6672017-06-22 15:40:53 +053099
100/**
101 * pmo_core_is_ap_mode_supports_arp_ns() - To check ap mode supports arp/ns
102 * @vdev_opmode: vdev opmode
103 *
104 * API to check if ap mode supports arp/ns offload
105 *
106 * Return: True if ap mode supports arp/ns offload
107 */
108
109bool pmo_core_is_ap_mode_supports_arp_ns(struct wlan_objmgr_psoc *psoc,
Jeff Johnsonc1e62782017-11-09 09:50:17 -0800110 enum QDF_OPMODE vdev_opmode);
Mukul Sharmad75a6672017-06-22 15:40:53 +0530111
112/**
113 * pmo_core_is_vdev_connected() - to check whether peer is associated or not
114 * @vdev: objmgr vdev
115 *
116 * Return: true in case success else false
117 */
118bool pmo_core_is_vdev_connected(struct wlan_objmgr_vdev *vdev);
119
120/**
121 * pmo_core_is_vdev_supports_offload() - Check offload is supported on vdev
122 * @vdev: objmgr vdev
123 *
124 * Return: true in case success else false
125 */
126bool pmo_core_is_vdev_supports_offload(struct wlan_objmgr_vdev *vdev);
127
128/**
129 * pmo_core_get_psoc_config(): API to get the psoc user configurations of pmo
130 * @psoc: objmgr psoc handle
131 * @psoc_cfg: fill the current psoc user configurations.
132 *
133 * Return pmo psoc configurations
134 */
135QDF_STATUS pmo_core_get_psoc_config(struct wlan_objmgr_psoc *psoc,
136 struct pmo_psoc_cfg *psoc_cfg);
137
138/**
139 * pmo_core_update_psoc_config(): API to update the psoc user configurations
140 * @psoc: objmgr psoc handle
141 * @psoc_cfg: pmo psoc configurations
142 *
143 * This api shall be used for soc config initialization as well update.
144 * In case of update caller must first call pmo_get_psoc_cfg to get
145 * current config and then apply changes on top of current config.
146 *
147 * Return QDF_STATUS -in case of success else return error
148 */
149QDF_STATUS pmo_core_update_psoc_config(struct wlan_objmgr_psoc *psoc,
150 struct pmo_psoc_cfg *psoc_cfg);
151
Dustin Brown06259e52018-02-28 16:00:02 -0800152/**
153 * pmo_psoc_set_caps() - overwrite configured device capability flags
154 * @psoc: the psoc for which the capabilities apply
155 * @caps: the cabability information to configure
156 *
157 * Return: None
158 */
159void pmo_psoc_set_caps(struct wlan_objmgr_psoc *psoc,
160 struct pmo_device_caps *caps);
Mukul Sharmad75a6672017-06-22 15:40:53 +0530161
162/**
163 * pmo_core_get_vdev_op_mode(): API to get the vdev operation mode
164 * @vdev: objmgr vdev handle
165 *
166 * API to get the vdev operation mode
167 *
168 * Return QDF_MAX_NO_OF_MODE - in case of error else return vdev opmode
169 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -0800170static inline enum QDF_OPMODE pmo_core_get_vdev_op_mode(
Mukul Sharmad75a6672017-06-22 15:40:53 +0530171 struct wlan_objmgr_vdev *vdev)
172{
Jeff Johnsonc1e62782017-11-09 09:50:17 -0800173 enum QDF_OPMODE op_mode = QDF_MAX_NO_OF_MODE;
Mukul Sharmad75a6672017-06-22 15:40:53 +0530174
175 if (!vdev)
176 return op_mode;
177 op_mode = wlan_vdev_mlme_get_opmode(vdev);
178
179 return op_mode;
180}
181
182/**
183 * pmo_core_psoc_update_dp_handle() - update psoc data path handle
184 * @psoc: objmgr psoc handle
185 * @dp_hdl: psoc data path handle
186 *
187 * Return: None
188 */
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800189static inline void
190pmo_core_psoc_update_dp_handle(struct wlan_objmgr_psoc *psoc, void *dp_hdl)
Mukul Sharmad75a6672017-06-22 15:40:53 +0530191{
192 struct pmo_psoc_priv_obj *psoc_ctx;
193
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800194 pmo_psoc_with_ctx(psoc, psoc_ctx) {
195 psoc_ctx->dp_hdl = dp_hdl;
196 }
Mukul Sharmad75a6672017-06-22 15:40:53 +0530197}
198
199/**
200 * pmo_core_psoc_get_dp_handle() - Get psoc data path handle
201 * @psoc: objmgr psoc handle
202 *
203 * Return: psoc data path handle
204 */
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800205static inline void *pmo_core_psoc_get_dp_handle(struct wlan_objmgr_psoc *psoc)
Mukul Sharmad75a6672017-06-22 15:40:53 +0530206{
Dustin Brownd3a53db2018-03-05 13:54:29 -0800207 void *dp_hdl = NULL;
Mukul Sharmad75a6672017-06-22 15:40:53 +0530208 struct pmo_psoc_priv_obj *psoc_ctx;
209
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800210 pmo_psoc_with_ctx(psoc, psoc_ctx) {
211 dp_hdl = psoc_ctx->dp_hdl;
212 }
Mukul Sharmad75a6672017-06-22 15:40:53 +0530213
214 return dp_hdl;
215}
216
217/**
Mukul Sharmad75a6672017-06-22 15:40:53 +0530218 * pmo_core_vdev_get_dp_handle() - Get vdev data path handle
Will Huangad015772018-06-15 11:27:50 +0800219 * @psoc_ctx: pmo psoc private context
220 * @vdev_id: vdev id config to get data path handle
Mukul Sharmad75a6672017-06-22 15:40:53 +0530221 *
222 * Return: Vdev data path handle
223 */
224static inline
Will Huangad015772018-06-15 11:27:50 +0800225struct cdp_vdev *pmo_core_vdev_get_dp_handle(struct pmo_psoc_priv_obj *psoc_ctx,
226 uint8_t vdev_id)
Mukul Sharmad75a6672017-06-22 15:40:53 +0530227{
Will Huangad015772018-06-15 11:27:50 +0800228 struct cdp_vdev *dp_hdl = NULL;
229 pmo_get_vdev_dp_handle handler;
Mukul Sharmad75a6672017-06-22 15:40:53 +0530230
Will Huangad015772018-06-15 11:27:50 +0800231 qdf_spin_lock_bh(&psoc_ctx->lock);
232 handler = psoc_ctx->get_vdev_dp_handle;
233 qdf_spin_unlock_bh(&psoc_ctx->lock);
234
235 if (handler)
236 dp_hdl = handler(vdev_id);
Mukul Sharmad75a6672017-06-22 15:40:53 +0530237
238 return dp_hdl;
239}
240
241/**
242 * pmo_core_psoc_update_htc_handle() - update psoc htc layer handle
243 * @psoc: objmgr psoc handle
244 * @htc_hdl: psoc htc layer handle
245 *
246 * Return: None
247 */
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800248static inline void
249pmo_core_psoc_update_htc_handle(struct wlan_objmgr_psoc *psoc, void *htc_hdl)
Mukul Sharmad75a6672017-06-22 15:40:53 +0530250{
251 struct pmo_psoc_priv_obj *psoc_ctx;
252
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800253 pmo_psoc_with_ctx(psoc, psoc_ctx) {
254 psoc_ctx->htc_hdl = htc_hdl;
255 }
Mukul Sharmad75a6672017-06-22 15:40:53 +0530256}
257
258/**
259 * pmo_core_psoc_get_htc_handle() - Get psoc htc layer handle
260 * @psoc: objmgr psoc handle
261 *
262 * Return: psoc htc layer handle
263 */
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800264static inline void *pmo_core_psoc_get_htc_handle(struct wlan_objmgr_psoc *psoc)
Mukul Sharmad75a6672017-06-22 15:40:53 +0530265{
Dustin Brownd3a53db2018-03-05 13:54:29 -0800266 void *htc_hdl = NULL;
Mukul Sharmad75a6672017-06-22 15:40:53 +0530267 struct pmo_psoc_priv_obj *psoc_ctx;
268
Dustin Brownfbe4e7d2018-02-28 12:49:28 -0800269 pmo_psoc_with_ctx(psoc, psoc_ctx) {
270 htc_hdl = psoc_ctx->htc_hdl;
271 }
Mukul Sharmad75a6672017-06-22 15:40:53 +0530272
273 return htc_hdl;
274}
275
276/**
277 * pmo_core_psoc_set_hif_handle() - update psoc hif layer handle
278 * @psoc: objmgr psoc handle
279 * @hif_hdl: hif context handle
280 *
281 * Return: None
282 */
283void pmo_core_psoc_set_hif_handle(struct wlan_objmgr_psoc *psoc,
284 void *hif_hdl);
285
286/**
287 * pmo_core_psoc_get_hif_handle() - Get psoc hif layer handle
288 * @psoc: objmgr psoc handle
289 *
290 * Return: psoc hif layer handle
291 */
292void *pmo_core_psoc_get_hif_handle(struct wlan_objmgr_psoc *psoc);
293
294/**
295 * pmo_core_psoc_set_txrx_handle() - update psoc pdev txrx layer handle
296 * @psoc: objmgr psoc handle
297 * @txrx_hdl: pdev txrx context handle
298 *
299 * Return: None
300 */
301void pmo_core_psoc_set_txrx_handle(struct wlan_objmgr_psoc *psoc,
302 void *txrx_hdl);
303
304/**
305 * pmo_core_psoc_get_txrx_handle() - Get psoc pdev txrx handle
306 * @psoc: objmgr psoc handle
307 *
308 * Return: pdev txrx handle
309 */
310void *pmo_core_psoc_get_txrx_handle(struct wlan_objmgr_psoc *psoc);
311
312/**
313 * pmo_is_vdev_up() - API to check whether vdev is UP
314 * @vdev: objmgr vdev handle
315 *
316 * Return:true if vdev is up else false
317 */
318static inline
319bool pmo_is_vdev_up(struct wlan_objmgr_vdev *vdev)
320{
321 enum wlan_vdev_state state = WLAN_VDEV_S_INIT;
322
323 if (!vdev) {
324 pmo_err("vdev context is invalid!");
325 return false;
326 }
327 state = wlan_vdev_mlme_get_state(vdev);
328
329 return state == WLAN_VDEV_S_RUN;
330}
331
Dustin Brownb9987af2018-03-01 17:15:11 -0800332/**
333 * pmo_intersect_arp_ns_offload() - intersect config and firmware capability for
334 * the ARP/NS Offload feature
335 * @psoc_ctx: A PMO psoc context
336 *
337 * Note: The caller is expected to grab the PMO context lock.
338 *
339 * Return: True if firmware supports and configuration has enabled the feature
340 */
341static inline bool
342pmo_intersect_arp_ns_offload(struct pmo_psoc_priv_obj *psoc_ctx)
343{
344 struct pmo_psoc_cfg *cfg = &psoc_ctx->psoc_cfg;
345 bool arp_ns_enabled =
346 cfg->ns_offload_enable_static ||
347 cfg->ns_offload_enable_dynamic ||
348 cfg->arp_offload_enable;
349
350 return arp_ns_enabled && psoc_ctx->caps.arp_ns_offload;
351}
352
353/**
354 * pmo_intersect_apf() - intersect config and firmware capability for
Nachiket Kukadee547a482018-05-22 16:43:30 +0530355 * the APF feature
Dustin Brownb9987af2018-03-01 17:15:11 -0800356 * @psoc_ctx: A PMO psoc context
357 *
358 * Note: The caller is expected to grab the PMO context lock.
359 *
360 * Return: True if firmware supports and configuration has enabled the feature
361 */
362static inline bool pmo_intersect_apf(struct pmo_psoc_priv_obj *psoc_ctx)
363{
364 return psoc_ctx->psoc_cfg.apf_enable && psoc_ctx->caps.apf;
365}
366
367/**
368 * pmo_intersect_packet_filter() - intersect config and firmware capability for
Nachiket Kukadee547a482018-05-22 16:43:30 +0530369 * the APF feature
Dustin Brownb9987af2018-03-01 17:15:11 -0800370 * @psoc_ctx: A PMO psoc context
371 *
372 * Note: The caller is expected to grab the PMO context lock.
373 *
374 * Return: True if firmware supports and configuration has enabled the feature
375 */
376static inline bool
377pmo_intersect_packet_filter(struct pmo_psoc_priv_obj *psoc_ctx)
378{
379 return psoc_ctx->psoc_cfg.packet_filter_enabled &&
380 psoc_ctx->caps.packet_filter;
381}
382
Wu Gao5395a2e2018-05-30 14:38:27 +0800383#endif /* WLAN_POWER_MANAGEMENT_OFFLOAD */
384
Mukul Sharmad75a6672017-06-22 15:40:53 +0530385#endif /* end of _WLAN_PMO_MAIN_H_ */