blob: d3028fe4ec9702c492c664b6ca81dfe916ab6ae2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05302 * Copyright (c) 2012-2014, 2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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;
Deepthi Gowri8e060d82016-07-29 12:04:38 +0530345 /* Store SME session Id in sessionTable */
346 psessionEntry->smeSessionId = pMac->lim.gpLimRemainOnChanReq->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 psessionEntry->limSystemRole = eLIM_P2P_DEVICE_ROLE;
348 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_SUPPORTED_RATES_11A,
349 psessionEntry->rateSet.rate, val , SIR_MAC_MAX_NUMBER_OF_RATES );
350 psessionEntry->rateSet.numRates = val;
351
352 CFG_GET_STR( nSirStatus, pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
353 psessionEntry->extRateSet.rate, val,
354 WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN );
355 psessionEntry->extRateSet.numRates = val;
356
357 sirCopyMacAddr(psessionEntry->selfMacAddr,
358 pMac->lim.gpLimRemainOnChanReq->selfMacAddr);
359
360 psessionEntry->currentOperChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
361 nSirStatus = eSIR_SUCCESS;
362 *ppP2pSession = psessionEntry;
363 }
364
365 return nSirStatus;
366}
367
368
369/*------------------------------------------------------------------
370 *
371 * limSuspenLink callback, on success link suspend, trigger change chn
372 *
373 *
374 *------------------------------------------------------------------*/
375
376tSirRetStatus limRemainOnChnlChangeChnReq(tpAniSirGlobal pMac,
377 eHalStatus status, tANI_U32 *data)
378{
379 tpPESession psessionEntry;
380 tANI_U8 sessionId = 0;
381 tSirRetStatus nSirStatus = eSIR_FAILURE;
382
383 if( NULL == pMac->lim.gpLimRemainOnChanReq )
384 {
385 //RemainOnChannel may have aborted
386 PELOGE(limLog( pMac, LOGE, FL(" gpLimRemainOnChanReq is NULL") );)
387 return nSirStatus;
388 }
389
390 /* The link is not suspended */
391 if (status != eHAL_STATUS_SUCCESS)
392 {
393 PELOGE(limLog( pMac, LOGE, FL(" Suspend link Failure ") );)
394 goto error;
395 }
396
397
398 if((psessionEntry = peFindSessionByBssid(
399 pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) != NULL)
400 {
401 goto change_channel;
402 }
403 else /* Session Entry does not exist for given BSSId */
404 {
405 /* Try to Create a new session */
406 if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &psessionEntry))
407 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700408 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 /* send remain on chn failure */
410 goto error;
411 }
412 }
413
414change_channel:
415 /* change channel to the requested by RemainOn Chn*/
416 limChangeChannelWithCallback(pMac,
417 pMac->lim.gpLimRemainOnChanReq->chnNum,
418 limRemainOnChnlSetLinkStat, NULL, psessionEntry);
419 return eSIR_SUCCESS;
420
421error:
422 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
423 return eSIR_FAILURE;
424}
425
426void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status,
427 tANI_U32 *data)
428{
429 limRemainOnChnlChangeChnReq(pMac, status, data);
430 return;
431}
432
433/*------------------------------------------------------------------
434 *
435 * Set the LINK state to LISTEN to allow only PROBE_REQ and Action frames
436 *
437 *------------------------------------------------------------------*/
438void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status,
439 tANI_U32 *data, tpPESession psessionEntry)
440{
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
442 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
443
444 if (status != eHAL_STATUS_SUCCESS)
445 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800446 limLog( pMac, LOGE, FL("Change channel not successful"));
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530447 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 }
449
450 // Start timer here to come back to operating channel.
Jeff Johnsone7245742012-09-05 17:12:55 -0700451 pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
452 pMac->lim.gTotalScanDuration = MsgRemainonChannel->duration;
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530453 if (pMac->lim.gDebugP2pRemainOnChannel)
454 {
455 pMac->lim.remOnChnSeqNum++;
456 if( eHAL_STATUS_SUCCESS == limPrepareAndSendStartRemainOnChannelMsg(
457 pMac, MsgRemainonChannel,
458 REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME) )
459 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530460 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530461 "%s: Successfully sent 1st marker frame with seq num = %d"
462 " on start ROC", __func__, pMac->lim.remOnChnSeqNum);
463 }
464 }
465
Gopichand Nakkala924e4552013-05-08 19:18:14 +0530466 if ((limSetLinkState(pMac, MsgRemainonChannel->isProbeRequestAllowed?
467 eSIR_LINK_LISTEN_STATE:eSIR_LINK_SEND_ACTION_STATE,nullBssid,
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 pMac->lim.gSelfMacAddr, limSetLinkStateP2PCallback,
469 NULL)) != eSIR_SUCCESS)
470 {
471 limLog( pMac, LOGE, "Unable to change link state");
472 goto error;
473 }
474
475 return;
476error:
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
478 return;
479}
480
481/*------------------------------------------------------------------
482 *
Viral Modid86bde22012-12-10 13:09:21 -0800483 * lim Insert NOA timer timeout callback - when timer fires, deactivate it and send
484 * scan rsp to csr/hdd
485 *
486 *------------------------------------------------------------------*/
487void limProcessInsertSingleShotNOATimeout(tpAniSirGlobal pMac)
488{
Viral Modid440e682013-03-06 02:25:31 -0800489 /* timeout means start NOA did not arrive; we need to deactivate and change the timer for
490 * future activations
Viral Modid86bde22012-12-10 13:09:21 -0800491 */
492 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800493
Viral Modid440e682013-03-06 02:25:31 -0800494 /* Even if insert NOA timedout, go ahead and process/send stored SME request */
495 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
Gopichand Nakkala4261ea52012-12-31 16:43:00 -0800496
Viral Modid86bde22012-12-10 13:09:21 -0800497 return;
498}
499
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530500/*-----------------------------------------------------------------
501 * lim Insert Timer callback function to check active DFS channels
502 * and convert them to passive channels if there was no
503 * beacon/proberesp for MAX_TIME_TO_BE_ACTIVE_CHANNEL time
504 *------------------------------------------------------------------*/
505void limConvertActiveChannelToPassiveChannel(tpAniSirGlobal pMac )
506{
507 tANI_U32 currentTime;
508 tANI_U32 lastTime = 0;
509 tANI_U32 timeDiff;
510 tANI_U8 i;
511 currentTime = vos_timer_get_system_time();
512 for (i = 1; i < SIR_MAX_24G_5G_CHANNEL_RANGE ; i++)
513 {
514 if ((pMac->lim.dfschannelList.timeStamp[i]) != 0)
515 {
516 lastTime = pMac->lim.dfschannelList.timeStamp[i];
517 if (currentTime >= lastTime)
518 {
519 timeDiff = (currentTime - lastTime);
520 }
521 else
522 {
523 timeDiff = (0xFFFFFFFF - lastTime) + currentTime;
524 }
525
526 if (timeDiff >= MAX_TIME_TO_BE_ACTIVE_CHANNEL)
527 {
528 limCovertChannelScanType( pMac, i,FALSE);
529 pMac->lim.dfschannelList.timeStamp[i] = 0;
530 }
531 }
532 }
533 /* lastTime is zero if there is no DFS active channels in the list.
534 * If this is non zero then we have active DFS channels so restart the timer.
535 */
536 if (lastTime != 0)
537 {
538 if (tx_timer_activate(
539 &pMac->lim.limTimers.gLimActiveToPassiveChannelTimer)
540 != TX_SUCCESS)
541 {
542 limLog(pMac, LOGE, FL("Could not activate Active to Passive Channel timer"));
543 }
544 }
545
546 return;
547
548}
549
Viral Modid86bde22012-12-10 13:09:21 -0800550/*------------------------------------------------------------------
551 *
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530552 * limSetLinkState callback function.
553 *
554 *------------------------------------------------------------------*/
555void limSetlinkStateCallback(tpAniSirGlobal pMac, void *callbackArg)
556{
557 if(pMac->lim.gDebugP2pRemainOnChannel)
558 {
559 if (eHAL_STATUS_SUCCESS == limPrepareAndSendCancelRemainOnChannelMsg(
560 pMac,
561 REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME))
562 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530563 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530564 "%s: Successfully sent 2nd marker frame with seq num=%d"
565 " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum);
566 }
567 }
568
569 return;
570
571}
572
573/*------------------------------------------------------------------
574 *
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 * limchannelchange callback, on success channel change, set the
576 * link_state to LISTEN
577 *
578 *------------------------------------------------------------------*/
579
580void limProcessRemainOnChnTimeout(tpAniSirGlobal pMac)
581{
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530582 tpPESession psessionEntry;
583 tANI_U8 sessionId;
584 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
Jeff Johnson295189b2012-06-20 16:38:30 -0700586
587 if (NULL == pMac->lim.gpLimRemainOnChanReq)
588 {
589 limLog( pMac, LOGE, "No Remain on channel pending");
590 return;
591 }
592
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530593 if(pMac->lim.gDebugP2pRemainOnChannel)
594 {
595 if (eHAL_STATUS_SUCCESS == limPrepareAndSendCancelRemainOnChannelMsg(
596 pMac,
597 REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME))
598 {
Rashmi Ramannac7744532013-10-06 16:49:08 +0530599 limLog( pMac, LOGE,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530600 "%s: Successfully sent 1st marker frame with seqnum = %d"
601 " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum);
602 }
603 }
604
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 /* get the previous valid LINK state */
606 if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid,
Rashmi Ramannad3a03bf2013-12-31 18:33:24 +0530607 pMac->lim.gSelfMacAddr, limSetlinkStateCallback, NULL) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 {
609 limLog( pMac, LOGE, "Unable to change link state");
610 return;
611 }
612
613 if (pMac->lim.gLimMlmState != eLIM_MLM_P2P_LISTEN_STATE )
614 {
615 limRemainOnChnRsp(pMac,eHAL_STATUS_SUCCESS, NULL);
616 }
617 else
618 {
619 /* get the session */
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530620 if((psessionEntry = peFindSessionByBssid(
621 pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 {
623 limLog(pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700624 FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 goto error;
626 }
627
628 limExitRemainOnChannel(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry);
629 return;
630error:
631 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
632 }
633 return;
634}
635
636
637/*------------------------------------------------------------------
638 *
639 * limchannelchange callback, on success channel change, set the link_state
640 * to LISTEN
641 *
642 *------------------------------------------------------------------*/
643
644void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status,
645 tANI_U32 *data, tpPESession psessionEntry)
646{
647
648 if (status != eHAL_STATUS_SUCCESS)
649 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700650 PELOGE(limLog( pMac, LOGE, "Remain on Channel Failed");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 goto error;
652 }
653 //Set the resume channel to Any valid channel (invalid).
654 //This will instruct HAL to set it to any previous valid channel.
655 peSetResumeChannel(pMac, 0, 0);
656 limResumeLink(pMac, limRemainOnChnRsp, NULL);
657 return;
658error:
659 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
660 return;
661}
662
663/*------------------------------------------------------------------
664 *
665 * Send remain on channel respone: Success/ Failure
666 *
667 *------------------------------------------------------------------*/
668void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
669{
670 tpPESession psessionEntry;
671 tANI_U8 sessionId;
672 tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq;
673 tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530674 tANI_U32 txStatus = 0;
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530675 tSirTxBdStatus txBdStatus = {0};
676
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 if ( NULL == MsgRemainonChannel )
678 {
679 PELOGE(limLog( pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700680 "%s: No Pointer for Remain on Channel Req", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 return;
682 }
683
Rashmi Ramannac7744532013-10-06 16:49:08 +0530684 limLog( pMac, LOG1, "Remain on channel rsp with status %d", status);
685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 //Incase of the Remain on Channel Failure Case
687 //Cleanup Everything
688 if(eHAL_STATUS_FAILURE == status)
689 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 //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;
Deepthi Gowri3ab7bff2015-04-15 20:24:39 +0530700 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 }
702
703 /* delete the session */
704 if((psessionEntry = peFindSessionByBssid(pMac,
705 MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL)
706 {
707 if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole )
708 {
709 peDeleteSession( pMac, psessionEntry);
710 }
711 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700712
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 /* Post the meessage to Sme */
Rashmi Ramannac7744532013-10-06 16:49:08 +0530714 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 MsgRemainonChannel->sessionId, 0);
716
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530717 vos_mem_free(pMac->lim.gpLimRemainOnChanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 pMac->lim.gpLimRemainOnChanReq = NULL;
719
720 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700721
722 /* If remain on channel timer expired and action frame is pending then
723 * indicaiton confirmation with status failure */
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800724 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700725 {
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530726 limLog(pMac, LOGE,
727 FL("Remain on channel expired, Action frame status failure"));
728
729 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
730 limP2PActionCnf(pMac, &txBdStatus);
731 else
732 limP2PActionCnf(pMac, &txStatus);
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 }
734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 return;
736}
737
738/*------------------------------------------------------------------
739 *
740 * Indicate the Mgmt Frame received to SME to HDD callback
741 * handle Probe_req/Action frame currently
742 *
743 *------------------------------------------------------------------*/
744void limSendSmeMgmtFrameInd(
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530745 tpAniSirGlobal pMac, tANI_U16 sessionId,
746 tANI_U8 *pRxPacketInfo, tpPESession psessionEntry,
Chilam NG571c65a2013-01-19 12:27:36 +0530747 tANI_S8 rxRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700748{
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530749 tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 tANI_U16 length;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530751 tANI_U8 frameType;
752 tpSirMacMgmtHdr frame;
753 tANI_U32 frameLen;
754 tANI_U8 rfBand = 0;
755 tANI_U32 rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700756
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530757 frame = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
758 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) + sizeof(tSirMacMgmtHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 length = sizeof(tSirSmeMgmtFrameInd) + frameLen;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530760 frameType = frame->fc.subType;
761 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
762 rxChannel = WDA_GET_RX_CH( pRxPacketInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -0700763
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530764 pSirSmeMgmtFrame = vos_mem_malloc(length);
765 if (NULL == pSirSmeMgmtFrame)
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 {
767 limLog(pMac, LOGP,
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530768 FL("AllocateMemory failed for eWNI_SME_LISTEN_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 return;
770 }
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530771 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772
Abhishek Singh7d624e12015-11-30 14:29:27 +0530773 pSirSmeMgmtFrame->frameLen = frameLen;
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 pSirSmeMgmtFrame->sessionId = sessionId;
775 pSirSmeMgmtFrame->frameType = frameType;
Chilam NG571c65a2013-01-19 12:27:36 +0530776 pSirSmeMgmtFrame->rxRssi = rxRssi;
Jeff Johnsone7245742012-09-05 17:12:55 -0700777
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530778 if (( IS_5G_BAND(rfBand)))
779 {
780 rxChannel = limUnmapChannel(rxChannel);
781 limLog(pMac, LOG1,
782 FL("rxChannel after unmapping is %d"), rxChannel);
783 if ( !rxChannel )
784 {
785 tpPESession pTempSessionEntry = limIsApSessionActive(pMac);
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530786 if(pMac->lim.gpLimRemainOnChanReq != NULL)
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530787 {
788 rxChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
789 limLog(pMac, LOG1,
790 FL("ROC timer is running."
791 " Assign ROC channel to rxChannel i.e., %d"), rxChannel);
792 }
793 else if ( (pTempSessionEntry != NULL) &&
794 (SIR_BAND_5_GHZ !=
795 limGetRFBand(pTempSessionEntry->currentOperChannel)) )
796 limLog(pMac, LOGW,
797 FL("No active p2p GO in 5GHz"
798 " but recvd Action frame in 5GHz"));
799 }
800 }
801
Sunil Ravif0998942013-02-04 07:01:12 -0800802 /*
803 * Work around to address LIM sending wrong channel to HDD for p2p action
804 * frames(In case of auto GO) recieved on 5GHz channel.
805 * As RXP has only 4bits to store the channel, we need some mechanism to
806 * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer
807 * is not running and if we get a frame then pass the Go session
808 * operating channel to HDD. Some vendors create separate p2p interface
809 * after group formation. In that case LIM session entry will be NULL for
810 * p2p device address. So search for p2p go session and pass it's
811 * operating channel.
812 * Need to revisit this path in case of GO+CLIENT concurrency.
Jeff Johnsone7245742012-09-05 17:12:55 -0700813 */
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530814 if (NULL == pMac->lim.gpLimRemainOnChanReq)
Jeff Johnsone7245742012-09-05 17:12:55 -0700815 {
Sunil Ravif0998942013-02-04 07:01:12 -0800816 tpPESession pTempSessionEntry = psessionEntry;
817 if( ( (NULL != pTempSessionEntry) ||
818 (pTempSessionEntry = limIsApSessionActive(pMac)) ) &&
819 (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) )
820 {
821 rxChannel = pTempSessionEntry->currentOperChannel;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530822 limLog(pMac, LOG1,
823 FL("Invalid rxChannel."
824 " Assign GO session op channel to rxChannel i.e., %d"), rxChannel);
Sunil Ravif0998942013-02-04 07:01:12 -0800825 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700826 }
Sunil Ravif0998942013-02-04 07:01:12 -0800827
828 pSirSmeMgmtFrame->rxChan = rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700829
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530830 vos_mem_zero(pSirSmeMgmtFrame->frameBuf, frameLen);
831 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832
Abhishek Singh7d624e12015-11-30 14:29:27 +0530833 if (pMac->mgmt_frame_ind_cb)
834 pMac->mgmt_frame_ind_cb(pSirSmeMgmtFrame);
835 else
836 {
837 limLog(pMac, LOGW,
838 FL("Management indication callback not registered!!"));
839 }
840 vos_mem_free(pSirSmeMgmtFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 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);
Agrawal Ashishb10d0392015-08-06 16:18:20 +0530896
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes,
898 DOT11F_EID_HTCAPS,ONE_BYTE);
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800899 limLog( pMac, LOG2, FL("pIe %p dot11HtCap.supportedMCSSet[0]=0x%x"),
900 pIe, dot11HtCap.supportedMCSSet[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if(pIe)
902 {
903 tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure
904 pHtcap->advCodingCap = dot11HtCap.advCodingCap;
905 pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet;
906 pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave;
907 pHtcap->greenField = dot11HtCap.greenField;
908 pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz;
909 pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz;
910 pHtcap->txSTBC = dot11HtCap.txSTBC;
911 pHtcap->rxSTBC = dot11HtCap.rxSTBC;
912 pHtcap->delayedBA = dot11HtCap.delayedBA ;
913 pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize;
914 pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz;
915 pHtcap->psmp = dot11HtCap.psmp;
916 pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame;
917 pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection;
918 pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor;
919 pHtcap->mpduDensity = dot11HtCap.mpduDensity;
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530920 vos_mem_copy((void *)pHtcap->supportedMCSSet,
921 (void *)(dot11HtCap.supportedMCSSet),
922 sizeof(pHtcap->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 pHtcap->pco = dot11HtCap.pco;
924 pHtcap->transitionTime = dot11HtCap.transitionTime;
925 pHtcap->mcsFeedback = dot11HtCap.mcsFeedback;
926 pHtcap->txBF = dot11HtCap.txBF;
927 pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding;
928 pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding;
929 pHtcap->rxZLF = dot11HtCap.rxZLF;
930 pHtcap->txZLF = dot11HtCap.txZLF;
931 pHtcap->implicitTxBF = dot11HtCap.implicitTxBF;
932 pHtcap->calibration = dot11HtCap.calibration;
933 pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF;
934 pHtcap->explicitUncompressedSteeringMatrix =
935 dot11HtCap.explicitUncompressedSteeringMatrix;
936 pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback;
937 pHtcap->explicitUncompressedSteeringMatrixFeedback =
938 dot11HtCap.explicitUncompressedSteeringMatrixFeedback;
939 pHtcap->explicitCompressedSteeringMatrixFeedback =
940 dot11HtCap.explicitCompressedSteeringMatrixFeedback;
941 pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae;
942 pHtcap->uncompressedSteeringMatrixBFAntennae =
943 dot11HtCap.uncompressedSteeringMatrixBFAntennae;
944 pHtcap->compressedSteeringMatrixBFAntennae =
945 dot11HtCap.compressedSteeringMatrixBFAntennae;
946 pHtcap->antennaSelection = dot11HtCap.antennaSelection;
947 pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx;
948 pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx;
949 pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback;
950 pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback;
951 pHtcap->rxAS = dot11HtCap.rxAS;
952 pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs;
953 }
954}
955
956
957void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
958{
959 tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr;
960 tANI_U32 nBytes;
961 tANI_U8 *pFrame;
962 void *pPacket;
963 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530964 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data;
966 tANI_U8 noaLen = 0;
Krunal Sonic768a932013-05-15 19:26:30 -0700967 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + (2*SIR_P2P_IE_HEADER_LEN)];
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 tANI_U8 origLen = 0;
969 tANI_U8 sessionId = 0;
970 v_U8_t *pP2PIe = NULL;
971 tpPESession psessionEntry;
972 v_U8_t *pPresenceRspNoaAttr = NULL;
973 v_U8_t *pNewP2PIe = NULL;
974 v_U16_t remainLen = 0;
Abhishek Singh0ebac9c2014-06-25 13:34:12 +0530975#ifdef WLAN_FEATURE_11W
976 tpSirMacMgmtHdr pMacHdr;
977 tpSirMacActionFrameHdr pActionHdr;
978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg);
980
981 limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"),
982 pFc->type, pFc->subType);
983
984 psessionEntry = peFindSessionByBssid(pMac,
985 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
986
987 /* Check for session corresponding to ADDR2 As Supplicant is filling
988 ADDR2 with BSSID */
989 if( NULL == psessionEntry )
990 {
991 psessionEntry = peFindSessionByBssid(pMac,
992 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
993 }
994
995 if( NULL == psessionEntry )
996 {
997 tANI_U8 isSessionActive = 0;
998 tANI_U8 i;
999
1000 /* If we are not able to find psessionEntry entry, then try to find
1001 active session, if found any active sessions then send the
1002 action frame, If no active sessions found then drop the frame */
1003 for (i =0; i < pMac->lim.maxBssId;i++)
1004 {
1005 psessionEntry = peFindSessionBySessionId(pMac,i);
1006 if ( NULL != psessionEntry)
1007 {
1008 isSessionActive = 1;
1009 break;
1010 }
1011 }
1012 if( !isSessionActive )
1013 {
1014 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1015 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1016 return;
1017 }
1018 }
1019
1020 if ((SIR_MAC_MGMT_FRAME == pFc->type)&&
1021 ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)||
1022 (SIR_MAC_MGMT_ACTION == pFc->subType)))
1023 {
1024 //if this is a probe RSP being sent from wpa_supplicant
1025 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1026 {
1027 //get proper offset for Probe RSP
1028 pP2PIe = limGetP2pIEPtr(pMac,
1029 (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
1030 nBytes - PROBE_RSP_IE_OFFSET);
1031 while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1]))
1032 {
1033 remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data);
1034 if (remainLen > 2)
1035 {
1036 pNewP2PIe = limGetP2pIEPtr(pMac,
1037 pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen);
1038 }
1039 if (pNewP2PIe)
1040 {
1041 pP2PIe = pNewP2PIe;
1042 pNewP2PIe = NULL;
1043 }
1044 else
1045 {
1046 break;
1047 }
1048 } //end of while
1049 }
1050 else
1051 {
1052 if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY ==
1053 *((v_U8_t *)pMbMsg->data+ACTION_OFFSET))
1054 {
1055 tpSirMacP2PActionFrameHdr pActionHdr =
1056 (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data +
1057 ACTION_OFFSET);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301058 if (vos_mem_compare( pActionHdr->Oui,
1059 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP ==
1061 pActionHdr->OuiSubType))
1062 { //In case of Presence RSP response
1063 pP2PIe = limGetP2pIEPtr(pMac,
1064 (v_U8_t *)pMbMsg->data + ACTION_OFFSET +
1065 sizeof(tSirMacP2PActionFrameHdr),
1066 (nBytes - ACTION_OFFSET -
1067 sizeof(tSirMacP2PActionFrameHdr)));
1068 if( NULL != pP2PIe )
1069 {
1070 //extract the presence of NoA attribute inside P2P IE
1071 pPresenceRspNoaAttr =
1072 limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN,
1073 pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE);
1074 }
1075 }
1076 }
1077 }
1078
1079 if (pP2PIe != NULL)
1080 {
1081 //get NoA attribute stream P2P IE
1082 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
1083 //need to append NoA attribute in P2P IE
1084 if (noaLen > 0)
1085 {
1086 origLen = pP2PIe[1];
1087 //if Presence Rsp has NoAttr
1088 if (pPresenceRspNoaAttr)
1089 {
1090 v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] |
1091 (pPresenceRspNoaAttr[2]<<8);
1092 /*One byte for attribute, 2bytes for length*/
1093 origLen -= (noaAttrLen + 1 + 2);
1094 //remove those bytes to copy
1095 nBytes -= (noaAttrLen + 1 + 2);
1096 //remove NoA from original Len
1097 pP2PIe[1] = origLen;
1098 }
1099 if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH)
1100 {
1101 //Form the new NoA Byte array in multiple P2P IEs
1102 noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream,
1103 noaLen,((pP2PIe[1] + (tANI_U16)noaLen)-
1104 SIR_MAC_MAX_IE_LENGTH));
1105 pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH;
1106 }
1107 else
1108 {
1109 pP2PIe[1] += noaLen; //increment the length of P2P IE
1110 }
1111 nBytes += noaLen;
1112 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001113 FL("noaLen=%d origLen=%d pP2PIe=%p"
Jeff Johnsonf2de0392013-11-22 18:28:57 -08001114 " nBytes=%d nBytesToCopy=%zu"),
1115 noaLen,origLen, pP2PIe, nBytes,
1116 ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 }
1118 }
1119
1120 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1121 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001122 limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
Madan Mohan Koyyalamudifb29a5d2012-10-11 12:14:17 -07001123 nBytes - PROBE_RSP_IE_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 }
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301125 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
1126 (0 != pMbMsg->wait))
Jeff Johnsone7245742012-09-05 17:12:55 -07001127 {
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301128 if (pMac->lim.gpLimRemainOnChanReq == NULL)
1129 {
1130 limLog( pMac, LOGE,
Sushant Kaushik87787972015-09-11 16:05:00 +05301131 FL("Failed to Send Action frame"));
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301132 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1133 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1134 return;
1135 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 }
1138
1139
1140 // Ok-- try to allocate some memory:
1141 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1142 (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket);
1143 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1144 {
1145 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001146 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 return;
1148 }
1149
1150 // Paranoia:
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301151 vos_mem_set(pFrame, nBytes, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001152
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +05301153 if ((noaLen > 0) && (noaLen<(SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 {
1155 // Add 2 bytes for length and Arribute field
1156 v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) -
1157 (v_U8_t *)pMbMsg->data);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301158 vos_mem_copy(pFrame, pMbMsg->data, nBytesToCopy);
1159 vos_mem_copy((pFrame + nBytesToCopy), noaStream, noaLen);
1160 vos_mem_copy((pFrame + nBytesToCopy + noaLen),
1161 pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001162
1163 }
1164 else
1165 {
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301166 vos_mem_copy(pFrame, pMbMsg->data, nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 }
1168
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301169#ifdef WLAN_FEATURE_11W
1170 pActionHdr = (tpSirMacActionFrameHdr) (pFrame + sizeof(tSirMacMgmtHdr));
Abhishek Singhdc9fc412016-01-19 15:53:02 +05301171 pMacHdr = (tpSirMacMgmtHdr)pFrame;
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301172
1173 /*
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301174 * Setting Protected bit only for Robust Action Frames
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301175 * This has to be based on the current Connection with the station
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301176 * limSetProtectedBit API will set the protected bit if connection is PMF
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301177 */
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301178 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301179 psessionEntry->limRmfEnabled && (!limIsGroupAddr(pMacHdr->da)) &&
Abhishek Singhdc9fc412016-01-19 15:53:02 +05301180 lim_is_robust_mgmt_action_frame(pActionHdr->category)) {
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301181 /* All psession checks are already done at start */
1182 limSetProtectedBit(pMac, psessionEntry, pMacHdr->da, pMacHdr);
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301183
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301184 }
1185#endif
1186
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 /* Use BD rate 2 for all P2P related frames. As these frames need to go
1188 * at OFDM rates. And BD rate2 we configured at 6Mbps.
1189 */
1190 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1191
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301192 if (SIR_MAC_MGMT_ACTION == pFc->subType)
1193 {
1194 limLog( pMac, LOG1, FL("Sending Action Frame over WQ5"));
1195 txFlag |= HAL_USE_FW_IN_TX_PATH;
1196 }
1197
Jeff Johnsone7245742012-09-05 17:12:55 -07001198 if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) ||
1199 (pMbMsg->noack)
1200 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 {
1202 halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes,
1203 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1204 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1205 txFlag );
1206
Jeff Johnsone7245742012-09-05 17:12:55 -07001207 if (!pMbMsg->noack)
1208 {
1209 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 halstatus, pMbMsg->sessionId, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001211 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001212 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 }
1214 else
1215 {
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +05301216 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes,
1218 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1219 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301220 limP2PActionCnf, txFlag, pMac->lim.txBdToken++ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001221
1222 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1223 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001224 limLog( pMac, LOGE, FL("could not send action frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus,
1226 pMbMsg->sessionId, 0);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001227 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 }
1229 else
1230 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001231 pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001232 limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %u" ),
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001233 pMac->lim.mgmtFrameSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07001234
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 }
1236 }
1237
1238 return;
1239}
1240
1241
1242void limAbortRemainOnChan(tpAniSirGlobal pMac)
1243{
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +05301244 limProcessRemainOnChnTimeout(pMac);
1245 limLog( pMac, LOG1, FL("Abort ROC !!!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 return;
1247}
1248
1249/* Power Save Related Functions */
1250tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1251{
1252 tpP2pPsConfig pNoA;
1253 tpP2pPsParams pMsgNoA;
1254 tSirMsgQ msg;
1255
1256 pNoA = (tpP2pPsConfig) pMsgBuf;
1257
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301258 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
1259 if (NULL == pMsgNoA)
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 {
1261 limLog( pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001262 FL( "Unable to allocate memory during NoA Update" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 return eSIR_MEM_ALLOC_FAILED;
1264 }
1265
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301266 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 pMsgNoA->opp_ps = pNoA->opp_ps;
1268 pMsgNoA->ctWindow = pNoA->ctWindow;
1269 pMsgNoA->duration = pNoA->duration;
1270 pMsgNoA->interval = pNoA->interval;
1271 pMsgNoA->count = pNoA->count;
1272 pMsgNoA->single_noa_duration = pNoA->single_noa_duration;
1273 pMsgNoA->psSelection = pNoA->psSelection;
1274
Viral Modid86bde22012-12-10 13:09:21 -08001275 msg.type = WDA_SET_P2P_GO_NOA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 msg.reserved = 0;
1277 msg.bodyptr = pMsgNoA;
1278 msg.bodyval = 0;
1279
1280 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1281 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001282 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 return eSIR_FAILURE;
1284 }
1285
1286 return eSIR_SUCCESS;
1287} /*** end __limProcessSmeGoNegReq() ***/
1288
Jeff Johnson295189b2012-06-20 16:38:30 -07001289