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