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