Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 0fe596e | 2017-09-19 08:36:48 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012-2014, 2016-2017 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [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. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /*=========================================================================== |
| 29 | L I M _ P 2 P . C |
| 30 | |
| 31 | OVERVIEW: |
| 32 | |
| 33 | This software unit holds the implementation of the WLAN Protocol Engine for |
| 34 | P2P. |
| 35 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 36 | ===========================================================================*/ |
| 37 | |
| 38 | /*=========================================================================== |
| 39 | |
| 40 | EDIT HISTORY FOR FILE |
| 41 | |
| 42 | |
| 43 | This section contains comments describing changes made to the module. |
| 44 | Notice that changes are listed in reverse chronological order. |
| 45 | |
| 46 | |
| 47 | $Header$$DateTime$$Author$ |
| 48 | |
| 49 | |
| 50 | when who what, where, why |
| 51 | ---------- --- -------------------------------------------------------- |
| 52 | 2011-05-02 djindal Corrected file indentation and changed remain on channel |
| 53 | handling for concurrency. |
| 54 | ===========================================================================*/ |
| 55 | |
| 56 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | #include "limUtils.h" |
| 58 | #include "limSessionUtils.h" |
| 59 | #include "wlan_qct_wda.h" |
| 60 | |
| 61 | #define PROBE_RSP_IE_OFFSET 36 |
| 62 | #define BSSID_OFFSET 16 |
| 63 | #define ADDR2_OFFSET 10 |
| 64 | #define ACTION_OFFSET 24 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 65 | |
Madan Mohan Koyyalamudi | 98b82ce | 2013-07-11 17:03:55 +0530 | [diff] [blame] | 66 | /* A DFS channel can be ACTIVE for max 9000 msec, from the last |
Gopichand Nakkala | d492d20 | 2013-05-10 02:50:47 +0530 | [diff] [blame] | 67 | received Beacon/Prpbe Resp. */ |
Madan Mohan Koyyalamudi | 98b82ce | 2013-07-11 17:03:55 +0530 | [diff] [blame] | 68 | #define MAX_TIME_TO_BE_ACTIVE_CHANNEL 9000 |
Gopichand Nakkala | d492d20 | 2013-05-10 02:50:47 +0530 | [diff] [blame] | 69 | |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 70 | #define REMAIN_ON_CHANNEL_UNKNOWN_ACTION_CATEGORY 0x20 |
| 71 | #define VENDOR_SPECIFIC_ELEMENT_ID 221 |
| 72 | #define REMAIN_ON_CHANNEL_MSG_SIZE 55 |
| 73 | #define REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME 1 |
| 74 | #define REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME 2 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 75 | |
| 76 | void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status, |
| 77 | tANI_U32 *data); |
| 78 | void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status, |
| 79 | tANI_U32 *data, tpPESession psessionEntry); |
| 80 | void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status, |
| 81 | tANI_U32 *data, tpPESession psessionEntry); |
| 82 | void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data); |
| 83 | extern tSirRetStatus limSetLinkState( |
| 84 | tpAniSirGlobal pMac, tSirLinkState state, |
| 85 | tSirMacAddr bssId, tSirMacAddr selfMacAddr, |
| 86 | tpSetLinkStateCallback callback, void *callbackArg); |
| 87 | |
| 88 | static tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession); |
Ganesh Kondabattini | 358fc9b | 2015-03-11 16:14:25 +0530 | [diff] [blame] | 89 | eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, void *pData); |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 90 | |
| 91 | /*---------------------------------------------------------------------------- |
| 92 | * |
| 93 | * The function limSendRemainOnChannelDebugMarkerFrame, prepares Marker frame |
| 94 | * for Start and End of remain on channel with RemainOnChannelMsg as Vendor |
| 95 | * Specific information element of the frame. |
| 96 | * |
| 97 | *----------------------------------------------------------------------------*/ |
| 98 | tSirRetStatus limSendRemainOnChannelDebugMarkerFrame(tpAniSirGlobal pMac, |
| 99 | tANI_U8 *remainOnChannelMsg) |
| 100 | { |
| 101 | tSirMacAddr magicMacAddr= {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; |
| 102 | tANI_U32 nBytes, nPayload; |
| 103 | tSirRetStatus nSirStatus; |
| 104 | tANI_U8 *pFrame; |
| 105 | void *pPacket; |
| 106 | eHalStatus halstatus; |
| 107 | tANI_U8 txFlag = 0; |
| 108 | publicVendorSpecific *pPublicVendorSpecific; |
| 109 | |
| 110 | pPublicVendorSpecific = vos_mem_malloc(sizeof(publicVendorSpecific)); |
| 111 | if( pPublicVendorSpecific == NULL ) |
| 112 | { |
| 113 | limLog( pMac, LOGE, |
| 114 | FL( "Unable to allocate memory for Vendor specific information" |
| 115 | " element" ) ); |
| 116 | return eSIR_MEM_ALLOC_FAILED; |
| 117 | } |
| 118 | // Assigning Action category code as unknown as this is debug marker frame |
| 119 | pPublicVendorSpecific->category = REMAIN_ON_CHANNEL_UNKNOWN_ACTION_CATEGORY; |
| 120 | pPublicVendorSpecific->elementid = VENDOR_SPECIFIC_ELEMENT_ID; |
| 121 | pPublicVendorSpecific->length = strlen(remainOnChannelMsg); |
| 122 | |
| 123 | nPayload = sizeof(publicVendorSpecific) + pPublicVendorSpecific->length; |
| 124 | |
| 125 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ); |
| 126 | |
| 127 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 128 | ( tANI_U16 )nBytes, ( void** ) &pFrame, |
| 129 | ( void** ) &pPacket ); |
| 130 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 131 | { |
| 132 | limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Remain" |
| 133 | " on channel action frame."), nBytes ); |
| 134 | nSirStatus = eSIR_MEM_ALLOC_FAILED; |
| 135 | goto end; |
| 136 | } |
| 137 | vos_mem_zero( pFrame, nBytes ); |
| 138 | |
| 139 | // Populate frame with MAC header |
| 140 | nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, |
| 141 | SIR_MAC_MGMT_ACTION, magicMacAddr, |
| 142 | pMac->lim.gSelfMacAddr); |
| 143 | if ( eSIR_SUCCESS != nSirStatus ) |
| 144 | { |
| 145 | limLog( pMac, LOGE, FL("Failed to populate the buffer descriptor for a" |
| 146 | " Action frame for remain on channel.") ); |
| 147 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 148 | ( void* ) pFrame, ( void* ) pPacket ); |
| 149 | goto end; |
| 150 | } |
| 151 | |
| 152 | // Copy Public Vendor specific fields to frame's information element |
| 153 | vos_mem_copy( (pFrame + (sizeof( tSirMacMgmtHdr ))), |
| 154 | pPublicVendorSpecific, sizeof(publicVendorSpecific) ); |
| 155 | // Copy Remain On channel message to Vendor Specific information field |
| 156 | vos_mem_copy( (pFrame + (nBytes - pPublicVendorSpecific->length)), |
| 157 | remainOnChannelMsg, pPublicVendorSpecific->length ); |
| 158 | |
| 159 | halstatus = halTxFrame( pMac, pPacket, |
| 160 | ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload, |
| 161 | HAL_TXRX_FRM_802_11_MGMT, |
| 162 | ANI_TXDIR_TODS, |
| 163 | 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, |
| 164 | limTxComplete, pFrame, txFlag ); |
| 165 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 166 | { |
| 167 | limLog( pMac, LOGE, FL("could not send marker frame for" |
| 168 | " remain on channel!" )); |
| 169 | //Pkt will be freed up by the callback |
| 170 | nSirStatus = eSIR_FAILURE; |
| 171 | goto end; |
| 172 | } |
| 173 | |
| 174 | nSirStatus = eSIR_SUCCESS; |
| 175 | |
| 176 | end: |
| 177 | vos_mem_free( pPublicVendorSpecific ); |
| 178 | return nSirStatus; |
| 179 | } |
| 180 | |
| 181 | /*------------------------------------------------------------------------- |
| 182 | * |
| 183 | * This function forms message for start of remain on channel with channel |
| 184 | * number, duration and sequence number. This message is added as data of |
| 185 | * vendor specific information element of Debug Marker Frame. Message will |
| 186 | * be in form "START-REMAIN-ON-CHANNEL<first/second-frame>-CHN=<channel>" |
| 187 | * "-FOR-DUR=<duraion>-SEQ=<sequence-num>" |
| 188 | * |
| 189 | *-------------------------------------------------------------------------*/ |
| 190 | eHalStatus limPrepareAndSendStartRemainOnChannelMsg(tpAniSirGlobal pMac, |
| 191 | tSirRemainOnChnReq *MsgRemainonChannel, tANI_U8 id) |
| 192 | { |
| 193 | tANI_U8 *startRemainOnChannelMsg; |
| 194 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 195 | |
| 196 | startRemainOnChannelMsg = vos_mem_malloc( REMAIN_ON_CHANNEL_MSG_SIZE ); |
| 197 | if( NULL == startRemainOnChannelMsg ) |
| 198 | { |
| 199 | limLog(pMac, LOGE, |
| 200 | FL("Unable to allocate memory for remain on channel message")); |
| 201 | return eHAL_STATUS_FAILURE; |
| 202 | } |
| 203 | |
| 204 | snprintf(startRemainOnChannelMsg, REMAIN_ON_CHANNEL_MSG_SIZE, |
| 205 | "START-REMAIN-ON-CHANNEL%d-CHN=%d-FOR-DUR=%d-SEQ=%d", |
| 206 | id, MsgRemainonChannel->chnNum, MsgRemainonChannel->duration, |
| 207 | pMac->lim.remOnChnSeqNum); |
| 208 | |
| 209 | if( eSIR_FAILURE == limSendRemainOnChannelDebugMarkerFrame(pMac, |
| 210 | startRemainOnChannelMsg) ) |
| 211 | { |
| 212 | limLog( pMac, LOGE, |
| 213 | "%s: Could not send %d debug marker frame at start" |
| 214 | " of remain on channel", __func__, id); |
| 215 | status = eHAL_STATUS_FAILURE; |
| 216 | } |
| 217 | vos_mem_free( startRemainOnChannelMsg ); |
| 218 | |
| 219 | return status; |
| 220 | |
| 221 | } |
| 222 | |
| 223 | /*---------------------------------------------------------------------------- |
| 224 | * |
| 225 | * This function forms message for cancel of remain on channel. This message |
| 226 | * is added as data of Vendor Specific information element of debug marker |
| 227 | * frame.Message will be in form "CANCEL-REMAIN-ON-CHANNEL<first/second-frame>" |
| 228 | * "-SEQ=<sequence-num>" |
| 229 | * |
| 230 | *----------------------------------------------------------------------------*/ |
| 231 | eHalStatus limPrepareAndSendCancelRemainOnChannelMsg(tpAniSirGlobal pMac, |
| 232 | tANI_U8 id) |
| 233 | { |
| 234 | tANI_U8 *cancelRemainOnChannelMsg; |
| 235 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 236 | |
| 237 | cancelRemainOnChannelMsg = vos_mem_malloc( REMAIN_ON_CHANNEL_MSG_SIZE ); |
| 238 | if( NULL == cancelRemainOnChannelMsg ) |
| 239 | { |
| 240 | limLog( pMac, LOGE, |
| 241 | FL( "Unable to allocate memory for end of" |
| 242 | " remain on channel message" )); |
| 243 | return eHAL_STATUS_FAILURE; |
| 244 | } |
| 245 | |
| 246 | snprintf(cancelRemainOnChannelMsg, REMAIN_ON_CHANNEL_MSG_SIZE, |
| 247 | "CANCEL-REMAIN-ON-CHANNEL%d-SEQ=%d", |
| 248 | id, pMac->lim.remOnChnSeqNum); |
| 249 | if( eSIR_FAILURE == limSendRemainOnChannelDebugMarkerFrame(pMac, |
| 250 | cancelRemainOnChannelMsg) ) |
| 251 | { |
| 252 | limLog( pMac, LOGE, |
| 253 | "%s: Could not send %d marker frame to debug cancel" |
| 254 | " remain on channel", __func__, id); |
| 255 | status = eHAL_STATUS_FAILURE; |
| 256 | } |
| 257 | vos_mem_free( cancelRemainOnChannelMsg ); |
| 258 | |
| 259 | return status; |
| 260 | |
| 261 | } |
| 262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | /*------------------------------------------------------------------ |
| 264 | * |
| 265 | * Below function is callback function, it is called when |
| 266 | * WDA_SET_LINK_STATE_RSP is received from WDI. callback function for |
| 267 | * P2P of limSetLinkState |
| 268 | * |
| 269 | *------------------------------------------------------------------*/ |
| 270 | void limSetLinkStateP2PCallback(tpAniSirGlobal pMac, void *callbackArg) |
| 271 | { |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 272 | tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq; |
| 273 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 274 | //Send Ready on channel indication to SME |
| 275 | if(pMac->lim.gpLimRemainOnChanReq) |
| 276 | { |
| 277 | limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RDY_IND, eHAL_STATUS_SUCCESS, |
| 278 | pMac->lim.gpLimRemainOnChanReq->sessionId, 0); |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 279 | if(pMac->lim.gDebugP2pRemainOnChannel) |
| 280 | { |
| 281 | if( eHAL_STATUS_SUCCESS == limPrepareAndSendStartRemainOnChannelMsg( |
| 282 | pMac, |
| 283 | MsgRemainonChannel, |
| 284 | REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME) ) |
| 285 | { |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 286 | limLog( pMac, LOGE, |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 287 | "%s: Successfully sent 2nd Marker frame " |
| 288 | "seq num = %d on start ROC", __func__, |
| 289 | pMac->lim.remOnChnSeqNum); |
| 290 | } |
| 291 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 292 | } |
| 293 | else |
| 294 | { |
| 295 | //This is possible in case remain on channel is aborted |
| 296 | limLog( pMac, LOGE, FL(" NULL pointer of gpLimRemainOnChanReq") ); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | /*------------------------------------------------------------------ |
| 301 | * |
| 302 | * Remain on channel req handler. Initiate the INIT_SCAN, CHN_CHANGE |
| 303 | * and SET_LINK Request from SME, chnNum and duration to remain on channel. |
| 304 | * |
| 305 | *------------------------------------------------------------------*/ |
| 306 | |
| 307 | |
| 308 | int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg) |
| 309 | { |
Pratik Bhalgat | a1bf8bb | 2012-11-22 17:02:26 +0530 | [diff] [blame] | 310 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | |
| 312 | tSirRemainOnChnReq *MsgBuff = (tSirRemainOnChnReq *)pMsg; |
| 313 | pMac->lim.gpLimRemainOnChanReq = MsgBuff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 314 | pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState; |
| 315 | pMac->lim.gLimMlmState = eLIM_MLM_P2P_LISTEN_STATE; |
| 316 | |
| 317 | pMac->lim.gTotalScanDuration = MsgBuff->duration; |
| 318 | |
| 319 | /* 1st we need to suspend link with callback to initiate change channel */ |
| 320 | limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN, |
| 321 | limRemainOnChnlSuspendLinkHdlr, NULL); |
| 322 | return FALSE; |
| 323 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | |
| 327 | tSirRetStatus limCreateSessionForRemainOnChn(tpAniSirGlobal pMac, tPESession **ppP2pSession) |
| 328 | { |
| 329 | tSirRetStatus nSirStatus = eSIR_FAILURE; |
| 330 | tpPESession psessionEntry; |
| 331 | tANI_U8 sessionId; |
| 332 | tANI_U32 val; |
| 333 | |
| 334 | if(pMac->lim.gpLimRemainOnChanReq && ppP2pSession) |
| 335 | { |
| 336 | if((psessionEntry = peCreateSession(pMac, |
| 337 | pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId, 1)) == NULL) |
| 338 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 339 | limLog(pMac, LOGE, FL("Session Can not be created ")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 340 | /* send remain on chn failure */ |
| 341 | return nSirStatus; |
| 342 | } |
| 343 | /* Store PE sessionId in session Table */ |
| 344 | psessionEntry->peSessionId = sessionId; |
Deepthi Gowri | 8e060d8 | 2016-07-29 12:04:38 +0530 | [diff] [blame] | 345 | /* Store SME session Id in sessionTable */ |
| 346 | psessionEntry->smeSessionId = pMac->lim.gpLimRemainOnChanReq->sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 347 | psessionEntry->limSystemRole = eLIM_P2P_DEVICE_ROLE; |
| 348 | CFG_GET_STR( nSirStatus, pMac, WNI_CFG_SUPPORTED_RATES_11A, |
| 349 | psessionEntry->rateSet.rate, val , SIR_MAC_MAX_NUMBER_OF_RATES ); |
| 350 | psessionEntry->rateSet.numRates = val; |
| 351 | |
| 352 | CFG_GET_STR( nSirStatus, pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 353 | psessionEntry->extRateSet.rate, val, |
| 354 | WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN ); |
| 355 | psessionEntry->extRateSet.numRates = val; |
| 356 | |
| 357 | sirCopyMacAddr(psessionEntry->selfMacAddr, |
| 358 | pMac->lim.gpLimRemainOnChanReq->selfMacAddr); |
| 359 | |
| 360 | psessionEntry->currentOperChannel = pMac->lim.gpLimRemainOnChanReq->chnNum; |
| 361 | nSirStatus = eSIR_SUCCESS; |
| 362 | *ppP2pSession = psessionEntry; |
| 363 | } |
| 364 | |
| 365 | return nSirStatus; |
| 366 | } |
| 367 | |
| 368 | |
| 369 | /*------------------------------------------------------------------ |
| 370 | * |
| 371 | * limSuspenLink callback, on success link suspend, trigger change chn |
| 372 | * |
| 373 | * |
| 374 | *------------------------------------------------------------------*/ |
| 375 | |
| 376 | tSirRetStatus limRemainOnChnlChangeChnReq(tpAniSirGlobal pMac, |
| 377 | eHalStatus status, tANI_U32 *data) |
| 378 | { |
| 379 | tpPESession psessionEntry; |
| 380 | tANI_U8 sessionId = 0; |
| 381 | tSirRetStatus nSirStatus = eSIR_FAILURE; |
| 382 | |
| 383 | if( NULL == pMac->lim.gpLimRemainOnChanReq ) |
| 384 | { |
| 385 | //RemainOnChannel may have aborted |
| 386 | PELOGE(limLog( pMac, LOGE, FL(" gpLimRemainOnChanReq is NULL") );) |
| 387 | return nSirStatus; |
| 388 | } |
| 389 | |
| 390 | /* The link is not suspended */ |
| 391 | if (status != eHAL_STATUS_SUCCESS) |
| 392 | { |
| 393 | PELOGE(limLog( pMac, LOGE, FL(" Suspend link Failure ") );) |
| 394 | goto error; |
| 395 | } |
| 396 | |
| 397 | |
| 398 | if((psessionEntry = peFindSessionByBssid( |
| 399 | pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) != NULL) |
| 400 | { |
| 401 | goto change_channel; |
| 402 | } |
| 403 | else /* Session Entry does not exist for given BSSId */ |
| 404 | { |
| 405 | /* Try to Create a new session */ |
| 406 | if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &psessionEntry)) |
| 407 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 408 | limLog(pMac, LOGE, FL("Session Can not be created ")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 409 | /* send remain on chn failure */ |
| 410 | goto error; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | change_channel: |
| 415 | /* change channel to the requested by RemainOn Chn*/ |
| 416 | limChangeChannelWithCallback(pMac, |
| 417 | pMac->lim.gpLimRemainOnChanReq->chnNum, |
| 418 | limRemainOnChnlSetLinkStat, NULL, psessionEntry); |
| 419 | return eSIR_SUCCESS; |
| 420 | |
| 421 | error: |
| 422 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 423 | return eSIR_FAILURE; |
| 424 | } |
| 425 | |
| 426 | void limRemainOnChnlSuspendLinkHdlr(tpAniSirGlobal pMac, eHalStatus status, |
| 427 | tANI_U32 *data) |
| 428 | { |
| 429 | limRemainOnChnlChangeChnReq(pMac, status, data); |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | /*------------------------------------------------------------------ |
| 434 | * |
| 435 | * Set the LINK state to LISTEN to allow only PROBE_REQ and Action frames |
| 436 | * |
| 437 | *------------------------------------------------------------------*/ |
| 438 | void limRemainOnChnlSetLinkStat(tpAniSirGlobal pMac, eHalStatus status, |
| 439 | tANI_U32 *data, tpPESession psessionEntry) |
| 440 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 441 | tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq; |
| 442 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 443 | |
| 444 | if (status != eHAL_STATUS_SUCCESS) |
| 445 | { |
Jeff Johnson | 0f4d0bc | 2013-11-03 17:48:50 -0800 | [diff] [blame] | 446 | limLog( pMac, LOGE, FL("Change channel not successful")); |
Agarwal Ashish | 2f8c56e | 2014-04-07 16:43:37 +0530 | [diff] [blame] | 447 | goto error; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | // Start timer here to come back to operating channel. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 451 | pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time(); |
| 452 | pMac->lim.gTotalScanDuration = MsgRemainonChannel->duration; |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 453 | if (pMac->lim.gDebugP2pRemainOnChannel) |
| 454 | { |
| 455 | pMac->lim.remOnChnSeqNum++; |
| 456 | if( eHAL_STATUS_SUCCESS == limPrepareAndSendStartRemainOnChannelMsg( |
| 457 | pMac, MsgRemainonChannel, |
| 458 | REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME) ) |
| 459 | { |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 460 | limLog( pMac, LOGE, |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 461 | "%s: Successfully sent 1st marker frame with seq num = %d" |
| 462 | " on start ROC", __func__, pMac->lim.remOnChnSeqNum); |
| 463 | } |
| 464 | } |
| 465 | |
Gopichand Nakkala | 924e455 | 2013-05-08 19:18:14 +0530 | [diff] [blame] | 466 | if ((limSetLinkState(pMac, MsgRemainonChannel->isProbeRequestAllowed? |
| 467 | eSIR_LINK_LISTEN_STATE:eSIR_LINK_SEND_ACTION_STATE,nullBssid, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 468 | pMac->lim.gSelfMacAddr, limSetLinkStateP2PCallback, |
| 469 | NULL)) != eSIR_SUCCESS) |
| 470 | { |
| 471 | limLog( pMac, LOGE, "Unable to change link state"); |
| 472 | goto error; |
| 473 | } |
| 474 | |
| 475 | return; |
| 476 | error: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 477 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | /*------------------------------------------------------------------ |
| 482 | * |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame] | 483 | * lim Insert NOA timer timeout callback - when timer fires, deactivate it and send |
| 484 | * scan rsp to csr/hdd |
| 485 | * |
| 486 | *------------------------------------------------------------------*/ |
| 487 | void limProcessInsertSingleShotNOATimeout(tpAniSirGlobal pMac) |
| 488 | { |
Viral Modi | d440e68 | 2013-03-06 02:25:31 -0800 | [diff] [blame] | 489 | /* timeout means start NOA did not arrive; we need to deactivate and change the timer for |
| 490 | * future activations |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame] | 491 | */ |
| 492 | limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER); |
Gopichand Nakkala | 4261ea5 | 2012-12-31 16:43:00 -0800 | [diff] [blame] | 493 | |
Viral Modi | d440e68 | 2013-03-06 02:25:31 -0800 | [diff] [blame] | 494 | /* Even if insert NOA timedout, go ahead and process/send stored SME request */ |
| 495 | limProcessRegdDefdSmeReqAfterNOAStart(pMac); |
Gopichand Nakkala | 4261ea5 | 2012-12-31 16:43:00 -0800 | [diff] [blame] | 496 | |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame] | 497 | return; |
| 498 | } |
| 499 | |
Gopichand Nakkala | d492d20 | 2013-05-10 02:50:47 +0530 | [diff] [blame] | 500 | /*----------------------------------------------------------------- |
| 501 | * lim Insert Timer callback function to check active DFS channels |
| 502 | * and convert them to passive channels if there was no |
| 503 | * beacon/proberesp for MAX_TIME_TO_BE_ACTIVE_CHANNEL time |
| 504 | *------------------------------------------------------------------*/ |
| 505 | void limConvertActiveChannelToPassiveChannel(tpAniSirGlobal pMac ) |
| 506 | { |
Abhishek Singh | 6fcdf65 | 2016-11-23 10:59:12 +0530 | [diff] [blame] | 507 | v_TIME_t currentTime; |
| 508 | v_TIME_t lastTime = 0; |
| 509 | v_TIME_t timeDiff; |
Gopichand Nakkala | d492d20 | 2013-05-10 02:50:47 +0530 | [diff] [blame] | 510 | tANI_U8 i; |
| 511 | currentTime = vos_timer_get_system_time(); |
| 512 | for (i = 1; i < SIR_MAX_24G_5G_CHANNEL_RANGE ; i++) |
| 513 | { |
| 514 | if ((pMac->lim.dfschannelList.timeStamp[i]) != 0) |
| 515 | { |
| 516 | lastTime = pMac->lim.dfschannelList.timeStamp[i]; |
| 517 | if (currentTime >= lastTime) |
| 518 | { |
| 519 | timeDiff = (currentTime - lastTime); |
| 520 | } |
| 521 | else |
| 522 | { |
| 523 | timeDiff = (0xFFFFFFFF - lastTime) + currentTime; |
| 524 | } |
| 525 | |
| 526 | if (timeDiff >= MAX_TIME_TO_BE_ACTIVE_CHANNEL) |
| 527 | { |
| 528 | limCovertChannelScanType( pMac, i,FALSE); |
| 529 | pMac->lim.dfschannelList.timeStamp[i] = 0; |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | /* lastTime is zero if there is no DFS active channels in the list. |
| 534 | * If this is non zero then we have active DFS channels so restart the timer. |
| 535 | */ |
| 536 | if (lastTime != 0) |
| 537 | { |
| 538 | if (tx_timer_activate( |
| 539 | &pMac->lim.limTimers.gLimActiveToPassiveChannelTimer) |
| 540 | != TX_SUCCESS) |
| 541 | { |
| 542 | limLog(pMac, LOGE, FL("Could not activate Active to Passive Channel timer")); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | return; |
| 547 | |
| 548 | } |
| 549 | |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame] | 550 | /*------------------------------------------------------------------ |
| 551 | * |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 552 | * limSetLinkState callback function. |
| 553 | * |
| 554 | *------------------------------------------------------------------*/ |
| 555 | void limSetlinkStateCallback(tpAniSirGlobal pMac, void *callbackArg) |
| 556 | { |
| 557 | if(pMac->lim.gDebugP2pRemainOnChannel) |
| 558 | { |
| 559 | if (eHAL_STATUS_SUCCESS == limPrepareAndSendCancelRemainOnChannelMsg( |
| 560 | pMac, |
| 561 | REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME)) |
| 562 | { |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 563 | limLog( pMac, LOGE, |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 564 | "%s: Successfully sent 2nd marker frame with seq num=%d" |
| 565 | " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | return; |
| 570 | |
| 571 | } |
| 572 | |
| 573 | /*------------------------------------------------------------------ |
| 574 | * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 575 | * limchannelchange callback, on success channel change, set the |
| 576 | * link_state to LISTEN |
| 577 | * |
| 578 | *------------------------------------------------------------------*/ |
| 579 | |
| 580 | void limProcessRemainOnChnTimeout(tpAniSirGlobal pMac) |
| 581 | { |
Agarwal Ashish | 2f8c56e | 2014-04-07 16:43:37 +0530 | [diff] [blame] | 582 | tpPESession psessionEntry; |
| 583 | tANI_U8 sessionId; |
| 584 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 585 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 586 | |
| 587 | if (NULL == pMac->lim.gpLimRemainOnChanReq) |
| 588 | { |
| 589 | limLog( pMac, LOGE, "No Remain on channel pending"); |
| 590 | return; |
| 591 | } |
| 592 | |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 593 | if(pMac->lim.gDebugP2pRemainOnChannel) |
| 594 | { |
| 595 | if (eHAL_STATUS_SUCCESS == limPrepareAndSendCancelRemainOnChannelMsg( |
| 596 | pMac, |
| 597 | REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME)) |
| 598 | { |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 599 | limLog( pMac, LOGE, |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 600 | "%s: Successfully sent 1st marker frame with seqnum = %d" |
| 601 | " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum); |
| 602 | } |
| 603 | } |
| 604 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 605 | /* get the previous valid LINK state */ |
| 606 | if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid, |
Rashmi Ramanna | d3a03bf | 2013-12-31 18:33:24 +0530 | [diff] [blame] | 607 | pMac->lim.gSelfMacAddr, limSetlinkStateCallback, NULL) != eSIR_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 608 | { |
| 609 | limLog( pMac, LOGE, "Unable to change link state"); |
| 610 | return; |
| 611 | } |
| 612 | |
| 613 | if (pMac->lim.gLimMlmState != eLIM_MLM_P2P_LISTEN_STATE ) |
| 614 | { |
| 615 | limRemainOnChnRsp(pMac,eHAL_STATUS_SUCCESS, NULL); |
| 616 | } |
| 617 | else |
| 618 | { |
| 619 | /* get the session */ |
Agarwal Ashish | 2f8c56e | 2014-04-07 16:43:37 +0530 | [diff] [blame] | 620 | if((psessionEntry = peFindSessionByBssid( |
| 621 | pMac,pMac->lim.gpLimRemainOnChanReq->selfMacAddr, &sessionId)) == NULL) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 622 | { |
| 623 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 624 | FL("Session Does not exist for given sessionID")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 625 | goto error; |
| 626 | } |
| 627 | |
| 628 | limExitRemainOnChannel(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry); |
| 629 | return; |
| 630 | error: |
| 631 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 632 | } |
| 633 | return; |
| 634 | } |
| 635 | |
| 636 | |
| 637 | /*------------------------------------------------------------------ |
| 638 | * |
| 639 | * limchannelchange callback, on success channel change, set the link_state |
| 640 | * to LISTEN |
| 641 | * |
| 642 | *------------------------------------------------------------------*/ |
| 643 | |
| 644 | void limExitRemainOnChannel(tpAniSirGlobal pMac, eHalStatus status, |
| 645 | tANI_U32 *data, tpPESession psessionEntry) |
| 646 | { |
| 647 | |
| 648 | if (status != eHAL_STATUS_SUCCESS) |
| 649 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 650 | PELOGE(limLog( pMac, LOGE, "Remain on Channel Failed");) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 651 | goto error; |
| 652 | } |
| 653 | //Set the resume channel to Any valid channel (invalid). |
| 654 | //This will instruct HAL to set it to any previous valid channel. |
| 655 | peSetResumeChannel(pMac, 0, 0); |
| 656 | limResumeLink(pMac, limRemainOnChnRsp, NULL); |
| 657 | return; |
| 658 | error: |
| 659 | limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL); |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | /*------------------------------------------------------------------ |
| 664 | * |
| 665 | * Send remain on channel respone: Success/ Failure |
| 666 | * |
| 667 | *------------------------------------------------------------------*/ |
| 668 | void limRemainOnChnRsp(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data) |
| 669 | { |
| 670 | tpPESession psessionEntry; |
| 671 | tANI_U8 sessionId; |
| 672 | tSirRemainOnChnReq *MsgRemainonChannel = pMac->lim.gpLimRemainOnChanReq; |
| 673 | tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
Ganesh Kondabattini | 358fc9b | 2015-03-11 16:14:25 +0530 | [diff] [blame] | 674 | tANI_U32 txStatus = 0; |
Ganesh Kondabattini | b18b329 | 2015-03-16 16:59:26 +0530 | [diff] [blame] | 675 | tSirTxBdStatus txBdStatus = {0}; |
| 676 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 677 | if ( NULL == MsgRemainonChannel ) |
| 678 | { |
| 679 | PELOGE(limLog( pMac, LOGP, |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 680 | "%s: No Pointer for Remain on Channel Req", __func__);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 681 | return; |
| 682 | } |
| 683 | |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 684 | limLog( pMac, LOG1, "Remain on channel rsp with status %d", status); |
| 685 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 686 | //Incase of the Remain on Channel Failure Case |
| 687 | //Cleanup Everything |
| 688 | if(eHAL_STATUS_FAILURE == status) |
| 689 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 690 | //Set the Link State to Idle |
| 691 | /* get the previous valid LINK state */ |
| 692 | if (limSetLinkState(pMac, eSIR_LINK_IDLE_STATE, nullBssid, |
| 693 | pMac->lim.gSelfMacAddr, NULL, NULL) != eSIR_SUCCESS) |
| 694 | { |
| 695 | limLog( pMac, LOGE, "Unable to change link state"); |
| 696 | } |
| 697 | |
Deepthi Gowri | 3ab7bff | 2015-04-15 20:24:39 +0530 | [diff] [blame] | 698 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | /* delete the session */ |
| 702 | if((psessionEntry = peFindSessionByBssid(pMac, |
| 703 | MsgRemainonChannel->selfMacAddr,&sessionId)) != NULL) |
| 704 | { |
| 705 | if ( eLIM_P2P_DEVICE_ROLE == psessionEntry->limSystemRole ) |
| 706 | { |
| 707 | peDeleteSession( pMac, psessionEntry); |
| 708 | } |
| 709 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 711 | /* Post the meessage to Sme */ |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 712 | limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | MsgRemainonChannel->sessionId, 0); |
| 714 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 715 | vos_mem_free(pMac->lim.gpLimRemainOnChanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 716 | pMac->lim.gpLimRemainOnChanReq = NULL; |
| 717 | |
| 718 | pMac->lim.gLimMlmState = pMac->lim.gLimPrevMlmState; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 719 | |
| 720 | /* If remain on channel timer expired and action frame is pending then |
| 721 | * indicaiton confirmation with status failure */ |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 722 | if (pMac->lim.mgmtFrameSessionId != 0xff) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 723 | { |
Ganesh Kondabattini | b18b329 | 2015-03-16 16:59:26 +0530 | [diff] [blame] | 724 | limLog(pMac, LOGE, |
| 725 | FL("Remain on channel expired, Action frame status failure")); |
| 726 | |
| 727 | if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION)) |
| 728 | limP2PActionCnf(pMac, &txBdStatus); |
| 729 | else |
| 730 | limP2PActionCnf(pMac, &txStatus); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 733 | return; |
| 734 | } |
| 735 | |
| 736 | /*------------------------------------------------------------------ |
| 737 | * |
| 738 | * Indicate the Mgmt Frame received to SME to HDD callback |
| 739 | * handle Probe_req/Action frame currently |
| 740 | * |
| 741 | *------------------------------------------------------------------*/ |
| 742 | void limSendSmeMgmtFrameInd( |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 743 | tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 744 | tANI_U8 *pRxPacketInfo, tpPESession psessionEntry, |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 745 | tANI_S8 rxRssi) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 746 | { |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 747 | tpSirSmeMgmtFrameInd pSirSmeMgmtFrame = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 748 | tANI_U16 length; |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 749 | tANI_U8 frameType; |
| 750 | tpSirMacMgmtHdr frame; |
| 751 | tANI_U32 frameLen; |
| 752 | tANI_U8 rfBand = 0; |
| 753 | tANI_U32 rxChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 754 | |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 755 | frame = WDA_GET_RX_MAC_HEADER(pRxPacketInfo); |
| 756 | frameLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) + sizeof(tSirMacMgmtHdr); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 757 | length = sizeof(tSirSmeMgmtFrameInd) + frameLen; |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 758 | frameType = frame->fc.subType; |
| 759 | rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo); |
| 760 | rxChannel = WDA_GET_RX_CH( pRxPacketInfo ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 761 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 762 | pSirSmeMgmtFrame = vos_mem_malloc(length); |
| 763 | if (NULL == pSirSmeMgmtFrame) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 764 | { |
| 765 | limLog(pMac, LOGP, |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 766 | FL("AllocateMemory failed for eWNI_SME_LISTEN_RSP")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 767 | return; |
| 768 | } |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 769 | vos_mem_set((void*)pSirSmeMgmtFrame, length, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 770 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 771 | pSirSmeMgmtFrame->frameLen = frameLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 772 | pSirSmeMgmtFrame->sessionId = sessionId; |
| 773 | pSirSmeMgmtFrame->frameType = frameType; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 774 | pSirSmeMgmtFrame->rxRssi = rxRssi; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 775 | |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 776 | if (( IS_5G_BAND(rfBand))) |
| 777 | { |
| 778 | rxChannel = limUnmapChannel(rxChannel); |
| 779 | limLog(pMac, LOG1, |
| 780 | FL("rxChannel after unmapping is %d"), rxChannel); |
| 781 | if ( !rxChannel ) |
| 782 | { |
| 783 | tpPESession pTempSessionEntry = limIsApSessionActive(pMac); |
Agarwal Ashish | 2f8c56e | 2014-04-07 16:43:37 +0530 | [diff] [blame] | 784 | if(pMac->lim.gpLimRemainOnChanReq != NULL) |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 785 | { |
| 786 | rxChannel = pMac->lim.gpLimRemainOnChanReq->chnNum; |
| 787 | limLog(pMac, LOG1, |
| 788 | FL("ROC timer is running." |
| 789 | " Assign ROC channel to rxChannel i.e., %d"), rxChannel); |
| 790 | } |
| 791 | else if ( (pTempSessionEntry != NULL) && |
| 792 | (SIR_BAND_5_GHZ != |
| 793 | limGetRFBand(pTempSessionEntry->currentOperChannel)) ) |
| 794 | limLog(pMac, LOGW, |
| 795 | FL("No active p2p GO in 5GHz" |
| 796 | " but recvd Action frame in 5GHz")); |
| 797 | } |
| 798 | } |
| 799 | |
Sunil Ravi | f099894 | 2013-02-04 07:01:12 -0800 | [diff] [blame] | 800 | /* |
| 801 | * Work around to address LIM sending wrong channel to HDD for p2p action |
| 802 | * frames(In case of auto GO) recieved on 5GHz channel. |
| 803 | * As RXP has only 4bits to store the channel, we need some mechanism to |
| 804 | * to distinguish between 2.4Ghz/5GHz channel. if gLimRemainOnChannelTImer |
| 805 | * is not running and if we get a frame then pass the Go session |
| 806 | * operating channel to HDD. Some vendors create separate p2p interface |
| 807 | * after group formation. In that case LIM session entry will be NULL for |
| 808 | * p2p device address. So search for p2p go session and pass it's |
| 809 | * operating channel. |
| 810 | * Need to revisit this path in case of GO+CLIENT concurrency. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 811 | */ |
Agarwal Ashish | 2f8c56e | 2014-04-07 16:43:37 +0530 | [diff] [blame] | 812 | if (NULL == pMac->lim.gpLimRemainOnChanReq) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 813 | { |
Sunil Ravi | f099894 | 2013-02-04 07:01:12 -0800 | [diff] [blame] | 814 | tpPESession pTempSessionEntry = psessionEntry; |
| 815 | if( ( (NULL != pTempSessionEntry) || |
| 816 | (pTempSessionEntry = limIsApSessionActive(pMac)) ) && |
| 817 | (SIR_BAND_5_GHZ == limGetRFBand(pTempSessionEntry->currentOperChannel)) ) |
| 818 | { |
| 819 | rxChannel = pTempSessionEntry->currentOperChannel; |
Rashmi Ramanna | 0d0adec | 2014-02-05 20:35:37 +0530 | [diff] [blame] | 820 | limLog(pMac, LOG1, |
| 821 | FL("Invalid rxChannel." |
| 822 | " Assign GO session op channel to rxChannel i.e., %d"), rxChannel); |
Sunil Ravi | f099894 | 2013-02-04 07:01:12 -0800 | [diff] [blame] | 823 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 824 | } |
Sunil Ravi | f099894 | 2013-02-04 07:01:12 -0800 | [diff] [blame] | 825 | |
| 826 | pSirSmeMgmtFrame->rxChan = rxChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 827 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 828 | vos_mem_zero(pSirSmeMgmtFrame->frameBuf, frameLen); |
| 829 | vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 830 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 831 | if (pMac->mgmt_frame_ind_cb) |
| 832 | pMac->mgmt_frame_ind_cb(pSirSmeMgmtFrame); |
| 833 | else |
| 834 | { |
| 835 | limLog(pMac, LOGW, |
| 836 | FL("Management indication callback not registered!!")); |
| 837 | } |
| 838 | vos_mem_free(pSirSmeMgmtFrame); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 839 | return; |
| 840 | } /*** end limSendSmeListenRsp() ***/ |
| 841 | |
| 842 | |
Ganesh Kondabattini | 358fc9b | 2015-03-11 16:14:25 +0530 | [diff] [blame] | 843 | eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, void *pData) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 844 | { |
Ganesh Kondabattini | 358fc9b | 2015-03-11 16:14:25 +0530 | [diff] [blame] | 845 | tANI_U32 txCompleteSuccess; |
Ganesh Kondabattini | b18b329 | 2015-03-16 16:59:26 +0530 | [diff] [blame] | 846 | tpSirTxBdStatus pTxBdStatus; |
Ganesh Kondabattini | 358fc9b | 2015-03-11 16:14:25 +0530 | [diff] [blame] | 847 | |
| 848 | if (!pData) |
| 849 | { |
| 850 | limLog(pMac, LOG1, |
| 851 | FL(" pData is NULL")); |
| 852 | return eHAL_STATUS_FAILURE; |
| 853 | } |
| 854 | |
Ganesh Kondabattini | b18b329 | 2015-03-16 16:59:26 +0530 | [diff] [blame] | 855 | if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION)) |
| 856 | { |
| 857 | pTxBdStatus = (tpSirTxBdStatus) pData; |
| 858 | txCompleteSuccess = pTxBdStatus->txCompleteStatus; |
Ganesh Kondabattini | 358fc9b | 2015-03-11 16:14:25 +0530 | [diff] [blame] | 859 | |
Ganesh Kondabattini | b18b329 | 2015-03-16 16:59:26 +0530 | [diff] [blame] | 860 | limLog(pMac, LOG1, |
| 861 | FL("txCompleteSuccess %d, Token %u, Session Id %d"), |
| 862 | txCompleteSuccess, pTxBdStatus->txBdToken, |
| 863 | pMac->lim.mgmtFrameSessionId); |
| 864 | } |
| 865 | else |
| 866 | { |
| 867 | txCompleteSuccess = *((tANI_U32*) pData); |
| 868 | |
| 869 | limLog(pMac, LOG1, |
| 870 | FL(" %s txCompleteSuccess %d, Session Id %d"), |
| 871 | __func__, txCompleteSuccess, pMac->lim.mgmtFrameSessionId); |
| 872 | } |
| 873 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 874 | if (pMac->lim.mgmtFrameSessionId != 0xff) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 875 | { |
| 876 | /* The session entry might be invalid(0xff) action confirmation received after |
| 877 | * remain on channel timer expired */ |
| 878 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
| 879 | (txCompleteSuccess ? eSIR_SME_SUCCESS : eSIR_SME_SEND_ACTION_FAIL), |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 880 | pMac->lim.mgmtFrameSessionId, 0); |
| 881 | pMac->lim.mgmtFrameSessionId = 0xff; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 882 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 883 | |
| 884 | return eHAL_STATUS_SUCCESS; |
| 885 | } |
| 886 | |
| 887 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 888 | void limSetHtCaps(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 *pIeStartPtr,tANI_U32 nBytes) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 889 | { |
| 890 | v_U8_t *pIe=NULL; |
| 891 | tDot11fIEHTCaps dot11HtCap; |
| 892 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 893 | PopulateDot11fHTCaps(pMac, psessionEntry, &dot11HtCap); |
Agrawal Ashish | b10d039 | 2015-08-06 16:18:20 +0530 | [diff] [blame] | 894 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 895 | pIe = limGetIEPtr(pMac,pIeStartPtr, nBytes, |
| 896 | DOT11F_EID_HTCAPS,ONE_BYTE); |
Jeff Johnson | 0fe596e | 2017-09-19 08:36:48 -0700 | [diff] [blame] | 897 | limLog( pMac, LOG2, FL("pIe %pK dot11HtCap.supportedMCSSet[0]=0x%x"), |
Jeff Johnson | c7c54b1 | 2013-11-17 11:49:03 -0800 | [diff] [blame] | 898 | pIe, dot11HtCap.supportedMCSSet[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 899 | if(pIe) |
| 900 | { |
| 901 | tHtCaps *pHtcap = (tHtCaps *)&pIe[2]; //convert from unpacked to packed structure |
| 902 | pHtcap->advCodingCap = dot11HtCap.advCodingCap; |
| 903 | pHtcap->supportedChannelWidthSet = dot11HtCap.supportedChannelWidthSet; |
| 904 | pHtcap->mimoPowerSave = dot11HtCap.mimoPowerSave; |
| 905 | pHtcap->greenField = dot11HtCap.greenField; |
| 906 | pHtcap->shortGI20MHz = dot11HtCap.shortGI20MHz; |
| 907 | pHtcap->shortGI40MHz = dot11HtCap.shortGI40MHz; |
| 908 | pHtcap->txSTBC = dot11HtCap.txSTBC; |
| 909 | pHtcap->rxSTBC = dot11HtCap.rxSTBC; |
| 910 | pHtcap->delayedBA = dot11HtCap.delayedBA ; |
| 911 | pHtcap->maximalAMSDUsize = dot11HtCap.maximalAMSDUsize; |
| 912 | pHtcap->dsssCckMode40MHz = dot11HtCap.dsssCckMode40MHz; |
| 913 | pHtcap->psmp = dot11HtCap.psmp; |
| 914 | pHtcap->stbcControlFrame = dot11HtCap.stbcControlFrame; |
| 915 | pHtcap->lsigTXOPProtection = dot11HtCap.lsigTXOPProtection; |
| 916 | pHtcap->maxRxAMPDUFactor = dot11HtCap.maxRxAMPDUFactor; |
| 917 | pHtcap->mpduDensity = dot11HtCap.mpduDensity; |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 918 | vos_mem_copy((void *)pHtcap->supportedMCSSet, |
| 919 | (void *)(dot11HtCap.supportedMCSSet), |
| 920 | sizeof(pHtcap->supportedMCSSet)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 921 | pHtcap->pco = dot11HtCap.pco; |
| 922 | pHtcap->transitionTime = dot11HtCap.transitionTime; |
| 923 | pHtcap->mcsFeedback = dot11HtCap.mcsFeedback; |
| 924 | pHtcap->txBF = dot11HtCap.txBF; |
| 925 | pHtcap->rxStaggeredSounding = dot11HtCap.rxStaggeredSounding; |
| 926 | pHtcap->txStaggeredSounding = dot11HtCap.txStaggeredSounding; |
| 927 | pHtcap->rxZLF = dot11HtCap.rxZLF; |
| 928 | pHtcap->txZLF = dot11HtCap.txZLF; |
| 929 | pHtcap->implicitTxBF = dot11HtCap.implicitTxBF; |
| 930 | pHtcap->calibration = dot11HtCap.calibration; |
| 931 | pHtcap->explicitCSITxBF = dot11HtCap.explicitCSITxBF; |
| 932 | pHtcap->explicitUncompressedSteeringMatrix = |
| 933 | dot11HtCap.explicitUncompressedSteeringMatrix; |
| 934 | pHtcap->explicitBFCSIFeedback = dot11HtCap.explicitBFCSIFeedback; |
| 935 | pHtcap->explicitUncompressedSteeringMatrixFeedback = |
| 936 | dot11HtCap.explicitUncompressedSteeringMatrixFeedback; |
| 937 | pHtcap->explicitCompressedSteeringMatrixFeedback = |
| 938 | dot11HtCap.explicitCompressedSteeringMatrixFeedback; |
| 939 | pHtcap->csiNumBFAntennae = dot11HtCap.csiNumBFAntennae; |
| 940 | pHtcap->uncompressedSteeringMatrixBFAntennae = |
| 941 | dot11HtCap.uncompressedSteeringMatrixBFAntennae; |
| 942 | pHtcap->compressedSteeringMatrixBFAntennae = |
| 943 | dot11HtCap.compressedSteeringMatrixBFAntennae; |
| 944 | pHtcap->antennaSelection = dot11HtCap.antennaSelection; |
| 945 | pHtcap->explicitCSIFeedbackTx = dot11HtCap.explicitCSIFeedbackTx; |
| 946 | pHtcap->antennaIndicesFeedbackTx = dot11HtCap.antennaIndicesFeedbackTx; |
| 947 | pHtcap->explicitCSIFeedback = dot11HtCap.explicitCSIFeedback; |
| 948 | pHtcap->antennaIndicesFeedback = dot11HtCap.antennaIndicesFeedback; |
| 949 | pHtcap->rxAS = dot11HtCap.rxAS; |
| 950 | pHtcap->txSoundingPPDUs = dot11HtCap.txSoundingPPDUs; |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | |
| 955 | void limSendP2PActionFrame(tpAniSirGlobal pMac, tpSirMsgQ pMsg) |
| 956 | { |
| 957 | tSirMbMsgP2p *pMbMsg = (tSirMbMsgP2p *)pMsg->bodyptr; |
| 958 | tANI_U32 nBytes; |
| 959 | tANI_U8 *pFrame; |
| 960 | void *pPacket; |
| 961 | eHalStatus halstatus; |
Kanchanapally, Vidyullatha | f9426e5 | 2013-12-24 17:28:54 +0530 | [diff] [blame] | 962 | tANI_U32 txFlag = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 963 | tpSirMacFrameCtl pFc = (tpSirMacFrameCtl ) pMbMsg->data; |
| 964 | tANI_U8 noaLen = 0; |
Krunal Soni | c768a93 | 2013-05-15 19:26:30 -0700 | [diff] [blame] | 965 | tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + (2*SIR_P2P_IE_HEADER_LEN)]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 966 | tANI_U8 origLen = 0; |
| 967 | tANI_U8 sessionId = 0; |
| 968 | v_U8_t *pP2PIe = NULL; |
| 969 | tpPESession psessionEntry; |
| 970 | v_U8_t *pPresenceRspNoaAttr = NULL; |
| 971 | v_U8_t *pNewP2PIe = NULL; |
| 972 | v_U16_t remainLen = 0; |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 973 | #ifdef WLAN_FEATURE_11W |
| 974 | tpSirMacMgmtHdr pMacHdr; |
| 975 | tpSirMacActionFrameHdr pActionHdr; |
| 976 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 977 | nBytes = pMbMsg->msgLen - sizeof(tSirMbMsg); |
| 978 | |
| 979 | limLog( pMac, LOG1, FL("sending pFc->type=%d pFc->subType=%d"), |
| 980 | pFc->type, pFc->subType); |
| 981 | |
| 982 | psessionEntry = peFindSessionByBssid(pMac, |
| 983 | (tANI_U8*)pMbMsg->data + BSSID_OFFSET, &sessionId); |
| 984 | |
| 985 | /* Check for session corresponding to ADDR2 As Supplicant is filling |
| 986 | ADDR2 with BSSID */ |
| 987 | if( NULL == psessionEntry ) |
| 988 | { |
| 989 | psessionEntry = peFindSessionByBssid(pMac, |
| 990 | (tANI_U8*)pMbMsg->data + ADDR2_OFFSET, &sessionId); |
| 991 | } |
| 992 | |
| 993 | if( NULL == psessionEntry ) |
| 994 | { |
| 995 | tANI_U8 isSessionActive = 0; |
| 996 | tANI_U8 i; |
| 997 | |
| 998 | /* If we are not able to find psessionEntry entry, then try to find |
| 999 | active session, if found any active sessions then send the |
| 1000 | action frame, If no active sessions found then drop the frame */ |
| 1001 | for (i =0; i < pMac->lim.maxBssId;i++) |
| 1002 | { |
| 1003 | psessionEntry = peFindSessionBySessionId(pMac,i); |
| 1004 | if ( NULL != psessionEntry) |
| 1005 | { |
| 1006 | isSessionActive = 1; |
| 1007 | break; |
| 1008 | } |
| 1009 | } |
| 1010 | if( !isSessionActive ) |
| 1011 | { |
| 1012 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
| 1013 | eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0); |
| 1014 | return; |
| 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | if ((SIR_MAC_MGMT_FRAME == pFc->type)&& |
| 1019 | ((SIR_MAC_MGMT_PROBE_RSP == pFc->subType)|| |
| 1020 | (SIR_MAC_MGMT_ACTION == pFc->subType))) |
| 1021 | { |
| 1022 | //if this is a probe RSP being sent from wpa_supplicant |
| 1023 | if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) |
| 1024 | { |
| 1025 | //get proper offset for Probe RSP |
| 1026 | pP2PIe = limGetP2pIEPtr(pMac, |
| 1027 | (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET, |
| 1028 | nBytes - PROBE_RSP_IE_OFFSET); |
| 1029 | while ((NULL != pP2PIe) && (SIR_MAC_MAX_IE_LENGTH == pP2PIe[1])) |
| 1030 | { |
| 1031 | remainLen = nBytes - (pP2PIe - (tANI_U8*)pMbMsg->data); |
| 1032 | if (remainLen > 2) |
| 1033 | { |
| 1034 | pNewP2PIe = limGetP2pIEPtr(pMac, |
| 1035 | pP2PIe+SIR_MAC_MAX_IE_LENGTH + 2, remainLen); |
| 1036 | } |
| 1037 | if (pNewP2PIe) |
| 1038 | { |
| 1039 | pP2PIe = pNewP2PIe; |
| 1040 | pNewP2PIe = NULL; |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | break; |
| 1045 | } |
| 1046 | } //end of while |
| 1047 | } |
| 1048 | else |
| 1049 | { |
| 1050 | if (SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY == |
| 1051 | *((v_U8_t *)pMbMsg->data+ACTION_OFFSET)) |
| 1052 | { |
| 1053 | tpSirMacP2PActionFrameHdr pActionHdr = |
| 1054 | (tpSirMacP2PActionFrameHdr)((v_U8_t *)pMbMsg->data + |
| 1055 | ACTION_OFFSET); |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 1056 | if (vos_mem_compare( pActionHdr->Oui, |
| 1057 | SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1058 | (SIR_MAC_ACTION_P2P_SUBTYPE_PRESENCE_RSP == |
| 1059 | pActionHdr->OuiSubType)) |
| 1060 | { //In case of Presence RSP response |
| 1061 | pP2PIe = limGetP2pIEPtr(pMac, |
| 1062 | (v_U8_t *)pMbMsg->data + ACTION_OFFSET + |
| 1063 | sizeof(tSirMacP2PActionFrameHdr), |
| 1064 | (nBytes - ACTION_OFFSET - |
| 1065 | sizeof(tSirMacP2PActionFrameHdr))); |
| 1066 | if( NULL != pP2PIe ) |
| 1067 | { |
| 1068 | //extract the presence of NoA attribute inside P2P IE |
| 1069 | pPresenceRspNoaAttr = |
| 1070 | limGetIEPtr(pMac,pP2PIe + SIR_P2P_IE_HEADER_LEN, |
| 1071 | pP2PIe[1], SIR_P2P_NOA_ATTR,TWO_BYTE); |
| 1072 | } |
| 1073 | } |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | if (pP2PIe != NULL) |
| 1078 | { |
| 1079 | //get NoA attribute stream P2P IE |
| 1080 | noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry); |
| 1081 | //need to append NoA attribute in P2P IE |
| 1082 | if (noaLen > 0) |
| 1083 | { |
| 1084 | origLen = pP2PIe[1]; |
| 1085 | //if Presence Rsp has NoAttr |
| 1086 | if (pPresenceRspNoaAttr) |
| 1087 | { |
| 1088 | v_U16_t noaAttrLen = pPresenceRspNoaAttr[1] | |
| 1089 | (pPresenceRspNoaAttr[2]<<8); |
| 1090 | /*One byte for attribute, 2bytes for length*/ |
| 1091 | origLen -= (noaAttrLen + 1 + 2); |
| 1092 | //remove those bytes to copy |
| 1093 | nBytes -= (noaAttrLen + 1 + 2); |
| 1094 | //remove NoA from original Len |
| 1095 | pP2PIe[1] = origLen; |
| 1096 | } |
| 1097 | if ((pP2PIe[1] + (tANI_U16)noaLen)> SIR_MAC_MAX_IE_LENGTH) |
| 1098 | { |
| 1099 | //Form the new NoA Byte array in multiple P2P IEs |
| 1100 | noaLen = limGetNoaAttrStreamInMultP2pIes(pMac, noaStream, |
| 1101 | noaLen,((pP2PIe[1] + (tANI_U16)noaLen)- |
| 1102 | SIR_MAC_MAX_IE_LENGTH)); |
| 1103 | pP2PIe[1] = SIR_MAC_MAX_IE_LENGTH; |
| 1104 | } |
| 1105 | else |
| 1106 | { |
| 1107 | pP2PIe[1] += noaLen; //increment the length of P2P IE |
| 1108 | } |
| 1109 | nBytes += noaLen; |
| 1110 | limLog( pMac, LOGE, |
Jeff Johnson | 0fe596e | 2017-09-19 08:36:48 -0700 | [diff] [blame] | 1111 | FL("noaLen=%d origLen=%d pP2PIe=%pK" |
Jeff Johnson | f2de039 | 2013-11-22 18:28:57 -0800 | [diff] [blame] | 1112 | " nBytes=%d nBytesToCopy=%zu"), |
| 1113 | noaLen,origLen, pP2PIe, nBytes, |
| 1114 | ((pP2PIe + origLen + 2) - (v_U8_t *)pMbMsg->data)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | if (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) |
| 1119 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1120 | limSetHtCaps( pMac, psessionEntry, (tANI_U8*)pMbMsg->data + PROBE_RSP_IE_OFFSET, |
Madan Mohan Koyyalamudi | fb29a5d | 2012-10-11 12:14:17 -0700 | [diff] [blame] | 1121 | nBytes - PROBE_RSP_IE_OFFSET); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1122 | } |
Kaushik, Sushant | c048622 | 2014-05-01 12:40:58 +0530 | [diff] [blame] | 1123 | if ((SIR_MAC_MGMT_ACTION == pFc->subType) && |
| 1124 | (0 != pMbMsg->wait)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1125 | { |
Kaushik, Sushant | c048622 | 2014-05-01 12:40:58 +0530 | [diff] [blame] | 1126 | if (pMac->lim.gpLimRemainOnChanReq == NULL) |
| 1127 | { |
| 1128 | limLog( pMac, LOGE, |
Sushant Kaushik | 8778797 | 2015-09-11 16:05:00 +0530 | [diff] [blame] | 1129 | FL("Failed to Send Action frame")); |
Kaushik, Sushant | c048622 | 2014-05-01 12:40:58 +0530 | [diff] [blame] | 1130 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
| 1131 | eHAL_STATUS_FAILURE, pMbMsg->sessionId, 0); |
| 1132 | return; |
| 1133 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1134 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | |
| 1138 | // Ok-- try to allocate some memory: |
| 1139 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1140 | (tANI_U16)nBytes, ( void** ) &pFrame, (void**) &pPacket); |
| 1141 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1142 | { |
| 1143 | limLog( pMac, LOGE, FL("Failed to allocate %d bytes for a Probe" |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1144 | " Request."), nBytes ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1145 | return; |
| 1146 | } |
| 1147 | |
| 1148 | // Paranoia: |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 1149 | vos_mem_set(pFrame, nBytes, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1150 | |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 1151 | if ((noaLen > 0) && (noaLen<(SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1152 | { |
| 1153 | // Add 2 bytes for length and Arribute field |
| 1154 | v_U32_t nBytesToCopy = ((pP2PIe + origLen + 2 ) - |
| 1155 | (v_U8_t *)pMbMsg->data); |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 1156 | vos_mem_copy(pFrame, pMbMsg->data, nBytesToCopy); |
| 1157 | vos_mem_copy((pFrame + nBytesToCopy), noaStream, noaLen); |
| 1158 | vos_mem_copy((pFrame + nBytesToCopy + noaLen), |
| 1159 | pMbMsg->data + nBytesToCopy, nBytes - nBytesToCopy - noaLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1160 | |
| 1161 | } |
| 1162 | else |
| 1163 | { |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 1164 | vos_mem_copy(pFrame, pMbMsg->data, nBytes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1165 | } |
| 1166 | |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1167 | #ifdef WLAN_FEATURE_11W |
| 1168 | pActionHdr = (tpSirMacActionFrameHdr) (pFrame + sizeof(tSirMacMgmtHdr)); |
Abhishek Singh | dc9fc41 | 2016-01-19 15:53:02 +0530 | [diff] [blame] | 1169 | pMacHdr = (tpSirMacMgmtHdr)pFrame; |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1170 | |
| 1171 | /* |
Abhishek Singh | 09d4e4a | 2016-01-12 11:20:22 +0530 | [diff] [blame] | 1172 | * Setting Protected bit only for Robust Action Frames |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1173 | * This has to be based on the current Connection with the station |
Abhishek Singh | 09d4e4a | 2016-01-12 11:20:22 +0530 | [diff] [blame] | 1174 | * limSetProtectedBit API will set the protected bit if connection is PMF |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1175 | */ |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1176 | if ((SIR_MAC_MGMT_ACTION == pFc->subType) && |
Abhishek Singh | 09d4e4a | 2016-01-12 11:20:22 +0530 | [diff] [blame] | 1177 | psessionEntry->limRmfEnabled && (!limIsGroupAddr(pMacHdr->da)) && |
Abhishek Singh | dc9fc41 | 2016-01-19 15:53:02 +0530 | [diff] [blame] | 1178 | lim_is_robust_mgmt_action_frame(pActionHdr->category)) { |
Abhishek Singh | 09d4e4a | 2016-01-12 11:20:22 +0530 | [diff] [blame] | 1179 | /* All psession checks are already done at start */ |
| 1180 | limSetProtectedBit(pMac, psessionEntry, pMacHdr->da, pMacHdr); |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1181 | |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1182 | } |
| 1183 | #endif |
| 1184 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1185 | /* Use BD rate 2 for all P2P related frames. As these frames need to go |
| 1186 | * at OFDM rates. And BD rate2 we configured at 6Mbps. |
| 1187 | */ |
| 1188 | txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME; |
| 1189 | |
Agarwal Ashish | a8e81f5 | 2014-04-02 01:59:52 +0530 | [diff] [blame] | 1190 | if (SIR_MAC_MGMT_ACTION == pFc->subType) |
| 1191 | { |
| 1192 | limLog( pMac, LOG1, FL("Sending Action Frame over WQ5")); |
| 1193 | txFlag |= HAL_USE_FW_IN_TX_PATH; |
| 1194 | } |
| 1195 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1196 | if ( (SIR_MAC_MGMT_PROBE_RSP == pFc->subType) || |
| 1197 | (pMbMsg->noack) |
| 1198 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1199 | { |
| 1200 | halstatus = halTxFrame( pMac, pPacket, (tANI_U16)nBytes, |
| 1201 | HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, |
| 1202 | 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame, |
| 1203 | txFlag ); |
| 1204 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1205 | if (!pMbMsg->noack) |
| 1206 | { |
| 1207 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1208 | halstatus, pMbMsg->sessionId, 0); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1209 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1210 | pMac->lim.mgmtFrameSessionId = 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1211 | } |
| 1212 | else |
| 1213 | { |
Gopichand Nakkala | 6265d6f | 2013-03-20 23:32:50 +0530 | [diff] [blame] | 1214 | pMac->lim.mgmtFrameSessionId = 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1215 | halstatus = halTxFrameWithTxComplete( pMac, pPacket, (tANI_U16)nBytes, |
| 1216 | HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, |
| 1217 | 7,/*SMAC_SWBD_TX_TID_MGMT_HIGH */ limTxComplete, pFrame, |
Ganesh Kondabattini | 10e6735 | 2015-03-16 17:41:57 +0530 | [diff] [blame] | 1218 | limP2PActionCnf, txFlag, pMac->lim.txBdToken++ ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1219 | |
| 1220 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1221 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1222 | limLog( pMac, LOGE, FL("could not send action frame!" )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1223 | limSendSmeRsp(pMac, eWNI_SME_ACTION_FRAME_SEND_CNF, halstatus, |
| 1224 | pMbMsg->sessionId, 0); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1225 | pMac->lim.mgmtFrameSessionId = 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1226 | } |
| 1227 | else |
| 1228 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1229 | pMac->lim.mgmtFrameSessionId = pMbMsg->sessionId; |
Jeff Johnson | 0f4d0bc | 2013-11-03 17:48:50 -0800 | [diff] [blame] | 1230 | limLog( pMac, LOG2, FL("lim.actionFrameSessionId = %u" ), |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1231 | pMac->lim.mgmtFrameSessionId); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1232 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | return; |
| 1237 | } |
| 1238 | |
| 1239 | |
| 1240 | void limAbortRemainOnChan(tpAniSirGlobal pMac) |
| 1241 | { |
Agarwal Ashish | 2f8c56e | 2014-04-07 16:43:37 +0530 | [diff] [blame] | 1242 | limProcessRemainOnChnTimeout(pMac); |
| 1243 | limLog( pMac, LOG1, FL("Abort ROC !!!" )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1244 | return; |
| 1245 | } |
| 1246 | |
| 1247 | /* Power Save Related Functions */ |
| 1248 | tSirRetStatus __limProcessSmeNoAUpdate(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) |
| 1249 | { |
| 1250 | tpP2pPsConfig pNoA; |
| 1251 | tpP2pPsParams pMsgNoA; |
| 1252 | tSirMsgQ msg; |
| 1253 | |
| 1254 | pNoA = (tpP2pPsConfig) pMsgBuf; |
| 1255 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 1256 | pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig )); |
| 1257 | if (NULL == pMsgNoA) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1258 | { |
| 1259 | limLog( pMac, LOGE, |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1260 | FL( "Unable to allocate memory during NoA Update" )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1261 | return eSIR_MEM_ALLOC_FAILED; |
| 1262 | } |
| 1263 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 1264 | vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1265 | pMsgNoA->opp_ps = pNoA->opp_ps; |
| 1266 | pMsgNoA->ctWindow = pNoA->ctWindow; |
| 1267 | pMsgNoA->duration = pNoA->duration; |
| 1268 | pMsgNoA->interval = pNoA->interval; |
| 1269 | pMsgNoA->count = pNoA->count; |
| 1270 | pMsgNoA->single_noa_duration = pNoA->single_noa_duration; |
| 1271 | pMsgNoA->psSelection = pNoA->psSelection; |
| 1272 | |
Viral Modi | d86bde2 | 2012-12-10 13:09:21 -0800 | [diff] [blame] | 1273 | msg.type = WDA_SET_P2P_GO_NOA_REQ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1274 | msg.reserved = 0; |
| 1275 | msg.bodyptr = pMsgNoA; |
| 1276 | msg.bodyval = 0; |
| 1277 | |
| 1278 | if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg)) |
| 1279 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 1280 | limLog(pMac, LOGE, FL("halPostMsgApi failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1281 | return eSIR_FAILURE; |
| 1282 | } |
| 1283 | |
| 1284 | return eSIR_SUCCESS; |
| 1285 | } /*** end __limProcessSmeGoNegReq() ***/ |
| 1286 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1287 | |