Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /*=========================================================================== |
| 23 | L I M _ P 2 P . C |
| 24 | |
| 25 | OVERVIEW: |
| 26 | |
| 27 | This software unit holds the implementation of the WLAN Protocol Engine for |
| 28 | P2P. |
| 29 | |
| 30 | Copyright (c) 2011 QUALCOMM Incorporated. |
| 31 | All Rights Reserved. |
| 32 | Qualcomm Confidential and Proprietary |
| 33 | ===========================================================================*/ |
| 34 | |
| 35 | /*=========================================================================== |
| 36 | |
| 37 | EDIT HISTORY FOR FILE |
| 38 | |
| 39 | |
| 40 | This section contains comments describing changes made to the module. |
| 41 | Notice that changes are listed in reverse chronological order. |
| 42 | |
| 43 | |
| 44 | $Header$$DateTime$$Author$ |
| 45 | |
| 46 | |
| 47 | when who what, where, why |
| 48 | ---------- --- -------------------------------------------------------- |
| 49 | 2011-05-02 djindal Corrected file indentation and changed remain on channel |
| 50 | handling for concurrency. |
| 51 | ===========================================================================*/ |
| 52 | |
| 53 | |
| 54 | #ifdef WLAN_FEATURE_P2P |
| 55 | #include "limUtils.h" |
| 56 | #include "limSessionUtils.h" |
| 57 | #include "wlan_qct_wda.h" |
| 58 | |
| 59 | #define PROBE_RSP_IE_OFFSET 36 |
| 60 | #define BSSID_OFFSET 16 |
| 61 | #define ADDR2_OFFSET 10 |
| 62 | #define ACTION_OFFSET 24 |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 63 | #define LIM_MIN_REM_TIME_FOR_TX_ACTION_FRAME 50 |
| 64 | #define LIM_MIN_REM_TIME_EXT_FOR_TX_ACTION_FRAME 60 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 65 | |
| 66 | |
| 67 | |
| 68 | void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status, |
| 69 | tANI_U32 *data); |
| 70 | void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status, |
| 71 | tANI_U32 *data, tpPESession psessionEntry); |
| 72 | void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status, |
| 73 | tANI_U32 *data, tpPESession psessionEntry); |
| 74 | void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data); |
| 75 | extern tSirRetStatus limSetLinkState( |
| 76 | tpAniSirGlobal pMac, tSirLinkState state, |
| 77 | tSirMacAddr bssId, tSirMacAddr selfMacAddr, |
| 78 | tpSetLinkStateCallback callback, void *callbackArg); |
| 79 | |
| 80 | static tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 81 | eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 82 | /*------------------------------------------------------------------ |
| 83 | * |
| 84 | * Below function is callback function, it is called when |
| 85 | * WDA_SET_LINK_STATE_RSP is received from WDI. callback function for |
| 86 | * P2P of limSetLinkState |
| 87 | * |
| 88 | *------------------------------------------------------------------*/ |
| 89 | void limSetLinkStateP2PCallback(tpAniSirGlobal pMac, void *callbackArg) |
| 90 | { |
| 91 | //Send Ready on channel indication to SME |
| 92 | if(pMac->lim.gpLimRemainOnChanReq) |
| 93 | { |
| 94 | limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RDY_IND, eHAL_STATUS_SUCCESS, |
| 95 | pMac->lim.gpLimRemainOnChanReq->sessionId, 0); |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | //This is possible in case remain on channel is aborted |
| 100 | limLog( pMac, LOGE, FL(" NULL pointer of gpLimRemainOnChanReq") ); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /*------------------------------------------------------------------ |
| 105 | * |
| 106 | * Remain on channel req handler. Initiate the INIT_SCAN, CHN_CHANGE |
| 107 | * and SET_LINK Request from SME, chnNum and duration to remain on channel. |
| 108 | * |
| 109 | *------------------------------------------------------------------*/ |
| 110 | |
| 111 | |
| 112 | int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg) |
| 113 | { |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 114 | |
| 115 | /* CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE - Currently removed the special optimization when a concurrent session |
| 116 | * exists with operating channel same as P2P listen channel since it was causing issues in P2P search. The reason was |
| 117 | * STA-AP link entering BMPS when returning to home channel causing P2P search to miss Probe Reqs and hence not |
| 118 | * respond with Probe Rsp causing peer device to NOT find us. |
| 119 | * If we need this optimization, we need to find a way to keep the STA-AP link awake (no BMPS) on home channel when in listen state |
| 120 | */ |
| 121 | #ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 122 | tANI_U8 i; |
| 123 | tpPESession psessionEntry; |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 124 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 125 | #ifdef WLAN_FEATURE_P2P_INTERNAL |
| 126 | tpPESession pP2pSession; |
| 127 | #endif |
| 128 | |
| 129 | tSirRemainOnChnReq *MsgBuff = (tSirRemainOnChnReq *)pMsg; |
| 130 | pMac->lim.gpLimRemainOnChanReq = MsgBuff; |
| 131 | |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 132 | #ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 133 | for (i =0; i < pMac->lim.maxBssId;i++) |
| 134 | { |
| 135 | psessionEntry = peFindSessionBySessionId(pMac,i); |
| 136 | |
| 137 | if ( (psessionEntry != NULL) ) |
| 138 | { |
| 139 | if (psessionEntry->currentOperChannel == MsgBuff->chnNum) |
| 140 | { |
| 141 | tANI_U32 val; |
| 142 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 143 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 144 | pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time(); |
| 145 | pMac->lim.gTotalScanDuration = MsgBuff->duration; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 146 | |
| 147 | /* get the duration from the request */ |
| 148 | val = SYS_MS_TO_TICKS(MsgBuff->duration); |
| 149 | |
Madan Mohan Koyyalamudi | 709790c | 2012-09-24 12:12:51 -0700 | [diff] [blame] | 150 | limLog( pMac, LOG2, "Start listen duration = %d", val); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 151 | if (tx_timer_change( |
| 152 | &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0) |
| 153 | != TX_SUCCESS) |
| 154 | { |
| 155 | limLog(pMac, LOGP, |
| 156 | FL("Unable to change remain on channel Timer val\n")); |
| 157 | goto error; |
| 158 | } |
| 159 | else if(TX_SUCCESS != tx_timer_activate( |
| 160 | &pMac->lim.limTimers.gLimRemainOnChannelTimer)) |
| 161 | { |
| 162 | limLog(pMac, LOGP, |
| 163 | FL("Unable to activate remain on channel Timer\n")); |
| 164 | limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER); |
| 165 | goto error; |
| 166 | } |
| 167 | |
| 168 | #ifdef WLAN_FEATURE_P2P_INTERNAL |
| 169 | //Session is needed to send probe rsp |
| 170 | if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &pP2pSession)) |
| 171 | { |
| 172 | limLog( pMac, LOGE, "Unable to create session"); |
| 173 | goto error; |
| 174 | } |
| 175 | #endif |
| 176 | |
| 177 | if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE, |
| 178 | nullBssid, pMac->lim.gSelfMacAddr, |
| 179 | limSetLinkStateP2PCallback, NULL)) != eSIR_SUCCESS) |
| 180 | { |
| 181 | limLog( pMac, LOGE, "Unable to change link state"); |
| 182 | goto error; |
| 183 | } |
| 184 | return FALSE; |
| 185 | } |
| 186 | } |
| 187 | } |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 188 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 189 | pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState; |
| 190 | pMac->lim.gLimMlmState = eLIM_MLM_P2P_LISTEN_STATE; |
| 191 | |
| 192 | pMac->lim.gTotalScanDuration = MsgBuff->duration; |
| 193 | |
| 194 | /* 1st we need to suspend link with callback to initiate change channel */ |
| 195 | limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN, |
| 196 | limRemainOnChnlSuspendLinkHdlr, NULL); |
| 197 | return FALSE; |
| 198 | |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 199 | #ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 200 | error: |
| 201 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 202 | /* pMsg is freed by the caller */ |
| 203 | return FALSE; |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 204 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | |
| 208 | tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession) |
| 209 | { |
| 210 | tSirRetStatus nSirStatus = eSIR_FAILURE; |
| 211 | tpPESession psessionEntry; |
| 212 | tANI_U8 sessionId; |
| 213 | tANI_U32 val; |
| 214 | |
| 215 | if(pMac->lim.gpLimRemainOnChanReq && ppP2pSession) |
| 216 | { |
| 217 | if((psessionEntry = peCreateSession(pMac, |
| 218 | pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId, 1)) == NULL) |
| 219 | { |
| 220 | limLog(pMac, LOGE, FL("Session Can not be created \n")); |
| 221 | /* send remain on chn failure */ |
| 222 | return nSirStatus; |
| 223 | } |
| 224 | /* Store PE sessionId in session Table */ |
| 225 | psessionEntry->peSessionId = sessionId; |
| 226 | |
| 227 | psessionEntry->limSystemRole = eLIM_P2P_DEVICE_ROLE; |
| 228 | CFG_GET_STR( nSirStatus, pMac, WNI_CFG_SUPPORTED_RATES_11A, |
| 229 | psessionEntry->rateSet.rate, val , SIR_MAC_MAX_NUMBER_OF_RATES ); |
| 230 | psessionEntry->rateSet.numRates = val; |
| 231 | |
| 232 | CFG_GET_STR( nSirStatus, pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 233 | psessionEntry->extRateSet.rate, val, |
| 234 | WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN ); |
| 235 | psessionEntry->extRateSet.numRates = val; |
| 236 | |
| 237 | sirCopyMacAddr(psessionEntry->selfMacAddr, |
| 238 | pMac->lim.gpLimRemainOnChanReq->selfMacAddr); |
| 239 | |
| 240 | psessionEntry->currentOperChannel = pMac->lim.gpLimRemainOnChanReq->chnNum; |
| 241 | nSirStatus = eSIR_SUCCESS; |
| 242 | *ppP2pSession = psessionEntry; |
| 243 | } |
| 244 | |
| 245 | return nSirStatus; |
| 246 | } |
| 247 | |
| 248 | |
| 249 | /*------------------------------------------------------------------ |
| 250 | * |
| 251 | * limSuspenLink callback, on success link suspend, trigger change chn |
| 252 | * |
| 253 | * |
| 254 | *------------------------------------------------------------------*/ |
| 255 | |
| 256 | tSirRetStatus limRemainOnChnlChangeChnReq(tpAniSirGlobal pMac, |
| 257 | eHalStatus status, tANI_U32 *data) |
| 258 | { |
| 259 | tpPESession psessionEntry; |
| 260 | tANI_U8 sessionId = 0; |
| 261 | tSirRetStatus nSirStatus = eSIR_FAILURE; |
| 262 | |
| 263 | if( NULL == pMac->lim.gpLimRemainOnChanReq ) |
| 264 | { |
| 265 | //RemainOnChannel may have aborted |
| 266 | PELOGE(limLog( pMac, LOGE, FL(" gpLimRemainOnChanReq is NULL") );) |
| 267 | return nSirStatus; |
| 268 | } |
| 269 | |
| 270 | /* The link is not suspended */ |
| 271 | if (status != eHAL_STATUS_SUCCESS) |
| 272 | { |
| 273 | PELOGE(limLog( pMac, LOGE, FL(" Suspend link Failure ") );) |
| 274 | goto error; |
| 275 | } |
| 276 | |
| 277 | |
| 278 | if((psessionEntry = peFindSessionByBssid( |
| 279 | pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) != NULL) |
| 280 | { |
| 281 | goto change_channel; |
| 282 | } |
| 283 | else /* Session Entry does not exist for given BSSId */ |
| 284 | { |
| 285 | /* Try to Create a new session */ |
| 286 | if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &psessionEntry)) |
| 287 | { |
| 288 | limLog(pMac, LOGE, FL("Session Can not be created \n")); |
| 289 | /* send remain on chn failure */ |
| 290 | goto error; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | change_channel: |
| 295 | /* change channel to the requested by RemainOn Chn*/ |
| 296 | limChangeChannelWithCallback(pMac, |
| 297 | pMac->lim.gpLimRemainOnChanReq->chnNum, |
| 298 | limRemainOnChnlSetLinkStat, NULL, psessionEntry); |
| 299 | return eSIR_SUCCESS; |
| 300 | |
| 301 | error: |
| 302 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 303 | return eSIR_FAILURE; |
| 304 | } |
| 305 | |
| 306 | void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status, |
| 307 | tANI_U32 *data) |
| 308 | { |
| 309 | limRemainOnChnlChangeChnReq(pMac, status, data); |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | /*------------------------------------------------------------------ |
| 314 | * |
| 315 | * Set the LINK state to LISTEN to allow only PROBE_REQ and Action frames |
| 316 | * |
| 317 | *------------------------------------------------------------------*/ |
| 318 | void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status, |
| 319 | tANI_U32 *data, tpPESession psessionEntry) |
| 320 | { |
| 321 | tANI_U32 val; |
| 322 | tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq; |
| 323 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 324 | |
| 325 | if (status != eHAL_STATUS_SUCCESS) |
| 326 | { |
| 327 | limLog( pMac, LOGE, "%s: Change channel not successful\n"); |
| 328 | goto error1; |
| 329 | } |
| 330 | |
| 331 | // Start timer here to come back to operating channel. |
| 332 | pMac->lim.limTimers.gLimRemainOnChannelTimer.sessionId = |
| 333 | psessionEntry->peSessionId; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 334 | pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time(); |
| 335 | pMac->lim.gTotalScanDuration = MsgRemainonChannel->duration; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 336 | |
| 337 | /* get the duration from the request */ |
| 338 | val = SYS_MS_TO_TICKS(MsgRemainonChannel->duration); |
| 339 | |
Madan Mohan Koyyalamudi | 709790c | 2012-09-24 12:12:51 -0700 | [diff] [blame] | 340 | limLog( pMac, LOG2, "Start listen duration = %d", val); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 341 | if (tx_timer_change(&pMac->lim.limTimers.gLimRemainOnChannelTimer, |
| 342 | val, 0) != TX_SUCCESS) |
| 343 | { |
| 344 | /** |
| 345 | * Could not change Remain on channel Timer. Log error. |
| 346 | */ |
| 347 | limLog(pMac, LOGP, |
| 348 | FL("Unable to change remain on channel Timer val\n")); |
| 349 | goto error; |
| 350 | } |
| 351 | |
| 352 | if(TX_SUCCESS != |
| 353 | tx_timer_activate(&pMac->lim.limTimers.gLimRemainOnChannelTimer)) |
| 354 | { |
| 355 | limLog( pMac, LOGE, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 356 | "%s: remain on channel Timer Start Failed\n", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 357 | goto error; |
| 358 | } |
| 359 | |
| 360 | if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE,nullBssid, |
| 361 | pMac->lim.gSelfMacAddr, limSetLinkStateP2PCallback, |
| 362 | NULL)) != eSIR_SUCCESS) |
| 363 | { |
| 364 | limLog( pMac, LOGE, "Unable to change link state"); |
| 365 | goto error; |
| 366 | } |
| 367 | |
| 368 | return; |
| 369 | error: |
| 370 | limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER); |
| 371 | error1: |
| 372 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 373 | return; |
| 374 | } |
| 375 | |
| 376 | /*------------------------------------------------------------------ |
| 377 | * |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame^] | 378 | * lim Insert NOA timer timeout callback - when timer fires, deactivate it and send |
| 379 | * scan rsp to csr/hdd |
| 380 | * |
| 381 | *------------------------------------------------------------------*/ |
| 382 | void limProcessInsertSingleShotNOATimeout(tpAniSirGlobal pMac) |
| 383 | { |
| 384 | /* timeout means start NOA did not arrive; we need to restart the timer and |
| 385 | * send the scan response from here |
| 386 | */ |
| 387 | limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER); |
| 388 | |
| 389 | // send the scan response back and do not even call insert NOA |
| 390 | limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId); |
| 391 | return; |
| 392 | } |
| 393 | |
| 394 | /*------------------------------------------------------------------ |
| 395 | * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 396 | * limchannelchange callback, on success channel change, set the |
| 397 | * link_state to LISTEN |
| 398 | * |
| 399 | *------------------------------------------------------------------*/ |
| 400 | |
| 401 | void limProcessRemainOnChnTimeout(tpAniSirGlobal pMac) |
| 402 | { |
| 403 | tpPESession psessionEntry; |
| 404 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 405 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 406 | //Timer might get extended while Sending Action Frame |
| 407 | //In that case don't process Channel Timeout |
| 408 | if (tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer)) |
| 409 | { |
| 410 | limLog( pMac, LOGE, |
| 411 | "still timer is running already and not processing limProcessRemainOnChnTimeout"); |
| 412 | return; |
| 413 | } |
| 414 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 415 | limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER); |
| 416 | |
| 417 | if (NULL == pMac->lim.gpLimRemainOnChanReq) |
| 418 | { |
| 419 | limLog( pMac, LOGE, "No Remain on channel pending"); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | /* get the previous valid LINK state */ |
| 424 | if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid, |
| 425 | pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS) |
| 426 | { |
| 427 | limLog( pMac, LOGE, "Unable to change link state"); |
| 428 | return; |
| 429 | } |
| 430 | |
| 431 | if (pMac->lim.gLimMlmState != eLIM_MLM_P2P_LISTEN_STATE ) |
| 432 | { |
| 433 | limRemainOnChnRsp(pMac,eHAL_STATUS_SUCCESS, NULL); |
| 434 | } |
| 435 | else |
| 436 | { |
| 437 | /* get the session */ |
| 438 | if((psessionEntry = peFindSessionBySessionId(pMac, |
| 439 | pMac->lim.limTimers.gLimRemainOnChannelTimer.sessionId))== NULL) |
| 440 | { |
| 441 | limLog(pMac, LOGE, |
| 442 | FL("Session Does not exist for given sessionID\n")); |
| 443 | goto error; |
| 444 | } |
| 445 | |
| 446 | limExitRemainOnChannel(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry); |
| 447 | return; |
| 448 | error: |
| 449 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 450 | } |
| 451 | return; |
| 452 | } |
| 453 | |
| 454 | |
| 455 | /*------------------------------------------------------------------ |
| 456 | * |
| 457 | * limchannelchange callback, on success channel change, set the link_state |
| 458 | * to LISTEN |
| 459 | * |
| 460 | *------------------------------------------------------------------*/ |
| 461 | |
| 462 | void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status, |
| 463 | tANI_U32 *data, tpPESession psessionEntry) |
| 464 | { |
| 465 | |
| 466 | if (status != eHAL_STATUS_SUCCESS) |
| 467 | { |
| 468 | PELOGE(limLog( pMac, LOGE, "Remain on Channel Failed\n");) |
| 469 | goto error; |
| 470 | } |
| 471 | //Set the resume channel to Any valid channel (invalid). |
| 472 | //This will instruct HAL to set it to any previous valid channel. |
| 473 | peSetResumeChannel(pMac, 0, 0); |
| 474 | limResumeLink(pMac, limRemainOnChnRsp, NULL); |
| 475 | return; |
| 476 | error: |
| 477 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | /*------------------------------------------------------------------ |
| 482 | * |
| 483 | * Send remain on channel respone: Success/ Failure |
| 484 | * |
| 485 | *------------------------------------------------------------------*/ |
| 486 | void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data) |
| 487 | { |
| 488 | tpPESession psessionEntry; |
| 489 | tANI_U8 sessionId; |
| 490 | tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq; |
| 491 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 492 | |
| 493 | if ( NULL == MsgRemainonChannel ) |
| 494 | { |
| 495 | PELOGE(limLog( pMac, LOGP, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 496 | "%s: No Pointer for Remain on Channel Req\n", __func__);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 497 | return; |
| 498 | } |
| 499 | |
| 500 | //Incase of the Remain on Channel Failure Case |
| 501 | //Cleanup Everything |
| 502 | if(eHAL_STATUS_FAILURE == status) |
| 503 | { |
| 504 | //Deactivate Remain on Channel Timer |
| 505 | limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER); |
| 506 | |
| 507 | //Set the Link State to Idle |
| 508 | /* get the previous valid LINK state */ |
| 509 | if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid, |
| 510 | pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS) |
| 511 | { |
| 512 | limLog( pMac, LOGE, "Unable to change link state"); |
| 513 | } |
| 514 | |
| 515 | pMac->lim.gLimSystemInScanLearnMode = 0; |
| 516 | pMac->lim.gLimHalScanState = eLIM_HAL_IDLE_SCAN_STATE; |
| 517 | } |
| 518 | |
| 519 | /* delete the session */ |
| 520 | if((psessionEntry = peFindSessionByBssid(pMac, |
| 521 | MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL) |
| 522 | { |
| 523 | if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole ) |
| 524 | { |
| 525 | peDeleteSession( pMac, psessionEntry); |
| 526 | } |
| 527 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 528 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 529 | /* Post the meessage to Sme */ |
| 530 | limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status, |
| 531 | MsgRemainonChannel->sessionId, 0); |
| 532 | |
| 533 | palFreeMemory( pMac->hHdd, pMac->lim.gpLimRemainOnChanReq ); |
| 534 | pMac->lim.gpLimRemainOnChanReq = NULL; |
| 535 | |
| 536 | pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 537 | |
| 538 | /* If remain on channel timer expired and action frame is pending then |
| 539 | * indicaiton confirmation with status failure */ |
| 540 | if (pMac->lim.actionFrameSessionId != 0xff) |
| 541 | { |
| 542 | limP2PActionCnf(pMac, 0); |
| 543 | } |
| 544 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 545 | return; |
| 546 | } |
| 547 | |
| 548 | /*------------------------------------------------------------------ |
| 549 | * |
| 550 | * Indicate the Mgmt Frame received to SME to HDD callback |
| 551 | * handle Probe_req/Action frame currently |
| 552 | * |
| 553 | *------------------------------------------------------------------*/ |
| 554 | void limSendSmeMgmtFrameInd( |
| 555 | tpAniSirGlobal pMac, tANI_U8 frameType, |
| 556 | tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 557 | tANI_U32 rxChannel, tpPESession psessionEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 558 | { |
| 559 | tSirMsgQ mmhMsg; |
| 560 | tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL; |
| 561 | tANI_U16 length; |
| 562 | |
| 563 | length = sizeof(tSirSmeMgmtFrameInd) + frameLen; |
| 564 | |
| 565 | if( eHAL_STATUS_SUCCESS != |
| 566 | palAllocateMemory( pMac->hHdd, (void **)&pSirSmeMgmtFrame, length )) |
| 567 | { |
| 568 | limLog(pMac, LOGP, |
| 569 | FL("palAllocateMemory failed for eWNI_SME_LISTEN_RSP\n")); |
| 570 | return; |
| 571 | } |
| 572 | palZeroMemory(pMac->hHdd, (void*)pSirSmeMgmtFrame, length); |
| 573 | |
| 574 | pSirSmeMgmtFrame->mesgType = eWNI_SME_MGMT_FRM_IND; |
| 575 | pSirSmeMgmtFrame->mesgLen = length; |
| 576 | pSirSmeMgmtFrame->sessionId = sessionId; |
| 577 | pSirSmeMgmtFrame->frameType = frameType; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 578 | |
| 579 | /* work around for 5Ghz channel is not correct since rxhannel |
| 580 | * is 4 bits. So we don't indicate more than 16 channels |
| 581 | */ |
| 582 | if( (VOS_FALSE == |
| 583 | tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer)) && |
| 584 | (psessionEntry != NULL) && |
| 585 | (SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel)) ) |
| 586 | { |
| 587 | pSirSmeMgmtFrame->rxChan = psessionEntry->currentOperChannel; |
| 588 | } |
| 589 | else |
| 590 | { |
| 591 | pSirSmeMgmtFrame->rxChan = rxChannel; |
| 592 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 593 | |
| 594 | vos_mem_zero(pSirSmeMgmtFrame->frameBuf,frameLen); |
| 595 | vos_mem_copy(pSirSmeMgmtFrame->frameBuf,frame,frameLen); |
| 596 | |
| 597 | mmhMsg.type = eWNI_SME_MGMT_FRM_IND; |
| 598 | mmhMsg.bodyptr = pSirSmeMgmtFrame; |
| 599 | mmhMsg.bodyval = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 600 | |
| 601 | if(VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer) && |
| 602 | ( (psessionEntry != NULL) && (psessionEntry->pePersona != VOS_P2P_GO_MODE)) && |
| 603 | (frameType == SIR_MAC_MGMT_ACTION)) |
| 604 | { |
| 605 | tANI_U32 curTime = vos_timer_get_system_time(); |
| 606 | if((curTime - pMac->lim.p2pRemOnChanTimeStamp) > (pMac->lim.gTotalScanDuration - LIM_MIN_REM_TIME_FOR_TX_ACTION_FRAME)) |
| 607 | { |
| 608 | unsigned int chanWaitTime, vStatus ; |
| 609 | |
| 610 | limLog( pMac, LOG1, FL("Rx: Extend the gLimRemainOnChannelTimer")); |
| 611 | |
| 612 | pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time(); |
| 613 | pMac->lim.gTotalScanDuration = LIM_MIN_REM_TIME_EXT_FOR_TX_ACTION_FRAME; |
| 614 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 615 | chanWaitTime = SYS_MS_TO_TICKS(LIM_MIN_REM_TIME_EXT_FOR_TX_ACTION_FRAME); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 616 | vStatus = tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer); |
| 617 | |
| 618 | if (VOS_STATUS_SUCCESS != vStatus) |
| 619 | { |
| 620 | limLog( pMac, LOGE, FL("Rx: Extend the gLimRemainOnChannelTimer")); |
| 621 | } |
| 622 | |
| 623 | if (tx_timer_change(&pMac->lim.limTimers.gLimRemainOnChannelTimer, chanWaitTime, 0) != TX_SUCCESS) |
| 624 | { |
| 625 | limLog( pMac, LOGE, FL("Unable to change the gLimRemainOnChannelTimer")); |
| 626 | } |
| 627 | |
| 628 | if (tx_timer_activate(&pMac->lim.limTimers.gLimRemainOnChannelTimer) != 0) |
| 629 | { |
| 630 | limLog( pMac, LOGE, FL("Unable to active the gLimRemainOnChannelTimer")); |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 635 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 636 | return; |
| 637 | } /*** end limSendSmeListenRsp() ***/ |
| 638 | |
| 639 | |
| 640 | eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess) |
| 641 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 642 | if (pMac->lim.actionFrameSessionId != 0xff) |
| 643 | { |
| 644 | /* The session entry might be invalid(0xff) action confirmation received after |
| 645 | * remain on channel timer expired */ |
| 646 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
| 647 | (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL), |
| 648 | pMac->lim.actionFrameSessionId, 0); |
| 649 | pMac->lim.actionFrameSessionId = 0xff; |
| 650 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 651 | |
| 652 | return eHAL_STATUS_SUCCESS; |
| 653 | } |
| 654 | |
| 655 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 656 | void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 657 | { |
| 658 | v_U8_t *pIe=NULL; |
| 659 | tDot11fIEHTCaps dot11HtCap; |
| 660 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 661 | PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 662 | pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes, |
| 663 | DOT11F_EID_HTCAPS,ONE_BYTE); |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 664 | limLog( pMac, LOG2, FL("pIe 0x%x dot11HtCap.supportedMCSSet[0]=0x%x"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 665 | (tANI_U32)pIe,dot11HtCap.supportedMCSSet[0]); |
| 666 | if(pIe) |
| 667 | { |
| 668 | tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure |
| 669 | pHtcap->advCodingCap = dot11HtCap.advCodingCap; |
| 670 | pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet; |
| 671 | pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave; |
| 672 | pHtcap->greenField = dot11HtCap.greenField; |
| 673 | pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz; |
| 674 | pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz; |
| 675 | pHtcap->txSTBC = dot11HtCap.txSTBC; |
| 676 | pHtcap->rxSTBC = dot11HtCap.rxSTBC; |
| 677 | pHtcap->delayedBA = dot11HtCap.delayedBA ; |
| 678 | pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize; |
| 679 | pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz; |
| 680 | pHtcap->psmp = dot11HtCap.psmp; |
| 681 | pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame; |
| 682 | pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection; |
| 683 | pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor; |
| 684 | pHtcap->mpduDensity = dot11HtCap.mpduDensity; |
| 685 | palCopyMemory( pMac->hHdd, (void *)pHtcap->supportedMCSSet, |
| 686 | (void *)(dot11HtCap.supportedMCSSet), |
| 687 | sizeof(pHtcap->supportedMCSSet)); |
| 688 | pHtcap->pco = dot11HtCap.pco; |
| 689 | pHtcap->transitionTime = dot11HtCap.transitionTime; |
| 690 | pHtcap->mcsFeedback = dot11HtCap.mcsFeedback; |
| 691 | pHtcap->txBF = dot11HtCap.txBF; |
| 692 | pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding; |
| 693 | pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding; |
| 694 | pHtcap->rxZLF = dot11HtCap.rxZLF; |
| 695 | pHtcap->txZLF = dot11HtCap.txZLF; |
| 696 | pHtcap->implicitTxBF = dot11HtCap.implicitTxBF; |
| 697 | pHtcap->calibration = dot11HtCap.calibration; |
| 698 | pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF; |
| 699 | pHtcap->explicitUncompressedSteeringMatrix = |
| 700 | dot11HtCap.explicitUncompressedSteeringMatrix; |
| 701 | pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback; |
| 702 | pHtcap->explicitUncompressedSteeringMatrixFeedback = |
| 703 | dot11HtCap.explicitUncompressedSteeringMatrixFeedback; |
| 704 | pHtcap->explicitCompressedSteeringMatrixFeedback = |
| 705 | dot11HtCap.explicitCompressedSteeringMatrixFeedback; |
| 706 | pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae; |
| 707 | pHtcap->uncompressedSteeringMatrixBFAntennae = |
| 708 | dot11HtCap.uncompressedSteeringMatrixBFAntennae; |
| 709 | pHtcap->compressedSteeringMatrixBFAntennae = |
| 710 | dot11HtCap.compressedSteeringMatrixBFAntennae; |
| 711 | pHtcap->antennaSelection = dot11HtCap.antennaSelection; |
| 712 | pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx; |
| 713 | pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx; |
| 714 | pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback; |
| 715 | pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback; |
| 716 | pHtcap->rxAS = dot11HtCap.rxAS; |
| 717 | pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs; |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | |
| 722 | void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg) |
| 723 | { |
| 724 | tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr; |
| 725 | tANI_U32 nBytes; |
| 726 | tANI_U8 *pFrame; |
| 727 | void *pPacket; |
| 728 | eHalStatus halstatus; |
| 729 | tANI_U8 txFlag = 0; |
| 730 | tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data; |
| 731 | tANI_U8 noaLen = 0; |
| 732 | tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN]; |
| 733 | tANI_U8 origLen = 0; |
| 734 | tANI_U8 sessionId = 0; |
| 735 | v_U8_t *pP2PIe = NULL; |
| 736 | tpPESession psessionEntry; |
| 737 | v_U8_t *pPresenceRspNoaAttr = NULL; |
| 738 | v_U8_t *pNewP2PIe = NULL; |
| 739 | v_U16_t remainLen = 0; |
| 740 | |
| 741 | nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg); |
| 742 | |
| 743 | limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"), |
| 744 | pFc->type, pFc->subType); |
| 745 | |
| 746 | psessionEntry = peFindSessionByBssid(pMac, |
| 747 | (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId); |
| 748 | |
| 749 | /* Check for session corresponding to ADDR2 As Supplicant is filling |
| 750 | ADDR2 with BSSID */ |
| 751 | if( NULL == psessionEntry ) |
| 752 | { |
| 753 | psessionEntry = peFindSessionByBssid(pMac, |
| 754 | (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId); |
| 755 | } |
| 756 | |
| 757 | if( NULL == psessionEntry ) |
| 758 | { |
| 759 | tANI_U8 isSessionActive = 0; |
| 760 | tANI_U8 i; |
| 761 | |
| 762 | /* If we are not able to find psessionEntry entry, then try to find |
| 763 | active session, if found any active sessions then send the |
| 764 | action frame, If no active sessions found then drop the frame */ |
| 765 | for (i =0; i < pMac->lim.maxBssId;i++) |
| 766 | { |
| 767 | psessionEntry = peFindSessionBySessionId(pMac,i); |
| 768 | if ( NULL != psessionEntry) |
| 769 | { |
| 770 | isSessionActive = 1; |
| 771 | break; |
| 772 | } |
| 773 | } |
| 774 | if( !isSessionActive ) |
| 775 | { |
| 776 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
| 777 | eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0); |
| 778 | return; |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | if ((SIR_MAC_MGMT_FRAME == pFc->type)&& |
| 783 | ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)|| |
| 784 | (SIR_MAC_MGMT_ACTION == pFc->subType))) |
| 785 | { |
| 786 | //if this is a probe RSP being sent from wpa_supplicant |
| 787 | if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) |
| 788 | { |
| 789 | //get proper offset for Probe RSP |
| 790 | pP2PIe = limGetP2pIEPtr(pMac, |
| 791 | (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET, |
| 792 | nBytes - PROBE_RSP_IE_OFFSET); |
| 793 | while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1])) |
| 794 | { |
| 795 | remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data); |
| 796 | if (remainLen > 2) |
| 797 | { |
| 798 | pNewP2PIe = limGetP2pIEPtr(pMac, |
| 799 | pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen); |
| 800 | } |
| 801 | if (pNewP2PIe) |
| 802 | { |
| 803 | pP2PIe = pNewP2PIe; |
| 804 | pNewP2PIe = NULL; |
| 805 | } |
| 806 | else |
| 807 | { |
| 808 | break; |
| 809 | } |
| 810 | } //end of while |
| 811 | } |
| 812 | else |
| 813 | { |
| 814 | if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY == |
| 815 | *((v_U8_t *)pMbMsg->data+ACTION_OFFSET)) |
| 816 | { |
| 817 | tpSirMacP2PActionFrameHdr pActionHdr = |
| 818 | (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data + |
| 819 | ACTION_OFFSET); |
| 820 | if ( palEqualMemory( pMac->hHdd, pActionHdr->Oui, |
| 821 | SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) && |
| 822 | (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP == |
| 823 | pActionHdr->OuiSubType)) |
| 824 | { //In case of Presence RSP response |
| 825 | pP2PIe = limGetP2pIEPtr(pMac, |
| 826 | (v_U8_t *)pMbMsg->data + ACTION_OFFSET + |
| 827 | sizeof(tSirMacP2PActionFrameHdr), |
| 828 | (nBytes - ACTION_OFFSET - |
| 829 | sizeof(tSirMacP2PActionFrameHdr))); |
| 830 | if( NULL != pP2PIe ) |
| 831 | { |
| 832 | //extract the presence of NoA attribute inside P2P IE |
| 833 | pPresenceRspNoaAttr = |
| 834 | limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN, |
| 835 | pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE); |
| 836 | } |
| 837 | } |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | if (pP2PIe != NULL) |
| 842 | { |
| 843 | //get NoA attribute stream P2P IE |
| 844 | noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry); |
| 845 | //need to append NoA attribute in P2P IE |
| 846 | if (noaLen > 0) |
| 847 | { |
| 848 | origLen = pP2PIe[1]; |
| 849 | //if Presence Rsp has NoAttr |
| 850 | if (pPresenceRspNoaAttr) |
| 851 | { |
| 852 | v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] | |
| 853 | (pPresenceRspNoaAttr[2]<<8); |
| 854 | /*One byte for attribute, 2bytes for length*/ |
| 855 | origLen -= (noaAttrLen + 1 + 2); |
| 856 | //remove those bytes to copy |
| 857 | nBytes -= (noaAttrLen + 1 + 2); |
| 858 | //remove NoA from original Len |
| 859 | pP2PIe[1] = origLen; |
| 860 | } |
| 861 | if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH) |
| 862 | { |
| 863 | //Form the new NoA Byte array in multiple P2P IEs |
| 864 | noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream, |
| 865 | noaLen,((pP2PIe[1] + (tANI_U16)noaLen)- |
| 866 | SIR_MAC_MAX_IE_LENGTH)); |
| 867 | pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH; |
| 868 | } |
| 869 | else |
| 870 | { |
| 871 | pP2PIe[1] += noaLen; //increment the length of P2P IE |
| 872 | } |
| 873 | nBytes += noaLen; |
| 874 | limLog( pMac, LOGE, |
| 875 | FL("noaLen=%d origLen=%d pP2PIe=0x%x" |
| 876 | " nBytes=%d nBytesToCopy=%d \n"), |
| 877 | noaLen,origLen,pP2PIe,nBytes, |
| 878 | ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data)); |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) |
| 883 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 884 | limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET, |
Madan Mohan Koyyalamudi | fb29a5d | 2012-10-11 12:14:17 -0700 | [diff] [blame] | 885 | nBytes - PROBE_RSP_IE_OFFSET); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 886 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 887 | |
| 888 | /* The minimum wait for any action frame should be atleast 100 ms. |
| 889 | * If supplicant sends action frame at the end of already running remain on channel time |
| 890 | * Then there is a chance to miss the response of the frame. So increase the remain on channel |
| 891 | * time for all action frame to make sure that we receive the response frame */ |
| 892 | if ((SIR_MAC_MGMT_ACTION == pFc->subType) && |
| 893 | (0 != pMbMsg->wait)) |
| 894 | { |
| 895 | if (tx_timer_running(&pMac->lim.limTimers.gLimRemainOnChannelTimer)) |
| 896 | { |
| 897 | tANI_U32 val = 0; |
| 898 | tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer); |
| 899 | /* get the duration from the request */ |
| 900 | pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time(); |
| 901 | pMac->lim.gTotalScanDuration = pMbMsg->wait; |
| 902 | |
| 903 | val = SYS_MS_TO_TICKS(pMbMsg->wait); |
| 904 | |
| 905 | limLog(pMac, LOG1, |
| 906 | FL("Tx: Extending the gLimRemainOnChannelTimer\n")); |
| 907 | if (tx_timer_change( |
| 908 | &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0) |
| 909 | != TX_SUCCESS) |
| 910 | { |
| 911 | limLog(pMac, LOGP, |
| 912 | FL("Unable to change remain on channel Timer val\n")); |
| 913 | return; |
| 914 | } |
| 915 | else if(TX_SUCCESS != tx_timer_activate( |
| 916 | &pMac->lim.limTimers.gLimRemainOnChannelTimer)) |
| 917 | { |
| 918 | limLog(pMac, LOGP, |
| 919 | FL("Unable to activate remain on channel Timer\n")); |
| 920 | limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER); |
| 921 | return; |
| 922 | } |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
| 927 | eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0); |
| 928 | return; |
| 929 | } |
| 930 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | |
| 934 | // Ok-- try to allocate some memory: |
| 935 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 936 | (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket); |
| 937 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 938 | { |
| 939 | limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe" |
| 940 | " Request.\n"), nBytes ); |
| 941 | return; |
| 942 | } |
| 943 | |
| 944 | // Paranoia: |
| 945 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 946 | |
| 947 | if (noaLen > 0) |
| 948 | { |
| 949 | // Add 2 bytes for length and Arribute field |
| 950 | v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) - |
| 951 | (v_U8_t *)pMbMsg->data); |
| 952 | palCopyMemory( pMac->hHdd, pFrame, pMbMsg->data, nBytesToCopy); |
| 953 | palCopyMemory( pMac->hHdd, (pFrame + nBytesToCopy), noaStream, noaLen); |
| 954 | palCopyMemory( pMac->hHdd, (pFrame + nBytesToCopy + noaLen), |
| 955 | pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen); |
| 956 | |
| 957 | } |
| 958 | else |
| 959 | { |
| 960 | palCopyMemory(pMac->hHdd, pFrame, pMbMsg->data, nBytes); |
| 961 | } |
| 962 | |
| 963 | /* Use BD rate 2 for all P2P related frames. As these frames need to go |
| 964 | * at OFDM rates. And BD rate2 we configured at 6Mbps. |
| 965 | */ |
| 966 | txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; |
| 967 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 968 | if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) || |
| 969 | (pMbMsg->noack) |
| 970 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 971 | { |
| 972 | halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes, |
| 973 | HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, |
| 974 | 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame, |
| 975 | txFlag ); |
| 976 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 977 | if (!pMbMsg->noack) |
| 978 | { |
| 979 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 980 | halstatus, pMbMsg->sessionId, 0); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 981 | } |
| 982 | pMac->lim.actionFrameSessionId = 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 983 | } |
| 984 | else |
| 985 | { |
| 986 | halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes, |
| 987 | HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, |
| 988 | 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame, |
| 989 | limP2PActionCnf, txFlag ); |
| 990 | |
| 991 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 992 | { |
| 993 | limLog( pMac, LOGE, FL("could not send action frame!\n" )); |
| 994 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus, |
| 995 | pMbMsg->sessionId, 0); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 996 | pMac->lim.actionFrameSessionId = 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 997 | } |
| 998 | else |
| 999 | { |
| 1000 | pMac->lim.actionFrameSessionId = pMbMsg->sessionId; |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1001 | limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %lu\n" ), |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1002 | pMac->lim.actionFrameSessionId); |
| 1003 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | return; |
| 1008 | } |
| 1009 | |
| 1010 | |
| 1011 | void limAbortRemainOnChan(tpAniSirGlobal pMac) |
| 1012 | { |
| 1013 | if(VOS_TRUE == tx_timer_running( |
| 1014 | &pMac->lim.limTimers.gLimRemainOnChannelTimer)) |
| 1015 | { |
| 1016 | //TODO check for state and take appropriate actions |
| 1017 | limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER); |
| 1018 | limProcessRemainOnChnTimeout(pMac); |
| 1019 | } |
| 1020 | return; |
| 1021 | } |
| 1022 | |
| 1023 | /* Power Save Related Functions */ |
| 1024 | tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) |
| 1025 | { |
| 1026 | tpP2pPsConfig pNoA; |
| 1027 | tpP2pPsParams pMsgNoA; |
| 1028 | tSirMsgQ msg; |
| 1029 | |
| 1030 | pNoA = (tpP2pPsConfig) pMsgBuf; |
| 1031 | |
| 1032 | if( eHAL_STATUS_SUCCESS != palAllocateMemory( |
| 1033 | pMac->hHdd, (void **) &pMsgNoA, sizeof( tP2pPsConfig ))) |
| 1034 | { |
| 1035 | limLog( pMac, LOGE, |
| 1036 | FL( "Unable to allocate memory during NoA Update\n" )); |
| 1037 | return eSIR_MEM_ALLOC_FAILED; |
| 1038 | } |
| 1039 | |
| 1040 | palZeroMemory( pMac->hHdd, (tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig)); |
| 1041 | pMsgNoA->opp_ps = pNoA->opp_ps; |
| 1042 | pMsgNoA->ctWindow = pNoA->ctWindow; |
| 1043 | pMsgNoA->duration = pNoA->duration; |
| 1044 | pMsgNoA->interval = pNoA->interval; |
| 1045 | pMsgNoA->count = pNoA->count; |
| 1046 | pMsgNoA->single_noa_duration = pNoA->single_noa_duration; |
| 1047 | pMsgNoA->psSelection = pNoA->psSelection; |
| 1048 | |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame^] | 1049 | msg.type = WDA_SET_P2P_GO_NOA_REQ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1050 | msg.reserved = 0; |
| 1051 | msg.bodyptr = pMsgNoA; |
| 1052 | msg.bodyval = 0; |
| 1053 | |
| 1054 | if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg)) |
| 1055 | { |
| 1056 | limLog(pMac, LOGE, FL("halPostMsgApi failed\n")); |
| 1057 | return eSIR_FAILURE; |
| 1058 | } |
| 1059 | |
| 1060 | return eSIR_SUCCESS; |
| 1061 | } /*** end __limProcessSmeGoNegReq() ***/ |
| 1062 | |
| 1063 | #endif |
| 1064 | |