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