blob: 52439a2c0c43461ca866986272041af05a4303b7 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson0fe596e2017-09-19 08:36:48 -07002 * Copyright (c) 2012-2014, 2016-2017 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{
Abhishek Singh6fcdf652016-11-23 10:59:12 +0530507 v_TIME_t currentTime;
508 v_TIME_t lastTime = 0;
509 v_TIME_t timeDiff;
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530510 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
Deepthi Gowri3ab7bff2015-04-15 20:24:39 +0530698 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 }
700
701 /* delete the session */
702 if((psessionEntry = peFindSessionByBssid(pMac,
703 MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL)
704 {
705 if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole )
706 {
707 peDeleteSession( pMac, psessionEntry);
708 }
709 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700710
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 /* Post the meessage to Sme */
Rashmi Ramannac7744532013-10-06 16:49:08 +0530712 limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 MsgRemainonChannel->sessionId, 0);
714
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530715 vos_mem_free(pMac->lim.gpLimRemainOnChanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 pMac->lim.gpLimRemainOnChanReq = NULL;
717
718 pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700719
720 /* If remain on channel timer expired and action frame is pending then
721 * indicaiton confirmation with status failure */
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800722 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700723 {
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530724 limLog(pMac, LOGE,
725 FL("Remain on channel expired, Action frame status failure"));
726
727 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
728 limP2PActionCnf(pMac, &txBdStatus);
729 else
730 limP2PActionCnf(pMac, &txStatus);
Jeff Johnsone7245742012-09-05 17:12:55 -0700731 }
732
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 return;
734}
735
736/*------------------------------------------------------------------
737 *
738 * Indicate the Mgmt Frame received to SME to HDD callback
739 * handle Probe_req/Action frame currently
740 *
741 *------------------------------------------------------------------*/
742void limSendSmeMgmtFrameInd(
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530743 tpAniSirGlobal pMac, tANI_U16 sessionId,
744 tANI_U8 *pRxPacketInfo, tpPESession psessionEntry,
Chilam NG571c65a2013-01-19 12:27:36 +0530745 tANI_S8 rxRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700746{
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530747 tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 tANI_U16 length;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530749 tANI_U8 frameType;
750 tpSirMacMgmtHdr frame;
751 tANI_U32 frameLen;
752 tANI_U8 rfBand = 0;
753 tANI_U32 rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700754
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530755 frame = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
756 frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) + sizeof(tSirMacMgmtHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 length = sizeof(tSirSmeMgmtFrameInd) + frameLen;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530758 frameType = frame->fc.subType;
759 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
760 rxChannel = WDA_GET_RX_CH( pRxPacketInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530762 pSirSmeMgmtFrame = vos_mem_malloc(length);
763 if (NULL == pSirSmeMgmtFrame)
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 {
765 limLog(pMac, LOGP,
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530766 FL("AllocateMemory failed for eWNI_SME_LISTEN_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return;
768 }
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530769 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
Abhishek Singh7d624e12015-11-30 14:29:27 +0530771 pSirSmeMgmtFrame->frameLen = frameLen;
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 pSirSmeMgmtFrame->sessionId = sessionId;
773 pSirSmeMgmtFrame->frameType = frameType;
Chilam NG571c65a2013-01-19 12:27:36 +0530774 pSirSmeMgmtFrame->rxRssi = rxRssi;
Jeff Johnsone7245742012-09-05 17:12:55 -0700775
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530776 if (( IS_5G_BAND(rfBand)))
777 {
778 rxChannel = limUnmapChannel(rxChannel);
779 limLog(pMac, LOG1,
780 FL("rxChannel after unmapping is %d"), rxChannel);
781 if ( !rxChannel )
782 {
783 tpPESession pTempSessionEntry = limIsApSessionActive(pMac);
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530784 if(pMac->lim.gpLimRemainOnChanReq != NULL)
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530785 {
786 rxChannel = pMac->lim.gpLimRemainOnChanReq->chnNum;
787 limLog(pMac, LOG1,
788 FL("ROC timer is running."
789 " Assign ROC channel to rxChannel i.e., %d"), rxChannel);
790 }
791 else if ( (pTempSessionEntry != NULL) &&
792 (SIR_BAND_5_GHZ !=
793 limGetRFBand(pTempSessionEntry->currentOperChannel)) )
794 limLog(pMac, LOGW,
795 FL("No active p2p GO in 5GHz"
796 " but recvd Action frame in 5GHz"));
797 }
798 }
799
Sunil Ravif0998942013-02-04 07:01:12 -0800800 /*
801 * Work around to address LIM sending wrong channel to HDD for p2p action
802 * frames(In case of auto GO) recieved on 5GHz channel.
803 * As RXP has only 4bits to store the channel, we need some mechanism to
804 * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer
805 * is not running and if we get a frame then pass the Go session
806 * operating channel to HDD. Some vendors create separate p2p interface
807 * after group formation. In that case LIM session entry will be NULL for
808 * p2p device address. So search for p2p go session and pass it's
809 * operating channel.
810 * Need to revisit this path in case of GO+CLIENT concurrency.
Jeff Johnsone7245742012-09-05 17:12:55 -0700811 */
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +0530812 if (NULL == pMac->lim.gpLimRemainOnChanReq)
Jeff Johnsone7245742012-09-05 17:12:55 -0700813 {
Sunil Ravif0998942013-02-04 07:01:12 -0800814 tpPESession pTempSessionEntry = psessionEntry;
815 if( ( (NULL != pTempSessionEntry) ||
816 (pTempSessionEntry = limIsApSessionActive(pMac)) ) &&
817 (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) )
818 {
819 rxChannel = pTempSessionEntry->currentOperChannel;
Rashmi Ramanna0d0adec2014-02-05 20:35:37 +0530820 limLog(pMac, LOG1,
821 FL("Invalid rxChannel."
822 " Assign GO session op channel to rxChannel i.e., %d"), rxChannel);
Sunil Ravif0998942013-02-04 07:01:12 -0800823 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700824 }
Sunil Ravif0998942013-02-04 07:01:12 -0800825
826 pSirSmeMgmtFrame->rxChan = rxChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -0700827
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530828 vos_mem_zero(pSirSmeMgmtFrame->frameBuf, frameLen);
829 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830
Abhishek Singh7d624e12015-11-30 14:29:27 +0530831 if (pMac->mgmt_frame_ind_cb)
832 pMac->mgmt_frame_ind_cb(pSirSmeMgmtFrame);
833 else
834 {
835 limLog(pMac, LOGW,
836 FL("Management indication callback not registered!!"));
837 }
838 vos_mem_free(pSirSmeMgmtFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 return;
840} /*** end limSendSmeListenRsp() ***/
841
842
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530843eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, void *pData)
Jeff Johnson295189b2012-06-20 16:38:30 -0700844{
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530845 tANI_U32 txCompleteSuccess;
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530846 tpSirTxBdStatus pTxBdStatus;
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530847
848 if (!pData)
849 {
850 limLog(pMac, LOG1,
851 FL(" pData is NULL"));
852 return eHAL_STATUS_FAILURE;
853 }
854
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530855 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
856 {
857 pTxBdStatus = (tpSirTxBdStatus) pData;
858 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530859
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530860 limLog(pMac, LOG1,
861 FL("txCompleteSuccess %d, Token %u, Session Id %d"),
862 txCompleteSuccess, pTxBdStatus->txBdToken,
863 pMac->lim.mgmtFrameSessionId);
864 }
865 else
866 {
867 txCompleteSuccess = *((tANI_U32*) pData);
868
869 limLog(pMac, LOG1,
870 FL(" %s txCompleteSuccess %d, Session Id %d"),
871 __func__, txCompleteSuccess, pMac->lim.mgmtFrameSessionId);
872 }
873
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800874 if (pMac->lim.mgmtFrameSessionId != 0xff)
Jeff Johnsone7245742012-09-05 17:12:55 -0700875 {
876 /* The session entry might be invalid(0xff) action confirmation received after
877 * remain on channel timer expired */
878 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
879 (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL),
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800880 pMac->lim.mgmtFrameSessionId, 0);
881 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnsone7245742012-09-05 17:12:55 -0700882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883
884 return eHAL_STATUS_SUCCESS;
885}
886
887
Jeff Johnsone7245742012-09-05 17:12:55 -0700888void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes)
Jeff Johnson295189b2012-06-20 16:38:30 -0700889{
890 v_U8_t *pIe=NULL;
891 tDot11fIEHTCaps dot11HtCap;
892
Jeff Johnsone7245742012-09-05 17:12:55 -0700893 PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap);
Agrawal Ashishb10d0392015-08-06 16:18:20 +0530894
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes,
896 DOT11F_EID_HTCAPS,ONE_BYTE);
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700897 limLog( pMac, LOG2, FL("pIe %pK dot11HtCap.supportedMCSSet[0]=0x%x"),
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800898 pIe, dot11HtCap.supportedMCSSet[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 if(pIe)
900 {
901 tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure
902 pHtcap->advCodingCap = dot11HtCap.advCodingCap;
903 pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet;
904 pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave;
905 pHtcap->greenField = dot11HtCap.greenField;
906 pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz;
907 pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz;
908 pHtcap->txSTBC = dot11HtCap.txSTBC;
909 pHtcap->rxSTBC = dot11HtCap.rxSTBC;
910 pHtcap->delayedBA = dot11HtCap.delayedBA ;
911 pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize;
912 pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz;
913 pHtcap->psmp = dot11HtCap.psmp;
914 pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame;
915 pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection;
916 pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor;
917 pHtcap->mpduDensity = dot11HtCap.mpduDensity;
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530918 vos_mem_copy((void *)pHtcap->supportedMCSSet,
919 (void *)(dot11HtCap.supportedMCSSet),
920 sizeof(pHtcap->supportedMCSSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 pHtcap->pco = dot11HtCap.pco;
922 pHtcap->transitionTime = dot11HtCap.transitionTime;
923 pHtcap->mcsFeedback = dot11HtCap.mcsFeedback;
924 pHtcap->txBF = dot11HtCap.txBF;
925 pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding;
926 pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding;
927 pHtcap->rxZLF = dot11HtCap.rxZLF;
928 pHtcap->txZLF = dot11HtCap.txZLF;
929 pHtcap->implicitTxBF = dot11HtCap.implicitTxBF;
930 pHtcap->calibration = dot11HtCap.calibration;
931 pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF;
932 pHtcap->explicitUncompressedSteeringMatrix =
933 dot11HtCap.explicitUncompressedSteeringMatrix;
934 pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback;
935 pHtcap->explicitUncompressedSteeringMatrixFeedback =
936 dot11HtCap.explicitUncompressedSteeringMatrixFeedback;
937 pHtcap->explicitCompressedSteeringMatrixFeedback =
938 dot11HtCap.explicitCompressedSteeringMatrixFeedback;
939 pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae;
940 pHtcap->uncompressedSteeringMatrixBFAntennae =
941 dot11HtCap.uncompressedSteeringMatrixBFAntennae;
942 pHtcap->compressedSteeringMatrixBFAntennae =
943 dot11HtCap.compressedSteeringMatrixBFAntennae;
944 pHtcap->antennaSelection = dot11HtCap.antennaSelection;
945 pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx;
946 pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx;
947 pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback;
948 pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback;
949 pHtcap->rxAS = dot11HtCap.rxAS;
950 pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs;
951 }
952}
953
954
955void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
956{
957 tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr;
958 tANI_U32 nBytes;
959 tANI_U8 *pFrame;
960 void *pPacket;
961 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530962 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data;
964 tANI_U8 noaLen = 0;
Krunal Sonic768a932013-05-15 19:26:30 -0700965 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + (2*SIR_P2P_IE_HEADER_LEN)];
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 tANI_U8 origLen = 0;
967 tANI_U8 sessionId = 0;
968 v_U8_t *pP2PIe = NULL;
969 tpPESession psessionEntry;
970 v_U8_t *pPresenceRspNoaAttr = NULL;
971 v_U8_t *pNewP2PIe = NULL;
972 v_U16_t remainLen = 0;
Abhishek Singh0ebac9c2014-06-25 13:34:12 +0530973#ifdef WLAN_FEATURE_11W
974 tpSirMacMgmtHdr pMacHdr;
975 tpSirMacActionFrameHdr pActionHdr;
976#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg);
978
979 limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"),
980 pFc->type, pFc->subType);
981
982 psessionEntry = peFindSessionByBssid(pMac,
983 (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId);
984
985 /* Check for session corresponding to ADDR2 As Supplicant is filling
986 ADDR2 with BSSID */
987 if( NULL == psessionEntry )
988 {
989 psessionEntry = peFindSessionByBssid(pMac,
990 (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId);
991 }
992
993 if( NULL == psessionEntry )
994 {
995 tANI_U8 isSessionActive = 0;
996 tANI_U8 i;
997
998 /* If we are not able to find psessionEntry entry, then try to find
999 active session, if found any active sessions then send the
1000 action frame, If no active sessions found then drop the frame */
1001 for (i =0; i < pMac->lim.maxBssId;i++)
1002 {
1003 psessionEntry = peFindSessionBySessionId(pMac,i);
1004 if ( NULL != psessionEntry)
1005 {
1006 isSessionActive = 1;
1007 break;
1008 }
1009 }
1010 if( !isSessionActive )
1011 {
1012 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1013 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1014 return;
1015 }
1016 }
1017
1018 if ((SIR_MAC_MGMT_FRAME == pFc->type)&&
1019 ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)||
1020 (SIR_MAC_MGMT_ACTION == pFc->subType)))
1021 {
1022 //if this is a probe RSP being sent from wpa_supplicant
1023 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1024 {
1025 //get proper offset for Probe RSP
1026 pP2PIe = limGetP2pIEPtr(pMac,
1027 (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
1028 nBytes - PROBE_RSP_IE_OFFSET);
1029 while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1]))
1030 {
1031 remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data);
1032 if (remainLen > 2)
1033 {
1034 pNewP2PIe = limGetP2pIEPtr(pMac,
1035 pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen);
1036 }
1037 if (pNewP2PIe)
1038 {
1039 pP2PIe = pNewP2PIe;
1040 pNewP2PIe = NULL;
1041 }
1042 else
1043 {
1044 break;
1045 }
1046 } //end of while
1047 }
1048 else
1049 {
1050 if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY ==
1051 *((v_U8_t *)pMbMsg->data+ACTION_OFFSET))
1052 {
1053 tpSirMacP2PActionFrameHdr pActionHdr =
1054 (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data +
1055 ACTION_OFFSET);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301056 if (vos_mem_compare( pActionHdr->Oui,
1057 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP ==
1059 pActionHdr->OuiSubType))
1060 { //In case of Presence RSP response
1061 pP2PIe = limGetP2pIEPtr(pMac,
1062 (v_U8_t *)pMbMsg->data + ACTION_OFFSET +
1063 sizeof(tSirMacP2PActionFrameHdr),
1064 (nBytes - ACTION_OFFSET -
1065 sizeof(tSirMacP2PActionFrameHdr)));
1066 if( NULL != pP2PIe )
1067 {
1068 //extract the presence of NoA attribute inside P2P IE
1069 pPresenceRspNoaAttr =
1070 limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN,
1071 pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE);
1072 }
1073 }
1074 }
1075 }
1076
1077 if (pP2PIe != NULL)
1078 {
1079 //get NoA attribute stream P2P IE
1080 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
1081 //need to append NoA attribute in P2P IE
1082 if (noaLen > 0)
1083 {
1084 origLen = pP2PIe[1];
1085 //if Presence Rsp has NoAttr
1086 if (pPresenceRspNoaAttr)
1087 {
1088 v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] |
1089 (pPresenceRspNoaAttr[2]<<8);
1090 /*One byte for attribute, 2bytes for length*/
1091 origLen -= (noaAttrLen + 1 + 2);
1092 //remove those bytes to copy
1093 nBytes -= (noaAttrLen + 1 + 2);
1094 //remove NoA from original Len
1095 pP2PIe[1] = origLen;
1096 }
1097 if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH)
1098 {
1099 //Form the new NoA Byte array in multiple P2P IEs
1100 noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream,
1101 noaLen,((pP2PIe[1] + (tANI_U16)noaLen)-
1102 SIR_MAC_MAX_IE_LENGTH));
1103 pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH;
1104 }
1105 else
1106 {
1107 pP2PIe[1] += noaLen; //increment the length of P2P IE
1108 }
1109 nBytes += noaLen;
1110 limLog( pMac, LOGE,
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001111 FL("noaLen=%d origLen=%d pP2PIe=%pK"
Jeff Johnsonf2de0392013-11-22 18:28:57 -08001112 " nBytes=%d nBytesToCopy=%zu"),
1113 noaLen,origLen, pP2PIe, nBytes,
1114 ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 }
1116 }
1117
1118 if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType)
1119 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001120 limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET,
Madan Mohan Koyyalamudifb29a5d2012-10-11 12:14:17 -07001121 nBytes - PROBE_RSP_IE_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 }
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301123 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
1124 (0 != pMbMsg->wait))
Jeff Johnsone7245742012-09-05 17:12:55 -07001125 {
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301126 if (pMac->lim.gpLimRemainOnChanReq == NULL)
1127 {
1128 limLog( pMac, LOGE,
Sushant Kaushik87787972015-09-11 16:05:00 +05301129 FL("Failed to Send Action frame"));
Kaushik, Sushantc0486222014-05-01 12:40:58 +05301130 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
1131 eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0);
1132 return;
1133 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 }
1136
1137
1138 // Ok-- try to allocate some memory:
1139 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1140 (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket);
1141 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1142 {
1143 limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001144 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 return;
1146 }
1147
1148 // Paranoia:
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301149 vos_mem_set(pFrame, nBytes, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001150
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +05301151 if ((noaLen > 0) && (noaLen<(SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 {
1153 // Add 2 bytes for length and Arribute field
1154 v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) -
1155 (v_U8_t *)pMbMsg->data);
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301156 vos_mem_copy(pFrame, pMbMsg->data, nBytesToCopy);
1157 vos_mem_copy((pFrame + nBytesToCopy), noaStream, noaLen);
1158 vos_mem_copy((pFrame + nBytesToCopy + noaLen),
1159 pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160
1161 }
1162 else
1163 {
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301164 vos_mem_copy(pFrame, pMbMsg->data, nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 }
1166
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301167#ifdef WLAN_FEATURE_11W
1168 pActionHdr = (tpSirMacActionFrameHdr) (pFrame + sizeof(tSirMacMgmtHdr));
Abhishek Singhdc9fc412016-01-19 15:53:02 +05301169 pMacHdr = (tpSirMacMgmtHdr)pFrame;
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301170
1171 /*
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301172 * Setting Protected bit only for Robust Action Frames
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301173 * This has to be based on the current Connection with the station
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301174 * limSetProtectedBit API will set the protected bit if connection is PMF
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301175 */
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301176 if ((SIR_MAC_MGMT_ACTION == pFc->subType) &&
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301177 psessionEntry->limRmfEnabled && (!limIsGroupAddr(pMacHdr->da)) &&
Abhishek Singhdc9fc412016-01-19 15:53:02 +05301178 lim_is_robust_mgmt_action_frame(pActionHdr->category)) {
Abhishek Singh09d4e4a2016-01-12 11:20:22 +05301179 /* All psession checks are already done at start */
1180 limSetProtectedBit(pMac, psessionEntry, pMacHdr->da, pMacHdr);
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301181
Abhishek Singh0ebac9c2014-06-25 13:34:12 +05301182 }
1183#endif
1184
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 /* Use BD rate 2 for all P2P related frames. As these frames need to go
1186 * at OFDM rates. And BD rate2 we configured at 6Mbps.
1187 */
1188 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1189
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301190 if (SIR_MAC_MGMT_ACTION == pFc->subType)
1191 {
1192 limLog( pMac, LOG1, FL("Sending Action Frame over WQ5"));
1193 txFlag |= HAL_USE_FW_IN_TX_PATH;
1194 }
1195
Jeff Johnsone7245742012-09-05 17:12:55 -07001196 if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) ||
1197 (pMbMsg->noack)
1198 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 {
1200 halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes,
1201 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1202 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
1203 txFlag );
1204
Jeff Johnsone7245742012-09-05 17:12:55 -07001205 if (!pMbMsg->noack)
1206 {
1207 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF,
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 halstatus, pMbMsg->sessionId, 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001209 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001210 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 }
1212 else
1213 {
Gopichand Nakkala6265d6f2013-03-20 23:32:50 +05301214 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes,
1216 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
1217 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301218 limP2PActionCnf, txFlag, pMac->lim.txBdToken++ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001219
1220 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1221 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001222 limLog( pMac, LOGE, FL("could not send action frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus,
1224 pMbMsg->sessionId, 0);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001225 pMac->lim.mgmtFrameSessionId = 0xff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 }
1227 else
1228 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001229 pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001230 limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %u" ),
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001231 pMac->lim.mgmtFrameSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07001232
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 }
1234 }
1235
1236 return;
1237}
1238
1239
1240void limAbortRemainOnChan(tpAniSirGlobal pMac)
1241{
Agarwal Ashish2f8c56e2014-04-07 16:43:37 +05301242 limProcessRemainOnChnTimeout(pMac);
1243 limLog( pMac, LOG1, FL("Abort ROC !!!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 return;
1245}
1246
1247/* Power Save Related Functions */
1248tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1249{
1250 tpP2pPsConfig pNoA;
1251 tpP2pPsParams pMsgNoA;
1252 tSirMsgQ msg;
1253
1254 pNoA = (tpP2pPsConfig) pMsgBuf;
1255
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301256 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
1257 if (NULL == pMsgNoA)
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 {
1259 limLog( pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001260 FL( "Unable to allocate memory during NoA Update" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 return eSIR_MEM_ALLOC_FAILED;
1262 }
1263
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +05301264 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 pMsgNoA->opp_ps = pNoA->opp_ps;
1266 pMsgNoA->ctWindow = pNoA->ctWindow;
1267 pMsgNoA->duration = pNoA->duration;
1268 pMsgNoA->interval = pNoA->interval;
1269 pMsgNoA->count = pNoA->count;
1270 pMsgNoA->single_noa_duration = pNoA->single_noa_duration;
1271 pMsgNoA->psSelection = pNoA->psSelection;
1272
Viral Modid86bde22012-12-10 13:09:21 -08001273 msg.type = WDA_SET_P2P_GO_NOA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 msg.reserved = 0;
1275 msg.bodyptr = pMsgNoA;
1276 msg.bodyval = 0;
1277
1278 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1279 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001280 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 return eSIR_FAILURE;
1282 }
1283
1284 return eSIR_SUCCESS;
1285} /*** end __limProcessSmeGoNegReq() ***/
1286
Jeff Johnson295189b2012-06-20 16:38:30 -07001287