blob: 3c51e00cb804593574c5a5bd618c7a8e50726b8f [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;
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 if ( NULL == MsgRemainonChannel )
675 {
676 PELOGE(limLog( pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700677 "%s: No Pointer for Remain on Channel Req", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 return;
679 }
680
Rashmi Ramannac7744532013-10-06 16:49:08 +0530681 limLog( pMac, LOG1, "Remain on channel rsp with status %d", status);
682
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 //Incase of the Remain on Channel Failure Case
684 //Cleanup Everything
685 if(eHAL_STATUS_FAILURE == status)
686 {
687 //Deactivate Remain on Channel Timer
688 limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
689
690 //Set the Link State to Idle
691 /* get the previous valid LINK state */
692 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
693 pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS)
694 {
695 limLog( pMac, LOGE, "Unable to change link state");
696 }
697
698 pMac->lim.gLimSystemInScanLearnMode = 0;
699 pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE;
700 }
701
702 /* delete the session */
703 if((psessionEntry = peFindSessionByBssid(pMac,
704 MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL)
705 {
706 if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole )
707 {
708 peDeleteSession( pMac, psessionEntry);
709 }
710 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700711
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 /* Post the meessage to Sme */
Rashmi Ramannac7744532013-10-06 16:49:08 +0530713 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 MsgRemainonChannel->sessionId, 0);
715
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530716 vos_mem_free(pMac->lim.gpLimRemainOnChanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 pMac->lim.gpLimRemainOnChanReq = NULL;
718
719 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700720
721 /* If remain on channel timer expired and action frame is pending then
722 * indicaiton confirmation with status failure */
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800723 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700724 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530725 limLog(pMac, LOGE,
726 FL("Remain on channel expired, Action frame status failure"));
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530727 limP2PActionCnf(pMac, &txStatus);
Jeff Johnsone7245742012-09-05 17:12:55 -0700728 }
729
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 return;
731}
732
733/*------------------------------------------------------------------
734 *
735 * Indicate the Mgmt Frame received to SME to HDD callback
736 * handle Probe_req/Action frame currently
737 *
738 *------------------------------------------------------------------*/
739void limSendSmeMgmtFrameInd(
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530740 tpAniSirGlobal pMac, tANI_U16 sessionId,
741 tANI_U8 *pRxPacketInfo, tpPESession psessionEntry,
Chilam NG571c65a2013-01-19 12:27:36 +0530742 tANI_S8 rxRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700743{
744 tSirMsgQ mmhMsg;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530745 tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 tANI_U16 length;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530747 tANI_U8 frameType;
748 tpSirMacMgmtHdr frame;
749 tANI_U32 frameLen;
750 tANI_U8 rfBand = 0;
751 tANI_U32 rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700752
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530753 frame = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
754 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) + sizeof(tSirMacMgmtHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 length = sizeof(tSirSmeMgmtFrameInd) + frameLen;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530756 frameType = frame->fc.subType;
757 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
758 rxChannel = WDA_GET_RX_CH( pRxPacketInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -0700759
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530760 pSirSmeMgmtFrame = vos_mem_malloc(length);
761 if (NULL == pSirSmeMgmtFrame)
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 {
763 limLog(pMac, LOGP,
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530764 FL("AllocateMemory failed for eWNI_SME_LISTEN_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 return;
766 }
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530767 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700768
769 pSirSmeMgmtFrame->mesgType = eWNI_SME_MGMT_FRM_IND;
770 pSirSmeMgmtFrame->mesgLen = length;
771 pSirSmeMgmtFrame->sessionId = sessionId;
772 pSirSmeMgmtFrame->frameType = frameType;
Chilam NG571c65a2013-01-19 12:27:36 +0530773 pSirSmeMgmtFrame->rxRssi = rxRssi;
Jeff Johnsone7245742012-09-05 17:12:55 -0700774
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530775 if (( IS_5G_BAND(rfBand)))
776 {
777 rxChannel = limUnmapChannel(rxChannel);
778 limLog(pMac, LOG1,
779 FL("rxChannel after unmapping is %d"), rxChannel);
780 if ( !rxChannel )
781 {
782 tpPESession pTempSessionEntry = limIsApSessionActive(pMac);
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530783 if(pMac->lim.gpLimRemainOnChanReq != NULL)
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530784 {
785 rxChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
786 limLog(pMac, LOG1,
787 FL("ROC timer is running."
788 " Assign ROC channel to rxChannel i.e., %d"), rxChannel);
789 }
790 else if ( (pTempSessionEntry != NULL) &&
791 (SIR_BAND_5_GHZ !=
792 limGetRFBand(pTempSessionEntry->currentOperChannel)) )
793 limLog(pMac, LOGW,
794 FL("No active p2p GO in 5GHz"
795 " but recvd Action frame in 5GHz"));
796 }
797 }
798
Sunil Ravif0998942013-02-04 07:01:12 -0800799 /*
800 * Work around to address LIM sending wrong channel to HDD for p2p action
801 * frames(In case of auto GO) recieved on 5GHz channel.
802 * As RXP has only 4bits to store the channel, we need some mechanism to
803 * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer
804 * is not running and if we get a frame then pass the Go session
805 * operating channel to HDD. Some vendors create separate p2p interface
806 * after group formation. In that case LIM session entry will be NULL for
807 * p2p device address. So search for p2p go session and pass it's
808 * operating channel.
809 * Need to revisit this path in case of GO+CLIENT concurrency.
Jeff Johnsone7245742012-09-05 17:12:55 -0700810 */
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530811 if (NULL == pMac->lim.gpLimRemainOnChanReq)
Jeff Johnsone7245742012-09-05 17:12:55 -0700812 {
Sunil Ravif0998942013-02-04 07:01:12 -0800813 tpPESession pTempSessionEntry = psessionEntry;
814 if( ( (NULL != pTempSessionEntry) ||
815 (pTempSessionEntry = limIsApSessionActive(pMac)) ) &&
816 (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) )
817 {
818 rxChannel = pTempSessionEntry->currentOperChannel;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530819 limLog(pMac, LOG1,
820 FL("Invalid rxChannel."
821 " Assign GO session op channel to rxChannel i.e., %d"), rxChannel);
Sunil Ravif0998942013-02-04 07:01:12 -0800822 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700823 }
Sunil Ravif0998942013-02-04 07:01:12 -0800824
825 pSirSmeMgmtFrame->rxChan = rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530827 vos_mem_zero(pSirSmeMgmtFrame->frameBuf, frameLen);
828 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700829
830 mmhMsg.type = eWNI_SME_MGMT_FRM_IND;
831 mmhMsg.bodyptr = pSirSmeMgmtFrame;
832 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700833
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
835 return;
836} /*** end limSendSmeListenRsp() ***/
837
838
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530839eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, void *pData)
Jeff Johnson295189b2012-06-20 16:38:30 -0700840{
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530841 tANI_U32 txCompleteSuccess;
842
843 if (!pData)
844 {
845 limLog(pMac, LOG1,
846 FL(" pData is NULL"));
847 return eHAL_STATUS_FAILURE;
848 }
849
850 txCompleteSuccess = *((tANI_U32*) pData);
851
Rashmi Ramannac7744532013-10-06 16:49:08 +0530852 limLog(pMac, LOG1,
853 FL(" %s txCompleteSuccess %d, Session Id %d"),
854 __func__, txCompleteSuccess, pMac->lim.mgmtFrameSessionId);
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800855 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700856 {
857 /* The session entry might be invalid(0xff) action confirmation received after
858 * remain on channel timer expired */
859 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
860 (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL),
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800861 pMac->lim.mgmtFrameSessionId, 0);
862 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnsone7245742012-09-05 17:12:55 -0700863 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700864
865 return eHAL_STATUS_SUCCESS;
866}
867
868
Jeff Johnsone7245742012-09-05 17:12:55 -0700869void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes)
Jeff Johnson295189b2012-06-20 16:38:30 -0700870{
871 v_U8_t *pIe=NULL;
872 tDot11fIEHTCaps dot11HtCap;
873
Jeff Johnsone7245742012-09-05 17:12:55 -0700874 PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap);
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes,
876 DOT11F_EID_HTCAPS,ONE_BYTE);
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800877 limLog( pMac, LOG2, FL("pIe %p dot11HtCap.supportedMCSSet[0]=0x%x"),
878 pIe, dot11HtCap.supportedMCSSet[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 if(pIe)
880 {
881 tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure
882 pHtcap->advCodingCap = dot11HtCap.advCodingCap;
883 pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet;
884 pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave;
885 pHtcap->greenField = dot11HtCap.greenField;
886 pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz;
887 pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz;
888 pHtcap->txSTBC = dot11HtCap.txSTBC;
889 pHtcap->rxSTBC = dot11HtCap.rxSTBC;
890 pHtcap->delayedBA = dot11HtCap.delayedBA ;
891 pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize;
892 pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz;
893 pHtcap->psmp = dot11HtCap.psmp;
894 pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame;
895 pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection;
896 pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor;
897 pHtcap->mpduDensity = dot11HtCap.mpduDensity;
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530898 vos_mem_copy((void *)pHtcap->supportedMCSSet,
899 (void *)(dot11HtCap.supportedMCSSet),
900 sizeof(pHtcap->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 pHtcap->pco = dot11HtCap.pco;
902 pHtcap->transitionTime = dot11HtCap.transitionTime;
903 pHtcap->mcsFeedback = dot11HtCap.mcsFeedback;
904 pHtcap->txBF = dot11HtCap.txBF;
905 pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding;
906 pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding;
907 pHtcap->rxZLF = dot11HtCap.rxZLF;
908 pHtcap->txZLF = dot11HtCap.txZLF;
909 pHtcap->implicitTxBF = dot11HtCap.implicitTxBF;
910 pHtcap->calibration = dot11HtCap.calibration;
911 pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF;
912 pHtcap->explicitUncompressedSteeringMatrix =
913 dot11HtCap.explicitUncompressedSteeringMatrix;
914 pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback;
915 pHtcap->explicitUncompressedSteeringMatrixFeedback =
916 dot11HtCap.explicitUncompressedSteeringMatrixFeedback;
917 pHtcap->explicitCompressedSteeringMatrixFeedback =
918 dot11HtCap.explicitCompressedSteeringMatrixFeedback;
919 pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae;
920 pHtcap->uncompressedSteeringMatrixBFAntennae =
921 dot11HtCap.uncompressedSteeringMatrixBFAntennae;
922 pHtcap->compressedSteeringMatrixBFAntennae =
923 dot11HtCap.compressedSteeringMatrixBFAntennae;
924 pHtcap->antennaSelection = dot11HtCap.antennaSelection;
925 pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx;
926 pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx;
927 pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback;
928 pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback;
929 pHtcap->rxAS = dot11HtCap.rxAS;
930 pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs;
931 }
932}
933
934
935void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
936{
937 tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr;
938 tANI_U32 nBytes;
939 tANI_U8 *pFrame;
940 void *pPacket;
941 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530942 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data;
944 tANI_U8 noaLen = 0;
Krunal Sonic768a932013-05-15 19:26:30 -0700945 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + (2*SIR_P2P_IE_HEADER_LEN)];
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 tANI_U8 origLen = 0;
947 tANI_U8 sessionId = 0;
948 v_U8_t *pP2PIe = NULL;
949 tpPESession psessionEntry;
950 v_U8_t *pPresenceRspNoaAttr = NULL;
951 v_U8_t *pNewP2PIe = NULL;
952 v_U16_t remainLen = 0;
Abhishek Singh0ebac9c2014-06-25 13:34:12 +0530953#ifdef WLAN_FEATURE_11W
954 tpSirMacMgmtHdr pMacHdr;
955 tpSirMacActionFrameHdr pActionHdr;
956#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg);
958
959 limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"),
960 pFc->type, pFc->subType);
961
962 psessionEntry = peFindSessionByBssid(pMac,
963 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
964
965 /* Check for session corresponding to ADDR2 As Supplicant is filling
966 ADDR2 with BSSID */
967 if( NULL == psessionEntry )
968 {
969 psessionEntry = peFindSessionByBssid(pMac,
970 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
971 }
972
973 if( NULL == psessionEntry )
974 {
975 tANI_U8 isSessionActive = 0;
976 tANI_U8 i;
977
978 /* If we are not able to find psessionEntry entry, then try to find
979 active session, if found any active sessions then send the
980 action frame, If no active sessions found then drop the frame */
981 for (i =0; i < pMac->lim.maxBssId;i++)
982 {
983 psessionEntry = peFindSessionBySessionId(pMac,i);
984 if ( NULL != psessionEntry)
985 {
986 isSessionActive = 1;
987 break;
988 }
989 }
990 if( !isSessionActive )
991 {
992 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
993 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
994 return;
995 }
996 }
997
998 if ((SIR_MAC_MGMT_FRAME == pFc->type)&&
999 ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)||
1000 (SIR_MAC_MGMT_ACTION == pFc->subType)))
1001 {
1002 //if this is a probe RSP being sent from wpa_supplicant
1003 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1004 {
1005 //get proper offset for Probe RSP
1006 pP2PIe = limGetP2pIEPtr(pMac,
1007 (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
1008 nBytes - PROBE_RSP_IE_OFFSET);
1009 while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1]))
1010 {
1011 remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data);
1012 if (remainLen > 2)
1013 {
1014 pNewP2PIe = limGetP2pIEPtr(pMac,
1015 pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen);
1016 }
1017 if (pNewP2PIe)
1018 {
1019 pP2PIe = pNewP2PIe;
1020 pNewP2PIe = NULL;
1021 }
1022 else
1023 {
1024 break;
1025 }
1026 } //end of while
1027 }
1028 else
1029 {
1030 if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY ==
1031 *((v_U8_t *)pMbMsg->data+ACTION_OFFSET))
1032 {
1033 tpSirMacP2PActionFrameHdr pActionHdr =
1034 (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data +
1035 ACTION_OFFSET);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301036 if (vos_mem_compare( pActionHdr->Oui,
1037 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP ==
1039 pActionHdr->OuiSubType))
1040 { //In case of Presence RSP response
1041 pP2PIe = limGetP2pIEPtr(pMac,
1042 (v_U8_t *)pMbMsg->data + ACTION_OFFSET +
1043 sizeof(tSirMacP2PActionFrameHdr),
1044 (nBytes - ACTION_OFFSET -
1045 sizeof(tSirMacP2PActionFrameHdr)));
1046 if( NULL != pP2PIe )
1047 {
1048 //extract the presence of NoA attribute inside P2P IE
1049 pPresenceRspNoaAttr =
1050 limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN,
1051 pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE);
1052 }
1053 }
1054 }
1055 }
1056
1057 if (pP2PIe != NULL)
1058 {
1059 //get NoA attribute stream P2P IE
1060 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
1061 //need to append NoA attribute in P2P IE
1062 if (noaLen > 0)
1063 {
1064 origLen = pP2PIe[1];
1065 //if Presence Rsp has NoAttr
1066 if (pPresenceRspNoaAttr)
1067 {
1068 v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] |
1069 (pPresenceRspNoaAttr[2]<<8);
1070 /*One byte for attribute, 2bytes for length*/
1071 origLen -= (noaAttrLen + 1 + 2);
1072 //remove those bytes to copy
1073 nBytes -= (noaAttrLen + 1 + 2);
1074 //remove NoA from original Len
1075 pP2PIe[1] = origLen;
1076 }
1077 if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH)
1078 {
1079 //Form the new NoA Byte array in multiple P2P IEs
1080 noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream,
1081 noaLen,((pP2PIe[1] + (tANI_U16)noaLen)-
1082 SIR_MAC_MAX_IE_LENGTH));
1083 pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH;
1084 }
1085 else
1086 {
1087 pP2PIe[1] += noaLen; //increment the length of P2P IE
1088 }
1089 nBytes += noaLen;
1090 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001091 FL("noaLen=%d origLen=%d pP2PIe=%p"
Jeff Johnsonf2de0392013-11-22 18:28:57 -08001092 " nBytes=%d nBytesToCopy=%zu"),
1093 noaLen,origLen, pP2PIe, nBytes,
1094 ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 }
1096 }
1097
1098 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1099 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001100 limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
Madan Mohan Koyyalamudifb29a5d2012-10-11 12:14:17 -07001101 nBytes - PROBE_RSP_IE_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 }
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301103 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
1104 (0 != pMbMsg->wait))
Jeff Johnsone7245742012-09-05 17:12:55 -07001105 {
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301106 if (pMac->lim.gpLimRemainOnChanReq == NULL)
1107 {
1108 limLog( pMac, LOGE,
1109 FL("Failed to Send Action frame \n"));
1110 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1111 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1112 return;
1113 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 }
1116
1117
1118 // Ok-- try to allocate some memory:
1119 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1120 (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket);
1121 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1122 {
1123 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001124 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 return;
1126 }
1127
1128 // Paranoia:
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301129 vos_mem_set(pFrame, nBytes, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001130
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +05301131 if ((noaLen > 0) && (noaLen<(SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 {
1133 // Add 2 bytes for length and Arribute field
1134 v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) -
1135 (v_U8_t *)pMbMsg->data);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301136 vos_mem_copy(pFrame, pMbMsg->data, nBytesToCopy);
1137 vos_mem_copy((pFrame + nBytesToCopy), noaStream, noaLen);
1138 vos_mem_copy((pFrame + nBytesToCopy + noaLen),
1139 pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001140
1141 }
1142 else
1143 {
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301144 vos_mem_copy(pFrame, pMbMsg->data, nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 }
1146
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301147#ifdef WLAN_FEATURE_11W
1148 pActionHdr = (tpSirMacActionFrameHdr) (pFrame + sizeof(tSirMacMgmtHdr));
1149
1150 /*
1151 * Setting Protected bit for SA_QUERY Action Frame
1152 * This has to be based on the current Connection with the station
1153 * limSetProtectedBit API will set the protected bit if connection if PMF
1154 */
1155
1156 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
1157 (SIR_MAC_ACTION_SA_QUERY == pActionHdr->category))
1158 {
1159 pMacHdr = (tpSirMacMgmtHdr ) pFrame;
1160 psessionEntry = peFindSessionByBssid(pMac,
1161 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
1162
1163 /* Check for session corresponding to ADDR2 ss supplicant is filling
1164 ADDR2 with BSSID */
1165 if(NULL == psessionEntry)
1166 {
1167 psessionEntry = peFindSessionByBssid(pMac,
1168 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
1169 }
1170
1171 if(NULL != psessionEntry)
1172 {
1173 limSetProtectedBit(pMac, psessionEntry, pMacHdr->da, pMacHdr);
1174 }
1175 else
1176 {
1177 limLog(pMac, LOGE,
1178 FL("Dropping SA Query frame - Unable to find PE Session \n"));
1179 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1180 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1181 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1182 ( void* ) pFrame, ( void* ) pPacket );
1183 return;
1184 }
1185
1186 /*
1187 * If wep bit is not set in MAC header then we are trying to
1188 * send SA Query via non PMF connection. Drop the packet.
1189 */
1190
1191 if(0 == pMacHdr->fc.wep)
1192 {
1193 limLog(pMac, LOGE,
1194 FL("Dropping SA Query frame due to non PMF connection\n"));
1195 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1196 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1197 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1198 ( void* ) pFrame, ( void* ) pPacket );
1199 return;
1200 }
1201 }
1202#endif
1203
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 /* Use BD rate 2 for all P2P related frames. As these frames need to go
1205 * at OFDM rates. And BD rate2 we configured at 6Mbps.
1206 */
1207 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1208
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301209 if (SIR_MAC_MGMT_ACTION == pFc->subType)
1210 {
1211 limLog( pMac, LOG1, FL("Sending Action Frame over WQ5"));
1212 txFlag |= HAL_USE_FW_IN_TX_PATH;
1213 }
1214
Jeff Johnsone7245742012-09-05 17:12:55 -07001215 if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) ||
1216 (pMbMsg->noack)
1217 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 {
1219 halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes,
1220 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1221 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1222 txFlag );
1223
Jeff Johnsone7245742012-09-05 17:12:55 -07001224 if (!pMbMsg->noack)
1225 {
1226 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 halstatus, pMbMsg->sessionId, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001228 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001229 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 }
1231 else
1232 {
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +05301233 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes,
1235 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1236 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1237 limP2PActionCnf, txFlag );
1238
1239 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1240 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001241 limLog( pMac, LOGE, FL("could not send action frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus,
1243 pMbMsg->sessionId, 0);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001244 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 }
1246 else
1247 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001248 pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001249 limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %u" ),
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001250 pMac->lim.mgmtFrameSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07001251
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 }
1253 }
1254
1255 return;
1256}
1257
1258
1259void limAbortRemainOnChan(tpAniSirGlobal pMac)
1260{
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +05301261 limProcessRemainOnChnTimeout(pMac);
1262 limLog( pMac, LOG1, FL("Abort ROC !!!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 return;
1264}
1265
1266/* Power Save Related Functions */
1267tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1268{
1269 tpP2pPsConfig pNoA;
1270 tpP2pPsParams pMsgNoA;
1271 tSirMsgQ msg;
1272
1273 pNoA = (tpP2pPsConfig) pMsgBuf;
1274
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301275 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
1276 if (NULL == pMsgNoA)
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 {
1278 limLog( pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001279 FL( "Unable to allocate memory during NoA Update" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 return eSIR_MEM_ALLOC_FAILED;
1281 }
1282
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301283 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 pMsgNoA->opp_ps = pNoA->opp_ps;
1285 pMsgNoA->ctWindow = pNoA->ctWindow;
1286 pMsgNoA->duration = pNoA->duration;
1287 pMsgNoA->interval = pNoA->interval;
1288 pMsgNoA->count = pNoA->count;
1289 pMsgNoA->single_noa_duration = pNoA->single_noa_duration;
1290 pMsgNoA->psSelection = pNoA->psSelection;
1291
Viral Modid86bde22012-12-10 13:09:21 -08001292 msg.type = WDA_SET_P2P_GO_NOA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 msg.reserved = 0;
1294 msg.bodyptr = pMsgNoA;
1295 msg.bodyval = 0;
1296
1297 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1298 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001299 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 return eSIR_FAILURE;
1301 }
1302
1303 return eSIR_SUCCESS;
1304} /*** end __limProcessSmeGoNegReq() ***/
1305
Jeff Johnson295189b2012-06-20 16:38:30 -07001306