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