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