blob: 8ba93a1a514869d2a35fbfd87d1d09e74beddfbb [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**=============================================================================
29* wlan_hdd_early_suspend.c
30*
31* \brief power management functions
32*
33* Description
Jeff Johnson295189b2012-06-20 16:38:30 -070034*
35==============================================================================**/
36/* $HEADER$ */
37
38/**-----------------------------------------------------------------------------
39* Include files
40* ----------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42#include <linux/pm.h>
43#include <linux/wait.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070044#include <wlan_hdd_includes.h>
45#include <wlan_qct_driver.h>
46#include <linux/wakelock.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48#include "halTypes.h"
49#include "sme_Api.h"
50#include <vos_api.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070051#include <vos_sched.h>
52#include <macInitApi.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include <wlan_qct_sys.h>
54#include <wlan_btc_svc.h>
55#include <wlan_nlink_common.h>
56#include <wlan_hdd_main.h>
57#include <wlan_hdd_assoc.h>
58#include <wlan_hdd_dev_pwr.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include <wlan_nlink_srv.h>
60#include <wlan_hdd_misc.h>
Amar Singhald08ce752014-03-21 16:28:27 -070061#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062
Jeff Johnson295189b2012-06-20 16:38:30 -070063#include <linux/semaphore.h>
64#include <wlan_hdd_hostapd.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "cfgApi.h"
Siddharth Bhal7bd19932015-03-03 16:54:36 +053066#include <wlan_logging_sock_svc.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070067
68#ifdef WLAN_BTAMP_FEATURE
69#include "bapApi.h"
70#include "bap_hdd_main.h"
71#include "bap_hdd_misc.h"
72#endif
73
Jeff Johnsone7245742012-09-05 17:12:55 -070074#include <linux/wcnss_wlan.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include <linux/inetdevice.h>
76#include <wlan_hdd_cfg.h>
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053077#include <wlan_hdd_cfg80211.h>
Gopichand Nakkala746a9452013-06-11 12:45:54 +053078#include <net/addrconf.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070079/**-----------------------------------------------------------------------------
80* Preprocessor definitions and constants
81* ----------------------------------------------------------------------------*/
82
83/**-----------------------------------------------------------------------------
84* Type declarations
85* ----------------------------------------------------------------------------*/
86
87/**-----------------------------------------------------------------------------
88* Function and variables declarations
89* ----------------------------------------------------------------------------*/
90#include "wlan_hdd_power.h"
91#include "wlan_hdd_packet_filtering.h"
92
Sameer Thalappile5637f42013-08-07 15:46:55 -070093#define HDD_SSR_BRING_UP_TIME 180000
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +053094#define NS_DEFAULT_SLOT_INDEX 4
95#define NS_EXTENDED_SLOT_INDEX 18
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97static eHalStatus g_full_pwr_status;
98static eHalStatus g_standby_status;
99
100extern VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700101extern void hdd_wlan_initial_scan(hdd_context_t *pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103extern struct notifier_block hdd_netdev_notifier;
Jeff Johnson295189b2012-06-20 16:38:30 -0700104extern tVOS_CON_MODE hdd_get_conparam ( void );
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -0700106static struct timer_list ssr_timer;
107static bool ssr_timer_started;
Jeff Johnson295189b2012-06-20 16:38:30 -0700108
Mukul Sharma75ee8aa2016-12-01 14:28:10 +0530109void inline check_and_set_suspend_resume_mcbc_filter(hdd_context_t *pHddCtx)
110{
111 hddLog(VOS_TRACE_LEVEL_INFO,
112 FL("offload: sus_res_mcbc_filter_valid: %d sus_res_mcbc_filter: %d configuredMcBcFilter: %d"),
113 pHddCtx->sus_res_mcastbcast_filter_valid,
114 pHddCtx->sus_res_mcastbcast_filter,
115 pHddCtx->configuredMcastBcastFilter);
116 if ( VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
117 {
118 pHddCtx->sus_res_mcastbcast_filter =
119 pHddCtx->configuredMcastBcastFilter;
120 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
121 hddLog(VOS_TRACE_LEVEL_INFO,
122 FL("offload: saving sus_res_mcastbcast_filter = %d"),
123 pHddCtx->sus_res_mcastbcast_filter);
124 }
125}
Abhishek Singh937ec542016-01-05 18:03:14 +0530126
127#ifdef FEATURE_WLAN_DIAG_SUPPORT
128/**
129 * hdd_wlan_offload_event()- send offloads event
130 *
131 * @type: offload type
132 * @state: enabled or disabled
133 *
134 * This Function send offloads enable/disable diag event
135 *
136 * Return: void.
137 */
138
139void hdd_wlan_offload_event(uint8_t type, uint8_t state)
140{
141 WLAN_VOS_DIAG_EVENT_DEF(host_offload,
142 struct vos_event_offload_req);
143 vos_mem_zero(&host_offload, sizeof(host_offload));
144
145 host_offload.offload_type = type;
146 host_offload.state = state;
147
148 WLAN_VOS_DIAG_EVENT_REPORT(&host_offload, EVENT_OFFLOAD_REQ);
149}
150#endif /* FEATURE_WLAN_DIAG_SUPPORT */
151
Jeff Johnson295189b2012-06-20 16:38:30 -0700152//Callback invoked by PMC to report status of standby request
153void hdd_suspend_standby_cbk (void *callbackContext, eHalStatus status)
154{
155 hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext;
156 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Standby status = %d", __func__, status);
157 g_standby_status = status;
158
159 if(eHAL_STATUS_SUCCESS == status)
160 {
161 pHddCtx->hdd_ps_state = eHDD_SUSPEND_STANDBY;
162 }
163 else
164 {
165 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestStandby failed",__func__);
166 }
167
168 complete(&pHddCtx->standby_comp_var);
169}
170
171//Callback invoked by PMC to report status of full power request
172void hdd_suspend_full_pwr_callback(void *callbackContext, eHalStatus status)
173{
174 hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext;
175 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Full Power status = %d", __func__, status);
176 g_full_pwr_status = status;
177
178 if(eHAL_STATUS_SUCCESS == status)
179 {
180 pHddCtx->hdd_ps_state = eHDD_SUSPEND_NONE;
181 }
182 else
183 {
184 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed",__func__);
185 }
186
187 complete(&pHddCtx->full_pwr_comp_var);
188}
189
190eHalStatus hdd_exit_standby(hdd_context_t *pHddCtx)
191{
192 eHalStatus status = VOS_STATUS_SUCCESS;
c_hpothuffdb5272013-10-02 16:42:35 +0530193 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -0700194
195 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed from standby",__func__);
196 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
197
198 g_full_pwr_status = eHAL_STATUS_FAILURE;
199 status = sme_RequestFullPower(pHddCtx->hHal, hdd_suspend_full_pwr_callback, pHddCtx,
200 eSME_FULL_PWR_NEEDED_BY_HDD);
201
202 if(status == eHAL_STATUS_PMC_PENDING)
203 {
204 //Block on a completion variable. Can't wait forever though
c_hpothuffdb5272013-10-02 16:42:35 +0530205 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 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 status = g_full_pwr_status;
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 goto failure;
219 }
220 }
221 else if(status != eHAL_STATUS_SUCCESS)
222 {
223 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed - status %d",
224 __func__, status);
225 VOS_ASSERT(0);
226 goto failure;
227 }
228 else
229 pHddCtx->hdd_ps_state = eHDD_SUSPEND_NONE;
230
231failure:
232 //No blocking to reduce latency. No other device should be depending on WLAN
233 //to finish resume and WLAN won't be instantly on after resume
234 return status;
235}
236
237
238//Helper routine to put the chip into standby
239VOS_STATUS hdd_enter_standby(hdd_context_t *pHddCtx)
240{
241 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
242 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
c_hpothuffdb5272013-10-02 16:42:35 +0530243 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -0700244
245 //Disable IMPS/BMPS as we do not want the device to enter any power
246 //save mode on its own during suspend sequence
247 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
248 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
249
250 //Note we do not disable queues unnecessarily. Queues should already be disabled
251 //if STA is disconnected or the queue will be disabled as and when disconnect
252 //happens because of standby procedure.
253
254 //Ensure that device is in full power first. There is scope for optimization
255 //here especially in scenarios where PMC is already in IMPS or REQUEST_IMPS.
256 //Core s/w needs to be optimized to handle this. Until then we request full
257 //power before issuing request for standby.
258 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
259 g_full_pwr_status = eHAL_STATUS_FAILURE;
260 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_suspend_full_pwr_callback,
261 pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD);
262
263 if(halStatus == eHAL_STATUS_PMC_PENDING)
264 {
265 //Block on a completion variable. Can't wait forever though
c_hpothuffdb5272013-10-02 16:42:35 +0530266 ret = wait_for_completion_interruptible_timeout(
267 &pHddCtx->full_pwr_comp_var,
268 msecs_to_jiffies(WLAN_WAIT_TIME_FULL_PWR));
269 if (0 >= ret)
270 {
271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on full_pwr_comp_var failed %ld",
272 __func__, ret);
273 }
274
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 if(g_full_pwr_status != eHAL_STATUS_SUCCESS)
276 {
277 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower Failed",__func__);
278 VOS_ASSERT(0);
279 vosStatus = VOS_STATUS_E_FAILURE;
280 goto failure;
281 }
282 }
283 else if(halStatus != eHAL_STATUS_SUCCESS)
284 {
285 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed - status %d",
286 __func__, halStatus);
287 VOS_ASSERT(0);
288 vosStatus = VOS_STATUS_E_FAILURE;
289 goto failure;
290 }
291
292 if(pHddCtx->hdd_mcastbcast_filter_set == TRUE) {
293 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
294 pHddCtx->hdd_mcastbcast_filter_set = FALSE;
295 }
296
297 //Request standby. Standby will cause the STA to disassociate first. TX queues
298 //will be disabled (by HDD) when STA disconnects. You do not want to disable TX
299 //queues here. Also do not assert if the failure code is eHAL_STATUS_PMC_NOT_NOW as PMC
300 //will send this failure code in case of concurrent sessions. Power Save cannot be supported
301 //when there are concurrent sessions.
302 INIT_COMPLETION(pHddCtx->standby_comp_var);
303 g_standby_status = eHAL_STATUS_FAILURE;
304 halStatus = sme_RequestStandby(pHddCtx->hHal, hdd_suspend_standby_cbk, pHddCtx);
305
306 if (halStatus == eHAL_STATUS_PMC_PENDING)
307 {
308 //Wait till WLAN device enters standby mode
c_hpothuffdb5272013-10-02 16:42:35 +0530309 ret = wait_for_completion_timeout(&pHddCtx->standby_comp_var,
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 msecs_to_jiffies(WLAN_WAIT_TIME_STANDBY));
c_hpothuffdb5272013-10-02 16:42:35 +0530311 if (0 >= ret)
312 {
313 hddLog(VOS_TRACE_LEVEL_ERROR,
314 FL("wait on standby_comp_var failed %ld"), ret);
315 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 if (g_standby_status != eHAL_STATUS_SUCCESS && g_standby_status != eHAL_STATUS_PMC_NOT_NOW)
317 {
318 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestStandby failed",__func__);
319 VOS_ASSERT(0);
320 vosStatus = VOS_STATUS_E_FAILURE;
321 goto failure;
322 }
323 }
324 else if (halStatus != eHAL_STATUS_SUCCESS && halStatus != eHAL_STATUS_PMC_NOT_NOW) {
325 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestStandby failed - status %d",
326 __func__, halStatus);
327 VOS_ASSERT(0);
328 vosStatus = VOS_STATUS_E_FAILURE;
329 goto failure;
330 }
331 else
332 pHddCtx->hdd_ps_state = eHDD_SUSPEND_STANDBY;
333
334failure:
335 //Restore IMPS config
336 if(pHddCtx->cfg_ini->fIsImpsEnabled)
337 sme_EnablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
338
339 //Restore BMPS config
340 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
341 sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
342
343 return vosStatus;
344}
345
346
347//Helper routine for Deep sleep entry
348VOS_STATUS hdd_enter_deep_sleep(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter)
349{
350 eHalStatus halStatus;
351 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
c_hpothuffdb5272013-10-02 16:42:35 +0530352 long ret;
Jeff Johnsonbc676b42013-02-14 16:04:08 -0800353
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 //Stop the Interface TX queue.
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530355 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 netif_tx_disable(pAdapter->dev);
357 netif_carrier_off(pAdapter->dev);
358
359 //Disable IMPS,BMPS as we do not want the device to enter any power
360 //save mode on it own during suspend sequence
361 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
362 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
363
364 //Ensure that device is in full power as we will touch H/W during vos_Stop
365 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
366 g_full_pwr_status = eHAL_STATUS_FAILURE;
367 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_suspend_full_pwr_callback,
368 pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD);
369
370 if(halStatus == eHAL_STATUS_PMC_PENDING)
371 {
372 //Block on a completion variable. Can't wait forever though
c_hpothuffdb5272013-10-02 16:42:35 +0530373 ret = wait_for_completion_interruptible_timeout(
374 &pHddCtx->full_pwr_comp_var,
375 msecs_to_jiffies(WLAN_WAIT_TIME_FULL_PWR));
376 if (0 >= ret)
377 {
378 hddLog(VOS_TRACE_LEVEL_ERROR,
379 FL("wait on full_pwr_comp_var failed %ld"), ret);
380 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 if(g_full_pwr_status != eHAL_STATUS_SUCCESS){
382 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: sme_RequestFullPower failed",__func__);
383 VOS_ASSERT(0);
384 }
385 }
386 else if(halStatus != eHAL_STATUS_SUCCESS)
387 {
388 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Request for Full Power failed",__func__);
389 VOS_ASSERT(0);
390 }
391
392 //Issue a disconnect. This is required to inform the supplicant that
393 //STA is getting disassociated and for GUI to be updated properly
394 INIT_COMPLETION(pAdapter->disconnect_comp_var);
395 halStatus = sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
396
397 //Success implies disconnect command got queued up successfully
398 if(halStatus == eHAL_STATUS_SUCCESS)
399 {
400 //Block on a completion variable. Can't wait forever though.
c_hpothuffdb5272013-10-02 16:42:35 +0530401 ret = wait_for_completion_interruptible_timeout(
402 &pAdapter->disconnect_comp_var,
403 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
404 if (0 >= ret)
405 {
406 hddLog(VOS_TRACE_LEVEL_ERROR,
407 FL("wait on disconnect_comp_var failed %ld"), ret);
408 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 }
410
411
412 //None of the steps should fail after this. Continue even in case of failure
413 vosStatus = vos_stop( pHddCtx->pvosContext );
c_hpothuffdb5272013-10-02 16:42:35 +0530414 if( !VOS_IS_STATUS_SUCCESS( vosStatus ))
415 {
416 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: vos_stop return failed %d",
417 __func__, vosStatus);
418 VOS_ASSERT(0);
Hanumantha Reddy Pothulabd9601a2016-02-12 13:22:27 +0530419 if (isSsrPanicOnFailure())
420 VOS_BUG(0);
c_hpothuffdb5272013-10-02 16:42:35 +0530421 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700422
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 pHddCtx->hdd_ps_state = eHDD_SUSPEND_DEEP_SLEEP;
424
425 //Restore IMPS config
426 if(pHddCtx->cfg_ini->fIsImpsEnabled)
427 sme_EnablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
428
429 //Restore BMPS config
430 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
431 sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
432
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 return vosStatus;
434}
435
436VOS_STATUS hdd_exit_deep_sleep(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter)
437{
438 VOS_STATUS vosStatus;
439 eHalStatus halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700440
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
442 "%s: calling hdd_set_sme_config",__func__);
443 vosStatus = hdd_set_sme_config( pHddCtx );
444 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
445 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
446 {
447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
448 "%s: Failed in hdd_set_sme_config",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 goto err_deep_sleep;
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 }
451
452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
453 "%s: calling vos_start",__func__);
454 vosStatus = vos_start( pHddCtx->pvosContext );
455 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
456 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
457 {
458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
459 "%s: Failed in vos_start",__func__);
Hanumantha Reddy Pothulabd9601a2016-02-12 13:22:27 +0530460 if (isSsrPanicOnFailure())
461 VOS_BUG(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 goto err_deep_sleep;
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 }
464
465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
466 "%s: calling hdd_post_voss_start_config",__func__);
467 vosStatus = hdd_post_voss_start_config( pHddCtx );
468 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
469 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
470 {
471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
472 "%s: Failed in hdd_post_voss_start_config",__func__);
473 goto err_voss_stop;
474 }
475
476
477 //Open a SME session for future operation
478 halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pHddCtx,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -0700479 (tANI_U8 *)&pAdapter->macAddressCurrent,
480 &pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 if ( !HAL_STATUS_SUCCESS( halStatus ) )
482 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700483 hddLog(VOS_TRACE_LEVEL_FATAL,"sme_OpenSession() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 halStatus, halStatus );
485 goto err_voss_stop;
486
487 }
488
489 pHddCtx->hdd_ps_state = eHDD_SUSPEND_NONE;
490
491 //Trigger the initial scan
492 hdd_wlan_initial_scan(pHddCtx);
493
494 return VOS_STATUS_SUCCESS;
495
496err_voss_stop:
497 vos_stop(pHddCtx->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498err_deep_sleep:
499 return VOS_STATUS_E_FAILURE;
500
501}
502
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +0530503void __hdd_ipv6_notifier_work_queue(struct work_struct *work)
Atul Mittal37385d72014-03-27 18:15:03 +0530504{
505 hdd_adapter_t* pAdapter =
506 container_of(work, hdd_adapter_t, ipv6NotifierWorkQueue);
507 hdd_context_t *pHddCtx;
508 int status;
509
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530510 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +0530511 if (NULL == pAdapter)
512 {
513 hddLog(LOGE, FL("Adapter is invalid"));
514 return;
515 }
Atul Mittal37385d72014-03-27 18:15:03 +0530516
517 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
518 status = wlan_hdd_validate_context(pHddCtx);
519 if (0 != status)
520 {
Atul Mittal37385d72014-03-27 18:15:03 +0530521 return;
522 }
523
Atul Mittal37385d72014-03-27 18:15:03 +0530524 if ((eConnectionState_Associated ==
525 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)
526 && (pHddCtx->hdd_wlan_suspended))
527 {
Mukul Sharma75ee8aa2016-12-01 14:28:10 +0530528 check_and_set_suspend_resume_mcbc_filter(pHddCtx);
Atul Mittal37385d72014-03-27 18:15:03 +0530529 // This invocation being part of the IPv6 registration callback,
530 // set the newly generated ip address to f/w in suspend mode.
531#ifdef WLAN_NS_OFFLOAD
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +0530532 if (pHddCtx->cfg_ini->fhostNSOffload)
533 {
534 hdd_conf_ns_offload(pAdapter, 1);
535 }
Atul Mittal37385d72014-03-27 18:15:03 +0530536#endif
537 }
538#ifdef WLAN_FEATURE_PACKET_FILTERING
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +0530539 /* wlan_hdd_set_mc_addr_list() is called from the early suspend
Atul Mittal37385d72014-03-27 18:15:03 +0530540 * only so when new ipv6 address is generated the screen may not
541 * on so we need to call it here to update the list in f/w.
542 */
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +0530543 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
Atul Mittal37385d72014-03-27 18:15:03 +0530544#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530545 EXIT();
Atul Mittal37385d72014-03-27 18:15:03 +0530546}
547
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +0530548void hdd_ipv6_notifier_work_queue(struct work_struct *work)
549{
550 vos_ssr_protect(__func__);
551 __hdd_ipv6_notifier_work_queue(work);
552 vos_ssr_unprotect(__func__);
553}
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +0530554int __wlan_hdd_ipv6_changed(struct notifier_block *nb,
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +0530555 unsigned long data, void *arg)
Atul Mittal37385d72014-03-27 18:15:03 +0530556{
557 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)arg;
558 struct net_device *ndev = ifa->idev->dev;
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530559 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Atul Mittal37385d72014-03-27 18:15:03 +0530560 hdd_context_t *pHddCtx;
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530561 VOS_STATUS vos_status;
Atul Mittal37385d72014-03-27 18:15:03 +0530562 int status;
563
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530564 ENTER();
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530565 pHddCtx = container_of(nb, hdd_context_t, ipv6_notifier);
566 status = wlan_hdd_validate_context(pHddCtx);
567 if (0 != status)
Atul Mittal37385d72014-03-27 18:15:03 +0530568 {
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530569 return NOTIFY_DONE;
570 }
Atul Mittal37385d72014-03-27 18:15:03 +0530571
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530572 vos_status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
573 while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == vos_status)
574 {
575 if (pAdapterNode->pAdapter && pAdapterNode->pAdapter->dev == ndev &&
576 (pAdapterNode->pAdapter->device_mode == WLAN_HDD_INFRA_STATION ||
577 pAdapterNode->pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
578 {
Abhishek Singhe0bc0992016-05-20 17:58:18 +0530579
580 if (eConnectionState_Associated ==
581 WLAN_HDD_GET_STATION_CTX_PTR
582 (pAdapterNode->pAdapter)->conn_info.connState)
583 sme_dhcp_done_ind(pHddCtx->hHal,
584 pAdapterNode->pAdapter->sessionId);
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530585 if (pHddCtx->cfg_ini->nEnableSuspend ==
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +0530586 WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER)
Vinay Krishna Eranna55029602015-02-06 15:43:35 +0530587 {
588 schedule_work(&pAdapterNode->pAdapter->ipv6NotifierWorkQueue);
589 }
590 else
591 {
592 hddLog(LOG1, FL("Not scheduling ipv6 wq nEnableSuspend = %d"),
593 pHddCtx->cfg_ini->nEnableSuspend);
594 }
595 break;
596 }
597 vos_status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
598 pAdapterNode = pNext;
Atul Mittal37385d72014-03-27 18:15:03 +0530599 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530600 EXIT();
Atul Mittal37385d72014-03-27 18:15:03 +0530601 return NOTIFY_DONE;
602}
603
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +0530604int wlan_hdd_ipv6_changed(struct notifier_block *nb,
605 unsigned long data, void *arg)
606{
607 int ret;
608 vos_ssr_protect(__func__);
609 ret = __wlan_hdd_ipv6_changed( nb, data, arg);
610 vos_ssr_unprotect(__func__);
611 return ret;
612}
613
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530614/*
615 * Function: hdd_conf_hostoffload
616 * Central function to configure the supported offloads,
617 * either enable or disable them.
618 */
619void hdd_conf_hostoffload(hdd_adapter_t *pAdapter, v_BOOL_t fenable)
620{
621 hdd_context_t *pHddCtx = NULL;
622 v_CONTEXT_t *pVosContext = NULL;
623 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
624
625 hddLog(VOS_TRACE_LEVEL_INFO, FL("Configuring offloads with flag: %d"),
626 fenable);
627
628 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
629
630 if (NULL == pVosContext)
631 {
632 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Global VOS context is Null"));
633 return;
634 }
635
636 //Get the HDD context.
637 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
638
639 if (NULL == pHddCtx)
640 {
641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HDD context is Null", __func__);
642 return;
643 }
644
645 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Arun Khandavalli08bcafd2016-11-08 14:45:48 +0530646 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
647 ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
648 (pHddCtx->is_ap_mode_wow_supported)))
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530649 {
650 if (fenable)
651 {
Arun Khandavalli08bcafd2016-11-08 14:45:48 +0530652 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
653 (eConnectionState_Associated ==
654 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
655 || (WLAN_HDD_SOFTAP == pAdapter->device_mode))
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530656 {
657 if ((pHddCtx->cfg_ini->fhostArpOffload))
658 {
659 /*
660 * Configure the ARP Offload.
661 * Even if it fails we have to reconfigure the MC/BC
662 * filter flag as we want RIVA not to drop BroadCast
663 * Packets
664 */
665 hddLog(VOS_TRACE_LEVEL_INFO,
666 FL("Calling ARP Offload with flag: %d"), fenable);
667 vstatus = hdd_conf_arp_offload(pAdapter, fenable);
668 pHddCtx->configuredMcastBcastFilter &=
669 ~(HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST);
670
671 if (!VOS_IS_STATUS_SUCCESS(vstatus))
672 {
Anurag Chouhan8a5f8902016-09-28 18:54:47 +0530673 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530674 "Failed to enable ARPOFfloadFeature %d",
675 vstatus);
676 }
677 }
678 //Configure GTK_OFFLOAD
679#ifdef WLAN_FEATURE_GTK_OFFLOAD
680 hdd_conf_gtk_offload(pAdapter, fenable);
681#endif
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530682
683#ifdef WLAN_NS_OFFLOAD
684 if (pHddCtx->cfg_ini->fhostNSOffload)
685 {
686 /*
687 * Configure the NS Offload.
688 * Even if it fails we have to reconfigure the MC/BC filter flag
689 * as we want RIVA not to drop Multicast Packets
690 */
691
692 hddLog(VOS_TRACE_LEVEL_INFO,
693 FL("Calling NS Offload with flag: %d"), fenable);
694 hdd_conf_ns_offload(pAdapter, fenable);
695 pHddCtx->configuredMcastBcastFilter &=
696 ~(HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST);
697 }
698#endif
Atul Mittal37385d72014-03-27 18:15:03 +0530699
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530700 }
701 }
702 else
703 {
704 //Disable ARPOFFLOAD
705 if (pHddCtx->cfg_ini->fhostArpOffload)
706 {
707 vstatus = hdd_conf_arp_offload(pAdapter, fenable);
708 if (!VOS_IS_STATUS_SUCCESS(vstatus))
709 {
710 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530711 "Failed to disable ARPOffload Feature %d", vstatus);
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530712 }
713 }
714 //Disable GTK_OFFLOAD
715#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530716 hdd_conf_gtk_offload(pAdapter, fenable);
717#endif
718
719#ifdef WLAN_NS_OFFLOAD
720 //Disable NSOFFLOAD
721 if (pHddCtx->cfg_ini->fhostNSOffload)
722 {
723 hdd_conf_ns_offload(pAdapter, fenable);
724 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +0530725 else
726 {
727 hddLog(VOS_TRACE_LEVEL_INFO,
728 FL("ns offload ini is disabled"));
729 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +0530730#endif
731 }
732 }
733 return;
734}
735
Atul Mittal37385d72014-03-27 18:15:03 +0530736
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530737#ifdef WLAN_NS_OFFLOAD
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +0530738/**----------------------------------------------------------------------------
739
740 \brief hdd_conf_ns_offload() - Configure NS offload
741
742 Called during SUSPEND to configure the NS offload (MC BC filter) which
743 reduces power consumption.
744
745 \param - pAdapter - Adapter context for which NS offload is to be configured
746 \param - fenable - 0 - disable.
747 1 - enable. (with IPv6 notifier registration)
748 2 - enable. (without IPv6 notifier registration)
749
750 \return - void
751
752 ---------------------------------------------------------------------------*/
753void hdd_conf_ns_offload(hdd_adapter_t *pAdapter, int fenable)
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530754{
755 struct inet6_dev *in6_dev;
756 struct inet6_ifaddr *ifp;
757 struct list_head *p;
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530758 int slot_index = NS_DEFAULT_SLOT_INDEX;
Girish Gowli1b6114f2014-05-17 17:17:09 +0530759 tANI_U8 **selfIPv6Addr = NULL;
760 tANI_U8 *selfIPv6AddrValid = NULL;
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530761 tSirHostOffloadReq offLoadRequest;
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530762 hdd_context_t *pHddCtx;
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530763 tHalHandle halHandle;
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530764
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530765 int i = 0, slot = 0;
766 int ret = 0;
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530767 eHalStatus returnStatus;
768
Vinay Krishna Eranna941360f2014-01-16 15:38:22 +0530769 ENTER();
770 hddLog(LOG1, FL(" fenable = %d"), fenable);
771
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530772 if (NULL == pAdapter)
773 {
774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is Null"));
775 return;
776 }
777
778 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530779 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
780
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530781 ret = wlan_hdd_validate_context(pHddCtx);
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530782 if (0 != ret)
783 {
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530784 return;
785 }
786
787 if (sme_IsFeatureSupportedByFW(EXTENDED_NSOFFLOAD_SLOT))
788 {
789 slot_index = NS_EXTENDED_SLOT_INDEX;
790 }
791
792 hddLog(VOS_TRACE_LEVEL_INFO, FL("slot_idex = %d"), slot_index);
793
794 selfIPv6AddrValid =
795 (tANI_U8 *)vos_mem_malloc(sizeof(tANI_U8) * slot_index);
796
797 if (NULL == selfIPv6AddrValid)
798 {
799 hddLog (VOS_TRACE_LEVEL_ERROR, FL("Failed to allocate memory for"
800 " selfIPv6AddrValid"));
801 goto end;
802 }
803
804 vos_mem_zero(selfIPv6AddrValid, slot_index * sizeof(tANI_U8));
805
806 selfIPv6Addr = (tANI_U8 **)vos_mem_malloc(sizeof(tANI_U8 *) * slot_index);
807
808 if (NULL == selfIPv6Addr)
809 {
810 hddLog (VOS_TRACE_LEVEL_ERROR, FL("Failed to allocate memory for"
811 " selfIPv6Addr"));
812 goto end;
813 }
814
815 vos_mem_zero(selfIPv6Addr, slot_index * sizeof(tANI_U8 *));
816
817 for (slot = 0; slot < slot_index; slot++)
818 {
819 selfIPv6Addr[slot] =
820 (tANI_U8 *)vos_mem_malloc(SIR_MAC_IPV6_ADDR_LEN);
821 if (NULL == selfIPv6Addr[slot])
822 {
823 hddLog (VOS_TRACE_LEVEL_ERROR, FL("Failed to allocate memory"
824 "for selfIPv6Addr"));
825 goto end;
826 }
827 vos_mem_zero(selfIPv6Addr[slot], SIR_MAC_IPV6_ADDR_LEN);
828 }
829
830 i = 0;
831
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530832 if (fenable)
833 {
834 in6_dev = __in6_dev_get(pAdapter->dev);
835 if (NULL != in6_dev)
836 {
Srinivas Girigowdad26a8072016-10-19 20:26:42 +0530837 read_lock_bh(&in6_dev->lock);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530838 list_for_each(p, &in6_dev->addr_list)
839 {
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530840 if (i >= slot_index)
841 {
842 hddLog (VOS_TRACE_LEVEL_ERROR,
843 FL("IPv6 address list is greater than IPv6"
844 "address supported by firmware"));
845 hddLog (VOS_TRACE_LEVEL_ERROR,
846 FL("FW supported IPv6 address = %d"), slot_index);
847 break;
848 }
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530849 ifp = list_entry(p, struct inet6_ifaddr, if_list);
850 switch(ipv6_addr_src_scope(&ifp->addr))
851 {
852 case IPV6_ADDR_SCOPE_LINKLOCAL:
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530853 vos_mem_copy(selfIPv6Addr[i], &ifp->addr.s6_addr,
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530854 sizeof(ifp->addr.s6_addr));
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530855 selfIPv6AddrValid[i] = SIR_IPV6_ADDR_VALID;
Hardik Kantilal Patel1341bdf2013-08-22 20:27:15 +0530856 hddLog (VOS_TRACE_LEVEL_INFO,
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530857 FL("Found IPV6_ADDR_SCOPE_LINKLOCAL Address : %pI6"),
858 selfIPv6Addr[i]);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530859 break;
860 case IPV6_ADDR_SCOPE_GLOBAL:
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530861 vos_mem_copy(selfIPv6Addr[i], &ifp->addr.s6_addr,
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530862 sizeof(ifp->addr.s6_addr));
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530863 selfIPv6AddrValid[i] = SIR_IPV6_ADDR_VALID;
Hardik Kantilal Patel1341bdf2013-08-22 20:27:15 +0530864 hddLog (VOS_TRACE_LEVEL_INFO,
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530865 FL("Found IPV6_ADDR_SCOPE_GLOBAL Address : %pI6"),
866 selfIPv6Addr[i]);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530867 break;
868 default:
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530869 hddLog(VOS_TRACE_LEVEL_ERROR,
870 FL("The Scope %d is not supported"),
871 ipv6_addr_src_scope(&ifp->addr));
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530872 }
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530873 if (selfIPv6AddrValid[i] == SIR_IPV6_ADDR_VALID)
874 {
875 i++;
876 }
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530877 }
Srinivas Girigowdad26a8072016-10-19 20:26:42 +0530878 read_unlock_bh(&in6_dev->lock);
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530879
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530880 vos_mem_zero(&offLoadRequest, sizeof(offLoadRequest));
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530881 for (i =0; i < slot_index; i++)
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530882 {
883 if (selfIPv6AddrValid[i])
884 {
885 //Filling up the request structure
886 /* Filling the selfIPv6Addr with solicited address
887 * A Solicited-Node multicast address is created by
888 * taking the last 24 bits of a unicast or anycast
889 * address and appending them to the prefix
890 *
891 * FF02:0000:0000:0000:0000:0001:FFXX:XX
892 *
893 * here XX is the unicast/anycast bits
894 */
895 offLoadRequest.nsOffloadInfo.selfIPv6Addr[0] = 0xFF;
896 offLoadRequest.nsOffloadInfo.selfIPv6Addr[1] = 0x02;
897 offLoadRequest.nsOffloadInfo.selfIPv6Addr[11] = 0x01;
898 offLoadRequest.nsOffloadInfo.selfIPv6Addr[12] = 0xFF;
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530899 offLoadRequest.nsOffloadInfo.selfIPv6Addr[13] =
900 selfIPv6Addr[i][13];
901 offLoadRequest.nsOffloadInfo.selfIPv6Addr[14] =
902 selfIPv6Addr[i][14];
903 offLoadRequest.nsOffloadInfo.selfIPv6Addr[15] =
904 selfIPv6Addr[i][15];
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530905 offLoadRequest.nsOffloadInfo.slotIdx = i;
906
907 vos_mem_copy(&offLoadRequest.nsOffloadInfo.targetIPv6Addr[0],
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530908 selfIPv6Addr[i], sizeof(tANI_U8)*SIR_MAC_IPV6_ADDR_LEN);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530909 vos_mem_copy(&offLoadRequest.nsOffloadInfo.selfMacAddr,
910 &pAdapter->macAddressCurrent.bytes,
911 sizeof(tANI_U8)*SIR_MAC_ADDR_LEN);
912
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530913 offLoadRequest.nsOffloadInfo.targetIPv6AddrValid[0] =
914 SIR_IPV6_ADDR_VALID;
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530915 offLoadRequest.offloadType = SIR_IPV6_NS_OFFLOAD;
916 offLoadRequest.enableOrDisable = SIR_OFFLOAD_ENABLE;
Abhishek Singh937ec542016-01-05 18:03:14 +0530917 hdd_wlan_offload_event(SIR_IPV6_NS_OFFLOAD,
918 SIR_OFFLOAD_ENABLE);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530919
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530920 hddLog (VOS_TRACE_LEVEL_INFO,
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530921 FL("configuredMcastBcastFilter: %d"
922 "NSOffload Slot = %d"),
923 pHddCtx->configuredMcastBcastFilter, i);
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530924
Kiet Lamc8e1eb52013-10-24 00:30:49 +0530925 if ((VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
Amar Singhald08ce752014-03-21 16:28:27 -0700926 && ((HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST ==
927 pHddCtx->sus_res_mcastbcast_filter) ||
928 (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST ==
929 pHddCtx->sus_res_mcastbcast_filter)) &&
930 (!WDA_IS_MCAST_FLT_ENABLE_IN_FW ||
931 (WDA_IS_MCAST_FLT_ENABLE_IN_FW &&
932 !(pHddCtx->cfg_ini->fEnableMCAddrList))))
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530933 {
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530934 offLoadRequest.enableOrDisable =
Amar Singhald08ce752014-03-21 16:28:27 -0700935 SIR_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE;
Madan Mohan Koyyalamudibadffe72013-09-11 13:09:14 +0530936 }
Abhishek Singh937ec542016-01-05 18:03:14 +0530937 hdd_wlan_offload_event(
938 SIR_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE,
939 SIR_OFFLOAD_ENABLE);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +0530940 hddLog(VOS_TRACE_LEVEL_INFO,
941 FL("offload: NS filter programmed %d"),
942 offLoadRequest.enableOrDisable);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530943 vos_mem_copy(&offLoadRequest.params.hostIpv6Addr,
944 &offLoadRequest.nsOffloadInfo.targetIPv6Addr[0],
945 sizeof(tANI_U8)*SIR_MAC_IPV6_ADDR_LEN);
946
947 hddLog (VOS_TRACE_LEVEL_INFO,
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530948 FL("Setting NSOffload with solicitedIp: %pI6,"
949 "targetIp: %pI6"),
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530950 offLoadRequest.nsOffloadInfo.selfIPv6Addr,
951 offLoadRequest.nsOffloadInfo.targetIPv6Addr[0]);
952
953 //Configure the Firmware with this
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530954 returnStatus = sme_SetHostOffload(halHandle,
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530955 pAdapter->sessionId, &offLoadRequest);
956 if(eHAL_STATUS_SUCCESS != returnStatus)
957 {
958 hddLog(VOS_TRACE_LEVEL_ERROR,
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530959 FL("Failed to enable HostOffload feature with"
960 " status: %d"), returnStatus);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530961 }
962 vos_mem_zero(&offLoadRequest, sizeof(offLoadRequest));
963 }
964 }
965 }
966 else
967 {
968 hddLog(VOS_TRACE_LEVEL_ERROR,
969 FL("IPv6 dev does not exist. Failed to request NSOffload"));
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530970 goto end;
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530971 }
972 }
973 else
974 {
975 //Disable NSOffload
976 vos_mem_zero((void *)&offLoadRequest, sizeof(tSirHostOffloadReq));
977 offLoadRequest.enableOrDisable = SIR_OFFLOAD_DISABLE;
978 offLoadRequest.offloadType = SIR_IPV6_NS_OFFLOAD;
Abhishek Singh937ec542016-01-05 18:03:14 +0530979 hdd_wlan_offload_event(SIR_IPV6_NS_OFFLOAD,
980 SIR_OFFLOAD_DISABLE);
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530981
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530982 for (i = 0; i < slot_index; i++)
Vinay Krishna Erannab29c6142014-01-07 12:20:51 +0530983 {
c_hpothu86feba52014-10-28 15:51:18 +0530984 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disable Slot= %d"), i);
Vinay Krishna Erannab29c6142014-01-07 12:20:51 +0530985 offLoadRequest.nsOffloadInfo.slotIdx = i;
986 if (eHAL_STATUS_SUCCESS !=
Vinay Krishna Eranna911a3b82014-01-07 12:20:51 +0530987 sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
988 pAdapter->sessionId, &offLoadRequest))
Vinay Krishna Erannab29c6142014-01-07 12:20:51 +0530989 {
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failure to disable"
991 " %d Slot"), i);
Vinay Krishna Erannab29c6142014-01-07 12:20:51 +0530992 }
993 }
Gopichand Nakkala746a9452013-06-11 12:45:54 +0530994 }
Hardik Kantilal Patele1760e12014-01-21 15:57:21 +0530995end:
996 while (slot > 0 && selfIPv6Addr[--slot])
997 {
998 vos_mem_free(selfIPv6Addr[slot]);
999 }
1000 if (selfIPv6Addr)
1001 {
1002 vos_mem_free(selfIPv6Addr);
1003 }
1004 if (selfIPv6AddrValid)
1005 {
1006 vos_mem_free(selfIPv6AddrValid);
1007 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301008 EXIT();
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301009 return;
1010}
1011#endif
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301012
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301013void __hdd_ipv4_notifier_work_queue(struct work_struct *work)
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301014{
1015 hdd_adapter_t* pAdapter =
1016 container_of(work, hdd_adapter_t, ipv4NotifierWorkQueue);
1017 hdd_context_t *pHddCtx;
1018 int status;
1019
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301020 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301021 if (NULL == pAdapter)
1022 {
1023 hddLog(LOGE, FL("Adapter is invalid"));
1024 return;
1025 }
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301026 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1027 status = wlan_hdd_validate_context(pHddCtx);
1028 if (0 != status)
1029 {
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301030 return;
1031 }
1032
1033 if ((eConnectionState_Associated ==
1034 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)
Deepthi Gowri5933f402014-01-23 17:48:24 +05301035 && (pHddCtx->hdd_wlan_suspended))
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301036 {
1037 // This invocation being part of the IPv4 registration callback,
1038 // we are passing second parameter as 2 to avoid registration
1039 // of IPv4 notifier again.
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301040 check_and_set_suspend_resume_mcbc_filter(pHddCtx);
1041 if (pHddCtx->cfg_ini->fhostArpOffload)
1042 {
1043 hdd_conf_arp_offload(pAdapter, 2);
1044 }
1045 else
1046 {
1047 hddLog(VOS_TRACE_LEVEL_INFO,
1048 FL("offload: arp offload ini is disabled in host"));
1049 }
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301050 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301051 EXIT();
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301052}
1053
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301054void hdd_ipv4_notifier_work_queue(struct work_struct *work)
1055{
1056 vos_ssr_protect(__func__);
1057 __hdd_ipv4_notifier_work_queue(work);
1058 vos_ssr_unprotect(__func__);
1059}
1060
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +05301061int __wlan_hdd_ipv4_changed(struct notifier_block *nb,
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +05301062 unsigned long data, void *arg)
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301063{
1064 struct in_ifaddr *ifa = (struct in_ifaddr *)arg;
1065 struct in_ifaddr **ifap = NULL;
1066 struct in_device *in_dev;
1067
1068 struct net_device *ndev = ifa->ifa_dev->dev;
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301069 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +05301070 hdd_context_t *pHddCtx;
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301071 VOS_STATUS vos_status;
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +05301072 int status;
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05301073
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301074 ENTER();
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301075 pHddCtx = container_of(nb, hdd_context_t, ipv4_notifier);
1076 status = wlan_hdd_validate_context(pHddCtx);
1077 if (0 != status)
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301078 {
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301079 return NOTIFY_DONE;
1080 }
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +05301081
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301082 vos_status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
1083 while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == vos_status)
1084 {
1085 if (pAdapterNode->pAdapter && pAdapterNode->pAdapter->dev == ndev &&
1086 (pAdapterNode->pAdapter->device_mode == WLAN_HDD_INFRA_STATION ||
1087 pAdapterNode->pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
1088 {
Abhishek Singhe0bc0992016-05-20 17:58:18 +05301089
1090 if (eConnectionState_Associated ==
1091 WLAN_HDD_GET_STATION_CTX_PTR
1092 (pAdapterNode->pAdapter)->conn_info.connState)
1093 sme_dhcp_done_ind(pHddCtx->hHal,
1094 pAdapterNode->pAdapter->sessionId);
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301095 if ((pHddCtx->cfg_ini->nEnableSuspend !=
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +05301096 WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER)
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301097 || (!pHddCtx->cfg_ini->fhostArpOffload))
1098 {
1099 hddLog(LOG1, FL("Offload not enabled MCBC=%d, ARPOffload=%d"),
1100 pHddCtx->cfg_ini->nEnableSuspend,
1101 pHddCtx->cfg_ini->fhostArpOffload);
1102 return NOTIFY_DONE;
1103 }
Vinay Krishna Eranna83b0ef72014-11-19 16:56:20 +05301104
Vinay Krishna Eranna55029602015-02-06 15:43:35 +05301105 if ((in_dev =
1106 __in_dev_get_rtnl(pAdapterNode->pAdapter->dev)) != NULL)
1107 {
1108 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
1109 ifap = &ifa->ifa_next)
1110 {
1111 if (!strcmp(pAdapterNode->pAdapter->dev->name,
1112 ifa->ifa_label))
1113 {
1114 break; /* found */
1115 }
1116 }
1117 }
1118 if(ifa && ifa->ifa_local)
1119 {
1120 schedule_work(&pAdapterNode->pAdapter->ipv4NotifierWorkQueue);
1121 }
1122 break;
1123 }
1124 vos_status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
1125 pAdapterNode = pNext;
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301126 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301127 EXIT();
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301128 return NOTIFY_DONE;
1129}
1130
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +05301131int wlan_hdd_ipv4_changed(struct notifier_block *nb,
1132 unsigned long data, void *arg)
1133{
1134 int ret;
1135 vos_ssr_protect(__func__);
1136 ret = __wlan_hdd_ipv4_changed( nb, data, arg);
1137 vos_ssr_unprotect(__func__);
1138 return ret;
1139}
1140
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301141/**----------------------------------------------------------------------------
1142
1143 \brief hdd_conf_arp_offload() - Configure ARP offload
1144
1145 Called during SUSPEND to configure the ARP offload (MC BC filter) which
1146 reduces power consumption.
1147
1148 \param - pAdapter -Adapter context for which ARP offload is to be configured
1149 \param - fenable - 0 - disable.
1150 1 - enable. (with IPv4 notifier registration)
1151 2 - enable. (without IPv4 notifier registration)
1152
1153 \return -
1154 VOS_STATUS_SUCCESS - on successful operation
1155 VOS_STATUS_E_FAILURE - on failure of operation
1156-----------------------------------------------------------------------------*/
1157VOS_STATUS hdd_conf_arp_offload(hdd_adapter_t *pAdapter, int fenable)
Jeff Johnson295189b2012-06-20 16:38:30 -07001158{
1159 struct in_ifaddr **ifap = NULL;
1160 struct in_ifaddr *ifa = NULL;
1161 struct in_device *in_dev;
1162 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 tSirHostOffloadReq offLoadRequest;
Yathish9f22e662012-12-10 14:21:35 -08001164 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
Sushant Kaushik87787972015-09-11 16:05:00 +05301166 hddLog(VOS_TRACE_LEVEL_INFO, FL(" fenable = %d "), fenable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 if(fenable)
1169 {
1170 if ((in_dev = __in_dev_get_rtnl(pAdapter->dev)) != NULL)
1171 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301172 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 ifap = &ifa->ifa_next)
1174 {
1175 if (!strcmp(pAdapter->dev->name, ifa->ifa_label))
1176 {
1177 break; /* found */
1178 }
1179 }
1180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 if(ifa && ifa->ifa_local)
1182 {
1183 offLoadRequest.offloadType = SIR_IPV4_ARP_REPLY_OFFLOAD;
1184 offLoadRequest.enableOrDisable = SIR_OFFLOAD_ENABLE;
Abhishek Singh937ec542016-01-05 18:03:14 +05301185 hdd_wlan_offload_event(SIR_IPV4_ARP_REPLY_OFFLOAD,
1186 SIR_OFFLOAD_ENABLE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001187
Arif Hussain6d2a3322013-11-17 19:50:10 -08001188 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001189
Amar Singhald53568e2013-09-26 11:03:45 -07001190 if (((HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST ==
1191 pHddCtx->sus_res_mcastbcast_filter) ||
1192 (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST ==
1193 pHddCtx->sus_res_mcastbcast_filter)) &&
1194 (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid))
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07001195 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301196 offLoadRequest.enableOrDisable =
Amar Singhald53568e2013-09-26 11:03:45 -07001197 SIR_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE;
1198 hddLog(VOS_TRACE_LEVEL_INFO,
1199 "offload: inside arp offload conditional check");
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 }
Abhishek Singh937ec542016-01-05 18:03:14 +05301201 hdd_wlan_offload_event(SIR_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE,
1202 SIR_OFFLOAD_ENABLE);
Amar Singhald53568e2013-09-26 11:03:45 -07001203
1204 hddLog(VOS_TRACE_LEVEL_INFO, "offload: arp filter programmed = %d",
1205 offLoadRequest.enableOrDisable);
1206
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 //converting u32 to IPV4 address
1208 for(i = 0 ; i < 4; i++)
1209 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301210 offLoadRequest.params.hostIpv4Addr[i] =
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 (ifa->ifa_local >> (i*8) ) & 0xFF ;
1212 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301213 hddLog(VOS_TRACE_LEVEL_INFO, " Enable SME HostOffload: %d.%d.%d.%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 offLoadRequest.params.hostIpv4Addr[0],
1215 offLoadRequest.params.hostIpv4Addr[1],
1216 offLoadRequest.params.hostIpv4Addr[2],
1217 offLoadRequest.params.hostIpv4Addr[3]);
1218
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301219 if (eHAL_STATUS_SUCCESS !=
1220 sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
1221 pAdapter->sessionId, &offLoadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 {
1223 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to enable HostOffload "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001224 "feature", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 return VOS_STATUS_E_FAILURE;
1226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 }
1228 else
1229 {
SaidiReddy Yenugaa8b32f92016-07-27 19:29:18 +05301230 hddLog(VOS_TRACE_LEVEL_WARN, FL("IP Address is not assigned"));
Agarwal Ashish971c2882013-10-30 20:11:12 +05301231 return VOS_STATUS_E_AGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 }
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301233
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05301234 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 }
1236 else
1237 {
1238 vos_mem_zero((void *)&offLoadRequest, sizeof(tSirHostOffloadReq));
1239 offLoadRequest.enableOrDisable = SIR_OFFLOAD_DISABLE;
1240 offLoadRequest.offloadType = SIR_IPV4_ARP_REPLY_OFFLOAD;
Abhishek Singh937ec542016-01-05 18:03:14 +05301241 hdd_wlan_offload_event(SIR_IPV4_ARP_REPLY_OFFLOAD,
1242 SIR_OFFLOAD_DISABLE);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301243 if (eHAL_STATUS_SUCCESS !=
1244 sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
1245 pAdapter->sessionId, &offLoadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 {
1247 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to disable host "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001248 "offload feature", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 return VOS_STATUS_E_FAILURE;
1250 }
1251 return VOS_STATUS_SUCCESS;
1252 }
1253}
1254
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301255/*
1256 * This function is called before setting mcbc filters
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301257 * to modify filter value considering Different Offloads
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301258*/
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301259void hdd_mcbc_filter_modification(hdd_context_t* pHddCtx,
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301260 tANI_U8 *pMcBcFilter)
1261{
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301262 if (NULL == pHddCtx)
1263 {
1264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("NULL HDD context passed"));
1265 return;
1266 }
1267
1268 *pMcBcFilter = pHddCtx->configuredMcastBcastFilter;
1269 if (pHddCtx->cfg_ini->fhostArpOffload)
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301270 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301271 /* ARP offload is enabled, do not block bcast packets at RXP
1272 * Will be using Bitmasking to reset the filter. As we have
1273 * disable Broadcast filtering, Anding with the negation
1274 * of Broadcast BIT
1275 */
Agarwal Ashishff451a32015-07-28 01:01:29 +05301276 hddLog(VOS_TRACE_LEVEL_INFO, FL(" ARP offload is enabled"));
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301277 *pMcBcFilter &= ~(HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST);
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301278 }
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301279
1280#ifdef WLAN_NS_OFFLOAD
1281 if (pHddCtx->cfg_ini->fhostNSOffload)
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301282 {
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301283 /* NS offload is enabled, do not block mcast packets at RXP
1284 * Will be using Bitmasking to reset the filter. As we have
1285 * disable Multicast filtering, Anding with the negation
1286 * of Multicast BIT
1287 */
Agarwal Ashishff451a32015-07-28 01:01:29 +05301288 hddLog(VOS_TRACE_LEVEL_INFO, FL(" NS offload is enabled"));
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301289 *pMcBcFilter &= ~(HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST);
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301290 }
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301291#endif
1292
Amar Singhald08ce752014-03-21 16:28:27 -07001293 if ((pHddCtx->cfg_ini->fEnableMCAddrList) && WDA_IS_MCAST_FLT_ENABLE_IN_FW)
1294 {
1295 *pMcBcFilter &= ~(HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST);
1296 }
1297
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301298 pHddCtx->configuredMcastBcastFilter = *pMcBcFilter;
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301299}
1300
Jeff Johnson295189b2012-06-20 16:38:30 -07001301void hdd_conf_mcastbcast_filter(hdd_context_t* pHddCtx, v_BOOL_t setfilter)
1302{
1303 eHalStatus halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 tpSirWlanSetRxpFilters wlanRxpFilterParam =
1305 vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
Agarwal Ashishff451a32015-07-28 01:01:29 +05301306 if (NULL == wlanRxpFilterParam)
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 {
1308 hddLog(VOS_TRACE_LEVEL_FATAL,
1309 "%s: vos_mem_alloc failed ", __func__);
1310 return;
1311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 hddLog(VOS_TRACE_LEVEL_INFO,
1313 "%s: Configuring Mcast/Bcast Filter Setting. setfilter %d", __func__, setfilter);
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301314 if (TRUE == setfilter)
1315 {
Gopichand Nakkala746a9452013-06-11 12:45:54 +05301316 hdd_mcbc_filter_modification(pHddCtx,
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301317 &wlanRxpFilterParam->configuredMcstBcstFilterSetting);
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301318 }
1319 else
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301320 {
1321 /*Use the current configured value to clear*/
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301322 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05301323 pHddCtx->configuredMcastBcastFilter;
1324 }
Gopichand Nakkalab8ddf462013-02-20 18:53:50 +05301325
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 wlanRxpFilterParam->setMcstBcstFilter = setfilter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 halStatus = sme_ConfigureRxpFilter(pHddCtx->hHal, wlanRxpFilterParam);
Masti, Narayanraddibdc261d2015-01-22 15:59:49 +05301328
1329 if (setfilter && (eHAL_STATUS_SUCCESS == halStatus))
Agarwal Ashishff451a32015-07-28 01:01:29 +05301330 {
Masti, Narayanraddibdc261d2015-01-22 15:59:49 +05301331 pHddCtx->hdd_mcastbcast_filter_set = TRUE;
Agarwal Ashishff451a32015-07-28 01:01:29 +05301332 }
Masti, Narayanraddibdc261d2015-01-22 15:59:49 +05301333
1334 hddLog(VOS_TRACE_LEVEL_INFO, "%s to post set/reset filter to"
1335 "lower mac with status %d"
1336 "configuredMcstBcstFilterSetting = %d"
1337 "setMcstBcstFilter = %d",(eHAL_STATUS_SUCCESS != halStatus) ?
1338 "Failed" : "Success", halStatus,
1339 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
1340 wlanRxpFilterParam->setMcstBcstFilter);
1341
Chilam Ngc4244af2013-04-01 15:37:32 -07001342 if (eHAL_STATUS_SUCCESS != halStatus)
1343 vos_mem_free(wlanRxpFilterParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001344}
1345
mukul sharmae4abd892016-11-24 22:03:31 +05301346/*
1347 * Enable/Disable McAddrList cfg item in fwr.
1348 */
1349eHalStatus hdd_set_mc_list_cfg_item(hdd_context_t* pHddCtx,
1350 bool value)
1351{
1352 eHalStatus ret_val;
1353
1354 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_ENABLE_MC_ADDR_LIST,
1355 value, NULL, eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1356 {
1357 ret_val = eHAL_STATUS_FAILURE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301358 hddLog(LOGE,
1359 FL("offload: can't pass WNI_CFG_ENABLE_MC_ADDR_LIST to CCM"));
mukul sharmae4abd892016-11-24 22:03:31 +05301360 return ret_val;
1361 }
1362
1363 ret_val = sme_update_cfg_int_param(pHddCtx->hHal,
1364 WNI_CFG_ENABLE_MC_ADDR_LIST);
1365 if (!HAL_STATUS_SUCCESS(ret_val))
1366 {
1367 hddLog(VOS_TRACE_LEVEL_ERROR,
1368 FL("Failed to toggle MC_ADDR_LIST_INI %d "),
1369 ret_val);
1370 return ret_val;
1371 }
1372 /* cache the value configured in fwr */
1373 pHddCtx->mc_list_cfg_in_fwr = value;
mukul sharmae4abd892016-11-24 22:03:31 +05301374 return eHAL_STATUS_SUCCESS;
1375}
1376
1377bool is_mc_list_cfg_disable_required(hdd_context_t* pHddCtx)
1378{
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301379 hddLog(VOS_TRACE_LEVEL_INFO,
1380 FL("offload: fEnableMCList %d sus_res_mcbc_filter %d mc_list_in_fwr %d"),
1381 pHddCtx->cfg_ini->fEnableMCAddrList,
1382 pHddCtx->sus_res_mcastbcast_filter,
1383 pHddCtx->mc_list_cfg_in_fwr);
1384
mukul sharmae4abd892016-11-24 22:03:31 +05301385 /*
1386 * If MCAddrList is enabled in ini and MCBC filter is set to
1387 * Either Filter None or Filter all BC then, Fwr need to push
1388 * all MC to host. This can be achieved by disabling cfg MCAddrList
1389 * in fwr. As in driver load, firmware have this value to 1 we
1390 * need to set it to 0. Same needs to be reverted on resume.
1391 */
1392 if (pHddCtx->cfg_ini->fEnableMCAddrList &&
1393 WDA_IS_MCAST_FLT_ENABLE_IN_FW &&
1394 ((VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)&&
1395 ((HDD_MCASTBCASTFILTER_FILTER_NONE ==
1396 pHddCtx->sus_res_mcastbcast_filter) ||
1397 (HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST ==
1398 pHddCtx->sus_res_mcastbcast_filter)))
1399 )
1400 {
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301401 hddLog(VOS_TRACE_LEVEL_INFO,
1402 FL("offload: cfg ini need to disable in fwr"));
mukul sharmae4abd892016-11-24 22:03:31 +05301403 return true;
1404 }
1405 else
1406 {
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301407 hddLog(VOS_TRACE_LEVEL_INFO,
1408 FL("offload: cfg ini disable not needed "));
mukul sharmae4abd892016-11-24 22:03:31 +05301409 return false;
1410 }
1411}
1412
1413/**
1414 * hdd_mc_addr_list_cfg_config() - To set mc list cfg configuration in fwr
1415 * @pHddCtx: hdd context handle
1416 * @action: true to disable MCAddrList in fwr to get all MC pkt to host
1417 * false to set ini value of MCAddrList in fwr if it was toggled
1418 * Return: none
1419 *
1420 * Ensure Below API is invoked always post modification
1421 * of sus_res_mcastbcast_filter.
1422 */
1423void hdd_mc_addr_list_cfg_config(hdd_context_t* pHddCtx, bool action)
1424{
1425 if (action)
1426 {
1427 /* check host need to disable mc list ini in fwr */
1428 if (is_mc_list_cfg_disable_required(pHddCtx))
1429 {
1430 /*
1431 * Yes Host should disable the mc list in fwr
1432 * But Ensure host might already disable it
1433 * This can happen when user issue set/clear MCBC
1434 * ioctl with 2 to 0 or vice versa.
1435 */
1436 if (pHddCtx->cfg_ini->fEnableMCAddrList ==
1437 pHddCtx->mc_list_cfg_in_fwr)
1438 {
1439 hdd_set_mc_list_cfg_item(pHddCtx,
1440 !pHddCtx->cfg_ini->fEnableMCAddrList);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301441 hddLog(VOS_TRACE_LEVEL_INFO,
1442 FL("offload: setting mc_list_cfg_in_fwr: %d"),
1443 !pHddCtx->cfg_ini->fEnableMCAddrList);
mukul sharmae4abd892016-11-24 22:03:31 +05301444 }
1445 }
1446 else
1447 {
1448 /* Host toggled mc list ini in fwr previosuly, set to ini value */
1449 if (pHddCtx->cfg_ini->fEnableMCAddrList !=
1450 pHddCtx->mc_list_cfg_in_fwr)
1451 {
1452 hdd_set_mc_list_cfg_item(pHddCtx,
1453 pHddCtx->cfg_ini->fEnableMCAddrList);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301454 hddLog(VOS_TRACE_LEVEL_INFO,
1455 FL("offload: setting mc_list_cfg_in_fwr: %d"),
1456 pHddCtx->cfg_ini->fEnableMCAddrList);
mukul sharmae4abd892016-11-24 22:03:31 +05301457 }
1458 }
1459 }
1460 else
1461 {
1462 /* Host toggled mc list ini in fwr previosuly, set to ini value */
1463 if (pHddCtx->cfg_ini->fEnableMCAddrList !=
1464 pHddCtx->mc_list_cfg_in_fwr)
1465 {
1466 hdd_set_mc_list_cfg_item(pHddCtx,
1467 pHddCtx->cfg_ini->fEnableMCAddrList);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301468 hddLog(VOS_TRACE_LEVEL_INFO,
1469 FL("offload: setting mc_list_cfg_in_fwr: %d"),
1470 pHddCtx->cfg_ini->fEnableMCAddrList);
mukul sharmae4abd892016-11-24 22:03:31 +05301471 }
1472 }
1473}
1474
Kapil Gupta2b44acb2016-12-30 16:49:51 +05301475/**
1476 * hdd_suspend_ind_callback: This API will set completion event for suspend
1477 * @pAdapter: hdd_adapter_t
1478 * @status: suspend status
1479 *
1480 * Return: none
1481 */
1482static void hdd_suspend_ind_callback(void *context, VOS_STATUS status)
1483{
1484 hdd_adapter_t *adapter = (hdd_adapter_t *)context;
1485 if (NULL == adapter)
1486 {
1487 hddLog(VOS_TRACE_LEVEL_ERROR,
1488 "%s: HDD adapter is NULL",__func__);
1489 return;
1490 }
1491 hddLog(VOS_TRACE_LEVEL_INFO, FL("suspend status %d"), status);
1492 complete(&adapter->wlan_suspend_comp_var);
1493}
1494
Jeff Johnson295189b2012-06-20 16:38:30 -07001495static void hdd_conf_suspend_ind(hdd_context_t* pHddCtx,
1496 hdd_adapter_t *pAdapter)
1497{
1498 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1499 tpSirWlanSuspendParam wlanSuspendParam =
1500 vos_mem_malloc(sizeof(tSirWlanSuspendParam));
1501
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301502 check_and_set_suspend_resume_mcbc_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 if(NULL == wlanSuspendParam)
1504 {
1505 hddLog(VOS_TRACE_LEVEL_FATAL,
1506 "%s: vos_mem_alloc failed ", __func__);
1507 return;
1508 }
1509
Amar Singhald53568e2013-09-26 11:03:45 -07001510 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 "%s: send wlan suspend indication", __func__);
1512
1513 if((pHddCtx->cfg_ini->nEnableSuspend == WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER))
1514 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301515 //Configure supported OffLoads
1516 hdd_conf_hostoffload(pAdapter, TRUE);
1517 wlanSuspendParam->configuredMcstBcstFilterSetting = pHddCtx->configuredMcastBcastFilter;
Sushant Kaushik439d4c72014-05-12 16:39:51 +05301518 hddLog(VOS_TRACE_LEVEL_INFO,
1519 FL("saving configuredMcastBcastFilterSetting = %d"),
1520 wlanSuspendParam->configuredMcstBcstFilterSetting);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05301522 /* During suspend, configure MC Addr list filter to the firmware
1523 * function takes care of checking necessary conditions before
1524 * configuring.
1525 */
1526 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001527#endif
Amar Singhald08ce752014-03-21 16:28:27 -07001528
1529 if( (pHddCtx->cfg_ini->fEnableMCAddrList) && WDA_IS_MCAST_FLT_ENABLE_IN_FW)
1530 {
1531
1532 hddLog(VOS_TRACE_LEVEL_INFO, "offload: MCaddrlist: FW capability set ");
1533 pHddCtx->configuredMcastBcastFilter &=
1534 ~(HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST);
1535 }
1536
1537 wlanSuspendParam->configuredMcstBcstFilterSetting =
1538 pHddCtx->configuredMcastBcastFilter;
mukul sharmae4abd892016-11-24 22:03:31 +05301539
Kapil Gupta2b44acb2016-12-30 16:49:51 +05301540 wlanSuspendParam->wlan_sus_callback = hdd_suspend_ind_callback;
1541 wlanSuspendParam->context = pAdapter;
mukul sharmae4abd892016-11-24 22:03:31 +05301542 /* mc add list cfg item configuration in fwr */
1543 hdd_mc_addr_list_cfg_config(pHddCtx, true);
1544
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 }
1546
1547 halStatus = sme_ConfigureSuspendInd(pHddCtx->hHal, wlanSuspendParam);
1548 if(eHAL_STATUS_SUCCESS == halStatus)
1549 {
1550 pHddCtx->hdd_mcastbcast_filter_set = TRUE;
Chilam Ngc4244af2013-04-01 15:37:32 -07001551 } else {
c_hpothuffdb5272013-10-02 16:42:35 +05301552 hddLog(VOS_TRACE_LEVEL_ERROR,
1553 FL("sme_ConfigureSuspendInd returned failure %d"), halStatus);
Chilam Ngc4244af2013-04-01 15:37:32 -07001554 vos_mem_free(wlanSuspendParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 }
1556}
1557
Gopichand Nakkala0f276812013-02-24 14:45:51 +05301558static void hdd_conf_resume_ind(hdd_adapter_t *pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001559{
Chilam Ngc4244af2013-04-01 15:37:32 -07001560 eHalStatus halStatus = eHAL_STATUS_FAILURE;
Yathish9f22e662012-12-10 14:21:35 -08001561 hdd_context_t* pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Chilam Ngc4244af2013-04-01 15:37:32 -07001562 tpSirWlanResumeParam wlanResumeParam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
Gopichand Nakkala0f276812013-02-24 14:45:51 +05301564 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 "%s: send wlan resume indication", __func__);
1566
Madan Mohan Koyyalamudia6d7eab2013-09-25 10:21:22 +05301567 wlanResumeParam = vos_mem_malloc(sizeof(tSirWlanResumeParam));
1568
1569 if (NULL == wlanResumeParam)
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 {
Madan Mohan Koyyalamudia6d7eab2013-09-25 10:21:22 +05301571 hddLog(VOS_TRACE_LEVEL_FATAL,
1572 "%s: memory allocation failed for wlanResumeParam ", __func__);
1573 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001575
Madan Mohan Koyyalamudia6d7eab2013-09-25 10:21:22 +05301576 //Disable supported OffLoads
1577 hdd_conf_hostoffload(pAdapter, FALSE);
1578
1579 wlanResumeParam->configuredMcstBcstFilterSetting =
1580 pHddCtx->configuredMcastBcastFilter;
1581 halStatus = sme_ConfigureResumeReq(pHddCtx->hHal, wlanResumeParam);
1582 if (eHAL_STATUS_SUCCESS != halStatus)
1583 {
c_hpothuffdb5272013-10-02 16:42:35 +05301584 hddLog(VOS_TRACE_LEVEL_ERROR,
1585 "%s: sme_ConfigureResumeReq return failure %d", __func__, halStatus);
Madan Mohan Koyyalamudia6d7eab2013-09-25 10:21:22 +05301586 vos_mem_free(wlanResumeParam);
1587 }
1588
1589 pHddCtx->hdd_mcastbcast_filter_set = FALSE;
mukul sharmae4abd892016-11-24 22:03:31 +05301590 /* mc add list cfg item configuration in fwr */
1591 hdd_mc_addr_list_cfg_config(pHddCtx, false);
Madan Mohan Koyyalamudia6d7eab2013-09-25 10:21:22 +05301592
Amar Singhalf8ba2b82013-12-02 12:54:38 -08001593 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
1594 pHddCtx->configuredMcastBcastFilter =
1595 pHddCtx->sus_res_mcastbcast_filter;
1596 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
1597 }
Amar Singhald53568e2013-09-26 11:03:45 -07001598
1599 hddLog(VOS_TRACE_LEVEL_INFO,
1600 "offload: in hdd_conf_resume_ind, restoring configuredMcastBcastFilter");
1601 hddLog(VOS_TRACE_LEVEL_INFO, "configuredMcastBcastFilter = %d",
1602 pHddCtx->configuredMcastBcastFilter);
Amar Singhal49fdfd52013-08-13 13:25:12 -07001603
Chilam Ngc4244af2013-04-01 15:37:32 -07001604
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05301605#ifdef WLAN_FEATURE_PACKET_FILTERING
1606 /* Filer was applied during suspend inditication
1607 * clear it when we resume.
1608 */
1609 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001610#endif
1611}
Jeff Johnson295189b2012-06-20 16:38:30 -07001612
Jeff Johnson295189b2012-06-20 16:38:30 -07001613//Suspend routine registered with Android OS
Sameer Thalappil45931fb2013-02-01 11:18:05 -08001614void hdd_suspend_wlan(void)
Jeff Johnson295189b2012-06-20 16:38:30 -07001615{
1616 hdd_context_t *pHddCtx = NULL;
1617 v_CONTEXT_t pVosContext = NULL;
Kapil Gupta2b44acb2016-12-30 16:49:51 +05301618 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 VOS_STATUS status;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301620 hdd_adapter_t *pAdapter = NULL;
1621 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
madan mohan koyyalamudi459d6e72013-07-09 23:36:00 +05301622 bool hdd_enter_bmps = FALSE;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08001623
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being suspended by Android OS",__func__);
1625
1626 //Get the global VOSS context.
1627 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1628 if(!pVosContext) {
1629 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
1630 return;
1631 }
1632
1633 //Get the HDD context.
1634 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1635
1636 if(!pHddCtx) {
1637 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
1638 return;
1639 }
1640
1641 if (pHddCtx->isLogpInProgress) {
1642 hddLog(VOS_TRACE_LEVEL_ERROR,
1643 "%s: Ignore suspend wlan, LOGP in progress!", __func__);
1644 return;
1645 }
1646
Padma, Santhosh Kumar2ee1ad02015-01-12 16:05:47 +05301647 if (pHddCtx->hdd_wlan_suspended)
1648 {
SaidiReddy Yenugaa8b32f92016-07-27 19:29:18 +05301649 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar2ee1ad02015-01-12 16:05:47 +05301650 "%s: Ignore suspend wlan, Already suspended!", __func__);
1651 return;
1652 }
1653
Mahesh A Saptasagar0ea15c22014-10-28 15:26:57 +05301654 pHddCtx->hdd_wlan_suspended = TRUE;
Abhishek Singh37471cd2016-01-05 17:09:57 +05301655 hdd_wlan_suspend_resume_event(HDD_WLAN_EARLY_SUSPEND);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301656 hdd_set_pwrparams(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1658 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
1659 {
1660 pAdapter = pAdapterNode->pAdapter;
1661 if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
Madan Mohan Koyyalamudi802d7582012-10-31 14:19:40 -07001662 && (WLAN_HDD_SOFTAP != pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) )
1664
Madan Mohan Koyyalamudi802d7582012-10-31 14:19:40 -07001665 { // we skip this registration for modes other than STA, SAP and P2P client modes.
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
1667 pAdapterNode = pNext;
1668 continue;
1669 }
madan mohan koyyalamudi459d6e72013-07-09 23:36:00 +05301670 /* Avoid multiple enter/exit BMPS in this while loop using
1671 * hdd_enter_bmps flag
1672 */
1673 if (FALSE == hdd_enter_bmps && (BMPS == pmcGetPmcState(pHddCtx->hHal)))
1674 {
1675 hdd_enter_bmps = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
madan mohan koyyalamudi459d6e72013-07-09 23:36:00 +05301677 /* If device was already in BMPS, and dynamic DTIM is set,
1678 * exit(set the device to full power) and enter BMPS again
1679 * to reflect new DTIM value */
1680 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
1681
1682 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
1683
1684 pHddCtx->hdd_ignore_dtim_enabled = TRUE;
1685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001686#ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP
1687 if (pHddCtx->cfg_ini->nEnableSuspend == WLAN_MAP_SUSPEND_TO_STANDBY)
1688 {
1689 //stop the interface before putting the chip to standby
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301690 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 netif_tx_disable(pAdapter->dev);
1692 netif_carrier_off(pAdapter->dev);
1693 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301694 else if (pHddCtx->cfg_ini->nEnableSuspend ==
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 WLAN_MAP_SUSPEND_TO_DEEP_SLEEP)
1696 {
1697 //Execute deep sleep procedure
1698 hdd_enter_deep_sleep(pHddCtx, pAdapter);
1699 }
1700#endif
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301701
Kapil Gupta2b44acb2016-12-30 16:49:51 +05301702 INIT_COMPLETION(pAdapter->wlan_suspend_comp_var);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301703 /*Suspend notification sent down to driver*/
1704 hdd_conf_suspend_ind(pHddCtx, pAdapter);
Kapil Gupta2b44acb2016-12-30 16:49:51 +05301705 ret = wait_for_completion_interruptible_timeout(
1706 &pAdapter->wlan_suspend_comp_var,
1707 msecs_to_jiffies(WLAN_WAIT_TIME_FULL_PWR));
1708 if (0 >= ret)
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:wait on suspend failed %ld",
1711 __func__, ret);
1712 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301713 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
1714 pAdapterNode = pNext;
1715 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301716
Jeff Johnson295189b2012-06-20 16:38:30 -07001717#ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP
1718 if(pHddCtx->cfg_ini->nEnableSuspend == WLAN_MAP_SUSPEND_TO_STANDBY)
1719 {
1720 hdd_enter_standby(pHddCtx);
1721 }
1722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001723
1724 return;
1725}
1726
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301727/**
1728 * @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1729 * suspend related data which was cleared during roaming in FWR.
1730 */
1731void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1732
1733{
1734 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1735 hdd_adapter_t *pAdapter;
1736 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1737
1738 ENTER();
1739
1740 spin_lock(&pHddCtx->filter_lock);
1741 check_and_set_suspend_resume_mcbc_filter(pHddCtx);
1742 spin_unlock(&pHddCtx->filter_lock);
1743
1744 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1745 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1746 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1747
1748 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1749 //No need to configure GTK Offload from here because it might possible
1750 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1751 //be handled as part of cfg80211_set_rekey_data processing.
1752 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1753 {
1754 pAdapter = pAdapterNode->pAdapter;
1755 if( pAdapter &&
1756 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1757 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1758 {
1759 if (pHddCtx->cfg_ini->fhostArpOffload)
1760 {
1761 //Configure ARPOFFLOAD
1762 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1763 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1764 {
1765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("Failed to disable ARPOffload Feature %d"), vstatus);
1767 }
1768 }
1769#ifdef WLAN_NS_OFFLOAD
1770 //Configure NSOFFLOAD
1771 if (pHddCtx->cfg_ini->fhostNSOffload)
1772 {
1773 hdd_conf_ns_offload(pAdapter, TRUE);
1774 }
1775#endif
1776#ifdef WLAN_FEATURE_PACKET_FILTERING
1777 /* During suspend, configure MC Addr list filter to the firmware
1778 * function takes care of checking necessary conditions before
1779 * configuring.
1780 */
1781 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
1782#endif
1783 }
1784 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
1785 pAdapterNode = pNext;
1786 }
1787 EXIT();
1788}
1789
Jeff Johnson295189b2012-06-20 16:38:30 -07001790static void hdd_PowerStateChangedCB
1791(
1792 v_PVOID_t callbackContext,
1793 tPmcState newState
1794)
1795{
1796 hdd_context_t *pHddCtx = callbackContext;
Mukul Sharmabb94ece2014-04-04 21:22:15 +05301797
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 /* if the driver was not in BMPS during early suspend,
1799 * the dynamic DTIM is now updated at Riva */
1800 if ((newState == BMPS) && pHddCtx->hdd_wlan_suspended
Abhishek Singh0ea13232016-02-12 16:46:10 +05301801 && (pHddCtx->cfg_ini->enableDynamicDTIM ||
1802 pHddCtx->cfg_ini->enableModulatedDTIM)
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 && (pHddCtx->hdd_ignore_dtim_enabled == FALSE))
1804 {
1805 pHddCtx->hdd_ignore_dtim_enabled = TRUE;
1806 }
1807 spin_lock(&pHddCtx->filter_lock);
Agarwal Ashish469b1e52014-01-17 09:13:10 +05301808 if ((newState == BMPS) && pHddCtx->hdd_wlan_suspended)
1809 {
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05301810 check_and_set_suspend_resume_mcbc_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 spin_unlock(&pHddCtx->filter_lock);
1812 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1814 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not able to set mcast/bcast filter ", __func__);
Mukul Sharmabb94ece2014-04-04 21:22:15 +05301815 }
Amar Singhal49fdfd52013-08-13 13:25:12 -07001816 else
Mihir Shete793209f2014-01-06 11:01:12 +05301817 {
1818 /* Android framework can send resume request when the WCN chip is
1819 * in IMPS mode. When the chip exits IMPS mode the firmware will
1820 * restore all the registers to the state they were before the chip
1821 * entered IMPS and so our hardware filter settings confgured by the
1822 * resume request will be lost. So reconfigure the filters on detecting
1823 * a change in the power state of the WCN chip.
1824 */
Agarwal Ashish469b1e52014-01-17 09:13:10 +05301825 spin_unlock(&pHddCtx->filter_lock);
Mihir Shete793209f2014-01-06 11:01:12 +05301826 if (IMPS != newState)
1827 {
Agarwal Ashish469b1e52014-01-17 09:13:10 +05301828 spin_lock(&pHddCtx->filter_lock);
Mihir Shete793209f2014-01-06 11:01:12 +05301829 if (FALSE == pHddCtx->hdd_wlan_suspended)
1830 {
Agarwal Ashish469b1e52014-01-17 09:13:10 +05301831 spin_unlock(&pHddCtx->filter_lock);
Mihir Shete793209f2014-01-06 11:01:12 +05301832 hddLog(VOS_TRACE_LEVEL_INFO,
1833 "Not in IMPS/BMPS and suspended state");
1834 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
1835 }
Agarwal Ashish469b1e52014-01-17 09:13:10 +05301836 else
1837 {
1838 spin_unlock(&pHddCtx->filter_lock);
1839 }
Mihir Shete793209f2014-01-06 11:01:12 +05301840 }
Agarwal Ashish469b1e52014-01-17 09:13:10 +05301841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001842}
1843
Jeff Johnson295189b2012-06-20 16:38:30 -07001844void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx)
1845{
1846 v_CONTEXT_t pVosContext;
1847 tHalHandle smeContext;
1848
1849 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1850 if (NULL == pVosContext)
1851 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001852 hddLog(LOGE, "%s: Invalid pContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 return;
1854 }
1855 smeContext = vos_get_context(VOS_MODULE_ID_SME, pVosContext);
1856 if (NULL == smeContext)
1857 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001858 hddLog(LOGE, "%s: Invalid smeContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 return;
1860 }
1861
1862 spin_lock_init(&pHddCtx->filter_lock);
1863 if (WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER ==
1864 pHddCtx->cfg_ini->nEnableSuspend)
1865 {
1866 pmcRegisterDeviceStateUpdateInd(smeContext,
1867 hdd_PowerStateChangedCB, pHddCtx);
1868 }
1869}
1870
1871void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx)
1872{
1873 v_CONTEXT_t pVosContext;
1874 tHalHandle smeContext;
1875
1876 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1877 if (NULL == pVosContext)
1878 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001879 hddLog(LOGE, "%s: Invalid pContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 return;
1881 }
1882 smeContext = vos_get_context(VOS_MODULE_ID_SME, pVosContext);
1883 if (NULL == smeContext)
1884 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001885 hddLog(LOGE, "%s: Invalid smeContext", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 return;
1887 }
1888
1889 if (WLAN_MAP_SUSPEND_TO_MCAST_BCAST_FILTER ==
1890 pHddCtx->cfg_ini->nEnableSuspend)
1891 {
1892 pmcDeregisterDeviceStateUpdateInd(smeContext, hdd_PowerStateChangedCB);
1893 }
1894}
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301895
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301896#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301897void hdd_conf_gtk_offload(hdd_adapter_t *pAdapter, v_BOOL_t fenable)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301898{
1899 eHalStatus ret;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301900 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301901 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1902
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301903 if(fenable)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301904 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301905 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1906 (GTK_OFFLOAD_ENABLE == pHddStaCtx->gtkOffloadReqParams.ulFlags ))
1907 {
1908 vos_mem_copy(&hddGtkOffloadReqParams,
1909 &pHddStaCtx->gtkOffloadReqParams,
1910 sizeof (tSirGtkOffloadParams));
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301911
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301912 ret = sme_SetGTKOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
1913 &hddGtkOffloadReqParams, pAdapter->sessionId);
1914 if (eHAL_STATUS_SUCCESS != ret)
1915 {
1916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1917 "%s: sme_SetGTKOffload failed, returned %d",
1918 __func__, ret);
1919 return;
1920 }
1921
1922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1923 "%s: sme_SetGTKOffload successfull", __func__);
1924 }
1925
1926 }
1927 else
1928 {
1929 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1930 (0 == memcmp(&pHddStaCtx->gtkOffloadReqParams.bssId,
1931 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN)) &&
1932 (GTK_OFFLOAD_ENABLE == pHddStaCtx->gtkOffloadReqParams.ulFlags))
1933 {
1934
1935 /* Host driver has previously offloaded GTK rekey */
1936 ret = sme_GetGTKOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301937 wlan_hdd_cfg80211_update_replayCounterCallback,
1938 pAdapter, pAdapter->sessionId);
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301939 if (eHAL_STATUS_SUCCESS != ret)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301940
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301941 {
1942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1943 "%s: sme_GetGTKOffload failed, returned %d",
1944 __func__, ret);
1945 return;
1946 }
1947 else
1948 {
1949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1950 "%s: sme_GetGTKOffload successful",
1951 __func__);
1952
1953 /* Sending GTK offload dissable */
1954 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
1955 sizeof (tSirGtkOffloadParams));
1956 hddGtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1957 ret = sme_SetGTKOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301958 &hddGtkOffloadReqParams, pAdapter->sessionId);
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301959 if (eHAL_STATUS_SUCCESS != ret)
1960 {
1961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1962 "%s: failed to dissable GTK offload, returned %d",
1963 __func__, ret);
1964 return;
1965 }
1966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1967 "%s: successfully dissabled GTK offload request to HAL",
1968 __func__);
1969 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301970 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301971 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05301972 return;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301973}
1974#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001975
Sameer Thalappil45931fb2013-02-01 11:18:05 -08001976void hdd_resume_wlan(void)
Jeff Johnson295189b2012-06-20 16:38:30 -07001977{
1978 hdd_context_t *pHddCtx = NULL;
1979 hdd_adapter_t *pAdapter = NULL;
1980 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1981 VOS_STATUS status;
1982 v_CONTEXT_t pVosContext = NULL;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08001983
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed by Android OS",__func__);
1985
1986 //Get the global VOSS context.
1987 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
1988 if(!pVosContext) {
1989 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
1990 return;
1991 }
1992
1993 //Get the HDD context.
1994 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
1995
1996 if(!pHddCtx) {
1997 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
1998 return;
1999 }
2000
Agarwal Ashish971c2882013-10-30 20:11:12 +05302001 if (pHddCtx->isLogpInProgress)
2002 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 hddLog(VOS_TRACE_LEVEL_INFO,
2004 "%s: Ignore resume wlan, LOGP in progress!", __func__);
2005 return;
2006 }
2007
Padma, Santhosh Kumar2ee1ad02015-01-12 16:05:47 +05302008 if (!pHddCtx->hdd_wlan_suspended)
2009 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05302010 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar2ee1ad02015-01-12 16:05:47 +05302011 "%s: Ignore resume wlan, Already resumed!", __func__);
2012 return;
2013 }
2014
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 pHddCtx->hdd_wlan_suspended = FALSE;
Abhishek Singh37471cd2016-01-05 17:09:57 +05302016 hdd_wlan_suspend_resume_event(HDD_WLAN_EARLY_RESUME);
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 /*loop through all adapters. Concurrency */
2018 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2019
2020 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
2021 {
2022 pAdapter = pAdapterNode->pAdapter;
2023 if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
Madan Mohan Koyyalamudi802d7582012-10-31 14:19:40 -07002024 && (WLAN_HDD_SOFTAP != pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) )
Madan Mohan Koyyalamudi802d7582012-10-31 14:19:40 -07002026 { // we skip this registration for modes other than STA, SAP and P2P client modes.
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2028 pAdapterNode = pNext;
2029 continue;
2030 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05302031
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05302032
Jeff Johnson295189b2012-06-20 16:38:30 -07002033#ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP
2034 if(pHddCtx->hdd_ps_state == eHDD_SUSPEND_DEEP_SLEEP)
2035 {
2036 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WLAN being resumed from deep sleep",__func__);
2037 hdd_exit_deep_sleep(pAdapter);
2038 }
2039#endif
2040
2041 if(pHddCtx->hdd_ignore_dtim_enabled == TRUE)
2042 {
2043 /*Switch back to DTIM 1*/
2044 tSirSetPowerParamsReq powerRequest = { 0 };
2045
2046 powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value;
2047 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
Yue Mac24062f2013-05-13 17:01:29 -07002048 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
Jeff Johnson295189b2012-06-20 16:38:30 -07002049
2050 /*Disabled ModulatedDTIM if enabled on suspend*/
2051 if(pHddCtx->cfg_ini->enableModulatedDTIM)
2052 powerRequest.uDTIMPeriod = 0;
2053
2054 /* Update ignoreDTIM and ListedInterval in CFG with default values */
2055 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
2056 NULL, eANI_BOOLEAN_FALSE);
2057 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
2058 NULL, eANI_BOOLEAN_FALSE);
2059
2060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002061 "Switch to DTIM%d",powerRequest.uListenInterval);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002062 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05302064 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2065 {
2066 /* put the device into full power */
2067 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05302069 /* put the device back into BMPS */
2070 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
Jeff Johnson295189b2012-06-20 16:38:30 -07002071
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05302072 pHddCtx->hdd_ignore_dtim_enabled = FALSE;
2073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 }
2075
Gopichand Nakkala0f276812013-02-24 14:45:51 +05302076 hdd_conf_resume_ind(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2078 pAdapterNode = pNext;
2079 }
2080
2081#ifdef SUPPORT_EARLY_SUSPEND_STANDBY_DEEPSLEEP
2082 if(pHddCtx->hdd_ps_state == eHDD_SUSPEND_STANDBY)
2083 {
2084 hdd_exit_standby(pHddCtx);
2085 }
2086#endif
2087
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 return;
2089}
2090
Jeff Johnson295189b2012-06-20 16:38:30 -07002091VOS_STATUS hdd_wlan_reset_initialization(void)
2092{
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 v_CONTEXT_t pVosContext = NULL;
2094
2095 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN being reset",__func__);
2096
2097 //Get the global VOSS context.
2098 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2099 if(!pVosContext)
2100 {
2101 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
2102 return VOS_STATUS_E_FAILURE;
2103 }
2104
2105 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Preventing the phone from going to suspend",__func__);
2106
2107 // Prevent the phone from going to sleep
Sushant Kaushik83392fa2015-05-05 17:44:40 +05302108 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07002109
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 return VOS_STATUS_SUCCESS;
2111}
2112
2113
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002114/*
2115 * Based on the ioctl command recieved by HDD, put WLAN driver
2116 * into the quiet mode. This is the same as the early suspend
2117 * notification that driver used to listen
2118 */
2119void hdd_set_wlan_suspend_mode(bool suspend)
Jeff Johnson295189b2012-06-20 16:38:30 -07002120{
Sandeep Puligilla308288f2014-06-05 22:21:46 +05302121 vos_ssr_protect(__func__);
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002122 if (suspend)
2123 hdd_suspend_wlan();
2124 else
2125 hdd_resume_wlan();
Sandeep Puligilla308288f2014-06-05 22:21:46 +05302126 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002127}
2128
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002129static void hdd_ssr_timer_init(void)
2130{
2131 init_timer(&ssr_timer);
2132}
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002133
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002134static void hdd_ssr_timer_del(void)
2135{
2136 del_timer(&ssr_timer);
2137 ssr_timer_started = false;
2138}
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002139
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002140static void hdd_ssr_timer_cb(unsigned long data)
2141{
2142 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD SSR timer expired", __func__);
Sameer Thalappile5637f42013-08-07 15:46:55 -07002143
2144#ifdef WCN_PRONTO
2145 if (wcnss_hardware_type() == WCNSS_PRONTO_HW)
2146 wcnss_pronto_log_debug_regs();
2147#endif
2148
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002149 VOS_BUG(0);
2150}
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002151
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002152static void hdd_ssr_timer_start(int msec)
2153{
2154 if(ssr_timer_started)
2155 {
2156 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: trying to start SSR timer when it's running"
2157 ,__func__);
2158 }
2159 ssr_timer.expires = jiffies + msecs_to_jiffies(msec);
2160 ssr_timer.function = hdd_ssr_timer_cb;
2161 add_timer(&ssr_timer);
2162 ssr_timer_started = true;
2163}
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002164
Sen, Devendrade5cfe92017-01-31 18:51:15 +05302165#ifdef FEATURE_WLAN_DIAG_SUPPORT
2166/**
2167 * hdd_wlan_ssr_shutdown_event()- send ssr shutdown state
2168 *
2169 * This Function send send ssr shutdown state diag event
2170 *
2171 * Return: void.
2172 */
2173static void hdd_wlan_ssr_shutdown_event(void)
2174{
2175 WLAN_VOS_DIAG_EVENT_DEF(ssr_shutdown,
2176 struct host_event_wlan_ssr_shutdown);
2177 vos_mem_zero(&ssr_shutdown, sizeof(ssr_shutdown));
2178 ssr_shutdown.status = SSR_SUB_SYSTEM_SHUTDOWN;
2179 WLAN_VOS_DIAG_EVENT_REPORT(&ssr_shutdown,
2180 EVENT_WLAN_SSR_SHUTDOWN_SUBSYSTEM);
2181}
2182#else
2183static inline void hdd_wlan_ssr_shutdown_event(void)
2184{
2185
2186};
2187#endif
2188
Jeff Johnson295189b2012-06-20 16:38:30 -07002189/* the HDD interface to WLAN driver shutdown,
2190 * the primary shutdown function in SSR
2191 */
2192VOS_STATUS hdd_wlan_shutdown(void)
2193{
2194 VOS_STATUS vosStatus;
2195 v_CONTEXT_t pVosContext = NULL;
2196 hdd_context_t *pHddCtx = NULL;
2197 pVosSchedContext vosSchedContext = NULL;
2198
2199 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN driver shutting down! ",__func__);
2200
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002201 /* if re-init never happens, then do SSR1 */
2202 hdd_ssr_timer_init();
2203 hdd_ssr_timer_start(HDD_SSR_BRING_UP_TIME);
2204
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 /* Get the global VOSS context. */
2206 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
2207 if(!pVosContext) {
2208 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
2209 return VOS_STATUS_E_FAILURE;
2210 }
2211 /* Get the HDD context. */
2212 pHddCtx = (hdd_context_t*)vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
2213 if(!pHddCtx) {
2214 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
2215 return VOS_STATUS_E_FAILURE;
2216 }
c_hpothud662a352013-12-26 15:09:12 +05302217
Abhishek Singh8a3e4dc2017-01-02 10:39:18 +05302218 vos_set_snoc_high_freq_voting(false);
c_hpothud662a352013-12-26 15:09:12 +05302219 //Stop the traffic monitor timer
Mahesh A Saptasagard461e432016-07-20 15:01:40 +05302220 if ((pHddCtx->cfg_ini->dynSplitscan)&& (VOS_TIMER_STATE_RUNNING ==
2221 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
c_hpothud662a352013-12-26 15:09:12 +05302222 {
2223 vos_timer_stop(&pHddCtx->tx_rx_trafficTmr);
2224 }
Padma, Santhosh Kumar9cd38332015-11-17 12:18:10 +05302225 vos_flush_delayed_work(&pHddCtx->spoof_mac_addr_work);
Kapil Gupta137ef892016-12-13 19:38:00 +05302226 vos_flush_work(&pHddCtx->sap_start_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 hdd_reset_all_adapters(pHddCtx);
Bhargav Shahd0715912015-10-01 18:17:37 +05302228
2229 /* set default value of Tcp delack and stop timer */
2230 hdd_set_default_stop_delack_timer(pHddCtx);
2231
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 /* DeRegister with platform driver as client for Suspend/Resume */
2233 vosStatus = hddDeregisterPmOps(pHddCtx);
2234 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2235 {
2236 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__);
2237 }
2238
2239 vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx);
2240 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2241 {
2242 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
2243 }
2244
2245 /* Disable IMPS/BMPS as we do not want the device to enter any power
2246 * save mode on its own during reset sequence
2247 */
2248 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
2249 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
2250 sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE);
2251
2252 vosSchedContext = get_vos_sched_ctxt();
2253
2254 /* Wakeup all driver threads */
2255 if(TRUE == pHddCtx->isMcThreadSuspended){
2256 complete(&vosSchedContext->ResumeMcEvent);
2257 pHddCtx->isMcThreadSuspended= FALSE;
2258 }
2259 if(TRUE == pHddCtx->isTxThreadSuspended){
2260 complete(&vosSchedContext->ResumeTxEvent);
2261 pHddCtx->isTxThreadSuspended= FALSE;
2262 }
2263 if(TRUE == pHddCtx->isRxThreadSuspended){
2264 complete(&vosSchedContext->ResumeRxEvent);
2265 pHddCtx->isRxThreadSuspended= FALSE;
2266 }
2267 /* Reset the Suspend Variable */
2268 pHddCtx->isWlanSuspended = FALSE;
2269
2270 /* Stop all the threads; we do not want any messages to be a processed,
2271 * any more and the best way to ensure that is to terminate the threads
2272 * gracefully.
2273 */
2274 /* Wait for MC to exit */
2275 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Shutting down MC thread",__func__);
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302276 set_bit(MC_SHUTDOWN_EVENT, &vosSchedContext->mcEventFlag);
2277 set_bit(MC_POST_EVENT, &vosSchedContext->mcEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 wake_up_interruptible(&vosSchedContext->mcWaitQueue);
Mihir Sheteb5425f72013-12-19 09:06:13 +05302279 wait_for_completion(&vosSchedContext->McShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07002280
2281 /* Wait for TX to exit */
2282 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Shutting down TX thread",__func__);
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302283 set_bit(TX_SHUTDOWN_EVENT, &vosSchedContext->txEventFlag);
2284 set_bit(TX_POST_EVENT, &vosSchedContext->txEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 wake_up_interruptible(&vosSchedContext->txWaitQueue);
Mihir Sheteb5425f72013-12-19 09:06:13 +05302286 wait_for_completion(&vosSchedContext->TxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07002287
2288 /* Wait for RX to exit */
2289 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Shutting down RX thread",__func__);
Mahesh A Saptasagar8b42b272016-02-24 16:22:45 +05302290 set_bit(RX_SHUTDOWN_EVENT, &vosSchedContext->rxEventFlag);
2291 set_bit(RX_POST_EVENT, &vosSchedContext->rxEventFlag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 wake_up_interruptible(&vosSchedContext->rxWaitQueue);
c_hpothuffdb5272013-10-02 16:42:35 +05302293
Mihir Sheteb5425f72013-12-19 09:06:13 +05302294 wait_for_completion(&vosSchedContext->RxShutdown);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295
2296#ifdef WLAN_BTAMP_FEATURE
2297 vosStatus = WLANBAP_Stop(pVosContext);
2298 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2299 {
2300 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2301 "%s: Failed to stop BAP",__func__);
2302 }
2303#endif //WLAN_BTAMP_FEATURE
2304 vosStatus = vos_wda_shutdown(pVosContext);
c_hpothuffdb5272013-10-02 16:42:35 +05302305 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2306 {
2307 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2308 "%s: Failed to stop wda %d", __func__, vosStatus);
2309 VOS_ASSERT(0);
2310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002311
2312 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Doing SME STOP",__func__);
2313 /* Stop SME - Cannot invoke vos_stop as vos_stop relies
2314 * on threads being running to process the SYS Stop
2315 */
Kiet Lama72a2322013-11-15 11:18:11 +05302316 vosStatus = sme_Stop(pHddCtx->hHal, HAL_STOP_TYPE_SYS_RESET);
c_hpothuffdb5272013-10-02 16:42:35 +05302317 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2318 {
2319 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2320 "%s: Failed to stop sme %d", __func__, vosStatus);
2321 VOS_ASSERT(0);
2322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002323
2324 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Doing MAC STOP",__func__);
2325 /* Stop MAC (PE and HAL) */
2326 vosStatus = macStop(pHddCtx->hHal, HAL_STOP_TYPE_SYS_RESET);
c_hpothuffdb5272013-10-02 16:42:35 +05302327 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2328 {
2329 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2330 "%s: Failed to stop mac %d", __func__, vosStatus);
2331 VOS_ASSERT(0);
2332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
2334 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Doing TL STOP",__func__);
2335 /* Stop TL */
2336 vosStatus = WLANTL_Stop(pVosContext);
c_hpothuffdb5272013-10-02 16:42:35 +05302337 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2338 {
2339 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2340 "%s: Failed to stop TL %d", __func__, vosStatus);
2341 VOS_ASSERT(0);
2342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002343
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 hdd_unregister_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Flush Queues",__func__);
2346 /* Clean up message queues of TX and MC thread */
2347 vos_sched_flush_mc_mqs(vosSchedContext);
2348 vos_sched_flush_tx_mqs(vosSchedContext);
2349 vos_sched_flush_rx_mqs(vosSchedContext);
Siddharth Bhal7bd19932015-03-03 16:54:36 +05302350#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
2351 wlan_logging_flush_pkt_queue();
c_manjeecfd1efb2015-09-25 19:32:34 +05302352 /*Free fw dump mem in case of SSR/Shutdown */
2353 wlan_set_fwr_mem_dump_state(FW_MEM_DUMP_IDLE);
2354 wlan_free_fwr_mem_dump_buffer();
Siddharth Bhal7bd19932015-03-03 16:54:36 +05302355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002356
2357 /* Deinit all the TX and MC queues */
2358 vos_sched_deinit_mqs(vosSchedContext);
2359 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Doing VOS Shutdown",__func__);
2360
2361 /* shutdown VOSS */
2362 vos_shutdown(pVosContext);
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05302363
2364 /*mac context has already been released in mac_close call
2365 so setting it to NULL in hdd context*/
2366 pHddCtx->hHal = (tHalHandle)NULL;
2367
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 if (free_riva_power_on_lock("wlan"))
2369 {
2370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock",
2371 __func__);
2372 }
Sen, Devendrade5cfe92017-01-31 18:51:15 +05302373 hdd_wlan_ssr_shutdown_event();
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN driver shutdown complete"
2375 ,__func__);
2376 return VOS_STATUS_SUCCESS;
2377}
2378
Anurag Chouhan7e2a9912017-02-09 20:21:40 +05302379static int hdd_dhcp_mdns_offload(hdd_adapter_t *adapter)
2380{
2381 hdd_config_t *config;
2382 int status = VOS_STATUS_SUCCESS;
2383 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2384
2385 config = hdd_ctx->cfg_ini;
2386 if (NULL == config) {
2387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2388 ("cfg_ini is NULL!!"));
2389 return -EINVAL;
2390 }
2391#ifdef DHCP_SERVER_OFFLOAD
2392 /* set dhcp server offload */
2393 if (config->enable_dhcp_srv_offload &&
2394 sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) {
2395 status = wlan_hdd_set_dhcp_server_offload(adapter);
2396 if (!VOS_IS_STATUS_SUCCESS(status))
2397 {
2398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2399 ("HDD DHCP Server Offload Failed!!"));
2400 return -EINVAL;
2401 }
2402 vos_event_reset(&adapter->dhcp_status.vos_event);
2403 status = vos_wait_single_event(&adapter->dhcp_status.vos_event, 2000);
2404 if (!VOS_IS_STATUS_SUCCESS(status) ||
2405 adapter->dhcp_status.dhcp_offload_status)
2406 {
2407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2408 ("ERROR: DHCP HDD vos wait for single_event failed!! %d"),
2409 adapter->dhcp_status.dhcp_offload_status);
2410 return -EINVAL;
2411 }
2412#ifdef MDNS_OFFLOAD
2413 if (config->enable_mdns_offload) {
2414 status = wlan_hdd_set_mdns_offload(adapter);
2415 if (VOS_IS_STATUS_SUCCESS(status))
2416 {
2417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2418 ("HDD MDNS Server Offload Failed!!"));
2419 return -EINVAL;
2420 }
2421 vos_event_reset(&adapter->mdns_status.vos_event);
2422 status = vos_wait_single_event(&adapter->
2423 mdns_status.vos_event, 2000);
2424 if (!VOS_IS_STATUS_SUCCESS(status) ||
2425 adapter->mdns_status.mdns_enable_status ||
2426 adapter->mdns_status.mdns_fqdn_status ||
2427 adapter->mdns_status.mdns_resp_status)
2428 {
2429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2430 ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"),
2431 adapter->mdns_status.mdns_enable_status,
2432 adapter->mdns_status.mdns_fqdn_status,
2433 adapter->mdns_status.mdns_resp_status);
2434 return -EINVAL;
2435 }
2436 }
2437#endif /* MDNS_OFFLOAD */
2438 } else {
2439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2440 ("DHCP Disabled ini %d, FW %d"),
2441 config->enable_dhcp_srv_offload,
2442 sme_IsFeatureSupportedByFW(SAP_OFFLOADS));
2443 }
2444#endif /* DHCP_SERVER_OFFLOAD */
2445 return status;
2446}
2447
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302448/**
2449 * hdd_ssr_restart_sap() - restart sap on SSR
2450 * @hdd_ctx: hdd context
2451 *
2452 * Return: nothing
2453 */
2454static void hdd_ssr_restart_sap(hdd_context_t *hdd_ctx)
2455{
2456 VOS_STATUS status;
2457 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
2458 hdd_adapter_t *adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002459
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302460 ENTER();
2461
2462 status = hdd_get_front_adapter (hdd_ctx, &adapter_node);
2463 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
2464 adapter = adapter_node->pAdapter;
2465 if (adapter && adapter->device_mode == WLAN_HDD_SOFTAP) {
2466 hddLog(VOS_TRACE_LEVEL_INFO, FL("in sap mode %p"),
2467 adapter);
2468 wlan_hdd_start_sap(adapter);
Anurag Chouhan7e2a9912017-02-09 20:21:40 +05302469 if (!VOS_IS_STATUS_SUCCESS(
2470 hdd_dhcp_mdns_offload(adapter)))
2471 hddLog(VOS_TRACE_LEVEL_INFO,
2472 FL("DHCP/MDNS offload Failed!!"));
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302473 }
2474 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
2475 adapter_node = next;
2476 }
2477
2478 EXIT();
2479}
Jeff Johnson295189b2012-06-20 16:38:30 -07002480
Sen, Devendrade5cfe92017-01-31 18:51:15 +05302481#ifdef FEATURE_WLAN_DIAG_SUPPORT
2482/**
2483* hdd_wlan_ssr_reinit_event()- send ssr reinit state
2484*
2485* This Function send send ssr reinit state diag event
2486*
2487* Return: void.
2488*/
2489static void hdd_wlan_ssr_reinit_event(void)
2490{
2491 WLAN_VOS_DIAG_EVENT_DEF(ssr_reinit, struct host_event_wlan_ssr_reinit);
2492 vos_mem_zero(&ssr_reinit, sizeof(ssr_reinit));
2493 ssr_reinit.status = SSR_SUB_SYSTEM_REINIT;
2494 WLAN_VOS_DIAG_EVENT_REPORT(&ssr_reinit,
2495 EVENT_WLAN_SSR_REINIT_SUBSYSTEM);
2496}
2497#else
2498static inline void hdd_wlan_ssr_reinit_event(void)
2499{
2500
2501}
2502#endif
2503
Jeff Johnson295189b2012-06-20 16:38:30 -07002504/* the HDD interface to WLAN driver re-init.
2505 * This is called to initialize/start WLAN driver after a shutdown.
2506 */
2507VOS_STATUS hdd_wlan_re_init(void)
2508{
2509 VOS_STATUS vosStatus;
2510 v_CONTEXT_t pVosContext = NULL;
2511 hdd_context_t *pHddCtx = NULL;
2512 eHalStatus halStatus;
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07002513#ifdef HAVE_WCNSS_CAL_DOWNLOAD
2514 int max_retries = 0;
2515#endif
Siddharth Bhalc7e79b62014-10-10 22:37:38 +05302516#ifdef HAVE_CBC_DONE
2517 int max_cbc_retries = 0;
2518#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002519#ifdef WLAN_BTAMP_FEATURE
2520 hdd_config_t *pConfig = NULL;
2521 WLANBAP_ConfigType btAmpConfig;
2522#endif
2523
Katya Nigam82a93062014-06-04 15:15:36 +05302524 struct device *dev = NULL;
Madan Mohan Koyyalamudib0e70642012-10-11 12:20:22 -07002525 hdd_ssr_timer_del();
Sushant Kaushik83392fa2015-05-05 17:44:40 +05302526 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT);
Sameer Thalappil5d7a33f2013-01-30 08:36:16 -08002527
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07002528#ifdef HAVE_WCNSS_CAL_DOWNLOAD
2529 /* wait until WCNSS driver downloads NV */
Yue Ma120f9ff2014-02-26 14:53:31 -08002530 while (!wcnss_device_ready() && 10 >= ++max_retries) {
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07002531 msleep(1000);
2532 }
Yue Ma120f9ff2014-02-26 14:53:31 -08002533 if (max_retries >= 10) {
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07002534 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__);
2535 goto err_re_init;
2536 }
2537#endif
2538
Siddharth Bhalc7e79b62014-10-10 22:37:38 +05302539#ifdef HAVE_CBC_DONE
2540 while (!wcnss_cbc_complete() && 20 >= ++max_cbc_retries) {
2541 msleep(1000);
2542 }
2543 if (max_cbc_retries >= 20) {
2544 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__);
2545 }
2546#endif
2547
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07002548 vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, TRUE);
2549
Sameer Thalappil5d7a33f2013-01-30 08:36:16 -08002550 /* The driver should always be initialized in STA mode after SSR */
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302551 if (VOS_STA_SAP_MODE != hdd_get_conparam())
2552 hdd_set_conparam(0);
Sameer Thalappil5d7a33f2013-01-30 08:36:16 -08002553
Katya Nigam82a93062014-06-04 15:15:36 +05302554 dev = wcnss_wlan_get_device();
2555 if (NULL == dev)
2556 {
2557 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wcnss dev is NULL",__func__);
2558 goto err_re_init;
2559 }
2560
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 /* Re-open VOSS, it is a re-open b'se control transport was never closed. */
Katya Nigam82a93062014-06-04 15:15:36 +05302562 vosStatus = vos_open(&pVosContext, dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2564 {
2565 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_open failed",__func__);
2566 goto err_re_init;
2567 }
2568
2569 /* Get the HDD context. */
2570 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
2571 if(!pHddCtx)
2572 {
2573 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
2574 goto err_vosclose;
2575 }
2576
2577 /* Save the hal context in Adapter */
2578 pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext );
2579 if ( NULL == pHddCtx->hHal )
2580 {
2581 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HAL context is null",__func__);
2582 goto err_vosclose;
2583 }
2584
2585 /* Set the SME configuration parameters. */
2586 vosStatus = hdd_set_sme_config(pHddCtx);
2587 if ( VOS_STATUS_SUCCESS != vosStatus )
2588 {
2589 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed hdd_set_sme_config",__func__);
2590 goto err_vosclose;
2591 }
2592
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 vosStatus = vos_preStart( pHddCtx->pvosContext );
2594 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2595 {
2596 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_preStart failed",__func__);
2597 goto err_vosclose;
2598 }
2599
2600 /* In the integrated architecture we update the configuration from
2601 the INI file and from NV before vOSS has been started so that
2602 the final contents are available to send down to the cCPU */
2603 /* Apply the cfg.ini to cfg.dat */
2604 if (FALSE == hdd_update_config_dat(pHddCtx))
2605 {
2606 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ );
2607 goto err_vosclose;
2608 }
2609
2610 /* Set the MAC Address, currently this is used by HAL to add self sta.
2611 * Remove this once self sta is added as part of session open. */
2612 halStatus = cfgSetStr(pHddCtx->hHal, WNI_CFG_STA_ID,
2613 (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0],
2614 sizeof(pHddCtx->cfg_ini->intfMacAddr[0]));
2615 if (!HAL_STATUS_SUCCESS(halStatus))
2616 {
2617 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. "
2618 "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus);
2619 goto err_vosclose;
2620 }
2621
2622 /* Start VOSS which starts up the SME/MAC/HAL modules and everything else
2623 Note: Firmware image will be read and downloaded inside vos_start API */
2624 vosStatus = vos_start( pVosContext );
2625 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2626 {
2627 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
Hanumantha Reddy Pothulabd9601a2016-02-12 13:22:27 +05302628 if (isSsrPanicOnFailure())
2629 VOS_BUG(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 goto err_vosclose;
2631 }
2632
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07002633 /* Exchange capability info between Host and FW and also get versioning info from FW */
2634 hdd_exchange_version_and_caps(pHddCtx);
2635
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 vosStatus = hdd_post_voss_start_config( pHddCtx );
2637 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2638 {
2639 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed",
2640 __func__);
2641 goto err_vosstop;
2642 }
2643
Mihir Shete04206452014-11-20 17:50:58 +05302644#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +05302645 vosStatus = wlan_hdd_init_channels_for_cc(pHddCtx, REINIT);
2646 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2647 {
2648 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed",
2649 __func__);
2650 goto err_vosstop;
2651 }
Mihir Shete04206452014-11-20 17:50:58 +05302652#endif
Agarwal Ashish6db9d532014-09-30 18:19:10 +05302653
Jeff Johnson295189b2012-06-20 16:38:30 -07002654#ifdef WLAN_BTAMP_FEATURE
2655 vosStatus = WLANBAP_Open(pVosContext);
2656 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2657 {
2658 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2659 "%s: Failed to open BAP",__func__);
2660 goto err_vosstop;
2661 }
2662 vosStatus = BSL_Init(pVosContext);
2663 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2664 {
2665 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2666 "%s: Failed to Init BSL",__func__);
2667 goto err_bap_close;
2668 }
2669 vosStatus = WLANBAP_Start(pVosContext);
2670 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2671 {
2672 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2673 "%s: Failed to start TL",__func__);
2674 goto err_bap_close;
2675 }
2676 pConfig = pHddCtx->cfg_ini;
2677 btAmpConfig.ucPreferredChannel = pConfig->preferredChannel;
2678 vosStatus = WLANBAP_SetConfig(&btAmpConfig);
2679#endif //WLAN_BTAMP_FEATURE
2680
2681 /* Restart all adapters */
2682 hdd_start_all_adapters(pHddCtx);
Sreelakshmi Konamkif0646d52016-12-09 12:35:31 +05302683 pHddCtx->last_scan_reject_session_id = 0xFF;
2684 pHddCtx->last_scan_reject_reason = 0;
Sreelakshmi Konamki20ebed92016-10-27 12:13:30 +05302685 pHddCtx->last_scan_reject_timestamp = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 pHddCtx->hdd_mcastbcast_filter_set = FALSE;
Anand N Sunkad0cbc27a2014-09-18 12:58:18 +05302687 pHddCtx->btCoexModeSet = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 hdd_register_mcast_bcast_filter(pHddCtx);
Agarwal Ashish4b87f922014-06-18 03:03:21 +05302689 wlan_hdd_tdls_init(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 /* Register with platform driver as client for Suspend/Resume */
2691 vosStatus = hddRegisterPmOps(pHddCtx);
2692 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2693 {
2694 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__);
2695 goto err_bap_stop;
2696 }
Hanumantha Reddy Pothulab7dd9972015-07-01 12:24:57 +05302697
2698#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
2699 if (pHddCtx->cfg_ini->wlanLoggingEnable &&
2700 (pHddCtx->cfg_ini->enableFWLogging ||
2701 pHddCtx->cfg_ini->enableMgmtLogging ||
2702 pHddCtx->cfg_ini->enableContFWLogging))
2703 {
2704 hdd_init_frame_logging(pHddCtx);
2705 }
2706#endif
2707
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 /* Allow the phone to go to sleep */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05302709 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 /* register for riva power on lock */
2711 if (req_riva_power_on_lock("wlan"))
2712 {
2713 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed",
2714 __func__);
2715 goto err_unregister_pmops;
2716 }
Gupta, Kapil7c34b322015-09-30 13:12:35 +05302717 sme_set_rssi_threshold_breached_cb(pHddCtx->hHal, hdd_rssi_threshold_breached_cb);
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07002718 vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Deepthi Gowri1ca95bb2016-01-13 19:47:53 +05302719
2720 sme_register_mgmt_frame_ind_callback(pHddCtx->hHal,hdd_indicate_mgmt_frame);
2721
Dasari Srinivas421bde82014-06-25 12:01:44 +05302722#ifdef WLAN_FEATURE_EXTSCAN
2723 sme_EXTScanRegisterCallback(pHddCtx->hHal,
2724 wlan_hdd_cfg80211_extscan_callback,
2725 pHddCtx);
2726#endif /* WLAN_FEATURE_EXTSCAN */
Padma, Santhosh Kumar2ccac212015-10-20 17:27:27 +05302727
2728#ifdef FEATURE_OEM_DATA_SUPPORT
2729 sme_OemDataRegisterCallback(pHddCtx->hHal,
2730 wlan_hdd_cfg80211_oemdata_callback,
2731 pHddCtx);
2732#endif /* FEATURE_OEM_DATA_SUPPORT */
2733
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 goto success;
2735
2736err_unregister_pmops:
2737 hddDeregisterPmOps(pHddCtx);
2738
2739err_bap_stop:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002740#ifdef CONFIG_HAS_EARLYSUSPEND
2741 hdd_unregister_mcast_bcast_filter(pHddCtx);
2742#endif
2743 hdd_close_all_adapters(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002744#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson32d95a32012-09-10 13:15:23 -07002745 WLANBAP_Stop(pVosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002746#endif
2747
2748#ifdef WLAN_BTAMP_FEATURE
2749err_bap_close:
2750 WLANBAP_Close(pVosContext);
2751#endif
2752
2753err_vosstop:
2754 vos_stop(pVosContext);
2755
2756err_vosclose:
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +05302757 if(!isSsrPanicOnFailure())
2758 {
2759 /* If we hit this, it means wlan driver is in bad state and needs
2760 * driver unload and load.
2761 */
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +05302762 vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE);
2763 return VOS_STATUS_E_FAILURE;
2764 }
2765
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 vos_close(pVosContext);
2767 vos_sched_close(pVosContext);
2768 if (pHddCtx)
2769 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 /* Unregister the Net Device Notifier */
2771 unregister_netdevice_notifier(&hdd_netdev_notifier);
2772 /* Clean up HDD Nlink Service */
2773 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Leo Chang59cdc7e2013-07-10 10:08:21 -07002774#ifdef WLAN_KD_READY_NOTIFIER
2775 nl_srv_exit(pHddCtx->ptt_pid);
2776#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -07002778#endif /* WLAN_KD_READY_NOTIFIER */
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 /* Free up dynamically allocated members inside HDD Adapter */
2780 kfree(pHddCtx->cfg_ini);
2781 pHddCtx->cfg_ini= NULL;
2782
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 wiphy_unregister(pHddCtx->wiphy);
Agrawal Ashish33ec71e2015-11-26 20:20:58 +05302784 hdd_wlan_free_wiphy_channels(pHddCtx->wiphy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 wiphy_free(pHddCtx->wiphy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 }
2787 vos_preClose(&pVosContext);
2788
2789#ifdef MEMORY_DEBUG
2790 vos_mem_exit();
2791#endif
2792
2793err_re_init:
2794 /* Allow the phone to go to sleep */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05302795 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_REINIT);
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -07002796 vos_set_reinit_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Sameer Thalappil451ebb92013-06-28 15:49:58 -07002797 VOS_BUG(0);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002798 return -EPERM;
Jeff Johnson295189b2012-06-20 16:38:30 -07002799
2800success:
Sen, Devendrade5cfe92017-01-31 18:51:15 +05302801 hdd_wlan_ssr_reinit_event();
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 /* Trigger replay of BTC events */
2803 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302804
2805 if (pHddCtx->cfg_ini->sap_internal_restart)
2806 hdd_ssr_restart_sap(pHddCtx);
2807
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 return VOS_STATUS_SUCCESS;
2809}