Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6 | /**============================================================================= |
| 7 | * wlan_hdd_early_suspend.c |
| 8 | * |
| 9 | * \brief power management functions |
| 10 | * |
| 11 | * Description |
| 12 | * Copyright 2009 (c) Qualcomm, Incorporated. |
| 13 | * All Rights Reserved. |
| 14 | * Qualcomm Confidential and Proprietary. |
| 15 | * |
| 16 | ==============================================================================**/ |
| 17 | /* $HEADER$ */ |
| 18 | |
| 19 | /**----------------------------------------------------------------------------- |
| 20 | * Include files |
| 21 | * ----------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 22 | |
| 23 | #include <linux/pm.h> |
| 24 | #include <linux/wait.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 25 | #include <wlan_hdd_includes.h> |
| 26 | #include <wlan_qct_driver.h> |
| 27 | #include <linux/wakelock.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | |
| 29 | #include "halTypes.h" |
| 30 | #include "sme_Api.h" |
| 31 | #include <vos_api.h> |
| 32 | #include "vos_power.h" |
| 33 | #include <vos_sched.h> |
| 34 | #include <macInitApi.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | #include <wlan_qct_sys.h> |
| 36 | #include <wlan_btc_svc.h> |
| 37 | #include <wlan_nlink_common.h> |
| 38 | #include <wlan_hdd_main.h> |
| 39 | #include <wlan_hdd_assoc.h> |
| 40 | #include <wlan_hdd_dev_pwr.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | #include <wlan_nlink_srv.h> |
| 42 | #include <wlan_hdd_misc.h> |
| 43 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | #include <linux/semaphore.h> |
| 45 | #include <wlan_hdd_hostapd.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 46 | #include "cfgApi.h" |
| 47 | |
| 48 | #ifdef WLAN_BTAMP_FEATURE |
| 49 | #include "bapApi.h" |
| 50 | #include "bap_hdd_main.h" |
| 51 | #include "bap_hdd_misc.h" |
| 52 | #endif |
| 53 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 54 | #include <linux/wcnss_wlan.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 55 | #include <linux/inetdevice.h> |
| 56 | #include <wlan_hdd_cfg.h> |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 57 | #include <wlan_hdd_cfg80211.h> |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 58 | #include <net/addrconf.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 59 | /**----------------------------------------------------------------------------- |
| 60 | * Preprocessor definitions and constants |
| 61 | * ----------------------------------------------------------------------------*/ |
| 62 | |
| 63 | /**----------------------------------------------------------------------------- |
| 64 | * Type declarations |
| 65 | * ----------------------------------------------------------------------------*/ |
| 66 | |
| 67 | /**----------------------------------------------------------------------------- |
| 68 | * Function and variables declarations |
| 69 | * ----------------------------------------------------------------------------*/ |
| 70 | #include "wlan_hdd_power.h" |
| 71 | #include "wlan_hdd_packet_filtering.h" |
| 72 | |
Sameer Thalappil | e5637f4 | 2013-08-07 15:46:55 -0700 | [diff] [blame] | 73 | #define HDD_SSR_BRING_UP_TIME 180000 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 74 | |
| 75 | static eHalStatus g_full_pwr_status; |
| 76 | static eHalStatus g_standby_status; |
| 77 | |
| 78 | extern VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx); |
| 79 | extern VOS_STATUS vos_chipExitDeepSleepVREGHandler( |
| 80 | vos_call_status_type* status, |
| 81 | vos_power_cb_type callback, |
| 82 | v_PVOID_t user_data); |
| 83 | extern void hdd_wlan_initial_scan(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 84 | |
| 85 | extern struct notifier_block hdd_netdev_notifier; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 86 | extern tVOS_CON_MODE hdd_get_conparam ( void ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 87 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 88 | static struct timer_list ssr_timer; |
| 89 | static bool ssr_timer_started; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 90 | |
| 91 | //Callback invoked by PMC to report status of standby request |
| 92 | void hdd_suspend_standby_cbk (void *callbackContext, eHalStatus status) |
| 93 | { |
| 94 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 95 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Standby status = %d", __func__, status); |
| 96 | g_standby_status = status; |
| 97 | |
| 98 | if(eHAL_STATUS_SUCCESS == status) |
| 99 | { |
| 100 | pHddCtx->hdd_ps_state = eHDD_SUSPEND_STANDBY; |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestStandby failed",__func__); |
| 105 | } |
| 106 | |
| 107 | complete(&pHddCtx->standby_comp_var); |
| 108 | } |
| 109 | |
| 110 | //Callback invoked by PMC to report status of full power request |
| 111 | void hdd_suspend_full_pwr_callback(void *callbackContext, eHalStatus status) |
| 112 | { |
| 113 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 114 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Full Power status = %d", __func__, status); |
| 115 | g_full_pwr_status = status; |
| 116 | |
| 117 | if(eHAL_STATUS_SUCCESS == status) |
| 118 | { |
| 119 | pHddCtx->hdd_ps_state = eHDD_SUSPEND_NONE; |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed",__func__); |
| 124 | } |
| 125 | |
| 126 | complete(&pHddCtx->full_pwr_comp_var); |
| 127 | } |
| 128 | |
| 129 | eHalStatus hdd_exit_standby(hdd_context_t *pHddCtx) |
| 130 | { |
| 131 | eHalStatus status = VOS_STATUS_SUCCESS; |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 132 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 133 | |
| 134 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed from standby",__func__); |
| 135 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 136 | |
| 137 | g_full_pwr_status = eHAL_STATUS_FAILURE; |
| 138 | status = sme_RequestFullPower(pHddCtx->hHal, hdd_suspend_full_pwr_callback, pHddCtx, |
| 139 | eSME_FULL_PWR_NEEDED_BY_HDD); |
| 140 | |
| 141 | if(status == eHAL_STATUS_PMC_PENDING) |
| 142 | { |
| 143 | //Block on a completion variable. Can't wait forever though |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 144 | ret = wait_for_completion_interruptible_timeout( |
| 145 | &pHddCtx->full_pwr_comp_var, |
| 146 | msecs_to_jiffies(WLAN_WAIT_TIME_FULL_PWR)); |
| 147 | if (0 >= ret) |
| 148 | { |
| 149 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on full_pwr_comp_var failed %ld", |
| 150 | __func__, ret); |
| 151 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 152 | status = g_full_pwr_status; |
| 153 | if(g_full_pwr_status != eHAL_STATUS_SUCCESS) |
| 154 | { |
| 155 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed",__func__); |
| 156 | VOS_ASSERT(0); |
| 157 | goto failure; |
| 158 | } |
| 159 | } |
| 160 | else if(status != eHAL_STATUS_SUCCESS) |
| 161 | { |
| 162 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed - status %d", |
| 163 | __func__, status); |
| 164 | VOS_ASSERT(0); |
| 165 | goto failure; |
| 166 | } |
| 167 | else |
| 168 | pHddCtx->hdd_ps_state = eHDD_SUSPEND_NONE; |
| 169 | |
| 170 | failure: |
| 171 | //No blocking to reduce latency. No other device should be depending on WLAN |
| 172 | //to finish resume and WLAN won't be instantly on after resume |
| 173 | return status; |
| 174 | } |
| 175 | |
| 176 | |
| 177 | //Helper routine to put the chip into standby |
| 178 | VOS_STATUS hdd_enter_standby(hdd_context_t *pHddCtx) |
| 179 | { |
| 180 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 181 | VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 182 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 183 | |
| 184 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 185 | //save mode on its own during suspend sequence |
| 186 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 187 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 188 | |
| 189 | //Note we do not disable queues unnecessarily. Queues should already be disabled |
| 190 | //if STA is disconnected or the queue will be disabled as and when disconnect |
| 191 | //happens because of standby procedure. |
| 192 | |
| 193 | //Ensure that device is in full power first. There is scope for optimization |
| 194 | //here especially in scenarios where PMC is already in IMPS or REQUEST_IMPS. |
| 195 | //Core s/w needs to be optimized to handle this. Until then we request full |
| 196 | //power before issuing request for standby. |
| 197 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 198 | g_full_pwr_status = eHAL_STATUS_FAILURE; |
| 199 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_suspend_full_pwr_callback, |
| 200 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 201 | |
| 202 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 203 | { |
| 204 | //Block on a completion variable. Can't wait forever though |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 205 | ret = wait_for_completion_interruptible_timeout( |
| 206 | &pHddCtx->full_pwr_comp_var, |
| 207 | msecs_to_jiffies(WLAN_WAIT_TIME_FULL_PWR)); |
| 208 | if (0 >= ret) |
| 209 | { |
| 210 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on full_pwr_comp_var failed %ld", |
| 211 | __func__, ret); |
| 212 | } |
| 213 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 214 | if(g_full_pwr_status != eHAL_STATUS_SUCCESS) |
| 215 | { |
| 216 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower Failed",__func__); |
| 217 | VOS_ASSERT(0); |
| 218 | vosStatus = VOS_STATUS_E_FAILURE; |
| 219 | goto failure; |
| 220 | } |
| 221 | } |
| 222 | else if(halStatus != eHAL_STATUS_SUCCESS) |
| 223 | { |
| 224 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed - status %d", |
| 225 | __func__, halStatus); |
| 226 | VOS_ASSERT(0); |
| 227 | vosStatus = VOS_STATUS_E_FAILURE; |
| 228 | goto failure; |
| 229 | } |
| 230 | |
| 231 | if(pHddCtx->hdd_mcastbcast_filter_set == TRUE) { |
| 232 | hdd_conf_mcastbcast_filter(pHddCtx, FALSE); |
| 233 | pHddCtx->hdd_mcastbcast_filter_set = FALSE; |
| 234 | } |
| 235 | |
| 236 | //Request standby. Standby will cause the STA to disassociate first. TX queues |
| 237 | //will be disabled (by HDD) when STA disconnects. You do not want to disable TX |
| 238 | //queues here. Also do not assert if the failure code is eHAL_STATUS_PMC_NOT_NOW as PMC |
| 239 | //will send this failure code in case of concurrent sessions. Power Save cannot be supported |
| 240 | //when there are concurrent sessions. |
| 241 | INIT_COMPLETION(pHddCtx->standby_comp_var); |
| 242 | g_standby_status = eHAL_STATUS_FAILURE; |
| 243 | halStatus = sme_RequestStandby(pHddCtx->hHal, hdd_suspend_standby_cbk, pHddCtx); |
| 244 | |
| 245 | if (halStatus == eHAL_STATUS_PMC_PENDING) |
| 246 | { |
| 247 | //Wait till WLAN device enters standby mode |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 248 | ret = wait_for_completion_timeout(&pHddCtx->standby_comp_var, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 249 | msecs_to_jiffies(WLAN_WAIT_TIME_STANDBY)); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 250 | if (0 >= ret) |
| 251 | { |
| 252 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 253 | FL("wait on standby_comp_var failed %ld"), ret); |
| 254 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 255 | if (g_standby_status != eHAL_STATUS_SUCCESS && g_standby_status != eHAL_STATUS_PMC_NOT_NOW) |
| 256 | { |
| 257 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestStandby failed",__func__); |
| 258 | VOS_ASSERT(0); |
| 259 | vosStatus = VOS_STATUS_E_FAILURE; |
| 260 | goto failure; |
| 261 | } |
| 262 | } |
| 263 | else if (halStatus != eHAL_STATUS_SUCCESS && halStatus != eHAL_STATUS_PMC_NOT_NOW) { |
| 264 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestStandby failed - status %d", |
| 265 | __func__, halStatus); |
| 266 | VOS_ASSERT(0); |
| 267 | vosStatus = VOS_STATUS_E_FAILURE; |
| 268 | goto failure; |
| 269 | } |
| 270 | else |
| 271 | pHddCtx->hdd_ps_state = eHDD_SUSPEND_STANDBY; |
| 272 | |
| 273 | failure: |
| 274 | //Restore IMPS config |
| 275 | if(pHddCtx->cfg_ini->fIsImpsEnabled) |
| 276 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 277 | |
| 278 | //Restore BMPS config |
| 279 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 280 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 281 | |
| 282 | return vosStatus; |
| 283 | } |
| 284 | |
| 285 | |
| 286 | //Helper routine for Deep sleep entry |
| 287 | VOS_STATUS hdd_enter_deep_sleep(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter) |
| 288 | { |
| 289 | eHalStatus halStatus; |
| 290 | VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; |
| 291 | vos_call_status_type callType; |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 292 | long ret; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 293 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 294 | //Stop the Interface TX queue. |
| 295 | netif_tx_disable(pAdapter->dev); |
| 296 | netif_carrier_off(pAdapter->dev); |
| 297 | |
| 298 | //Disable IMPS,BMPS as we do not want the device to enter any power |
| 299 | //save mode on it own during suspend sequence |
| 300 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 301 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 302 | |
| 303 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 304 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 305 | g_full_pwr_status = eHAL_STATUS_FAILURE; |
| 306 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_suspend_full_pwr_callback, |
| 307 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 308 | |
| 309 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 310 | { |
| 311 | //Block on a completion variable. Can't wait forever though |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 312 | ret = wait_for_completion_interruptible_timeout( |
| 313 | &pHddCtx->full_pwr_comp_var, |
| 314 | msecs_to_jiffies(WLAN_WAIT_TIME_FULL_PWR)); |
| 315 | if (0 >= ret) |
| 316 | { |
| 317 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 318 | FL("wait on full_pwr_comp_var failed %ld"), ret); |
| 319 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | if(g_full_pwr_status != eHAL_STATUS_SUCCESS){ |
| 321 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed",__func__); |
| 322 | VOS_ASSERT(0); |
| 323 | } |
| 324 | } |
| 325 | else if(halStatus != eHAL_STATUS_SUCCESS) |
| 326 | { |
| 327 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Request for Full Power failed",__func__); |
| 328 | VOS_ASSERT(0); |
| 329 | } |
| 330 | |
| 331 | //Issue a disconnect. This is required to inform the supplicant that |
| 332 | //STA is getting disassociated and for GUI to be updated properly |
| 333 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 334 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 335 | |
| 336 | //Success implies disconnect command got queued up successfully |
| 337 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 338 | { |
| 339 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 340 | ret = wait_for_completion_interruptible_timeout( |
| 341 | &pAdapter->disconnect_comp_var, |
| 342 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 343 | if (0 >= ret) |
| 344 | { |
| 345 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 346 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 347 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | |
| 351 | //None of the steps should fail after this. Continue even in case of failure |
| 352 | vosStatus = vos_stop( pHddCtx->pvosContext ); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 353 | if( !VOS_IS_STATUS_SUCCESS( vosStatus )) |
| 354 | { |
| 355 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: vos_stop return failed %d", |
| 356 | __func__, vosStatus); |
| 357 | VOS_ASSERT(0); |
| 358 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 359 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 360 | vosStatus = vos_chipAssertDeepSleep( &callType, NULL, NULL ); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 361 | if( VOS_IS_STATUS_SUCCESS( vosStatus )) |
| 362 | { |
| 363 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 364 | FL("vos_chipAssertDeepSleep return failed %d"), vosStatus); |
| 365 | VOS_ASSERT(0); |
| 366 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 367 | |
| 368 | //Vote off any PMIC voltage supplies |
| 369 | vosStatus = vos_chipPowerDown(NULL, NULL, NULL); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 370 | if( !VOS_IS_STATUS_SUCCESS( vosStatus )) |
| 371 | { |
| 372 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: vos_chipPowerDown return failed %d", |
| 373 | __func__, vosStatus); |
| 374 | VOS_ASSERT(0); |
| 375 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 376 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 377 | pHddCtx->hdd_ps_state = eHDD_SUSPEND_DEEP_SLEEP; |
| 378 | |
| 379 | //Restore IMPS config |
| 380 | if(pHddCtx->cfg_ini->fIsImpsEnabled) |
| 381 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 382 | |
| 383 | //Restore BMPS config |
| 384 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 385 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 386 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 387 | return vosStatus; |
| 388 | } |
| 389 | |
| 390 | VOS_STATUS hdd_exit_deep_sleep(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter) |
| 391 | { |
| 392 | VOS_STATUS vosStatus; |
| 393 | eHalStatus halStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 394 | |
| 395 | //Power Up Libra WLAN card first if not already powered up |
| 396 | vosStatus = vos_chipPowerUp(NULL,NULL,NULL); |
| 397 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 398 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 399 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN not Powered Up." |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 400 | "exiting", __func__); |
| 401 | goto err_deep_sleep; |
| 402 | } |
| 403 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 405 | "%s: calling hdd_set_sme_config",__func__); |
| 406 | vosStatus = hdd_set_sme_config( pHddCtx ); |
| 407 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 408 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 409 | { |
| 410 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 411 | "%s: Failed in hdd_set_sme_config",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 412 | goto err_deep_sleep; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 416 | "%s: calling vos_start",__func__); |
| 417 | vosStatus = vos_start( pHddCtx->pvosContext ); |
| 418 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 419 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 420 | { |
| 421 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 422 | "%s: Failed in vos_start",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 423 | goto err_deep_sleep; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 427 | "%s: calling hdd_post_voss_start_config",__func__); |
| 428 | vosStatus = hdd_post_voss_start_config( pHddCtx ); |
| 429 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 430 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 431 | { |
| 432 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 433 | "%s: Failed in hdd_post_voss_start_config",__func__); |
| 434 | goto err_voss_stop; |
| 435 | } |
| 436 | |
| 437 | |
| 438 | //Open a SME session for future operation |
| 439 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pHddCtx, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 440 | (tANI_U8 *)&pAdapter->macAddressCurrent, |
| 441 | &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 442 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 443 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 444 | hddLog(VOS_TRACE_LEVEL_FATAL,"sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 445 | halStatus, halStatus ); |
| 446 | goto err_voss_stop; |
| 447 | |
| 448 | } |
| 449 | |
| 450 | pHddCtx->hdd_ps_state = eHDD_SUSPEND_NONE; |
| 451 | |
| 452 | //Trigger the initial scan |
| 453 | hdd_wlan_initial_scan(pHddCtx); |
| 454 | |
| 455 | return VOS_STATUS_SUCCESS; |
| 456 | |
| 457 | err_voss_stop: |
| 458 | vos_stop(pHddCtx->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | err_deep_sleep: |
| 460 | return VOS_STATUS_E_FAILURE; |
| 461 | |
| 462 | } |
| 463 | |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 464 | /* |
| 465 | * Function: hdd_conf_hostoffload |
| 466 | * Central function to configure the supported offloads, |
| 467 | * either enable or disable them. |
| 468 | */ |
| 469 | void hdd_conf_hostoffload(hdd_adapter_t *pAdapter, v_BOOL_t fenable) |
| 470 | { |
| 471 | hdd_context_t *pHddCtx = NULL; |
| 472 | v_CONTEXT_t *pVosContext = NULL; |
| 473 | VOS_STATUS vstatus = VOS_STATUS_E_FAILURE; |
| 474 | |
| 475 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Configuring offloads with flag: %d"), |
| 476 | fenable); |
| 477 | |
| 478 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 479 | |
| 480 | if (NULL == pVosContext) |
| 481 | { |
| 482 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Global VOS context is Null")); |
| 483 | return; |
| 484 | } |
| 485 | |
| 486 | //Get the HDD context. |
| 487 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 488 | |
| 489 | if (NULL == pHddCtx) |
| 490 | { |
| 491 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HDD context is Null", __func__); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 496 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 497 | { |
| 498 | if (fenable) |
| 499 | { |
| 500 | if (eConnectionState_Associated == |
| 501 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) |
| 502 | { |
| 503 | if ((pHddCtx->cfg_ini->fhostArpOffload)) |
| 504 | { |
| 505 | /* |
| 506 | * Configure the ARP Offload. |
| 507 | * Even if it fails we have to reconfigure the MC/BC |
| 508 | * filter flag as we want RIVA not to drop BroadCast |
| 509 | * Packets |
| 510 | */ |
| 511 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 512 | FL("Calling ARP Offload with flag: %d"), fenable); |
| 513 | vstatus = hdd_conf_arp_offload(pAdapter, fenable); |
| 514 | pHddCtx->configuredMcastBcastFilter &= |
| 515 | ~(HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST); |
| 516 | |
| 517 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 518 | { |
| 519 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 520 | "Failed to enable ARPOFfloadFeature %d", |
| 521 | vstatus); |
| 522 | } |
| 523 | } |
| 524 | //Configure GTK_OFFLOAD |
| 525 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 526 | hdd_conf_gtk_offload(pAdapter, fenable); |
| 527 | #endif |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 528 | |
| 529 | #ifdef WLAN_NS_OFFLOAD |
| 530 | if (pHddCtx->cfg_ini->fhostNSOffload) |
| 531 | { |
| 532 | /* |
| 533 | * Configure the NS Offload. |
| 534 | * Even if it fails we have to reconfigure the MC/BC filter flag |
| 535 | * as we want RIVA not to drop Multicast Packets |
| 536 | */ |
| 537 | |
| 538 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 539 | FL("Calling NS Offload with flag: %d"), fenable); |
| 540 | hdd_conf_ns_offload(pAdapter, fenable); |
| 541 | pHddCtx->configuredMcastBcastFilter &= |
| 542 | ~(HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST); |
| 543 | } |
| 544 | #endif |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 545 | } |
| 546 | } |
| 547 | else |
| 548 | { |
| 549 | //Disable ARPOFFLOAD |
| 550 | if (pHddCtx->cfg_ini->fhostArpOffload) |
| 551 | { |
| 552 | vstatus = hdd_conf_arp_offload(pAdapter, fenable); |
| 553 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 554 | { |
| 555 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 556 | "Failed to disable ARPOffload Feature %d", vstatus); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | //Disable GTK_OFFLOAD |
| 560 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 561 | hdd_conf_gtk_offload(pAdapter, fenable); |
| 562 | #endif |
| 563 | |
| 564 | #ifdef WLAN_NS_OFFLOAD |
| 565 | //Disable NSOFFLOAD |
| 566 | if (pHddCtx->cfg_ini->fhostNSOffload) |
| 567 | { |
| 568 | hdd_conf_ns_offload(pAdapter, fenable); |
| 569 | } |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 570 | #endif |
| 571 | } |
| 572 | } |
| 573 | return; |
| 574 | } |
| 575 | |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 576 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 577 | void hdd_ipv6_notifier_work_queue(struct work_struct *work) |
| 578 | { |
| 579 | hdd_adapter_t* pAdapter = |
| 580 | container_of(work, hdd_adapter_t, ipv6NotifierWorkQueue); |
| 581 | hdd_context_t *pHddCtx; |
| 582 | int status; |
| 583 | |
| 584 | hddLog(LOG1, FL("Reconfiguring NS Offload")); |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 585 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 586 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 587 | status = wlan_hdd_validate_context(pHddCtx); |
| 588 | if (0 != status) |
| 589 | { |
| 590 | hddLog(LOGE, FL("HDD context is invalid")); |
| 591 | return; |
| 592 | } |
| 593 | |
Deepthi Gowri | 5933f40 | 2014-01-23 17:48:24 +0530 | [diff] [blame] | 594 | if ( VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid) |
| 595 | { |
| 596 | pHddCtx->sus_res_mcastbcast_filter = |
| 597 | pHddCtx->configuredMcastBcastFilter; |
| 598 | pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE; |
| 599 | } |
| 600 | |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 601 | if ((eConnectionState_Associated == |
| 602 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) |
Deepthi Gowri | 5933f40 | 2014-01-23 17:48:24 +0530 | [diff] [blame] | 603 | && (pHddCtx->hdd_wlan_suspended)) |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 604 | { |
| 605 | // This invocation being part of the IPv6 registration callback, |
| 606 | // we are passing second parameter as 2 to avoid registration |
| 607 | // of IPv6 notifier again. |
| 608 | hdd_conf_ns_offload(pAdapter, 2); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | static int wlan_hdd_ipv6_changed(struct notifier_block *nb, |
| 613 | unsigned long data, void *arg) |
| 614 | { |
| 615 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)arg; |
| 616 | struct net_device *ndev = ifa->idev->dev; |
| 617 | hdd_adapter_t *pAdapter = |
| 618 | container_of(nb, struct hdd_adapter_s, ipv6_notifier); |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 619 | hdd_context_t *pHddCtx; |
| 620 | int status; |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 621 | |
| 622 | if (pAdapter && pAdapter->dev == ndev) |
| 623 | { |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 624 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 625 | status = wlan_hdd_validate_context(pHddCtx); |
| 626 | if (0 != status) |
| 627 | { |
| 628 | hddLog(LOGE, FL("HDD context is invalid")); |
| 629 | return NOTIFY_DONE; |
| 630 | } |
| 631 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 632 | schedule_work(&pAdapter->ipv6NotifierWorkQueue); |
| 633 | } |
| 634 | |
| 635 | return NOTIFY_DONE; |
| 636 | } |
| 637 | |
| 638 | /**---------------------------------------------------------------------------- |
| 639 | |
| 640 | \brief hdd_conf_ns_offload() - Configure NS offload |
| 641 | |
| 642 | Called during SUSPEND to configure the NS offload (MC BC filter) which |
| 643 | reduces power consumption. |
| 644 | |
| 645 | \param - pAdapter - Adapter context for which NS offload is to be configured |
| 646 | \param - fenable - 0 - disable. |
| 647 | 1 - enable. (with IPv6 notifier registration) |
| 648 | 2 - enable. (without IPv6 notifier registration) |
| 649 | |
| 650 | \return - void |
| 651 | |
| 652 | ---------------------------------------------------------------------------*/ |
| 653 | void hdd_conf_ns_offload(hdd_adapter_t *pAdapter, int fenable) |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 654 | { |
| 655 | struct inet6_dev *in6_dev; |
| 656 | struct inet6_ifaddr *ifp; |
| 657 | struct list_head *p; |
| 658 | tANI_U8 selfIPv6Addr[SIR_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA][SIR_MAC_IPV6_ADDR_LEN] = {{0,}}; |
| 659 | tANI_BOOLEAN selfIPv6AddrValid[SIR_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA] = {0}; |
| 660 | tSirHostOffloadReq offLoadRequest; |
Madan Mohan Koyyalamudi | badffe7 | 2013-09-11 13:09:14 +0530 | [diff] [blame] | 661 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 662 | |
| 663 | int i =0; |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 664 | int ret =0; |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 665 | eHalStatus returnStatus; |
| 666 | |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 667 | ENTER(); |
| 668 | hddLog(LOG1, FL(" fenable = %d"), fenable); |
| 669 | |
Madan Mohan Koyyalamudi | badffe7 | 2013-09-11 13:09:14 +0530 | [diff] [blame] | 670 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 671 | |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 672 | if (fenable) |
| 673 | { |
| 674 | in6_dev = __in6_dev_get(pAdapter->dev); |
| 675 | if (NULL != in6_dev) |
| 676 | { |
| 677 | //read_lock_bh(&in6_dev->lock); |
| 678 | list_for_each(p, &in6_dev->addr_list) |
| 679 | { |
| 680 | ifp = list_entry(p, struct inet6_ifaddr, if_list); |
| 681 | switch(ipv6_addr_src_scope(&ifp->addr)) |
| 682 | { |
| 683 | case IPV6_ADDR_SCOPE_LINKLOCAL: |
| 684 | vos_mem_copy(&selfIPv6Addr[0], &ifp->addr.s6_addr, |
| 685 | sizeof(ifp->addr.s6_addr)); |
| 686 | selfIPv6AddrValid[0] = SIR_IPV6_ADDR_VALID; |
Hardik Kantilal Patel | 1341bdf | 2013-08-22 20:27:15 +0530 | [diff] [blame] | 687 | hddLog (VOS_TRACE_LEVEL_INFO, |
| 688 | "Found IPV6_ADDR_SCOPE_LINKLOCAL Address : %pI6", |
| 689 | selfIPv6Addr[0]); |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 690 | break; |
| 691 | case IPV6_ADDR_SCOPE_GLOBAL: |
| 692 | vos_mem_copy(&selfIPv6Addr[1], &ifp->addr.s6_addr, |
| 693 | sizeof(ifp->addr.s6_addr)); |
Hardik Kantilal Patel | 1341bdf | 2013-08-22 20:27:15 +0530 | [diff] [blame] | 694 | selfIPv6AddrValid[1] = SIR_IPV6_ADDR_VALID; |
| 695 | hddLog (VOS_TRACE_LEVEL_INFO, |
| 696 | "Found IPV6_ADDR_SCOPE_GLOBAL Address : %pI6", |
| 697 | selfIPv6Addr[1]); |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 698 | break; |
| 699 | default: |
| 700 | hddLog(LOGE, "The Scope %d is not supported", |
| 701 | ipv6_addr_src_scope(&ifp->addr)); |
| 702 | } |
| 703 | |
| 704 | } |
| 705 | //read_unlock_bh(&in6_dev->lock); |
| 706 | vos_mem_zero(&offLoadRequest, sizeof(offLoadRequest)); |
| 707 | for (i =0; i<SIR_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA; i++) |
| 708 | { |
| 709 | if (selfIPv6AddrValid[i]) |
| 710 | { |
| 711 | //Filling up the request structure |
| 712 | /* Filling the selfIPv6Addr with solicited address |
| 713 | * A Solicited-Node multicast address is created by |
| 714 | * taking the last 24 bits of a unicast or anycast |
| 715 | * address and appending them to the prefix |
| 716 | * |
| 717 | * FF02:0000:0000:0000:0000:0001:FFXX:XX |
| 718 | * |
| 719 | * here XX is the unicast/anycast bits |
| 720 | */ |
| 721 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[0] = 0xFF; |
| 722 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[1] = 0x02; |
| 723 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[11] = 0x01; |
| 724 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[12] = 0xFF; |
| 725 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[13] = selfIPv6Addr[i][13]; |
| 726 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[14] = selfIPv6Addr[i][14]; |
| 727 | offLoadRequest.nsOffloadInfo.selfIPv6Addr[15] = selfIPv6Addr[i][15]; |
| 728 | offLoadRequest.nsOffloadInfo.slotIdx = i; |
| 729 | |
| 730 | vos_mem_copy(&offLoadRequest.nsOffloadInfo.targetIPv6Addr[0], |
| 731 | &selfIPv6Addr[i][0], sizeof(tANI_U8)*SIR_MAC_IPV6_ADDR_LEN); |
| 732 | vos_mem_copy(&offLoadRequest.nsOffloadInfo.selfMacAddr, |
| 733 | &pAdapter->macAddressCurrent.bytes, |
| 734 | sizeof(tANI_U8)*SIR_MAC_ADDR_LEN); |
| 735 | |
| 736 | offLoadRequest.nsOffloadInfo.targetIPv6AddrValid[0] = SIR_IPV6_ADDR_VALID; |
| 737 | offLoadRequest.offloadType = SIR_IPV6_NS_OFFLOAD; |
| 738 | offLoadRequest.enableOrDisable = SIR_OFFLOAD_ENABLE; |
| 739 | |
Madan Mohan Koyyalamudi | badffe7 | 2013-09-11 13:09:14 +0530 | [diff] [blame] | 740 | hddLog (VOS_TRACE_LEVEL_INFO, |
| 741 | "configuredMcastBcastFilter: %d",pHddCtx->configuredMcastBcastFilter); |
| 742 | |
Kiet Lam | c8e1eb5 | 2013-10-24 00:30:49 +0530 | [diff] [blame] | 743 | if ((VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) |
| 744 | && ((HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST == |
| 745 | pHddCtx->sus_res_mcastbcast_filter) || |
| 746 | (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST == |
| 747 | pHddCtx->sus_res_mcastbcast_filter))) |
Madan Mohan Koyyalamudi | badffe7 | 2013-09-11 13:09:14 +0530 | [diff] [blame] | 748 | { |
| 749 | hddLog (VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 750 | "Set offLoadRequest with SIR_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE"); |
Madan Mohan Koyyalamudi | badffe7 | 2013-09-11 13:09:14 +0530 | [diff] [blame] | 751 | offLoadRequest.enableOrDisable = |
| 752 | SIR_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE; |
| 753 | } |
| 754 | |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 755 | vos_mem_copy(&offLoadRequest.params.hostIpv6Addr, |
| 756 | &offLoadRequest.nsOffloadInfo.targetIPv6Addr[0], |
| 757 | sizeof(tANI_U8)*SIR_MAC_IPV6_ADDR_LEN); |
| 758 | |
| 759 | hddLog (VOS_TRACE_LEVEL_INFO, |
| 760 | "Setting NSOffload with solicitedIp: %pI6, targetIp: %pI6", |
| 761 | offLoadRequest.nsOffloadInfo.selfIPv6Addr, |
| 762 | offLoadRequest.nsOffloadInfo.targetIPv6Addr[0]); |
| 763 | |
| 764 | //Configure the Firmware with this |
| 765 | returnStatus = sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 766 | pAdapter->sessionId, &offLoadRequest); |
| 767 | if(eHAL_STATUS_SUCCESS != returnStatus) |
| 768 | { |
| 769 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 770 | FL("Failed to enable HostOffload feature with status: %d"), |
| 771 | returnStatus); |
| 772 | } |
| 773 | vos_mem_zero(&offLoadRequest, sizeof(offLoadRequest)); |
| 774 | } |
| 775 | } |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 776 | if (fenable == 1 && !pAdapter->ipv6_notifier_registered) |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 777 | { |
| 778 | // Register IPv6 notifier to notify if any change in IP |
| 779 | // So that we can reconfigure the offload parameters |
| 780 | pAdapter->ipv6_notifier.notifier_call = |
| 781 | wlan_hdd_ipv6_changed; |
| 782 | ret = register_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 783 | if (ret) |
| 784 | { |
| 785 | hddLog(LOGE, FL("Failed to register IPv6 notifier")); |
| 786 | } |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 787 | else |
| 788 | { |
| 789 | hddLog(LOG1, FL("Registered IPv6 notifier")); |
| 790 | pAdapter->ipv6_notifier_registered = true; |
| 791 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 792 | } |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 793 | } |
| 794 | else |
| 795 | { |
| 796 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 797 | FL("IPv6 dev does not exist. Failed to request NSOffload")); |
| 798 | return; |
| 799 | } |
| 800 | } |
| 801 | else |
| 802 | { |
| 803 | //Disable NSOffload |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 804 | if (pAdapter->ipv6_notifier_registered) |
| 805 | { |
| 806 | hddLog(LOG1, FL("Unregistered IPv6 notifier")); |
| 807 | unregister_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 808 | pAdapter->ipv6_notifier_registered = false; |
| 809 | } |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 810 | vos_mem_zero((void *)&offLoadRequest, sizeof(tSirHostOffloadReq)); |
| 811 | offLoadRequest.enableOrDisable = SIR_OFFLOAD_DISABLE; |
| 812 | offLoadRequest.offloadType = SIR_IPV6_NS_OFFLOAD; |
| 813 | |
Vinay Krishna Eranna | b29c614 | 2014-01-07 12:20:51 +0530 | [diff] [blame] | 814 | //Disable NSOffload on all slots |
| 815 | for (i = 0; i<SIR_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA; i++) |
| 816 | { |
| 817 | offLoadRequest.nsOffloadInfo.slotIdx = i; |
| 818 | if (eHAL_STATUS_SUCCESS != |
Vinay Krishna Eranna | 911a3b8 | 2014-01-07 12:20:51 +0530 | [diff] [blame] | 819 | sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 820 | pAdapter->sessionId, &offLoadRequest)) |
Vinay Krishna Eranna | b29c614 | 2014-01-07 12:20:51 +0530 | [diff] [blame] | 821 | { |
| 822 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disable NSOflload" |
| 823 | " on slot %d"), i); |
| 824 | } |
| 825 | } |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 826 | } |
| 827 | return; |
| 828 | } |
| 829 | #endif |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 830 | |
| 831 | void hdd_ipv4_notifier_work_queue(struct work_struct *work) |
| 832 | { |
| 833 | hdd_adapter_t* pAdapter = |
| 834 | container_of(work, hdd_adapter_t, ipv4NotifierWorkQueue); |
| 835 | hdd_context_t *pHddCtx; |
| 836 | int status; |
| 837 | |
| 838 | hddLog(LOG1, FL("Reconfiguring ARP Offload")); |
| 839 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 840 | status = wlan_hdd_validate_context(pHddCtx); |
| 841 | if (0 != status) |
| 842 | { |
| 843 | hddLog(LOGE, FL("HDD context is invalid")); |
| 844 | return; |
| 845 | } |
| 846 | |
Deepthi Gowri | 5933f40 | 2014-01-23 17:48:24 +0530 | [diff] [blame] | 847 | if ( VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid) |
| 848 | { |
| 849 | pHddCtx->sus_res_mcastbcast_filter = |
| 850 | pHddCtx->configuredMcastBcastFilter; |
| 851 | pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE; |
| 852 | } |
| 853 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 854 | if ((eConnectionState_Associated == |
| 855 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) |
Deepthi Gowri | 5933f40 | 2014-01-23 17:48:24 +0530 | [diff] [blame] | 856 | && (pHddCtx->hdd_wlan_suspended)) |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 857 | { |
| 858 | // This invocation being part of the IPv4 registration callback, |
| 859 | // we are passing second parameter as 2 to avoid registration |
| 860 | // of IPv4 notifier again. |
| 861 | hdd_conf_arp_offload(pAdapter, 2); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | static int wlan_hdd_ipv4_changed(struct notifier_block *nb, |
| 866 | unsigned long data, void *arg) |
| 867 | { |
| 868 | struct in_ifaddr *ifa = (struct in_ifaddr *)arg; |
| 869 | struct in_ifaddr **ifap = NULL; |
| 870 | struct in_device *in_dev; |
| 871 | |
| 872 | struct net_device *ndev = ifa->ifa_dev->dev; |
| 873 | hdd_adapter_t *pAdapter = |
| 874 | container_of(nb, struct hdd_adapter_s, ipv4_notifier); |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 875 | hdd_context_t *pHddCtx; |
| 876 | int status; |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 877 | if (pAdapter && pAdapter->dev == ndev) |
| 878 | { |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 879 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 880 | status = wlan_hdd_validate_context(pHddCtx); |
| 881 | if (0 != status) |
| 882 | { |
| 883 | hddLog(LOGE, FL("HDD context is invalid")); |
| 884 | return NOTIFY_DONE; |
| 885 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 886 | if ((in_dev = __in_dev_get_rtnl(pAdapter->dev)) != NULL) |
| 887 | { |
| 888 | for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; |
| 889 | ifap = &ifa->ifa_next) |
| 890 | { |
| 891 | if (!strcmp(pAdapter->dev->name, ifa->ifa_label)) |
| 892 | { |
| 893 | break; /* found */ |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | if(ifa && ifa->ifa_local) |
| 898 | { |
| 899 | schedule_work(&pAdapter->ipv4NotifierWorkQueue); |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | return NOTIFY_DONE; |
| 904 | } |
| 905 | |
| 906 | /**---------------------------------------------------------------------------- |
| 907 | |
| 908 | \brief hdd_conf_arp_offload() - Configure ARP offload |
| 909 | |
| 910 | Called during SUSPEND to configure the ARP offload (MC BC filter) which |
| 911 | reduces power consumption. |
| 912 | |
| 913 | \param - pAdapter -Adapter context for which ARP offload is to be configured |
| 914 | \param - fenable - 0 - disable. |
| 915 | 1 - enable. (with IPv4 notifier registration) |
| 916 | 2 - enable. (without IPv4 notifier registration) |
| 917 | |
| 918 | \return - |
| 919 | VOS_STATUS_SUCCESS - on successful operation |
| 920 | VOS_STATUS_E_FAILURE - on failure of operation |
| 921 | -----------------------------------------------------------------------------*/ |
| 922 | VOS_STATUS hdd_conf_arp_offload(hdd_adapter_t *pAdapter, int fenable) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 923 | { |
| 924 | struct in_ifaddr **ifap = NULL; |
| 925 | struct in_ifaddr *ifa = NULL; |
| 926 | struct in_device *in_dev; |
| 927 | int i = 0; |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 928 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 929 | tSirHostOffloadReq offLoadRequest; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 930 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 931 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 932 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" fenable = %d \n"), fenable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 933 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 934 | if(fenable) |
| 935 | { |
| 936 | if ((in_dev = __in_dev_get_rtnl(pAdapter->dev)) != NULL) |
| 937 | { |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 938 | for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 939 | ifap = &ifa->ifa_next) |
| 940 | { |
| 941 | if (!strcmp(pAdapter->dev->name, ifa->ifa_label)) |
| 942 | { |
| 943 | break; /* found */ |
| 944 | } |
| 945 | } |
| 946 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 947 | if(ifa && ifa->ifa_local) |
| 948 | { |
| 949 | offLoadRequest.offloadType = SIR_IPV4_ARP_REPLY_OFFLOAD; |
| 950 | offLoadRequest.enableOrDisable = SIR_OFFLOAD_ENABLE; |
| 951 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 952 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Enabled", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 953 | |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 954 | if (((HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST == |
| 955 | pHddCtx->sus_res_mcastbcast_filter) || |
| 956 | (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST == |
| 957 | pHddCtx->sus_res_mcastbcast_filter)) && |
| 958 | (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)) |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 959 | { |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 960 | offLoadRequest.enableOrDisable = |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 961 | SIR_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE; |
| 962 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 963 | "offload: inside arp offload conditional check"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 964 | } |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 965 | |
| 966 | hddLog(VOS_TRACE_LEVEL_INFO, "offload: arp filter programmed = %d", |
| 967 | offLoadRequest.enableOrDisable); |
| 968 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 969 | //converting u32 to IPV4 address |
| 970 | for(i = 0 ; i < 4; i++) |
| 971 | { |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 972 | offLoadRequest.params.hostIpv4Addr[i] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 973 | (ifa->ifa_local >> (i*8) ) & 0xFF ; |
| 974 | } |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 975 | hddLog(VOS_TRACE_LEVEL_INFO, " Enable SME HostOffload: %d.%d.%d.%d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 976 | offLoadRequest.params.hostIpv4Addr[0], |
| 977 | offLoadRequest.params.hostIpv4Addr[1], |
| 978 | offLoadRequest.params.hostIpv4Addr[2], |
| 979 | offLoadRequest.params.hostIpv4Addr[3]); |
| 980 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 981 | if (eHAL_STATUS_SUCCESS != |
| 982 | sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 983 | pAdapter->sessionId, &offLoadRequest)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 984 | { |
| 985 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to enable HostOffload " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 986 | "feature", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 987 | return VOS_STATUS_E_FAILURE; |
| 988 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 989 | } |
| 990 | else |
| 991 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 992 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("IP Address is not assigned")); |
| 993 | return VOS_STATUS_E_AGAIN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 994 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 995 | |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 996 | if (fenable == 1 && !pAdapter->ipv4_notifier_registered) |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 997 | { |
| 998 | // Register IPv4 notifier to notify if any change in IP |
| 999 | // So that we can reconfigure the offload parameters |
| 1000 | pAdapter->ipv4_notifier.notifier_call = |
| 1001 | wlan_hdd_ipv4_changed; |
| 1002 | ret = register_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 1003 | if (ret) |
| 1004 | { |
| 1005 | hddLog(LOGE, FL("Failed to register IPv4 notifier")); |
| 1006 | } |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 1007 | else |
| 1008 | { |
| 1009 | hddLog(LOG1, FL("Registered IPv4 notifier")); |
| 1010 | pAdapter->ipv4_notifier_registered = true; |
| 1011 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 1012 | } |
| 1013 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1014 | } |
| 1015 | else |
| 1016 | { |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 1017 | if (pAdapter->ipv4_notifier_registered) |
| 1018 | { |
| 1019 | hddLog(LOG1, FL("Unregistered IPv4 notifier")); |
| 1020 | unregister_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 1021 | pAdapter->ipv4_notifier_registered = false; |
| 1022 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1023 | vos_mem_zero((void *)&offLoadRequest, sizeof(tSirHostOffloadReq)); |
| 1024 | offLoadRequest.enableOrDisable = SIR_OFFLOAD_DISABLE; |
| 1025 | offLoadRequest.offloadType = SIR_IPV4_ARP_REPLY_OFFLOAD; |
| 1026 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 1027 | if (eHAL_STATUS_SUCCESS != |
| 1028 | sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1029 | pAdapter->sessionId, &offLoadRequest)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1030 | { |
| 1031 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to disable host " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1032 | "offload feature", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1033 | return VOS_STATUS_E_FAILURE; |
| 1034 | } |
| 1035 | return VOS_STATUS_SUCCESS; |
| 1036 | } |
| 1037 | } |
| 1038 | |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1039 | /* |
| 1040 | * This function is called before setting mcbc filters |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1041 | * to modify filter value considering Different Offloads |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1042 | */ |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1043 | void hdd_mcbc_filter_modification(hdd_context_t* pHddCtx, |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1044 | tANI_U8 *pMcBcFilter) |
| 1045 | { |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1046 | if (NULL == pHddCtx) |
| 1047 | { |
| 1048 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("NULL HDD context passed")); |
| 1049 | return; |
| 1050 | } |
| 1051 | |
| 1052 | *pMcBcFilter = pHddCtx->configuredMcastBcastFilter; |
| 1053 | if (pHddCtx->cfg_ini->fhostArpOffload) |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1054 | { |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 1055 | /* ARP offload is enabled, do not block bcast packets at RXP |
| 1056 | * Will be using Bitmasking to reset the filter. As we have |
| 1057 | * disable Broadcast filtering, Anding with the negation |
| 1058 | * of Broadcast BIT |
| 1059 | */ |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1060 | *pMcBcFilter &= ~(HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST); |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1061 | } |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1062 | |
| 1063 | #ifdef WLAN_NS_OFFLOAD |
| 1064 | if (pHddCtx->cfg_ini->fhostNSOffload) |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1065 | { |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1066 | /* NS offload is enabled, do not block mcast packets at RXP |
| 1067 | * Will be using Bitmasking to reset the filter. As we have |
| 1068 | * disable Multicast filtering, Anding with the negation |
| 1069 | * of Multicast BIT |
| 1070 | */ |
| 1071 | *pMcBcFilter &= ~(HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST); |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1072 | } |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1073 | #endif |
| 1074 | |
| 1075 | pHddCtx->configuredMcastBcastFilter = *pMcBcFilter; |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1076 | } |
| 1077 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1078 | void hdd_conf_mcastbcast_filter(hdd_context_t* pHddCtx, v_BOOL_t setfilter) |
| 1079 | { |
| 1080 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | tpSirWlanSetRxpFilters wlanRxpFilterParam = |
| 1082 | vos_mem_malloc(sizeof(tSirWlanSetRxpFilters)); |
| 1083 | if(NULL == wlanRxpFilterParam) |
| 1084 | { |
| 1085 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1086 | "%s: vos_mem_alloc failed ", __func__); |
| 1087 | return; |
| 1088 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1089 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1090 | "%s: Configuring Mcast/Bcast Filter Setting. setfilter %d", __func__, setfilter); |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1091 | if (TRUE == setfilter) |
| 1092 | { |
Gopichand Nakkala | 746a945 | 2013-06-11 12:45:54 +0530 | [diff] [blame] | 1093 | hdd_mcbc_filter_modification(pHddCtx, |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1094 | &wlanRxpFilterParam->configuredMcstBcstFilterSetting); |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1095 | } |
| 1096 | else |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 1097 | { |
| 1098 | /*Use the current configured value to clear*/ |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1099 | wlanRxpFilterParam->configuredMcstBcstFilterSetting = |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 1100 | pHddCtx->configuredMcastBcastFilter; |
| 1101 | } |
Gopichand Nakkala | b8ddf46 | 2013-02-20 18:53:50 +0530 | [diff] [blame] | 1102 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1103 | wlanRxpFilterParam->setMcstBcstFilter = setfilter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1104 | halStatus = sme_ConfigureRxpFilter(pHddCtx->hHal, wlanRxpFilterParam); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1105 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 1106 | vos_mem_free(wlanRxpFilterParam); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1107 | if(setfilter && (eHAL_STATUS_SUCCESS == halStatus)) |
| 1108 | pHddCtx->hdd_mcastbcast_filter_set = TRUE; |
| 1109 | } |
| 1110 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1111 | static void hdd_conf_suspend_ind(hdd_context_t* pHddCtx, |
| 1112 | hdd_adapter_t *pAdapter) |
| 1113 | { |
| 1114 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
| 1115 | tpSirWlanSuspendParam wlanSuspendParam = |
| 1116 | vos_mem_malloc(sizeof(tSirWlanSuspendParam)); |
| 1117 | |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 1118 | if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid) { |
| 1119 | pHddCtx->sus_res_mcastbcast_filter = |
| 1120 | pHddCtx->configuredMcastBcastFilter; |
| 1121 | pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE; |
| 1122 | hddLog(VOS_TRACE_LEVEL_INFO, "offload: hdd_conf_suspend_ind"); |
| 1123 | hddLog(VOS_TRACE_LEVEL_INFO, "configuredMCastBcastFilter saved = %d", |
| 1124 | pHddCtx->configuredMcastBcastFilter); |
| 1125 | |
| 1126 | } |
| 1127 | |
Amar Singhal | 49fdfd5 | 2013-08-13 13:25:12 -0700 | [diff] [blame] | 1128 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1129 | if(NULL == wlanSuspendParam) |
| 1130 | { |
| 1131 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1132 | "%s: vos_mem_alloc failed ", __func__); |
| 1133 | return; |
| 1134 | } |
| 1135 | |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 1136 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1137 | "%s: send wlan suspend indication", __func__); |
| 1138 | |
| 1139 | if((pHddCtx->cfg_ini->nEnableSuspend == WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER)) |
| 1140 | { |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1141 | //Configure supported OffLoads |
| 1142 | hdd_conf_hostoffload(pAdapter, TRUE); |
| 1143 | wlanSuspendParam->configuredMcstBcstFilterSetting = pHddCtx->configuredMcastBcastFilter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1144 | |
| 1145 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
madan mohan koyyalamudi | bfd9cef | 2013-07-01 18:39:37 +0530 | [diff] [blame] | 1146 | /* During suspend, configure MC Addr list filter to the firmware |
| 1147 | * function takes care of checking necessary conditions before |
| 1148 | * configuring. |
| 1149 | */ |
| 1150 | wlan_hdd_set_mc_addr_list(pAdapter, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1151 | #endif |
| 1152 | } |
| 1153 | |
| 1154 | halStatus = sme_ConfigureSuspendInd(pHddCtx->hHal, wlanSuspendParam); |
| 1155 | if(eHAL_STATUS_SUCCESS == halStatus) |
| 1156 | { |
| 1157 | pHddCtx->hdd_mcastbcast_filter_set = TRUE; |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1158 | } else { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1159 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1160 | FL("sme_ConfigureSuspendInd returned failure %d"), halStatus); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1161 | vos_mem_free(wlanSuspendParam); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1162 | } |
| 1163 | } |
| 1164 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 1165 | static void hdd_conf_resume_ind(hdd_adapter_t *pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1166 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1167 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 1168 | hdd_context_t* pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1169 | tpSirWlanResumeParam wlanResumeParam; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1170 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 1171 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1172 | "%s: send wlan resume indication", __func__); |
| 1173 | |
Madan Mohan Koyyalamudi | a6d7eab | 2013-09-25 10:21:22 +0530 | [diff] [blame] | 1174 | wlanResumeParam = vos_mem_malloc(sizeof(tSirWlanResumeParam)); |
| 1175 | |
| 1176 | if (NULL == wlanResumeParam) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1177 | { |
Madan Mohan Koyyalamudi | a6d7eab | 2013-09-25 10:21:22 +0530 | [diff] [blame] | 1178 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1179 | "%s: memory allocation failed for wlanResumeParam ", __func__); |
| 1180 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1181 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1182 | |
Madan Mohan Koyyalamudi | a6d7eab | 2013-09-25 10:21:22 +0530 | [diff] [blame] | 1183 | //Disable supported OffLoads |
| 1184 | hdd_conf_hostoffload(pAdapter, FALSE); |
| 1185 | |
| 1186 | wlanResumeParam->configuredMcstBcstFilterSetting = |
| 1187 | pHddCtx->configuredMcastBcastFilter; |
| 1188 | halStatus = sme_ConfigureResumeReq(pHddCtx->hHal, wlanResumeParam); |
| 1189 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 1190 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1191 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1192 | "%s: sme_ConfigureResumeReq return failure %d", __func__, halStatus); |
Madan Mohan Koyyalamudi | a6d7eab | 2013-09-25 10:21:22 +0530 | [diff] [blame] | 1193 | vos_mem_free(wlanResumeParam); |
| 1194 | } |
| 1195 | |
| 1196 | pHddCtx->hdd_mcastbcast_filter_set = FALSE; |
| 1197 | |
Amar Singhal | f8ba2b8 | 2013-12-02 12:54:38 -0800 | [diff] [blame] | 1198 | if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) { |
| 1199 | pHddCtx->configuredMcastBcastFilter = |
| 1200 | pHddCtx->sus_res_mcastbcast_filter; |
| 1201 | pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE; |
| 1202 | } |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 1203 | |
| 1204 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1205 | "offload: in hdd_conf_resume_ind, restoring configuredMcastBcastFilter"); |
| 1206 | hddLog(VOS_TRACE_LEVEL_INFO, "configuredMcastBcastFilter = %d", |
| 1207 | pHddCtx->configuredMcastBcastFilter); |
Amar Singhal | 49fdfd5 | 2013-08-13 13:25:12 -0700 | [diff] [blame] | 1208 | |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 1209 | |
madan mohan koyyalamudi | bfd9cef | 2013-07-01 18:39:37 +0530 | [diff] [blame] | 1210 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 1211 | /* Filer was applied during suspend inditication |
| 1212 | * clear it when we resume. |
| 1213 | */ |
| 1214 | wlan_hdd_set_mc_addr_list(pAdapter, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1215 | #endif |
| 1216 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1217 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1218 | //Suspend routine registered with Android OS |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1219 | void hdd_suspend_wlan(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1220 | { |
| 1221 | hdd_context_t *pHddCtx = NULL; |
| 1222 | v_CONTEXT_t pVosContext = NULL; |
| 1223 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1224 | VOS_STATUS status; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 1225 | hdd_adapter_t *pAdapter = NULL; |
| 1226 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
madan mohan koyyalamudi | 459d6e7 | 2013-07-09 23:36:00 +0530 | [diff] [blame] | 1227 | bool hdd_enter_bmps = FALSE; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 1228 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1229 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being suspended by Android OS",__func__); |
| 1230 | |
| 1231 | //Get the global VOSS context. |
| 1232 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1233 | if(!pVosContext) { |
| 1234 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 1235 | return; |
| 1236 | } |
| 1237 | |
| 1238 | //Get the HDD context. |
| 1239 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 1240 | |
| 1241 | if(!pHddCtx) { |
| 1242 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 1243 | return; |
| 1244 | } |
| 1245 | |
| 1246 | if (pHddCtx->isLogpInProgress) { |
| 1247 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1248 | "%s: Ignore suspend wlan, LOGP in progress!", __func__); |
| 1249 | return; |
| 1250 | } |
| 1251 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 1252 | hdd_set_pwrparams(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1253 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1254 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1255 | { |
| 1256 | pAdapter = pAdapterNode->pAdapter; |
| 1257 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
Madan Mohan Koyyalamudi | 802d758 | 2012-10-31 14:19:40 -0700 | [diff] [blame] | 1258 | && (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1259 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
| 1260 | |
Madan Mohan Koyyalamudi | 802d758 | 2012-10-31 14:19:40 -0700 | [diff] [blame] | 1261 | { // we skip this registration for modes other than STA, SAP and P2P client modes. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1262 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1263 | pAdapterNode = pNext; |
| 1264 | continue; |
| 1265 | } |
madan mohan koyyalamudi | 459d6e7 | 2013-07-09 23:36:00 +0530 | [diff] [blame] | 1266 | /* Avoid multiple enter/exit BMPS in this while loop using |
| 1267 | * hdd_enter_bmps flag |
| 1268 | */ |
| 1269 | if (FALSE == hdd_enter_bmps && (BMPS == pmcGetPmcState(pHddCtx->hHal))) |
| 1270 | { |
| 1271 | hdd_enter_bmps = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1272 | |
madan mohan koyyalamudi | 459d6e7 | 2013-07-09 23:36:00 +0530 | [diff] [blame] | 1273 | /* If device was already in BMPS, and dynamic DTIM is set, |
| 1274 | * exit(set the device to full power) and enter BMPS again |
| 1275 | * to reflect new DTIM value */ |
| 1276 | wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE); |
| 1277 | |
| 1278 | wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO); |
| 1279 | |
| 1280 | pHddCtx->hdd_ignore_dtim_enabled = TRUE; |
| 1281 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1282 | #ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP |
| 1283 | if (pHddCtx->cfg_ini->nEnableSuspend == WLAN_MAP_SUSPEND_TO_STANDBY) |
| 1284 | { |
| 1285 | //stop the interface before putting the chip to standby |
| 1286 | netif_tx_disable(pAdapter->dev); |
| 1287 | netif_carrier_off(pAdapter->dev); |
| 1288 | } |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 1289 | else if (pHddCtx->cfg_ini->nEnableSuspend == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1290 | WLAN_MAP_SUSPEND_TO_DEEP_SLEEP) |
| 1291 | { |
| 1292 | //Execute deep sleep procedure |
| 1293 | hdd_enter_deep_sleep(pHddCtx, pAdapter); |
| 1294 | } |
| 1295 | #endif |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 1296 | |
| 1297 | /*Suspend notification sent down to driver*/ |
| 1298 | hdd_conf_suspend_ind(pHddCtx, pAdapter); |
| 1299 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 1300 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1301 | pAdapterNode = pNext; |
| 1302 | } |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 1303 | pHddCtx->hdd_wlan_suspended = TRUE; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 1304 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1305 | #ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP |
| 1306 | if(pHddCtx->cfg_ini->nEnableSuspend == WLAN_MAP_SUSPEND_TO_STANDBY) |
| 1307 | { |
| 1308 | hdd_enter_standby(pHddCtx); |
| 1309 | } |
| 1310 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1311 | |
| 1312 | return; |
| 1313 | } |
| 1314 | |
| 1315 | static void hdd_PowerStateChangedCB |
| 1316 | ( |
| 1317 | v_PVOID_t callbackContext, |
| 1318 | tPmcState newState |
| 1319 | ) |
| 1320 | { |
| 1321 | hdd_context_t *pHddCtx = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1322 | /* if the driver was not in BMPS during early suspend, |
| 1323 | * the dynamic DTIM is now updated at Riva */ |
| 1324 | if ((newState == BMPS) && pHddCtx->hdd_wlan_suspended |
| 1325 | && pHddCtx->cfg_ini->enableDynamicDTIM |
| 1326 | && (pHddCtx->hdd_ignore_dtim_enabled == FALSE)) |
| 1327 | { |
| 1328 | pHddCtx->hdd_ignore_dtim_enabled = TRUE; |
| 1329 | } |
| 1330 | spin_lock(&pHddCtx->filter_lock); |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1331 | if ((newState == BMPS) && pHddCtx->hdd_wlan_suspended) |
| 1332 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1333 | spin_unlock(&pHddCtx->filter_lock); |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1334 | if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid) |
| 1335 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 1336 | pHddCtx->sus_res_mcastbcast_filter = |
| 1337 | pHddCtx->configuredMcastBcastFilter; |
| 1338 | pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE; |
| 1339 | |
| 1340 | hddLog(VOS_TRACE_LEVEL_INFO, "offload: callback to associated"); |
| 1341 | hddLog(VOS_TRACE_LEVEL_INFO, "saving configuredMcastBcastFilter = %d", |
| 1342 | pHddCtx->configuredMcastBcastFilter); |
| 1343 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1344 | "offload: calling hdd_conf_mcastbcast_filter"); |
| 1345 | |
| 1346 | } |
| 1347 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1348 | hdd_conf_mcastbcast_filter(pHddCtx, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1349 | if(pHddCtx->hdd_mcastbcast_filter_set != TRUE) |
| 1350 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not able to set mcast/bcast filter ", __func__); |
| 1351 | } |
Amar Singhal | 49fdfd5 | 2013-08-13 13:25:12 -0700 | [diff] [blame] | 1352 | else |
Mihir Shete | 793209f | 2014-01-06 11:01:12 +0530 | [diff] [blame] | 1353 | { |
| 1354 | /* Android framework can send resume request when the WCN chip is |
| 1355 | * in IMPS mode. When the chip exits IMPS mode the firmware will |
| 1356 | * restore all the registers to the state they were before the chip |
| 1357 | * entered IMPS and so our hardware filter settings confgured by the |
| 1358 | * resume request will be lost. So reconfigure the filters on detecting |
| 1359 | * a change in the power state of the WCN chip. |
| 1360 | */ |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1361 | spin_unlock(&pHddCtx->filter_lock); |
Mihir Shete | 793209f | 2014-01-06 11:01:12 +0530 | [diff] [blame] | 1362 | if (IMPS != newState) |
| 1363 | { |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1364 | spin_lock(&pHddCtx->filter_lock); |
Mihir Shete | 793209f | 2014-01-06 11:01:12 +0530 | [diff] [blame] | 1365 | if (FALSE == pHddCtx->hdd_wlan_suspended) |
| 1366 | { |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1367 | spin_unlock(&pHddCtx->filter_lock); |
Mihir Shete | 793209f | 2014-01-06 11:01:12 +0530 | [diff] [blame] | 1368 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1369 | "Not in IMPS/BMPS and suspended state"); |
| 1370 | hdd_conf_mcastbcast_filter(pHddCtx, FALSE); |
| 1371 | } |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1372 | else |
| 1373 | { |
| 1374 | spin_unlock(&pHddCtx->filter_lock); |
| 1375 | } |
Mihir Shete | 793209f | 2014-01-06 11:01:12 +0530 | [diff] [blame] | 1376 | } |
Agarwal Ashish | 469b1e5 | 2014-01-17 09:13:10 +0530 | [diff] [blame] | 1377 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1378 | } |
| 1379 | |
| 1380 | |
| 1381 | |
| 1382 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx) |
| 1383 | { |
| 1384 | v_CONTEXT_t pVosContext; |
| 1385 | tHalHandle smeContext; |
| 1386 | |
| 1387 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1388 | if (NULL == pVosContext) |
| 1389 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1390 | hddLog(LOGE, "%s: Invalid pContext", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1391 | return; |
| 1392 | } |
| 1393 | smeContext = vos_get_context(VOS_MODULE_ID_SME, pVosContext); |
| 1394 | if (NULL == smeContext) |
| 1395 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1396 | hddLog(LOGE, "%s: Invalid smeContext", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1397 | return; |
| 1398 | } |
| 1399 | |
| 1400 | spin_lock_init(&pHddCtx->filter_lock); |
| 1401 | if (WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER == |
| 1402 | pHddCtx->cfg_ini->nEnableSuspend) |
| 1403 | { |
| 1404 | pmcRegisterDeviceStateUpdateInd(smeContext, |
| 1405 | hdd_PowerStateChangedCB, pHddCtx); |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx) |
| 1410 | { |
| 1411 | v_CONTEXT_t pVosContext; |
| 1412 | tHalHandle smeContext; |
| 1413 | |
| 1414 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1415 | if (NULL == pVosContext) |
| 1416 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1417 | hddLog(LOGE, "%s: Invalid pContext", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1418 | return; |
| 1419 | } |
| 1420 | smeContext = vos_get_context(VOS_MODULE_ID_SME, pVosContext); |
| 1421 | if (NULL == smeContext) |
| 1422 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1423 | hddLog(LOGE, "%s: Invalid smeContext", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1424 | return; |
| 1425 | } |
| 1426 | |
| 1427 | if (WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER == |
| 1428 | pHddCtx->cfg_ini->nEnableSuspend) |
| 1429 | { |
| 1430 | pmcDeregisterDeviceStateUpdateInd(smeContext, hdd_PowerStateChangedCB); |
| 1431 | } |
| 1432 | } |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1433 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1434 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1435 | void hdd_conf_gtk_offload(hdd_adapter_t *pAdapter, v_BOOL_t fenable) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1436 | { |
| 1437 | eHalStatus ret; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 1438 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1439 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1440 | |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1441 | if(fenable) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1442 | { |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1443 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 1444 | (GTK_OFFLOAD_ENABLE == pHddStaCtx->gtkOffloadReqParams.ulFlags )) |
| 1445 | { |
| 1446 | vos_mem_copy(&hddGtkOffloadReqParams, |
| 1447 | &pHddStaCtx->gtkOffloadReqParams, |
| 1448 | sizeof (tSirGtkOffloadParams)); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 1449 | |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1450 | ret = sme_SetGTKOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1451 | &hddGtkOffloadReqParams, pAdapter->sessionId); |
| 1452 | if (eHAL_STATUS_SUCCESS != ret) |
| 1453 | { |
| 1454 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1455 | "%s: sme_SetGTKOffload failed, returned %d", |
| 1456 | __func__, ret); |
| 1457 | return; |
| 1458 | } |
| 1459 | |
| 1460 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1461 | "%s: sme_SetGTKOffload successfull", __func__); |
| 1462 | } |
| 1463 | |
| 1464 | } |
| 1465 | else |
| 1466 | { |
| 1467 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 1468 | (0 == memcmp(&pHddStaCtx->gtkOffloadReqParams.bssId, |
| 1469 | &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN)) && |
| 1470 | (GTK_OFFLOAD_ENABLE == pHddStaCtx->gtkOffloadReqParams.ulFlags)) |
| 1471 | { |
| 1472 | |
| 1473 | /* Host driver has previously offloaded GTK rekey */ |
| 1474 | ret = sme_GetGTKOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1475 | wlan_hdd_cfg80211_update_replayCounterCallback, |
| 1476 | pAdapter, pAdapter->sessionId); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1477 | if (eHAL_STATUS_SUCCESS != ret) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1478 | |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1479 | { |
| 1480 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1481 | "%s: sme_GetGTKOffload failed, returned %d", |
| 1482 | __func__, ret); |
| 1483 | return; |
| 1484 | } |
| 1485 | else |
| 1486 | { |
| 1487 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1488 | "%s: sme_GetGTKOffload successful", |
| 1489 | __func__); |
| 1490 | |
| 1491 | /* Sending GTK offload dissable */ |
| 1492 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 1493 | sizeof (tSirGtkOffloadParams)); |
| 1494 | hddGtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
| 1495 | ret = sme_SetGTKOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 1496 | &hddGtkOffloadReqParams, pAdapter->sessionId); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1497 | if (eHAL_STATUS_SUCCESS != ret) |
| 1498 | { |
| 1499 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1500 | "%s: failed to dissable GTK offload, returned %d", |
| 1501 | __func__, ret); |
| 1502 | return; |
| 1503 | } |
| 1504 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1505 | "%s: successfully dissabled GTK offload request to HAL", |
| 1506 | __func__); |
| 1507 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1508 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1509 | } |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 1510 | return; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1511 | } |
| 1512 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1513 | |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1514 | void hdd_resume_wlan(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1515 | { |
| 1516 | hdd_context_t *pHddCtx = NULL; |
| 1517 | hdd_adapter_t *pAdapter = NULL; |
| 1518 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1519 | VOS_STATUS status; |
| 1520 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 1521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1522 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed by Android OS",__func__); |
| 1523 | |
| 1524 | //Get the global VOSS context. |
| 1525 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1526 | if(!pVosContext) { |
| 1527 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 1528 | return; |
| 1529 | } |
| 1530 | |
| 1531 | //Get the HDD context. |
| 1532 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 1533 | |
| 1534 | if(!pHddCtx) { |
| 1535 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 1536 | return; |
| 1537 | } |
| 1538 | |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 1539 | if (pHddCtx->isLogpInProgress) |
| 1540 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1541 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1542 | "%s: Ignore resume wlan, LOGP in progress!", __func__); |
| 1543 | return; |
| 1544 | } |
| 1545 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1546 | pHddCtx->hdd_wlan_suspended = FALSE; |
| 1547 | /*loop through all adapters. Concurrency */ |
| 1548 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1549 | |
| 1550 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1551 | { |
| 1552 | pAdapter = pAdapterNode->pAdapter; |
| 1553 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
Madan Mohan Koyyalamudi | 802d758 | 2012-10-31 14:19:40 -0700 | [diff] [blame] | 1554 | && (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1555 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Madan Mohan Koyyalamudi | 802d758 | 2012-10-31 14:19:40 -0700 | [diff] [blame] | 1556 | { // we skip this registration for modes other than STA, SAP and P2P client modes. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1557 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1558 | pAdapterNode = pNext; |
| 1559 | continue; |
| 1560 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1561 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 1562 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1563 | #ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP |
| 1564 | if(pHddCtx->hdd_ps_state == eHDD_SUSPEND_DEEP_SLEEP) |
| 1565 | { |
| 1566 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed from deep sleep",__func__); |
| 1567 | hdd_exit_deep_sleep(pAdapter); |
| 1568 | } |
| 1569 | #endif |
| 1570 | |
| 1571 | if(pHddCtx->hdd_ignore_dtim_enabled == TRUE) |
| 1572 | { |
| 1573 | /*Switch back to DTIM 1*/ |
| 1574 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 1575 | |
| 1576 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 1577 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 1578 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1579 | |
| 1580 | /*Disabled ModulatedDTIM if enabled on suspend*/ |
| 1581 | if(pHddCtx->cfg_ini->enableModulatedDTIM) |
| 1582 | powerRequest.uDTIMPeriod = 0; |
| 1583 | |
| 1584 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 1585 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 1586 | NULL, eANI_BOOLEAN_FALSE); |
| 1587 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 1588 | NULL, eANI_BOOLEAN_FALSE); |
| 1589 | |
| 1590 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1591 | "Switch to DTIM%d",powerRequest.uListenInterval); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 1592 | sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1593 | |
Madan Mohan Koyyalamudi | 69b3418 | 2013-01-16 08:51:40 +0530 | [diff] [blame] | 1594 | if (BMPS == pmcGetPmcState(pHddCtx->hHal)) |
| 1595 | { |
| 1596 | /* put the device into full power */ |
| 1597 | wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1598 | |
Madan Mohan Koyyalamudi | 69b3418 | 2013-01-16 08:51:40 +0530 | [diff] [blame] | 1599 | /* put the device back into BMPS */ |
| 1600 | wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1601 | |
Madan Mohan Koyyalamudi | 69b3418 | 2013-01-16 08:51:40 +0530 | [diff] [blame] | 1602 | pHddCtx->hdd_ignore_dtim_enabled = FALSE; |
| 1603 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1604 | } |
| 1605 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 1606 | hdd_conf_resume_ind(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1607 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1608 | pAdapterNode = pNext; |
| 1609 | } |
| 1610 | |
| 1611 | #ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP |
| 1612 | if(pHddCtx->hdd_ps_state == eHDD_SUSPEND_STANDBY) |
| 1613 | { |
| 1614 | hdd_exit_standby(pHddCtx); |
| 1615 | } |
| 1616 | #endif |
| 1617 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1618 | return; |
| 1619 | } |
| 1620 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1621 | VOS_STATUS hdd_wlan_reset_initialization(void) |
| 1622 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1623 | v_CONTEXT_t pVosContext = NULL; |
| 1624 | |
| 1625 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN being reset",__func__); |
| 1626 | |
| 1627 | //Get the global VOSS context. |
| 1628 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1629 | if(!pVosContext) |
| 1630 | { |
| 1631 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 1632 | return VOS_STATUS_E_FAILURE; |
| 1633 | } |
| 1634 | |
| 1635 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Preventing the phone from going to suspend",__func__); |
| 1636 | |
| 1637 | // Prevent the phone from going to sleep |
| 1638 | hdd_prevent_suspend(); |
| 1639 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1640 | return VOS_STATUS_SUCCESS; |
| 1641 | } |
| 1642 | |
| 1643 | |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1644 | /* |
| 1645 | * Based on the ioctl command recieved by HDD, put WLAN driver |
| 1646 | * into the quiet mode. This is the same as the early suspend |
| 1647 | * notification that driver used to listen |
| 1648 | */ |
| 1649 | void hdd_set_wlan_suspend_mode(bool suspend) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1650 | { |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1651 | if (suspend) |
| 1652 | hdd_suspend_wlan(); |
| 1653 | else |
| 1654 | hdd_resume_wlan(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1655 | } |
| 1656 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1657 | static void hdd_ssr_timer_init(void) |
| 1658 | { |
| 1659 | init_timer(&ssr_timer); |
| 1660 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1661 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1662 | static void hdd_ssr_timer_del(void) |
| 1663 | { |
| 1664 | del_timer(&ssr_timer); |
| 1665 | ssr_timer_started = false; |
| 1666 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1667 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1668 | static void hdd_ssr_timer_cb(unsigned long data) |
| 1669 | { |
| 1670 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD SSR timer expired", __func__); |
Sameer Thalappil | e5637f4 | 2013-08-07 15:46:55 -0700 | [diff] [blame] | 1671 | |
| 1672 | #ifdef WCN_PRONTO |
| 1673 | if (wcnss_hardware_type() == WCNSS_PRONTO_HW) |
| 1674 | wcnss_pronto_log_debug_regs(); |
| 1675 | #endif |
| 1676 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1677 | VOS_BUG(0); |
| 1678 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1679 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1680 | static void hdd_ssr_timer_start(int msec) |
| 1681 | { |
| 1682 | if(ssr_timer_started) |
| 1683 | { |
| 1684 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: trying to start SSR timer when it's running" |
| 1685 | ,__func__); |
| 1686 | } |
| 1687 | ssr_timer.expires = jiffies + msecs_to_jiffies(msec); |
| 1688 | ssr_timer.function = hdd_ssr_timer_cb; |
| 1689 | add_timer(&ssr_timer); |
| 1690 | ssr_timer_started = true; |
| 1691 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 1692 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1693 | /* the HDD interface to WLAN driver shutdown, |
| 1694 | * the primary shutdown function in SSR |
| 1695 | */ |
| 1696 | VOS_STATUS hdd_wlan_shutdown(void) |
| 1697 | { |
| 1698 | VOS_STATUS vosStatus; |
| 1699 | v_CONTEXT_t pVosContext = NULL; |
| 1700 | hdd_context_t *pHddCtx = NULL; |
| 1701 | pVosSchedContext vosSchedContext = NULL; |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1702 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1703 | |
| 1704 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN driver shutting down! ",__func__); |
| 1705 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1706 | /* if re-init never happens, then do SSR1 */ |
| 1707 | hdd_ssr_timer_init(); |
| 1708 | hdd_ssr_timer_start(HDD_SSR_BRING_UP_TIME); |
| 1709 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1710 | /* Get the global VOSS context. */ |
| 1711 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 1712 | if(!pVosContext) { |
| 1713 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 1714 | return VOS_STATUS_E_FAILURE; |
| 1715 | } |
| 1716 | /* Get the HDD context. */ |
| 1717 | pHddCtx = (hdd_context_t*)vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 1718 | if(!pHddCtx) { |
| 1719 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 1720 | return VOS_STATUS_E_FAILURE; |
| 1721 | } |
c_hpothu | d662a35 | 2013-12-26 15:09:12 +0530 | [diff] [blame] | 1722 | |
| 1723 | //Stop the traffic monitor timer |
| 1724 | if ( VOS_TIMER_STATE_RUNNING == |
| 1725 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 1726 | { |
| 1727 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 1728 | } |
| 1729 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1730 | hdd_reset_all_adapters(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1731 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 1732 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 1733 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 1734 | { |
| 1735 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 1736 | } |
| 1737 | |
| 1738 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 1739 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 1740 | { |
| 1741 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 1742 | } |
| 1743 | |
| 1744 | /* Disable IMPS/BMPS as we do not want the device to enter any power |
| 1745 | * save mode on its own during reset sequence |
| 1746 | */ |
| 1747 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 1748 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 1749 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 1750 | |
| 1751 | vosSchedContext = get_vos_sched_ctxt(); |
| 1752 | |
| 1753 | /* Wakeup all driver threads */ |
| 1754 | if(TRUE == pHddCtx->isMcThreadSuspended){ |
| 1755 | complete(&vosSchedContext->ResumeMcEvent); |
| 1756 | pHddCtx->isMcThreadSuspended= FALSE; |
| 1757 | } |
| 1758 | if(TRUE == pHddCtx->isTxThreadSuspended){ |
| 1759 | complete(&vosSchedContext->ResumeTxEvent); |
| 1760 | pHddCtx->isTxThreadSuspended= FALSE; |
| 1761 | } |
| 1762 | if(TRUE == pHddCtx->isRxThreadSuspended){ |
| 1763 | complete(&vosSchedContext->ResumeRxEvent); |
| 1764 | pHddCtx->isRxThreadSuspended= FALSE; |
| 1765 | } |
| 1766 | /* Reset the Suspend Variable */ |
| 1767 | pHddCtx->isWlanSuspended = FALSE; |
| 1768 | |
| 1769 | /* Stop all the threads; we do not want any messages to be a processed, |
| 1770 | * any more and the best way to ensure that is to terminate the threads |
| 1771 | * gracefully. |
| 1772 | */ |
| 1773 | /* Wait for MC to exit */ |
| 1774 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Shutting down MC thread",__func__); |
| 1775 | set_bit(MC_SHUTDOWN_EVENT_MASK, &vosSchedContext->mcEventFlag); |
| 1776 | set_bit(MC_POST_EVENT_MASK, &vosSchedContext->mcEventFlag); |
| 1777 | wake_up_interruptible(&vosSchedContext->mcWaitQueue); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1778 | ret = wait_for_completion_interruptible(&vosSchedContext->McShutdown); |
| 1779 | if (0 >= ret) |
| 1780 | { |
| 1781 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on McShutdown failed %ld", |
| 1782 | __func__, ret); |
| 1783 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1784 | |
| 1785 | /* Wait for TX to exit */ |
| 1786 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Shutting down TX thread",__func__); |
| 1787 | set_bit(TX_SHUTDOWN_EVENT_MASK, &vosSchedContext->txEventFlag); |
| 1788 | set_bit(TX_POST_EVENT_MASK, &vosSchedContext->txEventFlag); |
| 1789 | wake_up_interruptible(&vosSchedContext->txWaitQueue); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1790 | ret = wait_for_completion_interruptible(&vosSchedContext->TxShutdown); |
| 1791 | if (0 >= ret) |
| 1792 | { |
| 1793 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on TxShutdown failed %ld", |
| 1794 | __func__, ret); |
| 1795 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1796 | |
| 1797 | /* Wait for RX to exit */ |
| 1798 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Shutting down RX thread",__func__); |
| 1799 | set_bit(RX_SHUTDOWN_EVENT_MASK, &vosSchedContext->rxEventFlag); |
| 1800 | set_bit(RX_POST_EVENT_MASK, &vosSchedContext->rxEventFlag); |
| 1801 | wake_up_interruptible(&vosSchedContext->rxWaitQueue); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1802 | |
| 1803 | ret = wait_for_completion_interruptible(&vosSchedContext->RxShutdown); |
| 1804 | if (0 >= ret) |
| 1805 | { |
| 1806 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on RxShutdown failed %ld", |
| 1807 | __func__, ret); |
| 1808 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1809 | |
| 1810 | #ifdef WLAN_BTAMP_FEATURE |
| 1811 | vosStatus = WLANBAP_Stop(pVosContext); |
| 1812 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 1813 | { |
| 1814 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1815 | "%s: Failed to stop BAP",__func__); |
| 1816 | } |
| 1817 | #endif //WLAN_BTAMP_FEATURE |
| 1818 | vosStatus = vos_wda_shutdown(pVosContext); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1819 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 1820 | { |
| 1821 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1822 | "%s: Failed to stop wda %d", __func__, vosStatus); |
| 1823 | VOS_ASSERT(0); |
| 1824 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1825 | |
| 1826 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Doing SME STOP",__func__); |
| 1827 | /* Stop SME - Cannot invoke vos_stop as vos_stop relies |
| 1828 | * on threads being running to process the SYS Stop |
| 1829 | */ |
Kiet Lam | a72a232 | 2013-11-15 11:18:11 +0530 | [diff] [blame] | 1830 | vosStatus = sme_Stop(pHddCtx->hHal, HAL_STOP_TYPE_SYS_RESET); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1831 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 1832 | { |
| 1833 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1834 | "%s: Failed to stop sme %d", __func__, vosStatus); |
| 1835 | VOS_ASSERT(0); |
| 1836 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1837 | |
| 1838 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Doing MAC STOP",__func__); |
| 1839 | /* Stop MAC (PE and HAL) */ |
| 1840 | vosStatus = macStop(pHddCtx->hHal, HAL_STOP_TYPE_SYS_RESET); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1841 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 1842 | { |
| 1843 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1844 | "%s: Failed to stop mac %d", __func__, vosStatus); |
| 1845 | VOS_ASSERT(0); |
| 1846 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1847 | |
| 1848 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Doing TL STOP",__func__); |
| 1849 | /* Stop TL */ |
| 1850 | vosStatus = WLANTL_Stop(pVosContext); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1851 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 1852 | { |
| 1853 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 1854 | "%s: Failed to stop TL %d", __func__, vosStatus); |
| 1855 | VOS_ASSERT(0); |
| 1856 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1857 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1858 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1859 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Flush Queues",__func__); |
| 1860 | /* Clean up message queues of TX and MC thread */ |
| 1861 | vos_sched_flush_mc_mqs(vosSchedContext); |
| 1862 | vos_sched_flush_tx_mqs(vosSchedContext); |
| 1863 | vos_sched_flush_rx_mqs(vosSchedContext); |
| 1864 | |
| 1865 | /* Deinit all the TX and MC queues */ |
| 1866 | vos_sched_deinit_mqs(vosSchedContext); |
| 1867 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Doing VOS Shutdown",__func__); |
| 1868 | |
| 1869 | /* shutdown VOSS */ |
| 1870 | vos_shutdown(pVosContext); |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 1871 | |
| 1872 | /*mac context has already been released in mac_close call |
| 1873 | so setting it to NULL in hdd context*/ |
| 1874 | pHddCtx->hHal = (tHalHandle)NULL; |
| 1875 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1876 | if (free_riva_power_on_lock("wlan")) |
| 1877 | { |
| 1878 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 1879 | __func__); |
| 1880 | } |
| 1881 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN driver shutdown complete" |
| 1882 | ,__func__); |
| 1883 | return VOS_STATUS_SUCCESS; |
| 1884 | } |
| 1885 | |
| 1886 | |
| 1887 | |
| 1888 | /* the HDD interface to WLAN driver re-init. |
| 1889 | * This is called to initialize/start WLAN driver after a shutdown. |
| 1890 | */ |
| 1891 | VOS_STATUS hdd_wlan_re_init(void) |
| 1892 | { |
| 1893 | VOS_STATUS vosStatus; |
| 1894 | v_CONTEXT_t pVosContext = NULL; |
| 1895 | hdd_context_t *pHddCtx = NULL; |
| 1896 | eHalStatus halStatus; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 1897 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 1898 | int max_retries = 0; |
| 1899 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1900 | #ifdef WLAN_BTAMP_FEATURE |
| 1901 | hdd_config_t *pConfig = NULL; |
| 1902 | WLANBAP_ConfigType btAmpConfig; |
| 1903 | #endif |
| 1904 | |
Madan Mohan Koyyalamudi | b0e7064 | 2012-10-11 12:20:22 -0700 | [diff] [blame] | 1905 | hdd_ssr_timer_del(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1906 | hdd_prevent_suspend(); |
Sameer Thalappil | 5d7a33f | 2013-01-30 08:36:16 -0800 | [diff] [blame] | 1907 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 1908 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 1909 | /* wait until WCNSS driver downloads NV */ |
| 1910 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 1911 | msleep(1000); |
| 1912 | } |
| 1913 | if (max_retries >= 5) { |
| 1914 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
| 1915 | goto err_re_init; |
| 1916 | } |
| 1917 | #endif |
| 1918 | |
Sameer Thalappil | 9ab2fe5 | 2013-10-22 12:50:24 -0700 | [diff] [blame] | 1919 | vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 1920 | |
Sameer Thalappil | 5d7a33f | 2013-01-30 08:36:16 -0800 | [diff] [blame] | 1921 | /* The driver should always be initialized in STA mode after SSR */ |
| 1922 | hdd_set_conparam(0); |
| 1923 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1924 | /* Re-open VOSS, it is a re-open b'se control transport was never closed. */ |
| 1925 | vosStatus = vos_open(&pVosContext, 0); |
| 1926 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 1927 | { |
| 1928 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_open failed",__func__); |
| 1929 | goto err_re_init; |
| 1930 | } |
| 1931 | |
| 1932 | /* Get the HDD context. */ |
| 1933 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 1934 | if(!pHddCtx) |
| 1935 | { |
| 1936 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 1937 | goto err_vosclose; |
| 1938 | } |
| 1939 | |
| 1940 | /* Save the hal context in Adapter */ |
| 1941 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 1942 | if ( NULL == pHddCtx->hHal ) |
| 1943 | { |
| 1944 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HAL context is null",__func__); |
| 1945 | goto err_vosclose; |
| 1946 | } |
| 1947 | |
| 1948 | /* Set the SME configuration parameters. */ |
| 1949 | vosStatus = hdd_set_sme_config(pHddCtx); |
| 1950 | if ( VOS_STATUS_SUCCESS != vosStatus ) |
| 1951 | { |
| 1952 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed hdd_set_sme_config",__func__); |
| 1953 | goto err_vosclose; |
| 1954 | } |
| 1955 | |
| 1956 | /* Initialize the WMM module */ |
| 1957 | vosStatus = hdd_wmm_init(pHddCtx); |
| 1958 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus )) |
| 1959 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1960 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_wmm_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1961 | goto err_vosclose; |
| 1962 | } |
| 1963 | |
| 1964 | vosStatus = vos_preStart( pHddCtx->pvosContext ); |
| 1965 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 1966 | { |
| 1967 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_preStart failed",__func__); |
| 1968 | goto err_vosclose; |
| 1969 | } |
| 1970 | |
| 1971 | /* In the integrated architecture we update the configuration from |
| 1972 | the INI file and from NV before vOSS has been started so that |
| 1973 | the final contents are available to send down to the cCPU */ |
| 1974 | /* Apply the cfg.ini to cfg.dat */ |
| 1975 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 1976 | { |
| 1977 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
| 1978 | goto err_vosclose; |
| 1979 | } |
| 1980 | |
| 1981 | /* Set the MAC Address, currently this is used by HAL to add self sta. |
| 1982 | * Remove this once self sta is added as part of session open. */ |
| 1983 | halStatus = cfgSetStr(pHddCtx->hHal, WNI_CFG_STA_ID, |
| 1984 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 1985 | sizeof(pHddCtx->cfg_ini->intfMacAddr[0])); |
| 1986 | if (!HAL_STATUS_SUCCESS(halStatus)) |
| 1987 | { |
| 1988 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 1989 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus); |
| 1990 | goto err_vosclose; |
| 1991 | } |
| 1992 | |
| 1993 | /* Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 1994 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 1995 | vosStatus = vos_start( pVosContext ); |
| 1996 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 1997 | { |
| 1998 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
| 1999 | goto err_vosclose; |
| 2000 | } |
| 2001 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 2002 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 2003 | hdd_exchange_version_and_caps(pHddCtx); |
| 2004 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2005 | vosStatus = hdd_post_voss_start_config( pHddCtx ); |
| 2006 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 2007 | { |
| 2008 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 2009 | __func__); |
| 2010 | goto err_vosstop; |
| 2011 | } |
| 2012 | |
| 2013 | #ifdef WLAN_BTAMP_FEATURE |
| 2014 | vosStatus = WLANBAP_Open(pVosContext); |
| 2015 | if(!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 2016 | { |
| 2017 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2018 | "%s: Failed to open BAP",__func__); |
| 2019 | goto err_vosstop; |
| 2020 | } |
| 2021 | vosStatus = BSL_Init(pVosContext); |
| 2022 | if(!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 2023 | { |
| 2024 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2025 | "%s: Failed to Init BSL",__func__); |
| 2026 | goto err_bap_close; |
| 2027 | } |
| 2028 | vosStatus = WLANBAP_Start(pVosContext); |
| 2029 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 2030 | { |
| 2031 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2032 | "%s: Failed to start TL",__func__); |
| 2033 | goto err_bap_close; |
| 2034 | } |
| 2035 | pConfig = pHddCtx->cfg_ini; |
| 2036 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 2037 | vosStatus = WLANBAP_SetConfig(&btAmpConfig); |
| 2038 | #endif //WLAN_BTAMP_FEATURE |
| 2039 | |
| 2040 | /* Restart all adapters */ |
| 2041 | hdd_start_all_adapters(pHddCtx); |
| 2042 | pHddCtx->isLogpInProgress = FALSE; |
Sameer Thalappil | b511beb | 2013-09-09 17:11:51 -0700 | [diff] [blame] | 2043 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2044 | pHddCtx->hdd_mcastbcast_filter_set = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2045 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2046 | |
| 2047 | /* Register with platform driver as client for Suspend/Resume */ |
| 2048 | vosStatus = hddRegisterPmOps(pHddCtx); |
| 2049 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 2050 | { |
| 2051 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 2052 | goto err_bap_stop; |
| 2053 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2054 | /* Allow the phone to go to sleep */ |
| 2055 | hdd_allow_suspend(); |
| 2056 | /* register for riva power on lock */ |
| 2057 | if (req_riva_power_on_lock("wlan")) |
| 2058 | { |
| 2059 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 2060 | __func__); |
| 2061 | goto err_unregister_pmops; |
| 2062 | } |
Sameer Thalappil | 9ab2fe5 | 2013-10-22 12:50:24 -0700 | [diff] [blame] | 2063 | vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2064 | goto success; |
| 2065 | |
| 2066 | err_unregister_pmops: |
| 2067 | hddDeregisterPmOps(pHddCtx); |
| 2068 | |
| 2069 | err_bap_stop: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2070 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 2071 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
| 2072 | #endif |
| 2073 | hdd_close_all_adapters(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2074 | #ifdef WLAN_BTAMP_FEATURE |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2075 | WLANBAP_Stop(pVosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2076 | #endif |
| 2077 | |
| 2078 | #ifdef WLAN_BTAMP_FEATURE |
| 2079 | err_bap_close: |
| 2080 | WLANBAP_Close(pVosContext); |
| 2081 | #endif |
| 2082 | |
| 2083 | err_vosstop: |
| 2084 | vos_stop(pVosContext); |
| 2085 | |
| 2086 | err_vosclose: |
| 2087 | vos_close(pVosContext); |
| 2088 | vos_sched_close(pVosContext); |
| 2089 | if (pHddCtx) |
| 2090 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2091 | /* Unregister the Net Device Notifier */ |
| 2092 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 2093 | /* Clean up HDD Nlink Service */ |
| 2094 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 2095 | #ifdef WLAN_KD_READY_NOTIFIER |
| 2096 | nl_srv_exit(pHddCtx->ptt_pid); |
| 2097 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2098 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 2099 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2100 | /* Free up dynamically allocated members inside HDD Adapter */ |
| 2101 | kfree(pHddCtx->cfg_ini); |
| 2102 | pHddCtx->cfg_ini= NULL; |
| 2103 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2104 | wiphy_unregister(pHddCtx->wiphy); |
| 2105 | wiphy_free(pHddCtx->wiphy); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2106 | } |
| 2107 | vos_preClose(&pVosContext); |
| 2108 | |
| 2109 | #ifdef MEMORY_DEBUG |
| 2110 | vos_mem_exit(); |
| 2111 | #endif |
| 2112 | |
| 2113 | err_re_init: |
| 2114 | /* Allow the phone to go to sleep */ |
| 2115 | hdd_allow_suspend(); |
Sameer Thalappil | 9ab2fe5 | 2013-10-22 12:50:24 -0700 | [diff] [blame] | 2116 | vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 2117 | VOS_BUG(0); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 2118 | return -EPERM; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2119 | |
| 2120 | success: |
| 2121 | /* Trigger replay of BTC events */ |
| 2122 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
| 2123 | return VOS_STATUS_SUCCESS; |
| 2124 | } |