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