blob: f48a9eaffc0346769a3da3288d01dda5434f809f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Jeff Johnson295189b2012-06-20 16:38:30 -070041/*===========================================================================
42 L I M _ P 2 P . C
43
44 OVERVIEW:
45
46 This software unit holds the implementation of the WLAN Protocol Engine for
47 P2P.
48
49 Copyright (c) 2011 QUALCOMM Incorporated.
50 All Rights Reserved.
51 Qualcomm Confidential and Proprietary
52===========================================================================*/
53
54/*===========================================================================
55
56 EDIT HISTORY FOR FILE
57
58
59 This section contains comments describing changes made to the module.
60 Notice that changes are listed in reverse chronological order.
61
62
63 $Header$$DateTime$$Author$
64
65
66 when who what, where, why
67---------- --- --------------------------------------------------------
682011-05-02 djindal Corrected file indentation and changed remain on channel
69 handling for concurrency.
70===========================================================================*/
71
72
Jeff Johnson295189b2012-06-20 16:38:30 -070073#include "limUtils.h"
74#include "limSessionUtils.h"
75#include "wlan_qct_wda.h"
76
77#define PROBE_RSP_IE_OFFSET 36
78#define BSSID_OFFSET 16
79#define ADDR2_OFFSET 10
80#define ACTION_OFFSET 24
Jeff Johnson32d95a32012-09-10 13:15:23 -070081#define LIM_MIN_REM_TIME_FOR_TX_ACTION_FRAME 50
82#define LIM_MIN_REM_TIME_EXT_FOR_TX_ACTION_FRAME 60
Jeff Johnson295189b2012-06-20 16:38:30 -070083
84
85
86void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
87 tANI_U32 *data);
88void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
89 tANI_U32 *data, tpPESession psessionEntry);
90void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
91 tANI_U32 *data, tpPESession psessionEntry);
92void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data);
93extern tSirRetStatus limSetLinkState(
94 tpAniSirGlobal pMac, tSirLinkState state,
95 tSirMacAddr bssId, tSirMacAddr selfMacAddr,
96 tpSetLinkStateCallback callback, void *callbackArg);
97
98static tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession);
Jeff Johnsone7245742012-09-05 17:12:55 -070099eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess);
Jeff Johnson295189b2012-06-20 16:38:30 -0700100/*------------------------------------------------------------------
101 *
102 * Below function is callback function, it is called when
103 * WDA_SET_LINK_STATE_RSP is received from WDI. callback function for
104 * P2P of limSetLinkState
105 *
106 *------------------------------------------------------------------*/
107void limSetLinkStateP2PCallback(tpAniSirGlobal pMac, void *callbackArg)
108{
109 //Send Ready on channel indication to SME
110 if(pMac->lim.gpLimRemainOnChanReq)
111 {
112 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RDY_IND, eHAL_STATUS_SUCCESS,
113 pMac->lim.gpLimRemainOnChanReq->sessionId, 0);
114 }
115 else
116 {
117 //This is possible in case remain on channel is aborted
118 limLog( pMac, LOGE, FL(" NULL pointer of gpLimRemainOnChanReq") );
119 }
120}
121
122/*------------------------------------------------------------------
123 *
124 * Remain on channel req handler. Initiate the INIT_SCAN, CHN_CHANGE
125 * and SET_LINK Request from SME, chnNum and duration to remain on channel.
126 *
127 *------------------------------------------------------------------*/
128
129
130int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg)
131{
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530132
133 /* CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE - Currently removed the special optimization when a concurrent session
134 * exists with operating channel same as P2P listen channel since it was causing issues in P2P search. The reason was
135 * STA-AP link entering BMPS when returning to home channel causing P2P search to miss Probe Reqs and hence not
136 * respond with Probe Rsp causing peer device to NOT find us.
137 * If we need this optimization, we need to find a way to keep the STA-AP link awake (no BMPS) on home channel when in listen state
138 */
139#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 tANI_U8 i;
141 tpPESession psessionEntry;
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700143#ifdef WLAN_FEATURE_P2P_INTERNAL
144 tpPESession pP2pSession;
145#endif
146
147 tSirRemainOnChnReq *MsgBuff = (tSirRemainOnChnReq *)pMsg;
148 pMac->lim.gpLimRemainOnChanReq = MsgBuff;
149
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530150#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 for (i =0; i < pMac->lim.maxBssId;i++)
152 {
153 psessionEntry = peFindSessionBySessionId(pMac,i);
154
155 if ( (psessionEntry != NULL) )
156 {
157 if (psessionEntry->currentOperChannel == MsgBuff->chnNum)
158 {
159 tANI_U32 val;
160 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
161
Jeff Johnsone7245742012-09-05 17:12:55 -0700162 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
163 pMac->lim.gTotalScanDuration = MsgBuff->duration;
Jeff Johnson295189b2012-06-20 16:38:30 -0700164
165 /* get the duration from the request */
166 val = SYS_MS_TO_TICKS(MsgBuff->duration);
167
Madan Mohan Koyyalamudi709790c2012-09-24 12:12:51 -0700168 limLog( pMac, LOG2, "Start listen duration = %d", val);
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 if (tx_timer_change(
170 &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0)
171 != TX_SUCCESS)
172 {
173 limLog(pMac, LOGP,
174 FL("Unable to change remain on channel Timer val\n"));
175 goto error;
176 }
177 else if(TX_SUCCESS != tx_timer_activate(
178 &pMac->lim.limTimers.gLimRemainOnChannelTimer))
179 {
180 limLog(pMac, LOGP,
181 FL("Unable to activate remain on channel Timer\n"));
182 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
183 goto error;
184 }
185
186#ifdef WLAN_FEATURE_P2P_INTERNAL
187 //Session is needed to send probe rsp
188 if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &pP2pSession))
189 {
190 limLog( pMac, LOGE, "Unable to create session");
191 goto error;
192 }
193#endif
194
195 if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE,
196 nullBssid, pMac->lim.gSelfMacAddr,
197 limSetLinkStateP2PCallback, NULL)) != eSIR_SUCCESS)
198 {
199 limLog( pMac, LOGE, "Unable to change link state");
200 goto error;
201 }
202 return FALSE;
203 }
204 }
205 }
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530206#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
208 pMac->lim.gLimMlmState = eLIM_MLM_P2P_LISTEN_STATE;
209
210 pMac->lim.gTotalScanDuration = MsgBuff->duration;
211
212 /* 1st we need to suspend link with callback to initiate change channel */
213 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
214 limRemainOnChnlSuspendLinkHdlr, NULL);
215 return FALSE;
216
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530217#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
Jeff Johnson295189b2012-06-20 16:38:30 -0700218error:
219 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
220 /* pMsg is freed by the caller */
221 return FALSE;
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700223}
224
225
226tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession)
227{
228 tSirRetStatus nSirStatus = eSIR_FAILURE;
229 tpPESession psessionEntry;
230 tANI_U8 sessionId;
231 tANI_U32 val;
232
233 if(pMac->lim.gpLimRemainOnChanReq && ppP2pSession)
234 {
235 if((psessionEntry = peCreateSession(pMac,
236 pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId, 1)) == NULL)
237 {
238 limLog(pMac, LOGE, FL("Session Can not be created \n"));
239 /* send remain on chn failure */
240 return nSirStatus;
241 }
242 /* Store PE sessionId in session Table */
243 psessionEntry->peSessionId = sessionId;
244
245 psessionEntry->limSystemRole = eLIM_P2P_DEVICE_ROLE;
246 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_SUPPORTED_RATES_11A,
247 psessionEntry->rateSet.rate, val , SIR_MAC_MAX_NUMBER_OF_RATES );
248 psessionEntry->rateSet.numRates = val;
249
250 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
251 psessionEntry->extRateSet.rate, val,
252 WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN );
253 psessionEntry->extRateSet.numRates = val;
254
255 sirCopyMacAddr(psessionEntry->selfMacAddr,
256 pMac->lim.gpLimRemainOnChanReq->selfMacAddr);
257
258 psessionEntry->currentOperChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
259 nSirStatus = eSIR_SUCCESS;
260 *ppP2pSession = psessionEntry;
261 }
262
263 return nSirStatus;
264}
265
266
267/*------------------------------------------------------------------
268 *
269 * limSuspenLink callback, on success link suspend, trigger change chn
270 *
271 *
272 *------------------------------------------------------------------*/
273
274tSirRetStatus limRemainOnChnlChangeChnReq(tpAniSirGlobal pMac,
275 eHalStatus status, tANI_U32 *data)
276{
277 tpPESession psessionEntry;
278 tANI_U8 sessionId = 0;
279 tSirRetStatus nSirStatus = eSIR_FAILURE;
280
281 if( NULL == pMac->lim.gpLimRemainOnChanReq )
282 {
283 //RemainOnChannel may have aborted
284 PELOGE(limLog( pMac, LOGE, FL(" gpLimRemainOnChanReq is NULL") );)
285 return nSirStatus;
286 }
287
288 /* The link is not suspended */
289 if (status != eHAL_STATUS_SUCCESS)
290 {
291 PELOGE(limLog( pMac, LOGE, FL(" Suspend link Failure ") );)
292 goto error;
293 }
294
295
296 if((psessionEntry = peFindSessionByBssid(
297 pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) != NULL)
298 {
299 goto change_channel;
300 }
301 else /* Session Entry does not exist for given BSSId */
302 {
303 /* Try to Create a new session */
304 if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &psessionEntry))
305 {
306 limLog(pMac, LOGE, FL("Session Can not be created \n"));
307 /* send remain on chn failure */
308 goto error;
309 }
310 }
311
312change_channel:
313 /* change channel to the requested by RemainOn Chn*/
314 limChangeChannelWithCallback(pMac,
315 pMac->lim.gpLimRemainOnChanReq->chnNum,
316 limRemainOnChnlSetLinkStat, NULL, psessionEntry);
317 return eSIR_SUCCESS;
318
319error:
320 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
321 return eSIR_FAILURE;
322}
323
324void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
325 tANI_U32 *data)
326{
327 limRemainOnChnlChangeChnReq(pMac, status, data);
328 return;
329}
330
331/*------------------------------------------------------------------
332 *
333 * Set the LINK state to LISTEN to allow only PROBE_REQ and Action frames
334 *
335 *------------------------------------------------------------------*/
336void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
337 tANI_U32 *data, tpPESession psessionEntry)
338{
339 tANI_U32 val;
340 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
341 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
342
343 if (status != eHAL_STATUS_SUCCESS)
344 {
345 limLog( pMac, LOGE, "%s: Change channel not successful\n");
346 goto error1;
347 }
348
349 // Start timer here to come back to operating channel.
350 pMac->lim.limTimers.gLimRemainOnChannelTimer.sessionId =
351 psessionEntry->peSessionId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700352 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
353 pMac->lim.gTotalScanDuration = MsgRemainonChannel->duration;
Jeff Johnson295189b2012-06-20 16:38:30 -0700354
355 /* get the duration from the request */
356 val = SYS_MS_TO_TICKS(MsgRemainonChannel->duration);
357
Madan Mohan Koyyalamudi709790c2012-09-24 12:12:51 -0700358 limLog( pMac, LOG2, "Start listen duration = %d", val);
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 if (tx_timer_change(&pMac->lim.limTimers.gLimRemainOnChannelTimer,
360 val, 0) != TX_SUCCESS)
361 {
362 /**
363 * Could not change Remain on channel Timer. Log error.
364 */
365 limLog(pMac, LOGP,
366 FL("Unable to change remain on channel Timer val\n"));
367 goto error;
368 }
369
370 if(TX_SUCCESS !=
371 tx_timer_activate(&pMac->lim.limTimers.gLimRemainOnChannelTimer))
372 {
373 limLog( pMac, LOGE,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700374 "%s: remain on channel Timer Start Failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 goto error;
376 }
377
378 if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE,nullBssid,
379 pMac->lim.gSelfMacAddr, limSetLinkStateP2PCallback,
380 NULL)) != eSIR_SUCCESS)
381 {
382 limLog( pMac, LOGE, "Unable to change link state");
383 goto error;
384 }
385
386 return;
387error:
388 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
389error1:
390 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
391 return;
392}
393
394/*------------------------------------------------------------------
395 *
Viral Modid86bde22012-12-10 13:09:21 -0800396 * lim Insert NOA timer timeout callback - when timer fires, deactivate it and send
397 * scan rsp to csr/hdd
398 *
399 *------------------------------------------------------------------*/
400void limProcessInsertSingleShotNOATimeout(tpAniSirGlobal pMac)
401{
Viral Modid440e682013-03-06 02:25:31 -0800402 /* timeout means start NOA did not arrive; we need to deactivate and change the timer for
403 * future activations
Viral Modid86bde22012-12-10 13:09:21 -0800404 */
405 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800406
Viral Modid440e682013-03-06 02:25:31 -0800407 /* Even if insert NOA timedout, go ahead and process/send stored SME request */
408 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800409
Viral Modid86bde22012-12-10 13:09:21 -0800410 return;
411}
412
413/*------------------------------------------------------------------
414 *
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 * limchannelchange callback, on success channel change, set the
416 * link_state to LISTEN
417 *
418 *------------------------------------------------------------------*/
419
420void limProcessRemainOnChnTimeout(tpAniSirGlobal pMac)
421{
422 tpPESession psessionEntry;
423 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
424
Jeff Johnsone7245742012-09-05 17:12:55 -0700425 //Timer might get extended while Sending Action Frame
426 //In that case don't process Channel Timeout
427 if (tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer))
428 {
429 limLog( pMac, LOGE,
430 "still timer is running already and not processing limProcessRemainOnChnTimeout");
431 return;
432 }
433
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
435
436 if (NULL == pMac->lim.gpLimRemainOnChanReq)
437 {
438 limLog( pMac, LOGE, "No Remain on channel pending");
439 return;
440 }
441
442 /* get the previous valid LINK state */
443 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
444 pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS)
445 {
446 limLog( pMac, LOGE, "Unable to change link state");
447 return;
448 }
449
450 if (pMac->lim.gLimMlmState != eLIM_MLM_P2P_LISTEN_STATE )
451 {
452 limRemainOnChnRsp(pMac,eHAL_STATUS_SUCCESS, NULL);
453 }
454 else
455 {
456 /* get the session */
457 if((psessionEntry = peFindSessionBySessionId(pMac,
458 pMac->lim.limTimers.gLimRemainOnChannelTimer.sessionId))== NULL)
459 {
460 limLog(pMac, LOGE,
461 FL("Session Does not exist for given sessionID\n"));
462 goto error;
463 }
464
465 limExitRemainOnChannel(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry);
466 return;
467error:
468 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
469 }
470 return;
471}
472
473
474/*------------------------------------------------------------------
475 *
476 * limchannelchange callback, on success channel change, set the link_state
477 * to LISTEN
478 *
479 *------------------------------------------------------------------*/
480
481void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
482 tANI_U32 *data, tpPESession psessionEntry)
483{
484
485 if (status != eHAL_STATUS_SUCCESS)
486 {
487 PELOGE(limLog( pMac, LOGE, "Remain on Channel Failed\n");)
488 goto error;
489 }
490 //Set the resume channel to Any valid channel (invalid).
491 //This will instruct HAL to set it to any previous valid channel.
492 peSetResumeChannel(pMac, 0, 0);
493 limResumeLink(pMac, limRemainOnChnRsp, NULL);
494 return;
495error:
496 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
497 return;
498}
499
500/*------------------------------------------------------------------
501 *
502 * Send remain on channel respone: Success/ Failure
503 *
504 *------------------------------------------------------------------*/
505void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
506{
507 tpPESession psessionEntry;
508 tANI_U8 sessionId;
509 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
510 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
511
512 if ( NULL == MsgRemainonChannel )
513 {
514 PELOGE(limLog( pMac, LOGP,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700515 "%s: No Pointer for Remain on Channel Req\n", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 return;
517 }
518
519 //Incase of the Remain on Channel Failure Case
520 //Cleanup Everything
521 if(eHAL_STATUS_FAILURE == status)
522 {
523 //Deactivate Remain on Channel Timer
524 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
525
526 //Set the Link State to Idle
527 /* get the previous valid LINK state */
528 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
529 pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS)
530 {
531 limLog( pMac, LOGE, "Unable to change link state");
532 }
533
534 pMac->lim.gLimSystemInScanLearnMode = 0;
535 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
536 }
537
538 /* delete the session */
539 if((psessionEntry = peFindSessionByBssid(pMac,
540 MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL)
541 {
542 if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole )
543 {
544 peDeleteSession( pMac, psessionEntry);
545 }
546 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 /* Post the meessage to Sme */
549 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
550 MsgRemainonChannel->sessionId, 0);
551
552 palFreeMemory( pMac->hHdd, pMac->lim.gpLimRemainOnChanReq );
553 pMac->lim.gpLimRemainOnChanReq = NULL;
554
555 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700556
557 /* If remain on channel timer expired and action frame is pending then
558 * indicaiton confirmation with status failure */
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800559 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700560 {
561 limP2PActionCnf(pMac, 0);
562 }
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 return;
565}
566
567/*------------------------------------------------------------------
568 *
569 * Indicate the Mgmt Frame received to SME to HDD callback
570 * handle Probe_req/Action frame currently
571 *
572 *------------------------------------------------------------------*/
573void limSendSmeMgmtFrameInd(
574 tpAniSirGlobal pMac, tANI_U8 frameType,
575 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
Chilam NG571c65a2013-01-19 12:27:36 +0530576 tANI_U32 rxChannel, tpPESession psessionEntry,
577 tANI_S8 rxRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700578{
579 tSirMsgQ mmhMsg;
580 tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL;
581 tANI_U16 length;
582
583 length = sizeof(tSirSmeMgmtFrameInd) + frameLen;
584
585 if( eHAL_STATUS_SUCCESS !=
586 palAllocateMemory( pMac->hHdd, (void **)&pSirSmeMgmtFrame, length ))
587 {
588 limLog(pMac, LOGP,
589 FL("palAllocateMemory failed for eWNI_SME_LISTEN_RSP\n"));
590 return;
591 }
592 palZeroMemory(pMac->hHdd, (void*)pSirSmeMgmtFrame, length);
593
594 pSirSmeMgmtFrame->mesgType = eWNI_SME_MGMT_FRM_IND;
595 pSirSmeMgmtFrame->mesgLen = length;
596 pSirSmeMgmtFrame->sessionId = sessionId;
597 pSirSmeMgmtFrame->frameType = frameType;
Chilam NG571c65a2013-01-19 12:27:36 +0530598 pSirSmeMgmtFrame->rxRssi = rxRssi;
Jeff Johnsone7245742012-09-05 17:12:55 -0700599
Sunil Ravif0998942013-02-04 07:01:12 -0800600 /*
601 * Work around to address LIM sending wrong channel to HDD for p2p action
602 * frames(In case of auto GO) recieved on 5GHz channel.
603 * As RXP has only 4bits to store the channel, we need some mechanism to
604 * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer
605 * is not running and if we get a frame then pass the Go session
606 * operating channel to HDD. Some vendors create separate p2p interface
607 * after group formation. In that case LIM session entry will be NULL for
608 * p2p device address. So search for p2p go session and pass it's
609 * operating channel.
610 * Need to revisit this path in case of GO+CLIENT concurrency.
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 */
Sunil Ravif0998942013-02-04 07:01:12 -0800612 if( VOS_FALSE ==
613 tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer) )
Jeff Johnsone7245742012-09-05 17:12:55 -0700614 {
Sunil Ravif0998942013-02-04 07:01:12 -0800615 tpPESession pTempSessionEntry = psessionEntry;
616 if( ( (NULL != pTempSessionEntry) ||
617 (pTempSessionEntry = limIsApSessionActive(pMac)) ) &&
618 (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) )
619 {
620 rxChannel = pTempSessionEntry->currentOperChannel;
621 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700622 }
Sunil Ravif0998942013-02-04 07:01:12 -0800623
624 pSirSmeMgmtFrame->rxChan = rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700625
626 vos_mem_zero(pSirSmeMgmtFrame->frameBuf,frameLen);
627 vos_mem_copy(pSirSmeMgmtFrame->frameBuf,frame,frameLen);
628
629 mmhMsg.type = eWNI_SME_MGMT_FRM_IND;
630 mmhMsg.bodyptr = pSirSmeMgmtFrame;
631 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700632
633 if(VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer) &&
634 ( (psessionEntry != NULL) && (psessionEntry->pePersona != VOS_P2P_GO_MODE)) &&
635 (frameType == SIR_MAC_MGMT_ACTION))
636 {
637 tANI_U32 curTime = vos_timer_get_system_time();
638 if((curTime - pMac->lim.p2pRemOnChanTimeStamp) > (pMac->lim.gTotalScanDuration - LIM_MIN_REM_TIME_FOR_TX_ACTION_FRAME))
639 {
640 unsigned int chanWaitTime, vStatus ;
641
642 limLog( pMac, LOG1, FL("Rx: Extend the gLimRemainOnChannelTimer"));
643
644 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
645 pMac->lim.gTotalScanDuration = LIM_MIN_REM_TIME_EXT_FOR_TX_ACTION_FRAME;
646
Jeff Johnson32d95a32012-09-10 13:15:23 -0700647 chanWaitTime = SYS_MS_TO_TICKS(LIM_MIN_REM_TIME_EXT_FOR_TX_ACTION_FRAME);
Jeff Johnsone7245742012-09-05 17:12:55 -0700648 vStatus = tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
649
650 if (VOS_STATUS_SUCCESS != vStatus)
651 {
652 limLog( pMac, LOGE, FL("Rx: Extend the gLimRemainOnChannelTimer"));
653 }
654
655 if (tx_timer_change(&pMac->lim.limTimers.gLimRemainOnChannelTimer, chanWaitTime, 0) != TX_SUCCESS)
656 {
657 limLog( pMac, LOGE, FL("Unable to change the gLimRemainOnChannelTimer"));
658 }
659
660 if (tx_timer_activate(&pMac->lim.limTimers.gLimRemainOnChannelTimer) != 0)
661 {
662 limLog( pMac, LOGE, FL("Unable to active the gLimRemainOnChannelTimer"));
663 }
664 }
665 }
666
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
668 return;
669} /*** end limSendSmeListenRsp() ***/
670
671
672eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
673{
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800674 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700675 {
676 /* The session entry might be invalid(0xff) action confirmation received after
677 * remain on channel timer expired */
678 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
679 (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL),
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800680 pMac->lim.mgmtFrameSessionId, 0);
681 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnsone7245742012-09-05 17:12:55 -0700682 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700683
684 return eHAL_STATUS_SUCCESS;
685}
686
687
Jeff Johnsone7245742012-09-05 17:12:55 -0700688void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes)
Jeff Johnson295189b2012-06-20 16:38:30 -0700689{
690 v_U8_t *pIe=NULL;
691 tDot11fIEHTCaps dot11HtCap;
692
Jeff Johnsone7245742012-09-05 17:12:55 -0700693 PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap);
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes,
695 DOT11F_EID_HTCAPS,ONE_BYTE);
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700696 limLog( pMac, LOG2, FL("pIe 0x%x dot11HtCap.supportedMCSSet[0]=0x%x"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 (tANI_U32)pIe,dot11HtCap.supportedMCSSet[0]);
698 if(pIe)
699 {
700 tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure
701 pHtcap->advCodingCap = dot11HtCap.advCodingCap;
702 pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet;
703 pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave;
704 pHtcap->greenField = dot11HtCap.greenField;
705 pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz;
706 pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz;
707 pHtcap->txSTBC = dot11HtCap.txSTBC;
708 pHtcap->rxSTBC = dot11HtCap.rxSTBC;
709 pHtcap->delayedBA = dot11HtCap.delayedBA ;
710 pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize;
711 pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz;
712 pHtcap->psmp = dot11HtCap.psmp;
713 pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame;
714 pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection;
715 pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor;
716 pHtcap->mpduDensity = dot11HtCap.mpduDensity;
717 palCopyMemory( pMac->hHdd, (void *)pHtcap->supportedMCSSet,
718 (void *)(dot11HtCap.supportedMCSSet),
719 sizeof(pHtcap->supportedMCSSet));
720 pHtcap->pco = dot11HtCap.pco;
721 pHtcap->transitionTime = dot11HtCap.transitionTime;
722 pHtcap->mcsFeedback = dot11HtCap.mcsFeedback;
723 pHtcap->txBF = dot11HtCap.txBF;
724 pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding;
725 pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding;
726 pHtcap->rxZLF = dot11HtCap.rxZLF;
727 pHtcap->txZLF = dot11HtCap.txZLF;
728 pHtcap->implicitTxBF = dot11HtCap.implicitTxBF;
729 pHtcap->calibration = dot11HtCap.calibration;
730 pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF;
731 pHtcap->explicitUncompressedSteeringMatrix =
732 dot11HtCap.explicitUncompressedSteeringMatrix;
733 pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback;
734 pHtcap->explicitUncompressedSteeringMatrixFeedback =
735 dot11HtCap.explicitUncompressedSteeringMatrixFeedback;
736 pHtcap->explicitCompressedSteeringMatrixFeedback =
737 dot11HtCap.explicitCompressedSteeringMatrixFeedback;
738 pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae;
739 pHtcap->uncompressedSteeringMatrixBFAntennae =
740 dot11HtCap.uncompressedSteeringMatrixBFAntennae;
741 pHtcap->compressedSteeringMatrixBFAntennae =
742 dot11HtCap.compressedSteeringMatrixBFAntennae;
743 pHtcap->antennaSelection = dot11HtCap.antennaSelection;
744 pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx;
745 pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx;
746 pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback;
747 pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback;
748 pHtcap->rxAS = dot11HtCap.rxAS;
749 pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs;
750 }
751}
752
753
754void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
755{
756 tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr;
757 tANI_U32 nBytes;
758 tANI_U8 *pFrame;
759 void *pPacket;
760 eHalStatus halstatus;
761 tANI_U8 txFlag = 0;
762 tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data;
763 tANI_U8 noaLen = 0;
764 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
765 tANI_U8 origLen = 0;
766 tANI_U8 sessionId = 0;
767 v_U8_t *pP2PIe = NULL;
768 tpPESession psessionEntry;
769 v_U8_t *pPresenceRspNoaAttr = NULL;
770 v_U8_t *pNewP2PIe = NULL;
771 v_U16_t remainLen = 0;
772
773 nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg);
774
775 limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"),
776 pFc->type, pFc->subType);
777
778 psessionEntry = peFindSessionByBssid(pMac,
779 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
780
781 /* Check for session corresponding to ADDR2 As Supplicant is filling
782 ADDR2 with BSSID */
783 if( NULL == psessionEntry )
784 {
785 psessionEntry = peFindSessionByBssid(pMac,
786 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
787 }
788
789 if( NULL == psessionEntry )
790 {
791 tANI_U8 isSessionActive = 0;
792 tANI_U8 i;
793
794 /* If we are not able to find psessionEntry entry, then try to find
795 active session, if found any active sessions then send the
796 action frame, If no active sessions found then drop the frame */
797 for (i =0; i < pMac->lim.maxBssId;i++)
798 {
799 psessionEntry = peFindSessionBySessionId(pMac,i);
800 if ( NULL != psessionEntry)
801 {
802 isSessionActive = 1;
803 break;
804 }
805 }
806 if( !isSessionActive )
807 {
808 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
809 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
810 return;
811 }
812 }
813
814 if ((SIR_MAC_MGMT_FRAME == pFc->type)&&
815 ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)||
816 (SIR_MAC_MGMT_ACTION == pFc->subType)))
817 {
818 //if this is a probe RSP being sent from wpa_supplicant
819 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
820 {
821 //get proper offset for Probe RSP
822 pP2PIe = limGetP2pIEPtr(pMac,
823 (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
824 nBytes - PROBE_RSP_IE_OFFSET);
825 while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1]))
826 {
827 remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data);
828 if (remainLen > 2)
829 {
830 pNewP2PIe = limGetP2pIEPtr(pMac,
831 pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen);
832 }
833 if (pNewP2PIe)
834 {
835 pP2PIe = pNewP2PIe;
836 pNewP2PIe = NULL;
837 }
838 else
839 {
840 break;
841 }
842 } //end of while
843 }
844 else
845 {
846 if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY ==
847 *((v_U8_t *)pMbMsg->data+ACTION_OFFSET))
848 {
849 tpSirMacP2PActionFrameHdr pActionHdr =
850 (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data +
851 ACTION_OFFSET);
852 if ( palEqualMemory( pMac->hHdd, pActionHdr->Oui,
853 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) &&
854 (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP ==
855 pActionHdr->OuiSubType))
856 { //In case of Presence RSP response
857 pP2PIe = limGetP2pIEPtr(pMac,
858 (v_U8_t *)pMbMsg->data + ACTION_OFFSET +
859 sizeof(tSirMacP2PActionFrameHdr),
860 (nBytes - ACTION_OFFSET -
861 sizeof(tSirMacP2PActionFrameHdr)));
862 if( NULL != pP2PIe )
863 {
864 //extract the presence of NoA attribute inside P2P IE
865 pPresenceRspNoaAttr =
866 limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN,
867 pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE);
868 }
869 }
870 }
871 }
872
873 if (pP2PIe != NULL)
874 {
875 //get NoA attribute stream P2P IE
876 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
877 //need to append NoA attribute in P2P IE
878 if (noaLen > 0)
879 {
880 origLen = pP2PIe[1];
881 //if Presence Rsp has NoAttr
882 if (pPresenceRspNoaAttr)
883 {
884 v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] |
885 (pPresenceRspNoaAttr[2]<<8);
886 /*One byte for attribute, 2bytes for length*/
887 origLen -= (noaAttrLen + 1 + 2);
888 //remove those bytes to copy
889 nBytes -= (noaAttrLen + 1 + 2);
890 //remove NoA from original Len
891 pP2PIe[1] = origLen;
892 }
893 if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH)
894 {
895 //Form the new NoA Byte array in multiple P2P IEs
896 noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream,
897 noaLen,((pP2PIe[1] + (tANI_U16)noaLen)-
898 SIR_MAC_MAX_IE_LENGTH));
899 pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH;
900 }
901 else
902 {
903 pP2PIe[1] += noaLen; //increment the length of P2P IE
904 }
905 nBytes += noaLen;
906 limLog( pMac, LOGE,
907 FL("noaLen=%d origLen=%d pP2PIe=0x%x"
908 " nBytes=%d nBytesToCopy=%d \n"),
909 noaLen,origLen,pP2PIe,nBytes,
910 ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data));
911 }
912 }
913
914 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
915 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700916 limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
Madan Mohan Koyyalamudifb29a5d2012-10-11 12:14:17 -0700917 nBytes - PROBE_RSP_IE_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700919
920 /* The minimum wait for any action frame should be atleast 100 ms.
921 * If supplicant sends action frame at the end of already running remain on channel time
922 * Then there is a chance to miss the response of the frame. So increase the remain on channel
923 * time for all action frame to make sure that we receive the response frame */
924 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
925 (0 != pMbMsg->wait))
926 {
927 if (tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer))
928 {
929 tANI_U32 val = 0;
930 tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
931 /* get the duration from the request */
932 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
933 pMac->lim.gTotalScanDuration = pMbMsg->wait;
934
935 val = SYS_MS_TO_TICKS(pMbMsg->wait);
936
937 limLog(pMac, LOG1,
938 FL("Tx: Extending the gLimRemainOnChannelTimer\n"));
939 if (tx_timer_change(
940 &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0)
941 != TX_SUCCESS)
942 {
943 limLog(pMac, LOGP,
944 FL("Unable to change remain on channel Timer val\n"));
945 return;
946 }
947 else if(TX_SUCCESS != tx_timer_activate(
948 &pMac->lim.limTimers.gLimRemainOnChannelTimer))
949 {
950 limLog(pMac, LOGP,
951 FL("Unable to activate remain on channel Timer\n"));
952 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
953 return;
954 }
955 }
956 else
957 {
958 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
959 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
960 return;
961 }
962 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 }
964
965
966 // Ok-- try to allocate some memory:
967 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
968 (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket);
969 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
970 {
971 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe"
972 " Request.\n"), nBytes );
973 return;
974 }
975
976 // Paranoia:
977 palZeroMemory( pMac->hHdd, pFrame, nBytes );
978
979 if (noaLen > 0)
980 {
981 // Add 2 bytes for length and Arribute field
982 v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) -
983 (v_U8_t *)pMbMsg->data);
984 palCopyMemory( pMac->hHdd, pFrame, pMbMsg->data, nBytesToCopy);
985 palCopyMemory( pMac->hHdd, (pFrame + nBytesToCopy), noaStream, noaLen);
986 palCopyMemory( pMac->hHdd, (pFrame + nBytesToCopy + noaLen),
987 pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen);
988
989 }
990 else
991 {
992 palCopyMemory(pMac->hHdd, pFrame, pMbMsg->data, nBytes);
993 }
994
995 /* Use BD rate 2 for all P2P related frames. As these frames need to go
996 * at OFDM rates. And BD rate2 we configured at 6Mbps.
997 */
998 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
999
Jeff Johnsone7245742012-09-05 17:12:55 -07001000 if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) ||
1001 (pMbMsg->noack)
1002 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 {
1004 halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes,
1005 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1006 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1007 txFlag );
1008
Jeff Johnsone7245742012-09-05 17:12:55 -07001009 if (!pMbMsg->noack)
1010 {
1011 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 halstatus, pMbMsg->sessionId, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001014 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 }
1016 else
1017 {
1018 halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes,
1019 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1020 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1021 limP2PActionCnf, txFlag );
1022
1023 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1024 {
1025 limLog( pMac, LOGE, FL("could not send action frame!\n" ));
1026 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus,
1027 pMbMsg->sessionId, 0);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001028 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 }
1030 else
1031 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001032 pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001033 limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %lu\n" ),
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001034 pMac->lim.mgmtFrameSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07001035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 }
1037 }
1038
1039 return;
1040}
1041
1042
1043void limAbortRemainOnChan(tpAniSirGlobal pMac)
1044{
1045 if(VOS_TRUE == tx_timer_running(
1046 &pMac->lim.limTimers.gLimRemainOnChannelTimer))
1047 {
1048 //TODO check for state and take appropriate actions
1049 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
1050 limProcessRemainOnChnTimeout(pMac);
1051 }
1052 return;
1053}
1054
1055/* Power Save Related Functions */
1056tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1057{
1058 tpP2pPsConfig pNoA;
1059 tpP2pPsParams pMsgNoA;
1060 tSirMsgQ msg;
1061
1062 pNoA = (tpP2pPsConfig) pMsgBuf;
1063
1064 if( eHAL_STATUS_SUCCESS != palAllocateMemory(
1065 pMac->hHdd, (void **) &pMsgNoA, sizeof( tP2pPsConfig )))
1066 {
1067 limLog( pMac, LOGE,
1068 FL( "Unable to allocate memory during NoA Update\n" ));
1069 return eSIR_MEM_ALLOC_FAILED;
1070 }
1071
1072 palZeroMemory( pMac->hHdd, (tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig));
1073 pMsgNoA->opp_ps = pNoA->opp_ps;
1074 pMsgNoA->ctWindow = pNoA->ctWindow;
1075 pMsgNoA->duration = pNoA->duration;
1076 pMsgNoA->interval = pNoA->interval;
1077 pMsgNoA->count = pNoA->count;
1078 pMsgNoA->single_noa_duration = pNoA->single_noa_duration;
1079 pMsgNoA->psSelection = pNoA->psSelection;
1080
Viral Modid86bde22012-12-10 13:09:21 -08001081 msg.type = WDA_SET_P2P_GO_NOA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 msg.reserved = 0;
1083 msg.bodyptr = pMsgNoA;
1084 msg.bodyval = 0;
1085
1086 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1087 {
1088 limLog(pMac, LOGE, FL("halPostMsgApi failed\n"));
1089 return eSIR_FAILURE;
1090 }
1091
1092 return eSIR_SUCCESS;
1093} /*** end __limProcessSmeGoNegReq() ***/
1094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095