Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | * DOC: Declare suspend / resume related API's |
| 20 | */ |
| 21 | |
| 22 | #ifndef _WLAN_PMO_SUSPEND_RESUME_H_ |
| 23 | #define _WLAN_PMO_SUSPEND_RESUME_H_ |
| 24 | |
| 25 | #include "wlan_pmo_common_public_struct.h" |
| 26 | #include "wlan_pmo_wow.h" |
| 27 | |
| 28 | /** |
| 29 | * pmo_core_configure_dynamic_wake_events(): configure dyanmic wake events |
| 30 | * @wma: wma handle |
| 31 | * |
| 32 | * Some wake events need to be enabled dynamically. Control those here. |
| 33 | * |
| 34 | * Return: none |
| 35 | */ |
| 36 | void pmo_core_configure_dynamic_wake_events(struct wlan_objmgr_psoc *psoc); |
| 37 | |
| 38 | /** |
| 39 | * pmo_core_get_wow_bus_suspend(): API to get wow bus is suspended or not |
| 40 | * @psoc: objmgr psoc handle |
| 41 | * |
| 42 | * Return: True if bus suspende else false |
| 43 | */ |
| 44 | static inline |
| 45 | bool pmo_core_get_wow_bus_suspend(struct wlan_objmgr_psoc *psoc) |
| 46 | { |
| 47 | bool value; |
| 48 | struct pmo_psoc_priv_obj *psoc_ctx; |
| 49 | |
| 50 | psoc_ctx = pmo_psoc_get_priv(psoc); |
| 51 | qdf_spin_lock_bh(&psoc_ctx->lock); |
| 52 | value = psoc_ctx->wow.is_wow_bus_suspended; |
| 53 | qdf_spin_unlock_bh(&psoc_ctx->lock); |
| 54 | |
| 55 | return value; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * pmo_core_psoc_user_space_suspend_req() - Core handle user space suspend req |
| 60 | * @psoc: objmgr psoc handle |
| 61 | * @type: type of suspend |
| 62 | * |
| 63 | * Pmo core Handles user space suspend request for psoc |
| 64 | * |
| 65 | * Return: QDF status |
| 66 | */ |
| 67 | QDF_STATUS pmo_core_psoc_user_space_suspend_req(struct wlan_objmgr_psoc *psoc, |
| 68 | enum qdf_suspend_type type); |
| 69 | |
| 70 | /** |
| 71 | * pmo_core_psoc_user_space_resume_req() - Core handle user space resume req |
| 72 | * @psoc: objmgr psoc handle |
| 73 | * @type: type of suspend from resume required |
| 74 | * |
| 75 | * Pmo core Handles user space resume request for psoc |
| 76 | * |
| 77 | * Return: QDF status |
| 78 | */ |
| 79 | QDF_STATUS pmo_core_psoc_user_space_resume_req(struct wlan_objmgr_psoc *psoc, |
| 80 | enum qdf_suspend_type type); |
| 81 | |
| 82 | /** |
| 83 | * pmo_core_psoc_bus_suspend_req(): handles bus suspend for psoc |
| 84 | * @psoc: objmgr psoc |
| 85 | * @type: is this suspend part of runtime suspend or system suspend? |
| 86 | * @wow_params: collection of wow enable override parameters |
| 87 | * |
| 88 | * Bails if a scan is in progress. |
| 89 | * Calls the appropriate handlers based on configuration and event. |
| 90 | * |
| 91 | * Return: QDF_STATUS_SUCCESS for success or error code |
| 92 | */ |
| 93 | QDF_STATUS pmo_core_psoc_bus_suspend_req(struct wlan_objmgr_psoc *psoc, |
| 94 | enum qdf_suspend_type type, |
| 95 | struct pmo_wow_enable_params *wow_params); |
| 96 | |
| 97 | #ifdef FEATURE_RUNTIME_PM |
| 98 | /** |
| 99 | * pmo_core_psoc_bus_runtime_suspend(): handles bus runtime suspend |
| 100 | * @psoc: objmgr psoc |
| 101 | * @pld_cb: callback to do link auto suspend |
| 102 | * |
| 103 | * Suspend the wlan bus without apps suspend. |
| 104 | * |
| 105 | * Return: QDF_STATUS_SUCCESS for success or error code |
| 106 | */ |
| 107 | QDF_STATUS pmo_core_psoc_bus_runtime_suspend(struct wlan_objmgr_psoc *psoc, |
| 108 | pmo_pld_auto_suspend_cb pld_cb); |
| 109 | |
| 110 | /** |
| 111 | * pmo_core_psoc_bus_runtime_resume(): handles bus runtime resume |
| 112 | * @psoc: objmgr psoc |
| 113 | * @pld_cb: callback to do link auto resume |
| 114 | * |
| 115 | * Resume the wlan bus from runtime suspend. |
| 116 | * |
| 117 | * Return: QDF_STATUS_SUCCESS for success or error code |
| 118 | */ |
| 119 | QDF_STATUS pmo_core_psoc_bus_runtime_resume(struct wlan_objmgr_psoc *psoc, |
| 120 | pmo_pld_auto_resume_cb pld_cb); |
| 121 | #endif |
| 122 | |
| 123 | /** |
| 124 | * pmo_core_psoc_suspend_target() -Send suspend target command |
| 125 | * @psoc: objmgr psoc handle |
| 126 | * @disable_target_intr: disable target interrupt |
| 127 | * |
| 128 | * Return: QDF_STATUS_SUCCESS for success or error code |
| 129 | */ |
| 130 | QDF_STATUS pmo_core_psoc_suspend_target(struct wlan_objmgr_psoc *psoc, |
| 131 | int disable_target_intr); |
| 132 | |
| 133 | /** |
| 134 | * pmo_core_psoc_bus_resume() -handle bus resume request for psoc |
| 135 | * @psoc: objmgr psoc handle |
| 136 | * @type: is this suspend part of runtime suspend or system suspend? |
| 137 | * |
| 138 | * Return:QDF_STATUS_SUCCESS on success else error code |
| 139 | */ |
| 140 | QDF_STATUS pmo_core_psoc_bus_resume_req(struct wlan_objmgr_psoc *psoc, |
| 141 | enum qdf_suspend_type type); |
| 142 | |
| 143 | /** |
| 144 | * pmo_core_get_vdev_dtim_period() - Get vdev dtim period |
| 145 | * @vdev: objmgr vdev handle |
| 146 | * |
| 147 | * Return: Vdev dtim period |
| 148 | */ |
| 149 | static inline |
| 150 | uint8_t pmo_core_get_vdev_dtim_period(struct wlan_objmgr_vdev *vdev) |
| 151 | { |
| 152 | uint8_t dtim_period = 0; |
| 153 | |
| 154 | if (!vdev) { |
| 155 | pmo_err("vdev is null"); |
| 156 | QDF_ASSERT(0); |
| 157 | return 0; |
| 158 | } |
| 159 | /* TODO */ |
| 160 | /* dtim_period = wlan_vdev_mlme_get_dtim_period(vdev); */ |
| 161 | |
| 162 | return dtim_period; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * pmo_core_get_vdev_beacon_interval() - Get vdev beacon interval |
| 167 | * @vdev: objmgr vdev handle |
| 168 | * |
| 169 | * Return: Vdev beacon interval |
| 170 | */ |
| 171 | static inline |
| 172 | uint16_t pmo_core_get_vdev_beacon_interval(struct wlan_objmgr_vdev *vdev) |
| 173 | { |
| 174 | uint16_t beacon_interval = 0; |
| 175 | |
| 176 | if (!vdev) { |
| 177 | pmo_err("vdev is null"); |
| 178 | QDF_ASSERT(0); |
| 179 | return 0; |
| 180 | } |
| 181 | /* TODO */ |
| 182 | /* beacon_interval = wlan_vdev_mlme_get_beacon_interval(vdev); */ |
| 183 | |
| 184 | return beacon_interval; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * pmo_core_update_alt_modulated_dtim_enable() - update alt modulatate dtim |
| 189 | * @vdev: objmgr vdev handle |
| 190 | * @value: true when alt modulated dtim enable else false |
| 191 | * |
| 192 | * Return: None |
| 193 | */ |
| 194 | static inline |
| 195 | void pmo_core_update_alt_modulated_dtim_enable(struct wlan_objmgr_vdev *vdev, |
| 196 | bool value) |
| 197 | { |
| 198 | struct pmo_vdev_priv_obj *vdev_ctx; |
| 199 | |
| 200 | vdev_ctx = pmo_vdev_get_priv(vdev); |
| 201 | qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); |
| 202 | vdev_ctx->alt_modulated_dtim_enable = value; |
| 203 | qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * pmo_core_vdev_set_dtim_policy() - Set vdev beacon dtim policy |
| 208 | * @vdev: objmgr vdev handle |
| 209 | * @value: carry vdev dtim policy |
| 210 | * |
| 211 | * Return: None |
| 212 | */ |
| 213 | static inline |
| 214 | void pmo_core_vdev_set_dtim_policy(struct wlan_objmgr_vdev *vdev, |
| 215 | uint32_t value) |
| 216 | { |
| 217 | struct pmo_vdev_priv_obj *vdev_ctx; |
| 218 | |
| 219 | vdev_ctx = pmo_vdev_get_priv(vdev); |
| 220 | qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); |
| 221 | vdev_ctx->dtim_policy = value; |
| 222 | qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * pmo_core_vdev_get_dtim_policy() - Get vdev beacon dtim policy |
| 227 | * @vdev: objmgr vdev handle |
| 228 | * |
| 229 | * Return: vdev dtim policy |
| 230 | */ |
| 231 | static inline |
| 232 | uint32_t pmo_core_vdev_get_dtim_policy(struct wlan_objmgr_vdev *vdev) |
| 233 | { |
| 234 | uint32_t value; |
| 235 | struct pmo_vdev_priv_obj *vdev_ctx; |
| 236 | |
| 237 | vdev_ctx = pmo_vdev_get_priv(vdev); |
| 238 | qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); |
| 239 | value = vdev_ctx->dtim_policy; |
| 240 | qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); |
| 241 | |
| 242 | return value; |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * pmo_core_update_power_save_mode() - update power save mode |
| 247 | * @vdev: objmgr vdev handle |
| 248 | * @value:describe vdev power save mode |
| 249 | * |
| 250 | * Return: None |
| 251 | */ |
| 252 | static inline |
| 253 | void pmo_core_psoc_update_power_save_mode(struct wlan_objmgr_psoc *psoc, |
| 254 | uint8_t value) |
| 255 | { |
| 256 | struct pmo_psoc_priv_obj *psoc_ctx; |
| 257 | |
| 258 | psoc_ctx = pmo_psoc_get_priv(psoc); |
| 259 | qdf_spin_lock_bh(&psoc_ctx->lock); |
| 260 | psoc_ctx->psoc_cfg.power_save_mode = value; |
| 261 | qdf_spin_unlock_bh(&psoc_ctx->lock); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * pmo_core_psoc_get_power_save_mode() - Get psoc power save mode |
| 266 | * @psoc: objmgr psoc handle |
| 267 | * |
| 268 | * Return: vdev psoc power save mode value |
| 269 | */ |
| 270 | static inline |
| 271 | uint8_t pmo_core_psoc_get_power_save_mode(struct wlan_objmgr_psoc *psoc) |
| 272 | { |
| 273 | uint8_t value; |
| 274 | struct pmo_psoc_priv_obj *psoc_ctx; |
| 275 | |
| 276 | psoc_ctx = pmo_psoc_get_priv(psoc); |
| 277 | qdf_spin_lock_bh(&psoc_ctx->lock); |
| 278 | value = psoc_ctx->psoc_cfg.power_save_mode; |
| 279 | qdf_spin_unlock_bh(&psoc_ctx->lock); |
| 280 | |
| 281 | return value; |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * pmo_core_psoc_get_qpower_config() - get qpower configuration |
| 286 | * @psoc: objmgr psoc handle |
| 287 | * |
| 288 | * Power Save Offload configuration: |
| 289 | * 0 -> Power save offload is disabled |
| 290 | * 1 -> Legacy Power save enabled + Deep sleep Disabled |
| 291 | * 2 -> QPower enabled + Deep sleep Disabled |
| 292 | * 3 -> Legacy Power save enabled + Deep sleep Enabled |
| 293 | * 4 -> QPower enabled + Deep sleep Enabled |
| 294 | * 5 -> Duty cycling QPower enabled |
| 295 | * |
| 296 | * Return: enum powersave_qpower_mode with below values |
| 297 | * QPOWER_DISABLED if QPOWER is disabled |
| 298 | * QPOWER_ENABLED if QPOWER is enabled |
| 299 | * QPOWER_DUTY_CYCLING if DUTY CYCLING QPOWER is enabled |
| 300 | */ |
| 301 | static inline |
| 302 | enum pmo_power_save_qpower_mode pmo_core_psoc_get_qpower_config( |
| 303 | struct wlan_objmgr_psoc *psoc) |
| 304 | { |
| 305 | uint8_t ps_mode = pmo_core_psoc_get_power_save_mode(psoc); |
| 306 | |
| 307 | switch (ps_mode) { |
| 308 | case pmo_ps_qpower_no_deep_sleep: |
| 309 | case pmo_ps_qpower_deep_sleep: |
| 310 | pmo_info("QPOWER is enabled in power save mode %d", ps_mode); |
| 311 | return pmo_qpower_enabled; |
| 312 | case pmo_ps_duty_cycling_qpower: |
| 313 | pmo_info("DUTY cycling QPOWER is enabled in power save mode %d", |
| 314 | ps_mode); |
| 315 | return pmo_qpower_duty_cycling; |
| 316 | default: |
| 317 | pmo_info("QPOWER is disabled in power save mode %d", |
| 318 | ps_mode); |
| 319 | return pmo_qpower_disabled; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * pmo_core_vdev_get_pause_bitmap() - Get vdev pause bitmap |
| 325 | * @psoc_ctx: psoc priv ctx |
| 326 | * @vdev_id: vdev id |
| 327 | * |
| 328 | * Return: vdev pause bitmap |
| 329 | */ |
| 330 | static inline |
| 331 | uint16_t pmo_core_vdev_get_pause_bitmap(struct pmo_psoc_priv_obj *psoc_ctx, |
| 332 | uint8_t vdev_id) |
| 333 | { |
| 334 | uint16_t value = 0; |
| 335 | pmo_get_pause_bitmap handler; |
| 336 | |
| 337 | qdf_spin_lock_bh(&psoc_ctx->lock); |
| 338 | handler = psoc_ctx->get_pause_bitmap; |
| 339 | qdf_spin_unlock_bh(&psoc_ctx->lock); |
| 340 | |
| 341 | if (handler) |
| 342 | value = handler(vdev_id); |
| 343 | |
| 344 | return value; |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * wma_is_vdev_in_ap_mode() - check that vdev is in ap mode or not |
| 349 | * @wma: wma handle |
| 350 | * @vdev_id: vdev id |
| 351 | * |
| 352 | * Helper function to know whether given vdev id |
| 353 | * is in AP mode or not. |
| 354 | * |
| 355 | * Return: True/False |
| 356 | */ |
| 357 | static inline |
| 358 | bool pmo_is_vdev_in_ap_mode(struct wlan_objmgr_vdev *vdev) |
| 359 | { |
| 360 | enum tQDF_ADAPTER_MODE mode; |
| 361 | |
| 362 | mode = pmo_get_vdev_opmode(vdev); |
| 363 | |
| 364 | return (mode == QDF_SAP_MODE || mode == QDF_P2P_GO_MODE) == 1 ? 1 : 0; |
| 365 | } |
| 366 | |
| 367 | #ifdef QCA_IBSS_SUPPORT |
| 368 | /** |
| 369 | * pmo_is_vdev_in_ibss_mode() - check that vdev is in ibss mode or not |
| 370 | * @vdev: objmgr vdev handle |
| 371 | * @vdev_id: vdev id |
| 372 | * |
| 373 | * Helper function to know whether given vdev id |
| 374 | * is in IBSS mode or not. |
| 375 | * |
| 376 | * Return: True/False |
| 377 | */ |
| 378 | static inline |
| 379 | bool pmo_is_vdev_in_ibss_mode(struct wlan_objmgr_vdev *vdev) |
| 380 | { |
| 381 | enum tQDF_ADAPTER_MODE mode; |
| 382 | |
| 383 | mode = pmo_get_vdev_opmode(vdev); |
| 384 | |
| 385 | return (mode == QDF_IBSS_MODE) ? true : false; |
| 386 | } |
| 387 | #else |
| 388 | static inline bool pmo_is_vdev_in_ibss_mode(struct wlan_objmgr_vdev *vdev) |
| 389 | { |
| 390 | return false; |
| 391 | } |
| 392 | #endif /* QCA_IBSS_SUPPORT */ |
| 393 | |
| 394 | /** |
| 395 | * pmo_handle_initial_wake_up() - handle initial wake up |
| 396 | * @cb_ctx: callback context |
| 397 | * |
| 398 | * Return: None |
| 399 | */ |
| 400 | void pmo_core_psoc_handle_initial_wake_up(void *cb_ctx); |
| 401 | |
| 402 | /** |
| 403 | * pmo_core_psoc_is_target_wake_up_received() - check for initial wake up |
| 404 | * |
| 405 | * Check if target initial wake up is received and fail PM suspend gracefully |
| 406 | * |
| 407 | * Return: -EAGAIN if initial wake up is received else 0 |
| 408 | */ |
| 409 | int pmo_core_psoc_is_target_wake_up_received(struct wlan_objmgr_psoc *psoc); |
| 410 | |
| 411 | /** |
| 412 | * pmo_core_psoc_clear_target_wake_up() - clear initial wake up |
| 413 | * |
| 414 | * Clear target initial wake up reason |
| 415 | * |
| 416 | * Return: 0 for success and negative error code for failure |
| 417 | */ |
| 418 | int pmo_core_psoc_clear_target_wake_up(struct wlan_objmgr_psoc *psoc); |
| 419 | |
| 420 | /** |
| 421 | * pmo_core_psoc_target_suspend_acknowledge() - update target susspend status |
| 422 | * @context: HTC_INIT_INFO->context |
| 423 | * @wow_nack: true when wow is rejected |
| 424 | * |
| 425 | * Return: none |
| 426 | */ |
| 427 | void pmo_core_psoc_target_suspend_acknowledge(void *context, bool wow_nack); |
| 428 | |
| 429 | /** |
| 430 | * pmo_core_psoc_wakeup_host_event_received() - received host wake up event |
| 431 | * @psoc: objmgr psoc handle |
| 432 | * |
| 433 | * Return: None |
| 434 | */ |
| 435 | void pmo_core_psoc_wakeup_host_event_received(struct wlan_objmgr_psoc *psoc); |
| 436 | |
| 437 | #endif /* end of _WLAN_PMO_SUSPEND_RESUME_H_ */ |