Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 0c1331e | 2013-01-07 22:49:07 -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 | */ |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 21 | /* |
| 22 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 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 | */ |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 41 | |
| 42 | /*=========================================================================== |
| 43 | |
| 44 | limProcessTdls.c |
| 45 | |
| 46 | OVERVIEW: |
| 47 | |
| 48 | DEPENDENCIES: |
| 49 | |
| 50 | Are listed for each API below. |
| 51 | |
Gopichand Nakkala | bd9fa2d | 2013-01-08 13:16:22 -0800 | [diff] [blame] | 52 | |
| 53 | Copyright (c) 2010 QUALCOMM Incorporated. |
| 54 | All Rights Reserved. |
| 55 | Qualcomm Confidential and Proprietary |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 56 | ===========================================================================*/ |
| 57 | |
| 58 | /*=========================================================================== |
| 59 | |
| 60 | EDIT HISTORY FOR FILE |
| 61 | |
| 62 | |
| 63 | This section contains comments describing changes made to the module. |
| 64 | Notice that changes are listed in reverse chronological order. |
| 65 | |
| 66 | |
| 67 | $Header$$DateTime$$Author$ |
| 68 | |
| 69 | |
| 70 | when who what, where, why |
| 71 | ---------- --- -------------------------------------------------------- |
| 72 | 05/05/2010 Ashwani Initial Creation, added TDLS action frame functionality, |
| 73 | TDLS message exchange with SME..etc.. |
| 74 | |
| 75 | ===========================================================================*/ |
| 76 | |
| 77 | |
| 78 | /** |
| 79 | * \file limProcessTdls.c |
| 80 | * |
| 81 | * \brief Code for preparing,processing and sending 802.11z action frames |
| 82 | * |
| 83 | */ |
| 84 | |
| 85 | #ifdef FEATURE_WLAN_TDLS |
| 86 | |
| 87 | #include "sirApi.h" |
| 88 | #include "aniGlobal.h" |
| 89 | #include "sirMacProtDef.h" |
| 90 | #include "cfgApi.h" |
| 91 | #include "utilsApi.h" |
| 92 | #include "limTypes.h" |
| 93 | #include "limUtils.h" |
| 94 | #include "limSecurityUtils.h" |
| 95 | #include "dot11f.h" |
| 96 | #include "limStaHashApi.h" |
| 97 | #include "schApi.h" |
| 98 | #include "limSendMessages.h" |
| 99 | #include "utilsParser.h" |
| 100 | #include "limAssocUtils.h" |
| 101 | #include "dphHashTable.h" |
| 102 | #include "wlan_qct_wda.h" |
| 103 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 104 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 105 | #define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 106 | #else |
| 107 | #define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 108 | #endif |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 109 | |
| 110 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 111 | /* forword declarations */ |
| 112 | static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, |
| 113 | tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) ; |
| 114 | static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac, |
| 115 | tSirMacAddr peerMac, tANI_U8 status); |
| 116 | static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac, |
| 117 | tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) ; |
| 118 | static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac, |
| 119 | tANI_U8 state); |
| 120 | static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state, |
| 121 | tLimTdlsLinkSetupPeer **setupPeer) ; |
| 122 | static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peer_mac); |
| 123 | |
| 124 | static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peer_mac); |
| 125 | static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, |
| 126 | tpPESession psessionEntry) ; |
| 127 | |
| 128 | #endif |
| 129 | static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac, tSirMacAddr, |
| 130 | tLimTdlsLinkSetupPeer *setupPeer, tpPESession psessionEntry) ; |
| 131 | void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry, |
| 132 | tDot11fIELinkIdentifier *linkIden, |
| 133 | tSirMacAddr peerMac , tANI_U8 reqType) ; |
| 134 | void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac, |
| 135 | tDot11fIEExtCap *extCapability) ; |
| 136 | /* |
| 137 | * TDLS data frames will go out/come in as non-qos data. |
| 138 | * so, eth_890d_header will be aligned access.. |
| 139 | */ |
| 140 | static const tANI_U8 eth_890d_header[] = |
| 141 | { |
| 142 | 0xaa, 0xaa, 0x03, 0x00, |
| 143 | 0x00, 0x00, 0x89, 0x0d, |
| 144 | } ; |
| 145 | |
| 146 | /* |
| 147 | * type of links used in TDLS |
| 148 | */ |
| 149 | enum tdlsLinks |
| 150 | { |
| 151 | TDLS_LINK_AP, |
| 152 | TDLS_LINK_DIRECT |
| 153 | } eTdlsLink ; |
| 154 | |
| 155 | /* |
| 156 | * node status in node searching |
| 157 | */ |
| 158 | enum tdlsLinkNodeStatus |
| 159 | { |
| 160 | TDLS_NODE_NOT_FOUND, |
| 161 | TDLS_NODE_FOUND |
| 162 | } eTdlsLinkNodeStatus ; |
| 163 | |
| 164 | |
| 165 | enum tdlsReqType |
| 166 | { |
| 167 | TDLS_INITIATOR, |
| 168 | TDLS_RESPONDER |
| 169 | } eTdlsReqType ; |
| 170 | |
| 171 | typedef enum tdlsLinkSetupStatus |
| 172 | { |
| 173 | TDLS_SETUP_STATUS_SUCCESS = 0, |
| 174 | TDLS_SETUP_STATUS_FAILURE = 37 |
| 175 | }etdlsLinkSetupStatus ; |
| 176 | |
| 177 | /* some local defines */ |
| 178 | #define LINK_IDEN_BSSID_OFFSET (0) |
| 179 | #define PEER_MAC_OFFSET (12) |
| 180 | #define STA_MAC_OFFSET (6) |
| 181 | #define LINK_IDEN_ELE_ID (101) |
| 182 | //#define LINK_IDEN_LENGTH (18) |
| 183 | #define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier) |
| 184 | #define PTI_LINK_IDEN_OFFSET (5) |
| 185 | #define PTI_BUF_STATUS_OFFSET (25) |
| 186 | |
| 187 | /* TODO, Move this parameters to configuration */ |
| 188 | #define PEER_PSM_SUPPORT (0) |
| 189 | #define PEER_BUFFER_STA_SUPPORT (1) |
| 190 | #define CH_SWITCH_SUPPORT (0) |
| 191 | #define TDLS_SUPPORT (1) |
| 192 | #define TDLS_PROHIBITED (0) |
| 193 | #define TDLS_CH_SWITCH_PROHIBITED (1) |
| 194 | |
| 195 | #ifdef LIM_DEBUG_TDLS |
| 196 | #define TDLS_CASE_RETURN_STRING(x) case (x): return( ((const tANI_U8*)#x) + 8); /* 8 = remove redundant SIR_MAC_ */ |
| 197 | |
| 198 | #ifdef FEATURE_WLAN_TDLS |
| 199 | #define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100) |
| 200 | #define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800) |
| 201 | #define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200) |
| 202 | #endif |
| 203 | |
| 204 | const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode ) |
| 205 | { |
| 206 | switch( tdlsActionCode ) |
| 207 | { |
| 208 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ); |
| 209 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP); |
| 210 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF); |
| 211 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN); |
| 212 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND); |
| 213 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ); |
| 214 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP); |
| 215 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP); |
| 216 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ); |
| 217 | TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP); |
| 218 | } |
| 219 | return (const tANI_U8*)"UNKNOWN"; |
| 220 | } |
| 221 | #endif |
| 222 | #if 0 |
| 223 | static void printMacAddr(tSirMacAddr macAddr) |
| 224 | { |
| 225 | int i = 0 ; |
| 226 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: ")); |
| 227 | |
| 228 | for(i = 0 ; i < 6; i++) |
| 229 | { |
| 230 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 231 | (" %02x "), macAddr[i]); |
| 232 | } |
| 233 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("\n")); |
| 234 | return ; |
| 235 | } |
| 236 | #endif |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 237 | /* |
| 238 | * initialize TDLS setup list and related data structures. |
| 239 | */ |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 240 | void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry) |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 241 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 242 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 243 | pMac->lim.gLimTdlsDisResultList = NULL ; |
| 244 | pMac->lim.gLimTdlsDisStaCount = 0 ; |
| 245 | palZeroMemory(pMac->hHdd, &pMac->lim.gLimTdlsDisReq, |
| 246 | sizeof(tSirTdlsDisReq)); |
| 247 | palZeroMemory(pMac->hHdd, &pMac->lim.gLimTdlsLinkSetupInfo, |
| 248 | sizeof(tLimTdlsLinkSetupInfo)); |
| 249 | pMac->lim.gAddStaDisRspWait = 0 ; |
| 250 | |
| 251 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 252 | /* when reassociated, negative behavior will not be kept */ |
| 253 | /* you have to explicitly enable negative behavior per (re)association */ |
| 254 | pMac->lim.gLimTdlsNegativeBehavior = 0; |
| 255 | #endif |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 256 | #endif |
| 257 | limInitPeerIdxpool(pMac, pSessionEntry) ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 258 | |
| 259 | return ; |
| 260 | } |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 261 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 262 | void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on) |
| 263 | { |
| 264 | if(on) { |
| 265 | if(value == 255) |
| 266 | pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF; |
| 267 | else |
| 268 | pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1)); |
| 269 | } |
| 270 | else { |
| 271 | if(value == 255) |
| 272 | pMac->lim.gLimTdlsNegativeBehavior = 0; |
| 273 | else |
| 274 | pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1)); |
| 275 | } |
| 276 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("%d %d -> gLimTdlsNegativeBehavior= 0x%lx\n"), \ |
| 277 | value, on, pMac->lim.gLimTdlsNegativeBehavior)); |
| 278 | } |
| 279 | #endif |
| 280 | #if 0 |
| 281 | /* |
| 282 | * This function is used for creating TDLS public Action frame to |
| 283 | * transmit on Direct link |
| 284 | */ |
| 285 | static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame, |
| 286 | tANI_U8 type, tANI_U8 subType, |
| 287 | tANI_U8 *link_iden ) |
| 288 | { |
| 289 | tpSirMacMgmtHdr pMacHdr ; |
| 290 | tANI_U8 *bssid = link_iden ; |
| 291 | #if 0 |
| 292 | tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ; |
| 293 | tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ; |
| 294 | #else |
| 295 | tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ; |
| 296 | tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ; |
| 297 | #endif |
| 298 | tANI_U8 toDs = ANI_TXDIR_IBSS ; |
| 299 | |
| 300 | pMacHdr = (tpSirMacMgmtHdr) (pFrame); |
| 301 | |
| 302 | /* |
| 303 | * prepare 802.11 header |
| 304 | */ |
| 305 | pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION; |
| 306 | pMacHdr->fc.type = type ; |
| 307 | pMacHdr->fc.subType = subType ; |
| 308 | /* |
| 309 | * TL is not setting up below fields, so we are doing it here |
| 310 | */ |
| 311 | pMacHdr->fc.toDS = toDs ; |
| 312 | pMacHdr->fc.powerMgmt = 0 ; |
| 313 | |
| 314 | |
| 315 | palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->da, peerMac, |
| 316 | sizeof( tSirMacAddr )); |
| 317 | palCopyMemory( pMac->hHdd, |
| 318 | (tANI_U8 *) pMacHdr->sa, |
| 319 | staMac, sizeof( tSirMacAddr )); |
| 320 | |
| 321 | palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->bssId, |
| 322 | bssid, sizeof( tSirMacAddr )); |
| 323 | |
| 324 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, ("Preparing TDLS action frame\n%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x\n"), \ |
| 325 | pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5], \ |
| 326 | pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5], \ |
| 327 | pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2], \ |
| 328 | pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5])); |
| 329 | |
| 330 | return ; |
| 331 | } |
| 332 | #endif |
| 333 | /* |
| 334 | * prepare TDLS frame header, it includes |
| 335 | * | | | | |
| 336 | * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD |
| 337 | * | | | | |
| 338 | */ |
| 339 | static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame, |
| 340 | tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType, tpPESession psessionEntry ) |
| 341 | { |
| 342 | tpSirMacMgmtHdr pMacHdr ; |
| 343 | tANI_U32 header_offset = 0 ; |
| 344 | tANI_U8 *addr1 = NULL ; |
| 345 | tANI_U8 *addr3 = NULL ; |
| 346 | tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP) |
| 347 | ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ; |
| 348 | tANI_U8 *peerMac = (reqType == TDLS_INITIATOR) |
| 349 | ? link_iden->RespStaAddr : link_iden->InitStaAddr; |
| 350 | tANI_U8 *staMac = (reqType == TDLS_INITIATOR) |
| 351 | ? link_iden->InitStaAddr : link_iden->RespStaAddr; |
| 352 | |
| 353 | pMacHdr = (tpSirMacMgmtHdr) (pFrame); |
| 354 | |
| 355 | /* |
| 356 | * if TDLS frame goes through the AP link, it follows normal address |
| 357 | * pattern, if TDLS frame goes thorugh the direct link, then |
| 358 | * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID |
| 359 | */ |
| 360 | (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)), |
| 361 | (addr3 = (peerMac))) |
| 362 | : ((addr1 = (peerMac)), |
| 363 | (addr3 = (link_iden->bssid))) ; |
| 364 | /* |
| 365 | * prepare 802.11 header |
| 366 | */ |
| 367 | pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION; |
| 368 | pMacHdr->fc.type = SIR_MAC_DATA_FRAME ; |
| 369 | pMacHdr->fc.subType = SIR_MAC_DATA_DATA ; |
| 370 | /* |
| 371 | * TL is not setting up below fields, so we are doing it here |
| 372 | */ |
| 373 | pMacHdr->fc.toDS = toDs ; |
| 374 | pMacHdr->fc.powerMgmt = 0 ; |
| 375 | pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1; |
| 376 | |
| 377 | |
| 378 | palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->da, (tANI_U8 *)addr1, |
| 379 | sizeof( tSirMacAddr )); |
| 380 | palCopyMemory( pMac->hHdd, |
| 381 | (tANI_U8 *) pMacHdr->sa, |
| 382 | (tANI_U8 *) staMac, |
| 383 | sizeof( tSirMacAddr )); |
| 384 | |
| 385 | palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->bssId, |
| 386 | (tANI_U8 *) (addr3), sizeof( tSirMacAddr )); |
| 387 | |
| 388 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, ("Preparing TDLS frame header to %s\n%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x\n"), \ |
| 389 | (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD", \ |
| 390 | pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5], \ |
| 391 | pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5], \ |
| 392 | pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2], \ |
| 393 | pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5])); |
| 394 | |
| 395 | //printMacAddr(pMacHdr->bssId) ; |
| 396 | //printMacAddr(pMacHdr->sa) ; |
| 397 | //printMacAddr(pMacHdr->da) ; |
| 398 | |
| 399 | header_offset += sizeof(tSirMacMgmtHdr) ; |
| 400 | /* |
| 401 | * Now form RFC1042 header |
| 402 | */ |
| 403 | palCopyMemory(pMac->hHdd, (tANI_U8 *)(pFrame + header_offset), |
| 404 | (tANI_U8 *)eth_890d_header , sizeof(eth_890d_header)) ; |
| 405 | |
| 406 | header_offset += sizeof(eth_890d_header) ; |
| 407 | |
| 408 | /* add payload type as TDLS */ |
| 409 | *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ; |
| 410 | |
| 411 | return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ; |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | * This function can be used for bacst or unicast discovery request |
| 416 | * We are not differentiating it here, it will all depnds on peer MAC address, |
| 417 | */ |
| 418 | tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac, |
| 419 | tANI_U8 dialog, tpPESession psessionEntry) |
| 420 | { |
| 421 | tDot11fTDLSDisReq tdlsDisReq ; |
| 422 | tANI_U32 status = 0 ; |
| 423 | tANI_U32 nPayload = 0 ; |
| 424 | tANI_U32 size = 0 ; |
| 425 | tANI_U32 nBytes = 0 ; |
| 426 | tANI_U32 header_offset = 0 ; |
| 427 | tANI_U8 *pFrame; |
| 428 | void *pPacket; |
| 429 | eHalStatus halstatus; |
| 430 | |
| 431 | /* |
| 432 | * The scheme here is to fill out a 'tDot11fProbeRequest' structure |
| 433 | * and then hand it off to 'dot11fPackProbeRequest' (for |
| 434 | * serialization). We start by zero-initializing the structure: |
| 435 | */ |
| 436 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsDisReq, |
| 437 | sizeof( tDot11fTDLSDisReq ) ); |
| 438 | |
| 439 | /* |
| 440 | * setup Fixed fields, |
| 441 | */ |
| 442 | tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ; |
| 443 | tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ; |
| 444 | tdlsDisReq.DialogToken.token = dialog ; |
| 445 | |
| 446 | |
| 447 | size = sizeof(tSirMacAddr) ; |
| 448 | |
| 449 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier, |
| 450 | peer_mac, TDLS_INITIATOR) ; |
| 451 | |
| 452 | /* |
| 453 | * now we pack it. First, how much space are we going to need? |
| 454 | */ |
| 455 | status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload); |
| 456 | if ( DOT11F_FAILED( status ) ) |
| 457 | { |
| 458 | limLog( pMac, LOGP, FL("Failed to calculate the packed size f" |
| 459 | "or a discovery Request (0x%08x).\n"), status ); |
| 460 | /* We'll fall back on the worst case scenario: */ |
| 461 | nPayload = sizeof( tDot11fTDLSDisReq ); |
| 462 | } |
| 463 | else if ( DOT11F_WARNED( status ) ) |
| 464 | { |
| 465 | limLog( pMac, LOGW, FL("There were warnings while calculating" |
| 466 | "the packed size for a discovery Request (" |
| 467 | "0x%08x).\n"), status ); |
| 468 | } |
| 469 | |
| 470 | /* |
| 471 | * This frame is going out from PE as data frames with special ethertype |
| 472 | * 89-0d. |
| 473 | * 8 bytes of RFC 1042 header |
| 474 | */ |
| 475 | |
| 476 | |
| 477 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) |
| 478 | + sizeof( eth_890d_header ) |
| 479 | + PAYLOAD_TYPE_TDLS_SIZE ; |
| 480 | |
| 481 | /* Ok-- try to allocate memory from MGMT PKT pool */ |
| 482 | |
| 483 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 484 | ( tANI_U16 )nBytes, ( void** ) &pFrame, |
| 485 | ( void** ) &pPacket ); |
| 486 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 487 | { |
| 488 | limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS" |
| 489 | "Discovery Request.\n"), nBytes ); |
| 490 | return eSIR_MEM_ALLOC_FAILED; |
| 491 | } |
| 492 | |
| 493 | /* zero out the memory */ |
| 494 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 495 | |
| 496 | /* |
| 497 | * IE formation, memory allocation is completed, Now form TDLS discovery |
| 498 | * request frame |
| 499 | */ |
| 500 | |
| 501 | /* fill out the buffer descriptor */ |
| 502 | |
| 503 | header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, |
| 504 | LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, psessionEntry) ; |
| 505 | |
| 506 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 507 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ) |
| 508 | { |
| 509 | tdlsDisReq.LinkIdentifier.bssid[4] = 0xde; |
| 510 | tdlsDisReq.LinkIdentifier.bssid[5] = 0xad; |
| 511 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 512 | ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Discovery Req\n"), \ |
| 513 | tdlsDisReq.LinkIdentifier.bssid[0], |
| 514 | tdlsDisReq.LinkIdentifier.bssid[1], |
| 515 | tdlsDisReq.LinkIdentifier.bssid[2], |
| 516 | tdlsDisReq.LinkIdentifier.bssid[3], |
| 517 | tdlsDisReq.LinkIdentifier.bssid[4], |
| 518 | tdlsDisReq.LinkIdentifier.bssid[5]); |
| 519 | } |
| 520 | #endif |
| 521 | status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame |
| 522 | + header_offset, nPayload, &nPayload ); |
| 523 | |
| 524 | if ( DOT11F_FAILED( status ) ) |
| 525 | { |
| 526 | limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \ |
| 527 | (0x%08x).\n"), status ); |
| 528 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 529 | ( void* ) pFrame, ( void* ) pPacket ); |
| 530 | return eSIR_FAILURE; |
| 531 | } |
| 532 | else if ( DOT11F_WARNED( status ) ) |
| 533 | { |
| 534 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 535 | "Discovery Request (0x%08x).\n") ); |
| 536 | } |
| 537 | |
| 538 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 539 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA "), |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 540 | SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) )); |
| 541 | |
| 542 | halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, |
| 543 | HAL_TXRX_FRM_802_11_DATA, |
| 544 | ANI_TXDIR_TODS, |
| 545 | 7, |
| 546 | limTxComplete, pFrame, 0 ); |
| 547 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 548 | { |
| 549 | limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" )); |
| 550 | return eSIR_FAILURE; |
| 551 | |
| 552 | } |
| 553 | |
| 554 | return eSIR_SUCCESS; |
| 555 | |
| 556 | } |
| 557 | |
| 558 | /* |
| 559 | * Once Discovery response is sent successfully (or failure) on air, now send |
| 560 | * response to PE and send del STA to HAL. |
| 561 | */ |
| 562 | eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac, |
| 563 | tANI_U32 txCompleteSuccess) |
| 564 | { |
| 565 | eHalStatus status = eHAL_STATUS_SUCCESS ; |
| 566 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 567 | tpDphHashNode pStaDs = NULL ; |
| 568 | tSirTdlsPeerInfo *peerInfo = 0 ; |
| 569 | |
| 570 | /* find peer by looking into the list by expected state */ |
| 571 | peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ; |
| 572 | |
| 573 | if(NULL == peerInfo) |
| 574 | { |
| 575 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 576 | ("DisRspTxComplete: No TDLS state machine waits for this event\n")); |
| 577 | VOS_ASSERT(0) ; |
| 578 | return eHAL_STATUS_FAILURE; |
| 579 | } |
| 580 | |
| 581 | peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ; |
| 582 | |
| 583 | if(peerInfo->delStaNeeded) |
| 584 | { |
| 585 | tpPESession psessionEntry; |
| 586 | |
| 587 | peerInfo->delStaNeeded = false ; |
| 588 | psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId); |
| 589 | |
| 590 | if(NULL == psessionEntry) |
| 591 | { |
| 592 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 593 | ("DisRspTxComplete: sessionID %d is not found\n"), peerInfo->sessionId); |
| 594 | return eHAL_STATUS_FAILURE; |
| 595 | } |
| 596 | /* send del STA to remove context for this TDLS STA */ |
| 597 | pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ; |
| 598 | |
| 599 | /* now send indication to SME-->HDD->TL to remove STA from TL */ |
| 600 | if(pStaDs) |
| 601 | { |
| 602 | limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId, |
| 603 | pStaDs, eSIR_SUCCESS) ; |
| 604 | } |
| 605 | else |
| 606 | { |
| 607 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 608 | ("DisRspTxComplete: staDs not found for %02x:%02x:%02x:%02x:%02x:%02x\n"), |
| 609 | (peerInfo)->peerMac[0], |
| 610 | (peerInfo)->peerMac[1], |
| 611 | (peerInfo)->peerMac[2], |
| 612 | (peerInfo)->peerMac[3], |
| 613 | (peerInfo)->peerMac[4], |
| 614 | (peerInfo)->peerMac[5]) ; |
| 615 | VOS_ASSERT(0) ; |
| 616 | return eHAL_STATUS_FAILURE; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | if(!txCompleteSuccess) |
| 621 | { |
| 622 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 623 | ("TX complete failure for Dis RSP")); |
| 624 | limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE, |
| 625 | eWNI_SME_TDLS_DISCOVERY_START_IND) ; |
| 626 | status = eHAL_STATUS_FAILURE; |
| 627 | } |
| 628 | else |
| 629 | { |
| 630 | limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS, |
| 631 | eWNI_SME_TDLS_DISCOVERY_START_IND) ; |
| 632 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 633 | ("TX complete Success for Dis RSP")); |
| 634 | status = eHAL_STATUS_SUCCESS ; |
| 635 | } |
| 636 | //pMac->hal.pCBackFnTxComp = NULL ; |
| 637 | #endif |
| 638 | return status ; |
| 639 | |
| 640 | } |
| 641 | /* |
| 642 | * Once setup CNF is sent successfully (or failure) on air, now send |
| 643 | * response to PE and send del STA to HAL. |
| 644 | */ |
| 645 | eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac, |
| 646 | tANI_U32 txCompleteSuccess) |
| 647 | { |
| 648 | eHalStatus status = eHAL_STATUS_SUCCESS ; |
| 649 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 650 | tLimTdlsLinkSetupPeer *peerInfo = 0 ; |
| 651 | /* find peer by looking into the list by expected state */ |
| 652 | limTdlsFindSetupPeerByState(pMac, |
| 653 | TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ; |
| 654 | |
| 655 | if(NULL == peerInfo) |
| 656 | { |
| 657 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 658 | ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event\n")); |
| 659 | VOS_ASSERT(0) ; |
| 660 | return eHAL_STATUS_FAILURE; |
| 661 | } |
| 662 | |
| 663 | (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ; |
| 664 | (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ; |
| 665 | |
| 666 | if(!txCompleteSuccess) |
| 667 | { |
| 668 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 669 | ("TX complete Failure for setup CNF")); |
| 670 | limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac, |
| 671 | eWNI_SME_TDLS_LINK_START_RSP) ; |
| 672 | status = eHAL_STATUS_FAILURE; |
| 673 | } |
| 674 | else |
| 675 | { |
| 676 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 677 | ("RSP-->SME peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 678 | (peerInfo)->peerMac[0], |
| 679 | (peerInfo)->peerMac[1], |
| 680 | (peerInfo)->peerMac[2], |
| 681 | (peerInfo)->peerMac[3], |
| 682 | (peerInfo)->peerMac[4], |
| 683 | (peerInfo)->peerMac[5]) ; |
| 684 | |
| 685 | limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac, |
| 686 | eWNI_SME_TDLS_LINK_START_RSP) ; |
| 687 | |
| 688 | /* tdls_hklee: prepare PTI template and send it to HAL */ |
| 689 | limTdlsLinkEstablish(pMac, (peerInfo)->peerMac); |
| 690 | |
| 691 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 692 | ("TX complete Success for setup CNF")); |
| 693 | status = eHAL_STATUS_SUCCESS ; |
| 694 | } |
| 695 | //pMac->hal.pCBackFnTxComp = NULL ; |
| 696 | #endif |
| 697 | return status ; |
| 698 | |
| 699 | } |
| 700 | |
| 701 | /* |
| 702 | * Tx Complete for Teardown frame |
| 703 | */ |
| 704 | eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac, |
| 705 | tANI_U32 txCompleteSuccess) |
| 706 | { |
| 707 | eHalStatus status = eHAL_STATUS_SUCCESS ; |
| 708 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 709 | tpDphHashNode pStaDs = NULL ; |
| 710 | tLimTdlsLinkSetupPeer *peerInfo = 0 ; |
| 711 | tpPESession psessionEntry = NULL ; |
| 712 | //tANI_U16 msgType = 0 ; |
| 713 | |
| 714 | //tSirMacAddr peerMac = {0} ; |
| 715 | /* find peer by looking into the list by expected state */ |
| 716 | limTdlsFindSetupPeerByState(pMac, |
| 717 | TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ; |
| 718 | |
| 719 | if(NULL == peerInfo) |
| 720 | { |
| 721 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 722 | ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event\n")); |
| 723 | VOS_ASSERT(0) ; |
| 724 | return eHAL_STATUS_FAILURE; |
| 725 | } |
| 726 | |
| 727 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 728 | ("teardown peer Mac = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 729 | (peerInfo)->peerMac[0] , |
| 730 | (peerInfo)->peerMac[1] , |
| 731 | (peerInfo)->peerMac[2] , |
| 732 | (peerInfo)->peerMac[3] , |
| 733 | (peerInfo)->peerMac[4] , |
| 734 | (peerInfo)->peerMac[5] ) ; |
| 735 | |
| 736 | |
| 737 | //pMac->hal.pCBackFnTxComp = NULL ; |
| 738 | |
| 739 | psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId); |
| 740 | |
| 741 | if(NULL == psessionEntry) |
| 742 | { |
| 743 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 744 | ("limTdlsTeardownTxComplete: sessionID %d is not found\n"), (peerInfo)->tdls_sessionId); |
| 745 | VOS_ASSERT(0) ; |
| 746 | return eHAL_STATUS_FAILURE; |
| 747 | } |
| 748 | |
| 749 | if(!txCompleteSuccess) |
| 750 | { |
| 751 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 752 | ("TX complete failure for Teardown \n")) ; |
| 753 | |
| 754 | /* |
| 755 | * we should be sending Teradown to AP with status code |
| 756 | * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if |
| 757 | * that is delivered or not, any way we removing this peer STA from our |
| 758 | * list |
| 759 | */ |
| 760 | if(NULL != psessionEntry) |
| 761 | { |
| 762 | limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac, |
| 763 | eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ; |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state) |
| 768 | { |
| 769 | (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ; |
| 770 | (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ; |
| 771 | /* send del STA to remove context for this TDLS STA */ |
| 772 | if(NULL != psessionEntry) |
| 773 | { |
| 774 | /* tdls_hklee: send message to HAL before it is deleted */ |
| 775 | limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ; |
| 776 | |
| 777 | pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ; |
| 778 | } |
| 779 | |
| 780 | /* now send indication to SME-->HDD->TL to remove STA from TL */ |
| 781 | if(!pStaDs) |
| 782 | { |
| 783 | VOS_ASSERT(0) ; |
| 784 | return eSIR_FAILURE ; |
| 785 | } |
| 786 | limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId, |
| 787 | pStaDs, eSIR_SUCCESS) ; |
| 788 | |
| 789 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 790 | ("TX complete SUCCESS for Teardown\n")) ; |
| 791 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 792 | ("Prev State = %d\n"), (peerInfo)->tdls_prev_link_state) ; |
| 793 | limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac, |
| 794 | eWNI_SME_TDLS_TEARDOWN_RSP) ; |
| 795 | /* Delete Peer for Link Peer List */ |
| 796 | limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ; |
| 797 | } |
| 798 | else |
| 799 | { |
| 800 | (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ; |
| 801 | (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ; |
| 802 | limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac, |
| 803 | eWNI_SME_TDLS_TEARDOWN_IND) ; |
| 804 | } |
| 805 | |
| 806 | |
| 807 | #if 0 |
| 808 | /* if previous state is link restart, then restart link setup again */ |
| 809 | if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state) |
| 810 | { |
| 811 | tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ; |
| 812 | limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37, |
| 813 | peerMac, psessionEntry) ; |
| 814 | } |
| 815 | #endif |
| 816 | status = eHAL_STATUS_SUCCESS ; |
| 817 | #endif |
| 818 | return status ; |
| 819 | } |
| 820 | |
| 821 | /* |
| 822 | * Send TDLS discovery response frame on direct link. |
| 823 | */ |
| 824 | |
| 825 | static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac, |
| 826 | tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry) |
| 827 | { |
| 828 | tDot11fTDLSDisRsp tdlsDisRsp ; |
| 829 | tANI_U16 caps = 0 ; |
| 830 | tANI_U32 status = 0 ; |
| 831 | tANI_U32 nPayload = 0 ; |
| 832 | tANI_U32 nBytes = 0 ; |
| 833 | tANI_U8 *pFrame; |
| 834 | void *pPacket; |
| 835 | eHalStatus halstatus; |
| 836 | |
| 837 | /* |
| 838 | * The scheme here is to fill out a 'tDot11fProbeRequest' structure |
| 839 | * and then hand it off to 'dot11fPackProbeRequest' (for |
| 840 | * serialization). We start by zero-initializing the structure: |
| 841 | */ |
| 842 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsDisRsp, |
| 843 | sizeof( tDot11fTDLSDisRsp ) ); |
| 844 | |
| 845 | /* |
| 846 | * setup Fixed fields, |
| 847 | */ |
| 848 | tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE; |
| 849 | tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ; |
| 850 | tdlsDisRsp.DialogToken.token = dialog ; |
| 851 | |
| 852 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier, |
| 853 | peerMac, TDLS_RESPONDER) ; |
| 854 | |
| 855 | if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS) |
| 856 | { |
| 857 | /* |
| 858 | * Could not get Capabilities value |
| 859 | * from CFG. Log error. |
| 860 | */ |
| 861 | limLog(pMac, LOGP, |
| 862 | FL("could not retrieve Capabilities value\n")); |
| 863 | } |
| 864 | swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities ); |
| 865 | |
| 866 | /* populate supported rate IE */ |
| 867 | PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 868 | &tdlsDisRsp.SuppRates, psessionEntry ); |
| 869 | |
| 870 | /* Populate extended supported rates */ |
| 871 | PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 872 | &tdlsDisRsp.ExtSuppRates, psessionEntry ); |
| 873 | |
| 874 | /* Populate extended supported rates */ |
| 875 | PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap ); |
| 876 | |
| 877 | /* Include HT Capability IE */ |
| 878 | //This does not depend on peer capabilities. If it is supported then it should be included |
| 879 | PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsDisRsp.HTCaps ); |
| 880 | |
| 881 | /* |
| 882 | * now we pack it. First, how much space are we going to need? |
| 883 | */ |
| 884 | status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload); |
| 885 | if ( DOT11F_FAILED( status ) ) |
| 886 | { |
| 887 | limLog( pMac, LOGP, FL("Failed to calculate the packed size f" |
| 888 | "or a discovery Request (0x%08x).\n"), status ); |
| 889 | /* We'll fall back on the worst case scenario: */ |
| 890 | nPayload = sizeof( tDot11fProbeRequest ); |
| 891 | } |
| 892 | else if ( DOT11F_WARNED( status ) ) |
| 893 | { |
| 894 | limLog( pMac, LOGW, FL("There were warnings while calculating" |
| 895 | "the packed size for a discovery Request (" |
| 896 | "0x%08x).\n"), status ); |
| 897 | } |
| 898 | |
| 899 | /* |
| 900 | * This frame is going out from PE as data frames with special ethertype |
| 901 | * 89-0d. |
| 902 | * 8 bytes of RFC 1042 header |
| 903 | */ |
| 904 | |
| 905 | |
| 906 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ; |
| 907 | |
| 908 | /* Ok-- try to allocate memory from MGMT PKT pool */ |
| 909 | |
| 910 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 911 | ( tANI_U16 )nBytes, ( void** ) &pFrame, |
| 912 | ( void** ) &pPacket ); |
| 913 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 914 | { |
| 915 | limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS" |
| 916 | "Discovery Request.\n"), nBytes ); |
| 917 | return eSIR_MEM_ALLOC_FAILED; |
| 918 | } |
| 919 | |
| 920 | /* zero out the memory */ |
| 921 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 922 | |
| 923 | /* |
| 924 | * IE formation, memory allocation is completed, Now form TDLS discovery |
| 925 | * response frame |
| 926 | */ |
| 927 | |
| 928 | /* Make public Action Frame */ |
| 929 | |
| 930 | #if 0 |
| 931 | limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME, |
| 932 | SIR_MAC_MGMT_ACTION, |
| 933 | LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ; |
| 934 | #endif |
| 935 | limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME, |
| 936 | SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr); |
| 937 | |
| 938 | { |
| 939 | tpSirMacMgmtHdr pMacHdr; |
| 940 | pMacHdr = ( tpSirMacMgmtHdr ) pFrame; |
| 941 | pMacHdr->fc.toDS = ANI_TXDIR_IBSS; |
| 942 | pMacHdr->fc.powerMgmt = 0 ; |
| 943 | sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId); |
| 944 | } |
| 945 | |
| 946 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 947 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP) |
| 948 | { |
| 949 | tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde; |
| 950 | tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad; |
| 951 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 952 | ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Discovery Rsp\n"), \ |
| 953 | tdlsDisRsp.LinkIdentifier.bssid[0], |
| 954 | tdlsDisRsp.LinkIdentifier.bssid[1], |
| 955 | tdlsDisRsp.LinkIdentifier.bssid[2], |
| 956 | tdlsDisRsp.LinkIdentifier.bssid[3], |
| 957 | tdlsDisRsp.LinkIdentifier.bssid[4], |
| 958 | tdlsDisRsp.LinkIdentifier.bssid[5]); |
| 959 | } |
| 960 | #endif |
| 961 | status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame + |
| 962 | sizeof( tSirMacMgmtHdr ), |
| 963 | nPayload, &nPayload ); |
| 964 | |
| 965 | if ( DOT11F_FAILED( status ) ) |
| 966 | { |
| 967 | limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \ |
| 968 | (0x%08x).\n"), status ); |
| 969 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 970 | ( void* ) pFrame, ( void* ) pPacket ); |
| 971 | return eSIR_FAILURE; |
| 972 | } |
| 973 | else if ( DOT11F_WARNED( status ) ) |
| 974 | { |
| 975 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 976 | "Discovery Request (0x%08x).\n") ); |
| 977 | } |
| 978 | |
| 979 | #if 0 |
| 980 | if(pMac->hal.pCBackFnTxComp == NULL) |
| 981 | { |
| 982 | pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete; |
| 983 | |
| 984 | if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer)) |
| 985 | { |
| 986 | status = eHAL_STATUS_FAILURE; |
| 987 | return status; |
| 988 | |
| 989 | } |
| 990 | } |
| 991 | #endif |
| 992 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 993 | ("transmitting Discovery response on direct link\n")) ; |
| 994 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 995 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -DIRECT-> OTA"), |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 996 | SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) )); |
| 997 | |
| 998 | |
| 999 | /* |
| 1000 | * Transmit Discovery response and watch if this is delivered to |
| 1001 | * peer STA. |
| 1002 | */ |
| 1003 | halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes, |
| 1004 | HAL_TXRX_FRM_802_11_DATA, |
| 1005 | ANI_TXDIR_IBSS, |
| 1006 | 0, |
| 1007 | limTxComplete, pFrame, |
| 1008 | limTdlsDisRspTxComplete, |
| 1009 | HAL_USE_SELF_STA_REQUESTED_MASK ); |
| 1010 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1011 | { |
| 1012 | limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" )); |
| 1013 | return eSIR_FAILURE; |
| 1014 | |
| 1015 | } |
| 1016 | |
| 1017 | return eSIR_SUCCESS; |
| 1018 | |
| 1019 | } |
| 1020 | |
| 1021 | /* |
| 1022 | * TDLS setup Request frame on AP link |
| 1023 | */ |
| 1024 | |
| 1025 | tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac, |
| 1026 | tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry, |
| 1027 | tANI_U8 *addIe, tANI_U16 addIeLen) |
| 1028 | { |
| 1029 | tDot11fTDLSSetupReq tdlsSetupReq ; |
| 1030 | tANI_U16 caps = 0 ; |
| 1031 | tANI_U32 status = 0 ; |
| 1032 | tANI_U32 nPayload = 0 ; |
| 1033 | tANI_U32 nBytes = 0 ; |
| 1034 | tANI_U32 header_offset = 0 ; |
| 1035 | tANI_U8 *pFrame; |
| 1036 | void *pPacket; |
| 1037 | eHalStatus halstatus; |
| 1038 | |
| 1039 | /* |
| 1040 | * The scheme here is to fill out a 'tDot11fProbeRequest' structure |
| 1041 | * and then hand it off to 'dot11fPackProbeRequest' (for |
| 1042 | * serialization). We start by zero-initializing the structure: |
| 1043 | */ |
| 1044 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupReq, |
| 1045 | sizeof( tDot11fTDLSSetupReq ) ); |
| 1046 | tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ; |
| 1047 | tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ; |
| 1048 | tdlsSetupReq.DialogToken.token = dialog ; |
| 1049 | |
| 1050 | |
| 1051 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier, |
| 1052 | peerMac, TDLS_INITIATOR) ; |
| 1053 | |
| 1054 | if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS) |
| 1055 | { |
| 1056 | /* |
| 1057 | * Could not get Capabilities value |
| 1058 | * from CFG. Log error. |
| 1059 | */ |
| 1060 | limLog(pMac, LOGP, |
| 1061 | FL("could not retrieve Capabilities value\n")); |
| 1062 | } |
| 1063 | swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities ); |
| 1064 | |
| 1065 | /* populate supported rate IE */ |
| 1066 | PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 1067 | &tdlsSetupReq.SuppRates, psessionEntry ); |
| 1068 | |
| 1069 | /* Populate extended supported rates */ |
| 1070 | PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 1071 | &tdlsSetupReq.ExtSuppRates, psessionEntry ); |
| 1072 | |
| 1073 | /* Populate extended supported rates */ |
| 1074 | PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap ); |
| 1075 | |
| 1076 | /* |
| 1077 | * TODO: we need to see if we have to support conditions where we have |
| 1078 | * EDCA parameter info element is needed a) if we need different QOS |
| 1079 | * parameters for off channel operations or QOS is not supported on |
| 1080 | * AP link and we wanted to QOS on direct link. |
| 1081 | */ |
| 1082 | /* Populate QOS info, needed for Peer U-APSD session */ |
| 1083 | /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and |
| 1084 | TDLS doesn't want to depend on AP's capability */ |
| 1085 | tdlsSetupReq.QOSCapsStation.present = 1; |
| 1086 | tdlsSetupReq.QOSCapsStation.max_sp_length = 0; |
| 1087 | tdlsSetupReq.QOSCapsStation.qack = 0; |
| 1088 | tdlsSetupReq.QOSCapsStation.acbe_uapsd = 0; |
| 1089 | tdlsSetupReq.QOSCapsStation.acbk_uapsd = 0; |
| 1090 | tdlsSetupReq.QOSCapsStation.acvi_uapsd = 0; |
| 1091 | tdlsSetupReq.QOSCapsStation.acvo_uapsd = 0; |
| 1092 | |
| 1093 | |
| 1094 | /* |
| 1095 | * we will always try to init TDLS link with 11n capabilities |
| 1096 | * let TDLS setup response to come, and we will set our caps based |
| 1097 | * of peer caps |
| 1098 | */ |
| 1099 | |
| 1100 | /* Include HT Capability IE */ |
| 1101 | PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsSetupReq.HTCaps ); |
| 1102 | |
| 1103 | /* |
| 1104 | * now we pack it. First, how much space are we going to need? |
| 1105 | */ |
| 1106 | status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq, |
| 1107 | &nPayload); |
| 1108 | if ( DOT11F_FAILED( status ) ) |
| 1109 | { |
| 1110 | limLog( pMac, LOGP, FL("Failed to calculate the packed size f" |
| 1111 | "or a discovery Request (0x%08x).\n"), status ); |
| 1112 | /* We'll fall back on the worst case scenario: */ |
| 1113 | nPayload = sizeof( tDot11fProbeRequest ); |
| 1114 | } |
| 1115 | else if ( DOT11F_WARNED( status ) ) |
| 1116 | { |
| 1117 | limLog( pMac, LOGW, FL("There were warnings while calculating" |
| 1118 | "the packed size for a discovery Request (" |
| 1119 | "0x%08x).\n"), status ); |
| 1120 | } |
| 1121 | |
| 1122 | |
| 1123 | /* |
| 1124 | * This frame is going out from PE as data frames with special ethertype |
| 1125 | * 89-0d. |
| 1126 | * 8 bytes of RFC 1042 header |
| 1127 | */ |
| 1128 | |
| 1129 | |
| 1130 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) |
| 1131 | + sizeof( eth_890d_header ) |
| 1132 | + PAYLOAD_TYPE_TDLS_SIZE |
| 1133 | + addIeLen; |
| 1134 | |
| 1135 | /* Ok-- try to allocate memory from MGMT PKT pool */ |
| 1136 | |
| 1137 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1138 | ( tANI_U16 )nBytes , ( void** ) &pFrame, |
| 1139 | ( void** ) &pPacket ); |
| 1140 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1141 | { |
| 1142 | limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS" |
| 1143 | "Discovery Request.\n"), nBytes ); |
| 1144 | return eSIR_MEM_ALLOC_FAILED; |
| 1145 | } |
| 1146 | |
| 1147 | /* zero out the memory */ |
| 1148 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 1149 | |
| 1150 | /* |
| 1151 | * IE formation, memory allocation is completed, Now form TDLS discovery |
| 1152 | * request frame |
| 1153 | */ |
| 1154 | |
| 1155 | /* fill out the buffer descriptor */ |
| 1156 | |
| 1157 | header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, |
| 1158 | LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, psessionEntry) ; |
| 1159 | |
| 1160 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 1161 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ) |
| 1162 | { |
| 1163 | tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde; |
| 1164 | tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad; |
| 1165 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 1166 | ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Setup Req\n"), \ |
| 1167 | tdlsSetupReq.LinkIdentifier.bssid[0], |
| 1168 | tdlsSetupReq.LinkIdentifier.bssid[1], |
| 1169 | tdlsSetupReq.LinkIdentifier.bssid[2], |
| 1170 | tdlsSetupReq.LinkIdentifier.bssid[3], |
| 1171 | tdlsSetupReq.LinkIdentifier.bssid[4], |
| 1172 | tdlsSetupReq.LinkIdentifier.bssid[5]); |
| 1173 | } |
| 1174 | #endif |
| 1175 | status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame |
| 1176 | + header_offset, nPayload, &nPayload ); |
| 1177 | |
| 1178 | if ( DOT11F_FAILED( status ) ) |
| 1179 | { |
| 1180 | limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \ |
| 1181 | (0x%08x).\n"), status ); |
| 1182 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1183 | ( void* ) pFrame, ( void* ) pPacket ); |
| 1184 | return eSIR_FAILURE; |
| 1185 | } |
| 1186 | else if ( DOT11F_WARNED( status ) ) |
| 1187 | { |
| 1188 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 1189 | "Discovery Request (0x%08x).\n") ); |
| 1190 | } |
| 1191 | |
| 1192 | //Copy the additional IE. |
| 1193 | //TODO : addIe is added at the end of the frame. This means it doesnt |
| 1194 | //follow the order. This should be ok, but we should consider changing this |
| 1195 | //if there is any IOT issue. |
| 1196 | if( addIeLen != 0 ) |
| 1197 | { |
| 1198 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"), |
| 1199 | addIeLen )); |
| 1200 | palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); |
| 1201 | } |
| 1202 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 1203 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA"), |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1204 | SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) )); |
| 1205 | |
| 1206 | halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, |
| 1207 | HAL_TXRX_FRM_802_11_DATA, |
| 1208 | ANI_TXDIR_TODS, |
| 1209 | 7,//SMAC_SWBD_TX_TID_MGMT_HIGH, |
| 1210 | limTxComplete, pFrame, 0 ); |
| 1211 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1212 | { |
| 1213 | limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" )); |
| 1214 | return eSIR_FAILURE; |
| 1215 | |
| 1216 | } |
| 1217 | |
| 1218 | return eSIR_SUCCESS; |
| 1219 | |
| 1220 | } |
| 1221 | /* |
| 1222 | * Send TDLS Teardown frame on Direct link or AP link, depends on reason code. |
| 1223 | */ |
| 1224 | |
| 1225 | tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac, |
| 1226 | tSirMacAddr peerMac, tANI_U16 reason, tpPESession psessionEntry, |
| 1227 | tANI_U8 *addIe, tANI_U16 addIeLen) |
| 1228 | { |
| 1229 | tDot11fTDLSTeardown teardown ; |
| 1230 | tANI_U32 status = 0 ; |
| 1231 | tANI_U32 nPayload = 0 ; |
| 1232 | tANI_U32 nBytes = 0 ; |
| 1233 | tANI_U32 header_offset = 0 ; |
| 1234 | tANI_U8 *pFrame; |
| 1235 | void *pPacket; |
| 1236 | eHalStatus halstatus; |
| 1237 | |
| 1238 | /* |
| 1239 | * The scheme here is to fill out a 'tDot11fProbeRequest' structure |
| 1240 | * and then hand it off to 'dot11fPackProbeRequest' (for |
| 1241 | * serialization). We start by zero-initializing the structure: |
| 1242 | */ |
| 1243 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&teardown, |
| 1244 | sizeof( tDot11fTDLSTeardown ) ); |
| 1245 | teardown.Category.category = SIR_MAC_ACTION_TDLS ; |
| 1246 | teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ; |
| 1247 | teardown.Reason.code = reason ; |
| 1248 | |
| 1249 | PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier, |
| 1250 | peerMac, TDLS_INITIATOR) ; |
| 1251 | |
| 1252 | |
| 1253 | /* |
| 1254 | * now we pack it. First, how much space are we going to need? |
| 1255 | */ |
| 1256 | status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload); |
| 1257 | if ( DOT11F_FAILED( status ) ) |
| 1258 | { |
| 1259 | limLog( pMac, LOGP, FL("Failed to calculate the packed size f" |
| 1260 | "or a discovery Request (0x%08x).\n"), status ); |
| 1261 | /* We'll fall back on the worst case scenario: */ |
| 1262 | nPayload = sizeof( tDot11fProbeRequest ); |
| 1263 | } |
| 1264 | else if ( DOT11F_WARNED( status ) ) |
| 1265 | { |
| 1266 | limLog( pMac, LOGW, FL("There were warnings while calculating" |
| 1267 | "the packed size for a discovery Request (" |
| 1268 | "0x%08x).\n"), status ); |
| 1269 | } |
| 1270 | |
| 1271 | |
| 1272 | /* |
| 1273 | * This frame is going out from PE as data frames with special ethertype |
| 1274 | * 89-0d. |
| 1275 | * 8 bytes of RFC 1042 header |
| 1276 | */ |
| 1277 | |
| 1278 | |
| 1279 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) |
| 1280 | + sizeof( eth_890d_header ) |
| 1281 | + PAYLOAD_TYPE_TDLS_SIZE |
| 1282 | + addIeLen; |
| 1283 | |
| 1284 | /* Ok-- try to allocate memory from MGMT PKT pool */ |
| 1285 | |
| 1286 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1287 | ( tANI_U16 )nBytes, ( void** ) &pFrame, |
| 1288 | ( void** ) &pPacket ); |
| 1289 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1290 | { |
| 1291 | limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS" |
| 1292 | "Discovery Request.\n"), nBytes ); |
| 1293 | return eSIR_MEM_ALLOC_FAILED; |
| 1294 | } |
| 1295 | |
| 1296 | /* zero out the memory */ |
| 1297 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 1298 | |
| 1299 | /* |
| 1300 | * IE formation, memory allocation is completed, Now form TDLS discovery |
| 1301 | * request frame |
| 1302 | */ |
| 1303 | |
| 1304 | /* fill out the buffer descriptor */ |
| 1305 | |
| 1306 | header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, |
| 1307 | LINK_IDEN_ADDR_OFFSET(teardown), |
| 1308 | (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) |
| 1309 | ? TDLS_LINK_AP : TDLS_LINK_DIRECT, TDLS_INITIATOR, |
| 1310 | psessionEntry) ; |
| 1311 | |
| 1312 | status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame |
| 1313 | + header_offset, nPayload, &nPayload ); |
| 1314 | |
| 1315 | if ( DOT11F_FAILED( status ) ) |
| 1316 | { |
| 1317 | limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req \ |
| 1318 | (0x%08x).\n"), status ); |
| 1319 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1320 | ( void* ) pFrame, ( void* ) pPacket ); |
| 1321 | return eSIR_FAILURE; |
| 1322 | } |
| 1323 | else if ( DOT11F_WARNED( status ) ) |
| 1324 | { |
| 1325 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 1326 | "Teardown Request (0x%08x).\n") ); |
| 1327 | } |
| 1328 | #if 0 |
| 1329 | if(pMac->hal.pCBackFnTxComp == NULL) |
| 1330 | { |
| 1331 | pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete; |
| 1332 | if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer)) |
| 1333 | { |
| 1334 | status = eHAL_STATUS_FAILURE; |
| 1335 | return status; |
| 1336 | |
| 1337 | } |
| 1338 | } |
| 1339 | else |
| 1340 | { |
| 1341 | VOS_ASSERT(0) ; |
| 1342 | return status ; |
| 1343 | } |
| 1344 | #endif |
| 1345 | |
| 1346 | if( addIeLen != 0 ) |
| 1347 | { |
| 1348 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"), |
| 1349 | addIeLen )); |
| 1350 | palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); |
| 1351 | } |
| 1352 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 1353 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -%s-> OTA"), |
| 1354 | SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN), |
| 1355 | (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ? "AP": "DIRECT" )); |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1356 | |
| 1357 | halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes, |
| 1358 | HAL_TXRX_FRM_802_11_DATA, |
| 1359 | ANI_TXDIR_TODS, |
| 1360 | 7, |
| 1361 | limTxComplete, pFrame, |
| 1362 | limTdlsTeardownTxComplete, |
| 1363 | 0 ); |
| 1364 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1365 | { |
| 1366 | limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" )); |
| 1367 | return eSIR_FAILURE; |
| 1368 | |
| 1369 | } |
| 1370 | return eSIR_SUCCESS; |
| 1371 | |
| 1372 | } |
| 1373 | |
| 1374 | /* |
| 1375 | * Send Setup RSP frame on AP link. |
| 1376 | */ |
| 1377 | static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac, |
| 1378 | tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry, |
| 1379 | etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen ) |
| 1380 | { |
| 1381 | tDot11fTDLSSetupRsp tdlsSetupRsp ; |
| 1382 | tANI_U32 status = 0 ; |
| 1383 | tANI_U16 caps = 0 ; |
| 1384 | tANI_U32 nPayload = 0 ; |
| 1385 | tANI_U32 header_offset = 0 ; |
| 1386 | tANI_U32 nBytes = 0 ; |
| 1387 | tANI_U8 *pFrame; |
| 1388 | void *pPacket; |
| 1389 | eHalStatus halstatus; |
| 1390 | |
| 1391 | /* |
| 1392 | * The scheme here is to fill out a 'tDot11fProbeRequest' structure |
| 1393 | * and then hand it off to 'dot11fPackProbeRequest' (for |
| 1394 | * serialization). We start by zero-initializing the structure: |
| 1395 | */ |
| 1396 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupRsp, |
| 1397 | sizeof( tDot11fTDLSSetupRsp ) ); |
| 1398 | |
| 1399 | /* |
| 1400 | * setup Fixed fields, |
| 1401 | */ |
| 1402 | tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS; |
| 1403 | tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ; |
| 1404 | tdlsSetupRsp.DialogToken.token = dialog; |
| 1405 | |
| 1406 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier, |
| 1407 | peerMac, TDLS_RESPONDER) ; |
| 1408 | |
| 1409 | if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS) |
| 1410 | { |
| 1411 | /* |
| 1412 | * Could not get Capabilities value |
| 1413 | * from CFG. Log error. |
| 1414 | */ |
| 1415 | limLog(pMac, LOGP, |
| 1416 | FL("could not retrieve Capabilities value\n")); |
| 1417 | } |
| 1418 | swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities ); |
| 1419 | |
| 1420 | /* ipopulate supported rate IE */ |
| 1421 | PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 1422 | &tdlsSetupRsp.SuppRates, psessionEntry ); |
| 1423 | |
| 1424 | /* Populate extended supported rates */ |
| 1425 | PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 1426 | &tdlsSetupRsp.ExtSuppRates, psessionEntry ); |
| 1427 | |
| 1428 | /* Populate extended supported rates */ |
| 1429 | PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap ); |
| 1430 | |
| 1431 | /* |
| 1432 | * TODO: we need to see if we have to support conditions where we have |
| 1433 | * EDCA parameter info element is needed a) if we need different QOS |
| 1434 | * parameters for off channel operations or QOS is not supported on |
| 1435 | * AP link and we wanted to QOS on direct link. |
| 1436 | */ |
| 1437 | /* Populate QOS info, needed for Peer U-APSD session */ |
| 1438 | /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and |
| 1439 | TDLS doesn't want to depend on AP's capability */ |
| 1440 | tdlsSetupRsp.QOSCapsStation.present = 1; |
| 1441 | tdlsSetupRsp.QOSCapsStation.max_sp_length = 0; |
| 1442 | tdlsSetupRsp.QOSCapsStation.qack = 0; |
| 1443 | tdlsSetupRsp.QOSCapsStation.acbe_uapsd = 1; |
| 1444 | tdlsSetupRsp.QOSCapsStation.acbk_uapsd = 1; |
| 1445 | tdlsSetupRsp.QOSCapsStation.acvi_uapsd = 1; |
| 1446 | tdlsSetupRsp.QOSCapsStation.acvo_uapsd = 1; |
| 1447 | |
| 1448 | /* Include HT Info IE */ |
| 1449 | // if ( setupReq->HTCaps.present) |
| 1450 | // { |
| 1451 | PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsSetupRsp.HTCaps ); |
| 1452 | // } |
| 1453 | |
| 1454 | tdlsSetupRsp.Status.status = setupStatus ; |
| 1455 | |
| 1456 | /* |
| 1457 | * now we pack it. First, how much space are we going to need? |
| 1458 | */ |
| 1459 | status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp, |
| 1460 | &nPayload); |
| 1461 | if ( DOT11F_FAILED( status ) ) |
| 1462 | { |
| 1463 | limLog( pMac, LOGP, FL("Failed to calculate the packed size f" |
| 1464 | "or a discovery Request (0x%08x).\n"), status ); |
| 1465 | /* We'll fall back on the worst case scenario: */ |
| 1466 | nPayload = sizeof( tDot11fProbeRequest ); |
| 1467 | } |
| 1468 | else if ( DOT11F_WARNED( status ) ) |
| 1469 | { |
| 1470 | limLog( pMac, LOGW, FL("There were warnings while calculating" |
| 1471 | "the packed size for a discovery Request (" |
| 1472 | "0x%08x).\n"), status ); |
| 1473 | } |
| 1474 | |
| 1475 | /* |
| 1476 | * This frame is going out from PE as data frames with special ethertype |
| 1477 | * 89-0d. |
| 1478 | * 8 bytes of RFC 1042 header |
| 1479 | */ |
| 1480 | |
| 1481 | |
| 1482 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) |
| 1483 | + sizeof( eth_890d_header ) |
| 1484 | + PAYLOAD_TYPE_TDLS_SIZE |
| 1485 | + addIeLen; |
| 1486 | |
| 1487 | /* Ok-- try to allocate memory from MGMT PKT pool */ |
| 1488 | |
| 1489 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1490 | ( tANI_U16 )nBytes, ( void** ) &pFrame, |
| 1491 | ( void** ) &pPacket ); |
| 1492 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1493 | { |
| 1494 | limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS" |
| 1495 | "Discovery Request.\n"), nBytes ); |
| 1496 | return eSIR_MEM_ALLOC_FAILED; |
| 1497 | } |
| 1498 | |
| 1499 | /* zero out the memory */ |
| 1500 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 1501 | |
| 1502 | /* |
| 1503 | * IE formation, memory allocation is completed, Now form TDLS discovery |
| 1504 | * request frame |
| 1505 | */ |
| 1506 | |
| 1507 | /* fill out the buffer descriptor */ |
| 1508 | |
| 1509 | header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, |
| 1510 | LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp), |
| 1511 | TDLS_LINK_AP, TDLS_RESPONDER, |
| 1512 | psessionEntry) ; |
| 1513 | |
| 1514 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 1515 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP) |
| 1516 | { |
| 1517 | tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde; |
| 1518 | tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad; |
| 1519 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 1520 | ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Setup Rsp\n"), \ |
| 1521 | tdlsSetupRsp.LinkIdentifier.bssid[0], |
| 1522 | tdlsSetupRsp.LinkIdentifier.bssid[1], |
| 1523 | tdlsSetupRsp.LinkIdentifier.bssid[2], |
| 1524 | tdlsSetupRsp.LinkIdentifier.bssid[3], |
| 1525 | tdlsSetupRsp.LinkIdentifier.bssid[4], |
| 1526 | tdlsSetupRsp.LinkIdentifier.bssid[5]); |
| 1527 | } |
| 1528 | #endif |
| 1529 | status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame |
| 1530 | + header_offset, nPayload, &nPayload ); |
| 1531 | |
| 1532 | if ( DOT11F_FAILED( status ) ) |
| 1533 | { |
| 1534 | limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \ |
| 1535 | (0x%08x).\n"), status ); |
| 1536 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1537 | ( void* ) pFrame, ( void* ) pPacket ); |
| 1538 | return eSIR_FAILURE; |
| 1539 | } |
| 1540 | else if ( DOT11F_WARNED( status ) ) |
| 1541 | { |
| 1542 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 1543 | "Discovery Request (0x%08x).\n") ); |
| 1544 | } |
| 1545 | |
| 1546 | //Copy the additional IE. |
| 1547 | //TODO : addIe is added at the end of the frame. This means it doesnt |
| 1548 | //follow the order. This should be ok, but we should consider changing this |
| 1549 | //if there is any IOT issue. |
| 1550 | if( addIeLen != 0 ) |
| 1551 | { |
| 1552 | palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); |
| 1553 | } |
| 1554 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 1555 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA"), |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1556 | SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) )); |
| 1557 | |
| 1558 | halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes, |
| 1559 | HAL_TXRX_FRM_802_11_DATA, |
| 1560 | ANI_TXDIR_TODS, |
| 1561 | //ANI_TXDIR_IBSS, |
| 1562 | 7, |
| 1563 | limTxComplete, pFrame, 0 ); |
| 1564 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1565 | { |
| 1566 | limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" )); |
| 1567 | return eSIR_FAILURE; |
| 1568 | |
| 1569 | } |
| 1570 | |
| 1571 | return eSIR_SUCCESS; |
| 1572 | |
| 1573 | } |
| 1574 | |
| 1575 | /* |
| 1576 | * Send TDLS setup CNF frame on AP link |
| 1577 | */ |
| 1578 | |
| 1579 | tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac, |
| 1580 | tANI_U8 dialog, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen) |
| 1581 | { |
| 1582 | tDot11fTDLSSetupCnf tdlsSetupCnf ; |
| 1583 | tANI_U32 status = 0 ; |
| 1584 | tANI_U32 nPayload = 0 ; |
| 1585 | tANI_U32 nBytes = 0 ; |
| 1586 | tANI_U32 header_offset = 0 ; |
| 1587 | tANI_U8 *pFrame; |
| 1588 | void *pPacket; |
| 1589 | eHalStatus halstatus; |
| 1590 | |
| 1591 | /* |
| 1592 | * The scheme here is to fill out a 'tDot11fProbeRequest' structure |
| 1593 | * and then hand it off to 'dot11fPackProbeRequest' (for |
| 1594 | * serialization). We start by zero-initializing the structure: |
| 1595 | */ |
| 1596 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupCnf, |
| 1597 | sizeof( tDot11fTDLSSetupCnf ) ); |
| 1598 | |
| 1599 | /* |
| 1600 | * setup Fixed fields, |
| 1601 | */ |
| 1602 | tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS; |
| 1603 | tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ; |
| 1604 | tdlsSetupCnf.DialogToken.token = dialog ; |
| 1605 | |
| 1606 | #if 1 |
| 1607 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier, |
| 1608 | peerMac, TDLS_INITIATOR) ; |
| 1609 | #else |
| 1610 | palCopyMemory( pMac->hHdd, (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier, |
| 1611 | (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ; |
| 1612 | #endif |
| 1613 | |
| 1614 | /* |
| 1615 | * TODO: we need to see if we have to support conditions where we have |
| 1616 | * EDCA parameter info element is needed a) if we need different QOS |
| 1617 | * parameters for off channel operations or QOS is not supported on |
| 1618 | * AP link and we wanted to QOS on direct link. |
| 1619 | */ |
| 1620 | |
| 1621 | /* Include HT Info IE */ |
| 1622 | //if ( tdlsSetupCnf.HTCaps.present) |
| 1623 | //{ |
| 1624 | // PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry ); |
| 1625 | // } |
| 1626 | |
| 1627 | /* |
| 1628 | * now we pack it. First, how much space are we going to need? |
| 1629 | */ |
| 1630 | status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf, |
| 1631 | &nPayload); |
| 1632 | if ( DOT11F_FAILED( status ) ) |
| 1633 | { |
| 1634 | limLog( pMac, LOGP, FL("Failed to calculate the packed size f" |
| 1635 | "or a discovery Request (0x%08x).\n"), status ); |
| 1636 | /* We'll fall back on the worst case scenario: */ |
| 1637 | nPayload = sizeof( tDot11fProbeRequest ); |
| 1638 | } |
| 1639 | else if ( DOT11F_WARNED( status ) ) |
| 1640 | { |
| 1641 | limLog( pMac, LOGW, FL("There were warnings while calculating" |
| 1642 | "the packed size for a discovery Request (" |
| 1643 | "0x%08x).\n"), status ); |
| 1644 | } |
| 1645 | |
| 1646 | /* |
| 1647 | * This frame is going out from PE as data frames with special ethertype |
| 1648 | * 89-0d. |
| 1649 | * 8 bytes of RFC 1042 header |
| 1650 | */ |
| 1651 | |
| 1652 | |
| 1653 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) |
| 1654 | + sizeof( eth_890d_header ) |
| 1655 | + PAYLOAD_TYPE_TDLS_SIZE |
| 1656 | + addIeLen; |
| 1657 | |
| 1658 | /* Ok-- try to allocate memory from MGMT PKT pool */ |
| 1659 | |
| 1660 | halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1661 | ( tANI_U16 )nBytes, ( void** ) &pFrame, |
| 1662 | ( void** ) &pPacket ); |
| 1663 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1664 | { |
| 1665 | limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS" |
| 1666 | "Discovery Request.\n"), nBytes ); |
| 1667 | return eSIR_MEM_ALLOC_FAILED; |
| 1668 | } |
| 1669 | |
| 1670 | /* zero out the memory */ |
| 1671 | palZeroMemory( pMac->hHdd, pFrame, nBytes ); |
| 1672 | |
| 1673 | /* |
| 1674 | * IE formation, memory allocation is completed, Now form TDLS discovery |
| 1675 | * request frame |
| 1676 | */ |
| 1677 | |
| 1678 | /* fill out the buffer descriptor */ |
| 1679 | |
| 1680 | header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, |
| 1681 | LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR, |
| 1682 | psessionEntry) ; |
| 1683 | |
| 1684 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 1685 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) { |
| 1686 | tdlsSetupCnf.StatusCode.statusCode = 37; |
| 1687 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 1688 | ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf\n")); |
| 1689 | } |
| 1690 | #endif |
| 1691 | status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame |
| 1692 | + header_offset, nPayload, &nPayload ); |
| 1693 | |
| 1694 | if ( DOT11F_FAILED( status ) ) |
| 1695 | { |
| 1696 | limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \ |
| 1697 | (0x%08x).\n"), status ); |
| 1698 | palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, |
| 1699 | ( void* ) pFrame, ( void* ) pPacket ); |
| 1700 | return eSIR_FAILURE; |
| 1701 | } |
| 1702 | else if ( DOT11F_WARNED( status ) ) |
| 1703 | { |
| 1704 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 1705 | "Discovery Request (0x%08x).\n") ); |
| 1706 | } |
| 1707 | #if 0 |
| 1708 | if(pMac->hal.pCBackFnTxComp == NULL) |
| 1709 | { |
| 1710 | pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete; |
| 1711 | if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer)) |
| 1712 | { |
| 1713 | status = eHAL_STATUS_FAILURE; |
| 1714 | return status; |
| 1715 | |
| 1716 | } |
| 1717 | } |
| 1718 | else |
| 1719 | { |
| 1720 | VOS_ASSERT(0) ; |
| 1721 | return status ; |
| 1722 | } |
| 1723 | #endif |
| 1724 | //Copy the additional IE. |
| 1725 | //TODO : addIe is added at the end of the frame. This means it doesnt |
| 1726 | //follow the order. This should be ok, but we should consider changing this |
| 1727 | //if there is any IOT issue. |
| 1728 | if( addIeLen != 0 ) |
| 1729 | { |
| 1730 | palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); |
| 1731 | } |
| 1732 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 1733 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA"), |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1734 | SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) )); |
| 1735 | |
| 1736 | halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes, |
| 1737 | HAL_TXRX_FRM_802_11_DATA, |
| 1738 | ANI_TXDIR_TODS, |
| 1739 | 7, |
| 1740 | limTxComplete, pFrame, |
| 1741 | limTdlsSetupCnfTxComplete, |
| 1742 | 0 ); |
| 1743 | |
| 1744 | |
| 1745 | if ( ! HAL_STATUS_SUCCESS ( halstatus ) ) |
| 1746 | { |
| 1747 | limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" )); |
| 1748 | return eSIR_FAILURE; |
| 1749 | |
| 1750 | } |
| 1751 | |
| 1752 | return eSIR_SUCCESS; |
| 1753 | } |
| 1754 | |
| 1755 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 1756 | /* |
| 1757 | * Convert HT caps to lim based HT caps |
| 1758 | */ |
| 1759 | static void limTdlsCovertHTCaps(tpAniSirGlobal pMac , |
| 1760 | tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps) |
| 1761 | { |
| 1762 | |
| 1763 | /* HT Capability Info */ |
| 1764 | peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ; |
| 1765 | peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet = |
| 1766 | HTCaps->supportedChannelWidthSet ; |
| 1767 | peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ; |
| 1768 | peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ; |
| 1769 | peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ; |
| 1770 | peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ; |
| 1771 | peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ; |
| 1772 | peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ; |
| 1773 | peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA; |
| 1774 | peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ; |
| 1775 | peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ; |
| 1776 | peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ; |
| 1777 | peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ; |
| 1778 | peerInfo->tdlsPeerHtCaps.lsigTXOPProtection = |
| 1779 | HTCaps->lsigTXOPProtection ; |
| 1780 | |
| 1781 | /* HT Capa parameters */ |
| 1782 | peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ; |
| 1783 | peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ; |
| 1784 | peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ; |
| 1785 | |
| 1786 | /* Extended HT caps */ |
| 1787 | peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ; |
| 1788 | peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ; |
| 1789 | peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ; |
| 1790 | palCopyMemory(pMac->hHdd, peerInfo->supportedMCSSet, |
| 1791 | HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ; |
| 1792 | |
| 1793 | return ; |
| 1794 | } |
| 1795 | |
| 1796 | /* |
| 1797 | * update capability info.. |
| 1798 | */ |
| 1799 | void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo, |
| 1800 | tDot11fFfCapabilities *Capabilities) |
| 1801 | { |
| 1802 | |
| 1803 | capabilityInfo->ess = Capabilities->ess; |
| 1804 | capabilityInfo->ibss = Capabilities->ibss; |
| 1805 | capabilityInfo->cfPollable = Capabilities->cfPollable; |
| 1806 | capabilityInfo->cfPollReq = Capabilities->cfPollReq; |
| 1807 | capabilityInfo->privacy = Capabilities->privacy; |
| 1808 | capabilityInfo->shortPreamble = Capabilities->shortPreamble; |
| 1809 | capabilityInfo->pbcc = Capabilities->pbcc; |
| 1810 | capabilityInfo->channelAgility = Capabilities->channelAgility; |
| 1811 | capabilityInfo->spectrumMgt = Capabilities->spectrumMgt; |
| 1812 | capabilityInfo->qos = Capabilities->qos; |
| 1813 | capabilityInfo->shortSlotTime = Capabilities->shortSlotTime; |
| 1814 | capabilityInfo->apsd = Capabilities->apsd; |
| 1815 | capabilityInfo->rrm = Capabilities->rrm; |
| 1816 | capabilityInfo->dsssOfdm = Capabilities->dsssOfdm; |
| 1817 | capabilityInfo->immediateBA = Capabilities->immediateBA; |
| 1818 | |
| 1819 | return ; |
| 1820 | } |
| 1821 | |
| 1822 | /* |
| 1823 | * update Peer info from the link request frame recieved from Peer.. |
| 1824 | * in list of STA participating in TDLS link setup |
| 1825 | */ |
| 1826 | void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac, |
| 1827 | tLimTdlsLinkSetupPeer *setupPeer, |
| 1828 | tDot11fTDLSSetupReq *setupReq) |
| 1829 | { |
| 1830 | |
| 1831 | /* Populate peer info of tdls discovery result */ |
| 1832 | |
| 1833 | tdlsUpdateCapInfo(&setupPeer->capabilityInfo , &setupReq->Capabilities) ; |
| 1834 | |
| 1835 | if(setupReq->SuppRates.present) |
| 1836 | { |
| 1837 | ConvertSuppRates( pMac, &setupPeer->supportedRates, |
| 1838 | &setupReq->SuppRates ); |
| 1839 | } |
| 1840 | |
| 1841 | /* update QOS info, needed for Peer U-APSD session */ |
| 1842 | if(setupReq->QOSCapsStation.present) |
| 1843 | { |
| 1844 | ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps, |
| 1845 | &setupReq->QOSCapsStation) ; |
| 1846 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("setupReq->SPLen=%d (be %d %d %d %d vo) more %d qack %d.\n"), \ |
| 1847 | setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd, \ |
| 1848 | setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd, \ |
| 1849 | setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack, \ |
| 1850 | setupReq->QOSCapsStation.qack)); |
| 1851 | } |
| 1852 | |
| 1853 | if(setupReq->ExtSuppRates.present) |
| 1854 | { |
| 1855 | setupPeer->ExtRatesPresent = 1; |
| 1856 | ConvertExtSuppRates( pMac, &setupPeer->extendedRates, |
| 1857 | &setupReq->ExtSuppRates ); |
| 1858 | } |
| 1859 | /* update HT caps */ |
| 1860 | if(setupReq->HTCaps.present) |
| 1861 | { |
| 1862 | palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerHTCaps, |
| 1863 | &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ; |
| 1864 | } |
| 1865 | /* Update EXT caps */ |
| 1866 | if(setupReq->ExtCap.present) |
| 1867 | { |
| 1868 | palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerExtCaps, |
| 1869 | &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ; |
| 1870 | } |
| 1871 | |
| 1872 | return ; |
| 1873 | } |
| 1874 | |
| 1875 | /* |
| 1876 | * update peer Info recieved with TDLS setup RSP |
| 1877 | */ |
| 1878 | void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac, |
| 1879 | tLimTdlsLinkSetupPeer *setupPeer, |
| 1880 | tDot11fTDLSSetupRsp *setupRsp) |
| 1881 | { |
| 1882 | |
| 1883 | /* Populate peer info of tdls discovery result */ |
| 1884 | tdlsUpdateCapInfo(&setupPeer->capabilityInfo , &setupRsp->Capabilities) ; |
| 1885 | |
| 1886 | if(setupRsp->SuppRates.present) |
| 1887 | { |
| 1888 | tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ; |
| 1889 | ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates); |
| 1890 | } |
| 1891 | |
| 1892 | /* update QOS info, needed for Peer U-APSD session */ |
| 1893 | if(setupRsp->QOSCapsStation.present) |
| 1894 | { |
| 1895 | ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps, |
| 1896 | &setupRsp->QOSCapsStation) ; |
| 1897 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("setupRsp->SPLen=%d (be %d %d %d %d vo) more %d qack %d.\n"), \ |
| 1898 | setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd, \ |
| 1899 | setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd, \ |
| 1900 | setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack, \ |
| 1901 | setupRsp->QOSCapsStation.qack)); |
| 1902 | } |
| 1903 | |
| 1904 | if(setupRsp->ExtSuppRates.present) |
| 1905 | { |
| 1906 | setupPeer->ExtRatesPresent = 1; |
| 1907 | ConvertExtSuppRates( pMac, &setupPeer->extendedRates, |
| 1908 | &setupRsp->ExtSuppRates ); |
| 1909 | } |
| 1910 | /* update HT caps */ |
| 1911 | if(setupRsp->HTCaps.present) |
| 1912 | { |
| 1913 | palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerHTCaps, |
| 1914 | &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ; |
| 1915 | } |
| 1916 | |
| 1917 | /* update EXT caps */ |
| 1918 | if(setupRsp->ExtCap.present) |
| 1919 | { |
| 1920 | palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerExtCaps, |
| 1921 | &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ; |
| 1922 | } |
| 1923 | |
| 1924 | return ; |
| 1925 | } |
| 1926 | #endif |
| 1927 | /* |
| 1928 | * update HASH node entry info |
| 1929 | */ |
| 1930 | static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs, |
| 1931 | tLimTdlsLinkSetupPeer *setupPeerInfo, tpPESession psessionEntry) |
| 1932 | { |
| 1933 | //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ; |
| 1934 | tDot11fIEHTCaps htCap, *htCaps; |
| 1935 | tpDphHashNode pSessStaDs = NULL; |
| 1936 | tANI_U16 aid; |
| 1937 | |
| 1938 | //HACK- to get the session's htcaps. |
| 1939 | PopulateDot11fHTCaps(pMac, psessionEntry, &htCap); |
| 1940 | htCaps = &htCap; |
| 1941 | if(htCaps->present) |
| 1942 | { |
| 1943 | pStaDs->mlmStaContext.htCapability = 1 ; |
| 1944 | pStaDs->htGreenfield = htCaps->greenField ; |
| 1945 | pStaDs->htSupportedChannelWidthSet = htCaps->supportedChannelWidthSet ; |
| 1946 | pStaDs->htMIMOPSState = htCaps->mimoPowerSave ; |
| 1947 | pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize; |
| 1948 | pStaDs->htAMpduDensity = htCaps->mpduDensity; |
| 1949 | pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ; |
| 1950 | pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz; |
| 1951 | pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz; |
| 1952 | pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor; |
| 1953 | limFillRxHighestSupportedRate(pMac, |
| 1954 | &pStaDs->supportedRates.rxHighestDataRate, |
| 1955 | htCaps->supportedMCSSet); |
| 1956 | pStaDs->baPolicyFlag = 0xFF; |
| 1957 | |
| 1958 | pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ; |
| 1959 | } |
| 1960 | else |
| 1961 | { |
| 1962 | pStaDs->mlmStaContext.htCapability = 0 ; |
| 1963 | pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ; |
| 1964 | } |
| 1965 | |
| 1966 | pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid, |
| 1967 | &psessionEntry->dph.dphHashTable) ; |
| 1968 | |
| 1969 | /* Lets enable QOS parameter */ |
| 1970 | pStaDs->qosMode = 1; |
| 1971 | pStaDs->wmeEnabled = 1; |
| 1972 | pStaDs->lleEnabled = 0; |
| 1973 | pStaDs->qos.capability.qosInfo = pSessStaDs->qos.capability.qosInfo; //setupPeerInfo->qosCaps.qosInfo; |
| 1974 | |
| 1975 | /* populate matching rate set */ |
| 1976 | #if 0 |
| 1977 | #ifdef WLAN_FEATURE_11AC |
| 1978 | limPopulateMatchingRateSet(pMac, pStaDs, &setupPeerInfo->supportedRates, |
| 1979 | &setupPeerInfo->extendedRates, |
| 1980 | (tANI_U8 *)setupPeerInfo->tdlsPeerHTCaps.supportedMCSSet, |
| 1981 | &pStaDs->mlmStaContext.propRateSet, psessionEntry, NULL); |
| 1982 | #else |
| 1983 | limPopulateMatchingRateSet(pMac, pStaDs, &setupPeerInfo->supportedRates, |
| 1984 | &setupPeerInfo->extendedRates, |
| 1985 | (tANI_U8 *)setupPeerInfo->tdlsPeerHTCaps.supportedMCSSet, |
| 1986 | &pStaDs->mlmStaContext.propRateSet, psessionEntry); |
| 1987 | #endif |
| 1988 | #else |
| 1989 | palCopyMemory( pMac->hHdd, &pStaDs->supportedRates, &pSessStaDs->supportedRates, sizeof(pStaDs->supportedRates)); |
| 1990 | #endif |
| 1991 | |
| 1992 | pStaDs->mlmStaContext.capabilityInfo = pSessStaDs->mlmStaContext.capabilityInfo;// setupPeerInfo->capabilityInfo; |
| 1993 | |
| 1994 | return ; |
| 1995 | } |
| 1996 | |
| 1997 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 1998 | /* |
| 1999 | * find Peer in setup link list. |
| 2000 | */ |
| 2001 | |
| 2002 | tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac, |
| 2003 | tLimTdlsLinkSetupPeer **setupPeer) |
| 2004 | { |
| 2005 | tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ; |
| 2006 | tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ; |
| 2007 | tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ; |
| 2008 | |
| 2009 | while (linkSetupList != NULL) |
| 2010 | { |
| 2011 | if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac, |
| 2012 | (tANI_U8 *) linkSetupList->peerMac, |
| 2013 | sizeof(tSirMacAddr)) ) |
| 2014 | { |
| 2015 | checkNode = TDLS_NODE_FOUND ; |
| 2016 | *setupPeer = linkSetupList ; |
| 2017 | break ; |
| 2018 | } |
| 2019 | linkSetupList = linkSetupList->next; |
| 2020 | } |
| 2021 | |
| 2022 | return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ; |
| 2023 | } |
| 2024 | |
| 2025 | /* |
| 2026 | * find peer in Discovery list. |
| 2027 | * Dicovery list get populated in two instances, a) Recieved responses in reply |
| 2028 | * to discovery request b) If discover request is received from TDLS peer STA |
| 2029 | */ |
| 2030 | tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac) |
| 2031 | { |
| 2032 | tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ; |
| 2033 | tSirTdlsPeerInfo *peerInfo = NULL ; |
| 2034 | |
| 2035 | while (discoveryList != NULL) |
| 2036 | { |
| 2037 | peerInfo = &discoveryList->tdlsDisPeerInfo ; |
| 2038 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2039 | ("Peer in discovery list = %02x, %02x, %02x, %02x, %02x, %02x \n"), |
| 2040 | peerInfo->peerMac[0], |
| 2041 | peerInfo->peerMac[1], |
| 2042 | peerInfo->peerMac[2], |
| 2043 | peerInfo->peerMac[3], |
| 2044 | peerInfo->peerMac[4], |
| 2045 | peerInfo->peerMac[5]) ; |
| 2046 | |
| 2047 | if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac, |
| 2048 | (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) ) |
| 2049 | { |
| 2050 | break ; |
| 2051 | } |
| 2052 | discoveryList = discoveryList->next; |
| 2053 | } |
| 2054 | |
| 2055 | return peerInfo ; |
| 2056 | } |
| 2057 | |
| 2058 | /* |
| 2059 | * find peer in Discovery list by looking into peer state. |
| 2060 | * Dicovery list get populated in two instances, a) Recieved responses in reply |
| 2061 | * to discovery request b) If discover request is received from TDLS peer STA |
| 2062 | */ |
| 2063 | static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac, |
| 2064 | tANI_U8 state) |
| 2065 | { |
| 2066 | tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ; |
| 2067 | tSirTdlsPeerInfo *peerInfo = NULL ; |
| 2068 | |
| 2069 | while (discoveryList != NULL) |
| 2070 | { |
| 2071 | peerInfo = &discoveryList->tdlsDisPeerInfo ; |
| 2072 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2073 | ("peerInfo Mac = %02x, %02x, %02x, %02x, %02x, %02x "), |
| 2074 | peerInfo->peerMac[0], |
| 2075 | peerInfo->peerMac[1], |
| 2076 | peerInfo->peerMac[2], |
| 2077 | peerInfo->peerMac[3], |
| 2078 | peerInfo->peerMac[4], |
| 2079 | peerInfo->peerMac[5]) ; |
| 2080 | |
| 2081 | if (peerInfo->tdlsPeerState == state) |
| 2082 | { |
| 2083 | break ; |
| 2084 | } |
| 2085 | discoveryList = discoveryList->next; |
| 2086 | } |
| 2087 | |
| 2088 | return peerInfo ; |
| 2089 | } |
| 2090 | |
| 2091 | /* |
| 2092 | * find peer in Setup list by looking into peer state. |
| 2093 | * setup list get populated in two instances, a) Recieved responses in reply |
| 2094 | * to setup request b) If discover request is received from TDLS peer STA |
| 2095 | */ |
| 2096 | static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state, |
| 2097 | tLimTdlsLinkSetupPeer **setupPeer) |
| 2098 | { |
| 2099 | |
| 2100 | tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ; |
| 2101 | tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ; |
| 2102 | tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ; |
| 2103 | |
| 2104 | while (linkSetupList != NULL) |
| 2105 | { |
| 2106 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2107 | ("peer state = %02x\n"), (linkSetupList)->tdls_link_state) ; |
| 2108 | if((linkSetupList)->tdls_link_state == state) |
| 2109 | { |
| 2110 | checkNode = TDLS_NODE_FOUND ; |
| 2111 | *setupPeer = linkSetupList ; |
| 2112 | break ; |
| 2113 | } |
| 2114 | linkSetupList = (linkSetupList)->next; |
| 2115 | } |
| 2116 | |
| 2117 | return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ; |
| 2118 | } |
| 2119 | |
| 2120 | |
| 2121 | /* |
| 2122 | * delete Peer from Setup Link |
| 2123 | */ |
| 2124 | void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac) |
| 2125 | { |
| 2126 | tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ; |
| 2127 | tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ; |
| 2128 | tLimTdlsLinkSetupPeer *currentNode = NULL ; |
| 2129 | tLimTdlsLinkSetupPeer *prevNode = NULL ; |
| 2130 | |
| 2131 | for(currentNode = *linkSetupList ; currentNode != NULL ; |
| 2132 | prevNode = currentNode, currentNode = currentNode->next) |
| 2133 | { |
| 2134 | if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac, |
| 2135 | (tANI_U8 *) currentNode->peerMac, |
| 2136 | sizeof(tSirMacAddr)) ) |
| 2137 | { |
| 2138 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2139 | ("Del Node for Peer = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 2140 | currentNode->peerMac[0], |
| 2141 | currentNode->peerMac[1], |
| 2142 | currentNode->peerMac[2], |
| 2143 | currentNode->peerMac[3], |
| 2144 | currentNode->peerMac[4], |
| 2145 | currentNode->peerMac[5]) ; |
| 2146 | /* if it's first Node */ |
| 2147 | if(NULL == prevNode) |
| 2148 | { |
| 2149 | *linkSetupList = currentNode->next ; |
| 2150 | } |
| 2151 | else |
| 2152 | { |
| 2153 | prevNode->next = currentNode->next ; |
| 2154 | } |
| 2155 | palFreeMemory(pMac, currentNode) ; |
| 2156 | return ; |
| 2157 | } |
| 2158 | } |
| 2159 | |
| 2160 | return ; |
| 2161 | } |
| 2162 | |
| 2163 | |
| 2164 | |
| 2165 | /* |
| 2166 | * TDLS discovery request frame received from TDLS peer STA.. |
| 2167 | */ |
| 2168 | static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac, |
| 2169 | tANI_U8 *pBody, tANI_U32 frmLen ) |
| 2170 | { |
| 2171 | tDot11fTDLSDisReq tdlsDisReq = {{0}} ; |
| 2172 | tANI_U32 status = 0 ; |
| 2173 | tLimDisResultList *tdlsDisResult = NULL ; |
| 2174 | tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ; |
| 2175 | tSirMacAddr peerMac = {0} ; |
| 2176 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 2177 | tSirTdlsPeerInfo *peerInfo = NULL ; |
| 2178 | tpPESession psessionEntry = NULL ; |
| 2179 | tANI_U8 sessionId = 0 ; |
| 2180 | |
| 2181 | status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ; |
| 2182 | |
| 2183 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, |
| 2184 | ("TDLS dis request dialog = %d\n"), tdlsDisReq.DialogToken.token); |
| 2185 | |
| 2186 | if ( DOT11F_FAILED( status ) ) |
| 2187 | { |
| 2188 | limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \ |
| 2189 | frame (0x%08x, %d bytes):\n"),status, frmLen); |
| 2190 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2191 | return eSIR_FAILURE; |
| 2192 | } |
| 2193 | else if ( DOT11F_WARNED( status ) ) |
| 2194 | { |
| 2195 | limLog( pMac, LOGW, FL("There were warnings while unpacking an\ |
| 2196 | TDLS discovery Request frame (0x%08x," "%d bytes):\n"), |
| 2197 | status, frmLen ); |
| 2198 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2199 | } |
| 2200 | |
| 2201 | /* |
| 2202 | * find session entry using BSSID in link identifier, not using MAC |
| 2203 | * header beacuse, there is cases in TDLS, there may be BSSID will not |
| 2204 | * be present in header |
| 2205 | */ |
| 2206 | psessionEntry = peFindSessionByBssid(pMac, |
| 2207 | &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ; |
| 2208 | if(NULL == psessionEntry) |
| 2209 | { |
| 2210 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \ |
| 2211 | ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \ |
| 2212 | tdlsDisReq.LinkIdentifier.bssid[0], |
| 2213 | tdlsDisReq.LinkIdentifier.bssid[1], |
| 2214 | tdlsDisReq.LinkIdentifier.bssid[2], |
| 2215 | tdlsDisReq.LinkIdentifier.bssid[3], |
| 2216 | tdlsDisReq.LinkIdentifier.bssid[4], |
| 2217 | tdlsDisReq.LinkIdentifier.bssid[5]) ; |
| 2218 | |
| 2219 | //VOS_ASSERT(0) ; |
| 2220 | return eSIR_FAILURE; |
| 2221 | } |
| 2222 | |
| 2223 | /* varify BSSID */ |
| 2224 | status = palEqualMemory(pMac->hHdd, &psessionEntry->bssId[0], |
| 2225 | &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ; |
| 2226 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2227 | ("lim BSSID %02x, %02x, %02x, %02x, %02x, %02x\n"), |
| 2228 | psessionEntry->bssId[0], |
| 2229 | psessionEntry->bssId[1], |
| 2230 | psessionEntry->bssId[2], |
| 2231 | psessionEntry->bssId[3], |
| 2232 | psessionEntry->bssId[4], |
| 2233 | psessionEntry->bssId[5]) ; |
| 2234 | |
| 2235 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2236 | ("Dis req from BSSID %02x, %02x, %02x, %02x, %02x, %02x\n"), |
| 2237 | tdlsDisReq.LinkIdentifier.bssid[0], |
| 2238 | tdlsDisReq.LinkIdentifier.bssid[1], |
| 2239 | tdlsDisReq.LinkIdentifier.bssid[2], |
| 2240 | tdlsDisReq.LinkIdentifier.bssid[3], |
| 2241 | tdlsDisReq.LinkIdentifier.bssid[4], |
| 2242 | tdlsDisReq.LinkIdentifier.bssid[5] |
| 2243 | ) ; |
| 2244 | if(!status) |
| 2245 | { |
| 2246 | limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter\n")) ; |
| 2247 | |
| 2248 | return eSIR_FAILURE ; |
| 2249 | } |
| 2250 | |
| 2251 | /* |
| 2252 | * check if this is echo of our transmitted discovery request |
| 2253 | * drop it here, TODO: better to drop this in TL. |
| 2254 | */ |
| 2255 | status = palEqualMemory(pMac->hHdd, psessionEntry->selfMacAddr, |
| 2256 | &tdlsDisReq.LinkIdentifier.InitStaAddr[0], |
| 2257 | sizeof(tSirMacAddr)) ; |
| 2258 | if(status) |
| 2259 | { |
| 2260 | limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame\n")) ; |
| 2261 | return eSIR_FAILURE ; |
| 2262 | } |
| 2263 | |
| 2264 | /* |
| 2265 | * while processing Discovery request from Peer, |
| 2266 | * STA_MAC--> MAC of TDLS discovery initiator |
| 2267 | * STA_PEER_MAC--> MAC of TDLS discovery responder. |
| 2268 | */ |
| 2269 | palCopyMemory(pMac->hHdd, peerMac, |
| 2270 | &tdlsDisReq.LinkIdentifier.InitStaAddr[0], |
| 2271 | sizeof(tSirMacAddr)) ; |
| 2272 | /* TODO, do more validation */ |
| 2273 | |
| 2274 | /* see if discovery is already in progress */ |
| 2275 | peerInfo = limTdlsFindDisPeer(pMac, peerMac) ; |
| 2276 | |
| 2277 | if(NULL == peerInfo) |
| 2278 | { |
| 2279 | /* |
| 2280 | * we are allocating peer info for individual peers found in TDLS |
| 2281 | * discovery, we need to keep adding TDLS peers till we have timed |
| 2282 | * out. We are freeing this memory at the time we are sending this |
| 2283 | * collected peer info to SME. |
| 2284 | */ |
| 2285 | status = palAllocateMemory(pMac->hHdd, (void **)&tdlsDisResult, |
| 2286 | sizeof(tLimDisResultList)) ; |
| 2287 | |
| 2288 | if(status != eHAL_STATUS_SUCCESS) |
| 2289 | { |
| 2290 | limLog(pMac, LOGP, FL("alloc fail for TDLS discovery \ |
| 2291 | reponse info\n")) ; |
| 2292 | return eSIR_FAILURE ; |
| 2293 | } |
| 2294 | |
| 2295 | |
| 2296 | peerInfo = &tdlsDisResult->tdlsDisPeerInfo ; |
| 2297 | peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ; |
| 2298 | peerInfo->dialog = tdlsDisReq.DialogToken.token ; |
| 2299 | |
| 2300 | peerInfo->sessionId = psessionEntry->peSessionId; |
| 2301 | |
| 2302 | /* Populate peer info of tdls discovery result */ |
| 2303 | status = palCopyMemory(pMac->hHdd, peerInfo->peerMac, peerMac, |
| 2304 | sizeof(tSirMacAddr)) ; |
| 2305 | |
| 2306 | /* |
| 2307 | * Now, as per D13, there will not be any Supp rates, ext Supp rates |
| 2308 | * info in Discovery request frames, so we are populating this info |
| 2309 | * locally to pass it to ADD STA. |
| 2310 | */ |
| 2311 | do |
| 2312 | { |
| 2313 | tDot11fIESuppRates suppRates = {0} ; |
| 2314 | tDot11fIEExtSuppRates extSuppRates = {0} ; |
| 2315 | tANI_U16 caps = 0 ; |
| 2316 | tDot11fFfCapabilities capsInfo = {0} ; |
| 2317 | tDot11fIEHTCaps HTCaps = {0} ; |
| 2318 | /* populate supported rate IE */ |
| 2319 | PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 2320 | &suppRates, psessionEntry ); |
| 2321 | ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates, |
| 2322 | &suppRates); |
| 2323 | /* Populate extended supported rates */ |
| 2324 | PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, |
| 2325 | &extSuppRates, psessionEntry ); |
| 2326 | |
| 2327 | peerInfo->ExtRatesPresent = 1; |
| 2328 | ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates, |
| 2329 | &extSuppRates); |
| 2330 | |
| 2331 | if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS) |
| 2332 | { |
| 2333 | /* |
| 2334 | * Could not get Capabilities value |
| 2335 | * from CFG. Log error. |
| 2336 | */ |
| 2337 | limLog(pMac, LOGP, |
| 2338 | FL("could not retrieve Capabilities value\n")); |
| 2339 | } |
| 2340 | swapBitField16(caps, ( tANI_U16* )&capsInfo ); |
| 2341 | /* update Caps Info */ |
| 2342 | tdlsUpdateCapInfo(&peerInfo->capabilityInfo , &capsInfo) ; |
| 2343 | |
| 2344 | PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps ); |
| 2345 | limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ; |
| 2346 | |
| 2347 | } while (0) ; |
| 2348 | |
| 2349 | /* now add this new found discovery node into tdls discovery list */ |
| 2350 | tdlsDisResult->next = *disResultList ; |
| 2351 | *disResultList = tdlsDisResult ; |
| 2352 | pMac->lim.gLimTdlsDisStaCount++ ; |
| 2353 | |
| 2354 | /* See if for this peer already entry in setup Link */ |
| 2355 | limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ; |
| 2356 | |
| 2357 | /* |
| 2358 | * if there is no entry for this peer in setup list, we need to |
| 2359 | * do add sta for this peer to transmit discovery rsp. |
| 2360 | */ |
| 2361 | if(NULL == setupPeer) |
| 2362 | { |
| 2363 | /* To start with, send add STA request to HAL */ |
| 2364 | pMac->lim.gLimAddStaTdls = true ; |
| 2365 | peerInfo->delStaNeeded = true ; |
| 2366 | |
| 2367 | if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac, |
| 2368 | peerInfo, psessionEntry)) |
| 2369 | { |
| 2370 | VOS_ASSERT(0) ; |
| 2371 | limLog(pMac, LOGE, "Add STA for dis response is failed \n") ; |
| 2372 | return eSIR_FAILURE ; |
| 2373 | } |
| 2374 | } /* use setup link sta ID for discovery rsp */ |
| 2375 | else |
| 2376 | { |
| 2377 | peerInfo->delStaNeeded = false ; |
| 2378 | limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ; |
| 2379 | peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ; |
| 2380 | } |
| 2381 | |
| 2382 | } |
| 2383 | else |
| 2384 | { |
| 2385 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2386 | ("discovery procedure in progress for this peer\n")) ; |
| 2387 | } |
| 2388 | |
| 2389 | return eSIR_SUCCESS ; |
| 2390 | } |
| 2391 | |
| 2392 | /* Process TDLS setup Request Frame */ |
| 2393 | |
| 2394 | static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac, |
| 2395 | tANI_U8 *pBody, tANI_U32 frmLen) |
| 2396 | { |
| 2397 | |
| 2398 | tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ; |
| 2399 | tANI_U32 status = 0 ; |
| 2400 | tpPESession psessionEntry = NULL ; |
| 2401 | tANI_U8 sessionId = 0 ; |
| 2402 | tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ; |
| 2403 | tANI_U8 previousState = TDLS_LINK_IDLE_STATE ; |
| 2404 | /* create node for Link setup */ |
| 2405 | tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ; |
| 2406 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 2407 | tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ; |
| 2408 | |
| 2409 | status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ; |
| 2410 | |
| 2411 | if ( DOT11F_FAILED( status ) ) |
| 2412 | { |
| 2413 | limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \ |
| 2414 | frame (0x%08x, %d bytes):\n"),status, frmLen); |
| 2415 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2416 | return eSIR_FAILURE; |
| 2417 | } |
| 2418 | else if ( DOT11F_WARNED( status ) ) |
| 2419 | { |
| 2420 | limLog( pMac, LOGW, FL("There were warnings while unpacking an\ |
| 2421 | TDLS setup Request frame (0x%08x," "%d bytes):\n"), |
| 2422 | status, pBody ); |
| 2423 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2424 | } |
| 2425 | /* |
| 2426 | * find session entry using BSSID in link identifier, not using MAC |
| 2427 | * header beacuse, there is cases in TDLS, there may be BSSID will not |
| 2428 | * be present in header |
| 2429 | */ |
| 2430 | psessionEntry = peFindSessionByBssid(pMac, |
| 2431 | &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ; |
| 2432 | if(NULL == psessionEntry) |
| 2433 | { |
| 2434 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \ |
| 2435 | ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \ |
| 2436 | tdlsSetupReq.LinkIdentifier.bssid[0], |
| 2437 | tdlsSetupReq.LinkIdentifier.bssid[1], |
| 2438 | tdlsSetupReq.LinkIdentifier.bssid[2], |
| 2439 | tdlsSetupReq.LinkIdentifier.bssid[3], |
| 2440 | tdlsSetupReq.LinkIdentifier.bssid[4], |
| 2441 | tdlsSetupReq.LinkIdentifier.bssid[5]) ; |
| 2442 | |
| 2443 | //VOS_ASSERT(0) ; |
| 2444 | return eSIR_FAILURE ; |
| 2445 | } |
| 2446 | /* TODO: we don;t need this check now, varify BSSID */ |
| 2447 | status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, |
| 2448 | &tdlsSetupReq.LinkIdentifier.bssid[0], |
| 2449 | sizeof(tSirMacAddr)) ; |
| 2450 | |
| 2451 | if(!status) |
| 2452 | { |
| 2453 | limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter\n")) ; |
| 2454 | |
| 2455 | limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token , psessionEntry, |
| 2456 | TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ; |
| 2457 | return eSIR_FAILURE ; |
| 2458 | } |
| 2459 | |
| 2460 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 2461 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ) |
| 2462 | { |
| 2463 | /* simply ignore this setup request packet */ |
| 2464 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2465 | ("TDLS negative running: ignore TDLS Setup Req packet\n")); |
| 2466 | return eSIR_SUCCESS ; |
| 2467 | } |
| 2468 | if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ) |
| 2469 | { |
| 2470 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2471 | ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req\n")); |
| 2472 | /* format TDLS discovery request frame and transmit it */ |
| 2473 | limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry, |
| 2474 | NULL, 0) ; |
| 2475 | } |
| 2476 | #endif |
| 2477 | /* TODO, do more validation */ |
| 2478 | |
| 2479 | if(!limTdlsFindLinkPeer(pMac, |
| 2480 | &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], |
| 2481 | &tmpSetupPeer)) |
| 2482 | { |
| 2483 | tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ; |
| 2484 | |
| 2485 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2486 | ("Link is already setup with this peer\n" )) ; |
| 2487 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2488 | ("state = %d\n"), tmpSetupPeer->tdls_link_state) ; |
| 2489 | //return eSIR_FAILURE ; |
| 2490 | |
| 2491 | if(tmpSetupPeer == NULL) |
| 2492 | { |
| 2493 | VOS_ASSERT(0) ; |
| 2494 | return eSIR_FAILURE ; |
| 2495 | |
| 2496 | } |
| 2497 | switch(tmpSetupPeer->tdls_link_state) |
| 2498 | { |
| 2499 | |
| 2500 | case TDLS_LINK_SETUP_START_STATE: |
| 2501 | { |
| 2502 | v_SINT_t macCompare = 0 ; |
| 2503 | macCompare= vos_mem_compare2(tmpSetupPeer->peerMac, |
| 2504 | psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ; |
| 2505 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2506 | ("MAC comparison Rslt = %d\n"), macCompare ) ; |
| 2507 | if(0 > macCompare) |
| 2508 | { |
| 2509 | /* |
| 2510 | * Delete our Setup Request/Peer info and honour Peer |
| 2511 | * Setup Request, go ahead and respond for this |
| 2512 | */ |
| 2513 | /* Deactivate the timer */ |
| 2514 | tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ; |
| 2515 | #ifdef FEATURE_WLAN_TDLS_NEGATIVE |
| 2516 | if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ) |
| 2517 | != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ) |
| 2518 | #endif |
| 2519 | limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, |
| 2520 | tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP); |
| 2521 | |
| 2522 | limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ; |
| 2523 | tdlsStateStatus = TDLS_LINK_IDLE_STATE ; |
| 2524 | } |
| 2525 | else if(0 < macCompare) |
| 2526 | { |
| 2527 | /* |
| 2528 | * Go ahead with current setup as peer is going to |
| 2529 | * respond for setup request |
| 2530 | */ |
| 2531 | tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ; |
| 2532 | } |
| 2533 | else |
| 2534 | { |
| 2535 | /* same MAC, not possible */ |
| 2536 | VOS_ASSERT(0) ; |
| 2537 | } |
| 2538 | |
| 2539 | break ; |
| 2540 | } |
| 2541 | #if 1 |
| 2542 | case TDLS_LINK_SETUP_DONE_STATE: |
| 2543 | { |
| 2544 | tpDphHashNode pStaDs = NULL ; |
| 2545 | |
| 2546 | previousState = TDLS_LINK_SETUP_WAIT_STATE ; |
| 2547 | currentState = TDLS_LINK_TEARDOWN_START_STATE ; |
| 2548 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2549 | ("link Setup Done state " )) ; |
| 2550 | tmpSetupPeer->tdls_prev_link_state = previousState ; |
| 2551 | tmpSetupPeer->tdls_link_state = currentState ; |
| 2552 | setupPeer = tmpSetupPeer ; |
| 2553 | #if 0 |
| 2554 | /* Send Teardown to this Peer and Initiate new TDLS Setup */ |
| 2555 | limSendTdlsTeardownFrame(pMac, |
| 2556 | &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], |
| 2557 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ; |
| 2558 | #else |
| 2559 | |
| 2560 | /* tdls_hklee: send message to HAL before it is deleted, cause */ |
| 2561 | limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ; |
| 2562 | |
| 2563 | /* send del STA to remove context for this TDLS STA */ |
| 2564 | pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ; |
| 2565 | |
| 2566 | /* now send indication to SME-->HDD->TL to remove STA from TL */ |
| 2567 | |
| 2568 | if(pStaDs) |
| 2569 | { |
| 2570 | limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId, |
| 2571 | pStaDs, eSIR_SUCCESS) ; |
| 2572 | |
| 2573 | /* send Teardown Ind to SME */ |
| 2574 | limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac, |
| 2575 | eWNI_SME_TDLS_TEARDOWN_IND) ; |
| 2576 | /* remove node from setup list */ |
| 2577 | limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ; |
| 2578 | } |
| 2579 | #endif |
| 2580 | //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE; |
| 2581 | tdlsStateStatus = TDLS_LINK_IDLE_STATE ; |
| 2582 | break ; |
| 2583 | |
| 2584 | } |
| 2585 | default: |
| 2586 | { |
| 2587 | VOS_ASSERT(0) ; |
| 2588 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2589 | ("link Setup is Recieved in unknown state\n" )) ; |
| 2590 | break ; |
| 2591 | } |
| 2592 | #endif |
| 2593 | } |
| 2594 | if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE) |
| 2595 | return eSIR_FAILURE ; |
| 2596 | } |
| 2597 | |
| 2598 | if(currentState != TDLS_LINK_TEARDOWN_START_STATE) |
| 2599 | { |
| 2600 | /* |
| 2601 | * Now we are sure to send discovery response frame to TDLS discovery |
| 2602 | * initiator, we don't care, if this request is unicast ro broadcast, |
| 2603 | * we simply, send discovery response frame on direct link. |
| 2604 | */ |
| 2605 | if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, |
| 2606 | (void **) &setupPeer, sizeof( tLimTdlsLinkSetupPeer ))) |
| 2607 | { |
| 2608 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2609 | ( "Unable to allocate memory during ADD_STA\n" )); |
| 2610 | return eSIR_MEM_ALLOC_FAILED; |
| 2611 | } |
| 2612 | |
| 2613 | setupPeer->dialog = tdlsSetupReq.DialogToken.token ; |
| 2614 | //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ; |
| 2615 | //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ; |
| 2616 | setupPeer->tdls_prev_link_state = previousState ; |
| 2617 | setupPeer->tdls_link_state = currentState ; |
| 2618 | /* TDLS_sessionize: remember sessionId for future */ |
| 2619 | setupPeer->tdls_sessionId = psessionEntry->peSessionId; |
| 2620 | setupPeer->tdls_bIsResponder = 0; |
| 2621 | |
| 2622 | palCopyMemory(pMac->hHdd, setupPeer->peerMac, |
| 2623 | &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], |
| 2624 | sizeof(tSirMacAddr)) ; |
| 2625 | |
| 2626 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2627 | ("Setup REQ MAC = %02x,%02x, %02x, %02x, %02x, %02x\n"), |
| 2628 | setupPeer->peerMac[0], |
| 2629 | setupPeer->peerMac[1], |
| 2630 | setupPeer->peerMac[2], |
| 2631 | setupPeer->peerMac[3], |
| 2632 | setupPeer->peerMac[4], |
| 2633 | setupPeer->peerMac[5] ) ; |
| 2634 | |
| 2635 | limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ; |
| 2636 | pMac->lim.gLimAddStaTdls = true ; |
| 2637 | |
| 2638 | /* To start with, send add STA request to HAL */ |
| 2639 | if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac, |
| 2640 | setupPeer, psessionEntry)) |
| 2641 | { |
| 2642 | VOS_ASSERT(0) ; |
| 2643 | palFreeMemory(pMac->hHdd, (void **) &setupPeer) ; |
| 2644 | return eSIR_FAILURE ; |
| 2645 | } |
| 2646 | |
| 2647 | limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, |
| 2648 | tdlsSetupReq.DialogToken.token , psessionEntry, |
| 2649 | TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ; |
| 2650 | |
| 2651 | limStartTdlsTimer(pMac, psessionEntry->peSessionId, |
| 2652 | &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer, |
| 2653 | (tANI_U32)setupPeer->peerMac, |
| 2654 | WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT, |
| 2655 | SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ; |
| 2656 | |
| 2657 | /* update setup peer list */ |
| 2658 | setupPeer->next = linkSetupInfo->tdlsLinkSetupList ; |
| 2659 | linkSetupInfo->tdlsLinkSetupList = setupPeer ; |
| 2660 | } |
| 2661 | else |
| 2662 | { |
| 2663 | setupPeer->dialog = tdlsSetupReq.DialogToken.token ; |
| 2664 | //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ; |
| 2665 | //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ; |
| 2666 | setupPeer->tdls_prev_link_state = previousState ; |
| 2667 | setupPeer->tdls_link_state = currentState ; |
| 2668 | /* TDLS_sessionize: remember sessionId for future */ |
| 2669 | setupPeer->tdls_sessionId = psessionEntry->peSessionId; |
| 2670 | setupPeer->tdls_bIsResponder = 0; |
| 2671 | |
| 2672 | palCopyMemory(pMac->hHdd, setupPeer->peerMac, |
| 2673 | &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], |
| 2674 | sizeof(tSirMacAddr)) ; |
| 2675 | |
| 2676 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2677 | ("Setup REQ MAC = %02x,%02x, %02x, %02x, %02x, %02x\n"), |
| 2678 | setupPeer->peerMac[0], |
| 2679 | setupPeer->peerMac[1], |
| 2680 | setupPeer->peerMac[2], |
| 2681 | setupPeer->peerMac[3], |
| 2682 | setupPeer->peerMac[4], |
| 2683 | setupPeer->peerMac[5] ) ; |
| 2684 | |
| 2685 | limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ; |
| 2686 | limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, |
| 2687 | tdlsSetupReq.DialogToken.token , psessionEntry, |
| 2688 | TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ; |
| 2689 | |
| 2690 | limStartTdlsTimer(pMac, psessionEntry->peSessionId, |
| 2691 | &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer, |
| 2692 | (tANI_U32)setupPeer->peerMac, |
| 2693 | WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT, |
| 2694 | SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ; |
| 2695 | } |
| 2696 | |
| 2697 | |
| 2698 | return eSIR_SUCCESS ; |
| 2699 | |
| 2700 | } |
| 2701 | |
| 2702 | /* |
| 2703 | * TDLS discovery request frame received from TDLS peer STA.. |
| 2704 | */ |
| 2705 | static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac, |
| 2706 | tANI_U8 *pBody, tANI_U32 frmLen ) |
| 2707 | { |
| 2708 | tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ; |
| 2709 | tANI_U32 status = 0 ; |
| 2710 | tSirMacAddr peerMac = {0} ; |
| 2711 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 2712 | tpPESession psessionEntry = NULL ; |
| 2713 | tANI_U8 sessionId = 0 ; |
| 2714 | |
| 2715 | status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ; |
| 2716 | |
| 2717 | if ( DOT11F_FAILED( status ) ) |
| 2718 | { |
| 2719 | limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \ |
| 2720 | frame (0x%08x, %d bytes):\n"),status, frmLen); |
| 2721 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2722 | return eSIR_FAILURE; |
| 2723 | } |
| 2724 | else if ( DOT11F_WARNED( status ) ) |
| 2725 | { |
| 2726 | limLog( pMac, LOGW, FL("There were warnings while unpacking an\ |
| 2727 | TDLS discovery Request frame (0x%08x," "%d bytes):\n"), |
| 2728 | status, frmLen ); |
| 2729 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2730 | } |
| 2731 | |
| 2732 | /* |
| 2733 | * find session entry using BSSID in link identifier, not using MAC |
| 2734 | * header beacuse, there is cases in TDLS, there may be BSSID will not |
| 2735 | * be present in header |
| 2736 | */ |
| 2737 | psessionEntry = peFindSessionByBssid(pMac, |
| 2738 | &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ; |
| 2739 | if(NULL == psessionEntry) |
| 2740 | { |
| 2741 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \ |
| 2742 | ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \ |
| 2743 | tdlsSetupRsp.LinkIdentifier.bssid[0], |
| 2744 | tdlsSetupRsp.LinkIdentifier.bssid[1], |
| 2745 | tdlsSetupRsp.LinkIdentifier.bssid[2], |
| 2746 | tdlsSetupRsp.LinkIdentifier.bssid[3], |
| 2747 | tdlsSetupRsp.LinkIdentifier.bssid[4], |
| 2748 | tdlsSetupRsp.LinkIdentifier.bssid[5]) ; |
| 2749 | |
| 2750 | //VOS_ASSERT(0) ; |
| 2751 | return eSIR_FAILURE; |
| 2752 | } |
| 2753 | |
| 2754 | /* varify BSSID */ |
| 2755 | status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, |
| 2756 | &tdlsSetupRsp.LinkIdentifier.bssid[0], |
| 2757 | sizeof(tSirMacAddr)) ; |
| 2758 | |
| 2759 | if(!status) |
| 2760 | { |
| 2761 | limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter\n")) ; |
| 2762 | |
| 2763 | VOS_ASSERT(0) ; |
| 2764 | return eSIR_FAILURE ; |
| 2765 | } |
| 2766 | palCopyMemory(pMac->hHdd, peerMac, |
| 2767 | &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0], |
| 2768 | sizeof(tSirMacAddr)) ; |
| 2769 | |
| 2770 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2771 | ("TDLS setup RSP peer = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 2772 | peerMac[0], |
| 2773 | peerMac[1], |
| 2774 | peerMac[2], |
| 2775 | peerMac[3], |
| 2776 | peerMac[4], |
| 2777 | peerMac[5]) ; |
| 2778 | limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ; |
| 2779 | |
| 2780 | if(NULL == setupPeer) |
| 2781 | { |
| 2782 | limLog( pMac, LOGE, FL(" unknown setup Response frame \ |
| 2783 | other BSS\n")) ; |
| 2784 | return eSIR_FAILURE ; |
| 2785 | } |
| 2786 | |
| 2787 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2788 | ("deactivating Setup RSP timer\n")) ; |
| 2789 | |
| 2790 | /* Deactivate the timer */ |
| 2791 | tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ; |
| 2792 | |
| 2793 | /* |
| 2794 | * TDLS Setup RSP is recieved with Failure, Delete this STA entry |
| 2795 | * don't respond with TDLS CNF frame. |
| 2796 | */ |
| 2797 | if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status) |
| 2798 | { |
| 2799 | limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ; |
| 2800 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2801 | ("setup RSP with Failure Code\n")) ; |
| 2802 | return eSIR_FAILURE ; |
| 2803 | } |
| 2804 | |
| 2805 | /* update Link Info */ |
| 2806 | limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ; |
| 2807 | |
| 2808 | /* TODO, do more validation */ |
| 2809 | |
| 2810 | |
| 2811 | /* |
| 2812 | * Now we are sure to send link setup CNF frame to TDLS link setup |
| 2813 | * reponded, now we will create dph hash entry and send add STA to HAL |
| 2814 | */ |
| 2815 | |
| 2816 | pMac->lim.gLimAddStaTdls = true ; |
| 2817 | if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac, |
| 2818 | setupPeer, psessionEntry)) |
| 2819 | { |
| 2820 | /* through error */ |
| 2821 | VOS_ASSERT(0) ; |
| 2822 | return eSIR_FAILURE ; |
| 2823 | } |
| 2824 | /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */ |
| 2825 | |
| 2826 | |
| 2827 | /* send TDLS confim frame to TDLS Peer STA */ |
| 2828 | limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, psessionEntry, NULL, 0) ; |
| 2829 | |
| 2830 | /* |
| 2831 | * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and |
| 2832 | * wait for Setup CNF transmission on air, once we receive tx complete |
| 2833 | * message, we will change the peer state and send message to SME |
| 2834 | * callback.. |
| 2835 | */ |
| 2836 | (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ; |
| 2837 | (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ; |
| 2838 | |
| 2839 | return eSIR_SUCCESS ; |
| 2840 | } |
| 2841 | /* |
| 2842 | * TDLS setup CNF frame processing .. |
| 2843 | */ |
| 2844 | |
| 2845 | static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac, |
| 2846 | tANI_U8 *pBody, tANI_U32 frmLen) |
| 2847 | { |
| 2848 | tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ; |
| 2849 | tANI_U32 status = 0 ; |
| 2850 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 2851 | tpPESession psessionEntry = NULL ; |
| 2852 | tANI_U8 sessionId = 0 ; |
| 2853 | |
| 2854 | status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ; |
| 2855 | |
| 2856 | if ( DOT11F_FAILED( status ) ) |
| 2857 | { |
| 2858 | limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \ |
| 2859 | frame (0x%08x, %d bytes):\n"),status, frmLen); |
| 2860 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2861 | return eSIR_FAILURE; |
| 2862 | } |
| 2863 | else if ( DOT11F_WARNED( status ) ) |
| 2864 | { |
| 2865 | limLog( pMac, LOGW, FL("There were warnings while unpacking an\ |
| 2866 | TDLS discovery Response frame (0x%08x," "%d bytes):\n"), |
| 2867 | status, frmLen ); |
| 2868 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2869 | } |
| 2870 | /* |
| 2871 | * find session entry using BSSID in link identifier, not using MAC |
| 2872 | * header beacuse, there is cases in TDLS, there may be BSSID will not |
| 2873 | * be present in header |
| 2874 | */ |
| 2875 | psessionEntry = peFindSessionByBssid(pMac, |
| 2876 | &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ; |
| 2877 | if(NULL == psessionEntry) |
| 2878 | { |
| 2879 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \ |
| 2880 | ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \ |
| 2881 | tdlsSetupCnf.LinkIdentifier.bssid[0], |
| 2882 | tdlsSetupCnf.LinkIdentifier.bssid[1], |
| 2883 | tdlsSetupCnf.LinkIdentifier.bssid[2], |
| 2884 | tdlsSetupCnf.LinkIdentifier.bssid[3], |
| 2885 | tdlsSetupCnf.LinkIdentifier.bssid[4], |
| 2886 | tdlsSetupCnf.LinkIdentifier.bssid[5]) ; |
| 2887 | |
| 2888 | //VOS_ASSERT(0) ; |
| 2889 | return eSIR_FAILURE; |
| 2890 | } |
| 2891 | |
| 2892 | /* varify BSSID */ |
| 2893 | status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, |
| 2894 | &tdlsSetupCnf.LinkIdentifier.bssid[0], |
| 2895 | sizeof(tSirMacAddr)) ; |
| 2896 | |
| 2897 | if(!status) |
| 2898 | { |
| 2899 | limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter\n")) ; |
| 2900 | |
| 2901 | VOS_ASSERT(0) ; |
| 2902 | return eSIR_FAILURE ; |
| 2903 | } |
| 2904 | /* TODO, do more validation */ |
| 2905 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2906 | ("setup Cnf peer MAc = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 2907 | tdlsSetupCnf.LinkIdentifier.InitStaAddr[0], |
| 2908 | tdlsSetupCnf.LinkIdentifier.InitStaAddr[1], |
| 2909 | tdlsSetupCnf.LinkIdentifier.InitStaAddr[2], |
| 2910 | tdlsSetupCnf.LinkIdentifier.InitStaAddr[3], |
| 2911 | tdlsSetupCnf.LinkIdentifier.InitStaAddr[4], |
| 2912 | tdlsSetupCnf.LinkIdentifier.InitStaAddr[5] |
| 2913 | ) ; |
| 2914 | |
| 2915 | limTdlsFindLinkPeer(pMac, |
| 2916 | &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0], |
| 2917 | &setupPeer) ; |
| 2918 | |
| 2919 | if(NULL == setupPeer) |
| 2920 | { |
| 2921 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2922 | (" unknown setup CNF frame\n")) ; |
| 2923 | VOS_ASSERT(0) ; |
| 2924 | return eSIR_FAILURE ; |
| 2925 | } |
| 2926 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 2927 | ("setup CNF peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 2928 | (setupPeer)->peerMac[0], |
| 2929 | (setupPeer)->peerMac[1], |
| 2930 | (setupPeer)->peerMac[2], |
| 2931 | (setupPeer)->peerMac[3], |
| 2932 | (setupPeer)->peerMac[4], |
| 2933 | (setupPeer)->peerMac[5]) ; |
| 2934 | /*T match dialog token, before proceeding further */ |
| 2935 | if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token) |
| 2936 | { |
| 2937 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 2938 | ("setup CNF frame not matching with setup RSP\n")) ; |
| 2939 | VOS_ASSERT(0) ; |
| 2940 | return eSIR_FAILURE ; |
| 2941 | } |
| 2942 | |
| 2943 | /* |
| 2944 | * Now we are sure that, this set CNF is for us, now stop |
| 2945 | * the running timer.. |
| 2946 | */ |
| 2947 | tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ; |
| 2948 | |
| 2949 | /* change TDLS peer State */ |
| 2950 | (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ; |
| 2951 | (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ; |
| 2952 | |
| 2953 | /* send indication to SME that, new link is setup */ |
| 2954 | limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ; |
| 2955 | |
| 2956 | /* tdls_hklee: prepare PTI template and send it to HAL */ |
| 2957 | limTdlsLinkEstablish(pMac, (setupPeer)->peerMac); |
| 2958 | |
| 2959 | return eSIR_SUCCESS ; |
| 2960 | |
| 2961 | } |
| 2962 | |
| 2963 | /* |
| 2964 | * TDLS discovery response frame processing .. |
| 2965 | */ |
| 2966 | |
| 2967 | static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac, |
| 2968 | tANI_U8 *pBody, tANI_U32 frmLen, |
| 2969 | tANI_S8 rssi, tpPESession psessionEntry) |
| 2970 | { |
| 2971 | tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ; |
| 2972 | tANI_U32 status = 0 ; |
| 2973 | tLimDisResultList *tdlsDisResult = NULL ; |
| 2974 | tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ; |
| 2975 | tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ; |
| 2976 | |
| 2977 | status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ; |
| 2978 | |
| 2979 | if ( DOT11F_FAILED( status ) ) |
| 2980 | { |
| 2981 | limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \ |
| 2982 | frame (0x%08x, %d bytes):\n"),status, frmLen); |
| 2983 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 2984 | return eSIR_FAILURE; |
| 2985 | } |
| 2986 | else if ( DOT11F_WARNED( status ) ) |
| 2987 | { |
| 2988 | limLog( pMac, LOGW, FL("There were warnings while unpacking an\ |
| 2989 | TDLS discovery Response frame (0x%08x," "%d bytes):\n"), |
| 2990 | status, frmLen ); |
| 2991 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);) |
| 2992 | } |
| 2993 | /*TODO: match dialog token, before proceeding further */ |
| 2994 | |
| 2995 | /* varify BSSID */ |
| 2996 | status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, |
| 2997 | &tdlsDisRsp.LinkIdentifier.bssid[0], |
| 2998 | sizeof(tSirMacAddr)) ; |
| 2999 | |
| 3000 | if(!status) |
| 3001 | { |
| 3002 | limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS\n")) ; |
| 3003 | return eSIR_FAILURE ; |
| 3004 | } |
| 3005 | /* TODO, do more validation */ |
| 3006 | |
| 3007 | if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog) |
| 3008 | { |
| 3009 | limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame\n")) ; |
| 3010 | return eSIR_FAILURE ; |
| 3011 | } |
| 3012 | |
| 3013 | pMac->lim.gLimTdlsDisStaCount++ ; |
| 3014 | |
| 3015 | /* |
| 3016 | * we are allocating peer info for individual peers found in TDLS |
| 3017 | * discovery, we need to keep adding TDLS peers till we have timed |
| 3018 | * out. We are freeing this memory at the time we are sending this |
| 3019 | * collected peer info to SME. |
| 3020 | */ |
| 3021 | status = palAllocateMemory(pMac->hHdd, (void **)&tdlsDisResult, |
| 3022 | sizeof(tLimDisResultList)) ; |
| 3023 | |
| 3024 | if(status != eHAL_STATUS_SUCCESS) |
| 3025 | { |
| 3026 | limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info\n")) ; |
| 3027 | return eSIR_FAILURE ; |
| 3028 | } |
| 3029 | |
| 3030 | do |
| 3031 | { |
| 3032 | tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ; |
| 3033 | |
| 3034 | /* Populate peer info of tdls discovery result */ |
| 3035 | peerInfo->sessionId = psessionEntry->peSessionId; |
| 3036 | /* |
| 3037 | * When we receive DIS RSP from peer MAC, |
| 3038 | * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET |
| 3039 | * will carry our MAC. |
| 3040 | */ |
| 3041 | status = palCopyMemory(pMac->hHdd, peerInfo->peerMac, |
| 3042 | &tdlsDisRsp.LinkIdentifier.RespStaAddr[0], |
| 3043 | sizeof(tSirMacAddr)) ; |
| 3044 | |
| 3045 | /* update RSSI for this TDLS peer STA */ |
| 3046 | peerInfo->tdlsPeerRssi = rssi ; |
| 3047 | |
| 3048 | /* update Caps Info */ |
| 3049 | tdlsUpdateCapInfo(&peerInfo->capabilityInfo , |
| 3050 | &tdlsDisRsp.Capabilities) ; |
| 3051 | |
| 3052 | /* update Supp rates */ |
| 3053 | if(tdlsDisRsp.SuppRates.present) |
| 3054 | { |
| 3055 | ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates, |
| 3056 | &tdlsDisRsp.SuppRates ); |
| 3057 | } |
| 3058 | |
| 3059 | /* update EXT supp rates */ |
| 3060 | if(tdlsDisRsp.ExtSuppRates.present) |
| 3061 | { |
| 3062 | peerInfo->ExtRatesPresent = 1; |
| 3063 | ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates, |
| 3064 | &tdlsDisRsp.ExtSuppRates ); |
| 3065 | } |
| 3066 | /* update HT caps */ |
| 3067 | if (tdlsDisRsp.HTCaps.present) |
| 3068 | { |
| 3069 | palCopyMemory( pMac, &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps, |
| 3070 | sizeof( tDot11fIEHTCaps ) ); |
| 3071 | } |
| 3072 | /* update EXT caps */ |
| 3073 | if (tdlsDisRsp.ExtCap.present) |
| 3074 | { |
| 3075 | //palCopyMemory( pMac, &peerInfo->tdlsPeerExtenCaps, |
| 3076 | // &tdlsDisRsp.ExtCap, |
| 3077 | // sizeof( tDot11fIEExtCap ) ); |
| 3078 | } |
| 3079 | } while(0) ; |
| 3080 | |
| 3081 | /* now add this new found discovery node into tdls discovery list */ |
| 3082 | tdlsDisResult->next = *disResultList ; |
| 3083 | *disResultList = tdlsDisResult ; |
| 3084 | |
| 3085 | return eSIR_SUCCESS ; |
| 3086 | } |
| 3087 | |
| 3088 | /* |
| 3089 | * Process TDLS Teardown request frame from TDLS peer STA |
| 3090 | */ |
| 3091 | static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac, |
| 3092 | tANI_U8 *pBody, tANI_U32 frmLen ) |
| 3093 | { |
| 3094 | tDot11fTDLSTeardown tdlsTeardown = {{0}} ; |
| 3095 | tANI_U32 status = 0 ; |
| 3096 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 3097 | tpPESession psessionEntry = NULL ; |
| 3098 | tANI_U8 sessionId = 0 ; |
| 3099 | |
| 3100 | status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ; |
| 3101 | |
| 3102 | if ( DOT11F_FAILED( status ) ) |
| 3103 | { |
| 3104 | limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \ |
| 3105 | frame (0x%08x, %d bytes):\n"),status, frmLen); |
| 3106 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 3107 | return eSIR_FAILURE; |
| 3108 | } |
| 3109 | else if ( DOT11F_WARNED( status ) ) |
| 3110 | { |
| 3111 | limLog( pMac, LOGW, FL("There were warnings while unpacking an\ |
| 3112 | TDLS discovery Response frame (0x%08x," "%d bytes):\n"), |
| 3113 | status, frmLen ); |
| 3114 | PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);) |
| 3115 | } |
| 3116 | |
| 3117 | /* |
| 3118 | * find session entry using BSSID in link identifier, not using MAC |
| 3119 | * header beacuse, there is cases in TDLS, there may be BSSID will not |
| 3120 | * be present in header |
| 3121 | */ |
| 3122 | psessionEntry = peFindSessionByBssid(pMac, |
| 3123 | &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ; |
| 3124 | if(NULL == psessionEntry) |
| 3125 | { |
| 3126 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \ |
| 3127 | ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \ |
| 3128 | tdlsTeardown.LinkIdentifier.bssid[0], |
| 3129 | tdlsTeardown.LinkIdentifier.bssid[1], |
| 3130 | tdlsTeardown.LinkIdentifier.bssid[2], |
| 3131 | tdlsTeardown.LinkIdentifier.bssid[3], |
| 3132 | tdlsTeardown.LinkIdentifier.bssid[4], |
| 3133 | tdlsTeardown.LinkIdentifier.bssid[5]) ; |
| 3134 | |
| 3135 | //VOS_ASSERT(0) ; |
| 3136 | return eSIR_FAILURE; |
| 3137 | } |
| 3138 | |
| 3139 | /* varify BSSID */ |
| 3140 | status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, |
| 3141 | &tdlsTeardown.LinkIdentifier.bssid[0], |
| 3142 | sizeof(tSirMacAddr)) ; |
| 3143 | |
| 3144 | |
| 3145 | if(!status) |
| 3146 | { |
| 3147 | limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter\n")) ; |
| 3148 | VOS_ASSERT(0) ; |
| 3149 | return eSIR_FAILURE ; |
| 3150 | } |
| 3151 | |
| 3152 | limTdlsFindLinkPeer(pMac, |
| 3153 | &tdlsTeardown.LinkIdentifier.InitStaAddr[0], |
| 3154 | &setupPeer) ; |
| 3155 | |
| 3156 | if(NULL == setupPeer) |
| 3157 | { |
| 3158 | //ignore |
| 3159 | //VOS_ASSERT(0) ; |
| 3160 | limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored\n") ); |
| 3161 | |
| 3162 | return eSIR_FAILURE ; |
| 3163 | } |
| 3164 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3165 | ("teardown for peer %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 3166 | (setupPeer)->peerMac[0], |
| 3167 | (setupPeer)->peerMac[1], |
| 3168 | (setupPeer)->peerMac[2], |
| 3169 | (setupPeer)->peerMac[3], |
| 3170 | (setupPeer)->peerMac[4], |
| 3171 | (setupPeer)->peerMac[5]) ; |
| 3172 | |
| 3173 | switch(tdlsTeardown.Reason.code) |
| 3174 | { |
| 3175 | case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON: |
| 3176 | { |
| 3177 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3178 | ("teardown with unspecified reason\n")) ; |
| 3179 | break ; |
| 3180 | } |
| 3181 | case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE: |
| 3182 | { |
| 3183 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3184 | (" Teardown from AP, TDLS peer unreachable\n")) ; |
| 3185 | break ; |
| 3186 | } |
| 3187 | default: |
| 3188 | { |
| 3189 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3190 | (" unknown teardown\n")) ; |
| 3191 | break ; |
| 3192 | } |
| 3193 | } |
| 3194 | |
| 3195 | /* change TDLS peer State */ |
| 3196 | (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ; |
| 3197 | (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ; |
| 3198 | |
| 3199 | do |
| 3200 | { |
| 3201 | tpDphHashNode pStaDs = NULL ; |
| 3202 | |
| 3203 | /* tdls_hklee: send message to HAL before it is deleted, cause */ |
| 3204 | limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ; |
| 3205 | |
| 3206 | /* send del STA to remove context for this TDLS STA */ |
| 3207 | pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ; |
| 3208 | |
| 3209 | /* now send indication to SME-->HDD->TL to remove STA from TL */ |
| 3210 | |
| 3211 | if(pStaDs) |
| 3212 | { |
| 3213 | limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId, |
| 3214 | pStaDs, eSIR_SUCCESS) ; |
| 3215 | |
| 3216 | /* send Teardown Ind to SME */ |
| 3217 | limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac, |
| 3218 | eWNI_SME_TDLS_TEARDOWN_IND) ; |
| 3219 | /* remove node from setup list */ |
| 3220 | limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ; |
| 3221 | } |
| 3222 | |
| 3223 | }while(0) ; |
| 3224 | |
| 3225 | return status ; |
| 3226 | } |
| 3227 | |
| 3228 | /* |
| 3229 | * Common processing of TDLS action frames recieved |
| 3230 | */ |
| 3231 | void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd) |
| 3232 | { |
| 3233 | tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd); |
| 3234 | tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd)) |
| 3235 | ? (( sizeof( eth_890d_header ))) :(0)) ; |
| 3236 | |
| 3237 | tANI_U8 category = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ; |
| 3238 | tANI_U8 action = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ; |
| 3239 | tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ; |
| 3240 | tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ; |
| 3241 | //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd); |
| 3242 | |
| 3243 | if(category != SIR_MAC_ACTION_TDLS) |
| 3244 | { |
| 3245 | limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored\n"), category ); |
| 3246 | return ; |
| 3247 | } |
| 3248 | |
| 3249 | frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ; |
| 3250 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Received TDLS action %d (%s)"), \ |
| 3251 | action, limTraceTdlsActionString(action) )); |
| 3252 | |
| 3253 | switch(action) |
| 3254 | { |
| 3255 | |
| 3256 | case SIR_MAC_TDLS_SETUP_REQ: |
| 3257 | { |
| 3258 | limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ; |
| 3259 | break ; |
| 3260 | } |
| 3261 | case SIR_MAC_TDLS_SETUP_RSP: |
| 3262 | { |
| 3263 | limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ; |
| 3264 | break ; |
| 3265 | } |
| 3266 | case SIR_MAC_TDLS_SETUP_CNF: |
| 3267 | { |
| 3268 | limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ; |
| 3269 | break ; |
| 3270 | } |
| 3271 | case SIR_MAC_TDLS_TEARDOWN: |
| 3272 | { |
| 3273 | limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ; |
| 3274 | break ; |
| 3275 | } |
| 3276 | case SIR_MAC_TDLS_DIS_REQ: |
| 3277 | { |
| 3278 | limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ; |
| 3279 | break ; |
| 3280 | } |
| 3281 | case SIR_MAC_TDLS_PEER_TRAFFIC_IND: |
| 3282 | case SIR_MAC_TDLS_CH_SWITCH_REQ: |
| 3283 | case SIR_MAC_TDLS_CH_SWITCH_RSP: |
| 3284 | case SIR_MAC_TDLS_PEER_TRAFFIC_RSP: |
| 3285 | default: |
| 3286 | { |
| 3287 | break ; |
| 3288 | } |
| 3289 | } |
| 3290 | |
| 3291 | return ; |
| 3292 | } |
| 3293 | |
| 3294 | /* |
| 3295 | * ADD sta for dis response fame sent on direct link |
| 3296 | */ |
| 3297 | static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, |
| 3298 | tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) |
| 3299 | { |
| 3300 | tpDphHashNode pStaDs = NULL ; |
| 3301 | tSirRetStatus status = eSIR_SUCCESS ; |
| 3302 | tANI_U16 aid = 0 ; |
| 3303 | |
| 3304 | if(NULL == peerInfo) |
| 3305 | { |
| 3306 | VOS_ASSERT(0) ; |
| 3307 | return status ; |
| 3308 | |
| 3309 | } |
| 3310 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3311 | ("ADD STA peer MAC: %02x, %02x, %02x, %02x, %02x, %02x\n"), |
| 3312 | peerMac[0], |
| 3313 | peerMac[1], |
| 3314 | peerMac[2], |
| 3315 | peerMac[3], |
| 3316 | peerMac[4], |
| 3317 | peerMac[5]) ; |
| 3318 | |
| 3319 | |
| 3320 | if(NULL != dphLookupHashEntry(pMac, peerMac, |
| 3321 | &aid, &psessionEntry->dph.dphHashTable)) |
| 3322 | { |
| 3323 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3324 | (" there is hash entry for this client\n")) ; |
| 3325 | status = eSIR_FAILURE ; |
| 3326 | VOS_ASSERT(0) ; |
| 3327 | return status ; |
| 3328 | } |
| 3329 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 3330 | aid = limAssignPeerIdx(pMac, psessionEntry) ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3331 | |
| 3332 | pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable); |
| 3333 | |
| 3334 | if (pStaDs) |
| 3335 | { |
| 3336 | (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry); |
| 3337 | limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry); |
| 3338 | } |
| 3339 | pStaDs = dphAddHashEntry(pMac, peerMac, aid, |
| 3340 | &psessionEntry->dph.dphHashTable) ; |
| 3341 | |
| 3342 | if(NULL == pStaDs) |
| 3343 | { |
| 3344 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3345 | (" add hash entry failed\n")) ; |
| 3346 | status = eSIR_FAILURE ; |
| 3347 | VOS_ASSERT(0) ; |
| 3348 | return status; |
| 3349 | } |
| 3350 | if(eSIR_SUCCESS == status) |
| 3351 | { |
| 3352 | #ifdef TDLS_RATE_DEBUG |
| 3353 | tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ; |
| 3354 | tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ; |
| 3355 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3356 | ("pSta DS [%p] \n"), pStaDs) ; |
| 3357 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3358 | ("peerInfo->tdlsPeerSuppRates = [%p]\n"), |
| 3359 | (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ; |
| 3360 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3361 | ("peerInfo->tdlsPeerExtRates = [%p]\n"), |
| 3362 | (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ; |
| 3363 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3364 | ("peerInfo->tdlsPeerPropRates = [%p]\n"), |
| 3365 | (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ; |
| 3366 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3367 | ("peerInfo->mcs = [%p]\n"), |
| 3368 | (tANI_U8 *)peerInfo->supportedMCSSet) ; |
| 3369 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3370 | ("num of supp rates = %02x\n"), suppRates->numRates) ; |
| 3371 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3372 | ("num of ext rates = %01x\n"), extRates->numRates) ; |
| 3373 | #endif |
| 3374 | |
| 3375 | /* Populate matching rate set */ |
| 3376 | #ifdef WLAN_FEATURE_11AC |
| 3377 | if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs, |
| 3378 | &peerInfo->tdlsPeerSuppRates, |
| 3379 | &peerInfo->tdlsPeerExtRates, |
| 3380 | peerInfo->supportedMCSSet, |
| 3381 | &pStaDs->mlmStaContext.propRateSet, |
| 3382 | psessionEntry, NULL)) |
| 3383 | #else |
| 3384 | if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs, |
| 3385 | &peerInfo->tdlsPeerSuppRates, |
| 3386 | &peerInfo->tdlsPeerExtRates, |
| 3387 | peerInfo->supportedMCSSet, |
| 3388 | &pStaDs->mlmStaContext.propRateSet, |
| 3389 | psessionEntry)) |
| 3390 | #endif |
| 3391 | { |
| 3392 | VOS_ASSERT(0) ; |
| 3393 | } |
| 3394 | |
| 3395 | |
| 3396 | pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo; |
| 3397 | palCopyMemory(pMac->hHdd, pStaDs->staAddr, peerMac, |
| 3398 | sizeof(tSirMacAddr)) ; |
| 3399 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3400 | ("Add STA for Peer: %02x, %02x, %02x, %02x, %02x, %02x\n"), |
| 3401 | pStaDs->staAddr[0], |
| 3402 | pStaDs->staAddr[1], |
| 3403 | pStaDs->staAddr[2], |
| 3404 | pStaDs->staAddr[3], |
| 3405 | pStaDs->staAddr[4], |
| 3406 | pStaDs->staAddr[5]) ; |
| 3407 | |
| 3408 | |
| 3409 | pStaDs->staType = STA_ENTRY_TDLS_PEER ; |
| 3410 | |
| 3411 | status = limAddSta(pMac, pStaDs, psessionEntry); |
| 3412 | |
| 3413 | if(eSIR_SUCCESS != status) |
| 3414 | { |
| 3415 | /* should not fail */ |
| 3416 | VOS_ASSERT(0) ; |
| 3417 | } |
| 3418 | } |
| 3419 | |
| 3420 | return status ; |
| 3421 | } |
| 3422 | #endif |
| 3423 | /* |
| 3424 | * Add STA for TDLS setup procedure |
| 3425 | */ |
| 3426 | static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac, |
| 3427 | tSirMacAddr peerMac, tLimTdlsLinkSetupPeer *setupPeer, |
| 3428 | tpPESession psessionEntry) |
| 3429 | { |
| 3430 | tpDphHashNode pStaDs = NULL ; |
| 3431 | tSirRetStatus status = eSIR_SUCCESS ; |
| 3432 | tANI_U16 aid = 0 ; |
| 3433 | |
Lee Hoonki | f987a0b | 2013-01-29 02:07:07 -0800 | [diff] [blame^] | 3434 | pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, |
| 3435 | &psessionEntry->dph.dphHashTable); |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3436 | if(NULL == pStaDs) |
| 3437 | { |
Lee Hoonki | f987a0b | 2013-01-29 02:07:07 -0800 | [diff] [blame^] | 3438 | aid = limAssignPeerIdx(pMac, psessionEntry) ; |
| 3439 | |
| 3440 | if( !aid ) |
| 3441 | { |
| 3442 | //Reject request. |
| 3443 | return eSIR_FAILURE; |
| 3444 | } |
| 3445 | VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, |
| 3446 | ("limTdlsSetupAddSta: Aid = %d, for peer = %02x,%02x,%02x,%02x,%02x,%02x\n"), |
| 3447 | aid, peerMac[0],peerMac[1],peerMac[2], |
| 3448 | peerMac[3],peerMac[4],peerMac[5]) ; |
| 3449 | pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable); |
| 3450 | |
| 3451 | if (pStaDs) |
| 3452 | { |
| 3453 | (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry); |
| 3454 | limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry); |
| 3455 | } |
| 3456 | |
| 3457 | pStaDs = dphAddHashEntry(pMac, peerMac, aid, |
| 3458 | &psessionEntry->dph.dphHashTable) ; |
| 3459 | |
| 3460 | if(NULL == pStaDs) |
| 3461 | { |
| 3462 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3463 | (" add hash entry failed\n")) ; |
| 3464 | status = eSIR_FAILURE ; |
| 3465 | VOS_ASSERT(0) ; |
| 3466 | } |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3467 | } |
Lee Hoonki | f987a0b | 2013-01-29 02:07:07 -0800 | [diff] [blame^] | 3468 | else |
| 3469 | { |
| 3470 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3471 | (" there is hash entry for this client\n")) ; |
| 3472 | /*TODO: for now We are returning from here but we should tell |
| 3473 | firmware that station configuration is modified once we |
| 3474 | got that from supplicant*/ |
| 3475 | return eSIR_FAILURE; |
| 3476 | } |
| 3477 | |
| 3478 | limTdlsUpdateHashNodeInfo(pMac, pStaDs, setupPeer, psessionEntry) ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3479 | |
| 3480 | pStaDs->staType = STA_ENTRY_TDLS_PEER ; |
| 3481 | |
| 3482 | status = limAddSta(pMac, pStaDs, psessionEntry); |
| 3483 | |
| 3484 | if(eSIR_SUCCESS != status) |
| 3485 | { |
| 3486 | /* should not fail */ |
| 3487 | VOS_ASSERT(0) ; |
Lee Hoonki | f987a0b | 2013-01-29 02:07:07 -0800 | [diff] [blame^] | 3488 | } |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3489 | return status ; |
| 3490 | } |
| 3491 | |
| 3492 | /* |
| 3493 | * Del STA, after Link is teardown or discovery response sent on direct link |
| 3494 | */ |
| 3495 | static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, |
| 3496 | tpPESession psessionEntry) |
| 3497 | { |
| 3498 | tSirRetStatus status = eSIR_SUCCESS ; |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 3499 | tANI_U16 peerIdx = 0 ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3500 | tpDphHashNode pStaDs = NULL ; |
| 3501 | |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 3502 | pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx, |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3503 | &psessionEntry->dph.dphHashTable) ; |
| 3504 | |
| 3505 | if(pStaDs) |
| 3506 | { |
| 3507 | |
| 3508 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3509 | ("DEL STA peer MAC: %02x, %02x, %02x, %02x, %02x, %02x \n"), |
| 3510 | pStaDs->staAddr[0], |
| 3511 | pStaDs->staAddr[1], |
| 3512 | pStaDs->staAddr[2], |
| 3513 | pStaDs->staAddr[3], |
| 3514 | pStaDs->staAddr[4], |
| 3515 | pStaDs->staAddr[5] |
| 3516 | ) ; |
| 3517 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 3518 | VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, |
| 3519 | ("limTdlsDelSta: STA type = %x, sta idx = %x\n"),pStaDs->staType, |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3520 | pStaDs->staIndex) ; |
| 3521 | |
| 3522 | status = limDelSta(pMac, pStaDs, false, psessionEntry) ; |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 3523 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3524 | if(eSIR_SUCCESS == status) |
| 3525 | { |
Gopichand Nakkala | 777e603 | 2012-12-31 16:39:21 -0800 | [diff] [blame] | 3526 | limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ; |
| 3527 | limReleasePeerIdx(pMac, peerIdx, psessionEntry) ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3528 | } |
| 3529 | else |
| 3530 | { |
| 3531 | VOS_ASSERT(0) ; |
| 3532 | } |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 3533 | #endif |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 3534 | } |
| 3535 | |
| 3536 | return pStaDs ; |
| 3537 | } |
| 3538 | |
| 3539 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 3540 | /* |
| 3541 | * Prepare link establish message for HAL, construct PTI template. |
| 3542 | * |
| 3543 | */ |
| 3544 | static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac) |
| 3545 | { |
| 3546 | tANI_U8 pFrame[64] ; |
| 3547 | tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ; |
| 3548 | tANI_U32 status = 0 ; |
| 3549 | tANI_U32 nPayload = 0 ; |
| 3550 | tANI_U32 nBytes = 0 ; |
| 3551 | tANI_U32 header_offset = 0 ; |
| 3552 | tANI_U16 aid = 0 ; |
| 3553 | tDphHashNode *pStaDs = NULL ; |
| 3554 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 3555 | tpPESession psessionEntry = NULL ; |
| 3556 | |
| 3557 | |
| 3558 | limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ; |
| 3559 | if(NULL == setupPeer) { |
| 3560 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3561 | ("limTdlsLinkEstablish: cannot find peer mac in tdls linksetup list: %02X %02X %02X %02X %02X %02X\n"), \ |
| 3562 | peerMac[0], peerMac[1], peerMac[2], \ |
| 3563 | peerMac[3], peerMac[4], peerMac[5]); |
| 3564 | return eSIR_FAILURE; |
| 3565 | } |
| 3566 | |
| 3567 | psessionEntry = peFindSessionBySessionId(pMac, |
| 3568 | setupPeer->tdls_sessionId) ; |
| 3569 | |
| 3570 | if(NULL == psessionEntry) |
| 3571 | { |
| 3572 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3573 | ("limTdlsLinkEstablish: sessionID %d is not found\n"), setupPeer->tdls_sessionId); |
| 3574 | VOS_ASSERT(0) ; |
| 3575 | return eHAL_STATUS_FAILURE; |
| 3576 | } |
| 3577 | |
| 3578 | /* */ |
| 3579 | pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ; |
| 3580 | if(pStaDs == NULL) { |
| 3581 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3582 | ("limTdlsLinkEstablish: cannot find peer mac in hash table: %02X %02X %02X %02X %02X %02X\n"), \ |
| 3583 | peerMac[0], peerMac[1], peerMac[2], \ |
| 3584 | peerMac[3], peerMac[4], peerMac[5]); |
| 3585 | return eSIR_FAILURE; |
| 3586 | } |
| 3587 | |
| 3588 | palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsPtiTemplate, |
| 3589 | sizeof( tDot11fTDLSPeerTrafficInd ) ); |
| 3590 | |
| 3591 | /* |
| 3592 | * setup Fixed fields, |
| 3593 | */ |
| 3594 | tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS; |
| 3595 | tdlsPtiTemplate.Action.action = SIR_MAC_TDLS_PEER_TRAFFIC_IND; |
| 3596 | tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */ |
| 3597 | #if 1 |
| 3598 | /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address, |
| 3599 | then below code makes such an way */ |
| 3600 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier, |
| 3601 | peerMac, !setupPeer->tdls_bIsResponder) ; |
| 3602 | #else |
| 3603 | /* below code will make PTI's linkIdentifier's initiator address be selfAddr */ |
| 3604 | PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier, |
| 3605 | peerMac, TDLS_INITIATOR) ; |
| 3606 | #endif |
| 3607 | |
| 3608 | /* PUBufferStatus will be filled by firmware at the time of transmission */ |
| 3609 | tdlsPtiTemplate.PUBufferStatus.present = 1; |
| 3610 | |
| 3611 | /* TODO: get ExtendedCapabilities IE */ |
| 3612 | |
| 3613 | /* |
| 3614 | * now we pack it. First, how much space are we going to need? |
| 3615 | */ |
| 3616 | status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload); |
| 3617 | if ( DOT11F_FAILED( status ) ) |
| 3618 | { |
| 3619 | limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x).\n"), status ); |
| 3620 | /* We'll fall back on the worst case scenario: */ |
| 3621 | nPayload = sizeof( tdlsPtiTemplate ); |
| 3622 | } |
| 3623 | else if ( DOT11F_WARNED( status ) ) |
| 3624 | { |
| 3625 | limLog( pMac, LOGW, FL("There were warnings while calculating the packed size for a PTI template (0x%08x).\n"), status ); |
| 3626 | } |
| 3627 | |
| 3628 | /* |
| 3629 | * This frame is going out from PE as data frames with special ethertype |
| 3630 | * 89-0d. |
| 3631 | * 8 bytes of RFC 1042 header |
| 3632 | */ |
| 3633 | |
| 3634 | nBytes = nPayload + sizeof( tSirMacMgmtHdr ) |
| 3635 | + sizeof( eth_890d_header ) |
| 3636 | + PAYLOAD_TYPE_TDLS_SIZE ; |
| 3637 | |
| 3638 | if(nBytes > 64) { |
| 3639 | limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64.\n"), nBytes); |
| 3640 | nBytes = 64; |
| 3641 | } |
| 3642 | /* zero out the memory */ |
| 3643 | palZeroMemory( pMac->hHdd, pFrame, sizeof(pFrame) ); |
| 3644 | |
| 3645 | /* fill out the buffer descriptor */ |
| 3646 | |
| 3647 | header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, |
| 3648 | LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ; |
| 3649 | |
| 3650 | status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame |
| 3651 | + header_offset, nPayload, &nPayload ); |
| 3652 | |
| 3653 | if ( DOT11F_FAILED( status ) ) |
| 3654 | { |
| 3655 | limLog( pMac, LOGE, FL("Failed to pack a PTI template \ |
| 3656 | (0x%08x).\n"), status ); |
| 3657 | return eSIR_FAILURE; |
| 3658 | } |
| 3659 | else if ( DOT11F_WARNED( status ) ) |
| 3660 | { |
| 3661 | limLog( pMac, LOGW, FL("There were warnings while packing TDLS" |
| 3662 | "Peer Traffic Indication (0x%08x).\n") ); |
| 3663 | } |
| 3664 | |
| 3665 | LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("bIsResponder=%d, header_offset=%ld, linkIdenOffset=%d, ptiBufStatusOffset=%d \n"), \ |
| 3666 | setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET)); |
| 3667 | |
| 3668 | limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder, |
| 3669 | header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET, |
| 3670 | nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps); |
| 3671 | |
| 3672 | return eSIR_SUCCESS; |
| 3673 | } |
| 3674 | |
| 3675 | /* |
| 3676 | * Prepare link teardown message for HAL from peer_mac |
| 3677 | * |
| 3678 | */ |
| 3679 | static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac) |
| 3680 | { |
| 3681 | tDphHashNode *pStaDs = NULL ; |
| 3682 | tANI_U16 aid = 0 ; |
| 3683 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 3684 | tpPESession psessionEntry = NULL ; |
| 3685 | |
| 3686 | |
| 3687 | limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ; |
| 3688 | if(NULL == setupPeer) { |
| 3689 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3690 | ("limTdlsLinkTeardown: cannot find peer mac in tdls linksetup list: %02X %02X %02X %02X %02X %02X\n"), \ |
| 3691 | peerMac[0], peerMac[1], peerMac[2], \ |
| 3692 | peerMac[3], peerMac[4], peerMac[5]); |
| 3693 | return eSIR_FAILURE; |
| 3694 | } |
| 3695 | |
| 3696 | psessionEntry = peFindSessionBySessionId(pMac, |
| 3697 | setupPeer->tdls_sessionId) ; |
| 3698 | |
| 3699 | if(NULL == psessionEntry) |
| 3700 | { |
| 3701 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3702 | ("limTdlsLinkTeardown: sessionID %d is not found\n"), setupPeer->tdls_sessionId); |
| 3703 | VOS_ASSERT(0) ; |
| 3704 | return eHAL_STATUS_FAILURE; |
| 3705 | } |
| 3706 | |
| 3707 | |
| 3708 | /* */ |
| 3709 | pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable); |
| 3710 | |
| 3711 | if(pStaDs == NULL) { |
| 3712 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3713 | ("limTdlsLinkTeardown: cannot find peer mac in hash table: %02X %02X %02X %02X %02X %02X\n"), \ |
| 3714 | peerMac[0], peerMac[1], peerMac[2], \ |
| 3715 | peerMac[3], peerMac[4], peerMac[5]); |
| 3716 | return eSIR_FAILURE; |
| 3717 | } |
| 3718 | |
| 3719 | limSendTdlsLinkTeardown(pMac, pStaDs->staIndex); |
| 3720 | |
| 3721 | return eSIR_SUCCESS; |
| 3722 | } |
| 3723 | |
| 3724 | /* |
| 3725 | * Prepare Discovery RSP message for SME, collect peerINfo for all the |
| 3726 | * peers discovered and delete/clean discovery lists in PE. |
| 3727 | */ |
| 3728 | |
| 3729 | static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac, |
| 3730 | tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount) |
| 3731 | { |
| 3732 | tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp); |
| 3733 | tANI_U8 status = eHAL_STATUS_SUCCESS ; |
| 3734 | |
| 3735 | /* |
| 3736 | * allocate memory for tdls discovery response, allocated memory should |
| 3737 | * be alloc_mem = tdlsStaCount * sizeof(peerinfo) |
| 3738 | * + siezeof tSirTdlsDisRsp. |
| 3739 | */ |
| 3740 | disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo)); |
| 3741 | |
| 3742 | /* now allocate memory */ |
| 3743 | status = palAllocateMemory( pMac->hHdd, (void **)&disRsp, disMsgRspSize ) ; |
| 3744 | |
| 3745 | if(eHAL_STATUS_FAILURE == status) |
| 3746 | { |
| 3747 | limLog(pMac, LOGP, FL("palAllocateMemory failed for DIS RSP")); |
| 3748 | return NULL ; |
| 3749 | } |
| 3750 | |
| 3751 | if(disStaCount) |
| 3752 | { |
| 3753 | tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ; |
| 3754 | tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ; |
| 3755 | |
| 3756 | tLimDisResultList *currentNode = tdlsDisRspList ; |
| 3757 | while(tdlsDisRspList != NULL) |
| 3758 | { |
| 3759 | |
| 3760 | palCopyMemory( pMac->hHdd, (tANI_U8 *)peerInfo, |
| 3761 | (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo, |
| 3762 | sizeof(tSirTdlsPeerInfo)); |
| 3763 | |
| 3764 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 3765 | ("Msg Sent to PE, peer MAC: %02x, %02x, %02x, %02x, %02x, %02x\n"), |
| 3766 | peerInfo->peerMac[0] , |
| 3767 | peerInfo->peerMac[1] , |
| 3768 | peerInfo->peerMac[2] , |
| 3769 | peerInfo->peerMac[3] , |
| 3770 | peerInfo->peerMac[4] , |
| 3771 | peerInfo->peerMac[5]) ; |
| 3772 | disStaCount-- ; |
| 3773 | peerInfo++ ; |
| 3774 | currentNode = tdlsDisRspList ; |
| 3775 | tdlsDisRspList = tdlsDisRspList->next ; |
| 3776 | palFreeMemory(pMac->hHdd, currentNode) ; |
| 3777 | /* boundary condition check, may be fatal */ |
| 3778 | if(((!disStaCount) && (tdlsDisRspList)) |
| 3779 | || ((!tdlsDisRspList) && disStaCount)) |
| 3780 | { |
| 3781 | limLog(pMac, LOG1, FL("mismatch in dis sta count and\ |
| 3782 | and number of nodes in list\n")) ; |
| 3783 | VOS_ASSERT(0) ; |
| 3784 | return NULL ; |
| 3785 | } |
| 3786 | } /* end of while */ |
| 3787 | |
| 3788 | /* All discovery STA processed */ |
| 3789 | pMac->lim.gLimTdlsDisResultList = NULL ; |
| 3790 | |
| 3791 | } /* end of if dis STA count */ |
| 3792 | |
| 3793 | return (disRsp) ; |
| 3794 | } |
| 3795 | |
| 3796 | /* Send Teardown response back to PE */ |
| 3797 | |
| 3798 | void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode, |
| 3799 | tSirMacAddr peerMac, tANI_U16 msgType) |
| 3800 | { |
| 3801 | tSirMsgQ mmhMsg = {0} ; |
| 3802 | tSirTdlsTeardownRsp *teardownRspMsg = NULL ; |
| 3803 | tANI_U8 status = eHAL_STATUS_SUCCESS ; |
| 3804 | |
| 3805 | mmhMsg.type = msgType ; |
| 3806 | |
| 3807 | status = palAllocateMemory( pMac->hHdd, (void **)&teardownRspMsg, |
| 3808 | sizeof(tSirTdlsTeardownRsp)) ; |
| 3809 | |
| 3810 | if(eHAL_STATUS_SUCCESS != status) |
| 3811 | { |
| 3812 | VOS_ASSERT(0) ; |
| 3813 | } |
| 3814 | palCopyMemory( pMac->hHdd, teardownRspMsg->peerMac, (tANI_U8 *)peerMac, |
| 3815 | sizeof(tSirMacAddr)) ; |
| 3816 | teardownRspMsg->statusCode = statusCode ; |
| 3817 | mmhMsg.bodyptr = teardownRspMsg ; |
| 3818 | mmhMsg.bodyval = 0; |
| 3819 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 3820 | |
| 3821 | return ; |
| 3822 | |
| 3823 | } |
| 3824 | |
| 3825 | /* |
| 3826 | * Send Link start RSP back to SME after link is setup or failed |
| 3827 | */ |
| 3828 | void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac, |
| 3829 | tSirResultCodes statusCode, |
| 3830 | tSirMacAddr peerMac, |
| 3831 | tANI_U16 msgType) |
| 3832 | { |
| 3833 | tSirMsgQ mmhMsg = {0} ; |
| 3834 | tSirTdlsLinksetupRsp *setupRspMsg = NULL ; |
| 3835 | tANI_U8 status = eHAL_STATUS_SUCCESS ; |
| 3836 | |
| 3837 | mmhMsg.type = msgType ; |
| 3838 | |
| 3839 | status = palAllocateMemory( pMac->hHdd, (void **)&setupRspMsg, |
| 3840 | sizeof(tSirTdlsLinksetupRsp)) ; |
| 3841 | |
| 3842 | if(eHAL_STATUS_SUCCESS != status) |
| 3843 | { |
| 3844 | VOS_ASSERT(0) ; |
| 3845 | } |
| 3846 | |
| 3847 | palCopyMemory( pMac->hHdd, setupRspMsg->peerMac, (tANI_U8 *)peerMac, |
| 3848 | sizeof(tSirMacAddr)) ; |
| 3849 | setupRspMsg->statusCode = statusCode ; |
| 3850 | mmhMsg.bodyptr = setupRspMsg ; |
| 3851 | mmhMsg.bodyval = 0; |
| 3852 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 3853 | |
| 3854 | return ; |
| 3855 | } |
| 3856 | |
| 3857 | /* |
| 3858 | * Send TDLS discovery RSP back to SME |
| 3859 | */ |
| 3860 | void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode, |
| 3861 | tANI_U16 msgType) |
| 3862 | { |
| 3863 | tSirMsgQ mmhMsg = {0} ; |
| 3864 | tSirTdlsDisRsp *tdlsDisRsp = NULL ; |
| 3865 | |
| 3866 | mmhMsg.type = msgType ; |
| 3867 | |
| 3868 | if(eSIR_SME_SUCCESS == statusCode) |
| 3869 | { |
| 3870 | tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ; |
| 3871 | |
| 3872 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 3873 | ("no of TDLS STA discovered: %d\n"), tdlsStaCount) ; |
| 3874 | tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ; |
| 3875 | |
| 3876 | if(tdlsDisRsp) |
| 3877 | { |
| 3878 | tdlsDisRsp->numDisSta = tdlsStaCount ; |
| 3879 | } |
| 3880 | else |
| 3881 | { |
| 3882 | limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP\n")); |
| 3883 | VOS_ASSERT(0) ; |
| 3884 | return ; |
| 3885 | } |
| 3886 | /* all Discovery STA is processed */ |
| 3887 | pMac->lim.gLimTdlsDisStaCount = 0 ; |
| 3888 | } |
| 3889 | else |
| 3890 | { |
| 3891 | tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ; |
| 3892 | } |
| 3893 | |
| 3894 | tdlsDisRsp->statusCode = statusCode ; |
| 3895 | mmhMsg.bodyptr = tdlsDisRsp ; |
| 3896 | mmhMsg.bodyval = 0; |
| 3897 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 3898 | |
| 3899 | return ; |
| 3900 | } |
| 3901 | |
| 3902 | /* |
| 3903 | * Once Link is setup with PEER, send Add STA ind to SME |
| 3904 | */ |
| 3905 | static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac, |
| 3906 | tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) |
| 3907 | { |
| 3908 | tSirMsgQ mmhMsg = {0} ; |
| 3909 | tSirTdlsPeerInd *peerInd = NULL ; |
| 3910 | mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ; |
| 3911 | if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &peerInd, |
| 3912 | (sizeof(tSirTdlsPeerInd)))) |
| 3913 | { |
| 3914 | PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));) |
| 3915 | return eSIR_FAILURE; |
| 3916 | } |
| 3917 | |
| 3918 | palCopyMemory( pMac->hHdd, peerInd->peerMac, |
| 3919 | (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr)); |
| 3920 | peerInd->sessionId = sessionId; |
| 3921 | peerInd->staId = pStaDs->staIndex ; |
| 3922 | peerInd->ucastSig = pStaDs->ucUcastSig ; |
| 3923 | peerInd->bcastSig = pStaDs->ucBcastSig ; |
| 3924 | peerInd->length = sizeof(tSmeIbssPeerInd) ; |
| 3925 | |
| 3926 | mmhMsg.bodyptr = peerInd ; |
| 3927 | mmhMsg.bodyval = 0; |
| 3928 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 3929 | |
| 3930 | return eSIR_SUCCESS ; |
| 3931 | |
| 3932 | } |
| 3933 | |
| 3934 | /* |
| 3935 | * Once link is teardown, send Del Peer Ind to SME |
| 3936 | */ |
| 3937 | static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac, |
| 3938 | tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) |
| 3939 | { |
| 3940 | tSirMsgQ mmhMsg = {0} ; |
| 3941 | tSirTdlsPeerInd *peerInd = NULL ; |
| 3942 | mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ; |
| 3943 | if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &peerInd, |
| 3944 | (sizeof(tSirTdlsPeerInd)))) |
| 3945 | { |
| 3946 | PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));) |
| 3947 | return eSIR_FAILURE; |
| 3948 | } |
| 3949 | |
| 3950 | palCopyMemory( pMac->hHdd, peerInd->peerMac, |
| 3951 | (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr)); |
| 3952 | peerInd->sessionId = sessionId; |
| 3953 | peerInd->staId = pStaDs->staIndex ; |
| 3954 | peerInd->ucastSig = pStaDs->ucUcastSig ; |
| 3955 | peerInd->bcastSig = pStaDs->ucBcastSig ; |
| 3956 | peerInd->length = sizeof(tSmeIbssPeerInd) ; |
| 3957 | |
| 3958 | mmhMsg.bodyptr = peerInd ; |
| 3959 | |
| 3960 | //peerInd->statusCode = status ; |
| 3961 | mmhMsg.bodyval = 0; |
| 3962 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 3963 | return eSIR_SUCCESS ; |
| 3964 | |
| 3965 | } |
| 3966 | |
| 3967 | /* |
| 3968 | * Send Link setup Ind to SME, This is the case where, link setup is |
| 3969 | * initiated by peer STA |
| 3970 | */ |
| 3971 | static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac, |
| 3972 | tSirMacAddr peerMac, tANI_U8 status) |
| 3973 | { |
| 3974 | tSirMsgQ mmhMsg = {0} ; |
| 3975 | tSirTdlsLinkSetupInd *setupInd = NULL ; |
| 3976 | |
| 3977 | mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ; |
| 3978 | if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &setupInd, |
| 3979 | (sizeof(tSirTdlsLinkSetupInd)))) |
| 3980 | { |
| 3981 | PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));) |
| 3982 | return eSIR_FAILURE; |
| 3983 | } |
| 3984 | |
| 3985 | palCopyMemory( pMac->hHdd, setupInd->peerMac, |
| 3986 | (tANI_U8 *) peerMac, sizeof(tSirMacAddr)); |
| 3987 | setupInd->length = sizeof(tSirTdlsLinkSetupInd); |
| 3988 | setupInd->statusCode = status ; |
| 3989 | mmhMsg.bodyptr = setupInd ; |
| 3990 | mmhMsg.bodyval = 0; |
| 3991 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 3992 | |
| 3993 | return eSIR_SUCCESS ; |
| 3994 | |
| 3995 | } |
| 3996 | |
| 3997 | /* |
| 3998 | * Setup RSP timer handler |
| 3999 | */ |
| 4000 | void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId) |
| 4001 | { |
| 4002 | |
| 4003 | tANI_U32 statusCode; |
| 4004 | tSirMsgQ msg; |
| 4005 | tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal; |
| 4006 | |
| 4007 | /* Prepare and post message to LIM Message Queue */ |
| 4008 | |
| 4009 | msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT; |
| 4010 | msg.bodyptr = NULL ; |
| 4011 | msg.bodyval = timerId ; |
| 4012 | |
| 4013 | if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS) |
| 4014 | limLog(pMac, LOGE, |
| 4015 | FL("posting message %X to LIM failed, reason=%d\n"), |
| 4016 | msg.type, statusCode); |
| 4017 | return ; |
| 4018 | } |
| 4019 | |
| 4020 | /* |
| 4021 | * Link setup CNF timer |
| 4022 | */ |
| 4023 | void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId) |
| 4024 | { |
| 4025 | |
| 4026 | tANI_U32 statusCode; |
| 4027 | tSirMsgQ msg; |
| 4028 | tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal; |
| 4029 | |
| 4030 | // Prepare and post message to LIM Message Queue |
| 4031 | |
| 4032 | msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT; |
| 4033 | msg.bodyptr = NULL ; |
| 4034 | msg.bodyval = timerId ; |
| 4035 | |
| 4036 | if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS) |
| 4037 | limLog(pMac, LOGE, |
| 4038 | FL("posting message %X to LIM failed, reason=%d\n"), |
| 4039 | msg.type, statusCode); |
| 4040 | return ; |
| 4041 | } |
| 4042 | |
| 4043 | /* |
| 4044 | * start TDLS timer |
| 4045 | */ |
| 4046 | void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer, |
| 4047 | tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg) |
| 4048 | { |
| 4049 | tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) |
| 4050 | ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT |
| 4051 | : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ; |
| 4052 | |
| 4053 | void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) |
| 4054 | ? (limTdlsLinkSetupRspTimerHandler) |
| 4055 | : limTdlsLinkSetupCnfTimerHandler ; |
| 4056 | |
| 4057 | /* TODO: Read timer vals from CFG */ |
| 4058 | |
| 4059 | cfgValue = SYS_MS_TO_TICKS(cfgValue); |
| 4060 | /* |
| 4061 | * create TDLS discovery response wait timer and activate it |
| 4062 | */ |
| 4063 | if (tx_timer_create(timer, "TDLS link setup timers", timerFunc, |
| 4064 | timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) |
| 4065 | { |
| 4066 | limLog(pMac, LOGP, |
| 4067 | FL("could not create TDLS discovery response wait timer\n")); |
| 4068 | return; |
| 4069 | } |
| 4070 | |
| 4071 | //assign appropriate sessionId to the timer object |
| 4072 | timer->sessionId = sessionId; |
| 4073 | |
| 4074 | MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, |
| 4075 | eLIM_TDLS_DISCOVERY_RSP_WAIT)); |
| 4076 | if (tx_timer_activate(timer) != TX_SUCCESS) |
| 4077 | { |
| 4078 | limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!\n")); |
| 4079 | return ; |
| 4080 | } |
| 4081 | |
| 4082 | return ; |
| 4083 | |
| 4084 | } |
| 4085 | #endif |
| 4086 | |
| 4087 | /* |
| 4088 | * Once Link is setup with PEER, send Add STA ind to SME |
| 4089 | */ |
| 4090 | static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac, |
| 4091 | tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs, |
| 4092 | tANI_U8 status) |
| 4093 | { |
| 4094 | tSirMsgQ mmhMsg = {0} ; |
| 4095 | tSirTdlsAddStaRsp *addStaRsp = NULL ; |
| 4096 | mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ; |
| 4097 | if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &addStaRsp, |
| 4098 | (sizeof(tSirTdlsAddStaRsp)))) |
| 4099 | { |
| 4100 | PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));) |
| 4101 | return eSIR_FAILURE; |
| 4102 | } |
| 4103 | |
| 4104 | addStaRsp->sessionId = sessionId; |
| 4105 | addStaRsp->statusCode = status; |
| 4106 | if( pStaDs ) |
| 4107 | { |
| 4108 | addStaRsp->staId = pStaDs->staIndex ; |
| 4109 | addStaRsp->ucastSig = pStaDs->ucUcastSig ; |
| 4110 | addStaRsp->bcastSig = pStaDs->ucBcastSig ; |
| 4111 | } |
| 4112 | if( peerMac ) |
| 4113 | { |
| 4114 | palCopyMemory( pMac->hHdd, addStaRsp->peerMac, |
| 4115 | (tANI_U8 *) peerMac, sizeof(tSirMacAddr)); |
| 4116 | } |
| 4117 | addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ; |
| 4118 | addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ; |
| 4119 | |
| 4120 | mmhMsg.bodyptr = addStaRsp; |
| 4121 | mmhMsg.bodyval = 0; |
| 4122 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 4123 | |
| 4124 | return eSIR_SUCCESS ; |
| 4125 | |
| 4126 | } |
| 4127 | /* |
| 4128 | * STA RSP received from HAL |
| 4129 | */ |
| 4130 | eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg, |
| 4131 | tpPESession psessionEntry) |
| 4132 | { |
| 4133 | tAddStaParams *pAddStaParams = (tAddStaParams *) msg ; |
| 4134 | tANI_U8 status = eSIR_SUCCESS ; |
| 4135 | tDphHashNode *pStaDs = NULL ; |
| 4136 | tANI_U16 aid = 0 ; |
| 4137 | |
| 4138 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 4139 | VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, |
| 4140 | ("limTdlsAddStaRsp: staIdx=%d, staMac=%02x:%02x:%02x:%02x:%02x:%02x"), pAddStaParams->staIdx, \ |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 4141 | pAddStaParams->staMac[0], |
| 4142 | pAddStaParams->staMac[1], |
| 4143 | pAddStaParams->staMac[2], |
| 4144 | pAddStaParams->staMac[3], |
| 4145 | pAddStaParams->staMac[4], |
| 4146 | pAddStaParams->staMac[5] ) ; |
| 4147 | |
| 4148 | if (pAddStaParams->status != eHAL_STATUS_SUCCESS) |
| 4149 | { |
| 4150 | VOS_ASSERT(0) ; |
| 4151 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4152 | ("Add sta failed \n")) ; |
| 4153 | status = eSIR_FAILURE; |
| 4154 | goto add_sta_error; |
| 4155 | } |
| 4156 | |
| 4157 | pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid, |
| 4158 | &psessionEntry->dph.dphHashTable); |
| 4159 | if(NULL == pStaDs) |
| 4160 | { |
| 4161 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4162 | ("pStaDs is NULL \n")) ; |
| 4163 | status = eSIR_FAILURE; |
| 4164 | goto add_sta_error; |
| 4165 | } |
| 4166 | |
| 4167 | pStaDs->bssId = pAddStaParams->bssIdx; |
| 4168 | pStaDs->staIndex = pAddStaParams->staIdx; |
| 4169 | pStaDs->ucUcastSig = pAddStaParams->ucUcastSig; |
| 4170 | pStaDs->ucBcastSig = pAddStaParams->ucBcastSig; |
| 4171 | pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE; |
| 4172 | pStaDs->valid = 1 ; |
| 4173 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 4174 | status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId, |
| 4175 | pStaDs, eSIR_SUCCESS ) ; |
| 4176 | if(eSIR_FAILURE == status) |
| 4177 | { |
| 4178 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4179 | ("Peer IND msg to SME failed\n")) ; |
| 4180 | palFreeMemory( pMac->hHdd, (void *) pAddStaParams ); |
| 4181 | return eSIR_FAILURE ; |
| 4182 | } |
| 4183 | |
| 4184 | /* |
| 4185 | * Now, there is two things a) ADD STA RSP for ADD STA request sent |
| 4186 | * after recieving discovery request from Peer. |
| 4187 | * now we have to send discovery response, if there is any pending |
| 4188 | * discovery equest.. |
| 4189 | */ |
| 4190 | do |
| 4191 | { |
| 4192 | tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac, |
| 4193 | pAddStaParams->staMac) ; |
| 4194 | |
| 4195 | |
| 4196 | if(peerInfo) |
| 4197 | { |
| 4198 | /* |
| 4199 | * send TDLS discovery response frame on direct link, state machine |
| 4200 | * is rolling.., once discovery response is get Acked, we will |
| 4201 | * send response to SME based on TxComplete callback results |
| 4202 | */ |
| 4203 | limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ; |
| 4204 | peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ; |
| 4205 | } |
| 4206 | } while(0) ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 4207 | #endif |
| 4208 | add_sta_error: |
| 4209 | status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId, |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 4210 | pAddStaParams->staMac, pStaDs, status) ; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 4211 | palFreeMemory( pMac->hHdd, (void *) pAddStaParams ); |
| 4212 | return status ; |
| 4213 | } |
| 4214 | |
| 4215 | /* |
| 4216 | * FUNCTION: Populate Link Identifier element IE |
| 4217 | * |
| 4218 | */ |
| 4219 | |
| 4220 | |
| 4221 | void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry, |
| 4222 | tDot11fIELinkIdentifier *linkIden, |
| 4223 | tSirMacAddr peerMac, tANI_U8 reqType) |
| 4224 | { |
| 4225 | //tANI_U32 size = sizeof(tSirMacAddr) ; |
| 4226 | tANI_U8 *initStaAddr = NULL ; |
| 4227 | tANI_U8 *respStaAddr = NULL ; |
| 4228 | |
| 4229 | (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr), |
| 4230 | (respStaAddr = linkIden->RespStaAddr)) |
| 4231 | : ((respStaAddr = linkIden->InitStaAddr ), |
| 4232 | (initStaAddr = linkIden->RespStaAddr)) ; |
| 4233 | palCopyMemory( pMac->hHdd, (tANI_U8 *)linkIden->bssid, |
| 4234 | (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ; |
| 4235 | |
| 4236 | palCopyMemory( pMac->hHdd, (tANI_U8 *)initStaAddr, |
| 4237 | psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ; |
| 4238 | |
| 4239 | palCopyMemory( pMac->hHdd, (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac, |
| 4240 | sizeof( tSirMacAddr )); |
| 4241 | |
| 4242 | linkIden->present = 1 ; |
| 4243 | return ; |
| 4244 | |
| 4245 | } |
| 4246 | |
| 4247 | void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac, |
| 4248 | tDot11fIEExtCap *extCapability) |
| 4249 | { |
| 4250 | extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ; |
| 4251 | extCapability->TDLSPeerUAPSDBufferSTA = PEER_BUFFER_STA_SUPPORT ; |
| 4252 | extCapability->TDLSChannelSwitching = CH_SWITCH_SUPPORT ; |
| 4253 | extCapability->TDLSSupport = TDLS_SUPPORT ; |
| 4254 | extCapability->TDLSProhibited = TDLS_PROHIBITED ; |
| 4255 | extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ; |
| 4256 | extCapability->present = 1 ; |
| 4257 | return ; |
| 4258 | } |
| 4259 | |
| 4260 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
| 4261 | /* |
| 4262 | * Public Action frame common processing |
| 4263 | * This Function will be moved/merged to appropriate place |
| 4264 | * once other public action frames (particularly 802.11k) |
| 4265 | * is in place |
| 4266 | */ |
| 4267 | void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd, |
| 4268 | tpPESession psessionEntry) |
| 4269 | { |
| 4270 | tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ; |
| 4271 | tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ; |
| 4272 | tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ; |
| 4273 | |
| 4274 | limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ; |
| 4275 | return ; |
| 4276 | } |
| 4277 | |
| 4278 | eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac, |
| 4279 | tLimTdlsLinkSetupInfo *linkSetupInfo, |
| 4280 | tANI_U8 dialog, tSirMacAddr peerMac, |
| 4281 | tpPESession psessionEntry) |
| 4282 | { |
| 4283 | tLimTdlsLinkSetupPeer *setupPeer = NULL ; |
| 4284 | |
| 4285 | /* |
| 4286 | * we allocate the TDLS setup Peer Memory here, we will free'd this |
| 4287 | * memory after teardown, if the link is successfully setup or |
| 4288 | * free this memory if any timeout is happen in link setup procedure |
| 4289 | */ |
| 4290 | if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, |
| 4291 | (void **) &setupPeer, sizeof( tLimTdlsLinkSetupPeer ))) |
| 4292 | { |
| 4293 | limLog( pMac, LOGP, |
| 4294 | FL( "Unable to allocate memory during ADD_STA\n" )); |
| 4295 | VOS_ASSERT(0) ; |
| 4296 | return eSIR_MEM_ALLOC_FAILED; |
| 4297 | } |
| 4298 | setupPeer->dialog = dialog ; |
| 4299 | setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ; |
| 4300 | setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ; |
| 4301 | |
| 4302 | /* TDLS_sessionize: remember sessionId for future */ |
| 4303 | setupPeer->tdls_sessionId = psessionEntry->peSessionId; |
| 4304 | setupPeer->tdls_bIsResponder = 1; |
| 4305 | |
| 4306 | /* |
| 4307 | * we only populate peer MAC, so it can assit us to find the |
| 4308 | * TDLS peer after response/or after response timeout |
| 4309 | */ |
| 4310 | palCopyMemory(pMac->hHdd, setupPeer->peerMac, peerMac, |
| 4311 | sizeof(tSirMacAddr)) ; |
| 4312 | /* format TDLS discovery request frame and transmit it */ |
| 4313 | limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ; |
| 4314 | |
| 4315 | limStartTdlsTimer(pMac, psessionEntry->peSessionId, |
| 4316 | &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer, |
| 4317 | (tANI_U32)setupPeer->peerMac, |
| 4318 | WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT, |
| 4319 | SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ; |
| 4320 | /* update setup peer list */ |
| 4321 | setupPeer->next = linkSetupInfo->tdlsLinkSetupList ; |
| 4322 | linkSetupInfo->tdlsLinkSetupList = setupPeer ; |
| 4323 | |
| 4324 | /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to |
| 4325 | * SME later when TDLS setup cnf TX complete is successful. --> see |
| 4326 | * limTdlsSetupCnfTxComplete() |
| 4327 | */ |
| 4328 | return eSIR_SUCCESS ; |
| 4329 | } |
| 4330 | #endif |
| 4331 | |
| 4332 | /* |
| 4333 | * Process Send Mgmt Request from SME and transmit to AP. |
| 4334 | */ |
| 4335 | tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac, |
| 4336 | tANI_U32 *pMsgBuf) |
| 4337 | { |
| 4338 | /* get all discovery request parameters */ |
| 4339 | tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ; |
| 4340 | tpPESession psessionEntry; |
| 4341 | tANI_U8 sessionId; |
| 4342 | tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 4343 | |
| 4344 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 4345 | ("Send Mgmt Recieved\n")) ; |
| 4346 | |
| 4347 | if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId)) |
| 4348 | == NULL) |
| 4349 | { |
| 4350 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4351 | "PE Session does not exist for given sme sessionId %d\n", |
| 4352 | pSendMgmtReq->sessionId); |
| 4353 | goto lim_tdls_send_mgmt_error; |
| 4354 | } |
| 4355 | |
| 4356 | /* check if we are in proper state to work as TDLS client */ |
| 4357 | if (psessionEntry->limSystemRole != eLIM_STA_ROLE) |
| 4358 | { |
| 4359 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4360 | "send mgmt received in wrong system Role %d\n", |
| 4361 | psessionEntry->limSystemRole); |
| 4362 | goto lim_tdls_send_mgmt_error; |
| 4363 | } |
| 4364 | |
| 4365 | /* |
| 4366 | * if we are still good, go ahead and check if we are in proper state to |
| 4367 | * do TDLS discovery req/rsp/....frames. |
| 4368 | */ |
| 4369 | if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) && |
| 4370 | (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) |
| 4371 | { |
| 4372 | |
| 4373 | limLog(pMac, LOGE, "send mgmt received in invalid LIMsme \ |
| 4374 | state (%d)\n", psessionEntry->limSmeState); |
| 4375 | goto lim_tdls_send_mgmt_error; |
| 4376 | } |
| 4377 | |
| 4378 | switch( pSendMgmtReq->reqType ) |
| 4379 | { |
| 4380 | case SIR_MAC_TDLS_DIS_REQ: |
| 4381 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 4382 | "Transmit Discovery Request Frame\n") ; |
| 4383 | /* format TDLS discovery request frame and transmit it */ |
| 4384 | limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, |
| 4385 | psessionEntry) ; |
| 4386 | resultCode = eSIR_SME_SUCCESS; |
| 4387 | break; |
| 4388 | case SIR_MAC_TDLS_DIS_RSP: |
| 4389 | { |
| 4390 | //Send a response mgmt action frame |
| 4391 | limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac, |
| 4392 | pSendMgmtReq->dialog, psessionEntry) ; |
| 4393 | resultCode = eSIR_SME_SUCCESS; |
| 4394 | } |
| 4395 | break; |
| 4396 | case SIR_MAC_TDLS_SETUP_REQ: |
| 4397 | { |
| 4398 | limSendTdlsLinkSetupReqFrame(pMac, |
| 4399 | pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, |
| 4400 | &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq))); |
| 4401 | resultCode = eSIR_SME_SUCCESS; |
| 4402 | } |
| 4403 | break; |
| 4404 | case SIR_MAC_TDLS_SETUP_RSP: |
| 4405 | { |
| 4406 | limSendTdlsSetupRspFrame(pMac, |
| 4407 | pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode, |
| 4408 | &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq))); |
| 4409 | resultCode = eSIR_SME_SUCCESS; |
| 4410 | } |
| 4411 | break; |
| 4412 | case SIR_MAC_TDLS_SETUP_CNF: |
| 4413 | { |
| 4414 | limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, |
| 4415 | psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq))); |
| 4416 | resultCode = eSIR_SME_SUCCESS; |
| 4417 | } |
| 4418 | break; |
| 4419 | case SIR_MAC_TDLS_TEARDOWN: |
| 4420 | { |
| 4421 | limSendTdlsTeardownFrame(pMac, |
| 4422 | pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, psessionEntry, |
| 4423 | &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq))); |
| 4424 | resultCode = eSIR_SME_SUCCESS; |
| 4425 | } |
| 4426 | break; |
| 4427 | case SIR_MAC_TDLS_PEER_TRAFFIC_IND: |
| 4428 | { |
| 4429 | } |
| 4430 | break; |
| 4431 | case SIR_MAC_TDLS_CH_SWITCH_REQ: |
| 4432 | { |
| 4433 | } |
| 4434 | break; |
| 4435 | case SIR_MAC_TDLS_CH_SWITCH_RSP: |
| 4436 | { |
| 4437 | } |
| 4438 | break; |
| 4439 | case SIR_MAC_TDLS_PEER_TRAFFIC_RSP: |
| 4440 | { |
| 4441 | } |
| 4442 | break; |
| 4443 | default: |
| 4444 | break; |
| 4445 | } |
| 4446 | |
| 4447 | lim_tdls_send_mgmt_error: |
| 4448 | |
| 4449 | limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP, |
| 4450 | resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId); |
| 4451 | |
| 4452 | return eSIR_SUCCESS; |
| 4453 | } |
| 4454 | |
| 4455 | /* |
| 4456 | * Once link is teardown, send Del Peer Ind to SME |
| 4457 | */ |
| 4458 | static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac, |
| 4459 | tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs, |
| 4460 | tANI_U8 status) |
| 4461 | { |
| 4462 | tSirMsgQ mmhMsg = {0} ; |
| 4463 | tSirTdlsDelStaRsp *pDelSta = NULL ; |
| 4464 | mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ; |
| 4465 | if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &pDelSta, |
| 4466 | (sizeof(tSirTdlsDelStaRsp)))) |
| 4467 | { |
| 4468 | PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));) |
| 4469 | return eSIR_FAILURE; |
| 4470 | } |
| 4471 | |
| 4472 | pDelSta->sessionId = sessionId; |
| 4473 | pDelSta->statusCode = status ; |
| 4474 | if( pStaDs ) |
| 4475 | { |
| 4476 | pDelSta->staId = pStaDs->staIndex ; |
| 4477 | } |
| 4478 | if( peerMac ) |
| 4479 | { |
| 4480 | palCopyMemory(pMac->hHdd, pDelSta->peerMac, peerMac, sizeof(tSirMacAddr)); |
| 4481 | } |
| 4482 | |
| 4483 | pDelSta->length = sizeof(tSirTdlsDelStaRsp) ; |
| 4484 | pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ; |
| 4485 | |
| 4486 | mmhMsg.bodyptr = pDelSta; |
| 4487 | |
| 4488 | mmhMsg.bodyval = 0; |
| 4489 | limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT); |
| 4490 | return eSIR_SUCCESS ; |
| 4491 | |
| 4492 | } |
| 4493 | |
| 4494 | /* |
| 4495 | * Process Send Mgmt Request from SME and transmit to AP. |
| 4496 | */ |
| 4497 | tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac, |
| 4498 | tANI_U32 *pMsgBuf) |
| 4499 | { |
| 4500 | /* get all discovery request parameters */ |
| 4501 | tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ; |
| 4502 | tpPESession psessionEntry; |
| 4503 | tANI_U8 sessionId; |
| 4504 | tLimTdlsLinkSetupPeer setupPeer = {0}; |
| 4505 | |
| 4506 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 4507 | ("Send Mgmt Recieved\n")) ; |
| 4508 | |
| 4509 | if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId)) |
| 4510 | == NULL) |
| 4511 | { |
| 4512 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4513 | "PE Session does not exist for given sme sessionId %d\n", |
| 4514 | pAddStaReq->sessionId); |
| 4515 | goto lim_tdls_add_sta_error; |
| 4516 | } |
| 4517 | |
| 4518 | /* check if we are in proper state to work as TDLS client */ |
| 4519 | if (psessionEntry->limSystemRole != eLIM_STA_ROLE) |
| 4520 | { |
| 4521 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4522 | "send mgmt received in wrong system Role %d\n", |
| 4523 | psessionEntry->limSystemRole); |
| 4524 | goto lim_tdls_add_sta_error; |
| 4525 | } |
| 4526 | |
| 4527 | /* |
| 4528 | * if we are still good, go ahead and check if we are in proper state to |
| 4529 | * do TDLS discovery req/rsp/....frames. |
| 4530 | */ |
| 4531 | if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) && |
| 4532 | (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) |
| 4533 | { |
| 4534 | |
| 4535 | limLog(pMac, LOGE, "send mgmt received in invalid LIMsme \ |
| 4536 | state (%d)\n", psessionEntry->limSmeState); |
| 4537 | goto lim_tdls_add_sta_error; |
| 4538 | } |
| 4539 | |
| 4540 | pMac->lim.gLimAddStaTdls = true ; |
| 4541 | |
| 4542 | /* To start with, send add STA request to HAL */ |
| 4543 | if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq->peerMac, |
| 4544 | &setupPeer, psessionEntry)) |
| 4545 | { |
Lee Hoonki | f987a0b | 2013-01-29 02:07:07 -0800 | [diff] [blame^] | 4546 | limLog(pMac, LOGE, "%s: Add TDLS Station request failed \n", __func__); |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 4547 | goto lim_tdls_add_sta_error; |
| 4548 | } |
| 4549 | return eSIR_SUCCESS; |
| 4550 | lim_tdls_add_sta_error: |
| 4551 | limSendSmeTdlsAddStaRsp(pMac, |
| 4552 | pAddStaReq->sessionId, pAddStaReq->peerMac, NULL, eSIR_FAILURE ); |
| 4553 | |
| 4554 | return eSIR_SUCCESS; |
| 4555 | } |
| 4556 | /* |
| 4557 | * Process Del Sta Request from SME . |
| 4558 | */ |
| 4559 | tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac, |
| 4560 | tANI_U32 *pMsgBuf) |
| 4561 | { |
| 4562 | /* get all discovery request parameters */ |
| 4563 | tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ; |
| 4564 | tpPESession psessionEntry; |
| 4565 | tANI_U8 sessionId; |
| 4566 | tpDphHashNode pStaDs = NULL ; |
| 4567 | |
| 4568 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, |
| 4569 | ("Send Mgmt Recieved\n")) ; |
| 4570 | |
| 4571 | if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId)) |
| 4572 | == NULL) |
| 4573 | { |
| 4574 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4575 | "PE Session does not exist for given sme sessionId %d\n", |
| 4576 | pDelStaReq->sessionId); |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 4577 | limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac, |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 4578 | NULL, eSIR_FAILURE) ; |
| 4579 | return eSIR_FAILURE; |
| 4580 | } |
| 4581 | |
| 4582 | /* check if we are in proper state to work as TDLS client */ |
| 4583 | if (psessionEntry->limSystemRole != eLIM_STA_ROLE) |
| 4584 | { |
| 4585 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, |
| 4586 | "Del sta received in wrong system Role %d\n", |
| 4587 | psessionEntry->limSystemRole); |
| 4588 | goto lim_tdls_del_sta_error; |
| 4589 | } |
| 4590 | |
| 4591 | /* |
| 4592 | * if we are still good, go ahead and check if we are in proper state to |
| 4593 | * do TDLS discovery req/rsp/....frames. |
| 4594 | */ |
| 4595 | if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) && |
| 4596 | (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) |
| 4597 | { |
| 4598 | |
| 4599 | limLog(pMac, LOGE, "Del Sta received in invalid LIMsme \ |
| 4600 | state (%d)\n", psessionEntry->limSmeState); |
| 4601 | goto lim_tdls_del_sta_error; |
| 4602 | } |
| 4603 | |
| 4604 | pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ; |
| 4605 | |
| 4606 | /* now send indication to SME-->HDD->TL to remove STA from TL */ |
| 4607 | |
| 4608 | if(pStaDs) |
| 4609 | { |
| 4610 | limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac, |
| 4611 | pStaDs, eSIR_SUCCESS) ; |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 4612 | |
| 4613 | limReleasePeerIdx(pMac, pStaDs->staIndex, psessionEntry) ; |
| 4614 | limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ; |
| 4615 | |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 4616 | return eSIR_SUCCESS; |
| 4617 | |
| 4618 | } |
| 4619 | |
| 4620 | lim_tdls_del_sta_error: |
| 4621 | limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac, |
| 4622 | NULL, eSIR_FAILURE) ; |
| 4623 | |
| 4624 | return eSIR_SUCCESS; |
| 4625 | } |
| 4626 | #endif |