blob: bf2ab7747a0cb18888202a166638e88059de4dcb [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 Johnson295189b2012-06-20 16:38:30 -070081
82
83void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
84 tANI_U32 *data);
85void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
86 tANI_U32 *data, tpPESession psessionEntry);
87void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
88 tANI_U32 *data, tpPESession psessionEntry);
89void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data);
90extern tSirRetStatus limSetLinkState(
91 tpAniSirGlobal pMac, tSirLinkState state,
92 tSirMacAddr bssId, tSirMacAddr selfMacAddr,
93 tpSetLinkStateCallback callback, void *callbackArg);
94
95static tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession);
Jeff Johnsone7245742012-09-05 17:12:55 -070096eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess);
Jeff Johnson295189b2012-06-20 16:38:30 -070097/*------------------------------------------------------------------
98 *
99 * Below function is callback function, it is called when
100 * WDA_SET_LINK_STATE_RSP is received from WDI. callback function for
101 * P2P of limSetLinkState
102 *
103 *------------------------------------------------------------------*/
104void limSetLinkStateP2PCallback(tpAniSirGlobal pMac, void *callbackArg)
105{
106 //Send Ready on channel indication to SME
107 if(pMac->lim.gpLimRemainOnChanReq)
108 {
109 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RDY_IND, eHAL_STATUS_SUCCESS,
110 pMac->lim.gpLimRemainOnChanReq->sessionId, 0);
111 }
112 else
113 {
114 //This is possible in case remain on channel is aborted
115 limLog( pMac, LOGE, FL(" NULL pointer of gpLimRemainOnChanReq") );
116 }
117}
118
119/*------------------------------------------------------------------
120 *
121 * Remain on channel req handler. Initiate the INIT_SCAN, CHN_CHANGE
122 * and SET_LINK Request from SME, chnNum and duration to remain on channel.
123 *
124 *------------------------------------------------------------------*/
125
126
127int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg)
128{
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530129
130 /* CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE - Currently removed the special optimization when a concurrent session
131 * exists with operating channel same as P2P listen channel since it was causing issues in P2P search. The reason was
132 * STA-AP link entering BMPS when returning to home channel causing P2P search to miss Probe Reqs and hence not
133 * respond with Probe Rsp causing peer device to NOT find us.
134 * 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
135 */
136#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 tANI_U8 i;
138 tpPESession psessionEntry;
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700140#ifdef WLAN_FEATURE_P2P_INTERNAL
141 tpPESession pP2pSession;
142#endif
143
144 tSirRemainOnChnReq *MsgBuff = (tSirRemainOnChnReq *)pMsg;
145 pMac->lim.gpLimRemainOnChanReq = MsgBuff;
146
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530147#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 for (i =0; i < pMac->lim.maxBssId;i++)
149 {
150 psessionEntry = peFindSessionBySessionId(pMac,i);
151
152 if ( (psessionEntry != NULL) )
153 {
154 if (psessionEntry->currentOperChannel == MsgBuff->chnNum)
155 {
156 tANI_U32 val;
157 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
158
Jeff Johnsone7245742012-09-05 17:12:55 -0700159 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
160 pMac->lim.gTotalScanDuration = MsgBuff->duration;
Jeff Johnson295189b2012-06-20 16:38:30 -0700161
162 /* get the duration from the request */
163 val = SYS_MS_TO_TICKS(MsgBuff->duration);
164
Madan Mohan Koyyalamudi709790c2012-09-24 12:12:51 -0700165 limLog( pMac, LOG2, "Start listen duration = %d", val);
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 if (tx_timer_change(
167 &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0)
168 != TX_SUCCESS)
169 {
170 limLog(pMac, LOGP,
171 FL("Unable to change remain on channel Timer val\n"));
172 goto error;
173 }
174 else if(TX_SUCCESS != tx_timer_activate(
175 &pMac->lim.limTimers.gLimRemainOnChannelTimer))
176 {
177 limLog(pMac, LOGP,
178 FL("Unable to activate remain on channel Timer\n"));
179 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
180 goto error;
181 }
182
183#ifdef WLAN_FEATURE_P2P_INTERNAL
184 //Session is needed to send probe rsp
185 if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &pP2pSession))
186 {
187 limLog( pMac, LOGE, "Unable to create session");
188 goto error;
189 }
190#endif
191
192 if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE,
193 nullBssid, pMac->lim.gSelfMacAddr,
194 limSetLinkStateP2PCallback, NULL)) != eSIR_SUCCESS)
195 {
196 limLog( pMac, LOGE, "Unable to change link state");
197 goto error;
198 }
199 return FALSE;
200 }
201 }
202 }
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530203#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
205 pMac->lim.gLimMlmState = eLIM_MLM_P2P_LISTEN_STATE;
206
207 pMac->lim.gTotalScanDuration = MsgBuff->duration;
208
209 /* 1st we need to suspend link with callback to initiate change channel */
210 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
211 limRemainOnChnlSuspendLinkHdlr, NULL);
212 return FALSE;
213
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530214#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
Jeff Johnson295189b2012-06-20 16:38:30 -0700215error:
216 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
217 /* pMsg is freed by the caller */
218 return FALSE;
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530219#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700220}
221
222
223tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession)
224{
225 tSirRetStatus nSirStatus = eSIR_FAILURE;
226 tpPESession psessionEntry;
227 tANI_U8 sessionId;
228 tANI_U32 val;
229
230 if(pMac->lim.gpLimRemainOnChanReq && ppP2pSession)
231 {
232 if((psessionEntry = peCreateSession(pMac,
233 pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId, 1)) == NULL)
234 {
235 limLog(pMac, LOGE, FL("Session Can not be created \n"));
236 /* send remain on chn failure */
237 return nSirStatus;
238 }
239 /* Store PE sessionId in session Table */
240 psessionEntry->peSessionId = sessionId;
241
242 psessionEntry->limSystemRole = eLIM_P2P_DEVICE_ROLE;
243 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_SUPPORTED_RATES_11A,
244 psessionEntry->rateSet.rate, val , SIR_MAC_MAX_NUMBER_OF_RATES );
245 psessionEntry->rateSet.numRates = val;
246
247 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
248 psessionEntry->extRateSet.rate, val,
249 WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN );
250 psessionEntry->extRateSet.numRates = val;
251
252 sirCopyMacAddr(psessionEntry->selfMacAddr,
253 pMac->lim.gpLimRemainOnChanReq->selfMacAddr);
254
255 psessionEntry->currentOperChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
256 nSirStatus = eSIR_SUCCESS;
257 *ppP2pSession = psessionEntry;
258 }
259
260 return nSirStatus;
261}
262
263
264/*------------------------------------------------------------------
265 *
266 * limSuspenLink callback, on success link suspend, trigger change chn
267 *
268 *
269 *------------------------------------------------------------------*/
270
271tSirRetStatus limRemainOnChnlChangeChnReq(tpAniSirGlobal pMac,
272 eHalStatus status, tANI_U32 *data)
273{
274 tpPESession psessionEntry;
275 tANI_U8 sessionId = 0;
276 tSirRetStatus nSirStatus = eSIR_FAILURE;
277
278 if( NULL == pMac->lim.gpLimRemainOnChanReq )
279 {
280 //RemainOnChannel may have aborted
281 PELOGE(limLog( pMac, LOGE, FL(" gpLimRemainOnChanReq is NULL") );)
282 return nSirStatus;
283 }
284
285 /* The link is not suspended */
286 if (status != eHAL_STATUS_SUCCESS)
287 {
288 PELOGE(limLog( pMac, LOGE, FL(" Suspend link Failure ") );)
289 goto error;
290 }
291
292
293 if((psessionEntry = peFindSessionByBssid(
294 pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) != NULL)
295 {
296 goto change_channel;
297 }
298 else /* Session Entry does not exist for given BSSId */
299 {
300 /* Try to Create a new session */
301 if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &psessionEntry))
302 {
303 limLog(pMac, LOGE, FL("Session Can not be created \n"));
304 /* send remain on chn failure */
305 goto error;
306 }
307 }
308
309change_channel:
310 /* change channel to the requested by RemainOn Chn*/
311 limChangeChannelWithCallback(pMac,
312 pMac->lim.gpLimRemainOnChanReq->chnNum,
313 limRemainOnChnlSetLinkStat, NULL, psessionEntry);
314 return eSIR_SUCCESS;
315
316error:
317 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
318 return eSIR_FAILURE;
319}
320
321void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
322 tANI_U32 *data)
323{
324 limRemainOnChnlChangeChnReq(pMac, status, data);
325 return;
326}
327
328/*------------------------------------------------------------------
329 *
330 * Set the LINK state to LISTEN to allow only PROBE_REQ and Action frames
331 *
332 *------------------------------------------------------------------*/
333void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
334 tANI_U32 *data, tpPESession psessionEntry)
335{
336 tANI_U32 val;
337 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
338 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
339
340 if (status != eHAL_STATUS_SUCCESS)
341 {
342 limLog( pMac, LOGE, "%s: Change channel not successful\n");
343 goto error1;
344 }
345
346 // Start timer here to come back to operating channel.
347 pMac->lim.limTimers.gLimRemainOnChannelTimer.sessionId =
348 psessionEntry->peSessionId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700349 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
350 pMac->lim.gTotalScanDuration = MsgRemainonChannel->duration;
Jeff Johnson295189b2012-06-20 16:38:30 -0700351
352 /* get the duration from the request */
353 val = SYS_MS_TO_TICKS(MsgRemainonChannel->duration);
354
Madan Mohan Koyyalamudi709790c2012-09-24 12:12:51 -0700355 limLog( pMac, LOG2, "Start listen duration = %d", val);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 if (tx_timer_change(&pMac->lim.limTimers.gLimRemainOnChannelTimer,
357 val, 0) != TX_SUCCESS)
358 {
359 /**
360 * Could not change Remain on channel Timer. Log error.
361 */
362 limLog(pMac, LOGP,
363 FL("Unable to change remain on channel Timer val\n"));
364 goto error;
365 }
366
367 if(TX_SUCCESS !=
368 tx_timer_activate(&pMac->lim.limTimers.gLimRemainOnChannelTimer))
369 {
370 limLog( pMac, LOGE,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700371 "%s: remain on channel Timer Start Failed\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 goto error;
373 }
374
375 if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE,nullBssid,
376 pMac->lim.gSelfMacAddr, limSetLinkStateP2PCallback,
377 NULL)) != eSIR_SUCCESS)
378 {
379 limLog( pMac, LOGE, "Unable to change link state");
380 goto error;
381 }
382
383 return;
384error:
385 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
386error1:
387 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
388 return;
389}
390
391/*------------------------------------------------------------------
392 *
Viral Modid86bde22012-12-10 13:09:21 -0800393 * lim Insert NOA timer timeout callback - when timer fires, deactivate it and send
394 * scan rsp to csr/hdd
395 *
396 *------------------------------------------------------------------*/
397void limProcessInsertSingleShotNOATimeout(tpAniSirGlobal pMac)
398{
Viral Modid440e682013-03-06 02:25:31 -0800399 /* timeout means start NOA did not arrive; we need to deactivate and change the timer for
400 * future activations
Viral Modid86bde22012-12-10 13:09:21 -0800401 */
402 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800403
Viral Modid440e682013-03-06 02:25:31 -0800404 /* Even if insert NOA timedout, go ahead and process/send stored SME request */
405 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800406
Viral Modid86bde22012-12-10 13:09:21 -0800407 return;
408}
409
410/*------------------------------------------------------------------
411 *
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 * limchannelchange callback, on success channel change, set the
413 * link_state to LISTEN
414 *
415 *------------------------------------------------------------------*/
416
417void limProcessRemainOnChnTimeout(tpAniSirGlobal pMac)
418{
419 tpPESession psessionEntry;
420 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
421
Jeff Johnsone7245742012-09-05 17:12:55 -0700422 //Timer might get extended while Sending Action Frame
423 //In that case don't process Channel Timeout
424 if (tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer))
425 {
426 limLog( pMac, LOGE,
427 "still timer is running already and not processing limProcessRemainOnChnTimeout");
428 return;
429 }
430
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
432
433 if (NULL == pMac->lim.gpLimRemainOnChanReq)
434 {
435 limLog( pMac, LOGE, "No Remain on channel pending");
436 return;
437 }
438
439 /* get the previous valid LINK state */
440 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
441 pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS)
442 {
443 limLog( pMac, LOGE, "Unable to change link state");
444 return;
445 }
446
447 if (pMac->lim.gLimMlmState != eLIM_MLM_P2P_LISTEN_STATE )
448 {
449 limRemainOnChnRsp(pMac,eHAL_STATUS_SUCCESS, NULL);
450 }
451 else
452 {
453 /* get the session */
454 if((psessionEntry = peFindSessionBySessionId(pMac,
455 pMac->lim.limTimers.gLimRemainOnChannelTimer.sessionId))== NULL)
456 {
457 limLog(pMac, LOGE,
458 FL("Session Does not exist for given sessionID\n"));
459 goto error;
460 }
461
462 limExitRemainOnChannel(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry);
463 return;
464error:
465 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
466 }
467 return;
468}
469
470
471/*------------------------------------------------------------------
472 *
473 * limchannelchange callback, on success channel change, set the link_state
474 * to LISTEN
475 *
476 *------------------------------------------------------------------*/
477
478void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
479 tANI_U32 *data, tpPESession psessionEntry)
480{
481
482 if (status != eHAL_STATUS_SUCCESS)
483 {
484 PELOGE(limLog( pMac, LOGE, "Remain on Channel Failed\n");)
485 goto error;
486 }
487 //Set the resume channel to Any valid channel (invalid).
488 //This will instruct HAL to set it to any previous valid channel.
489 peSetResumeChannel(pMac, 0, 0);
490 limResumeLink(pMac, limRemainOnChnRsp, NULL);
491 return;
492error:
493 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
494 return;
495}
496
497/*------------------------------------------------------------------
498 *
499 * Send remain on channel respone: Success/ Failure
500 *
501 *------------------------------------------------------------------*/
502void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
503{
504 tpPESession psessionEntry;
505 tANI_U8 sessionId;
506 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
507 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
508
509 if ( NULL == MsgRemainonChannel )
510 {
511 PELOGE(limLog( pMac, LOGP,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700512 "%s: No Pointer for Remain on Channel Req\n", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 return;
514 }
515
516 //Incase of the Remain on Channel Failure Case
517 //Cleanup Everything
518 if(eHAL_STATUS_FAILURE == status)
519 {
520 //Deactivate Remain on Channel Timer
521 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
522
523 //Set the Link State to Idle
524 /* get the previous valid LINK state */
525 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
526 pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS)
527 {
528 limLog( pMac, LOGE, "Unable to change link state");
529 }
530
531 pMac->lim.gLimSystemInScanLearnMode = 0;
532 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
533 }
534
535 /* delete the session */
536 if((psessionEntry = peFindSessionByBssid(pMac,
537 MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL)
538 {
539 if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole )
540 {
541 peDeleteSession( pMac, psessionEntry);
542 }
543 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700544
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 /* Post the meessage to Sme */
546 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
547 MsgRemainonChannel->sessionId, 0);
548
549 palFreeMemory( pMac->hHdd, pMac->lim.gpLimRemainOnChanReq );
550 pMac->lim.gpLimRemainOnChanReq = NULL;
551
552 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700553
554 /* If remain on channel timer expired and action frame is pending then
555 * indicaiton confirmation with status failure */
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800556 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700557 {
558 limP2PActionCnf(pMac, 0);
559 }
560
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 return;
562}
563
564/*------------------------------------------------------------------
565 *
566 * Indicate the Mgmt Frame received to SME to HDD callback
567 * handle Probe_req/Action frame currently
568 *
569 *------------------------------------------------------------------*/
570void limSendSmeMgmtFrameInd(
571 tpAniSirGlobal pMac, tANI_U8 frameType,
572 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
Chilam NG571c65a2013-01-19 12:27:36 +0530573 tANI_U32 rxChannel, tpPESession psessionEntry,
574 tANI_S8 rxRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700575{
576 tSirMsgQ mmhMsg;
577 tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL;
578 tANI_U16 length;
579
580 length = sizeof(tSirSmeMgmtFrameInd) + frameLen;
581
582 if( eHAL_STATUS_SUCCESS !=
583 palAllocateMemory( pMac->hHdd, (void **)&pSirSmeMgmtFrame, length ))
584 {
585 limLog(pMac, LOGP,
586 FL("palAllocateMemory failed for eWNI_SME_LISTEN_RSP\n"));
587 return;
588 }
589 palZeroMemory(pMac->hHdd, (void*)pSirSmeMgmtFrame, length);
590
591 pSirSmeMgmtFrame->mesgType = eWNI_SME_MGMT_FRM_IND;
592 pSirSmeMgmtFrame->mesgLen = length;
593 pSirSmeMgmtFrame->sessionId = sessionId;
594 pSirSmeMgmtFrame->frameType = frameType;
Chilam NG571c65a2013-01-19 12:27:36 +0530595 pSirSmeMgmtFrame->rxRssi = rxRssi;
Jeff Johnsone7245742012-09-05 17:12:55 -0700596
Sunil Ravif0998942013-02-04 07:01:12 -0800597 /*
598 * Work around to address LIM sending wrong channel to HDD for p2p action
599 * frames(In case of auto GO) recieved on 5GHz channel.
600 * As RXP has only 4bits to store the channel, we need some mechanism to
601 * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer
602 * is not running and if we get a frame then pass the Go session
603 * operating channel to HDD. Some vendors create separate p2p interface
604 * after group formation. In that case LIM session entry will be NULL for
605 * p2p device address. So search for p2p go session and pass it's
606 * operating channel.
607 * Need to revisit this path in case of GO+CLIENT concurrency.
Jeff Johnsone7245742012-09-05 17:12:55 -0700608 */
Sunil Ravif0998942013-02-04 07:01:12 -0800609 if( VOS_FALSE ==
610 tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer) )
Jeff Johnsone7245742012-09-05 17:12:55 -0700611 {
Sunil Ravif0998942013-02-04 07:01:12 -0800612 tpPESession pTempSessionEntry = psessionEntry;
613 if( ( (NULL != pTempSessionEntry) ||
614 (pTempSessionEntry = limIsApSessionActive(pMac)) ) &&
615 (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) )
616 {
617 rxChannel = pTempSessionEntry->currentOperChannel;
618 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700619 }
Sunil Ravif0998942013-02-04 07:01:12 -0800620
621 pSirSmeMgmtFrame->rxChan = rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700622
623 vos_mem_zero(pSirSmeMgmtFrame->frameBuf,frameLen);
624 vos_mem_copy(pSirSmeMgmtFrame->frameBuf,frame,frameLen);
625
626 mmhMsg.type = eWNI_SME_MGMT_FRM_IND;
627 mmhMsg.bodyptr = pSirSmeMgmtFrame;
628 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700629
630 if(VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer) &&
631 ( (psessionEntry != NULL) && (psessionEntry->pePersona != VOS_P2P_GO_MODE)) &&
632 (frameType == SIR_MAC_MGMT_ACTION))
633 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700634 unsigned int chanWaitTime, vStatus ;
635
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +0530636 limLog( pMac, LOG1, FL("Rx: Extend the gLimRemainOnChannelTimer = %d "),
637 pMac->lim.gTotalScanDuration);
Jeff Johnsone7245742012-09-05 17:12:55 -0700638
639 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
Jeff Johnsone7245742012-09-05 17:12:55 -0700640
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +0530641 chanWaitTime = SYS_MS_TO_TICKS(pMac->lim.gTotalScanDuration);
Jeff Johnsone7245742012-09-05 17:12:55 -0700642 vStatus = tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
643
644 if (VOS_STATUS_SUCCESS != vStatus)
645 {
646 limLog( pMac, LOGE, FL("Rx: Extend the gLimRemainOnChannelTimer"));
647 }
648
649 if (tx_timer_change(&pMac->lim.limTimers.gLimRemainOnChannelTimer, chanWaitTime, 0) != TX_SUCCESS)
650 {
651 limLog( pMac, LOGE, FL("Unable to change the gLimRemainOnChannelTimer"));
652 }
653
654 if (tx_timer_activate(&pMac->lim.limTimers.gLimRemainOnChannelTimer) != 0)
655 {
656 limLog( pMac, LOGE, FL("Unable to active the gLimRemainOnChannelTimer"));
657 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700658 }
659
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
661 return;
662} /*** end limSendSmeListenRsp() ***/
663
664
665eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
666{
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800667 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700668 {
669 /* The session entry might be invalid(0xff) action confirmation received after
670 * remain on channel timer expired */
671 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
672 (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL),
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800673 pMac->lim.mgmtFrameSessionId, 0);
674 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnsone7245742012-09-05 17:12:55 -0700675 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700676
677 return eHAL_STATUS_SUCCESS;
678}
679
680
Jeff Johnsone7245742012-09-05 17:12:55 -0700681void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes)
Jeff Johnson295189b2012-06-20 16:38:30 -0700682{
683 v_U8_t *pIe=NULL;
684 tDot11fIEHTCaps dot11HtCap;
685
Jeff Johnsone7245742012-09-05 17:12:55 -0700686 PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap);
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes,
688 DOT11F_EID_HTCAPS,ONE_BYTE);
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700689 limLog( pMac, LOG2, FL("pIe 0x%x dot11HtCap.supportedMCSSet[0]=0x%x"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 (tANI_U32)pIe,dot11HtCap.supportedMCSSet[0]);
691 if(pIe)
692 {
693 tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure
694 pHtcap->advCodingCap = dot11HtCap.advCodingCap;
695 pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet;
696 pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave;
697 pHtcap->greenField = dot11HtCap.greenField;
698 pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz;
699 pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz;
700 pHtcap->txSTBC = dot11HtCap.txSTBC;
701 pHtcap->rxSTBC = dot11HtCap.rxSTBC;
702 pHtcap->delayedBA = dot11HtCap.delayedBA ;
703 pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize;
704 pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz;
705 pHtcap->psmp = dot11HtCap.psmp;
706 pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame;
707 pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection;
708 pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor;
709 pHtcap->mpduDensity = dot11HtCap.mpduDensity;
710 palCopyMemory( pMac->hHdd, (void *)pHtcap->supportedMCSSet,
711 (void *)(dot11HtCap.supportedMCSSet),
712 sizeof(pHtcap->supportedMCSSet));
713 pHtcap->pco = dot11HtCap.pco;
714 pHtcap->transitionTime = dot11HtCap.transitionTime;
715 pHtcap->mcsFeedback = dot11HtCap.mcsFeedback;
716 pHtcap->txBF = dot11HtCap.txBF;
717 pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding;
718 pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding;
719 pHtcap->rxZLF = dot11HtCap.rxZLF;
720 pHtcap->txZLF = dot11HtCap.txZLF;
721 pHtcap->implicitTxBF = dot11HtCap.implicitTxBF;
722 pHtcap->calibration = dot11HtCap.calibration;
723 pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF;
724 pHtcap->explicitUncompressedSteeringMatrix =
725 dot11HtCap.explicitUncompressedSteeringMatrix;
726 pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback;
727 pHtcap->explicitUncompressedSteeringMatrixFeedback =
728 dot11HtCap.explicitUncompressedSteeringMatrixFeedback;
729 pHtcap->explicitCompressedSteeringMatrixFeedback =
730 dot11HtCap.explicitCompressedSteeringMatrixFeedback;
731 pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae;
732 pHtcap->uncompressedSteeringMatrixBFAntennae =
733 dot11HtCap.uncompressedSteeringMatrixBFAntennae;
734 pHtcap->compressedSteeringMatrixBFAntennae =
735 dot11HtCap.compressedSteeringMatrixBFAntennae;
736 pHtcap->antennaSelection = dot11HtCap.antennaSelection;
737 pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx;
738 pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx;
739 pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback;
740 pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback;
741 pHtcap->rxAS = dot11HtCap.rxAS;
742 pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs;
743 }
744}
745
746
747void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
748{
749 tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr;
750 tANI_U32 nBytes;
751 tANI_U8 *pFrame;
752 void *pPacket;
753 eHalStatus halstatus;
754 tANI_U8 txFlag = 0;
755 tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data;
756 tANI_U8 noaLen = 0;
757 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
758 tANI_U8 origLen = 0;
759 tANI_U8 sessionId = 0;
760 v_U8_t *pP2PIe = NULL;
761 tpPESession psessionEntry;
762 v_U8_t *pPresenceRspNoaAttr = NULL;
763 v_U8_t *pNewP2PIe = NULL;
764 v_U16_t remainLen = 0;
765
766 nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg);
767
768 limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"),
769 pFc->type, pFc->subType);
770
771 psessionEntry = peFindSessionByBssid(pMac,
772 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
773
774 /* Check for session corresponding to ADDR2 As Supplicant is filling
775 ADDR2 with BSSID */
776 if( NULL == psessionEntry )
777 {
778 psessionEntry = peFindSessionByBssid(pMac,
779 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
780 }
781
782 if( NULL == psessionEntry )
783 {
784 tANI_U8 isSessionActive = 0;
785 tANI_U8 i;
786
787 /* If we are not able to find psessionEntry entry, then try to find
788 active session, if found any active sessions then send the
789 action frame, If no active sessions found then drop the frame */
790 for (i =0; i < pMac->lim.maxBssId;i++)
791 {
792 psessionEntry = peFindSessionBySessionId(pMac,i);
793 if ( NULL != psessionEntry)
794 {
795 isSessionActive = 1;
796 break;
797 }
798 }
799 if( !isSessionActive )
800 {
801 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
802 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
803 return;
804 }
805 }
806
807 if ((SIR_MAC_MGMT_FRAME == pFc->type)&&
808 ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)||
809 (SIR_MAC_MGMT_ACTION == pFc->subType)))
810 {
811 //if this is a probe RSP being sent from wpa_supplicant
812 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
813 {
814 //get proper offset for Probe RSP
815 pP2PIe = limGetP2pIEPtr(pMac,
816 (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
817 nBytes - PROBE_RSP_IE_OFFSET);
818 while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1]))
819 {
820 remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data);
821 if (remainLen > 2)
822 {
823 pNewP2PIe = limGetP2pIEPtr(pMac,
824 pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen);
825 }
826 if (pNewP2PIe)
827 {
828 pP2PIe = pNewP2PIe;
829 pNewP2PIe = NULL;
830 }
831 else
832 {
833 break;
834 }
835 } //end of while
836 }
837 else
838 {
839 if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY ==
840 *((v_U8_t *)pMbMsg->data+ACTION_OFFSET))
841 {
842 tpSirMacP2PActionFrameHdr pActionHdr =
843 (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data +
844 ACTION_OFFSET);
845 if ( palEqualMemory( pMac->hHdd, pActionHdr->Oui,
846 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) &&
847 (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP ==
848 pActionHdr->OuiSubType))
849 { //In case of Presence RSP response
850 pP2PIe = limGetP2pIEPtr(pMac,
851 (v_U8_t *)pMbMsg->data + ACTION_OFFSET +
852 sizeof(tSirMacP2PActionFrameHdr),
853 (nBytes - ACTION_OFFSET -
854 sizeof(tSirMacP2PActionFrameHdr)));
855 if( NULL != pP2PIe )
856 {
857 //extract the presence of NoA attribute inside P2P IE
858 pPresenceRspNoaAttr =
859 limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN,
860 pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE);
861 }
862 }
863 }
864 }
865
866 if (pP2PIe != NULL)
867 {
868 //get NoA attribute stream P2P IE
869 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
870 //need to append NoA attribute in P2P IE
871 if (noaLen > 0)
872 {
873 origLen = pP2PIe[1];
874 //if Presence Rsp has NoAttr
875 if (pPresenceRspNoaAttr)
876 {
877 v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] |
878 (pPresenceRspNoaAttr[2]<<8);
879 /*One byte for attribute, 2bytes for length*/
880 origLen -= (noaAttrLen + 1 + 2);
881 //remove those bytes to copy
882 nBytes -= (noaAttrLen + 1 + 2);
883 //remove NoA from original Len
884 pP2PIe[1] = origLen;
885 }
886 if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH)
887 {
888 //Form the new NoA Byte array in multiple P2P IEs
889 noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream,
890 noaLen,((pP2PIe[1] + (tANI_U16)noaLen)-
891 SIR_MAC_MAX_IE_LENGTH));
892 pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH;
893 }
894 else
895 {
896 pP2PIe[1] += noaLen; //increment the length of P2P IE
897 }
898 nBytes += noaLen;
899 limLog( pMac, LOGE,
900 FL("noaLen=%d origLen=%d pP2PIe=0x%x"
901 " nBytes=%d nBytesToCopy=%d \n"),
902 noaLen,origLen,pP2PIe,nBytes,
903 ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data));
904 }
905 }
906
907 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
908 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700909 limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
Madan Mohan Koyyalamudifb29a5d2012-10-11 12:14:17 -0700910 nBytes - PROBE_RSP_IE_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700912
913 /* The minimum wait for any action frame should be atleast 100 ms.
914 * If supplicant sends action frame at the end of already running remain on channel time
915 * Then there is a chance to miss the response of the frame. So increase the remain on channel
916 * time for all action frame to make sure that we receive the response frame */
917 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
918 (0 != pMbMsg->wait))
919 {
920 if (tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer))
921 {
922 tANI_U32 val = 0;
923 tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
924 /* get the duration from the request */
925 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
926 pMac->lim.gTotalScanDuration = pMbMsg->wait;
927
928 val = SYS_MS_TO_TICKS(pMbMsg->wait);
929
930 limLog(pMac, LOG1,
931 FL("Tx: Extending the gLimRemainOnChannelTimer\n"));
932 if (tx_timer_change(
933 &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0)
934 != TX_SUCCESS)
935 {
936 limLog(pMac, LOGP,
937 FL("Unable to change remain on channel Timer val\n"));
938 return;
939 }
940 else if(TX_SUCCESS != tx_timer_activate(
941 &pMac->lim.limTimers.gLimRemainOnChannelTimer))
942 {
943 limLog(pMac, LOGP,
944 FL("Unable to activate remain on channel Timer\n"));
945 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
946 return;
947 }
948 }
949 else
950 {
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +0530951 limLog(pMac, LOGE,
952 FL("Failed to Send Action frame \n"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700953 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
954 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
955 return;
956 }
957 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 }
959
960
961 // Ok-- try to allocate some memory:
962 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
963 (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket);
964 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
965 {
966 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe"
967 " Request.\n"), nBytes );
968 return;
969 }
970
971 // Paranoia:
972 palZeroMemory( pMac->hHdd, pFrame, nBytes );
973
974 if (noaLen > 0)
975 {
976 // Add 2 bytes for length and Arribute field
977 v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) -
978 (v_U8_t *)pMbMsg->data);
979 palCopyMemory( pMac->hHdd, pFrame, pMbMsg->data, nBytesToCopy);
980 palCopyMemory( pMac->hHdd, (pFrame + nBytesToCopy), noaStream, noaLen);
981 palCopyMemory( pMac->hHdd, (pFrame + nBytesToCopy + noaLen),
982 pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen);
983
984 }
985 else
986 {
987 palCopyMemory(pMac->hHdd, pFrame, pMbMsg->data, nBytes);
988 }
989
990 /* Use BD rate 2 for all P2P related frames. As these frames need to go
991 * at OFDM rates. And BD rate2 we configured at 6Mbps.
992 */
993 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
994
Jeff Johnsone7245742012-09-05 17:12:55 -0700995 if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) ||
996 (pMbMsg->noack)
997 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 {
999 halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes,
1000 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1001 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1002 txFlag );
1003
Jeff Johnsone7245742012-09-05 17:12:55 -07001004 if (!pMbMsg->noack)
1005 {
1006 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 halstatus, pMbMsg->sessionId, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001008 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001009 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 }
1011 else
1012 {
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +05301013 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes,
1015 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1016 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1017 limP2PActionCnf, txFlag );
1018
1019 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1020 {
1021 limLog( pMac, LOGE, FL("could not send action frame!\n" ));
1022 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus,
1023 pMbMsg->sessionId, 0);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001024 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 }
1026 else
1027 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001028 pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001029 limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %lu\n" ),
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001030 pMac->lim.mgmtFrameSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07001031
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 }
1033 }
1034
1035 return;
1036}
1037
1038
1039void limAbortRemainOnChan(tpAniSirGlobal pMac)
1040{
1041 if(VOS_TRUE == tx_timer_running(
1042 &pMac->lim.limTimers.gLimRemainOnChannelTimer))
1043 {
1044 //TODO check for state and take appropriate actions
1045 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
1046 limProcessRemainOnChnTimeout(pMac);
1047 }
1048 return;
1049}
1050
1051/* Power Save Related Functions */
1052tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1053{
1054 tpP2pPsConfig pNoA;
1055 tpP2pPsParams pMsgNoA;
1056 tSirMsgQ msg;
1057
1058 pNoA = (tpP2pPsConfig) pMsgBuf;
1059
1060 if( eHAL_STATUS_SUCCESS != palAllocateMemory(
1061 pMac->hHdd, (void **) &pMsgNoA, sizeof( tP2pPsConfig )))
1062 {
1063 limLog( pMac, LOGE,
1064 FL( "Unable to allocate memory during NoA Update\n" ));
1065 return eSIR_MEM_ALLOC_FAILED;
1066 }
1067
1068 palZeroMemory( pMac->hHdd, (tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig));
1069 pMsgNoA->opp_ps = pNoA->opp_ps;
1070 pMsgNoA->ctWindow = pNoA->ctWindow;
1071 pMsgNoA->duration = pNoA->duration;
1072 pMsgNoA->interval = pNoA->interval;
1073 pMsgNoA->count = pNoA->count;
1074 pMsgNoA->single_noa_duration = pNoA->single_noa_duration;
1075 pMsgNoA->psSelection = pNoA->psSelection;
1076
Viral Modid86bde22012-12-10 13:09:21 -08001077 msg.type = WDA_SET_P2P_GO_NOA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 msg.reserved = 0;
1079 msg.bodyptr = pMsgNoA;
1080 msg.bodyval = 0;
1081
1082 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1083 {
1084 limLog(pMac, LOGE, FL("halPostMsgApi failed\n"));
1085 return eSIR_FAILURE;
1086 }
1087
1088 return eSIR_SUCCESS;
1089} /*** end __limProcessSmeGoNegReq() ***/
1090
Jeff Johnson295189b2012-06-20 16:38:30 -07001091