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