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