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