blob: b878353adf60fc0031c0a98fbe7877060ba97fda [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * Airgo Networks, Inc proprietary. All rights reserved.
24 * This file limProcessMlmMessages.cc contains the code
25 * for processing MLM request messages.
26 * Author: Chandra Modumudi
27 * Date: 02/12/02
28 * History:-
29 * Date Modified by Modification Information
30 * --------------------------------------------------------------------
31 *
32 */
33#include "palTypes.h"
34#ifdef ANI_PRODUCT_TYPE_AP
35#include "wniCfgAp.h"
36#else
37#include "wniCfgSta.h"
38#endif
39#include "aniGlobal.h"
40#include "sirApi.h"
41#include "sirParams.h"
42#include "cfgApi.h"
43
44#include "schApi.h"
45#include "utilsApi.h"
46#include "limUtils.h"
47#include "limAssocUtils.h"
48#include "limPropExtsUtils.h"
49#include "limSecurityUtils.h"
50#include "limSendMessages.h"
51#include "pmmApi.h"
52#include "limSendMessages.h"
53//#include "limSessionUtils.h"
54#include "limSessionUtils.h"
55#ifdef WLAN_FEATURE_VOWIFI_11R
56#include <limFT.h>
57#endif
58
59
60
61// MLM REQ processing function templates
62static void limProcessMlmStartReq(tpAniSirGlobal, tANI_U32 *);
63static void limProcessMlmScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnsone7245742012-09-05 17:12:55 -070064#ifdef FEATURE_OEM_DATA_SUPPORT
65static void limProcessMlmOemDataReq(tpAniSirGlobal, tANI_U32 *);
66#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070067static void limProcessMlmJoinReq(tpAniSirGlobal, tANI_U32 *);
68static void limProcessMlmAuthReq(tpAniSirGlobal, tANI_U32 *);
69static void limProcessMlmAssocReq(tpAniSirGlobal, tANI_U32 *);
70static void limProcessMlmReassocReq(tpAniSirGlobal, tANI_U32 *);
71static void limProcessMlmDisassocReq(tpAniSirGlobal, tANI_U32 *);
72static void limProcessMlmDeauthReq(tpAniSirGlobal, tANI_U32 *);
73static void limProcessMlmSetKeysReq(tpAniSirGlobal, tANI_U32 *);
74
75static void limProcessMlmAddBAReq( tpAniSirGlobal, tANI_U32 * );
76static void limProcessMlmAddBARsp( tpAniSirGlobal, tANI_U32 * );
77static void limProcessMlmDelBAReq( tpAniSirGlobal, tANI_U32 * );
78
79// MLM Timeout event handler templates
80static void limProcessMinChannelTimeout(tpAniSirGlobal);
81static void limProcessMaxChannelTimeout(tpAniSirGlobal);
82static void limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac);
83static void limProcessJoinFailureTimeout(tpAniSirGlobal);
84static void limProcessAuthFailureTimeout(tpAniSirGlobal);
85static void limProcessAuthRspTimeout(tpAniSirGlobal, tANI_U32);
86static void limProcessAssocFailureTimeout(tpAniSirGlobal, tANI_U32);
87
88static void limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 * pMsgBuf);
89void
Jeff Johnsone7245742012-09-05 17:12:55 -070090limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070091#define IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) (pMac->lim.gpLimMlmScanReq->backgroundScanMode == eSIR_AGGRESSIVE_BACKGROUND_SCAN)
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -070092#define IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac) (pMac->lim.gpLimMlmScanReq->backgroundScanMode == eSIR_NORMAL_BACKGROUND_SCAN)
Jeff Johnson295189b2012-06-20 16:38:30 -070093
94/**
95 * limProcessMlmReqMessages()
96 *
97 *FUNCTION:
98 * This function is called by limPostMlmMessage(). This
99 * function handles MLM primitives invoked by SME.
100 *
101 *LOGIC:
102 * Depending on the message type, corresponding function will be
103 * called.
104 *
105 *ASSUMPTIONS:
106 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
107 * APIs exposed by Beacon Processing module for setting parameters
108 * at MAC hardware.
109 * 2. If attempt to Reassociate with an AP fails, link with current
110 * AP is restored back.
111 *
112 *NOTE:
113 *
114 * @param pMac Pointer to Global MAC structure
115 * @param msgType Indicates the MLM primitive message type
116 * @param *pMsgBuf A pointer to the MLM message buffer
117 *
118 * @return None
119 */
120
121void
122limProcessMlmReqMessages(tpAniSirGlobal pMac, tpSirMsgQ Msg)
123{
124 switch (Msg->type)
125 {
126 case LIM_MLM_START_REQ: limProcessMlmStartReq(pMac, Msg->bodyptr); break;
127 case LIM_MLM_SCAN_REQ: limProcessMlmScanReq(pMac, Msg->bodyptr); break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700128#ifdef FEATURE_OEM_DATA_SUPPORT
129 case LIM_MLM_OEM_DATA_REQ: limProcessMlmOemDataReq(pMac, Msg->bodyptr); break;
130#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 case LIM_MLM_JOIN_REQ: limProcessMlmJoinReq(pMac, Msg->bodyptr); break;
132 case LIM_MLM_AUTH_REQ: limProcessMlmAuthReq(pMac, Msg->bodyptr); break;
133 case LIM_MLM_ASSOC_REQ: limProcessMlmAssocReq(pMac, Msg->bodyptr); break;
134 case LIM_MLM_REASSOC_REQ: limProcessMlmReassocReq(pMac, Msg->bodyptr); break;
135 case LIM_MLM_DISASSOC_REQ: limProcessMlmDisassocReq(pMac, Msg->bodyptr); break;
136 case LIM_MLM_DEAUTH_REQ: limProcessMlmDeauthReq(pMac, Msg->bodyptr); break;
137 case LIM_MLM_SETKEYS_REQ: limProcessMlmSetKeysReq(pMac, Msg->bodyptr); break;
138 case LIM_MLM_REMOVEKEY_REQ: limProcessMlmRemoveKeyReq(pMac, Msg->bodyptr); break;
139 case SIR_LIM_MIN_CHANNEL_TIMEOUT: limProcessMinChannelTimeout(pMac); break;
140 case SIR_LIM_MAX_CHANNEL_TIMEOUT: limProcessMaxChannelTimeout(pMac); break;
141 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
142 limProcessPeriodicProbeReqTimer(pMac); break;
143 case SIR_LIM_JOIN_FAIL_TIMEOUT: limProcessJoinFailureTimeout(pMac); break;
144 case SIR_LIM_AUTH_FAIL_TIMEOUT: limProcessAuthFailureTimeout(pMac); break;
145 case SIR_LIM_AUTH_RSP_TIMEOUT: limProcessAuthRspTimeout(pMac, Msg->bodyval); break;
146 case SIR_LIM_ASSOC_FAIL_TIMEOUT: limProcessAssocFailureTimeout(pMac, Msg->bodyval); break;
147#ifdef WLAN_FEATURE_VOWIFI_11R
148 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:limProcessFTPreauthRspTimeout(pMac); break;
149#endif
150#ifdef WLAN_FEATURE_P2P
151 case SIR_LIM_REMAIN_CHN_TIMEOUT: limProcessRemainOnChnTimeout(pMac); break;
152#endif
153 case LIM_MLM_ADDBA_REQ: limProcessMlmAddBAReq( pMac, Msg->bodyptr ); break;
154 case LIM_MLM_ADDBA_RSP: limProcessMlmAddBARsp( pMac, Msg->bodyptr ); break;
155 case LIM_MLM_DELBA_REQ: limProcessMlmDelBAReq( pMac, Msg->bodyptr ); break;
156 case LIM_MLM_TSPEC_REQ:
157 default:
158 break;
159 } // switch (msgType)
160} /*** end limProcessMlmReqMessages() ***/
161
162
163/**
164 * limSetScanMode()
165 *
166 *FUNCTION:
167 * This function is called to setup system into Scan mode
168 *
169 *LOGIC:
170 * NA
171 *
172 *ASSUMPTIONS:
173 * NA
174 *
175 *NOTE:
176 *
177 * @param pMac - Pointer to Global MAC structure
178 * @return None
179 */
180
181void
182limSetScanMode(tpAniSirGlobal pMac)
183{
184 tSirLinkTrafficCheck checkTraffic;
185
186 /// Set current scan channel id to the first in the channel list
187 pMac->lim.gLimCurrentScanChannelId = 0;
188
189#ifdef ANI_PRODUCT_TYPE_CLIENT
190 if ( IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) )
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700191 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 checkTraffic = eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700193 }
194 else if (IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac))
195 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 checkTraffic = eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700197 }
198 else
199 checkTraffic = eSIR_CHECK_ROAMING_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700200#else
201 /* Currently checking the traffic before scan for Linux station. This is because MLM
202 * scan request is not filled as scan is received via Measurement req in Linux. This
203 * should be made as common code for Windows/Linux station once the scan requests are
204 * enabled in Linux
205 * TODO */
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700206 if ( IS_MLM_SCAN_REQ_BACKGROUND_SCAN_AGGRESSIVE(pMac) ||
207 IS_MLM_SCAN_REQ_BACKGROUND_SCAN_NORMAL(pMac))
208 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 checkTraffic = eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700210 }
211 else
212 checkTraffic = eSIR_CHECK_ROAMING_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700213#endif
214
215 PELOG1(limLog(pMac, LOG1, FL("Calling limSendHalInitScanReq\n"));)
216 limSendHalInitScanReq(pMac, eLIM_HAL_INIT_SCAN_WAIT_STATE, checkTraffic);
217
218 return ;
219} /*** end limSetScanMode() ***/
220
221//WLAN_SUSPEND_LINK Related
222
223/* limIsLinkSuspended()
224 *
225 *FUNCTION:
226 * This function returns is link is suspended or not.
227 *
228 *LOGIC:
229 * Since Suspen link uses init scan, it just returns
230 * gLimSystemInScanLearnMode flag.
231 *
232 *ASSUMPTIONS:
233 * NA
234 *
235 *NOTE:
236 *
237 * @param pMac - Pointer to Global MAC structure
238 * @return None
239 */
240tANI_U8
241limIsLinkSuspended(tpAniSirGlobal pMac)
242{
243 return pMac->lim.gLimSystemInScanLearnMode;
244}
245/**
246 * limSuspendLink()
247 *
248 *FUNCTION:
249 * This function is called to suspend traffic. Internally this function uses WDA_INIT_SCAN_REQ.
250 *
251 *LOGIC:
252 * NA
253 *
254 *ASSUMPTIONS:
255 * NA
256 *
257 *NOTE:
258 *
259 * @param pMac - Pointer to Global MAC structure
260 * @param trafficCheck - Takes value from enum tSirLinkTrafficCheck.
261 * @param callback - Callback function to be called after suspending the link.
262 * @param data - Pointer to any buffer that will be passed to callback.
263 * @return None
264 */
265void
266limSuspendLink(tpAniSirGlobal pMac, tSirLinkTrafficCheck trafficCheck, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
267{
268 if( NULL == callback )
269 {
270 limLog( pMac, LOGE, "%s:%d: Invalid parameters\n", __FUNCTION__, __LINE__ );
271 return;
272 }
273
274 if( pMac->lim.gpLimSuspendCallback )
275 {
276 limLog( pMac, LOGE, "%s:%d: gLimSuspendLink callback is not NULL...something is wrong\n", __FUNCTION__, __LINE__ );
277 callback( pMac, eHAL_STATUS_FAILURE, data );
278 return;
279 }
280
281 pMac->lim.gLimSystemInScanLearnMode = 1;
282 pMac->lim.gpLimSuspendCallback = callback;
283 pMac->lim.gpLimSuspendData = data;
284 limSendHalInitScanReq(pMac, eLIM_HAL_SUSPEND_LINK_WAIT_STATE, trafficCheck );
285}
286
287/**
288 * limResumeLink()
289 *
290 *FUNCTION:
291 * This function is called to Resume traffic after a suspend. Internally this function uses WDA_FINISH_SCAN_REQ.
292 *
293 *LOGIC:
294 * NA
295 *
296 *ASSUMPTIONS:
297 * NA
298 *
299 *NOTE:
300 *
301 * @param pMac - Pointer to Global MAC structure
302 * @param callback - Callback function to be called after Resuming the link.
303 * @param data - Pointer to any buffer that will be passed to callback.
304 * @return None
305 */
306void
307limResumeLink(tpAniSirGlobal pMac, SUSPEND_RESUME_LINK_CALLBACK callback, tANI_U32 *data)
308{
309 if( NULL == callback )
310 {
311 limLog( pMac, LOGE, "%s:%d: Invalid parameters\n", __FUNCTION__, __LINE__ );
312 return;
313 }
314
315 if( pMac->lim.gpLimResumeCallback )
316 {
317 limLog( pMac, LOGE, "%s:%d: gLimResumeLink callback is not NULL...something is wrong\n", __FUNCTION__, __LINE__ );
318 callback( pMac, eHAL_STATUS_FAILURE, data );
319 return;
320 }
321
322 pMac->lim.gpLimResumeCallback = callback;
323 pMac->lim.gpLimResumeData = data;
324 limSendHalFinishScanReq(pMac, eLIM_HAL_RESUME_LINK_WAIT_STATE );
325}
326//end WLAN_SUSPEND_LINK Related
327
328
329/**
330 *
331 * limChangeChannelWithCallback()
332 *
333 * FUNCTION:
334 * This function is called to change channel and perform off channel operation
335 * if required. The caller registers a callback to be called at the end of the
336 * channel change.
337 *
338 */
339void
340limChangeChannelWithCallback(tpAniSirGlobal pMac, tANI_U8 newChannel,
341 CHANGE_CHANNEL_CALLBACK callback,
342 tANI_U32 *cbdata, tpPESession psessionEntry)
343{
344 // Sanity checks for the current and new channel
345#if defined WLAN_VOWIFI_DEBUG
346 PELOGE(limLog( pMac, LOGE, "Switching channel to %d\n", newChannel);)
347#endif
348 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
349
350 pMac->lim.gpchangeChannelCallback = callback;
351 pMac->lim.gpchangeChannelData = cbdata;
352
353 limSendSwitchChnlParams(pMac, newChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -0700354 PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 psessionEntry->maxTxPower, psessionEntry->peSessionId);
356
357 return;
358}
359
360
361/**
362 * limContinuePostChannelScan()
363 *
364 *FUNCTION:
365 * This function is called to scan the current channel.
366 *
367 *LOGIC:
368 *
369 *ASSUMPTIONS:
370 * NA
371 *
372 *NOTE:
373 * NA
374 *
375 * @param pMac - Pointer to Global MAC structure
376 *
377 * @return None
378 */
379
380void limContinuePostChannelScan(tpAniSirGlobal pMac)
381{
382 tANI_U8 channelNum;
383 tANI_U8 handleError = 0;
384 tANI_U8 i = 0;
385 tSirRetStatus status = eSIR_SUCCESS;
386
387 if( pMac->lim.abortScan || (NULL == pMac->lim.gpLimMlmScanReq ) ||
388 (pMac->lim.gLimCurrentScanChannelId >
389 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)))
390 {
391 pMac->lim.abortScan = 0;
392 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
393 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
394 //Set the resume channel to Any valid channel (invalid).
395 //This will instruct HAL to set it to any previous valid channel.
396 peSetResumeChannel(pMac, 0, 0);
397
398 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
399 return;
400 }
401
402 channelNum = limGetCurrentScanChannel(pMac);
403 if ((pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN) &&
404 (limActiveScanAllowed(pMac, channelNum)))
405 {
406 TX_TIMER *periodicScanTimer;
407 PELOG2(limLog(pMac, LOG2, FL("ACTIVE Scan chan %d, sending probe\n"), channelNum);)
408
409 do
410 {
411 /* Prepare and send Probe Request frame for all the SSIDs present in the saved MLM
412 */
413
414 PELOGE(limLog(pMac, LOG1, FL("sending ProbeReq number %d, for SSID %s on channel: %d\n"),
415 i, pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);)
416 // include additional IE if there is
417 status = limSendProbeReqMgmtFrame( pMac, &pMac->lim.gpLimMlmScanReq->ssId[i],
418 pMac->lim.gpLimMlmScanReq->bssId, channelNum, pMac->lim.gSelfMacAddr,
419 pMac->lim.gpLimMlmScanReq->dot11mode,
420 pMac->lim.gpLimMlmScanReq->uIEFieldLen,
421 (tANI_U8 *)(pMac->lim.gpLimMlmScanReq)+pMac->lim.gpLimMlmScanReq->uIEFieldOffset);
422
423 if ( status != eSIR_SUCCESS)
424 {
425 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID %s on channel: %d\n"),
426 pMac->lim.gpLimMlmScanReq->ssId[i].ssId, channelNum);)
427 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
428 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
429 return;
430 }
431 i++;
432 } while (i < pMac->lim.gpLimMlmScanReq->numSsid);
433
434 {
435#if defined WLAN_FEATURE_VOWIFI
436 //If minChannelTime is set to zero, SME is requesting scan to not use min channel timer.
437 //This is used in 11k to request for beacon measurement request with a fixed duration in
438 //max channel time.
439 if( pMac->lim.gpLimMlmScanReq->minChannelTime != 0 )
440 {
441#endif
442 /// TXP has sent Probe Request
443 /// Activate minChannelTimer
444 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
445
446#ifdef GEN6_TODO
447 /* revisit this piece of code to assign the appropriate sessionId below
448 * priority - LOW/might not be needed
449 */
450 pMac->lim.limTimers.gLimMinChannelTimer.sessionId = sessionId;
451#endif
452
Jeff Johnsone7245742012-09-05 17:12:55 -0700453 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_MIN_CHANNEL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700454
455 if (tx_timer_activate(&pMac->lim.limTimers.gLimMinChannelTimer) != TX_SUCCESS)
456 {
457 limLog(pMac, LOGP, FL("could not start min channel timer\n"));
458 return;
459 }
460
461 // Initialize max timer too
462 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
463#if defined WLAN_FEATURE_VOWIFI
464 }
465 else
466 {
467#if defined WLAN_VOWIFI_DEBUG
468 PELOGE(limLog( pMac, LOGE, "Min channel time == 0, Use only max chan timer\n" );)
469#endif
470 //No Need to start Min channel timer. Start Max Channel timer.
471 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
472 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
473 == TX_TIMER_ERROR)
474 {
475 /// Could not activate max channel timer.
476 // Log error
477 limLog(pMac,LOGP, FL("could not start max channel timer\n"));
478 return;
479 }
480
481 }
482#endif
483 }
484 /* Start peridic timer which will trigger probe req based on min/max
485 channel timer */
486 periodicScanTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
487 if (tx_timer_activate(periodicScanTimer) != TX_SUCCESS)
488 {
489 limLog(pMac, LOGP, FL("could not start periodic probe req "
490 "timer\n"));
491 return;
492 }
493 periodicScanTimer->sessionId = channelNum;
494 }
495 else
496 {
497 tANI_U32 val;
498 PELOG2(limLog(pMac, LOG2, FL("START PASSIVE Scan chan %d\n"), channelNum);)
499
500 /// Passive Scanning. Activate maxChannelTimer
Jeff Johnsone7245742012-09-05 17:12:55 -0700501 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, NO_SESSION, eLIM_MAX_CHANNEL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimMaxChannelTimer)
503 != TX_SUCCESS)
504 {
505 // Could not deactivate max channel timer.
506 // Log error
507 limLog(pMac, LOGP, FL("Unable to deactivate max channel timer\n"));
508 return;
509 }
510 else
511 {
512 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
513 &val) != eSIR_SUCCESS)
514 {
515 /**
516 * Could not get max channel value
517 * from CFG. Log error.
518 */
519 limLog(pMac, LOGP, FL("could not retrieve passive max channel value\n"));
520 return;
521 }
522 else
523 {
524 tANI_U32 val1 = 0;
525
526 val = SYS_MS_TO_TICKS(val);
Jeff Johnsone7245742012-09-05 17:12:55 -0700527 //TODO: consider sessions.
528#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700529#ifdef ANI_PRODUCT_TYPE_CLIENT
530 // If a background was triggered via Quiet BSS,
531 // then we need to adjust the MIN and MAX channel
532 // timer's accordingly to the Quiet duration that
533 // was specified
534 if( eLIM_QUIET_RUNNING == pMac->lim.gLimSpecMgmt.quietState &&
535 pMac->lim.gLimTriggerBackgroundScanDuringQuietBss )
536 {
537 // gLimQuietDuration is already cached in units of
538 // system ticks. No conversion is reqd...
539 val1 = pMac->lim.gLimSpecMgmt.quietDuration;
540 }
541 else
542 {
543 val1 = SYS_MS_TO_TICKS(pMac->lim.gpLimMlmScanReq->maxChannelTime);
544 }
545#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700546#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 //Pick the longer stay time
548 val = (val > val1) ? val : val1;
Jeff Johnsone7245742012-09-05 17:12:55 -0700549 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_MAX_CHANNEL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 if (tx_timer_change(&pMac->lim.limTimers.gLimMaxChannelTimer,
551 val, 0) != TX_SUCCESS)
552 {
553 // Could not change max channel timer.
554 // Log error
555 limLog(pMac, LOGP, FL("Unable to change max channel timer\n"));
556 return;
557 }
558 else if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer) != TX_SUCCESS)
559 {
560 limLog(pMac, LOGP, FL("could not start max channel timer\n"));
561 return;
562 }
563
564 }
565 }
566 // Wait for Beacons to arrive
567 } // if (pMac->lim.gLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
568
569 if( handleError )
570 {
571 //
572 // FIXME - With this, LIM/SoftMAC will try and recover
573 // state, but eWNI_SME_SCAN_CNF maybe reporting an
574 // incorrect status back to the SME. Some of the possible
575 // errors are:
576 // eSIR_SME_HAL_SCAN_INIT_FAILED
577 // eSIR_SME_RESOURCES_UNAVAILABLE
578 //
579 //Set the resume channel to Any valid channel (invalid).
580 //This will instruct HAL to set it to any previous valid channel.
581 peSetResumeChannel(pMac, 0, 0);
582 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
583 //limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
584 }
585 else
586 {
587 limAddScanChannelInfo(pMac, channelNum);
588 }
589
590 return;
591}
592
593
594
595
596/*
597* Creates a Raw frame to be sent before every Scan, if required.
598* If only infra link is active (mlmState = Link Estb), then send Data Null
599* If only BT-AMP-AP link is active(mlmState = BSS_STARTED), then send CTS2Self frame.
600* If only BT-AMP-STA link is active(mlmState = BSS_STARTED or Link Est) then send CTS2Self
601* If Only IBSS link is active, then send CTS2Self
602* for concurrent scenario: Infra+BT or Infra+IBSS, always send CTS2Self, no need to send Data Null
603*
604*/
605static void __limCreateInitScanRawFrame(tpAniSirGlobal pMac,
606 tpInitScanParams pInitScanParam)
607{
608 tANI_U8 i;
609 pInitScanParam->scanEntry.activeBSScnt = 0;
610
611 /* Don't send CTS to self as we have issue with BTQM queues where BTQM can
612 * not handle transmition of CTS2self frames. Sending CTS 2 self at this
613 * juncture also doesn't serve much purpose as probe request frames go out
614 * immediately, No need to notify BSS in IBSS case.
615 * */
616
617 for(i =0; i < pMac->lim.maxBssId; i++)
618 {
619 if(pMac->lim.gpSession[i].valid == TRUE)
620 {
621 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
622 {
623 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
624 (pInitScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
625 {
626 pInitScanParam->scanEntry.bssIdx[pInitScanParam->scanEntry.activeBSScnt]
627 = pMac->lim.gpSession[i].bssIdx;
628 pInitScanParam->scanEntry.activeBSScnt++;
629
630 }
631 }
632#ifdef WLAN_FEATURE_P2P
633 else if( (eLIM_AP_ROLE == pMac->lim.gpSession[i].limSystemRole )
634 && ( VOS_P2P_GO_MODE == pMac->lim.gpSession[i].pePersona )
635 )
636 {
637 pInitScanParam->useNoA = TRUE;
638 }
639#endif
640 }
641 }
642 if (pInitScanParam->scanEntry.activeBSScnt)
643 {
644 pInitScanParam->notifyBss = TRUE;
645 pInitScanParam->frameType = SIR_MAC_DATA_FRAME;
646 pInitScanParam->frameLength = 0;
647 }
648}
649
650/*
651* Creates a Raw frame to be sent during finish scan, if required.
652* Send data null frame, only when there is just one session active and that session is
653* in 'link Estb' state.
654* if more than one session is active, don't send any frame.
655* for concurrent scenario: Infra+BT or Infra+IBSS, no need to send Data Null
656*
657*/
658static void __limCreateFinishScanRawFrame(tpAniSirGlobal pMac,
659 tpFinishScanParams pFinishScanParam)
660{
661 tANI_U8 i;
662 pFinishScanParam->scanEntry.activeBSScnt = 0;
663
664 for(i =0; i < pMac->lim.maxBssId; i++)
665 {
666 if(pMac->lim.gpSession[i].valid == TRUE)
667 {
668 if(pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
669 {
670 //BT-STA can either be in LINK-ESTB state or BSS_STARTED State
671 //for BT, need to send CTS2Self
672 if ((pMac->lim.gpSession[i].limSystemRole != eLIM_BT_AMP_STA_ROLE) &&
673 (pFinishScanParam->scanEntry.activeBSScnt < HAL_NUM_BSSID))
674 {
675 pFinishScanParam->scanEntry.bssIdx[pFinishScanParam->scanEntry.activeBSScnt]
676 = pMac->lim.gpSession[i].bssIdx;
677 pFinishScanParam->scanEntry.activeBSScnt++;
678 }
679 }
680 }
681 }
682
683 if (pFinishScanParam->scanEntry.activeBSScnt)
684 {
685 pFinishScanParam->notifyBss = TRUE;
686 pFinishScanParam->frameType = SIR_MAC_DATA_FRAME;
687 pFinishScanParam->frameLength = 0;
688 }
689}
690
691void
692limSendHalInitScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState, tSirLinkTrafficCheck trafficCheck)
693{
694
695
696 tSirMsgQ msg;
697 tpInitScanParams pInitScanParam;
698 tSirRetStatus rc = eSIR_SUCCESS;
699
700 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pInitScanParam,
701 sizeof(*pInitScanParam)))
702 {
703 PELOGW(limLog(pMac, LOGW, FL("palAllocateMemory() failed\n"));)
704 goto error;
705 }
706
707 /*Initialize the pInitScanParam with 0*/
708 palZeroMemory( pMac->hHdd, (tANI_U8 *)pInitScanParam, sizeof(*pInitScanParam));
709
710 msg.type = WDA_INIT_SCAN_REQ;
711 msg.bodyptr = pInitScanParam;
712 msg.bodyval = 0;
713
714 palZeroMemory( pMac->hHdd, (tANI_U8 *)&pInitScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr));
715 if (nextState == eLIM_HAL_INIT_LEARN_WAIT_STATE)
716 {
717 pInitScanParam->notifyBss = TRUE;
718 pInitScanParam->notifyHost = FALSE;
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700719 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
720 {
721 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SCAN;
722 }
723 else
724 {
725 pInitScanParam->scanMode = eHAL_SYS_MODE_LEARN;
726 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700727
Jeff Johnsone7245742012-09-05 17:12:55 -0700728 pInitScanParam->frameType = SIR_MAC_CTRL_CTS;
729 __limCreateInitScanRawFrame(pMac, pInitScanParam);
730 pInitScanParam->checkLinkTraffic = trafficCheck;
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 }
732 else
733 {
734 if(nextState == eLIM_HAL_SUSPEND_LINK_WAIT_STATE)
735 {
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700736 if (eSIR_CHECK_ROAMING_SCAN == trafficCheck)
737 {
738 pInitScanParam->scanMode = eHAL_SYS_MODE_ROAM_SUSPEND_LINK;
739 }
740 else
741 {
742 pInitScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
743 }
744
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 }
746 else
747 {
748 pInitScanParam->scanMode = eHAL_SYS_MODE_SCAN;
749 }
750 __limCreateInitScanRawFrame(pMac, pInitScanParam);
751#ifdef WLAN_FEATURE_P2P
752 if (pInitScanParam->useNoA)
753 {
754 pInitScanParam->scanDuration = pMac->lim.gTotalScanDuration;
755 }
756#endif
757 /* Inform HAL whether it should check for traffic on the link
758 * prior to performing a background scan
759 */
760 pInitScanParam->checkLinkTraffic = trafficCheck;
761 }
762
763 pMac->lim.gLimHalScanState = nextState;
764 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -0700765 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700766
767 rc = wdaPostCtrlMsg(pMac, &msg);
768 if (rc == eSIR_SUCCESS) {
769 PELOG3(limLog(pMac, LOG3, FL("wdaPostCtrlMsg() return eSIR_SUCCESS pMac=%x nextState=%d\n"),
770 pMac, pMac->lim.gLimHalScanState);)
771 return;
772 }
773
774 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
775 palFreeMemory(pMac->hHdd, (void *)pInitScanParam);
776 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d\n"), rc);)
777
778error:
779 switch(nextState)
780 {
781 case eLIM_HAL_START_SCAN_WAIT_STATE:
782 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
783 break;
784
785#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
786 case eLIM_HAL_START_LEARN_WAIT_STATE:
787 // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
788 {
789 limRestorePreLearnState(pMac);
790 limReEnableLearnMode(pMac);
791 }
792 break;
793
794#endif
795
796 //WLAN_SUSPEND_LINK Related
797 case eLIM_HAL_SUSPEND_LINK_WAIT_STATE:
798 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
799 if( pMac->lim.gpLimSuspendCallback )
800 {
801 pMac->lim.gpLimSuspendCallback( pMac, rc, pMac->lim.gpLimSuspendData );
802 pMac->lim.gpLimSuspendCallback = NULL;
803 pMac->lim.gpLimSuspendData = NULL;
804 }
805 pMac->lim.gLimSystemInScanLearnMode = 0;
806 break;
807 //end WLAN_SUSPEND_LINK Related
808 default:
809 break;
810 }
811 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
812
813 return ;
814}
815
816void
817limSendHalStartScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
818{
819 tSirMsgQ msg;
820 tpStartScanParams pStartScanParam;
821 tSirRetStatus rc = eSIR_SUCCESS;
822
823 /**
824 * The Start scan request to be sent only if Start Scan is not already requested
825 */
826 if(pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE)
827 {
828
829 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
830 (void **)&pStartScanParam,
831 sizeof(*pStartScanParam)))
832 {
833 PELOGW(limLog(pMac, LOGW, FL("palAllocateMemory() failed\n"));)
834 goto error;
835 }
836
837 msg.type = WDA_START_SCAN_REQ;
838 msg.bodyptr = pStartScanParam;
839 msg.bodyval = 0;
840 pStartScanParam->status = eHAL_STATUS_SUCCESS;
841 pStartScanParam->scanChannel = (tANI_U8)channelNum;
842
843 pMac->lim.gLimHalScanState = nextState;
844 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
845
Jeff Johnsone7245742012-09-05 17:12:55 -0700846 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Mohit Khanna23863762012-09-11 17:40:09 -0700847 limLog(pMac, LOG1, FL("Channel %d\n"), channelNum);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848
849 rc = wdaPostCtrlMsg(pMac, &msg);
850 if (rc == eSIR_SUCCESS) {
851 return;
852 }
853
854 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
855 palFreeMemory(pMac->hHdd, (void *)pStartScanParam);
856 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d\n"), rc);)
857
858error:
859 switch(nextState)
860 {
861 case eLIM_HAL_START_SCAN_WAIT_STATE:
862 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_INIT_FAILED);
863 break;
864
865#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
866 case eLIM_HAL_START_LEARN_WAIT_STATE:
867 //if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
868 {
869 limRestorePreLearnState(pMac);
870 limReEnableLearnMode(pMac);
871 }
872 break;
873
874#endif
875
876 default:
877 break;
878 }
879 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
880
881 }
882 else
883 {
884 PELOGW(limLog(pMac, LOGW, FL("Invalid state for START_SCAN_REQ message=%d\n"), pMac->lim.gLimHalScanState);)
885 }
886
887 return;
888}
889
890void limSendHalEndScanReq(tpAniSirGlobal pMac, tANI_U8 channelNum, tLimLimHalScanState nextState)
891{
892 tSirMsgQ msg;
893 tpEndScanParams pEndScanParam;
894 tSirRetStatus rc = eSIR_SUCCESS;
895
896 /**
897 * The End scan request to be sent only if End Scan is not already requested or
898 * Start scan is not already requestd
899 */
900 if((pMac->lim.gLimHalScanState != eLIM_HAL_END_SCAN_WAIT_STATE) &&
901 (pMac->lim.gLimHalScanState != eLIM_HAL_START_SCAN_WAIT_STATE))
902 {
903
904 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pEndScanParam,
905 sizeof(*pEndScanParam)))
906 {
907 PELOGW(limLog(pMac, LOGW, FL("palAllocateMemory() failed\n"));)
908 goto error;
909 }
910
911 msg.type = WDA_END_SCAN_REQ;
912 msg.bodyptr = pEndScanParam;
913 msg.bodyval = 0;
914 pEndScanParam->status = eHAL_STATUS_SUCCESS;
915 pEndScanParam->scanChannel = (tANI_U8)channelNum;
916
917 pMac->lim.gLimHalScanState = nextState;
918 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -0700919 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700920
921 rc = wdaPostCtrlMsg(pMac, &msg);
922 if (rc == eSIR_SUCCESS) {
923 return;
924 }
925
926 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
927 palFreeMemory(pMac->hHdd, (void *)pEndScanParam);
928 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d\n"), rc);)
929
930 error:
931 switch(nextState)
932 {
933 case eLIM_HAL_END_SCAN_WAIT_STATE:
934 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_END_FAILED);
935 break;
936
937#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
938 case eLIM_HAL_END_LEARN_WAIT_STATE:
939 // if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
940 {
941 limRestorePreLearnState(pMac);
942 limReEnableLearnMode(pMac);
943 }
944 break;
945#endif
946
947 default:
948 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg Rcvd invalid nextState %d\n"), nextState);)
949 break;
950 }
951 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
952 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d\n"), rc);)
953 }
954 else
955 {
956 PELOGW(limLog(pMac, LOGW, FL("Invalid state for END_SCAN_REQ message=%d\n"), pMac->lim.gLimHalScanState);)
957 }
958
959
960 return;
961}
962
963/**
964 * limSendHalFinishScanReq()
965 *
966 *FUNCTION:
967 * This function is called to finish scan/learn request..
968 *
969 *LOGIC:
970 *
971 *ASSUMPTIONS:
972 * NA
973 *
974 *NOTE:
975 * NA
976 *
977 * @param pMac - Pointer to Global MAC structure
978 * @param nextState - this parameters determines whether this call is for scan or learn
979 *
980 * @return None
981 */
982void limSendHalFinishScanReq(tpAniSirGlobal pMac, tLimLimHalScanState nextState)
983{
984
985 tSirMsgQ msg;
986 tpFinishScanParams pFinishScanParam;
987 tSirRetStatus rc = eSIR_SUCCESS;
988
989 if(pMac->lim.gLimHalScanState == nextState)
990 {
991 /*
992 * PE may receive multiple probe responses, while waiting for HAL to send 'FINISH_SCAN_RSP' message
993 * PE was sending multiple finish scan req messages to HAL
994 * this check will avoid that.
995 * If PE is already waiting for the 'finish_scan_rsp' message from HAL, it will ignore this request.
996 */
997 PELOGW(limLog(pMac, LOGW, FL("Next Scan State is same as the current state: %d \n"), nextState);)
998 return;
999 }
1000
1001
1002 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pFinishScanParam,
1003 sizeof(*pFinishScanParam)))
1004 {
1005 PELOGW(limLog(pMac, LOGW, FL("palAllocateMemory() failed\n"));)
1006 goto error;
1007 }
1008
1009 msg.type = WDA_FINISH_SCAN_REQ;
1010 msg.bodyptr = pFinishScanParam;
1011 msg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001012
1013 peGetResumeChannel(pMac, &pFinishScanParam->currentOperChannel, &pFinishScanParam->cbState);
1014
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 palZeroMemory( pMac->hHdd, (tANI_U8 *)&pFinishScanParam->macMgmtHdr, sizeof(tSirMacMgmtHdr));
1016
1017 if (nextState == eLIM_HAL_FINISH_LEARN_WAIT_STATE)
1018 {
1019 //AP - No pkt need to be transmitted
1020 pFinishScanParam->scanMode = eHAL_SYS_MODE_LEARN;
1021 pFinishScanParam->notifyBss = FALSE;
1022 pFinishScanParam->notifyHost = FALSE;
1023 pFinishScanParam->frameType = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001024
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 pFinishScanParam->frameLength = 0;
1026 pMac->lim.gLimHalScanState = nextState;
1027 }
1028 else
1029 {
1030 /* If STA is associated with an AP (ie. STA is in
1031 * LINK_ESTABLISHED state), then STA need to inform
1032 * the AP via either DATA-NULL
1033 */
1034 if (nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE)
1035 {
1036 pFinishScanParam->scanMode = eHAL_SYS_MODE_SUSPEND_LINK;
1037 }
1038 else
1039 {
1040 pFinishScanParam->scanMode = eHAL_SYS_MODE_SCAN;
1041 }
1042 pFinishScanParam->notifyHost = FALSE;
1043 __limCreateFinishScanRawFrame(pMac, pFinishScanParam);
1044 //WLAN_SUSPEND_LINK Related
1045 pMac->lim.gLimHalScanState = nextState;
1046 //end WLAN_SUSPEND_LINK Related
1047 }
1048
1049 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001050 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001051
1052 rc = wdaPostCtrlMsg(pMac, &msg);
1053 if (rc == eSIR_SUCCESS) {
1054 return;
1055 }
1056 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1057 palFreeMemory(pMac->hHdd, (void *)pFinishScanParam);
1058 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg failed, error code %d\n"), rc);)
1059
1060 error:
1061 if(nextState == eLIM_HAL_FINISH_SCAN_WAIT_STATE)
1062 limCompleteMlmScan(pMac, eSIR_SME_HAL_SCAN_FINISH_FAILED);
1063 //WLAN_SUSPEND_LINK Related
1064 else if ( nextState == eLIM_HAL_RESUME_LINK_WAIT_STATE )
1065 {
1066 if( pMac->lim.gpLimResumeCallback )
1067 {
1068 pMac->lim.gpLimResumeCallback( pMac, rc, pMac->lim.gpLimResumeData );
1069 pMac->lim.gpLimResumeCallback = NULL;
1070 pMac->lim.gpLimResumeData = NULL;
1071 pMac->lim.gLimSystemInScanLearnMode = 0;
1072 }
1073 }
1074 //end WLAN_SUSPEND_LINK Related
1075 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
1076 return;
1077}
1078
1079/**
1080 * limContinueChannelScan()
1081 *
1082 *FUNCTION:
1083 * This function is called by limPerformChannelScan().
1084 * This function is called to continue channel scanning when
1085 * Beacon/Probe Response frame are received.
1086 *
1087 *LOGIC:
1088 * Scan criteria stored in pMac->lim.gLimMlmScanReq is used
1089 * to perform channel scan. In this function MLM sub module
1090 * makes channel switch, sends PROBE REQUEST frame in case of
1091 * ACTIVE SCANNING, starts min/max channel timers, programs
1092 * NAV to probeDelay timer and waits for Beacon/Probe Response.
1093 * Once all required channels are scanned, LIM_MLM_SCAN_CNF
1094 * primitive is used to send Scan results to SME sub module.
1095 *
1096 *ASSUMPTIONS:
1097 * 1. In case of Active scanning, start MAX channel time iff
1098 * MIN channel timer expired and activity is observed on
1099 * the channel.
1100 *
1101 *NOTE:
1102 * NA
1103 *
1104 * @param pMac Pointer to Global MAC structure
1105 * @return None
1106 */
1107void
1108limContinueChannelScan(tpAniSirGlobal pMac)
1109{
1110 tANI_U8 channelNum;
1111
1112 PELOG1(limLog(pMac, LOG1, FL("Continue SCAN : chan %d tot %d\n"),
1113 pMac->lim.gLimCurrentScanChannelId,
1114 pMac->lim.gpLimMlmScanReq->channelList.numChannels);)
1115
1116 if (pMac->lim.gLimCurrentScanChannelId >
1117 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1)
1118 || pMac->lim.abortScan)
1119 {
1120#ifndef ANI_SNIFFER
1121 pMac->lim.abortScan = 0;
1122 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1123 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1124
1125 //Set the resume channel to Any valid channel (invalid).
1126 //This will instruct HAL to set it to any previous valid channel.
1127 peSetResumeChannel(pMac, 0, 0);
1128
1129 /// Done scanning all required channels
1130 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
1131#endif
1132 return;
1133 }
1134
1135 /// Atleast one more channel is to be scanned
1136
1137 if ((pMac->lim.gLimReturnAfterFirstMatch & 0x40) ||
1138 (pMac->lim.gLimReturnAfterFirstMatch & 0x80))
1139 {
1140 while (pMac->lim.gLimCurrentScanChannelId <=
1141 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1142 {
1143 if (((limGetCurrentScanChannel(pMac) <= 14) &&
1144 pMac->lim.gLim24Band11dScanDone) ||
1145 ((limGetCurrentScanChannel(pMac) > 14) &&
1146 pMac->lim.gLim50Band11dScanDone))
1147 {
1148 limLog(pMac, LOGW, FL("skipping chan %d\n"),
1149 limGetCurrentScanChannel(pMac));
1150 pMac->lim.gLimCurrentScanChannelId++;
1151 }
1152 else
1153 break;
1154 }
1155
1156 if (pMac->lim.gLimCurrentScanChannelId >
1157 (tANI_U32) (pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
1158 {
1159 pMac->lim.abortScan = 0;
1160 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1161 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1162 /// Done scanning all required channels
1163 //Set the resume channel to Any valid channel (invalid).
1164 //This will instruct HAL to set it to any previous valid channel.
1165 peSetResumeChannel(pMac, 0, 0);
1166 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
1167 return;
1168 }
1169 }
1170
1171 channelNum = limGetCurrentScanChannel(pMac);
1172 PELOG2(limLog(pMac, LOG2, FL("Current Channel to be scanned is %d\n"),
1173 channelNum);)
1174
1175 limSendHalStartScanReq(pMac, channelNum, eLIM_HAL_START_SCAN_WAIT_STATE);
1176 return;
1177} /*** end limContinueChannelScan() ***/
1178
1179
1180
1181/**
1182 * limRestorePreScanState()
1183 *
1184 *FUNCTION:
1185 * This function is called by limContinueChannelScan()
1186 * to restore HW state prior to entering 'scan state'
1187 *
1188 *LOGIC
1189 *
1190 *ASSUMPTIONS:
1191 *
1192 *NOTE:
1193 * NA
1194 *
1195 * @param pMac Pointer to Global MAC structure
1196 * @return None
1197 */
1198void
1199limRestorePreScanState(tpAniSirGlobal pMac)
1200{
1201 int i;
1202
1203 /// Deactivate MIN/MAX channel timers if running
1204 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
1205 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
1206
1207 /* Re-activate Heartbeat timers for connected sessions as scan
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001208 * is done if the DUT is in active mode
1209 * AND it is not a ROAMING ("background") scan */
1210 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 (ePMM_STATE_READY == pMac->pmm.gPmmState))
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001212 && (pMac->lim.gLimBackgroundScanMode != eSIR_ROAMING_SCAN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 {
1214 for(i=0;i<pMac->lim.maxBssId;i++)
1215 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001216 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1217 (pMac->lim.gpSession[i].valid == TRUE) &&
1218 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 {
1220 limReactivateHeartBeatTimer(pMac, peFindSessionBySessionId(pMac,i));
1221 }
1222 }
1223 }
1224
1225 /**
1226 * clean up message queue.
1227 * If SME messages, redirect to deferred queue.
1228 * The rest will be discarded.
1229 */
1230 //limCleanupMsgQ(pMac);
1231
1232 pMac->lim.gLimSystemInScanLearnMode = 0;
1233 PELOG1(limLog(pMac, LOG1, FL("Scan ended, took %d tu\n"), (tx_time_get() - pMac->lim.scanStartTime));)
1234} /*** limRestorePreScanState() ***/
1235
Jeff Johnsone7245742012-09-05 17:12:55 -07001236#ifdef FEATURE_OEM_DATA_SUPPORT
1237
1238void limSendHalOemDataReq(tpAniSirGlobal pMac)
1239{
1240 tSirMsgQ msg;
1241 tpStartOemDataReq pStartOemDataReq = NULL;
1242 tSirRetStatus rc = eSIR_SUCCESS;
1243 tpLimMlmOemDataRsp pMlmOemDataRsp;
1244 tANI_U32 reqLen = 0;
1245 if(NULL == pMac->lim.gpLimMlmOemDataReq)
1246 {
1247 PELOGE(limLog(pMac, LOGE, FL("Null pointer\n"));)
1248 goto error;
1249 }
1250
1251 reqLen = sizeof(tStartOemDataReq);
1252
1253 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd, (void**)&pStartOemDataReq, reqLen))
1254 {
1255 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Could not allocate memory for pStartOemDataReq\n"));)
1256 goto error;
1257 }
1258
1259 palZeroMemory(pMac->hHdd, (tANI_U8*)(pStartOemDataReq), reqLen);
1260
1261 //Now copy over the information to the OEM DATA REQ to HAL
1262 palCopyMemory(pMac->hHdd, pStartOemDataReq->selfMacAddr, pMac->lim.gpLimMlmOemDataReq->selfMacAddr, sizeof(tSirMacAddr));
1263
1264 palCopyMemory(pMac->hHdd, pStartOemDataReq->oemDataReq, pMac->lim.gpLimMlmOemDataReq->oemDataReq, OEM_DATA_REQ_SIZE);
1265
1266 //Create the message to be passed to HAL
1267 msg.type = WDA_START_OEM_DATA_REQ;
1268 msg.bodyptr = pStartOemDataReq;
1269 msg.bodyval = 0;
1270
1271 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1272 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
1273
1274 rc = wdaPostCtrlMsg(pMac, &msg);
1275 if(rc == eSIR_SUCCESS)
1276 {
1277 return;
1278 }
1279
1280 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1281 palFreeMemory(pMac->hHdd, (void*)pStartOemDataReq);
1282 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: posting WDA_START_OEM_DATA_REQ to HAL failed\n"));)
1283
1284error:
1285 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
1286
1287 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd, (void**)(&pMlmOemDataRsp), sizeof(tLimMlmOemDataRsp)))
1288 {
1289 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure\n"));
1290 return;
1291 }
1292
1293 if(NULL != pMac->lim.gpLimMlmOemDataReq)
1294 {
1295 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmOemDataReq);
1296 pMac->lim.gpLimMlmOemDataReq = NULL;
1297 }
1298
1299 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1300
1301 return;
1302}
1303/**
1304 * limSetOemDataReqModeFailed()
1305 *
1306 * FUNCTION:
1307 * This function is used as callback to resume link after the suspend fails while
1308 * starting oem data req mode.
1309 * LOGIC:
1310 * NA
1311 *
1312 * ASSUMPTIONS:
1313 * NA
1314 *
1315 * NOTE:
1316 *
1317 * @param pMac - Pointer to Global MAC structure
1318 * @return None
1319 */
1320
1321void limSetOemDataReqModeFailed(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1322{
1323 tpLimMlmOemDataRsp pMlmOemDataRsp;
1324
1325 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
1326
1327 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd, (void**)(&pMlmOemDataRsp), sizeof(tLimMlmOemDataRsp)))
1328 {
1329 limLog(pMac->hHdd, LOGP, FL("OEM_DATA: memory allocation for pMlmOemDataRsp failed under suspend link failure\n"));
1330 return;
1331 }
1332
1333 if(NULL != pMac->lim.gpLimMlmOemDataReq)
1334 {
1335 palFreeMemory(pMac->hHdd, pMac->lim.gpLimMlmOemDataReq);
1336 pMac->lim.gpLimMlmOemDataReq = NULL;
1337 }
1338
1339 palZeroMemory(pMac->hHdd, pMlmOemDataRsp, sizeof(tLimMlmOemDataRsp));
1340
1341 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1342
1343 return;
1344}
1345
1346/**
1347 * limSetOemDataReqMode()
1348 *
1349 *FUNCTION:
1350 * This function is called to setup system into OEM DATA REQ mode
1351 *
1352 *LOGIC:
1353 * NA
1354 *
1355 *ASSUMPTIONS:
1356 * NA
1357 *
1358 *NOTE:
1359 *
1360 * @param pMac - Pointer to Global MAC structure
1361 * @return None
1362 */
1363
1364void limSetOemDataReqMode(tpAniSirGlobal pMac, eHalStatus status, tANI_U32* data)
1365{
1366 if(status != eHAL_STATUS_SUCCESS)
1367 {
1368 limLog(pMac, LOGE, FL("OEM_DATA: failed in suspend link\n"));
1369 goto error;
1370 }
1371 else
1372 {
1373 PELOGE(limLog(pMac, LOGE, FL("OEM_DATA: Calling limSendHalOemDataReq\n"));)
1374 limSendHalOemDataReq(pMac);
1375 return;
1376 }
1377
1378error:
1379 limResumeLink(pMac, limSetOemDataReqModeFailed, NULL);
1380 return ;
1381} /*** end limSendHalOemDataReq() ***/
1382
1383#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001384
1385static void
1386mlm_add_sta(
1387 tpAniSirGlobal pMac,
1388 tpAddStaParams pSta,
1389 tANI_U8 *pBssid,
1390 tANI_U8 htCapable,
1391 tpPESession psessionEntry) //psessionEntry may required in future
1392{
1393 tANI_U32 val;
1394 int i;
1395
1396
1397 pSta->staType = STA_ENTRY_SELF; // Identifying self
1398
1399 palCopyMemory( pMac->hHdd, pSta->bssId, pBssid, sizeof( tSirMacAddr ));
1400 palCopyMemory( pMac->hHdd, pSta->staMac, psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
1401
1402 /* Configuration related parameters to be changed to support BT-AMP */
1403
1404 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_LISTEN_INTERVAL, &val ))
1405 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL\n"));
1406
1407 pSta->listenInterval = (tANI_U16) val;
1408
1409 if (eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) )
1410 limLog(pMac, LOGP, FL("Couldn't get SHORT_PREAMBLE\n"));
1411 pSta->shortPreambleSupported = (tANI_U8)val;
1412
1413 pSta->assocId = 0; // Is SMAC OK with this?
1414 pSta->wmmEnabled = 0;
1415 pSta->uAPSD = 0;
1416 pSta->maxSPLen = 0;
1417 pSta->us32MaxAmpduDuration = 0;
1418 pSta->maxAmpduSize = 0; // 0: 8k, 1: 16k,2: 32k,3: 64k
1419
1420
1421 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1422 {
1423 pSta->htCapable = htCapable;
1424#ifdef WLAN_SOFTAP_FEATURE
1425 pSta->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
1426 pSta->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry );
1427 pSta->mimoPS = (tSirMacHTMIMOPowerSaveState)limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
1428 pSta->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
1429 pSta->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
1430 pSta->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
1431 pSta->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
1432 pSta->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
1433 pSta->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
1434 pSta->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
1435 pSta->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
1436#else
1437 pSta->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD );
1438 pSta->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET );
1439 pSta->mimoPS = (tSirMacHTMIMOPowerSaveState)limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE );
1440 pSta->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE );
1441 pSta->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION );
1442 pSta->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA );
1443 pSta->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY );
1444 pSta->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH );
1445 pSta->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ);
1446 pSta->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ);
1447 pSta->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ);
1448
1449#endif
1450 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001451#ifdef WLAN_FEATURE_11AC
1452 if (psessionEntry->vhtCapability)
1453 {
1454 pSta->vhtCapable = VOS_TRUE;
1455 }
1456#endif
1457#ifdef WLAN_FEATURE_11AC
1458 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry,NULL);
1459#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 limPopulateOwnRateSet(pMac, &pSta->supportedRates, NULL, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001461#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 limFillSupportedRatesInfo(pMac, NULL, &pSta->supportedRates,psessionEntry);
1463
1464 limLog( pMac, LOGE, FL( "GF: %d, ChnlWidth: %d, MimoPS: %d, lsigTXOP: %d, dsssCCK: %d, SGI20: %d, SGI40%d\n") ,
1465 pSta->greenFieldCapable, pSta->txChannelWidthSet, pSta->mimoPS, pSta->lsigTxopProtection,
1466 pSta->fDsssCckMode40Mhz,pSta->fShortGI20Mhz, pSta->fShortGI40Mhz);
1467
1468#ifdef WLAN_FEATURE_P2P
1469 if (VOS_P2P_GO_MODE == psessionEntry->pePersona)
1470 {
1471 pSta->p2pCapableSta = 1;
1472 }
1473#endif
1474
1475 //Disable BA. It will be set as part of ADDBA negotiation.
1476 for( i = 0; i < STACFG_MAX_TC; i++ )
1477 {
1478 pSta->staTCParams[i].txUseBA = eBA_DISABLE;
1479 pSta->staTCParams[i].rxUseBA = eBA_DISABLE;
1480 }
1481
1482}
1483
1484//
1485// New HAL interface - WDA_ADD_BSS_REQ
1486// Package WDA_ADD_BSS_REQ to HAL, in order to start a BSS
1487//
1488tSirResultCodes
1489limMlmAddBss (
1490 tpAniSirGlobal pMac,
1491 tLimMlmStartReq *pMlmStartReq,
1492 tpPESession psessionEntry)
1493{
1494 tSirMsgQ msgQ;
1495 tpAddBssParams pAddBssParams = NULL;
1496 tANI_U32 retCode;
1497
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 // Package WDA_ADD_BSS_REQ message parameters
1499
1500 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1501 (void **) &pAddBssParams, sizeof( tAddBssParams )))
1502 {
1503 limLog( pMac, LOGE, FL( "Unable to PAL allocate memory during ADD_BSS\n" ));
1504 // Respond to SME with LIM_MLM_START_CNF
1505 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1506 }
1507
1508 palZeroMemory(pMac->hHdd, pAddBssParams, sizeof(tAddBssParams));
1509
1510 // Fill in tAddBssParams members
1511 palCopyMemory( pMac->hHdd, pAddBssParams->bssId, pMlmStartReq->bssId,
1512 sizeof( tSirMacAddr ));
1513
1514 // Fill in tAddBssParams selfMacAddr
1515 palCopyMemory ( pMac->hHdd, pAddBssParams->selfMacAddr,
1516 psessionEntry->selfMacAddr,
1517 sizeof( tSirMacAddr ));
1518
1519 pAddBssParams->bssType = pMlmStartReq->bssType;
1520 if ((pMlmStartReq->bssType == eSIR_IBSS_MODE) ||
1521 (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE)||
1522 (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE)) {
1523 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
1524 }
1525#ifdef WLAN_SOFTAP_FEATURE
1526 else if (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE){
1527#else
1528 else{
1529#endif
1530 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_AP;
1531 }
1532
1533#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 pAddBssParams->shortSlotTimeSupported = psessionEntry->shortSlotTimeSupported;
Jeff Johnson295189b2012-06-20 16:38:30 -07001535#endif
1536
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 pAddBssParams->beaconInterval = pMlmStartReq->beaconPeriod;
1538 pAddBssParams->dtimPeriod = pMlmStartReq->dtimPeriod;
1539 pAddBssParams->cfParamSet.cfpCount = pMlmStartReq->cfParamSet.cfpCount;
1540 pAddBssParams->cfParamSet.cfpPeriod = pMlmStartReq->cfParamSet.cfpPeriod;
1541 pAddBssParams->cfParamSet.cfpMaxDuration = pMlmStartReq->cfParamSet.cfpMaxDuration;
1542 pAddBssParams->cfParamSet.cfpDurRemaining = pMlmStartReq->cfParamSet.cfpDurRemaining;
1543
1544 pAddBssParams->rateSet.numRates = pMlmStartReq->rateSet.numRates;
1545 palCopyMemory( pMac->hHdd, pAddBssParams->rateSet.rate,
1546 pMlmStartReq->rateSet.rate, pMlmStartReq->rateSet.numRates );
1547
1548 pAddBssParams->nwType = pMlmStartReq->nwType;
1549
1550 pAddBssParams->htCapable = pMlmStartReq->htCapable;
Jeff Johnsone7245742012-09-05 17:12:55 -07001551#ifdef WLAN_FEATURE_11AC
1552 pAddBssParams->vhtCapable = psessionEntry->vhtCapability;
1553 pAddBssParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
1554#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 pAddBssParams->htOperMode = pMlmStartReq->htOperMode;
1556 pAddBssParams->dualCTSProtection = pMlmStartReq->dualCTSProtection;
1557 pAddBssParams->txChannelWidthSet = pMlmStartReq->txChannelWidthSet;
1558
1559 pAddBssParams->currentOperChannel = pMlmStartReq->channelNumber;
Jeff Johnsone7245742012-09-05 17:12:55 -07001560 pAddBssParams->currentExtChannel = pMlmStartReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001561
1562 /* Update PE sessionId*/
1563 pAddBssParams->sessionId = pMlmStartReq->sessionId;
1564
1565 //Send the SSID to HAL to enable SSID matching for IBSS
1566 palCopyMemory( pMac->hHdd, &(pAddBssParams->ssId.ssId),
1567 pMlmStartReq->ssId.ssId,
1568 pMlmStartReq->ssId.length);
1569 pAddBssParams->ssId.length = pMlmStartReq->ssId.length;
1570#ifdef WLAN_SOFTAP_FEATURE
1571 pAddBssParams->bHiddenSSIDEn = pMlmStartReq->ssidHidden;
1572 limLog( pMac, LOGE, FL( "TRYING TO HIDE SSID %d\n" ),pAddBssParams->bHiddenSSIDEn);
1573 // CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed.
1574 pAddBssParams->bProxyProbeRespEn = 0;
1575 pAddBssParams->obssProtEnabled = pMlmStartReq->obssProtEnabled;
1576
1577#endif
1578#if defined WLAN_FEATURE_VOWIFI
1579 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
1580#endif
1581 mlm_add_sta(pMac, &pAddBssParams->staContext,
1582 pAddBssParams->bssId, pAddBssParams->htCapable,psessionEntry);
1583
1584 pAddBssParams->status = eHAL_STATUS_SUCCESS;
1585 pAddBssParams->respReqd = 1;
1586
1587 // Set a new state for MLME
1588 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001590
1591 pAddBssParams->halPersona=psessionEntry->pePersona; //pass on the session persona to hal
1592
1593 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
1594
1595#if defined WLAN_FEATURE_VOWIFI_11R
1596 pAddBssParams->extSetStaKeyParamValid = 0;
1597#endif
1598
1599 //
1600 // FIXME_GEN4
1601 // A global counter (dialog token) is required to keep track of
1602 // all PE <-> HAL communication(s)
1603 //
1604 msgQ.type = WDA_ADD_BSS_REQ;
1605 msgQ.reserved = 0;
1606 msgQ.bodyptr = pAddBssParams;
1607 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001608 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001609
1610 limLog( pMac, LOGW, FL( "Sending WDA_ADD_BSS_REQ...\n" ));
1611 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
1612 {
1613 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X\n"), retCode );
1614 palFreeMemory(pMac->hHdd,(void *)pAddBssParams);
1615 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
1616 }
1617
1618 return eSIR_SME_SUCCESS;
1619}
1620
1621
1622/**
1623 * limProcessMlmStartReq()
1624 *
1625 *FUNCTION:
1626 * This function is called to process MLM_START_REQ message
1627 * from SME
1628 *
1629 *LOGIC:
1630 * 1) MLME receives LIM_MLM_START_REQ from LIM
1631 * 2) MLME sends WDA_ADD_BSS_REQ to HAL
1632 * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
1633 * MLME now waits for HAL to send WDA_ADD_BSS_RSP
1634 *
1635 *ASSUMPTIONS:
1636 *
1637 *NOTE:
1638 *
1639 * @param pMac Pointer to Global MAC structure
1640 * @param *pMsgBuf A pointer to the MLM message buffer
1641 * @return None
1642 */
1643
1644static void
1645limProcessMlmStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1646{
1647 tLimMlmStartReq *pMlmStartReq;
1648 tLimMlmStartCnf mlmStartCnf;
1649 tpPESession psessionEntry = NULL;
1650
1651 if(pMsgBuf == NULL)
1652 {
1653 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
1654 return;
1655 }
1656
1657 pMlmStartReq = (tLimMlmStartReq *) pMsgBuf;
1658 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmStartReq->sessionId))==NULL)
1659 {
1660 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
1661 mlmStartCnf.resultCode = eSIR_SME_REFUSED;
1662 goto end;
1663 }
1664
1665 if (psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE)
1666 {
1667 /**
1668 * Should not have received Start req in states other than idle.
1669 * Return Start confirm with failure code.
1670 */
1671 PELOGE(limLog(pMac, LOGE, FL("received unexpected MLM_START_REQ in state %X\n"),psessionEntry->limMlmState);)
1672 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
1673 mlmStartCnf.resultCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1674 goto end;
1675 }
1676
1677 #if 0
1678 if (cfgSetInt(pMac, WNI_CFG_CURRENT_CHANNEL, pMlmStartReq->channelNumber)!= eSIR_SUCCESS)
1679 limLog(pMac, LOGP, FL("could not set CURRENT_CHANNEL at CFG\n"));
1680
1681 pMac->lim.gLimCurrentChannelId = pMlmStartReq->channelNumber;
1682 #endif //TO SUPPORT BT-AMP
1683
1684
1685 // Update BSSID & SSID at CFG database
1686 #if 0 //We are not using the BSSID and SSID from the config file, instead we are reading form the session table
1687 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) pMlmStartReq->bssId, sizeof(tSirMacAddr))
1688 != eSIR_SUCCESS)
1689 limLog(pMac, LOGP, FL("could not update BSSID at CFG\n"));
1690
1691
1692
1693 palCopyMemory( pMac->hHdd, pMac->lim.gLimCurrentBssId,
1694 pMlmStartReq->bssId,
1695 sizeof(tSirMacAddr));
1696 #endif //TO SUPPORT BT-AMP
1697
1698 #if 0
1699 if (cfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *) &pMlmStartReq->ssId.ssId, pMlmStartReq->ssId.length)
1700 != eSIR_SUCCESS)
1701 limLog(pMac, LOGP, FL("could not update SSID at CFG\n"));
1702 #endif //To SUPPORT BT-AMP
1703
1704
1705 // pMac->lim.gLimCurrentSSID.length = pMlmStartReq->ssId.length;
1706
1707 #if 0
1708 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
1709 (tANI_U8 *) &pMac->lim.gpLimStartBssReq->operationalRateSet.rate,
1710 pMac->lim.gpLimStartBssReq->operationalRateSet.numRates)
1711 != eSIR_SUCCESS)
1712 limLog(pMac, LOGP, FL("could not update Operational Rateset at CFG\n"));
1713 #endif //TO SUPPORT BT-AMP
1714
1715
1716#if defined(ANI_PRODUCT_TYPE_AP) && (WNI_POLARIS_FW_PACKAGE == ADVANCED)
1717 if (cfgSetInt(pMac, WNI_CFG_CURRENT_TX_POWER_LEVEL, pMac->lim.gpLimStartBssReq->powerLevel)
1718 != eSIR_SUCCESS)
1719 limLog(pMac, LOGP, FL("could not set WNI_CFG_CURRENT_TX_POWER_LEVEL at CFG\n"));
1720#endif
1721
1722#ifdef WLAN_SOFTAP_FEATURE
1723#if 0 // Periodic timer for remove WPS PBC proble response entry in PE is disbaled now.
1724 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1725 {
1726 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_FALSE)
1727 {
1728 if (tx_timer_create(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer,
1729 "PS OVERLAP Timer",
1730 limWPSOverlapTimerHandler,
1731 SIR_LIM_WPS_OVERLAP_TIMEOUT, // expiration_input
1732 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // initial_ticks
1733 SYS_MS_TO_TICKS(LIM_WPS_OVERLAP_TIMER_MS), // reschedule_ticks
1734 TX_AUTO_ACTIVATE /* TX_NO_ACTIVATE*/) != TX_SUCCESS)
1735 {
1736 limLog(pMac, LOGP, FL("failed to create WPS overlap Timer\n"));
1737 }
1738
1739 pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId = pMlmStartReq->sessionId;
1740 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_TRUE;
1741 limLog(pMac, LOGE, FL("Create WPS overlap Timer, session=%d\n"), pMlmStartReq->sessionId);
1742
1743 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
1744 {
1745 limLog(pMac, LOGP, FL("tx_timer_activate failed\n"));
1746 }
1747 }
1748 }
1749#endif
1750#endif
1751
1752
1753
1754 mlmStartCnf.resultCode = limMlmAddBss(pMac, pMlmStartReq,psessionEntry);
1755
1756end:
1757 /* Update PE session Id */
1758 mlmStartCnf.sessionId = pMlmStartReq->sessionId;
1759
1760 /// Free up buffer allocated for LimMlmScanReq
1761 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf);
1762
1763 //
1764 // Respond immediately to LIM, only if MLME has not been
1765 // successfully able to send WDA_ADD_BSS_REQ to HAL.
1766 // Else, LIM_MLM_START_CNF will be sent after receiving
1767 // WDA_ADD_BSS_RSP from HAL
1768 //
1769 if( eSIR_SME_SUCCESS != mlmStartCnf.resultCode )
1770 limPostSmeMessage(pMac, LIM_MLM_START_CNF, (tANI_U32 *) &mlmStartCnf);
1771} /*** limProcessMlmStartReq() ***/
1772
1773
1774/*
1775* This function checks if Scan is allowed or not.
1776* It checks each session and if any session is not in the normal state,
1777* it will return false.
1778* Note: BTAMP_STA can be in LINK_EST as well as BSS_STARTED State, so
1779* both cases are handled below.
1780*/
1781
1782static tANI_U8 __limMlmScanAllowed(tpAniSirGlobal pMac)
1783{
1784 int i;
1785
Jeff Johnson43971f52012-07-17 12:26:56 -07001786 if(pMac->lim.gLimMlmState != eLIM_MLM_IDLE_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 {
1788 return FALSE;
1789 }
1790 for(i =0; i < pMac->lim.maxBssId; i++)
1791 {
1792 if(pMac->lim.gpSession[i].valid == TRUE)
1793 {
1794 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
1795 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1796 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) )||
1797
1798 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
1799 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
1800 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
1801 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
1802#ifdef WLAN_FEATURE_P2P
1803 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
1804 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
1805 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
1806 && (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_BSS_STARTED_STATE) )
1807#endif
1808 ))
1809 {
1810 return FALSE;
1811
1812 }
1813 }
1814 }
1815
1816 return TRUE;
1817}
1818
1819
1820
1821/**
1822 * limProcessMlmScanReq()
1823 *
1824 *FUNCTION:
1825 * This function is called to process MLM_SCAN_REQ message
1826 * from SME
1827 *
1828 *LOGIC:
1829 *
1830 *ASSUMPTIONS:
1831 *
1832 *NOTE:
1833 *
1834 * @param pMac Pointer to Global MAC structure
1835 * @param *pMsgBuf A pointer to the MLM message buffer
1836 * @return None
1837 */
1838
1839static void
1840limProcessMlmScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1841{
1842 tLimMlmScanCnf mlmScanCnf;
1843
1844 if (pMac->lim.gLimSystemInScanLearnMode)
1845 {
1846 PELOGE(limLog(pMac, LOGE,
1847 FL("Sending START_SCAN from LIM while one req is pending\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001848 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudid4b301b2012-10-11 14:15:54 -07001849 /*Send back a failure*/
1850 mlmScanCnf.resultCode = eSIR_SME_SCAN_FAILED;
1851 mlmScanCnf.scanResultLength = 0;
1852 limPostSmeMessage(pMac,
1853 LIM_MLM_SCAN_CNF,
1854 (tANI_U32 *) &mlmScanCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 return;
1856 }
1857
1858 if(__limMlmScanAllowed(pMac) &&
1859 (((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels != 0))
1860
1861 {
1862 /// Hold onto SCAN REQ criteria
1863 pMac->lim.gpLimMlmScanReq = (tLimMlmScanReq *) pMsgBuf;
1864
1865 PELOG3(limLog(pMac, LOG3, FL("Number of channels to scan are %d \n"),
1866 pMac->lim.gpLimMlmScanReq->channelList.numChannels);)
1867
1868 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
1869
1870 if (pMac->lim.gpLimMlmScanReq->scanType == eSIR_ACTIVE_SCAN)
1871 pMac->lim.gLimMlmState = eLIM_MLM_WT_PROBE_RESP_STATE;
1872 else // eSIR_PASSIVE_SCAN
1873 pMac->lim.gLimMlmState = eLIM_MLM_PASSIVE_SCAN_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001874 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001875
1876 pMac->lim.gLimSystemInScanLearnMode = 1;
1877
1878#ifdef WLAN_FEATURE_P2P
1879 pMac->lim.gTotalScanDuration =
1880 pMac->lim.gpLimMlmScanReq->maxChannelTime*
1881 pMac->lim.gpLimMlmScanReq->channelList.numChannels;
1882#endif
1883 limSetScanMode(pMac);
1884 }
1885 else
1886 {
1887 /**
1888 * Should not have received SCAN req in other states
1889 * OR should not have received LIM_MLM_SCAN_REQ with
1890 * zero number of channels
1891 * Log error
1892 */
1893 limLog(pMac, LOGW,
1894 FL("received unexpected MLM_SCAN_REQ in state %X OR zero number of channels: %X\n"),
1895 pMac->lim.gLimMlmState, ((tLimMlmScanReq *) pMsgBuf)->channelList.numChannels);
1896 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
1897
1898 /// Free up buffer allocated for
1899 /// pMac->lim.gLimMlmScanReq
1900 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf);
1901
1902 /// Return Scan confirm with INVALID_PARAMETERS
1903
1904 mlmScanCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1905 mlmScanCnf.scanResultLength = 0;
1906 limPostSmeMessage(pMac,
1907 LIM_MLM_SCAN_CNF,
1908 (tANI_U32 *) &mlmScanCnf);
1909 }
1910} /*** limProcessMlmScanReq() ***/
1911
Jeff Johnsone7245742012-09-05 17:12:55 -07001912#ifdef FEATURE_OEM_DATA_SUPPORT
1913static void limProcessMlmOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1914{
1915 tLimMlmOemDataRsp* pMlmOemDataRsp;
1916
1917 if (((pMac->lim.gLimMlmState == eLIM_MLM_IDLE_STATE) ||
1918 (pMac->lim.gLimMlmState == eLIM_MLM_JOINED_STATE) ||
1919 (pMac->lim.gLimMlmState == eLIM_MLM_AUTHENTICATED_STATE) ||
1920 (pMac->lim.gLimMlmState == eLIM_MLM_BSS_STARTED_STATE) ||
1921 (pMac->lim.gLimMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)))
1922 {
1923 //Hold onto the oem data request criteria
1924 pMac->lim.gpLimMlmOemDataReq = (tLimMlmOemDataReq*)pMsgBuf;
1925
1926 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
1927
1928 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
1929
1930 //Now request for link suspension
1931 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN, limSetOemDataReqMode, NULL);
1932 }
1933 else
1934 {
1935 /**
1936 * Should not have received oem data req in other states
1937 * Log error
1938 */
1939
1940 PELOGW(limLog(pMac, LOGW, FL("OEM_DATA: unexpected LIM_MLM_OEM_DATA_REQ in invalid state %X\n"),pMac->lim.gLimMlmState);)
1941
1942 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
1943
1944 /// Free up buffer allocated
1945 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf);
1946
1947 /// Return Meas confirm with INVALID_PARAMETERS
1948 if(eHAL_STATUS_SUCCESS == palAllocateMemory(pMac->hHdd, (void**)&pMlmOemDataRsp, sizeof(tLimMlmOemDataRsp)))
1949 {
1950 limPostSmeMessage(pMac, LIM_MLM_OEM_DATA_CNF, (tANI_U32*)pMlmOemDataRsp);
1951 palFreeMemory(pMac->hHdd, pMlmOemDataRsp);
1952 }
1953 else
1954 {
1955 limLog(pMac, LOGP, FL("Could not allocate memory for pMlmOemDataRsp\n"));
1956 return;
1957 }
1958 }
1959
1960 return;
1961}
1962#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001963
1964
1965/**
1966 * limProcessMlmPostJoinSuspendLink()
1967 *
1968 *FUNCTION:
1969 * This function is called after the suspend link while joining
1970 * off channel.
1971 *
1972 *LOGIC:
1973 * Check for suspend state.
1974 * If success, proceed with setting link state to recieve the
1975 * probe response/beacon from intended AP.
1976 * Switch to the APs channel.
1977 * On an error case, send the MLM_JOIN_CNF with error status.
1978 *
1979 *ASSUMPTIONS:
1980 *
1981 *NOTE:
1982 *
1983 * @param pMac Pointer to Global MAC structure
1984 * @param status status of suspend link.
1985 * @param ctx passed while calling suspend link(psessionEntry)
1986 * @return None
1987 */
1988static void
1989limProcessMlmPostJoinSuspendLink(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *ctx)
1990{
Jeff Johnsone7245742012-09-05 17:12:55 -07001991 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 tLimMlmJoinCnf mlmJoinCnf;
1993 tpPESession psessionEntry = (tpPESession)ctx;
1994 tSirLinkState linkState;
1995
1996 if( eHAL_STATUS_SUCCESS != status )
1997 {
1998 limLog(pMac, LOGP, FL("Suspend link failed. Not proceeding with join\n"));
1999 goto error;
2000 }
2001 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2002 psessionEntry->limMlmState = eLIM_MLM_WT_JOIN_BEACON_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002003 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002004
2005 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
2006
2007 //assign appropriate sessionId to the timer object
2008 pMac->lim.limTimers.gLimJoinFailureTimer.sessionId = psessionEntry->peSessionId;
2009
2010 linkState = ((psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) ? eSIR_LINK_BTAMP_PREASSOC_STATE : eSIR_LINK_PREASSOC_STATE);
2011 limLog(pMac, LOG1, FL("[limProcessMlmJoinReq]: linkState:%d\n"),linkState);
2012
2013 if (limSetLinkState(pMac, linkState,
2014 psessionEntry->pLimMlmJoinReq->bssDescription.bssId,
2015 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS )
2016 {
2017 limLog(pMac, LOGE, FL("limSetLinkState to eSIR_LINK_PREASSOC_STATE Failed!!\n"));
2018 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002019 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
2020 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 goto error;
2022 }
2023
2024 /** Derive channel from BSS description and store it in the CFG */
2025 // chanNum = pMac->lim.gpLimMlmJoinReq->bssDescription.channelId;
2026
2027 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07002028 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 //store the channel switch sessionEntry in the lim global var
2030 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_JOIN;
2031
Jeff Johnsone7245742012-09-05 17:12:55 -07002032 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002033
2034 return;
2035error:
2036 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2037 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
2038 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2039 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
2040
2041}
2042
2043
2044
2045/**
2046 * limProcessMlmJoinReq()
2047 *
2048 *FUNCTION:
2049 * This function is called to process MLM_JOIN_REQ message
2050 * from SME
2051 *
2052 *LOGIC:
2053 * 1) Initialize LIM, HAL, DPH
2054 * 2) Configure the BSS for which the JOIN REQ was received
2055 * a) Send WDA_ADD_BSS_REQ to HAL -
2056 * This will identify the BSS that we are interested in
2057 * --AND--
2058 * Add a STA entry for the AP (in a STA context)
2059 * b) Wait for WDA_ADD_BSS_RSP
2060 * c) Send WDA_ADD_STA_REQ to HAL
2061 * This will add the "local STA" entry to the STA table
2062 * 3) Continue as before, i.e,
2063 * a) Send a PROBE REQ
2064 * b) Wait for PROBE RSP/BEACON containing the SSID that
2065 * we are interested in
2066 * c) Then start an AUTH seq
2067 * d) Followed by the ASSOC seq
2068 *
2069 *ASSUMPTIONS:
2070 *
2071 *NOTE:
2072 *
2073 * @param pMac Pointer to Global MAC structure
2074 * @param *pMsgBuf A pointer to the MLM message buffer
2075 * @return None
2076 */
2077
2078static void
2079limProcessMlmJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2080{
2081 tLimMlmJoinCnf mlmJoinCnf;
2082 tANI_U8 sessionId;
2083 tpPESession psessionEntry;
2084
2085 sessionId = ((tpLimMlmJoinReq)pMsgBuf)->sessionId;
2086
2087 if((psessionEntry = peFindSessionBySessionId(pMac,sessionId))== NULL)
2088 {
2089 limLog(pMac, LOGP, FL("session does not exist for given sessionId\n"));
2090
2091 goto error;
2092 }
2093
2094 if (( (psessionEntry->limSystemRole != eLIM_AP_ROLE ) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE )) &&
2095 ( (psessionEntry->limMlmState == eLIM_MLM_IDLE_STATE) ||
2096 (psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE)) &&
2097 (SIR_MAC_GET_ESS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo) !=
2098 SIR_MAC_GET_IBSS( ((tpLimMlmJoinReq) pMsgBuf)->bssDescription.capabilityInfo)))
2099 {
2100 #if 0
2101 if (pMac->lim.gpLimMlmJoinReq)
2102 palFreeMemory( pMac->hHdd, pMac->lim.gpLimMlmJoinReq);
2103 #endif //TO SUPPORT BT-AMP , review 23sep
2104
2105 /// Hold onto Join request parameters
2106
2107 psessionEntry->pLimMlmJoinReq =(tpLimMlmJoinReq) pMsgBuf;
2108
2109 if( isLimSessionOffChannel(pMac, sessionId) )
2110 {
2111 //suspend link
2112 limSuspendLink(pMac, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
2113 limProcessMlmPostJoinSuspendLink, (tANI_U32*)psessionEntry );
2114 }
2115 else
2116 {
2117 //No need to suspend link.
2118 limProcessMlmPostJoinSuspendLink( pMac, eHAL_STATUS_SUCCESS,
2119 (tANI_U32*) psessionEntry );
2120 }
2121
2122 return;
2123 }
2124 else
2125 {
2126 /**
2127 * Should not have received JOIN req in states other than
2128 * Idle state or on AP.
2129 * Return join confirm with invalid parameters code.
2130 */
2131 PELOGE(limLog(pMac, LOGE,
2132 FL("Unexpected Join request for role %d state %X\n"),
2133 psessionEntry->limSystemRole,
2134 psessionEntry->limMlmState);)
2135 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
2136
2137 limLog(pMac, LOGE, FL("Unexpected Join request for role %d state %X\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07002138 psessionEntry->limSystemRole, psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 }
2140
2141error:
2142
2143
2144 mlmJoinCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2145 mlmJoinCnf.sessionId = sessionId;
2146 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2147 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
2148
2149
2150} /*** limProcessMlmJoinReq() ***/
2151
2152
2153
2154/**
2155 * limProcessMlmAuthReq()
2156 *
2157 *FUNCTION:
2158 * This function is called to process MLM_AUTH_REQ message
2159 * from SME
2160 *
2161 *LOGIC:
2162 *
2163 *ASSUMPTIONS:
2164 *
2165 *NOTE:
2166 *
2167 * @param pMac Pointer to Global MAC structure
2168 * @param *pMsgBuf A pointer to the MLM message buffer
2169 * @return None
2170 */
2171
2172static void
2173limProcessMlmAuthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2174{
2175 tANI_U32 numPreAuthContexts;
2176 tSirMacAddr currentBssId;
2177 tSirMacAuthFrameBody authFrameBody;
2178 tLimMlmAuthCnf mlmAuthCnf;
2179 struct tLimPreAuthNode *preAuthNode;
2180 tpDphHashNode pStaDs;
2181 tANI_U8 sessionId;
2182 tpPESession psessionEntry;
2183
2184 if(pMsgBuf == NULL)
2185 {
2186 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
2187 return;
2188 }
2189
2190 pMac->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) pMsgBuf;
2191 sessionId = pMac->lim.gpLimMlmAuthReq->sessionId;
2192 if((psessionEntry= peFindSessionBySessionId(pMac,sessionId) )== NULL)
2193 {
2194 limLog(pMac, LOGP, FL("Session Does not exist for given sessionId\n"));
2195 return;
2196 }
2197
2198 /**
2199 * Expect Auth request only when:
2200 * 1. STA joined/associated with a BSS or
2201 * 2. STA is in IBSS mode
2202 * and STA is going to authenticate with a unicast
2203 * adress and requested authentication algorithm is
2204 * supported.
2205 */
2206 #if 0
2207 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2208 eSIR_SUCCESS)
2209 {
2210 /// Could not get BSSID from CFG. Log error.
2211 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
2212 }
2213 #endif //To SuppoRT BT-AMP
2214
2215 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2216
2217 if (((((psessionEntry->limSystemRole== eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2218 ((psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) ||
2219 (psessionEntry->limMlmState ==
2220 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
2221 ((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) &&
2222 (psessionEntry->limMlmState == eLIM_MLM_BSS_STARTED_STATE))) &&
2223 (limIsGroupAddr(pMac->lim.gpLimMlmAuthReq->peerMacAddr)
2224 == false) &&
2225#ifdef WLAN_SOFTAP_FEATURE
2226 (limIsAuthAlgoSupported(
2227 pMac,
2228 pMac->lim.gpLimMlmAuthReq->authType,
2229 psessionEntry) == true)
2230#else
2231 (limIsAuthAlgoSupported(
2232 pMac,
2233 pMac->lim.gpLimMlmAuthReq->authType) == true)
2234#endif
2235 )
2236 {
2237 /**
2238 * This is a request for pre-authentication.
2239 * Check if there exists context already for
2240 * the requsted peer OR
2241 * if this request is for the AP we're currently
2242 * associated with.
2243 * If yes, return auth confirm immediately when
2244 * requested auth type is same as the one used before.
2245 */
2246 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
2247 (psessionEntry->limMlmState ==
2248 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2249 (((pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable)) != NULL) &&
2250 (pMac->lim.gpLimMlmAuthReq->authType ==
2251 pStaDs->mlmStaContext.authType)) &&
2252 (palEqualMemory( pMac->hHdd,pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2253 currentBssId,
2254 sizeof(tSirMacAddr)) )) ||
2255 (((preAuthNode =
2256 limSearchPreAuthList(
2257 pMac,
2258 pMac->lim.gpLimMlmAuthReq->peerMacAddr)) != NULL) &&
2259 (preAuthNode->authType ==
2260 pMac->lim.gpLimMlmAuthReq->authType)))
2261 {
2262 PELOG2(limLog(pMac, LOG2,
2263 FL("Already have pre-auth context with peer\n"));
2264 limPrintMacAddr(pMac, pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2265 LOG2);)
2266
2267 mlmAuthCnf.resultCode = (tSirResultCodes)
2268 eSIR_MAC_SUCCESS_STATUS;
2269
2270
2271 goto end;
2272 }
2273 else
2274 {
2275 if (wlan_cfgGetInt(pMac, WNI_CFG_MAX_NUM_PRE_AUTH,
2276 (tANI_U32 *) &numPreAuthContexts) != eSIR_SUCCESS)
2277 {
2278 limLog(pMac, LOGP,
2279 FL("Could not retrieve NumPreAuthLimit from CFG\n"));
2280 }
2281#ifdef ANI_AP_SDK_OPT
2282 if(numPreAuthContexts > SIR_SDK_OPT_MAX_NUM_PRE_AUTH)
2283 numPreAuthContexts = SIR_SDK_OPT_MAX_NUM_PRE_AUTH;
2284#endif // ANI_AP_SDK_OPT
2285
2286 if (pMac->lim.gLimNumPreAuthContexts == numPreAuthContexts)
2287 {
2288 PELOGW(limLog(pMac, LOGW,
2289 FL("Number of pre-auth reached max limit\n"));)
2290
2291 /// Return Auth confirm with reject code
2292 mlmAuthCnf.resultCode =
2293 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
2294
2295 goto end;
2296 }
2297 }
2298
2299 // Delete pre-auth node if exists
2300 if (preAuthNode)
2301 limDeletePreAuthNode(pMac,
2302 pMac->lim.gpLimMlmAuthReq->peerMacAddr);
2303
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2305 psessionEntry->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002306 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002307
2308 /// Prepare & send Authentication frame
2309 authFrameBody.authAlgoNumber =
2310 (tANI_U8) pMac->lim.gpLimMlmAuthReq->authType;
2311 authFrameBody.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
2312 authFrameBody.authStatusCode = 0;
2313 limSendAuthMgmtFrame(pMac,
2314 &authFrameBody,
2315 pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2316 LIM_NO_WEP_IN_FC,psessionEntry);
2317
Jeff Johnsone7245742012-09-05 17:12:55 -07002318 //assign appropriate sessionId to the timer object
2319 pMac->lim.limTimers.gLimAuthFailureTimer.sessionId = sessionId;
2320
2321 // Activate Auth failure timer
2322 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_AUTH_FAIL_TIMER));
2323 if (tx_timer_activate(&pMac->lim.limTimers.gLimAuthFailureTimer)
2324 != TX_SUCCESS)
2325 {
2326 /// Could not start Auth failure timer.
2327 // Log error
2328 limLog(pMac, LOGP,
2329 FL("could not start Auth failure timer\n"));
2330 // Cleanup as if auth timer expired
2331 limProcessAuthFailureTimeout(pMac);
2332 }
2333
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 return;
2335 }
2336 else
2337 {
2338 /**
2339 * Unexpected auth request.
2340 * Return Auth confirm with Invalid parameters code.
2341 */
2342 mlmAuthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2343
2344 goto end;
2345 }
2346
2347end:
2348 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmAuthCnf.peerMacAddr,
2349 (tANI_U8 *) &pMac->lim.gpLimMlmAuthReq->peerMacAddr,
2350 sizeof(tSirMacAddr));
2351
2352 mlmAuthCnf.authType = pMac->lim.gpLimMlmAuthReq->authType;
2353 mlmAuthCnf.sessionId = sessionId;
2354
2355 /// Free up buffer allocated
2356 /// for pMac->lim.gLimMlmAuthReq
2357 palFreeMemory( pMac->hHdd, pMac->lim.gpLimMlmAuthReq);
2358 pMac->lim.gpLimMlmAuthReq = NULL;
2359 limPostSmeMessage(pMac, LIM_MLM_AUTH_CNF, (tANI_U32 *) &mlmAuthCnf);
2360} /*** limProcessMlmAuthReq() ***/
2361
2362
2363
2364/**
2365 * limProcessMlmAssocReq()
2366 *
2367 *FUNCTION:
2368 * This function is called to process MLM_ASSOC_REQ message
2369 * from SME
2370 *
2371 *LOGIC:
2372 *
2373 *ASSUMPTIONS:
2374 *
2375 *NOTE:
2376 *
2377 * @param pMac Pointer to Global MAC structure
2378 * @param *pMsgBuf A pointer to the MLM message buffer
2379 * @return None
2380 */
2381
2382static void
2383limProcessMlmAssocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2384{
2385 tSirMacAddr currentBssId;
2386 tLimMlmAssocReq *pMlmAssocReq;
2387 tLimMlmAssocCnf mlmAssocCnf;
2388 tpPESession psessionEntry;
2389 // tANI_U8 sessionId;
2390
2391 if(pMsgBuf == NULL)
2392 {
2393 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
2394 return;
2395 }
2396 pMlmAssocReq = (tLimMlmAssocReq *) pMsgBuf;
2397
2398 if( (psessionEntry = peFindSessionBySessionId(pMac,pMlmAssocReq->sessionId) )== NULL)
2399 {
2400 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002401 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmAssocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 return;
2403 }
2404
2405 #if 0
2406 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2407 eSIR_SUCCESS)
2408 {
2409 /// Could not get BSSID from CFG. Log error.
2410 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
2411 }
2412 #endif //TO SUPPORT BT-AMP
2413 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2414
2415 if ( (psessionEntry->limSystemRole != eLIM_AP_ROLE && psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE) &&
2416 (psessionEntry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE || psessionEntry->limMlmState == eLIM_MLM_JOINED_STATE) &&
2417 (palEqualMemory(pMac->hHdd,pMlmAssocReq->peerMacAddr, currentBssId, sizeof(tSirMacAddr))) )
2418 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002419
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 /// map the session entry pointer to the AssocFailureTimer
2421 pMac->lim.limTimers.gLimAssocFailureTimer.sessionId = pMlmAssocReq->sessionId;
2422
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2424 psessionEntry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002425 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002426
2427 /// Prepare and send Association request frame
2428 limSendAssocReqMgmtFrame(pMac, pMlmAssocReq,psessionEntry);
2429
2430 //Set the link state to postAssoc, so HW can start receiving frames from AP.
2431 if ((psessionEntry->bssType == eSIR_BTAMP_STA_MODE)||
2432 ((psessionEntry->bssType == eSIR_BTAMP_AP_MODE) && (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)))
2433 {
2434 if(limSetLinkState(pMac, eSIR_LINK_BTAMP_POSTASSOC_STATE, currentBssId,
2435 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
2436 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState\n"));)
2437 } else {
2438 if(limSetLinkState(pMac, eSIR_LINK_POSTASSOC_STATE, currentBssId,
2439 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
2440 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState\n"));)
2441 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002442 /// Start association failure timer
2443 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
2444 if (tx_timer_activate(&pMac->lim.limTimers.gLimAssocFailureTimer)
2445 != TX_SUCCESS)
2446 {
2447 /// Could not start Assoc failure timer.
2448 // Log error
2449 limLog(pMac, LOGP,
2450 FL("could not start Association failure timer\n"));
2451 // Cleanup as if assoc timer expired
2452 limProcessAssocFailureTimeout(pMac,LIM_ASSOC );
2453
2454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002455
2456 return;
2457 }
2458 else
2459 {
2460 /**
2461 * Received Association request either in invalid state
2462 * or to a peer MAC entity whose address is different
2463 * from one that STA is currently joined with or on AP.
2464 * Return Assoc confirm with Invalid parameters code.
2465 */
2466
2467 // Log error
2468 PELOGW(limLog(pMac, LOGW,
2469 FL("received unexpected MLM_ASSOC_CNF in state %X for role=%d, MAC addr= "),
2470 psessionEntry->limMlmState,
2471 psessionEntry->limSystemRole);)
2472 limPrintMacAddr(pMac, pMlmAssocReq->peerMacAddr, LOGW);
2473 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2474
2475 mlmAssocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2476 mlmAssocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2477
2478 goto end;
2479 }
2480
2481end:
2482 /* Update PE session Id*/
2483 mlmAssocCnf.sessionId = pMlmAssocReq->sessionId;
2484
2485 /// Free up buffer allocated for assocReq
2486 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmAssocReq);
2487
2488 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
2489} /*** limProcessMlmAssocReq() ***/
2490
2491
2492
2493/**
2494 * limProcessMlmReassocReq()
2495 *
2496 *FUNCTION:
2497 * This function is called to process MLM_REASSOC_REQ message
2498 * from SME
2499 *
2500 *LOGIC:
2501 *
2502 *ASSUMPTIONS:
2503 *
2504 *NOTE:
2505 *
2506 * @param pMac Pointer to Global MAC structure
2507 * @param *pMsgBuf A pointer to the MLM message buffer
2508 * @return None
2509 */
2510
2511static void
2512limProcessMlmReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2513{
Jeff Johnsone7245742012-09-05 17:12:55 -07002514 tANI_U8 chanNum, secChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 struct tLimPreAuthNode *pAuthNode;
2516 tLimMlmReassocReq *pMlmReassocReq;
2517 tLimMlmReassocCnf mlmReassocCnf;
2518 tpPESession psessionEntry;
2519
2520 if(pMsgBuf == NULL)
2521 {
2522 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
2523 return;
2524 }
2525
2526 pMlmReassocReq = (tLimMlmReassocReq *) pMsgBuf;
2527
2528 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmReassocReq->sessionId)) == NULL)
2529 {
2530 PELOGE(limLog(pMac, LOGE,FL("Session Does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002531 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 return;
2533 }
2534
2535 if (((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) &&
2536 (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))
2537 {
2538 if (psessionEntry->pLimMlmReassocReq)
2539 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmReassocReq);
2540
2541 /* Hold Re-Assoc request as part of Session, knock-out pMac */
2542 /// Hold onto Reassoc request parameters
2543 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
2544
2545 // See if we have pre-auth context with new AP
2546 pAuthNode = limSearchPreAuthList(pMac, psessionEntry->limReAssocbssId);
2547
2548 if (!pAuthNode &&
2549 (!palEqualMemory( pMac->hHdd,pMlmReassocReq->peerMacAddr,
2550 psessionEntry->bssId,
2551 sizeof(tSirMacAddr)) ))
2552 {
2553 // Either pre-auth context does not exist AND
2554 // we are not reassociating with currently
2555 // associated AP.
2556 // Return Reassoc confirm with not authenticated
2557 mlmReassocCnf.resultCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2558 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2559
2560 goto end;
2561 }
2562
2563 //assign the sessionId to the timer object
2564 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = pMlmReassocReq->sessionId;
2565
2566 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2567 psessionEntry->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002568 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002569
2570#if 0
2571 // Update BSSID at CFG database
2572 if (wlan_cfgSetStr(pMac, WNI_CFG_BSSID,
2573 pMac->lim.gLimReassocBssId,
2574 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
2575 {
2576 /// Could not update BSSID at CFG. Log error.
2577 limLog(pMac, LOGP, FL("could not update BSSID at CFG\n"));
2578 }
2579#endif //TO SUPPORT BT-AMP
2580
2581 /* Copy Global Reassoc ID*/
2582 // sirCopyMacAddr(psessionEntry->reassocbssId,pMac->lim.gLimReAssocBssId);
2583
2584 /**
2585 * Derive channel from BSS description and
2586 * store it at CFG.
2587 */
2588
2589 chanNum = psessionEntry->limReassocChannelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07002590 secChannelOffset = psessionEntry->reAssocHtSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002591
2592 /* To Support BT-AMP .. read channel number from psessionEntry*/
2593 //chanNum = psessionEntry->currentOperChannel;
2594
2595 // Apply previously set configuration at HW
2596 limApplyConfiguration(pMac,psessionEntry);
2597
2598 //store the channel switch sessionEntry in the lim global var
2599 /* We have already saved the ReAssocreq Pointer abobe */
2600 //psessionEntry->pLimReAssocReq = (void *)pMlmReassocReq;
2601 psessionEntry->channelChangeReasonCode = LIM_SWITCH_CHANNEL_REASSOC;
2602
Jeff Johnsone7245742012-09-05 17:12:55 -07002603 /** Switch channel to the new Operating channel for Reassoc*/
2604 limSetChannel(pMac, chanNum, secChannelOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002605
2606 return;
2607 }
2608 else
2609 {
2610 /**
2611 * Received Reassoc request in invalid state or
2612 * in AP role.Return Reassoc confirm with Invalid
2613 * parameters code.
2614 */
2615
2616 // Log error
2617 PELOGW(limLog(pMac, LOGW,
2618 FL("received unexpected MLM_REASSOC_CNF in state %X for role=%d, MAC addr= "),
2619 psessionEntry->limMlmState,
2620 psessionEntry->limSystemRole);)
2621 limPrintMacAddr(pMac, pMlmReassocReq->peerMacAddr,
2622 LOGW);
2623 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
2624
2625 mlmReassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2626 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2627
2628 goto end;
2629 }
2630
2631end:
2632 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2633 /* Update PE sessio Id*/
2634 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
2635 /// Free up buffer allocated for reassocReq
2636 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
2637 psessionEntry->pLimReAssocReq = NULL;
2638
2639 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2640} /*** limProcessMlmReassocReq() ***/
2641
2642
2643static void
2644limProcessMlmDisassocReqPostSuspend(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
2645{
2646 tANI_U16 aid;
2647 tSirMacAddr currentBssId;
2648 tpDphHashNode pStaDs;
2649 tLimMlmDisassocReq *pMlmDisassocReq;
2650 tLimMlmDisassocCnf mlmDisassocCnf;
2651 tpPESession psessionEntry;
2652 extern tANI_BOOLEAN sendDisassocFrame;
2653
2654 if(eHAL_STATUS_SUCCESS != suspendStatus)
2655 {
2656 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X\n"), suspendStatus);)
2657#if 0
2658 //It can ignore the status and proceed with the disassoc processing.
2659 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
2660 goto end;
2661#endif
2662 }
2663
2664 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
2665
2666
2667 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocReq->sessionId))== NULL)
2668 {
2669
2670 PELOGE(limLog(pMac, LOGE,
2671 FL("session does not exist for given sessionId\n"));)
2672 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2673 goto end;
2674 }
2675 #if 0
2676 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2677 eSIR_SUCCESS)
2678 {
2679 /// Could not get BSSID from CFG. Log error.
2680 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
2681 }
2682 #endif //BT-AMP Support
2683 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2684
2685 switch (psessionEntry->limSystemRole)
2686 {
2687 case eLIM_STA_ROLE:
2688 case eLIM_BT_AMP_STA_ROLE:
2689 if ( !palEqualMemory( pMac->hHdd,pMlmDisassocReq->peerMacAddr,
2690 currentBssId,
2691 sizeof(tSirMacAddr)) )
2692 {
2693 PELOGW(limLog(pMac, LOGW,
2694 FL("received MLM_DISASSOC_REQ with invalid BSS id "));)
2695 limPrintMacAddr(pMac, pMlmDisassocReq->peerMacAddr, LOGW);
2696
2697 /// Prepare and Send LIM_MLM_DISASSOC_CNF
2698
2699 mlmDisassocCnf.resultCode =
2700 eSIR_SME_INVALID_PARAMETERS;
2701
2702 goto end;
2703 }
2704
2705 break;
2706
2707 case eLIM_STA_IN_IBSS_ROLE:
2708
2709 break;
2710
2711 default: // eLIM_AP_ROLE
2712
2713 // Fall through
2714 break;
2715
2716 } // end switch (psessionEntry->limSystemRole)
2717
2718 /**
2719 * Check if there exists a context for the peer entity
2720 * to be disassociated with.
2721 */
2722 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2723 if ((pStaDs == NULL) ||
2724 (pStaDs &&
2725 ((pStaDs->mlmStaContext.mlmState !=
2726 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2727 (pStaDs->mlmStaContext.mlmState !=
2728 eLIM_MLM_WT_ASSOC_CNF_STATE) &&
2729 (pStaDs->mlmStaContext.mlmState !=
2730 eLIM_MLM_ASSOCIATED_STATE))))
2731 {
2732 /**
2733 * Received LIM_MLM_DISASSOC_REQ for STA that does not
2734 * have context or in some transit state.
2735 * Log error
2736 */
2737 PELOGW(limLog(pMac, LOGW,
2738 FL("received MLM_DISASSOC_REQ for STA that either has no context or in some transit state, Addr= "));)
2739 limPrintMacAddr(pMac, pMlmDisassocReq->peerMacAddr, LOGW);
2740
2741 /// Prepare and Send LIM_MLM_DISASSOC_CNF
2742
2743 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2744
2745 goto end;
2746 }
2747
2748 //pStaDs->mlmStaContext.rxPurgeReq = 1;
2749 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
2750 pMlmDisassocReq->reasonCode;
2751 pStaDs->mlmStaContext.cleanupTrigger = pMlmDisassocReq->disassocTrigger;
2752
2753 /// Send Disassociate frame to peer entity
Jeff Johnsone7245742012-09-05 17:12:55 -07002754 if (sendDisassocFrame && (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 {
2756 limSendDisassocMgmtFrame(pMac,
2757 pMlmDisassocReq->reasonCode,
2758 pMlmDisassocReq->peerMacAddr,psessionEntry);
2759 }
2760 else
2761 {
2762 sendDisassocFrame = 1;
2763 }
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 /// Receive path cleanup with dummy packet
2766 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs,psessionEntry))
2767 {
2768 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2769 goto end;
2770 }
2771
2772#ifdef WLAN_FEATURE_VOWIFI_11R
2773 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
2774 (
2775#ifdef FEATURE_WLAN_CCX
2776 (psessionEntry->isCCXconnection ) ||
2777#endif
Madan Mohan Koyyalamudi3cf164e2012-10-24 14:43:17 -07002778#ifdef FEATURE_WLAN_LFR
2779 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
2780#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 (psessionEntry->is11Rconnection )) &&
2782 (pMlmDisassocReq->reasonCode != eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
2783 {
2784 PELOGE(limLog(pMac, LOGE, FL("FT Preauth Session Cleanup \n"));)
2785 limFTCleanup(pMac);
2786 }
Madan Mohan Koyyalamudi3cf164e2012-10-24 14:43:17 -07002787 else
2788 {
2789 PELOGE(limLog(pMac, LOGE, FL("No FT Preauth Session Cleanup in role %d"
2790#ifdef FEATURE_WLAN_CCX
2791 " isCCX %d"
2792#endif
2793#ifdef FEATURE_WLAN_LFR
2794 " isLFR %d"
2795#endif
2796 " is11r %d reason %d\n"),
2797 psessionEntry->limSystemRole,
2798#ifdef FEATURE_WLAN_CCX
2799 psessionEntry->isCCXconnection,
2800#endif
2801#ifdef FEATURE_WLAN_LFR
2802 psessionEntry->isFastRoamIniFeatureEnabled,
2803#endif
2804 psessionEntry->is11Rconnection,
2805 pMlmDisassocReq->reasonCode);)
2806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002807#endif
2808
2809 /// Free up buffer allocated for mlmDisassocReq
2810 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
2811
2812 return;
2813
2814end:
2815 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
2816 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
2817 sizeof(tSirMacAddr));
2818 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
2819 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
2820
2821 /* Update PE session ID*/
2822 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
2823
2824 /// Free up buffer allocated for mlmDisassocReq
2825 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDisassocReq);
2826
2827 limPostSmeMessage(pMac,
2828 LIM_MLM_DISASSOC_CNF,
2829 (tANI_U32 *) &mlmDisassocCnf);
2830}
2831
2832/**
2833 * limProcessMlmDisassocReq()
2834 *
2835 *FUNCTION:
2836 * This function is called to process MLM_DISASSOC_REQ message
2837 * from SME
2838 *
2839 *LOGIC:
2840 *
2841 *ASSUMPTIONS:
2842 *
2843 *NOTE:
2844 *
2845 * @param pMac Pointer to Global MAC structure
2846 * @param *pMsgBuf A pointer to the MLM message buffer
2847 * @return None
2848 */
2849
2850static void
2851limProcessMlmDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2852{
2853// tANI_U16 aid;
2854// tSirMacAddr currentBssId;
2855// tpDphHashNode pStaDs;
2856 tLimMlmDisassocReq *pMlmDisassocReq;
2857// tLimMlmDisassocCnf mlmDisassocCnf;
2858 tpPESession psessionEntry;
2859// extern tANI_BOOLEAN sendDisassocFrame;
2860
2861 if(pMsgBuf == NULL)
2862 {
2863 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
2864 return;
2865 }
2866
2867 pMlmDisassocReq = (tLimMlmDisassocReq *) pMsgBuf;
2868
2869 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDisassocReq->sessionId))== NULL)
2870 {
2871
2872 PELOGE(limLog(pMac, LOGE,
2873 FL("session does not exist for given sessionId\n"));)
2874 return;
2875 }
2876
Jeff Johnsone7245742012-09-05 17:12:55 -07002877 if( (psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
2878 isLimSessionOffChannel(pMac, pMlmDisassocReq->sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 {
2880 //suspend link
2881 limSuspendLink(pMac, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
2882 limProcessMlmDisassocReqPostSuspend, (tANI_U32*)pMsgBuf );
2883 }
2884 else
2885 {
2886 //No need to suspend link.
2887 limProcessMlmDisassocReqPostSuspend( pMac, eHAL_STATUS_SUCCESS,
2888 (tANI_U32*) pMsgBuf );
2889 }
2890} /*** limProcessMlmDisassocReq() ***/
2891
2892static void
2893limProcessMlmDeauthReqPostSuspend(tpAniSirGlobal pMac, eHalStatus suspendStatus, tANI_U32 *pMsgBuf)
2894{
2895 tANI_U16 aid;
2896 tSirMacAddr currentBssId;
2897 tpDphHashNode pStaDs;
2898 struct tLimPreAuthNode *pAuthNode;
2899 tLimMlmDeauthReq *pMlmDeauthReq;
2900 tLimMlmDeauthCnf mlmDeauthCnf;
2901 tpPESession psessionEntry;
2902
2903
2904 if(eHAL_STATUS_SUCCESS != suspendStatus)
2905 {
2906 PELOGE(limLog(pMac, LOGE,FL("Suspend Status is not success %X\n"), suspendStatus);)
2907#if 0
2908 //It can ignore the status and proceed with the disassoc processing.
2909 mlmDisassocCnf.resultCode = eSIR_SME_REFUSED;
2910 goto end;
2911#endif
2912 }
2913
2914 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
2915
2916 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
2917 {
2918
2919 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002920 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 return;
2922 }
2923 #if 0
2924 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
2925 eSIR_SUCCESS)
2926 {
2927 /// Could not get BSSID from CFG. Log error.
2928 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
2929 }
2930 #endif //SUPPORT BT-AMP
2931 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
2932
2933 switch (psessionEntry->limSystemRole)
2934 {
2935 case eLIM_STA_ROLE:
2936 case eLIM_BT_AMP_STA_ROLE:
2937 switch (psessionEntry->limMlmState)
2938 {
2939 case eLIM_MLM_IDLE_STATE:
2940 // Attempting to Deauthenticate
2941 // with a pre-authenticated peer.
2942 // Deauthetiate with peer if there
2943 // exists a pre-auth context below.
2944 break;
2945
2946 case eLIM_MLM_AUTHENTICATED_STATE:
2947 case eLIM_MLM_WT_ASSOC_RSP_STATE:
2948 case eLIM_MLM_LINK_ESTABLISHED_STATE:
2949 if (!palEqualMemory( pMac->hHdd,pMlmDeauthReq->peerMacAddr,
2950 currentBssId,
2951 sizeof(tSirMacAddr)) )
2952 {
2953 PELOGW(limLog(pMac, LOGW,
2954 FL("received MLM_DEAUTH_REQ with invalid BSS id "));)
2955 PELOGE(limLog(pMac, LOGE, FL("Peer MAC Addr : "));)
2956 limPrintMacAddr(pMac, pMlmDeauthReq->peerMacAddr,LOGE);
2957
2958 PELOGE(limLog(pMac, LOGE, FL("\n CFG BSSID Addr : "));)
2959 limPrintMacAddr(pMac, currentBssId,LOGE);
2960
2961 /// Prepare and Send LIM_MLM_DEAUTH_CNF
2962
2963 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2964
2965 goto end;
2966 }
2967
2968 if ((psessionEntry->limMlmState ==
2969 eLIM_MLM_AUTHENTICATED_STATE) ||
2970 (psessionEntry->limMlmState ==
2971 eLIM_MLM_WT_ASSOC_RSP_STATE))
2972 {
2973 // Send Deauthentication frame
2974 // to peer entity
2975 limSendDeauthMgmtFrame(
2976 pMac,
2977 pMlmDeauthReq->reasonCode,
2978 pMlmDeauthReq->peerMacAddr,psessionEntry);
2979
2980 /// Prepare and Send LIM_MLM_DEAUTH_CNF
2981 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
2982 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002983 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 goto end;
2985 }
2986 else
2987 {
2988 // LINK_ESTABLISED_STATE
2989 // Cleanup RX & TX paths
2990 // below
2991 }
2992
2993 break;
2994
2995 default:
2996
2997 PELOGW(limLog(pMac, LOGW,
2998 FL("received MLM_DEAUTH_REQ with in state %d for peer "),
2999 psessionEntry->limMlmState);)
3000 limPrintMacAddr(pMac, pMlmDeauthReq->peerMacAddr, LOGW);
3001 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3002
3003 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3004 mlmDeauthCnf.resultCode =
3005 eSIR_SME_STA_NOT_AUTHENTICATED;
3006
3007 goto end;
3008 }
3009
3010 break;
3011
3012 case eLIM_STA_IN_IBSS_ROLE:
Jeff Johnsone7245742012-09-05 17:12:55 -07003013 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003014
3015 return;
3016
3017 default: // eLIM_AP_ROLE
3018 break;
3019
3020 } // end switch (psessionEntry->limSystemRole)
3021
3022 /**
3023 * Check if there exists a context for the peer entity
3024 * to be deauthenticated with.
3025 */
3026 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3027
3028 if (pStaDs == NULL)
3029 {
3030 /// Check if there exists pre-auth context for this STA
3031 pAuthNode = limSearchPreAuthList(pMac,
3032 pMlmDeauthReq->peerMacAddr);
3033
3034 if (pAuthNode == NULL)
3035 {
3036 /**
3037 * Received DEAUTH REQ for a STA that is neither
3038 * Associated nor Pre-authenticated. Log error,
3039 * Prepare and Send LIM_MLM_DEAUTH_CNF
3040 */
3041 PELOGW(limLog(pMac, LOGW,
3042 FL("received MLM_DEAUTH_REQ for STA that does not have context, Addr="));)
3043 limPrintMacAddr(pMac, pMlmDeauthReq->peerMacAddr, LOGW);
3044
3045 mlmDeauthCnf.resultCode =
3046 eSIR_SME_STA_NOT_AUTHENTICATED;
3047 }
3048 else
3049 {
3050 mlmDeauthCnf.resultCode = eSIR_SME_SUCCESS;
3051
3052 /// Delete STA from pre-auth STA list
3053 limDeletePreAuthNode(pMac, pMlmDeauthReq->peerMacAddr);
3054
3055 /// Send Deauthentication frame to peer entity
3056 limSendDeauthMgmtFrame(pMac,
3057 pMlmDeauthReq->reasonCode,
3058 pMlmDeauthReq->peerMacAddr,psessionEntry);
3059 }
3060
3061 goto end;
3062 }
3063 else if ((pStaDs->mlmStaContext.mlmState !=
3064 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
3065 (pStaDs->mlmStaContext.mlmState !=
3066 eLIM_MLM_WT_ASSOC_CNF_STATE))
3067 {
3068 /**
3069 * Received LIM_MLM_DEAUTH_REQ for STA that is n
3070 * some transit state. Log error.
3071 */
3072 PELOGW(limLog(pMac, LOGW,
3073 FL("received MLM_DEAUTH_REQ for STA that either has no context or in some transit state, Addr="));)
3074 limPrintMacAddr(pMac, pMlmDeauthReq->peerMacAddr, LOGW);
3075
3076 /// Prepare and Send LIM_MLM_DEAUTH_CNF
3077
3078 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3079
3080 goto end;
3081 }
3082
3083 //pStaDs->mlmStaContext.rxPurgeReq = 1;
3084 pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)
3085 pMlmDeauthReq->reasonCode;
3086 pStaDs->mlmStaContext.cleanupTrigger = pMlmDeauthReq->deauthTrigger;
3087
3088 /// Send Deauthentication frame to peer entity
3089 limSendDeauthMgmtFrame(pMac, pMlmDeauthReq->reasonCode,
3090 pMlmDeauthReq->peerMacAddr,psessionEntry);
3091
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 /// Receive path cleanup with dummy packet
3093 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3094
3095 /// Free up buffer allocated for mlmDeauthReq
3096 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3097
3098 return;
3099
3100end:
3101 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
3102 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3103 sizeof(tSirMacAddr));
3104 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3105 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3106 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3107
3108 // Free up buffer allocated
3109 // for mlmDeauthReq
3110 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmDeauthReq);
3111
3112 limPostSmeMessage(pMac,
3113 LIM_MLM_DEAUTH_CNF,
3114 (tANI_U32 *) &mlmDeauthCnf);
3115
3116}
3117
3118/**
3119 * limProcessMlmDeauthReq()
3120 *
3121 *FUNCTION:
3122 * This function is called to process MLM_DEAUTH_REQ message
3123 * from SME
3124 *
3125 *LOGIC:
3126 *
3127 *ASSUMPTIONS:
3128 *
3129 *NOTE:
3130 *
3131 * @param pMac Pointer to Global MAC structure
3132 * @param *pMsgBuf A pointer to the MLM message buffer
3133 * @return None
3134 */
3135
3136static void
3137limProcessMlmDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3138{
3139// tANI_U16 aid;
3140// tSirMacAddr currentBssId;
3141// tpDphHashNode pStaDs;
3142// struct tLimPreAuthNode *pAuthNode;
3143 tLimMlmDeauthReq *pMlmDeauthReq;
3144// tLimMlmDeauthCnf mlmDeauthCnf;
3145 tpPESession psessionEntry;
3146
3147 if(pMsgBuf == NULL)
3148 {
3149 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
3150 return;
3151 }
3152
3153 pMlmDeauthReq = (tLimMlmDeauthReq *) pMsgBuf;
3154
3155 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDeauthReq->sessionId))== NULL)
3156 {
3157
3158 PELOGE(limLog(pMac, LOGE, FL("session does not exist for given sessionId\n"));)
3159 return;
3160 }
3161
Jeff Johnsone7245742012-09-05 17:12:55 -07003162 if( (psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
3163 isLimSessionOffChannel(pMac, pMlmDeauthReq->sessionId) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 {
3165 //suspend link
3166 limSuspendLink(pMac, eSIR_DONT_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
3167 limProcessMlmDeauthReqPostSuspend, (tANI_U32*)pMsgBuf );
3168 }
3169 else
3170 {
3171 //No need to suspend link.
3172 limProcessMlmDeauthReqPostSuspend( pMac, eHAL_STATUS_SUCCESS,
3173 (tANI_U32*) pMsgBuf );
3174 }
3175} /*** limProcessMlmDeauthReq() ***/
3176
3177
3178
3179/**
3180 * @function : limProcessMlmSetKeysReq()
3181 *
3182 * @brief : This function is called to process MLM_SETKEYS_REQ message
3183 * from SME
3184 *
3185 *LOGIC:
3186 *
3187 *ASSUMPTIONS:
3188 *
3189 *NOTE:
3190 *
3191 * @param pMac Pointer to Global MAC structure
3192 * @param *pMsgBuf A pointer to the MLM message buffer
3193 * @return None
3194 */
3195
3196static void
3197limProcessMlmSetKeysReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3198{
3199tANI_U16 aid;
3200tANI_U16 staIdx = 0;
3201tANI_U32 defaultKeyId = 0;
3202tSirMacAddr currentBssId;
3203tpDphHashNode pStaDs;
3204tLimMlmSetKeysReq *pMlmSetKeysReq;
3205tLimMlmSetKeysCnf mlmSetKeysCnf;
3206tpPESession psessionEntry;
3207
3208 if(pMsgBuf == NULL)
3209 {
3210 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
3211 return;
3212 }
3213
3214
3215 pMlmSetKeysReq = (tLimMlmSetKeysReq *) pMsgBuf;
3216 // Hold onto the SetKeys request parameters
3217 pMac->lim.gpLimMlmSetKeysReq = (void *) pMlmSetKeysReq;
3218
3219 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmSetKeysReq->sessionId))== NULL)
3220 {
3221 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given sessionId\n"));)
3222 return;
3223 }
3224
3225 limLog( pMac, LOGW,
3226 FL( "Received MLM_SETKEYS_REQ with parameters:\n"
3227 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - "),
3228 pMlmSetKeysReq->aid,
3229 pMlmSetKeysReq->edType,
3230 pMlmSetKeysReq->numKeys );
3231 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3232
3233 #if 0
3234 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID, currentBssId, &cfg )) {
3235 limLog( pMac, LOGP, FL("Could not retrieve BSSID\n"));
3236 return;
3237 }
3238 #endif //TO SUPPORT BT-AMP
3239 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3240
3241 switch( psessionEntry->limSystemRole ) {
3242 case eLIM_STA_ROLE:
3243 case eLIM_BT_AMP_STA_ROLE:
3244 if((!limIsAddrBC( pMlmSetKeysReq->peerMacAddr ) ) &&
3245 (!palEqualMemory( pMac->hHdd,pMlmSetKeysReq->peerMacAddr,
3246 currentBssId, sizeof(tSirMacAddr))) ){
3247 limLog( pMac, LOGW, FL("Received MLM_SETKEYS_REQ with invalid BSSID\n"));
3248 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3249
3250 // Prepare and Send LIM_MLM_SETKEYS_CNF with error code
3251 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3252 goto end;
3253 }
3254 // Fall thru' & 'Plumb' keys below
3255 break;
3256 case eLIM_STA_IN_IBSS_ROLE:
3257 default: // others
3258 // Fall thru...
3259 break;
3260 }
3261
3262 /**
3263 * Use the "unicast" parameter to determine if the "Group Keys"
3264 * are being set.
3265 * pMlmSetKeysReq->key.unicast = 0 -> Multicast/broadcast
3266 * pMlmSetKeysReq->key.unicast - 1 -> Unicast keys are being set
3267 */
3268 if( limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
3269 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d \n"), pMlmSetKeysReq->sessionId);
3270 /** When trying to set Group Keys for any
3271 * security mode other than WEP, use the
3272 * STA Index corresponding to the AP...
3273 */
3274 switch( pMlmSetKeysReq->edType ) {
3275 case eSIR_ED_CCMP:
3276
3277#ifdef WLAN_FEATURE_11W
3278 case eSIR_ED_AES_128_CMAC:
3279#endif
3280 staIdx = psessionEntry->staId;
3281 break;
3282
3283 default:
3284 break;
3285 }
3286 }else {
3287 limLog( pMac, LOG1, FL("Trying to set Unicast Keys...\n"));
3288 /**
3289 * Check if there exists a context for the
3290 * peer entity for which keys need to be set.
3291 */
3292
3293
3294 pStaDs = dphLookupHashEntry( pMac, pMlmSetKeysReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
3295
3296#ifdef WLAN_SOFTAP_FEATURE
3297 if ((pStaDs == NULL) ||
3298 ((pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) && (psessionEntry->limSystemRole != eLIM_AP_ROLE))) {
3299#else
3300 if ((pStaDs == NULL) ||
3301 ((pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) )) {
3302#endif
3303 /**
3304 * Received LIM_MLM_SETKEYS_REQ for STA
3305 * that does not have context or in some
3306 * transit state. Log error.
3307 */
3308 limLog( pMac, LOG1,
3309 FL("Received MLM_SETKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3310 limPrintMacAddr( pMac, pMlmSetKeysReq->peerMacAddr, LOGW );
3311
3312 // Prepare and Send LIM_MLM_SETKEYS_CNF
3313 mlmSetKeysCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3314 goto end;
3315 } else
3316 staIdx = pStaDs->staIndex;
3317 }
3318
3319 if ((pMlmSetKeysReq->numKeys == 0) && (pMlmSetKeysReq->edType != eSIR_ED_NONE)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003320 //
3321 // Broadcast/Multicast Keys (for WEP!!) are NOT sent
3322 // via this interface!!
3323 //
3324 // This indicates to HAL that the WEP Keys need to be
3325 // extracted from the CFG and applied to hardware
3326 defaultKeyId = 0xff;
3327 }else if(pMlmSetKeysReq->key[0].keyId &&
3328 ((pMlmSetKeysReq->edType == eSIR_ED_WEP40) ||
3329 (pMlmSetKeysReq->edType == eSIR_ED_WEP104))){
3330 /* If the Key Id is non zero and encryption mode is WEP,
3331 * the key index is coming from the upper layers so that key only
3332 * need to be used as the default tx key, This is being used only
3333 * in case of WEP mode in HAL */
3334 defaultKeyId = pMlmSetKeysReq->key[0].keyId;
3335 }else
3336 defaultKeyId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003337
3338 limLog( pMac, LOG1,
3339 FL( "Trying to set keys for STA Index [%d], using defaultKeyId [%d]\n" ),
3340 staIdx,
3341 defaultKeyId );
3342
3343 if(limIsAddrBC( pMlmSetKeysReq->peerMacAddr )) {
3344 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3345 psessionEntry->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003346 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 limLog( pMac, LOG1, FL("Trying to set Group Keys...%d \n"),
3348 psessionEntry->peSessionId);
3349
3350 // Package WDA_SET_BSSKEY_REQ message parameters
3351 limSendSetBssKeyReq(pMac, pMlmSetKeysReq,psessionEntry);
3352 return;
3353 }else {
3354 // Package WDA_SET_STAKEY_REQ / WDA_SET_STA_BCASTKEY_REQ message parameters
3355 limSendSetStaKeyReq(pMac, pMlmSetKeysReq, staIdx, (tANI_U8) defaultKeyId,psessionEntry);
3356 return;
3357 }
3358
3359end:
3360 mlmSetKeysCnf.sessionId= pMlmSetKeysReq->sessionId;
3361 limPostSmeSetKeysCnf( pMac, pMlmSetKeysReq, &mlmSetKeysCnf );
3362
3363} /*** limProcessMlmSetKeysReq() ***/
3364
3365/**
3366 * limProcessMlmRemoveKeyReq()
3367 *
3368 *FUNCTION:
3369 * This function is called to process MLM_REMOVEKEY_REQ message
3370 * from SME
3371 *
3372 *LOGIC:
3373 *
3374 *ASSUMPTIONS:
3375 *
3376 *NOTE:
3377 *
3378 * @param pMac Pointer to Global MAC structure
3379 * @param *pMsgBuf A pointer to the MLM message buffer
3380 * @return None
3381 */
3382
3383static void
3384limProcessMlmRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3385{
3386tANI_U16 aid;
3387tANI_U16 staIdx = 0;
3388tSirMacAddr currentBssId;
3389tpDphHashNode pStaDs;
3390tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3391tLimMlmRemoveKeyCnf mlmRemoveKeyCnf;
3392 tpPESession psessionEntry;
3393
3394 if(pMsgBuf == NULL)
3395 {
3396 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
3397 return;
3398 }
3399
3400 pMlmRemoveKeyReq = (tLimMlmRemoveKeyReq *) pMsgBuf;
3401
3402
3403 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmRemoveKeyReq->sessionId))== NULL)
3404 {
3405 PELOGE(limLog(pMac, LOGE,
3406 FL("session does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003407 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 return;
3409 }
3410
3411
3412 if( pMac->lim.gpLimMlmRemoveKeyReq != NULL )
3413 {
3414 // Free any previous requests.
3415 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimMlmRemoveKeyReq);
3416 pMac->lim.gpLimMlmRemoveKeyReq = NULL;
3417 }
3418 // Hold onto the RemoveKeys request parameters
3419 pMac->lim.gpLimMlmRemoveKeyReq = (void *) pMlmRemoveKeyReq;
3420
3421 #if 0
3422 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
3423 WNI_CFG_BSSID,
3424 currentBssId,
3425 &cfg ))
3426 limLog( pMac, LOGP, FL("Could not retrieve BSSID\n"));
3427 #endif //TO-SUPPORT BT-AMP
3428 sirCopyMacAddr(currentBssId,psessionEntry->bssId);
3429
3430 switch( psessionEntry->limSystemRole )
3431 {
3432 case eLIM_STA_ROLE:
3433 case eLIM_BT_AMP_STA_ROLE:
3434 if(( limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr ) != true ) &&
3435 (!palEqualMemory( pMac->hHdd,pMlmRemoveKeyReq->peerMacAddr,
3436 currentBssId,
3437 sizeof(tSirMacAddr))))
3438 {
3439 limLog( pMac, LOGW,
3440 FL("Received MLM_REMOVEKEY_REQ with invalid BSSID\n"));
3441 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
3442
3443 // Prepare and Send LIM_MLM_REMOVEKEY_CNF with error code
3444 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3445 goto end;
3446 }
3447 break;
3448
3449 case eLIM_STA_IN_IBSS_ROLE:
3450 default: // eLIM_AP_ROLE
3451 // Fall thru...
3452 break;
3453 }
3454
3455
3456 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
3457 if(limIsAddrBC( pMlmRemoveKeyReq->peerMacAddr )) //Second condition for IBSS or AP role.
3458 {
3459 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_BSS_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003460 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 // Package WDA_REMOVE_BSSKEY_REQ message parameters
3462 limSendRemoveBssKeyReq( pMac,pMlmRemoveKeyReq,psessionEntry);
3463 return;
3464 }
3465
3466 /**
3467 * Check if there exists a context for the
3468 * peer entity for which keys need to be removed.
3469 */
3470 pStaDs = dphLookupHashEntry( pMac, pMlmRemoveKeyReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable );
3471 if ((pStaDs == NULL) ||
3472 (pStaDs &&
3473 (pStaDs->mlmStaContext.mlmState !=
3474 eLIM_MLM_LINK_ESTABLISHED_STATE)))
3475 {
3476 /**
3477 * Received LIM_MLM_REMOVEKEY_REQ for STA
3478 * that does not have context or in some
3479 * transit state. Log error.
3480 */
3481 limLog( pMac, LOGW,
3482 FL("Received MLM_REMOVEKEYS_REQ for STA that either has no context or in some transit state, Addr = "));
3483 limPrintMacAddr( pMac, pMlmRemoveKeyReq->peerMacAddr, LOGW );
3484
3485 // Prepare and Send LIM_MLM_REMOVEKEY_CNF
3486 mlmRemoveKeyCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3487 mlmRemoveKeyCnf.sessionId = pMlmRemoveKeyReq->sessionId;
3488
3489
3490 goto end;
3491 }
3492 else
3493 staIdx = pStaDs->staIndex;
3494
3495
3496
3497 psessionEntry->limMlmState = eLIM_MLM_WT_REMOVE_STA_KEY_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003498 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003499
3500 // Package WDA_REMOVE_STAKEY_REQ message parameters
3501 limSendRemoveStaKeyReq( pMac,pMlmRemoveKeyReq,staIdx,psessionEntry);
3502 return;
3503
3504end:
3505 limPostSmeRemoveKeyCnf( pMac,
Jeff Johnsone7245742012-09-05 17:12:55 -07003506 psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 pMlmRemoveKeyReq,
3508 &mlmRemoveKeyCnf );
3509
3510} /*** limProcessMlmRemoveKeyReq() ***/
3511
3512
3513/**
3514 * limProcessMinChannelTimeout()
3515 *
3516 *FUNCTION:
3517 * This function is called to process Min Channel Timeout
3518 * during channel scan.
3519 *
3520 *LOGIC:
3521 *
3522 *ASSUMPTIONS:
3523 *
3524 *NOTE:
3525 *
3526 * @param pMac Pointer to Global MAC structure
3527 * @return None
3528 */
3529
3530static void
3531limProcessMinChannelTimeout(tpAniSirGlobal pMac)
3532{
3533 tANI_U8 channelNum;
3534
3535#ifdef GEN6_TODO
3536 //if the min Channel is maintained per session, then use the below seesionEntry
3537 //priority - LOW/might not be needed
3538
3539 //TBD-RAJESH HOW TO GET sessionEntry?????
3540 tpPESession psessionEntry;
3541
3542 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimMinChannelTimer.sessionId))== NULL)
3543 {
3544 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3545 return;
3546 }
3547#endif
3548
3549
3550 if (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE)
3551 {
3552 PELOG1(limLog(pMac, LOG1, FL("Scanning : min channel timeout occurred\n"));)
3553
3554 /// Min channel timer timed out
3555 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
3556 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
3557 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
3558 if (pMac->lim.gLimCurrentScanChannelId <=
3559 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
3560 {
3561 channelNum = (tANI_U8)limGetCurrentScanChannel(pMac);
3562 }
3563 else
3564 {
3565 // This shouldn't be the case, but when this happens, this timeout should be for the last channelId.
3566 // Get the channelNum as close to correct as possible.
3567 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
3568 {
3569 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
3570 }
3571 else
3572 {
3573 channelNum = 1;
3574 }
3575 }
3576
3577 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
3578 }
3579 else
3580 {
3581 /**
3582 * MIN channel timer should not have timed out
3583 * in states other than wait_probe_response.
3584 * Log error.
3585 */
3586 limLog(pMac, LOGW,
3587 FL("received unexpected MIN channel timeout in state %X\n"),
3588 pMac->lim.gLimMlmState);
3589 limPrintMlmState(pMac, LOGE, pMac->lim.gLimMlmState);
3590 }
3591} /*** limProcessMinChannelTimeout() ***/
3592
3593
3594
3595/**
3596 * limProcessMaxChannelTimeout()
3597 *
3598 *FUNCTION:
3599 * This function is called to process Max Channel Timeout
3600 * during channel scan.
3601 *
3602 *LOGIC:
3603 *
3604 *ASSUMPTIONS:
3605 *
3606 *NOTE:
3607 *
3608 * @param pMac Pointer to Global MAC structure
3609 * @return None
3610 */
3611
3612static void
3613limProcessMaxChannelTimeout(tpAniSirGlobal pMac)
3614{
3615 tANI_U8 channelNum;
3616
3617
3618 if (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE ||
3619 pMac->lim.gLimMlmState == eLIM_MLM_PASSIVE_SCAN_STATE)
3620 {
3621 PELOG1(limLog(pMac, LOG1, FL("Scanning : Max channel timed out\n"));)
3622 /**
3623 * MAX channel timer timed out
3624 * Continue channel scan.
3625 */
3626 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
3627 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_PROBE_REQ_TIMER);
3628 pMac->lim.limTimers.gLimPeriodicProbeReqTimer.sessionId = 0xff;
3629 if (pMac->lim.gLimCurrentScanChannelId <=
3630 (tANI_U32)(pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1))
3631 {
3632 channelNum = limGetCurrentScanChannel(pMac);
3633 }
3634 else
3635 {
3636 if(pMac->lim.gpLimMlmScanReq->channelList.channelNumber)
3637 {
3638 channelNum = pMac->lim.gpLimMlmScanReq->channelList.channelNumber[pMac->lim.gpLimMlmScanReq->channelList.numChannels - 1];
3639 }
3640 else
3641 {
3642 channelNum = 1;
3643 }
3644 }
3645 limSendHalEndScanReq(pMac, channelNum, eLIM_HAL_END_SCAN_WAIT_STATE);
3646 }
3647 else
3648 {
3649 /**
3650 * MAX channel timer should not have timed out
3651 * in states other than wait_scan.
3652 * Log error.
3653 */
3654 limLog(pMac, LOGW,
3655 FL("received unexpected MAX channel timeout in state %X\n"),
3656 pMac->lim.gLimMlmState);
3657 limPrintMlmState(pMac, LOGW, pMac->lim.gLimMlmState);
3658 }
3659} /*** limProcessMaxChannelTimeout() ***/
3660
3661/**
3662 * limProcessPeriodicProbeReqTimer()
3663 *
3664 *FUNCTION:
3665 * This function is called to process periodic probe request
3666 * to send during scan.
3667 *
3668 *LOGIC:
3669 *
3670 *ASSUMPTIONS:
3671 *
3672 *NOTE:
3673 *
3674 * @param pMac Pointer to Global MAC structure
3675 * @return None
3676 */
3677
3678static void
3679limProcessPeriodicProbeReqTimer(tpAniSirGlobal pMac)
3680{
3681 tANI_U8 channelNum;
3682 tANI_U8 i = 0;
3683 tSirRetStatus status = eSIR_SUCCESS;
3684 TX_TIMER *pPeriodicProbeReqTimer;
3685 pPeriodicProbeReqTimer = &pMac->lim.limTimers.gLimPeriodicProbeReqTimer;
3686
3687 if(vos_timer_getCurrentState(&pPeriodicProbeReqTimer->vosTimer)
3688 != VOS_TIMER_STATE_STOPPED)
3689 {
3690 PELOG1(limLog(pMac, LOG1, FL("Invalid state of timer\n"));)
3691 return;
3692 }
3693
3694 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) &&
3695 (pPeriodicProbeReqTimer->sessionId != 0xff))
3696 {
3697 tLimMlmScanReq *pLimMlmScanReq = pMac->lim.gpLimMlmScanReq;
3698 PELOG1(limLog(pMac, LOG1, FL("Scanning : Periodic scanning\n"));)
3699 /**
3700 * Periodic channel timer timed out
3701 * to send probe request.
3702 */
3703 channelNum = limGetCurrentScanChannel(pMac);
3704 do
3705 {
3706 /* Prepare and send Probe Request frame for all the SSIDs
3707 * present in the saved MLM
3708 */
3709
3710 /*
3711 * PELOGE(limLog(pMac, LOGW, FL("sending ProbeReq number %d,"
3712 * " for SSID %s on channel: %d\n"),
3713 * i, pLimMlmScanReq->ssId[i].ssId,
3714 * channelNum);)
3715 */
3716 status = limSendProbeReqMgmtFrame( pMac, &pLimMlmScanReq->ssId[i],
3717 pLimMlmScanReq->bssId, channelNum, pMac->lim.gSelfMacAddr,
3718 pLimMlmScanReq->dot11mode, pLimMlmScanReq->uIEFieldLen,
3719 (tANI_U8 *)(pLimMlmScanReq) + pLimMlmScanReq->uIEFieldOffset);
3720
3721
3722 if ( status != eSIR_SUCCESS)
3723 {
3724 PELOGE(limLog(pMac, LOGE, FL("send ProbeReq failed for SSID "
3725 "%s on channel: %d\n"),
3726 pLimMlmScanReq->ssId[i].ssId,
3727 channelNum);)
3728 return;
3729 }
3730 i++;
3731 } while (i < pLimMlmScanReq->numSsid);
3732
3733 /* Activate timer again */
3734 if (tx_timer_activate(pPeriodicProbeReqTimer) != TX_SUCCESS)
3735 {
3736 limLog(pMac, LOGP, FL("could not start periodic probe"
3737 " req timer\n"));
3738 return;
3739 }
3740 }
3741 else
3742 {
3743 /**
3744 * Periodic scan is timeout is happening in
3745 * in states other than wait_scan.
3746 * Log error.
3747 */
Mohit Khanna23863762012-09-11 17:40:09 -07003748 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 FL("received unexpected Periodic scan timeout in state %X\n"),
3750 pMac->lim.gLimMlmState);
3751 }
3752} /*** limProcessPeriodicProbeReqTimer() ***/
3753
3754/**
3755 * limProcessJoinFailureTimeout()
3756 *
3757 *FUNCTION:
3758 * This function is called to process JoinFailureTimeout
3759 *
3760 *LOGIC:
3761 *
3762 *ASSUMPTIONS:
3763 *
3764 *NOTE:
3765 *
3766 * @param pMac Pointer to Global MAC structure
3767 * @return None
3768 */
3769
3770static void
3771limProcessJoinFailureTimeout(tpAniSirGlobal pMac)
3772{
3773 tLimMlmJoinCnf mlmJoinCnf;
3774 tSirMacAddr bssid;
3775 tANI_U32 len;
3776
3777 //fetch the sessionEntry based on the sessionId
3778 tpPESession psessionEntry;
3779
3780 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimJoinFailureTimer.sessionId))== NULL)
3781 {
3782 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3783 return;
3784 }
3785
3786 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
3787 {
3788 len = sizeof(tSirMacAddr);
3789
3790 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, bssid, &len) !=
3791 eSIR_SUCCESS)
3792 {
3793 /// Could not get BSSID from CFG. Log error.
3794 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
3795 return;
3796 }
3797
3798 // 'Change' timer for future activations
3799 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3800
3801 /**
3802 * Issue MLM join confirm with timeout reason code
3803 */
3804 PELOGE(limLog(pMac, LOGE, FL(" Join Failure Timeout occurred.\n"));)
3805
3806 mlmJoinCnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
3807 mlmJoinCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3808
3809 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003810 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 if(limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, psessionEntry->bssId,
3812 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
3813 PELOGE(limLog(pMac, LOGE, FL("Failed to set the LinkState\n"));)
3814 /* Update PE session Id */
3815 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3816
3817
3818 // Freeup buffer allocated to join request
3819 if (psessionEntry->pLimMlmJoinReq)
3820 {
3821 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmJoinReq);
3822 psessionEntry->pLimMlmJoinReq = NULL;
3823 }
3824
3825 limPostSmeMessage(pMac,
3826 LIM_MLM_JOIN_CNF,
3827 (tANI_U32 *) &mlmJoinCnf);
3828
3829 return;
3830 }
3831 else
3832 {
3833 /**
3834 * Join failure timer should not have timed out
3835 * in states other than wait_join_beacon state.
3836 * Log error.
3837 */
3838 limLog(pMac, LOGW,
3839 FL("received unexpected JOIN failure timeout in state %X\n"),psessionEntry->limMlmState);
3840 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
3841 }
3842} /*** limProcessJoinFailureTimeout() ***/
3843
3844
3845
3846/**
3847 * limProcessAuthFailureTimeout()
3848 *
3849 *FUNCTION:
3850 * This function is called to process Min Channel Timeout
3851 * during channel scan.
3852 *
3853 *LOGIC:
3854 *
3855 *ASSUMPTIONS:
3856 *
3857 *NOTE:
3858 *
3859 * @param pMac Pointer to Global MAC structure
3860 * @return None
3861 */
3862
3863static void
3864limProcessAuthFailureTimeout(tpAniSirGlobal pMac)
3865{
3866 //fetch the sessionEntry based on the sessionId
3867 tpPESession psessionEntry;
3868
3869 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAuthFailureTimer.sessionId))== NULL)
3870 {
3871 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3872 return;
3873 }
3874
3875 switch (psessionEntry->limMlmState)
3876 {
3877 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
3878 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
3879 /**
3880 * Requesting STA did not receive next auth frame
3881 * before Auth Failure timeout.
3882 * Issue MLM auth confirm with timeout reason code
3883 */
3884
3885
3886 limRestoreFromAuthState(pMac,eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
3887 break;
3888
3889 default:
3890 /**
3891 * Auth failure timer should not have timed out
3892 * in states other than wt_auth_frame2/4
3893 * Log error.
3894 */
3895 PELOGE(limLog(pMac, LOGE, FL("received unexpected AUTH failure timeout in state %X\n"), psessionEntry->limMlmState);)
3896 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
3897
3898 break;
3899 }
3900} /*** limProcessAuthFailureTimeout() ***/
3901
3902
3903
3904/**
3905 * limProcessAuthRspTimeout()
3906 *
3907 *FUNCTION:
3908 * This function is called to process Min Channel Timeout
3909 * during channel scan.
3910 *
3911 *LOGIC:
3912 *
3913 *ASSUMPTIONS:
3914 *
3915 *NOTE:
3916 *
3917 * @param pMac Pointer to Global MAC structure
3918 * @return None
3919 */
3920
3921static void
3922limProcessAuthRspTimeout(tpAniSirGlobal pMac, tANI_U32 authIndex)
3923{
3924 struct tLimPreAuthNode *pAuthNode;
3925 tpPESession psessionEntry;
3926 tANI_U8 sessionId;
3927
3928 pAuthNode = limGetPreAuthNodeFromIndex(pMac, &pMac->lim.gLimPreAuthTimerTable, authIndex);
3929
3930 if((psessionEntry = peFindSessionByBssid(pMac, pAuthNode->peerMacAddr, &sessionId)) == NULL)
3931 {
3932 limLog(pMac, LOGW, FL("session does not exist for given BSSID \n"));
3933 return;
3934 }
3935
3936 if (psessionEntry->limSystemRole == eLIM_AP_ROLE ||
3937 psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
3938 {
3939 // Check if there exists a context for the STA
3940
3941 if (pAuthNode == NULL)
3942 {
3943 /**
3944 * Authentication response timer timedout for an STA
3945 * that does not have context at AP/STA in IBSS mode.
3946 */
3947
3948 // Log error
3949 PELOGE(limLog(pMac, LOGE, FL("received unexpected message\n"));)
3950 }
3951 else
3952 {
3953 if (pAuthNode->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE)
3954 {
3955 /**
3956 * Authentication response timer timedout
3957 * in unexpected state. Log error
3958 */
3959 PELOGE(limLog(pMac, LOGE,
3960 FL("received unexpected AUTH rsp timeout for MAC address "));
3961 limPrintMacAddr(pMac, pAuthNode->peerMacAddr, LOGE);)
3962 }
3963 else
3964 {
3965 // Authentication response timer
3966 // timedout for an STA.
3967 pAuthNode->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
3968 pAuthNode->fTimerStarted = 0;
3969 PELOG1( limLog(pMac, LOG1,
3970 FL("AUTH rsp timedout for MAC address "));
3971 limPrintMacAddr(pMac, pAuthNode->peerMacAddr, LOG1);)
3972
3973 // Change timer to reactivate it in future
3974 limDeactivateAndChangePerStaIdTimer(pMac,
3975 eLIM_AUTH_RSP_TIMER,
3976 pAuthNode->authNodeIdx);
3977
3978 limDeletePreAuthNode(pMac, pAuthNode->peerMacAddr);
3979 }
3980 }
3981 }
3982} /*** limProcessAuthRspTimeout() ***/
3983
3984
3985/**
3986 * limProcessAssocFailureTimeout()
3987 *
3988 *FUNCTION:
3989 * This function is called to process Min Channel Timeout
3990 * during channel scan.
3991 *
3992 *LOGIC:
3993 *
3994 *ASSUMPTIONS:
3995 *
3996 *NOTE:
3997 *
3998 * @param pMac Pointer to Global MAC structure
3999 * @return None
4000 */
4001
4002static void
4003limProcessAssocFailureTimeout(tpAniSirGlobal pMac, tANI_U32 MsgType)
4004{
4005
4006 tLimMlmAssocCnf mlmAssocCnf;
4007 tpPESession psessionEntry;
4008
4009 //to fetch the lim/mlm state based on the sessionId, use the below sessionEntry
4010 tANI_U8 sessionId;
4011
4012 if(MsgType == LIM_ASSOC)
4013 {
4014 sessionId = pMac->lim.limTimers.gLimAssocFailureTimer.sessionId;
4015 }
4016 else
4017 {
4018 sessionId = pMac->lim.limTimers.gLimReassocFailureTimer.sessionId;
4019 }
4020
4021 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
4022 {
4023 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
4024 return;
4025 }
4026
4027 /**
4028 * Expected Re/Association Response frame
4029 * not received within Re/Association Failure Timeout.
4030 */
4031
4032
4033
4034
4035 /* CR: vos packet memory is leaked when assoc rsp timeouted/failed. */
4036 /* notify TL that association is failed so that TL can flush the cached frame */
4037 WLANTL_AssocFailed (psessionEntry->staId);
4038
4039 // Log error
4040 PELOG1(limLog(pMac, LOG1,
4041 FL("Re/Association Response not received before timeout \n"));)
4042
4043 if (( (psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )||
4044 ( (psessionEntry->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
4045 (psessionEntry->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
4046 (psessionEntry->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4047 {
4048 /**
4049 * Re/Assoc failure timer should not have timedout on AP
4050 * or in a state other than wt_re/assoc_response.
4051 */
4052
4053 // Log error
4054 limLog(pMac, LOGW,
4055 FL("received unexpected REASSOC failure timeout in state %X for role %d\n"),
4056 psessionEntry->limMlmState, psessionEntry->limSystemRole);
4057 limPrintMlmState(pMac, LOGW, psessionEntry->limMlmState);
4058 }
4059 else
4060 {
4061
4062 if ((MsgType == LIM_ASSOC) ||
4063 ((MsgType == LIM_REASSOC) && (psessionEntry->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE)))
4064 {
4065 PELOGE(limLog(pMac, LOGE, FL("(Re)Assoc Failure Timeout occurred.\n"));)
4066
4067 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004068 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
4069
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 // 'Change' timer for future activations
4071 limDeactivateAndChangeTimer(pMac, eLIM_ASSOC_FAIL_TIMER);
4072
4073 // Free up buffer allocated for JoinReq held by
4074 // MLM state machine
4075 if (psessionEntry->pLimMlmJoinReq)
4076 {
4077 palFreeMemory( pMac->hHdd, psessionEntry->pLimMlmJoinReq);
4078 psessionEntry->pLimMlmJoinReq = NULL;
4079 }
4080
4081#if defined(ANI_PRODUCT_TYPE_CLIENT)
4082 //To remove the preauth node in case of fail to associate
4083 if (limSearchPreAuthList(pMac, psessionEntry->bssId))
4084 {
4085 PELOG1(limLog(pMac, LOG1, FL(" delete pre auth node for %02X-%02X-%02X-%02X-%02X-%02X\n"),
4086 psessionEntry->bssId[0], psessionEntry->bssId[1], psessionEntry->bssId[2],
4087 psessionEntry->bssId[3], psessionEntry->bssId[4], psessionEntry->bssId[5]);)
4088 limDeletePreAuthNode(pMac, psessionEntry->bssId);
4089 }
4090#endif
4091
4092 mlmAssocCnf.resultCode =
4093 eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
4094 mlmAssocCnf.protStatusCode =
4095 eSIR_MAC_UNSPEC_FAILURE_STATUS;
4096
4097 /* Update PE session Id*/
4098 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
4099 if (MsgType == LIM_ASSOC)
4100 limPostSmeMessage(pMac, LIM_MLM_ASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4101 else
4102 {
4103 /* Will come here only in case of 11r, CCx FT when reassoc rsp
4104 is not received and we receive a reassoc - timesout */
4105 mlmAssocCnf.resultCode = eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
4106 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmAssocCnf);
4107 }
4108 }
4109 else
4110 {
4111 /**
4112 * Restore pre-reassoc req state.
4113 * Set BSSID to currently associated AP address.
4114 */
4115 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004116 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004117
4118 limRestorePreReassocState(pMac,
4119 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry);
4120 }
4121 }
4122} /*** limProcessAssocFailureTimeout() ***/
4123
4124
4125
4126/**
4127 * limCompleteMlmScan()
4128 *
4129 *FUNCTION:
4130 * This function is called to send MLM_SCAN_CNF message
4131 * to SME state machine.
4132 *
4133 *LOGIC:
4134 *
4135 *ASSUMPTIONS:
4136 *
4137 *NOTE:
4138 *
4139 * @param pMac Pointer to Global MAC structure
4140 * @param retCode Result code to be sent
4141 * @return None
4142 */
4143
4144void
4145limCompleteMlmScan(tpAniSirGlobal pMac, tSirResultCodes retCode)
4146{
4147 tLimMlmScanCnf mlmScanCnf;
4148
4149 /// Restore previous MLM state
4150 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004151 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 limRestorePreScanState(pMac);
4153
4154 // Free up pMac->lim.gLimMlmScanReq
4155 if( NULL != pMac->lim.gpLimMlmScanReq )
4156 {
4157 palFreeMemory( pMac->hHdd, pMac->lim.gpLimMlmScanReq);
4158 pMac->lim.gpLimMlmScanReq = NULL;
4159 }
4160
4161 mlmScanCnf.resultCode = retCode;
4162 mlmScanCnf.scanResultLength = pMac->lim.gLimMlmScanResultLength;
4163
4164 limPostSmeMessage(pMac, LIM_MLM_SCAN_CNF, (tANI_U32 *) &mlmScanCnf);
4165
4166} /*** limCompleteMlmScan() ***/
4167
4168/**
4169 * \brief Setup an A-MPDU/BA session
4170 *
4171 * \sa limProcessMlmAddBAReq
4172 *
4173 * \param pMac The global tpAniSirGlobal object
4174 *
4175 * \param pMsgBuf The MLME ADDBA Req message buffer
4176 *
4177 * \return none
4178 */
4179void limProcessMlmAddBAReq( tpAniSirGlobal pMac,
4180 tANI_U32 *pMsgBuf )
4181{
4182tSirRetStatus status = eSIR_SUCCESS;
4183tpLimMlmAddBAReq pMlmAddBAReq;
4184tpLimMlmAddBACnf pMlmAddBACnf;
4185 tpPESession psessionEntry;
4186
4187 if(pMsgBuf == NULL)
4188 {
4189 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
4190 return;
4191 }
4192
4193 pMlmAddBAReq = (tpLimMlmAddBAReq) pMsgBuf;
4194 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBAReq->sessionId))== NULL)
4195 {
4196 PELOGE(limLog(pMac, LOGE,
4197 FL("session does not exist for given sessionId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004198 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 return;
4200 }
4201
4202
4203 // Send ADDBA Req over the air
4204 status = limSendAddBAReq( pMac, pMlmAddBAReq,psessionEntry);
4205
4206 //
4207 // Respond immediately to LIM, only if MLME has not been
4208 // successfully able to send WDA_ADDBA_REQ to HAL.
4209 // Else, LIM_MLM_ADDBA_CNF will be sent after receiving
4210 // ADDBA Rsp from peer entity
4211 //
4212 if( eSIR_SUCCESS != status )
4213 {
4214 // Allocate for LIM_MLM_ADDBA_CNF
4215 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4216 (void **) &pMlmAddBACnf,
4217 sizeof( tLimMlmAddBACnf )))
4218 {
4219 limLog( pMac, LOGP,
4220 FL("palAllocateMemory failed with error code %d\n"));
4221 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
4222 return;
4223 }
4224 else
4225 {
4226 palZeroMemory( pMac->hHdd, (void *) pMlmAddBACnf, sizeof( tLimMlmAddBACnf ));
4227 palCopyMemory( pMac->hHdd,
4228 (void *) pMlmAddBACnf->peerMacAddr,
4229 (void *) pMlmAddBAReq->peerMacAddr,
4230 sizeof( tSirMacAddr ));
4231
4232 pMlmAddBACnf->baDialogToken = pMlmAddBAReq->baDialogToken;
4233 pMlmAddBACnf->baTID = pMlmAddBAReq->baTID;
4234 pMlmAddBACnf->baPolicy = pMlmAddBAReq->baPolicy;
4235 pMlmAddBACnf->baBufferSize = pMlmAddBAReq->baBufferSize;
4236 pMlmAddBACnf->baTimeout = pMlmAddBAReq->baTimeout;
4237 pMlmAddBACnf->sessionId = pMlmAddBAReq->sessionId;
4238
4239 // Update the result code
4240 pMlmAddBACnf->addBAResultCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
4241
4242 limPostSmeMessage( pMac,
4243 LIM_MLM_ADDBA_CNF,
4244 (tANI_U32 *) pMlmAddBACnf );
4245 }
4246
4247 // Restore MLME state
4248 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07004249 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004250
4251 }
4252
4253 // Free the buffer allocated for tLimMlmAddBAReq
4254 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
4255
4256}
4257
4258/**
4259 * \brief Send an ADDBA Rsp to peer STA in response
4260 * to an ADDBA Req received earlier
4261 *
4262 * \sa limProcessMlmAddBARsp
4263 *
4264 * \param pMac The global tpAniSirGlobal object
4265 *
4266 * \param pMsgBuf The MLME ADDBA Rsp message buffer
4267 *
4268 * \return none
4269 */
4270void limProcessMlmAddBARsp( tpAniSirGlobal pMac,
4271 tANI_U32 *pMsgBuf )
4272{
4273tpLimMlmAddBARsp pMlmAddBARsp;
4274 tANI_U16 aid;
4275 tpDphHashNode pSta;
4276 tpPESession psessionEntry;
4277
4278
4279 if(pMsgBuf == NULL)
4280 {
4281 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
4282 return;
4283 }
4284
4285 pMlmAddBARsp = (tpLimMlmAddBARsp) pMsgBuf;
4286
4287 if(( psessionEntry = peFindSessionBySessionId(pMac,pMlmAddBARsp->sessionId))== NULL)
4288 {
4289 PELOGE(limLog(pMac, LOGE,
4290 FL("session does not exist for given session ID\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004291 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 return;
4293 }
4294
4295
4296 // Send ADDBA Rsp over the air
4297 if( eSIR_SUCCESS != limSendAddBARsp( pMac,pMlmAddBARsp,psessionEntry))
4298 {
4299 limLog( pMac, LOGE,
4300 FL("Failed to send ADDBA Rsp to peer \n"));
4301 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGE );
4302 /* Clean the BA context maintained by HAL and TL on failure */
4303 pSta = dphLookupHashEntry( pMac, pMlmAddBARsp->peerMacAddr, &aid,
4304 &psessionEntry->dph.dphHashTable);
4305 if( NULL != pSta )
4306 {
4307 limPostMsgDelBAInd( pMac, pSta, pMlmAddBARsp->baTID, eBA_RECIPIENT,
4308 psessionEntry);
4309 }
4310 }
4311
4312 // Time to post a WDA_DELBA_IND to HAL in order
4313 // to cleanup the HAL and SoftMAC entries
4314
4315
4316 // Free the buffer allocated for tLimMlmAddBARsp
4317 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
4318
4319}
4320
4321/**
4322 * \brief Setup an A-MPDU/BA session
4323 *
4324 * \sa limProcessMlmDelBAReq
4325 *
4326 * \param pMac The global tpAniSirGlobal object
4327 *
4328 * \param pMsgBuf The MLME DELBA Req message buffer
4329 *
4330 * \return none
4331 */
4332void limProcessMlmDelBAReq( tpAniSirGlobal pMac,
4333 tANI_U32 *pMsgBuf )
4334{
4335 tSirRetStatus status = eSIR_SUCCESS;
4336 tpLimMlmDelBAReq pMlmDelBAReq;
4337 tpLimMlmDelBACnf pMlmDelBACnf;
4338 tpPESession psessionEntry;
4339
4340
4341 if(pMsgBuf == NULL)
4342 {
4343 PELOGE(limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));)
4344 return;
4345 }
4346
4347 // TODO - Need to validate MLME state
4348 pMlmDelBAReq = (tpLimMlmDelBAReq) pMsgBuf;
4349
4350 if((psessionEntry = peFindSessionBySessionId(pMac,pMlmDelBAReq->sessionId))== NULL)
4351 {
4352 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004353 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 return;
4355 }
4356
4357 // Send DELBA Ind over the air
4358 if( eSIR_SUCCESS !=
4359 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
4360 status = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
4361 else
4362 {
4363 tANI_U16 aid;
4364 tpDphHashNode pSta;
4365
4366 // Time to post a WDA_DELBA_IND to HAL in order
4367 // to cleanup the HAL and SoftMAC entries
4368 pSta = dphLookupHashEntry( pMac, pMlmDelBAReq->peerMacAddr, &aid , &psessionEntry->dph.dphHashTable);
4369 if( NULL != pSta )
4370 {
4371 status = limPostMsgDelBAInd( pMac,
4372 pSta,
4373 pMlmDelBAReq->baTID,
4374 pMlmDelBAReq->baDirection,psessionEntry);
4375
4376 }
4377 }
4378
4379 //
4380 // Respond immediately to SME with DELBA CNF using
4381 // LIM_MLM_DELBA_CNF with appropriate status
4382 //
4383
4384 // Allocate for LIM_MLM_DELBA_CNF
4385 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4386 (void **) &pMlmDelBACnf,
4387 sizeof( tLimMlmDelBACnf )))
4388 {
4389 limLog( pMac, LOGP, FL("palAllocateMemory failed\n"));
4390 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
4391 return;
4392 }
4393 else
4394 {
4395 palZeroMemory( pMac->hHdd, (void *) pMlmDelBACnf, sizeof( tLimMlmDelBACnf ));
4396
4397 palCopyMemory( pMac->hHdd,
4398 (void *) pMlmDelBACnf,
4399 (void *) pMlmDelBAReq,
4400 sizeof( tLimMlmDelBAReq ));
4401
4402 // Update DELBA result code
4403 pMlmDelBACnf->delBAReasonCode = pMlmDelBAReq->delBAReasonCode;
4404
4405 /* Update PE session Id*/
4406 pMlmDelBACnf->sessionId = pMlmDelBAReq->sessionId;
4407
4408 limPostSmeMessage( pMac,
4409 LIM_MLM_DELBA_CNF,
4410 (tANI_U32 *) pMlmDelBACnf );
4411 }
4412
4413 // Free the buffer allocated for tLimMlmDelBAReq
4414 palFreeMemory( pMac->hHdd, (tANI_U8 *) pMsgBuf );
4415
4416}
4417
4418/**
4419 * @function : limSMPowerSaveStateInd( )
4420 *
4421 * @brief : This function is called upon receiving the PMC Indication to update the STA's MimoPs State.
4422 *
4423 * LOGIC:
4424 *
4425 * ASSUMPTIONS:
4426 * NA
4427 *
4428 * NOTE:
4429 * NA
4430 *
4431 * @param pMac - Pointer to Global MAC structure
4432 * @param limMsg - Lim Message structure object with the MimoPSparam in body
4433 * @return None
4434 */
4435
4436tSirRetStatus
4437limSMPowerSaveStateInd(tpAniSirGlobal pMac, tSirMacHTMIMOPowerSaveState state)
4438{
4439#if 0
4440 tSirRetStatus retStatus = eSIR_SUCCESS;
4441#if 0
4442 tANI_U32 cfgVal1;
4443 tANI_U16 cfgVal2;
4444 tSirMacHTCapabilityInfo *pHTCapabilityInfo;
4445 tpDphHashNode pSta = NULL;
4446
4447 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
4448 /** Verify the Mode of operation */
4449 if (pMac->lim.gLimSystemRole != eSYSTEM_STA_ROLE) {
4450 PELOGE(limLog(pMac, LOGE, FL("Got PMC indication when System not in the STA Role\n"));)
4451 return eSIR_FAILURE;
4452 }
4453
4454 if ((pMac->lim.gHTMIMOPSState == state) || (state == eSIR_HT_MIMO_PS_NA )) {
4455 PELOGE(limLog(pMac, LOGE, FL("Got Indication when already in the same mode or State passed is NA:%d \n"), state);)
4456 return eSIR_FAILURE;
4457 }
4458
4459 if (!pMac->lim.htCapability){
4460 PELOGW(limLog(pMac, LOGW, FL(" Not in 11n or HT capable mode\n"));)
4461 return eSIR_FAILURE;
4462 }
4463
4464 /** Update the CFG about the default MimoPS State */
4465 if (wlan_cfgGetInt(pMac, WNI_CFG_HT_CAP_INFO, &cfgVal1) != eSIR_SUCCESS) {
4466 limLog(pMac, LOGP, FL("could not retrieve HT Cap CFG \n"));
4467 return eSIR_FAILURE;
4468 }
4469
4470 cfgVal2 = (tANI_U16)cfgVal1;
4471 pHTCapabilityInfo = (tSirMacHTCapabilityInfo *) &cfgVal2;
4472 pHTCapabilityInfo->mimoPowerSave = state;
4473
4474 if(cfgSetInt(pMac, WNI_CFG_HT_CAP_INFO, *(tANI_U16*)pHTCapabilityInfo) != eSIR_SUCCESS) {
4475 limLog(pMac, LOGP, FL("could not update HT Cap Info CFG\n"));
4476 return eSIR_FAILURE;
4477 }
4478
4479 PELOG2(limLog(pMac, LOG2, FL(" The HT Capability for Mimo Pwr is updated to State: %u \n"),state);)
4480 if (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE) {
4481 PELOG2(limLog(pMac, LOG2,FL(" The STA is not in the Connected/Link Est Sme_State: %d \n"), pMac->lim.gLimSmeState);)
4482 /** Update in the LIM the MIMO PS state of the SELF */
4483 pMac->lim.gHTMIMOPSState = state;
4484 return eSIR_SUCCESS;
4485 }
4486
4487 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4488 if (!pSta->mlmStaContext.htCapability) {
4489 limLog( pMac, LOGE,FL( "limSendSMPowerState: Peer is not HT Capable \n" ));
4490 return eSIR_FAILURE;
4491 }
4492
4493 if (isEnteringMimoPS(pMac->lim.gHTMIMOPSState, state)) {
4494 tSirMacAddr macAddr;
4495 /** Obtain the AP's Mac Address */
4496 palCopyMemory(pMac ->hHdd, (tANI_U8 *)macAddr, psessionEntry->bssId, sizeof(tSirMacAddr));
4497 /** Send Action Frame with the corresponding mode */
4498 retStatus = limSendSMPowerStateFrame(pMac, macAddr, state);
4499 if (retStatus != eSIR_SUCCESS) {
4500 PELOGE(limLog(pMac, LOGE, "Update SM POWER: Sending Action Frame has failed\n");)
4501 return retStatus;
4502 }
4503 }
4504
4505 /** Update MlmState about the SetMimoPS State */
4506 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
4507 pMac->lim.gLimMlmState = eLIM_MLM_WT_SET_MIMOPS_STATE;
4508 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, 0, pMac->lim.gLimMlmState));
4509
4510 /** Update the HAL and s/w mac about the mode to be set */
4511 retStatus = limPostSMStateUpdate( pMac,psessionEntry->staId, state);
4512
4513 PELOG2(limLog(pMac, LOG2, " Updated the New SMPS State");)
4514 /** Update in the LIM the MIMO PS state of the SELF */
4515 pMac->lim.gHTMIMOPSState = state;
4516#endif
4517 return retStatus;
4518#endif
4519return eSIR_SUCCESS;
4520}
4521
Jeff Johnsone7245742012-09-05 17:12:55 -07004522#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004523ePhyChanBondState limGet11ACPhyCBState(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 htSecondaryChannelOffset,tANI_U8 peerCenterChan, tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07004524{
4525 ePhyChanBondState cbState = PHY_SINGLE_CHANNEL_CENTERED;
4526
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004527 if(!psessionEntry->apChanWidth)
Jeff Johnsone7245742012-09-05 17:12:55 -07004528 {
4529 return htSecondaryChannelOffset;
4530 }
4531
4532 if ( (htSecondaryChannelOffset
4533 == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
4534 )
4535 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004536 if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07004537 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004538 else if ((channel + 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07004539 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004540 else if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07004541 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
4542 else
4543 limLog (pMac, LOGP,
4544 FL("Invalid Channel Number = %d Center Chan = %d \n"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004545 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07004546 }
4547 if ( (htSecondaryChannelOffset
4548 == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
4549 )
4550 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004551 if ((channel - 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07004552 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004553 else if ((channel + 2 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07004554 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004555 else if ((channel - 6 ) == peerCenterChan )
Jeff Johnsone7245742012-09-05 17:12:55 -07004556 cbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
4557 else
4558 limLog (pMac, LOGP,
4559 FL("Invalid Channel Number = %d Center Chan = %d \n"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004560 channel, peerCenterChan);
Jeff Johnsone7245742012-09-05 17:12:55 -07004561 }
4562 return cbState;
4563}
4564
4565#endif
4566
Jeff Johnson295189b2012-06-20 16:38:30 -07004567void
Jeff Johnsone7245742012-09-05 17:12:55 -07004568limSetChannel(tpAniSirGlobal pMac, tANI_U8 channel, tANI_U8 secChannelOffset, tPowerdBm maxTxPower, tANI_U8 peSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004569{
4570#if !defined WLAN_FEATURE_VOWIFI
4571 tANI_U32 localPwrConstraint;
4572#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004573 tpPESession peSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574
Jeff Johnsone7245742012-09-05 17:12:55 -07004575 peSession = peFindSessionBySessionId (pMac, peSessionId);
4576
4577 if ( NULL == peSession)
4578 {
4579 limLog (pMac, LOGP, FL("Invalid PE session = %d\n"), peSessionId);
4580 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004582#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07004583#ifdef WLAN_FEATURE_11AC
4584 if ( peSession->vhtCapability )
4585 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004586 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004587 }
4588 else
4589#endif
4590 {
4591 limSendSwitchChnlParams( pMac, channel, secChannelOffset, maxTxPower, peSessionId);
4592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004593#else
4594 if (wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
4595 limLog(pMac, LOGP, FL("could not read WNI_CFG_LOCAL_POWER_CONSTRAINT from CFG\n"));
4596 return;
4597 }
4598 // Send WDA_CHNL_SWITCH_IND to HAL
Jeff Johnsone7245742012-09-05 17:12:55 -07004599#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004600 if ( peSession->vhtCapability && peSession->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07004601 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004602 limSendSwitchChnlParams( pMac, channel, limGet11ACPhyCBState( pMac,channel,secChannelOffset,peSession->apCenterChan, peSession), maxTxPower, peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004603 }
4604 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004605#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004606 {
4607 limSendSwitchChnlParams( pMac, channel, secChannelOffset, (tPowerdBm)localPwrConstraint, peSessionId);
4608 }
4609#endif
4610
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 }