Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Ryan Hsu | e839f8f | 2016-01-08 09:57:17 -0800 | [diff] [blame] | 2 | * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * DOC: wlan_hdd_green_ap.c |
| 24 | * |
| 25 | * WLAN Host Device Driver Green AP implementation |
| 26 | * |
| 27 | */ |
| 28 | |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 29 | /* denote that this file does not allow legacy hddLog */ |
| 30 | #define HDD_DISALLOW_LEGACY_HDDLOG 1 |
| 31 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | /* Include Files */ |
| 33 | #include <wlan_hdd_main.h> |
| 34 | #include <wlan_hdd_misc.h> |
| 35 | #include "wlan_hdd_green_ap.h" |
| 36 | #include "wma_api.h" |
| 37 | #include "cds_concurrency.h" |
| 38 | |
| 39 | #define GREEN_AP_PS_ON_TIME (0) |
| 40 | #define GREEN_AP_PS_DELAY_TIME (20) |
| 41 | |
| 42 | /** |
| 43 | * enum hdd_green_ap_ps_state - Green-AP power save states |
| 44 | * @GREEN_AP_PS_IDLE_STATE: the Green_AP is not enabled |
| 45 | * @GREEN_AP_PS_OFF_STATE: in Power Saving OFF state |
| 46 | * @GREEN_AP_PS_WAIT_STATE: in transition to Power Saving ON state |
| 47 | * @GREEN_AP_PS_ON_STATE: in Power Saving ON state |
| 48 | */ |
| 49 | enum hdd_green_ap_ps_state { |
| 50 | GREEN_AP_PS_IDLE_STATE = 1, |
| 51 | GREEN_AP_PS_OFF_STATE, |
| 52 | GREEN_AP_PS_WAIT_STATE, |
| 53 | GREEN_AP_PS_ON_STATE, |
| 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * enum hdd_green_ap_event - Green-AP power save events |
| 58 | * @GREEN_AP_PS_START_EVENT: event to indicate to enable Green_AP |
| 59 | * @GREEN_AP_PS_START_EVENT: event to indicate to disable Green_AP |
| 60 | * @GREEN_AP_ADD_STA_EVENT: event to indicate a new STA connected |
| 61 | * @GREEN_AP_DEL_STA_EVENT: event to indicate a STA disconnected |
| 62 | * @GREEN_AP_PS_ON_EVENT: event to indicate to enter Power Saving state |
| 63 | * @GREEN_AP_PS_WAIT_EVENT: event to indicate in the transition to Power Saving |
| 64 | */ |
| 65 | enum hdd_green_ap_event { |
| 66 | GREEN_AP_PS_START_EVENT = 1, |
| 67 | GREEN_AP_PS_STOP_EVENT, |
| 68 | GREEN_AP_ADD_STA_EVENT, |
| 69 | GREEN_AP_DEL_STA_EVENT, |
| 70 | GREEN_AP_PS_ON_EVENT, |
| 71 | GREEN_AP_PS_WAIT_EVENT, |
| 72 | }; |
| 73 | |
| 74 | /** |
| 75 | * struct hdd_green_ap_ctx - Green-AP context |
| 76 | * @ps_enable: Whether or not Green AP is enabled |
| 77 | * @ps_on_time: Amount of time to stay in Green AP power saving state |
| 78 | * @ps_delay_time: Amount of time to delay when changing states |
| 79 | * @num_nodes: Number of connected clients |
| 80 | * @ps_state: Current state |
| 81 | * @ps_event: Event to trigger when timer expires |
| 82 | * @ps_timer: Event timer |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 83 | * @egap_support: Enhanced Green AP support flag |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | */ |
| 85 | struct hdd_green_ap_ctx { |
| 86 | uint8_t ps_enable; |
| 87 | uint32_t ps_on_time; |
| 88 | uint32_t ps_delay_time; |
| 89 | uint32_t num_nodes; |
| 90 | |
| 91 | enum hdd_green_ap_ps_state ps_state; |
| 92 | enum hdd_green_ap_event ps_event; |
| 93 | |
| 94 | cdf_mc_timer_t ps_timer; |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 95 | |
| 96 | bool egap_support; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | /** |
| 100 | * hdd_wlan_green_ap_update() - update the current State and Event |
| 101 | * @hdd_ctx: Global HDD context |
| 102 | * @state: New state |
| 103 | * @event: New event |
| 104 | * |
| 105 | * Return: none |
| 106 | */ |
| 107 | static void hdd_wlan_green_ap_update(struct hdd_context_s *hdd_ctx, |
| 108 | enum hdd_green_ap_ps_state state, |
| 109 | enum hdd_green_ap_event event) |
| 110 | { |
| 111 | struct hdd_green_ap_ctx *green_ap = hdd_ctx->green_ap_ctx; |
| 112 | |
| 113 | green_ap->ps_state = state; |
| 114 | green_ap->ps_event = event; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * hdd_wlan_green_ap_enable() - Send Green AP configuration to firmware |
| 119 | * @adapter: Adapter upon which Green AP is being configured |
| 120 | * @enable: Flag which indicates if Green AP is being enabled or disabled |
| 121 | * |
| 122 | * Return: 0 upon success, non-zero upon failure |
| 123 | */ |
| 124 | static int hdd_wlan_green_ap_enable(hdd_adapter_t *adapter, |
| 125 | uint8_t enable) |
| 126 | { |
| 127 | int ret; |
| 128 | |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 129 | hdd_notice("Set Green-AP val: %d", enable); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 130 | |
| 131 | ret = wma_cli_set_command(adapter->sessionId, |
| 132 | WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID, |
| 133 | enable, DBG_CMD); |
| 134 | |
| 135 | return ret; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * hdd_wlan_green_ap_mc() - Green AP state machine |
| 140 | * @hdd_ctx: HDD global context |
| 141 | * @event: New event being processed |
| 142 | * |
| 143 | * Return: none |
| 144 | */ |
| 145 | static void hdd_wlan_green_ap_mc(struct hdd_context_s *hdd_ctx, |
| 146 | enum hdd_green_ap_event event) |
| 147 | { |
| 148 | struct hdd_green_ap_ctx *green_ap; |
| 149 | hdd_adapter_t *adapter; |
| 150 | |
| 151 | green_ap = hdd_ctx->green_ap_ctx; |
| 152 | if (green_ap == NULL) |
| 153 | return; |
| 154 | |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 155 | hdd_notice("Green-AP event: %d, state: %d, num_nodes: %d", |
| 156 | event, green_ap->ps_state, green_ap->num_nodes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 157 | |
| 158 | /* handle the green ap ps event */ |
| 159 | switch (event) { |
| 160 | case GREEN_AP_PS_START_EVENT: |
| 161 | green_ap->ps_enable = 1; |
| 162 | break; |
| 163 | |
| 164 | case GREEN_AP_PS_STOP_EVENT: |
| 165 | if (!(cds_get_concurrency_mode() & CDF_SAP_MASK)) |
| 166 | green_ap->ps_enable = 0; |
| 167 | break; |
| 168 | |
| 169 | case GREEN_AP_ADD_STA_EVENT: |
| 170 | green_ap->num_nodes++; |
| 171 | break; |
| 172 | |
| 173 | case GREEN_AP_DEL_STA_EVENT: |
| 174 | if (green_ap->num_nodes) |
| 175 | green_ap->num_nodes--; |
| 176 | break; |
| 177 | |
| 178 | case GREEN_AP_PS_ON_EVENT: |
| 179 | case GREEN_AP_PS_WAIT_EVENT: |
| 180 | break; |
| 181 | |
| 182 | default: |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 183 | hdd_err("invalid event %d", event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 184 | break; |
| 185 | } |
| 186 | |
| 187 | /* Confirm that power save is enabled before doing state transitions */ |
| 188 | if (!green_ap->ps_enable) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 189 | hdd_notice("Green-AP is disabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 190 | hdd_wlan_green_ap_update(hdd_ctx, |
| 191 | GREEN_AP_PS_IDLE_STATE, |
| 192 | GREEN_AP_PS_WAIT_EVENT); |
| 193 | goto done; |
| 194 | } |
| 195 | |
| 196 | adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP); |
| 197 | if (adapter == NULL) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 198 | hdd_err("Green-AP no SAP adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 199 | goto done; |
| 200 | } |
| 201 | |
| 202 | /* handle the green ap ps state */ |
| 203 | switch (green_ap->ps_state) { |
| 204 | case GREEN_AP_PS_IDLE_STATE: |
| 205 | hdd_wlan_green_ap_update(hdd_ctx, |
| 206 | GREEN_AP_PS_OFF_STATE, |
| 207 | GREEN_AP_PS_WAIT_EVENT); |
| 208 | break; |
| 209 | |
| 210 | case GREEN_AP_PS_OFF_STATE: |
| 211 | if (!green_ap->num_nodes) { |
| 212 | hdd_wlan_green_ap_update(hdd_ctx, |
| 213 | GREEN_AP_PS_WAIT_STATE, |
| 214 | GREEN_AP_PS_WAIT_EVENT); |
| 215 | cdf_mc_timer_start(&green_ap->ps_timer, |
| 216 | green_ap->ps_delay_time); |
| 217 | } |
| 218 | break; |
| 219 | |
| 220 | case GREEN_AP_PS_WAIT_STATE: |
| 221 | if (!green_ap->num_nodes) { |
| 222 | hdd_wlan_green_ap_update(hdd_ctx, |
| 223 | GREEN_AP_PS_ON_STATE, |
| 224 | GREEN_AP_PS_WAIT_EVENT); |
| 225 | |
| 226 | hdd_wlan_green_ap_enable(adapter, 1); |
| 227 | |
| 228 | if (green_ap->ps_on_time) { |
| 229 | hdd_wlan_green_ap_update(hdd_ctx, |
| 230 | 0, |
| 231 | GREEN_AP_PS_WAIT_EVENT); |
| 232 | cdf_mc_timer_start(&green_ap->ps_timer, |
| 233 | green_ap->ps_on_time); |
| 234 | } |
| 235 | } else { |
| 236 | hdd_wlan_green_ap_update(hdd_ctx, |
| 237 | GREEN_AP_PS_OFF_STATE, |
| 238 | GREEN_AP_PS_WAIT_EVENT); |
| 239 | } |
| 240 | break; |
| 241 | |
| 242 | case GREEN_AP_PS_ON_STATE: |
| 243 | if (green_ap->num_nodes) { |
| 244 | if (hdd_wlan_green_ap_enable(adapter, 0)) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 245 | hdd_err("FAILED TO SET GREEN-AP mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 246 | goto done; |
| 247 | } |
| 248 | hdd_wlan_green_ap_update(hdd_ctx, |
| 249 | GREEN_AP_PS_OFF_STATE, |
| 250 | GREEN_AP_PS_WAIT_EVENT); |
| 251 | } else if ((green_ap->ps_event == GREEN_AP_PS_WAIT_EVENT) |
| 252 | && (green_ap->ps_on_time)) { |
| 253 | |
| 254 | /* ps_on_time timeout, switch to ps off */ |
| 255 | hdd_wlan_green_ap_update(hdd_ctx, |
| 256 | GREEN_AP_PS_WAIT_STATE, |
| 257 | GREEN_AP_PS_ON_EVENT); |
| 258 | |
| 259 | if (hdd_wlan_green_ap_enable(adapter, 0)) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 260 | hdd_err("FAILED TO SET GREEN-AP mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 261 | goto done; |
| 262 | } |
| 263 | |
| 264 | cdf_mc_timer_start(&green_ap->ps_timer, |
| 265 | green_ap->ps_delay_time); |
| 266 | } |
| 267 | break; |
| 268 | |
| 269 | default: |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 270 | hdd_err("invalid state %d", green_ap->ps_state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 271 | hdd_wlan_green_ap_update(hdd_ctx, GREEN_AP_PS_OFF_STATE, |
| 272 | GREEN_AP_PS_WAIT_EVENT); |
| 273 | break; |
| 274 | } |
| 275 | |
| 276 | done: |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * hdd_wlan_green_ap_timer_fn() - Green AP Timer handler |
| 282 | * @ctx: Global HDD context |
| 283 | * |
| 284 | * Return: none |
| 285 | */ |
| 286 | static void hdd_wlan_green_ap_timer_fn(void *ctx) |
| 287 | { |
| 288 | struct hdd_context_s *hdd_ctx = ctx; |
| 289 | struct hdd_green_ap_ctx *green_ap; |
| 290 | |
| 291 | if (0 != wlan_hdd_validate_context(hdd_ctx)) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 292 | hdd_err("HDD context is not valid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 293 | return; |
| 294 | } |
| 295 | |
| 296 | green_ap = hdd_ctx->green_ap_ctx; |
| 297 | if (green_ap) |
| 298 | hdd_wlan_green_ap_mc(hdd_ctx, green_ap->ps_event); |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * hdd_wlan_green_ap_attach() - Attach Green AP context to HDD context |
| 303 | * @hdd_ctx: Global HDD contect |
| 304 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 305 | * Return: QDF_STATUS_SUCCESS on success, otherwise CDF_STATUS_E_* error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 306 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 307 | static QDF_STATUS hdd_wlan_green_ap_attach(struct hdd_context_s *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 308 | { |
| 309 | struct hdd_green_ap_ctx *green_ap; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 310 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 311 | |
| 312 | ENTER(); |
| 313 | |
| 314 | green_ap = cdf_mem_malloc(sizeof(*green_ap)); |
| 315 | if (!green_ap) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 316 | hdd_alert("Memory allocation for Green-AP failed!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 317 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 318 | goto error; |
| 319 | } |
| 320 | |
| 321 | cdf_mem_zero(green_ap, sizeof(*green_ap)); |
| 322 | green_ap->ps_state = GREEN_AP_PS_OFF_STATE; |
| 323 | green_ap->ps_event = 0; |
| 324 | green_ap->num_nodes = 0; |
| 325 | green_ap->ps_on_time = GREEN_AP_PS_ON_TIME; |
| 326 | green_ap->ps_delay_time = GREEN_AP_PS_DELAY_TIME; |
| 327 | |
| 328 | cdf_mc_timer_init(&green_ap->ps_timer, |
| 329 | CDF_TIMER_TYPE_SW, |
| 330 | hdd_wlan_green_ap_timer_fn, hdd_ctx); |
| 331 | |
| 332 | error: |
| 333 | hdd_ctx->green_ap_ctx = green_ap; |
| 334 | |
| 335 | EXIT(); |
| 336 | return status; |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * hdd_wlan_green_ap_deattach() - Detach Green AP context from HDD context |
| 341 | * @hdd_ctx: Global HDD contect |
| 342 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 343 | * Return: QDF_STATUS_SUCCESS on success, otherwise CDF_STATUS_E_* error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 344 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 345 | static QDF_STATUS hdd_wlan_green_ap_deattach(struct hdd_context_s *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 346 | { |
| 347 | struct hdd_green_ap_ctx *green_ap = hdd_ctx->green_ap_ctx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 348 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 349 | |
| 350 | ENTER(); |
| 351 | |
| 352 | if (green_ap == NULL) { |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 353 | hdd_notice("Green-AP is not enabled"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 354 | status = QDF_STATUS_E_NOSUPPORT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 355 | goto done; |
| 356 | } |
| 357 | |
| 358 | /* check if the timer status is destroyed */ |
| 359 | if (CDF_TIMER_STATE_RUNNING == |
| 360 | cdf_mc_timer_get_current_state(&green_ap->ps_timer)) |
| 361 | cdf_mc_timer_stop(&green_ap->ps_timer); |
| 362 | |
| 363 | /* Destroy the Green AP timer */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 364 | if (!QDF_IS_STATUS_SUCCESS(cdf_mc_timer_destroy(&green_ap->ps_timer))) |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 365 | hdd_notice("Cannot deallocate Green-AP's timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 366 | |
| 367 | /* release memory */ |
| 368 | cdf_mem_zero(green_ap, sizeof(*green_ap)); |
| 369 | cdf_mem_free(green_ap); |
| 370 | hdd_ctx->green_ap_ctx = NULL; |
| 371 | |
| 372 | done: |
| 373 | |
| 374 | EXIT(); |
| 375 | return status; |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * hdd_wlan_green_ap_init() - Initialize Green AP feature |
| 380 | * @hdd_ctx: HDD global context |
| 381 | * |
| 382 | * Return: none |
| 383 | */ |
| 384 | void hdd_wlan_green_ap_init(struct hdd_context_s *hdd_ctx) |
| 385 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 386 | if (!QDF_IS_STATUS_SUCCESS(hdd_wlan_green_ap_attach(hdd_ctx))) |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 387 | hdd_err("Failed to allocate Green-AP resource"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | /** |
| 391 | * hdd_wlan_green_ap_deinit() - De-initialize Green AP feature |
| 392 | * @hdd_ctx: HDD global context |
| 393 | * |
| 394 | * Return: none |
| 395 | */ |
| 396 | void hdd_wlan_green_ap_deinit(struct hdd_context_s *hdd_ctx) |
| 397 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 398 | if (!QDF_IS_STATUS_SUCCESS(hdd_wlan_green_ap_deattach(hdd_ctx))) |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 399 | hdd_err("Cannot deallocate Green-AP resource"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | /** |
| 403 | * hdd_wlan_green_ap_start_bss() - Notify Green AP of Start BSS event |
| 404 | * @hdd_ctx: HDD global context |
| 405 | * |
| 406 | * Return: none |
| 407 | */ |
| 408 | void hdd_wlan_green_ap_start_bss(struct hdd_context_s *hdd_ctx) |
| 409 | { |
| 410 | struct hdd_config *cfg = hdd_ctx->config; |
| 411 | |
Ryan Hsu | cb118cf | 2015-11-09 16:03:53 -0800 | [diff] [blame] | 412 | /* check if the firmware and ini are both enabled the egap, |
| 413 | * and also the feature_flag enable, then we enable the egap |
| 414 | */ |
| 415 | if (hdd_ctx->green_ap_ctx->egap_support && cfg->enable_egap && |
| 416 | cfg->egap_feature_flag) { |
Ryan Hsu | e839f8f | 2016-01-08 09:57:17 -0800 | [diff] [blame] | 417 | hdd_notice("Set EGAP - enabled: %d, flag: %x, inact_time: %d, wait_time: %d", |
| 418 | cfg->enable_egap, cfg->egap_feature_flag, |
| 419 | cfg->egap_inact_time, cfg->egap_wait_time); |
Ryan Hsu | cb118cf | 2015-11-09 16:03:53 -0800 | [diff] [blame] | 420 | if (!sme_send_egap_conf_params(cfg->enable_egap, |
| 421 | cfg->egap_inact_time, |
| 422 | cfg->egap_wait_time, |
| 423 | cfg->egap_feature_flag)) { |
| 424 | /* EGAP is enabled, disable host GAP */ |
| 425 | hdd_wlan_green_ap_mc(hdd_ctx, GREEN_AP_PS_STOP_EVENT); |
| 426 | goto exit; |
| 427 | } |
| 428 | /* fall through, if send_egap_conf_params() failed, |
| 429 | * then check host GAP and enable it accordingly |
| 430 | */ |
| 431 | } |
| 432 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 433 | if (!(CDF_STA_MASK & hdd_ctx->concurrency_mode) && |
| 434 | cfg->enable2x2 && cfg->enableGreenAP) { |
| 435 | hdd_wlan_green_ap_mc(hdd_ctx, GREEN_AP_PS_START_EVENT); |
| 436 | } else { |
| 437 | hdd_wlan_green_ap_mc(hdd_ctx, GREEN_AP_PS_STOP_EVENT); |
Jeff Johnson | 417af55 | 2015-11-09 15:15:01 -0800 | [diff] [blame] | 438 | hdd_notice("Green-AP: is disabled, due to sta_concurrency: %d, enable2x2: %d, enableGreenAP: %d", |
| 439 | CDF_STA_MASK & hdd_ctx->concurrency_mode, |
| 440 | cfg->enable2x2, cfg->enableGreenAP); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 441 | } |
Ryan Hsu | cb118cf | 2015-11-09 16:03:53 -0800 | [diff] [blame] | 442 | exit: |
| 443 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | /** |
| 447 | * hdd_wlan_green_ap_stop_bss() - Notify Green AP of Stop BSS event |
| 448 | * @hdd_ctx: HDD global context |
| 449 | * |
| 450 | * Return: none |
| 451 | */ |
| 452 | void hdd_wlan_green_ap_stop_bss(struct hdd_context_s *hdd_ctx) |
| 453 | { |
| 454 | hdd_wlan_green_ap_mc(hdd_ctx, GREEN_AP_PS_STOP_EVENT); |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * hdd_wlan_green_ap_add_sta() - Notify Green AP of Add Station event |
| 459 | * @hdd_ctx: HDD global context |
| 460 | * |
| 461 | * Return: none |
| 462 | */ |
| 463 | void hdd_wlan_green_ap_add_sta(struct hdd_context_s *hdd_ctx) |
| 464 | { |
| 465 | hdd_wlan_green_ap_mc(hdd_ctx, GREEN_AP_ADD_STA_EVENT); |
| 466 | } |
| 467 | |
| 468 | /** |
| 469 | * hdd_wlan_green_ap_del_sta() - Notify Green AP of Delete Station event |
| 470 | * @hdd_ctx: HDD global context |
| 471 | * |
| 472 | * Return: none |
| 473 | */ |
| 474 | void hdd_wlan_green_ap_del_sta(struct hdd_context_s *hdd_ctx) |
| 475 | { |
| 476 | hdd_wlan_green_ap_mc(hdd_ctx, GREEN_AP_DEL_STA_EVENT); |
| 477 | } |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 478 | |
| 479 | /** |
| 480 | * hdd_wlan_set_egap_support() - helper function to set egap support flag |
| 481 | * @hdd_ctx: pointer to hdd context |
| 482 | * @param: pointer to target configuration |
| 483 | * |
| 484 | * Return: None |
| 485 | */ |
| 486 | void hdd_wlan_set_egap_support(hdd_context_t *hdd_ctx, void *param) |
| 487 | { |
| 488 | struct wma_tgt_cfg *cfg = (struct wma_tgt_cfg *) param; |
| 489 | |
| 490 | if (hdd_ctx && cfg) |
| 491 | hdd_ctx->green_ap_ctx->egap_support = cfg->egap_support; |
| 492 | } |