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