blob: b23b55e9f777a0f5491dc05c479db8cf51536b0e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 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.
Jeff Johnson295189b2012-06-20 16:38:30 -070020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/*===========================================================================
29 L I M _ P 2 P . C
30
31 OVERVIEW:
32
33 This software unit holds the implementation of the WLAN Protocol Engine for
34 P2P.
35
Jeff Johnson295189b2012-06-20 16:38:30 -070036===========================================================================*/
37
38/*===========================================================================
39
40 EDIT HISTORY FOR FILE
41
42
43 This section contains comments describing changes made to the module.
44 Notice that changes are listed in reverse chronological order.
45
46
47 $Header$$DateTime$$Author$
48
49
50 when who what, where, why
51---------- --- --------------------------------------------------------
522011-05-02 djindal Corrected file indentation and changed remain on channel
53 handling for concurrency.
54===========================================================================*/
55
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "limUtils.h"
58#include "limSessionUtils.h"
59#include "wlan_qct_wda.h"
60
61#define PROBE_RSP_IE_OFFSET 36
62#define BSSID_OFFSET 16
63#define ADDR2_OFFSET 10
64#define ACTION_OFFSET 24
Jeff Johnson295189b2012-06-20 16:38:30 -070065
Madan Mohan Koyyalamudi98b82ce2013-07-11 17:03:55 +053066/* A DFS channel can be ACTIVE for max 9000 msec, from the last
Gopichand Nakkalad492d202013-05-10 02:50:47 +053067 received Beacon/Prpbe Resp. */
Madan Mohan Koyyalamudi98b82ce2013-07-11 17:03:55 +053068#define MAX_TIME_TO_BE_ACTIVE_CHANNEL 9000
Gopichand Nakkalad492d202013-05-10 02:50:47 +053069
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +053070#define REMAIN_ON_CHANNEL_UNKNOWN_ACTION_CATEGORY 0x20
71#define VENDOR_SPECIFIC_ELEMENT_ID 221
72#define REMAIN_ON_CHANNEL_MSG_SIZE 55
73#define REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME 1
74#define REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME 2
Jeff Johnson295189b2012-06-20 16:38:30 -070075
76void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
77 tANI_U32 *data);
78void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
79 tANI_U32 *data, tpPESession psessionEntry);
80void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
81 tANI_U32 *data, tpPESession psessionEntry);
82void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data);
83extern tSirRetStatus limSetLinkState(
84 tpAniSirGlobal pMac, tSirLinkState state,
85 tSirMacAddr bssId, tSirMacAddr selfMacAddr,
86 tpSetLinkStateCallback callback, void *callbackArg);
87
88static tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession);
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +053089eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, void *pData);
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +053090
91/*----------------------------------------------------------------------------
92 *
93 * The function limSendRemainOnChannelDebugMarkerFrame, prepares Marker frame
94 * for Start and End of remain on channel with RemainOnChannelMsg as Vendor
95 * Specific information element of the frame.
96 *
97 *----------------------------------------------------------------------------*/
98tSirRetStatus limSendRemainOnChannelDebugMarkerFrame(tpAniSirGlobal pMac,
99 tANI_U8 *remainOnChannelMsg)
100{
101 tSirMacAddr magicMacAddr= {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
102 tANI_U32 nBytes, nPayload;
103 tSirRetStatus nSirStatus;
104 tANI_U8 *pFrame;
105 void *pPacket;
106 eHalStatus halstatus;
107 tANI_U8 txFlag = 0;
108 publicVendorSpecific *pPublicVendorSpecific;
109
110 pPublicVendorSpecific = vos_mem_malloc(sizeof(publicVendorSpecific));
111 if( pPublicVendorSpecific == NULL )
112 {
113 limLog( pMac, LOGE,
114 FL( "Unable to allocate memory for Vendor specific information"
115 " element" ) );
116 return eSIR_MEM_ALLOC_FAILED;
117 }
118 // Assigning Action category code as unknown as this is debug marker frame
119 pPublicVendorSpecific->category = REMAIN_ON_CHANNEL_UNKNOWN_ACTION_CATEGORY;
120 pPublicVendorSpecific->elementid = VENDOR_SPECIFIC_ELEMENT_ID;
121 pPublicVendorSpecific->length = strlen(remainOnChannelMsg);
122
123 nPayload = sizeof(publicVendorSpecific) + pPublicVendorSpecific->length;
124
125 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
126
127 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
128 ( tANI_U16 )nBytes, ( void** ) &pFrame,
129 ( void** ) &pPacket );
130 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
131 {
132 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Remain"
133 " on channel action frame."), nBytes );
134 nSirStatus = eSIR_MEM_ALLOC_FAILED;
135 goto end;
136 }
137 vos_mem_zero( pFrame, nBytes );
138
139 // Populate frame with MAC header
140 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
141 SIR_MAC_MGMT_ACTION, magicMacAddr,
142 pMac->lim.gSelfMacAddr);
143 if ( eSIR_SUCCESS != nSirStatus )
144 {
145 limLog( pMac, LOGE, FL("Failed to populate the buffer descriptor for a"
146 " Action frame for remain on channel.") );
147 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
148 ( void* ) pFrame, ( void* ) pPacket );
149 goto end;
150 }
151
152 // Copy Public Vendor specific fields to frame's information element
153 vos_mem_copy( (pFrame + (sizeof( tSirMacMgmtHdr ))),
154 pPublicVendorSpecific, sizeof(publicVendorSpecific) );
155 // Copy Remain On channel message to Vendor Specific information field
156 vos_mem_copy( (pFrame + (nBytes - pPublicVendorSpecific->length)),
157 remainOnChannelMsg, pPublicVendorSpecific->length );
158
159 halstatus = halTxFrame( pMac, pPacket,
160 ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
161 HAL_TXRX_FRM_802_11_MGMT,
162 ANI_TXDIR_TODS,
163 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
164 limTxComplete, pFrame, txFlag );
165 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
166 {
167 limLog( pMac, LOGE, FL("could not send marker frame for"
168 " remain on channel!" ));
169 //Pkt will be freed up by the callback
170 nSirStatus = eSIR_FAILURE;
171 goto end;
172 }
173
174 nSirStatus = eSIR_SUCCESS;
175
176end:
177 vos_mem_free( pPublicVendorSpecific );
178 return nSirStatus;
179}
180
181/*-------------------------------------------------------------------------
182 *
183 * This function forms message for start of remain on channel with channel
184 * number, duration and sequence number. This message is added as data of
185 * vendor specific information element of Debug Marker Frame. Message will
186 * be in form "START-REMAIN-ON-CHANNEL<first/second-frame>-CHN=<channel>"
187 * "-FOR-DUR=<duraion>-SEQ=<sequence-num>"
188 *
189 *-------------------------------------------------------------------------*/
190eHalStatus limPrepareAndSendStartRemainOnChannelMsg(tpAniSirGlobal pMac,
191 tSirRemainOnChnReq *MsgRemainonChannel, tANI_U8 id)
192{
193 tANI_U8 *startRemainOnChannelMsg;
194 eHalStatus status = eHAL_STATUS_SUCCESS;
195
196 startRemainOnChannelMsg = vos_mem_malloc( REMAIN_ON_CHANNEL_MSG_SIZE );
197 if( NULL == startRemainOnChannelMsg )
198 {
199 limLog(pMac, LOGE,
200 FL("Unable to allocate memory for remain on channel message"));
201 return eHAL_STATUS_FAILURE;
202 }
203
204 snprintf(startRemainOnChannelMsg, REMAIN_ON_CHANNEL_MSG_SIZE,
205 "START-REMAIN-ON-CHANNEL%d-CHN=%d-FOR-DUR=%d-SEQ=%d",
206 id, MsgRemainonChannel->chnNum, MsgRemainonChannel->duration,
207 pMac->lim.remOnChnSeqNum);
208
209 if( eSIR_FAILURE == limSendRemainOnChannelDebugMarkerFrame(pMac,
210 startRemainOnChannelMsg) )
211 {
212 limLog( pMac, LOGE,
213 "%s: Could not send %d debug marker frame at start"
214 " of remain on channel", __func__, id);
215 status = eHAL_STATUS_FAILURE;
216 }
217 vos_mem_free( startRemainOnChannelMsg );
218
219 return status;
220
221}
222
223/*----------------------------------------------------------------------------
224 *
225 * This function forms message for cancel of remain on channel. This message
226 * is added as data of Vendor Specific information element of debug marker
227 * frame.Message will be in form "CANCEL-REMAIN-ON-CHANNEL<first/second-frame>"
228 * "-SEQ=<sequence-num>"
229 *
230 *----------------------------------------------------------------------------*/
231eHalStatus limPrepareAndSendCancelRemainOnChannelMsg(tpAniSirGlobal pMac,
232 tANI_U8 id)
233{
234 tANI_U8 *cancelRemainOnChannelMsg;
235 eHalStatus status = eHAL_STATUS_SUCCESS;
236
237 cancelRemainOnChannelMsg = vos_mem_malloc( REMAIN_ON_CHANNEL_MSG_SIZE );
238 if( NULL == cancelRemainOnChannelMsg )
239 {
240 limLog( pMac, LOGE,
241 FL( "Unable to allocate memory for end of"
242 " remain on channel message" ));
243 return eHAL_STATUS_FAILURE;
244 }
245
246 snprintf(cancelRemainOnChannelMsg, REMAIN_ON_CHANNEL_MSG_SIZE,
247 "CANCEL-REMAIN-ON-CHANNEL%d-SEQ=%d",
248 id, pMac->lim.remOnChnSeqNum);
249 if( eSIR_FAILURE == limSendRemainOnChannelDebugMarkerFrame(pMac,
250 cancelRemainOnChannelMsg) )
251 {
252 limLog( pMac, LOGE,
253 "%s: Could not send %d marker frame to debug cancel"
254 " remain on channel", __func__, id);
255 status = eHAL_STATUS_FAILURE;
256 }
257 vos_mem_free( cancelRemainOnChannelMsg );
258
259 return status;
260
261}
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263/*------------------------------------------------------------------
264 *
265 * Below function is callback function, it is called when
266 * WDA_SET_LINK_STATE_RSP is received from WDI. callback function for
267 * P2P of limSetLinkState
268 *
269 *------------------------------------------------------------------*/
270void limSetLinkStateP2PCallback(tpAniSirGlobal pMac, void *callbackArg)
271{
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530272 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 //Send Ready on channel indication to SME
275 if(pMac->lim.gpLimRemainOnChanReq)
276 {
277 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RDY_IND, eHAL_STATUS_SUCCESS,
278 pMac->lim.gpLimRemainOnChanReq->sessionId, 0);
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530279 if(pMac->lim.gDebugP2pRemainOnChannel)
280 {
281 if( eHAL_STATUS_SUCCESS == limPrepareAndSendStartRemainOnChannelMsg(
282 pMac,
283 MsgRemainonChannel,
284 REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME) )
285 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530286 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530287 "%s: Successfully sent 2nd Marker frame "
288 "seq num = %d on start ROC", __func__,
289 pMac->lim.remOnChnSeqNum);
290 }
291 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 }
293 else
294 {
295 //This is possible in case remain on channel is aborted
296 limLog( pMac, LOGE, FL(" NULL pointer of gpLimRemainOnChanReq") );
297 }
298}
299
300/*------------------------------------------------------------------
301 *
302 * Remain on channel req handler. Initiate the INIT_SCAN, CHN_CHANGE
303 * and SET_LINK Request from SME, chnNum and duration to remain on channel.
304 *
305 *------------------------------------------------------------------*/
306
307
308int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg)
309{
Pratik Bhalgata1bf8bb2012-11-22 17:02:26 +0530310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312 tSirRemainOnChnReq *MsgBuff = (tSirRemainOnChnReq *)pMsg;
313 pMac->lim.gpLimRemainOnChanReq = MsgBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
315 pMac->lim.gLimMlmState = eLIM_MLM_P2P_LISTEN_STATE;
316
317 pMac->lim.gTotalScanDuration = MsgBuff->duration;
318
319 /* 1st we need to suspend link with callback to initiate change channel */
320 limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
321 limRemainOnChnlSuspendLinkHdlr, NULL);
322 return FALSE;
323
Jeff Johnson295189b2012-06-20 16:38:30 -0700324}
325
326
327tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession)
328{
329 tSirRetStatus nSirStatus = eSIR_FAILURE;
330 tpPESession psessionEntry;
331 tANI_U8 sessionId;
332 tANI_U32 val;
333
334 if(pMac->lim.gpLimRemainOnChanReq && ppP2pSession)
335 {
336 if((psessionEntry = peCreateSession(pMac,
337 pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId, 1)) == NULL)
338 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700339 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 /* send remain on chn failure */
341 return nSirStatus;
342 }
343 /* Store PE sessionId in session Table */
344 psessionEntry->peSessionId = sessionId;
345
346 psessionEntry->limSystemRole = eLIM_P2P_DEVICE_ROLE;
347 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_SUPPORTED_RATES_11A,
348 psessionEntry->rateSet.rate, val , SIR_MAC_MAX_NUMBER_OF_RATES );
349 psessionEntry->rateSet.numRates = val;
350
351 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
352 psessionEntry->extRateSet.rate, val,
353 WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN );
354 psessionEntry->extRateSet.numRates = val;
355
356 sirCopyMacAddr(psessionEntry->selfMacAddr,
357 pMac->lim.gpLimRemainOnChanReq->selfMacAddr);
358
359 psessionEntry->currentOperChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
360 nSirStatus = eSIR_SUCCESS;
361 *ppP2pSession = psessionEntry;
362 }
363
364 return nSirStatus;
365}
366
367
368/*------------------------------------------------------------------
369 *
370 * limSuspenLink callback, on success link suspend, trigger change chn
371 *
372 *
373 *------------------------------------------------------------------*/
374
375tSirRetStatus limRemainOnChnlChangeChnReq(tpAniSirGlobal pMac,
376 eHalStatus status, tANI_U32 *data)
377{
378 tpPESession psessionEntry;
379 tANI_U8 sessionId = 0;
380 tSirRetStatus nSirStatus = eSIR_FAILURE;
381
382 if( NULL == pMac->lim.gpLimRemainOnChanReq )
383 {
384 //RemainOnChannel may have aborted
385 PELOGE(limLog( pMac, LOGE, FL(" gpLimRemainOnChanReq is NULL") );)
386 return nSirStatus;
387 }
388
389 /* The link is not suspended */
390 if (status != eHAL_STATUS_SUCCESS)
391 {
392 PELOGE(limLog( pMac, LOGE, FL(" Suspend link Failure ") );)
393 goto error;
394 }
395
396
397 if((psessionEntry = peFindSessionByBssid(
398 pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) != NULL)
399 {
400 goto change_channel;
401 }
402 else /* Session Entry does not exist for given BSSId */
403 {
404 /* Try to Create a new session */
405 if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &psessionEntry))
406 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700407 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 /* send remain on chn failure */
409 goto error;
410 }
411 }
412
413change_channel:
414 /* change channel to the requested by RemainOn Chn*/
415 limChangeChannelWithCallback(pMac,
416 pMac->lim.gpLimRemainOnChanReq->chnNum,
417 limRemainOnChnlSetLinkStat, NULL, psessionEntry);
418 return eSIR_SUCCESS;
419
420error:
421 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
422 return eSIR_FAILURE;
423}
424
425void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
426 tANI_U32 *data)
427{
428 limRemainOnChnlChangeChnReq(pMac, status, data);
429 return;
430}
431
432/*------------------------------------------------------------------
433 *
434 * Set the LINK state to LISTEN to allow only PROBE_REQ and Action frames
435 *
436 *------------------------------------------------------------------*/
437void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
438 tANI_U32 *data, tpPESession psessionEntry)
439{
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
441 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
442
443 if (status != eHAL_STATUS_SUCCESS)
444 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800445 limLog( pMac, LOGE, FL("Change channel not successful"));
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530446 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 }
448
449 // Start timer here to come back to operating channel.
Jeff Johnsone7245742012-09-05 17:12:55 -0700450 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
451 pMac->lim.gTotalScanDuration = MsgRemainonChannel->duration;
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530452 if (pMac->lim.gDebugP2pRemainOnChannel)
453 {
454 pMac->lim.remOnChnSeqNum++;
455 if( eHAL_STATUS_SUCCESS == limPrepareAndSendStartRemainOnChannelMsg(
456 pMac, MsgRemainonChannel,
457 REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME) )
458 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530459 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530460 "%s: Successfully sent 1st marker frame with seq num = %d"
461 " on start ROC", __func__, pMac->lim.remOnChnSeqNum);
462 }
463 }
464
Gopichand Nakkala924e4552013-05-08 19:18:14 +0530465 if ((limSetLinkState(pMac, MsgRemainonChannel->isProbeRequestAllowed?
466 eSIR_LINK_LISTEN_STATE:eSIR_LINK_SEND_ACTION_STATE,nullBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 pMac->lim.gSelfMacAddr, limSetLinkStateP2PCallback,
468 NULL)) != eSIR_SUCCESS)
469 {
470 limLog( pMac, LOGE, "Unable to change link state");
471 goto error;
472 }
473
474 return;
475error:
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
477 return;
478}
479
480/*------------------------------------------------------------------
481 *
Viral Modid86bde22012-12-10 13:09:21 -0800482 * lim Insert NOA timer timeout callback - when timer fires, deactivate it and send
483 * scan rsp to csr/hdd
484 *
485 *------------------------------------------------------------------*/
486void limProcessInsertSingleShotNOATimeout(tpAniSirGlobal pMac)
487{
Viral Modid440e682013-03-06 02:25:31 -0800488 /* timeout means start NOA did not arrive; we need to deactivate and change the timer for
489 * future activations
Viral Modid86bde22012-12-10 13:09:21 -0800490 */
491 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800492
Viral Modid440e682013-03-06 02:25:31 -0800493 /* Even if insert NOA timedout, go ahead and process/send stored SME request */
494 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800495
Viral Modid86bde22012-12-10 13:09:21 -0800496 return;
497}
498
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530499/*-----------------------------------------------------------------
500 * lim Insert Timer callback function to check active DFS channels
501 * and convert them to passive channels if there was no
502 * beacon/proberesp for MAX_TIME_TO_BE_ACTIVE_CHANNEL time
503 *------------------------------------------------------------------*/
504void limConvertActiveChannelToPassiveChannel(tpAniSirGlobal pMac )
505{
506 tANI_U32 currentTime;
507 tANI_U32 lastTime = 0;
508 tANI_U32 timeDiff;
509 tANI_U8 i;
510 currentTime = vos_timer_get_system_time();
511 for (i = 1; i < SIR_MAX_24G_5G_CHANNEL_RANGE ; i++)
512 {
513 if ((pMac->lim.dfschannelList.timeStamp[i]) != 0)
514 {
515 lastTime = pMac->lim.dfschannelList.timeStamp[i];
516 if (currentTime >= lastTime)
517 {
518 timeDiff = (currentTime - lastTime);
519 }
520 else
521 {
522 timeDiff = (0xFFFFFFFF - lastTime) + currentTime;
523 }
524
525 if (timeDiff >= MAX_TIME_TO_BE_ACTIVE_CHANNEL)
526 {
527 limCovertChannelScanType( pMac, i,FALSE);
528 pMac->lim.dfschannelList.timeStamp[i] = 0;
529 }
530 }
531 }
532 /* lastTime is zero if there is no DFS active channels in the list.
533 * If this is non zero then we have active DFS channels so restart the timer.
534 */
535 if (lastTime != 0)
536 {
537 if (tx_timer_activate(
538 &pMac->lim.limTimers.gLimActiveToPassiveChannelTimer)
539 != TX_SUCCESS)
540 {
541 limLog(pMac, LOGE, FL("Could not activate Active to Passive Channel timer"));
542 }
543 }
544
545 return;
546
547}
548
Viral Modid86bde22012-12-10 13:09:21 -0800549/*------------------------------------------------------------------
550 *
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530551 * limSetLinkState callback function.
552 *
553 *------------------------------------------------------------------*/
554void limSetlinkStateCallback(tpAniSirGlobal pMac, void *callbackArg)
555{
556 if(pMac->lim.gDebugP2pRemainOnChannel)
557 {
558 if (eHAL_STATUS_SUCCESS == limPrepareAndSendCancelRemainOnChannelMsg(
559 pMac,
560 REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME))
561 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530562 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530563 "%s: Successfully sent 2nd marker frame with seq num=%d"
564 " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum);
565 }
566 }
567
568 return;
569
570}
571
572/*------------------------------------------------------------------
573 *
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 * limchannelchange callback, on success channel change, set the
575 * link_state to LISTEN
576 *
577 *------------------------------------------------------------------*/
578
579void limProcessRemainOnChnTimeout(tpAniSirGlobal pMac)
580{
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530581 tpPESession psessionEntry;
582 tANI_U8 sessionId;
583 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
586 if (NULL == pMac->lim.gpLimRemainOnChanReq)
587 {
588 limLog( pMac, LOGE, "No Remain on channel pending");
589 return;
590 }
591
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530592 if(pMac->lim.gDebugP2pRemainOnChannel)
593 {
594 if (eHAL_STATUS_SUCCESS == limPrepareAndSendCancelRemainOnChannelMsg(
595 pMac,
596 REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME))
597 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530598 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530599 "%s: Successfully sent 1st marker frame with seqnum = %d"
600 " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum);
601 }
602 }
603
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 /* get the previous valid LINK state */
605 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530606 pMac->lim.gSelfMacAddr, limSetlinkStateCallback, NULL) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 {
608 limLog( pMac, LOGE, "Unable to change link state");
609 return;
610 }
611
612 if (pMac->lim.gLimMlmState != eLIM_MLM_P2P_LISTEN_STATE )
613 {
614 limRemainOnChnRsp(pMac,eHAL_STATUS_SUCCESS, NULL);
615 }
616 else
617 {
618 /* get the session */
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530619 if((psessionEntry = peFindSessionByBssid(
620 pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 {
622 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700623 FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 goto error;
625 }
626
627 limExitRemainOnChannel(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry);
628 return;
629error:
630 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
631 }
632 return;
633}
634
635
636/*------------------------------------------------------------------
637 *
638 * limchannelchange callback, on success channel change, set the link_state
639 * to LISTEN
640 *
641 *------------------------------------------------------------------*/
642
643void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
644 tANI_U32 *data, tpPESession psessionEntry)
645{
646
647 if (status != eHAL_STATUS_SUCCESS)
648 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700649 PELOGE(limLog( pMac, LOGE, "Remain on Channel Failed");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 goto error;
651 }
652 //Set the resume channel to Any valid channel (invalid).
653 //This will instruct HAL to set it to any previous valid channel.
654 peSetResumeChannel(pMac, 0, 0);
655 limResumeLink(pMac, limRemainOnChnRsp, NULL);
656 return;
657error:
658 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
659 return;
660}
661
662/*------------------------------------------------------------------
663 *
664 * Send remain on channel respone: Success/ Failure
665 *
666 *------------------------------------------------------------------*/
667void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
668{
669 tpPESession psessionEntry;
670 tANI_U8 sessionId;
671 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
672 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530673 tANI_U32 txStatus = 0;
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530674 tSirTxBdStatus txBdStatus = {0};
675
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 if ( NULL == MsgRemainonChannel )
677 {
678 PELOGE(limLog( pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700679 "%s: No Pointer for Remain on Channel Req", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 return;
681 }
682
Rashmi Ramannac7744532013-10-06 16:49:08 +0530683 limLog( pMac, LOG1, "Remain on channel rsp with status %d", status);
684
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 //Incase of the Remain on Channel Failure Case
686 //Cleanup Everything
687 if(eHAL_STATUS_FAILURE == status)
688 {
689 //Deactivate Remain on Channel Timer
690 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
691
692 //Set the Link State to Idle
693 /* get the previous valid LINK state */
694 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
695 pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS)
696 {
697 limLog( pMac, LOGE, "Unable to change link state");
698 }
699
700 pMac->lim.gLimSystemInScanLearnMode = 0;
701 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
702 }
703
704 /* delete the session */
705 if((psessionEntry = peFindSessionByBssid(pMac,
706 MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL)
707 {
708 if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole )
709 {
710 peDeleteSession( pMac, psessionEntry);
711 }
712 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700713
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 /* Post the meessage to Sme */
Rashmi Ramannac7744532013-10-06 16:49:08 +0530715 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 MsgRemainonChannel->sessionId, 0);
717
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530718 vos_mem_free(pMac->lim.gpLimRemainOnChanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 pMac->lim.gpLimRemainOnChanReq = NULL;
720
721 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700722
723 /* If remain on channel timer expired and action frame is pending then
724 * indicaiton confirmation with status failure */
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800725 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700726 {
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530727 limLog(pMac, LOGE,
728 FL("Remain on channel expired, Action frame status failure"));
729
730 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
731 limP2PActionCnf(pMac, &txBdStatus);
732 else
733 limP2PActionCnf(pMac, &txStatus);
Jeff Johnsone7245742012-09-05 17:12:55 -0700734 }
735
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 return;
737}
738
739/*------------------------------------------------------------------
740 *
741 * Indicate the Mgmt Frame received to SME to HDD callback
742 * handle Probe_req/Action frame currently
743 *
744 *------------------------------------------------------------------*/
745void limSendSmeMgmtFrameInd(
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530746 tpAniSirGlobal pMac, tANI_U16 sessionId,
747 tANI_U8 *pRxPacketInfo, tpPESession psessionEntry,
Chilam NG571c65a2013-01-19 12:27:36 +0530748 tANI_S8 rxRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700749{
750 tSirMsgQ mmhMsg;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530751 tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 tANI_U16 length;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530753 tANI_U8 frameType;
754 tpSirMacMgmtHdr frame;
755 tANI_U32 frameLen;
756 tANI_U8 rfBand = 0;
757 tANI_U32 rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700758
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530759 frame = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
760 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) + sizeof(tSirMacMgmtHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 length = sizeof(tSirSmeMgmtFrameInd) + frameLen;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530762 frameType = frame->fc.subType;
763 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
764 rxChannel = WDA_GET_RX_CH( pRxPacketInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -0700765
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530766 pSirSmeMgmtFrame = vos_mem_malloc(length);
767 if (NULL == pSirSmeMgmtFrame)
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 {
769 limLog(pMac, LOGP,
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530770 FL("AllocateMemory failed for eWNI_SME_LISTEN_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 return;
772 }
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530773 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700774
775 pSirSmeMgmtFrame->mesgType = eWNI_SME_MGMT_FRM_IND;
776 pSirSmeMgmtFrame->mesgLen = length;
777 pSirSmeMgmtFrame->sessionId = sessionId;
778 pSirSmeMgmtFrame->frameType = frameType;
Chilam NG571c65a2013-01-19 12:27:36 +0530779 pSirSmeMgmtFrame->rxRssi = rxRssi;
Jeff Johnsone7245742012-09-05 17:12:55 -0700780
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530781 if (( IS_5G_BAND(rfBand)))
782 {
783 rxChannel = limUnmapChannel(rxChannel);
784 limLog(pMac, LOG1,
785 FL("rxChannel after unmapping is %d"), rxChannel);
786 if ( !rxChannel )
787 {
788 tpPESession pTempSessionEntry = limIsApSessionActive(pMac);
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530789 if(pMac->lim.gpLimRemainOnChanReq != NULL)
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530790 {
791 rxChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
792 limLog(pMac, LOG1,
793 FL("ROC timer is running."
794 " Assign ROC channel to rxChannel i.e., %d"), rxChannel);
795 }
796 else if ( (pTempSessionEntry != NULL) &&
797 (SIR_BAND_5_GHZ !=
798 limGetRFBand(pTempSessionEntry->currentOperChannel)) )
799 limLog(pMac, LOGW,
800 FL("No active p2p GO in 5GHz"
801 " but recvd Action frame in 5GHz"));
802 }
803 }
804
Sunil Ravif0998942013-02-04 07:01:12 -0800805 /*
806 * Work around to address LIM sending wrong channel to HDD for p2p action
807 * frames(In case of auto GO) recieved on 5GHz channel.
808 * As RXP has only 4bits to store the channel, we need some mechanism to
809 * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer
810 * is not running and if we get a frame then pass the Go session
811 * operating channel to HDD. Some vendors create separate p2p interface
812 * after group formation. In that case LIM session entry will be NULL for
813 * p2p device address. So search for p2p go session and pass it's
814 * operating channel.
815 * Need to revisit this path in case of GO+CLIENT concurrency.
Jeff Johnsone7245742012-09-05 17:12:55 -0700816 */
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530817 if (NULL == pMac->lim.gpLimRemainOnChanReq)
Jeff Johnsone7245742012-09-05 17:12:55 -0700818 {
Sunil Ravif0998942013-02-04 07:01:12 -0800819 tpPESession pTempSessionEntry = psessionEntry;
820 if( ( (NULL != pTempSessionEntry) ||
821 (pTempSessionEntry = limIsApSessionActive(pMac)) ) &&
822 (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) )
823 {
824 rxChannel = pTempSessionEntry->currentOperChannel;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530825 limLog(pMac, LOG1,
826 FL("Invalid rxChannel."
827 " Assign GO session op channel to rxChannel i.e., %d"), rxChannel);
Sunil Ravif0998942013-02-04 07:01:12 -0800828 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700829 }
Sunil Ravif0998942013-02-04 07:01:12 -0800830
831 pSirSmeMgmtFrame->rxChan = rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700832
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530833 vos_mem_zero(pSirSmeMgmtFrame->frameBuf, frameLen);
834 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 mmhMsg.type = eWNI_SME_MGMT_FRM_IND;
837 mmhMsg.bodyptr = pSirSmeMgmtFrame;
838 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700839
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
841 return;
842} /*** end limSendSmeListenRsp() ***/
843
844
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530845eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, void *pData)
Jeff Johnson295189b2012-06-20 16:38:30 -0700846{
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530847 tANI_U32 txCompleteSuccess;
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530848 tpSirTxBdStatus pTxBdStatus;
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530849
850 if (!pData)
851 {
852 limLog(pMac, LOG1,
853 FL(" pData is NULL"));
854 return eHAL_STATUS_FAILURE;
855 }
856
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530857 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
858 {
859 pTxBdStatus = (tpSirTxBdStatus) pData;
860 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530861
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530862 limLog(pMac, LOG1,
863 FL("txCompleteSuccess %d, Token %u, Session Id %d"),
864 txCompleteSuccess, pTxBdStatus->txBdToken,
865 pMac->lim.mgmtFrameSessionId);
866 }
867 else
868 {
869 txCompleteSuccess = *((tANI_U32*) pData);
870
871 limLog(pMac, LOG1,
872 FL(" %s txCompleteSuccess %d, Session Id %d"),
873 __func__, txCompleteSuccess, pMac->lim.mgmtFrameSessionId);
874 }
875
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800876 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700877 {
878 /* The session entry might be invalid(0xff) action confirmation received after
879 * remain on channel timer expired */
880 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
881 (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL),
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800882 pMac->lim.mgmtFrameSessionId, 0);
883 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnsone7245742012-09-05 17:12:55 -0700884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885
886 return eHAL_STATUS_SUCCESS;
887}
888
889
Jeff Johnsone7245742012-09-05 17:12:55 -0700890void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes)
Jeff Johnson295189b2012-06-20 16:38:30 -0700891{
892 v_U8_t *pIe=NULL;
893 tDot11fIEHTCaps dot11HtCap;
894
Jeff Johnsone7245742012-09-05 17:12:55 -0700895 PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes,
897 DOT11F_EID_HTCAPS,ONE_BYTE);
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800898 limLog( pMac, LOG2, FL("pIe %p dot11HtCap.supportedMCSSet[0]=0x%x"),
899 pIe, dot11HtCap.supportedMCSSet[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 if(pIe)
901 {
902 tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure
903 pHtcap->advCodingCap = dot11HtCap.advCodingCap;
904 pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet;
905 pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave;
906 pHtcap->greenField = dot11HtCap.greenField;
907 pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz;
908 pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz;
909 pHtcap->txSTBC = dot11HtCap.txSTBC;
910 pHtcap->rxSTBC = dot11HtCap.rxSTBC;
911 pHtcap->delayedBA = dot11HtCap.delayedBA ;
912 pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize;
913 pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz;
914 pHtcap->psmp = dot11HtCap.psmp;
915 pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame;
916 pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection;
917 pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor;
918 pHtcap->mpduDensity = dot11HtCap.mpduDensity;
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530919 vos_mem_copy((void *)pHtcap->supportedMCSSet,
920 (void *)(dot11HtCap.supportedMCSSet),
921 sizeof(pHtcap->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pHtcap->pco = dot11HtCap.pco;
923 pHtcap->transitionTime = dot11HtCap.transitionTime;
924 pHtcap->mcsFeedback = dot11HtCap.mcsFeedback;
925 pHtcap->txBF = dot11HtCap.txBF;
926 pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding;
927 pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding;
928 pHtcap->rxZLF = dot11HtCap.rxZLF;
929 pHtcap->txZLF = dot11HtCap.txZLF;
930 pHtcap->implicitTxBF = dot11HtCap.implicitTxBF;
931 pHtcap->calibration = dot11HtCap.calibration;
932 pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF;
933 pHtcap->explicitUncompressedSteeringMatrix =
934 dot11HtCap.explicitUncompressedSteeringMatrix;
935 pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback;
936 pHtcap->explicitUncompressedSteeringMatrixFeedback =
937 dot11HtCap.explicitUncompressedSteeringMatrixFeedback;
938 pHtcap->explicitCompressedSteeringMatrixFeedback =
939 dot11HtCap.explicitCompressedSteeringMatrixFeedback;
940 pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae;
941 pHtcap->uncompressedSteeringMatrixBFAntennae =
942 dot11HtCap.uncompressedSteeringMatrixBFAntennae;
943 pHtcap->compressedSteeringMatrixBFAntennae =
944 dot11HtCap.compressedSteeringMatrixBFAntennae;
945 pHtcap->antennaSelection = dot11HtCap.antennaSelection;
946 pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx;
947 pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx;
948 pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback;
949 pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback;
950 pHtcap->rxAS = dot11HtCap.rxAS;
951 pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs;
952 }
953}
954
955
956void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
957{
958 tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr;
959 tANI_U32 nBytes;
960 tANI_U8 *pFrame;
961 void *pPacket;
962 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530963 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data;
965 tANI_U8 noaLen = 0;
Krunal Sonic768a932013-05-15 19:26:30 -0700966 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + (2*SIR_P2P_IE_HEADER_LEN)];
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 tANI_U8 origLen = 0;
968 tANI_U8 sessionId = 0;
969 v_U8_t *pP2PIe = NULL;
970 tpPESession psessionEntry;
971 v_U8_t *pPresenceRspNoaAttr = NULL;
972 v_U8_t *pNewP2PIe = NULL;
973 v_U16_t remainLen = 0;
Abhishek Singh0ebac9c2014-06-25 13:34:12 +0530974#ifdef WLAN_FEATURE_11W
975 tpSirMacMgmtHdr pMacHdr;
976 tpSirMacActionFrameHdr pActionHdr;
977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg);
979
980 limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"),
981 pFc->type, pFc->subType);
982
983 psessionEntry = peFindSessionByBssid(pMac,
984 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
985
986 /* Check for session corresponding to ADDR2 As Supplicant is filling
987 ADDR2 with BSSID */
988 if( NULL == psessionEntry )
989 {
990 psessionEntry = peFindSessionByBssid(pMac,
991 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
992 }
993
994 if( NULL == psessionEntry )
995 {
996 tANI_U8 isSessionActive = 0;
997 tANI_U8 i;
998
999 /* If we are not able to find psessionEntry entry, then try to find
1000 active session, if found any active sessions then send the
1001 action frame, If no active sessions found then drop the frame */
1002 for (i =0; i < pMac->lim.maxBssId;i++)
1003 {
1004 psessionEntry = peFindSessionBySessionId(pMac,i);
1005 if ( NULL != psessionEntry)
1006 {
1007 isSessionActive = 1;
1008 break;
1009 }
1010 }
1011 if( !isSessionActive )
1012 {
1013 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1014 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1015 return;
1016 }
1017 }
1018
1019 if ((SIR_MAC_MGMT_FRAME == pFc->type)&&
1020 ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)||
1021 (SIR_MAC_MGMT_ACTION == pFc->subType)))
1022 {
1023 //if this is a probe RSP being sent from wpa_supplicant
1024 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1025 {
1026 //get proper offset for Probe RSP
1027 pP2PIe = limGetP2pIEPtr(pMac,
1028 (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
1029 nBytes - PROBE_RSP_IE_OFFSET);
1030 while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1]))
1031 {
1032 remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data);
1033 if (remainLen > 2)
1034 {
1035 pNewP2PIe = limGetP2pIEPtr(pMac,
1036 pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen);
1037 }
1038 if (pNewP2PIe)
1039 {
1040 pP2PIe = pNewP2PIe;
1041 pNewP2PIe = NULL;
1042 }
1043 else
1044 {
1045 break;
1046 }
1047 } //end of while
1048 }
1049 else
1050 {
1051 if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY ==
1052 *((v_U8_t *)pMbMsg->data+ACTION_OFFSET))
1053 {
1054 tpSirMacP2PActionFrameHdr pActionHdr =
1055 (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data +
1056 ACTION_OFFSET);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301057 if (vos_mem_compare( pActionHdr->Oui,
1058 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP ==
1060 pActionHdr->OuiSubType))
1061 { //In case of Presence RSP response
1062 pP2PIe = limGetP2pIEPtr(pMac,
1063 (v_U8_t *)pMbMsg->data + ACTION_OFFSET +
1064 sizeof(tSirMacP2PActionFrameHdr),
1065 (nBytes - ACTION_OFFSET -
1066 sizeof(tSirMacP2PActionFrameHdr)));
1067 if( NULL != pP2PIe )
1068 {
1069 //extract the presence of NoA attribute inside P2P IE
1070 pPresenceRspNoaAttr =
1071 limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN,
1072 pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE);
1073 }
1074 }
1075 }
1076 }
1077
1078 if (pP2PIe != NULL)
1079 {
1080 //get NoA attribute stream P2P IE
1081 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
1082 //need to append NoA attribute in P2P IE
1083 if (noaLen > 0)
1084 {
1085 origLen = pP2PIe[1];
1086 //if Presence Rsp has NoAttr
1087 if (pPresenceRspNoaAttr)
1088 {
1089 v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] |
1090 (pPresenceRspNoaAttr[2]<<8);
1091 /*One byte for attribute, 2bytes for length*/
1092 origLen -= (noaAttrLen + 1 + 2);
1093 //remove those bytes to copy
1094 nBytes -= (noaAttrLen + 1 + 2);
1095 //remove NoA from original Len
1096 pP2PIe[1] = origLen;
1097 }
1098 if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH)
1099 {
1100 //Form the new NoA Byte array in multiple P2P IEs
1101 noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream,
1102 noaLen,((pP2PIe[1] + (tANI_U16)noaLen)-
1103 SIR_MAC_MAX_IE_LENGTH));
1104 pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH;
1105 }
1106 else
1107 {
1108 pP2PIe[1] += noaLen; //increment the length of P2P IE
1109 }
1110 nBytes += noaLen;
1111 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001112 FL("noaLen=%d origLen=%d pP2PIe=%p"
Jeff Johnsonf2de0392013-11-22 18:28:57 -08001113 " nBytes=%d nBytesToCopy=%zu"),
1114 noaLen,origLen, pP2PIe, nBytes,
1115 ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 }
1117 }
1118
1119 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1120 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001121 limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
Madan Mohan Koyyalamudifb29a5d2012-10-11 12:14:17 -07001122 nBytes - PROBE_RSP_IE_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 }
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301124 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
1125 (0 != pMbMsg->wait))
Jeff Johnsone7245742012-09-05 17:12:55 -07001126 {
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301127 if (pMac->lim.gpLimRemainOnChanReq == NULL)
1128 {
1129 limLog( pMac, LOGE,
1130 FL("Failed to Send Action frame \n"));
1131 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1132 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1133 return;
1134 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 }
1137
1138
1139 // Ok-- try to allocate some memory:
1140 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1141 (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket);
1142 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1143 {
1144 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001145 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 return;
1147 }
1148
1149 // Paranoia:
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301150 vos_mem_set(pFrame, nBytes, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001151
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +05301152 if ((noaLen > 0) && (noaLen<(SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 {
1154 // Add 2 bytes for length and Arribute field
1155 v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) -
1156 (v_U8_t *)pMbMsg->data);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301157 vos_mem_copy(pFrame, pMbMsg->data, nBytesToCopy);
1158 vos_mem_copy((pFrame + nBytesToCopy), noaStream, noaLen);
1159 vos_mem_copy((pFrame + nBytesToCopy + noaLen),
1160 pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001161
1162 }
1163 else
1164 {
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301165 vos_mem_copy(pFrame, pMbMsg->data, nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 }
1167
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301168#ifdef WLAN_FEATURE_11W
1169 pActionHdr = (tpSirMacActionFrameHdr) (pFrame + sizeof(tSirMacMgmtHdr));
1170
1171 /*
1172 * Setting Protected bit for SA_QUERY Action Frame
1173 * This has to be based on the current Connection with the station
1174 * limSetProtectedBit API will set the protected bit if connection if PMF
1175 */
1176
1177 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
1178 (SIR_MAC_ACTION_SA_QUERY == pActionHdr->category))
1179 {
1180 pMacHdr = (tpSirMacMgmtHdr ) pFrame;
1181 psessionEntry = peFindSessionByBssid(pMac,
1182 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
1183
1184 /* Check for session corresponding to ADDR2 ss supplicant is filling
1185 ADDR2 with BSSID */
1186 if(NULL == psessionEntry)
1187 {
1188 psessionEntry = peFindSessionByBssid(pMac,
1189 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
1190 }
1191
1192 if(NULL != psessionEntry)
1193 {
1194 limSetProtectedBit(pMac, psessionEntry, pMacHdr->da, pMacHdr);
1195 }
1196 else
1197 {
1198 limLog(pMac, LOGE,
1199 FL("Dropping SA Query frame - Unable to find PE Session \n"));
1200 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1201 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1202 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1203 ( void* ) pFrame, ( void* ) pPacket );
1204 return;
1205 }
1206
1207 /*
1208 * If wep bit is not set in MAC header then we are trying to
1209 * send SA Query via non PMF connection. Drop the packet.
1210 */
1211
1212 if(0 == pMacHdr->fc.wep)
1213 {
1214 limLog(pMac, LOGE,
1215 FL("Dropping SA Query frame due to non PMF connection\n"));
1216 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1217 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1218 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1219 ( void* ) pFrame, ( void* ) pPacket );
1220 return;
1221 }
1222 }
1223#endif
1224
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 /* Use BD rate 2 for all P2P related frames. As these frames need to go
1226 * at OFDM rates. And BD rate2 we configured at 6Mbps.
1227 */
1228 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1229
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301230 if (SIR_MAC_MGMT_ACTION == pFc->subType)
1231 {
1232 limLog( pMac, LOG1, FL("Sending Action Frame over WQ5"));
1233 txFlag |= HAL_USE_FW_IN_TX_PATH;
1234 }
1235
Jeff Johnsone7245742012-09-05 17:12:55 -07001236 if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) ||
1237 (pMbMsg->noack)
1238 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 {
1240 halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes,
1241 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1242 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1243 txFlag );
1244
Jeff Johnsone7245742012-09-05 17:12:55 -07001245 if (!pMbMsg->noack)
1246 {
1247 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 halstatus, pMbMsg->sessionId, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001249 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001250 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 }
1252 else
1253 {
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +05301254 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes,
1256 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1257 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301258 limP2PActionCnf, txFlag, pMac->lim.txBdToken++ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001259
1260 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1261 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001262 limLog( pMac, LOGE, FL("could not send action frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus,
1264 pMbMsg->sessionId, 0);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001265 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 }
1267 else
1268 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001269 pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001270 limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %u" ),
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001271 pMac->lim.mgmtFrameSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07001272
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 }
1274 }
1275
1276 return;
1277}
1278
1279
1280void limAbortRemainOnChan(tpAniSirGlobal pMac)
1281{
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +05301282 limProcessRemainOnChnTimeout(pMac);
1283 limLog( pMac, LOG1, FL("Abort ROC !!!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 return;
1285}
1286
1287/* Power Save Related Functions */
1288tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1289{
1290 tpP2pPsConfig pNoA;
1291 tpP2pPsParams pMsgNoA;
1292 tSirMsgQ msg;
1293
1294 pNoA = (tpP2pPsConfig) pMsgBuf;
1295
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301296 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
1297 if (NULL == pMsgNoA)
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 {
1299 limLog( pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001300 FL( "Unable to allocate memory during NoA Update" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 return eSIR_MEM_ALLOC_FAILED;
1302 }
1303
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301304 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 pMsgNoA->opp_ps = pNoA->opp_ps;
1306 pMsgNoA->ctWindow = pNoA->ctWindow;
1307 pMsgNoA->duration = pNoA->duration;
1308 pMsgNoA->interval = pNoA->interval;
1309 pMsgNoA->count = pNoA->count;
1310 pMsgNoA->single_noa_duration = pNoA->single_noa_duration;
1311 pMsgNoA->psSelection = pNoA->psSelection;
1312
Viral Modid86bde22012-12-10 13:09:21 -08001313 msg.type = WDA_SET_P2P_GO_NOA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 msg.reserved = 0;
1315 msg.bodyptr = pMsgNoA;
1316 msg.bodyval = 0;
1317
1318 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1319 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001320 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 return eSIR_FAILURE;
1322 }
1323
1324 return eSIR_SUCCESS;
1325} /*** end __limProcessSmeGoNegReq() ***/
1326
Jeff Johnson295189b2012-06-20 16:38:30 -07001327