blob: 1667a2e96bec36fb86ea6f3636dc62ec1dc01c75 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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 Lamaa8e15a2014-02-11 23:30:06 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
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 V1ccee932012-12-12 14:49:46 -080028/*===========================================================================
29
30 limProcessTdls.c
31
32 OVERVIEW:
33
34 DEPENDENCIES:
35
36 Are listed for each API below.
Kiran V1ccee932012-12-12 14:49:46 -080037===========================================================================*/
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---------- --- --------------------------------------------------------
5305/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 Lee6c6822a2013-02-06 14:10:46 -080085/* define NO_PAD_TDLS_MIN_8023_SIZE to NOT padding: See CR#447630
86There was IOT issue with cisco 1252 open mode, where it pads
87discovery req/teardown frame with some junk value up to min size.
88To avoid this issue, we pad QCOM_VENDOR_IE.
89If 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 V1ccee932012-12-12 14:49:46 -080095
Agarwal Ashishb4891ef2014-11-10 20:08:36 +053096
Kiran V1ccee932012-12-12 14:49:46 -080097#ifdef FEATURE_WLAN_TDLS_INTERNAL
98/* forword declarations */
99static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
100 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) ;
101static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
102 tSirMacAddr peerMac, tANI_U8 status);
103static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
104 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) ;
105static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
106 tANI_U8 state);
107static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
108 tLimTdlsLinkSetupPeer **setupPeer) ;
109static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
110
111static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
112static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
113 tpPESession psessionEntry) ;
114
115#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800116static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
117 tSirTdlsAddStaReq *pAddStaReq,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530118 tpPESession psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800119void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
120 tDot11fIELinkIdentifier *linkIden,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530121 tSirMacAddr peerMac, tANI_U8 reqType) ;
Kiran V1ccee932012-12-12 14:49:46 -0800122void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
123 tDot11fIEExtCap *extCapability) ;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800124
Naresh Jayarambc62ba42014-02-12 21:39:14 +0530125void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
126 tpPESession psessionEntry,
127 tDot11fIESuppChannels *suppChannels,
128 tDot11fIESuppOperatingClasses *suppOperClasses);
129
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800130void limLogVHTCap(tpAniSirGlobal pMac,
131 tDot11fIEVHTCaps *pDot11f);
132tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
133 tpSirSupportedRates pRates,
134 tDot11fIEVHTCaps *pPeerVHTCaps,
135 tpPESession psessionEntry);
136ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode);
Atul Mittalb849d5a2014-07-29 12:08:39 +0530137/*only 31 op classes are available, 1 entry for current op class*/
138static tDot11fIESuppOperatingClasses op_classes = {0};
139
140op_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 POTTETIe8bd41a2015-01-29 14:52:43 +0530157 {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 Mittalb849d5a2014-07-29 12:08:39 +0530160 {0, 0, 0, {0}},
161
162};/*end global_op_class*/
163
164op_class_map_t us_op_class[] = {
165 {1, 20, BW20, {36, 40, 44, 48}},
166 {2, 20, BW20, {52, 56, 60, 64}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530167 {4, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530168 {5, 20, BW20, {149, 153, 157, 161, 165}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530169 {12, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530170 {22, 40, BW40PLUS, {36, 44}},
171 {23, 40, BW40PLUS, {52, 60}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530172 {24, 40, BW40PLUS, {100, 108, 116, 124, 132, 140}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530173 {26, 40, BW40PLUS, {149, 157}},
174 {27, 40, BW40MINUS, {40, 48}},
175 {28, 40, BW40MINUS, {56, 64}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530176 {29, 40, BW40MINUS, {104, 112, 120, 128, 136, 144}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530177 {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 POTTETIe8bd41a2015-01-29 14:52:43 +0530180 {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 Mittalb849d5a2014-07-29 12:08:39 +0530183 {0, 0, 0, {0}},
184};/*end us_op_class*/
185
186op_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 POTTETIe8bd41a2015-01-29 14:52:43 +0530200 {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
201 116, 120, 124, 128}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530202 {0, 0, 0, {0}},
203};/*end euro_op_class*/
204
205op_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 POTTETIe8bd41a2015-01-29 14:52:43 +0530217 {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
218 116, 120, 124, 128}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530219 {0, 0, 0, {0}},
220};/*end japan_op_class*/
221
Kiran V1ccee932012-12-12 14:49:46 -0800222/*
223 * TDLS data frames will go out/come in as non-qos data.
224 * so, eth_890d_header will be aligned access..
225 */
226static 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 */
235enum tdlsLinks
236{
237 TDLS_LINK_AP,
238 TDLS_LINK_DIRECT
239} eTdlsLink ;
240
241/*
242 * node status in node searching
243 */
244enum tdlsLinkNodeStatus
245{
246 TDLS_NODE_NOT_FOUND,
247 TDLS_NODE_FOUND
248} eTdlsLinkNodeStatus ;
249
250
251enum tdlsReqType
252{
253 TDLS_INITIATOR,
254 TDLS_RESPONDER
255} eTdlsReqType ;
256
257typedef enum tdlsLinkSetupStatus
258{
259 TDLS_SETUP_STATUS_SUCCESS = 0,
260 TDLS_SETUP_STATUS_FAILURE = 37
261}etdlsLinkSetupStatus ;
262
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +0530263/* These maps to Kernel TDLS peer capability
264 * flags and should get changed as and when necessary
265 */
266enum 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 V1ccee932012-12-12 14:49:46 -0800272/* 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 Lee93e67ff2013-03-19 15:49:25 -0700284#define PEER_BUFFER_STA_SUPPORT (0)
Kiran V1ccee932012-12-12 14:49:46 -0800285#define CH_SWITCH_SUPPORT (0)
286#define TDLS_SUPPORT (1)
287#define TDLS_PROHIBITED (0)
288#define TDLS_CH_SWITCH_PROHIBITED (1)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800289/** @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 V1ccee932012-12-12 14:49:46 -0800308
309#ifdef LIM_DEBUG_TDLS
Kiran V1ccee932012-12-12 14:49:46 -0800310
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 Nakkala0f3eb5c2013-05-07 16:48:38 +0530317#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 V1ccee932012-12-12 14:49:46 -0800325const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
326{
327 switch( tdlsActionCode )
328 {
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530329 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 V1ccee932012-12-12 14:49:46 -0800339 }
340 return (const tANI_U8*)"UNKNOWN";
341}
342#endif
343#if 0
344static 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 Lokere531ca702013-04-01 13:24:23 -0700354 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (""));
Kiran V1ccee932012-12-12 14:49:46 -0800355 return ;
356}
357#endif
Kiran V1ccee932012-12-12 14:49:46 -0800358/*
359 * initialize TDLS setup list and related data structures.
360 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800361void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800362{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800363#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800364 pMac->lim.gLimTdlsDisResultList = NULL ;
365 pMac->lim.gLimTdlsDisStaCount = 0 ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530366 vos_mem_set(&pMac->lim.gLimTdlsDisReq, sizeof(tSirTdlsDisReq), 0);
367 vos_mem_set(&pMac->lim.gLimTdlsLinkSetupInfo, sizeof(tLimTdlsLinkSetupInfo), 0);
Kiran V1ccee932012-12-12 14:49:46 -0800368 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 Nakkala777e6032012-12-31 16:39:21 -0800375#endif
376 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800377
378 return ;
379}
Kiran V1ccee932012-12-12 14:49:46 -0800380#ifdef FEATURE_WLAN_TDLS_NEGATIVE
381void 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 Johnson0f4d0bc2013-11-03 17:48:50 -0800395 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("%d %d -> gLimTdlsNegativeBehavior= 0x%lx"),
Kiran V1ccee932012-12-12 14:49:46 -0800396 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 */
404static 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530434 vos_mem_copy( (tANI_U8 *) pMacHdr->da, peerMac, sizeof( tSirMacAddr ));
435 vos_mem_copy( (tANI_U8 *) pMacHdr->sa,
Kiran V1ccee932012-12-12 14:49:46 -0800436 staMac, sizeof( tSirMacAddr ));
437
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530438 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Kiran V1ccee932012-12-12 14:49:46 -0800439 bssid, sizeof( tSirMacAddr ));
440
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800441 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 V1ccee932012-12-12 14:49:46 -0800445 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 */
456static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530457 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType,
458 tANI_U8 tid, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800459{
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530460 tpSirMacDataHdr3a pMacHdr ;
Kiran V1ccee932012-12-12 14:49:46 -0800461 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 Nakkala0f3eb5c2013-05-07 16:48:38 +0530471 pMacHdr = (tpSirMacDataHdr3a) (pFrame);
Kiran V1ccee932012-12-12 14:49:46 -0800472
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 Nakkala0f3eb5c2013-05-07 16:48:38 +0530487 pMacHdr->fc.subType = IS_QOS_ENABLED(psessionEntry) ? SIR_MAC_DATA_QOS_DATA : SIR_MAC_DATA_DATA;
488
Kiran V1ccee932012-12-12 14:49:46 -0800489 /*
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530497 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 V1ccee932012-12-12 14:49:46 -0800503
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530504 vos_mem_copy( (tANI_U8 *) pMacHdr->addr3,
505 (tANI_U8 *) (addr3),
506 sizeof( tSirMacAddr ));
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530507
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530508 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 V1ccee932012-12-12 14:49:46 -0800514
515 //printMacAddr(pMacHdr->bssId) ;
516 //printMacAddr(pMacHdr->sa) ;
517 //printMacAddr(pMacHdr->da) ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530518
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 V1ccee932012-12-12 14:49:46 -0800527 /*
528 * Now form RFC1042 header
529 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530530 vos_mem_copy((tANI_U8 *)(pFrame + header_offset),
531 (tANI_U8 *)eth_890d_header, sizeof(eth_890d_header)) ;
Kiran V1ccee932012-12-12 14:49:46 -0800532
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 Nakkalab977a972013-02-18 19:15:09 -0800542 * 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 Ahujab3a1a152014-11-11 22:14:10 +0530554 limLog(pMac, LOGE, FL("sessionID %d is not found"),
555 pMac->lim.mgmtFrameSessionId);
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800556 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 V1ccee932012-12-12 14:49:46 -0800565 * 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 */
568tSirRetStatus 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 Lee6c6822a2013-02-06 14:10:46 -0800580#ifndef NO_PAD_TDLS_MIN_8023_SIZE
581 tANI_U32 padLen = 0;
582#endif
Kiran V1ccee932012-12-12 14:49:46 -0800583
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530589 vos_mem_set( (tANI_U8*)&tdlsDisReq,
590 sizeof( tDot11fTDLSDisReq ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800591
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 Ahujab3a1a152014-11-11 22:14:10 +0530611 limLog(pMac, LOGE,
612 FL("Failed to calculate the packed size for a discovery Request (0x%08x)."),
613 status);
Kiran V1ccee932012-12-12 14:49:46 -0800614 /* We'll fall back on the worst case scenario: */
615 nPayload = sizeof( tDot11fTDLSDisReq );
616 }
617 else if ( DOT11F_WARNED( status ) )
618 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530619 limLog(pMac, LOGW,
620 FL("There were warnings while calculating the packed size for a discovery Request (0x%08x)."),
621 status);
Kiran V1ccee932012-12-12 14:49:46 -0800622 }
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 Nakkala0f3eb5c2013-05-07 16:48:38 +0530631 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
632 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
633 + sizeof( eth_890d_header )
634 + PAYLOAD_TYPE_TDLS_SIZE ;
Kiran V1ccee932012-12-12 14:49:46 -0800635
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800636#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 V1ccee932012-12-12 14:49:46 -0800653 /* 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 Ahujab3a1a152014-11-11 22:14:10 +0530660 limLog(pMac, LOGE,
661 FL("Failed to allocate %d bytes for a TDLS Discovery Request."),
662 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -0800663 return eSIR_MEM_ALLOC_FAILED;
664 }
665
666 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530667 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800668
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 Nakkala0f3eb5c2013-05-07 16:48:38 +0530677 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800678
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 Hussain24bafea2013-11-15 15:10:03 -0800685 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Req"),
686 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800687 }
688#endif
689 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
690 + header_offset, nPayload, &nPayload );
691
692 if ( DOT11F_FAILED( status ) )
693 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530694 limLog(pMac, LOGE, FL("Failed to pack a TDLS discovery req (0x%08x)."),
695 status);
Kiran V1ccee932012-12-12 14:49:46 -0800696 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 Ahujab3a1a152014-11-11 22:14:10 +0530702 limLog(pMac, LOGW, FL("There were warnings while packing TDLS Discovery Request (0x%08x)."),
703 status);
Kiran V1ccee932012-12-12 14:49:46 -0800704 }
705
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800706#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 Ahujab3a1a152014-11-11 22:14:10 +0530718 limLog(pMac, LOG1, FL("Padding Vendor Specific Ie Len = %d"), padLen);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800719
720 /* padding zero if more than 5 bytes are required */
721 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530722 vos_mem_set( pFrame + header_offset + nPayload + MIN_VENDOR_SPECIFIC_IE_SIZE,
723 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800724 }
725#endif
Kiran V1ccee932012-12-12 14:49:46 -0800726
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530727 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 V1ccee932012-12-12 14:49:46 -0800732
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800733 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -0800734 HAL_TXRX_FRM_802_11_DATA,
735 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530736 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800737 limTxComplete, pFrame,
738 limMgmtTXComplete,
739 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME);
Kiran V1ccee932012-12-12 14:49:46 -0800740 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
741 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800742 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530743 limLog(pMac, LOGE, FL("could not send TDLS Discovery Request frame"));
Kiran V1ccee932012-12-12 14:49:46 -0800744 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -0800745 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800746 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -0800747
748 return eSIR_SUCCESS;
749
750}
751
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800752#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800753/*
754 * Once Discovery response is sent successfully (or failure) on air, now send
755 * response to PE and send del STA to HAL.
756 */
757eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac,
758 tANI_U32 txCompleteSuccess)
759{
760 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800761 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 Lokere531ca702013-04-01 13:24:23 -0700770 ("DisRspTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800771 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 Lokere531ca702013-04-01 13:24:23 -0700787 ("DisRspTxComplete: sessionID %d is not found"), peerInfo->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800788 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 Hussain24bafea2013-11-15 15:10:03 -0800802 ("DisRspTxComplete: staDs not found for " MAC_ADDRESS_STR),
803 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800804 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 V1ccee932012-12-12 14:49:46 -0800826 return status ;
827
828}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800829#endif
830
831#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800832/*
833 * Once setup CNF is sent successfully (or failure) on air, now send
834 * response to PE and send del STA to HAL.
835 */
836eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
837 tANI_U32 txCompleteSuccess)
838{
839 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800840 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 Lokere531ca702013-04-01 13:24:23 -0700848 ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800849 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 Hussain24bafea2013-11-15 15:10:03 -0800867 ("RSP-->SME peer MAC = " MAC_ADDRESS_STR),
868 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800869
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 V1ccee932012-12-12 14:49:46 -0800881 return status ;
Kiran V1ccee932012-12-12 14:49:46 -0800882}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800883#endif
Kiran V1ccee932012-12-12 14:49:46 -0800884
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800885#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800886/*
887 * Tx Complete for Teardown frame
888 */
889eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
890 tANI_U32 txCompleteSuccess)
891{
892 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800893 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 Lokere531ca702013-04-01 13:24:23 -0700906 ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800907 VOS_ASSERT(0) ;
908 return eHAL_STATUS_FAILURE;
909 }
910
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530911 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800912 ("teardown peer Mac = " MAC_ADDRESS_STR),
913 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800914
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 Lokere531ca702013-04-01 13:24:23 -0700923 ("limTdlsTeardownTxComplete: sessionID %d is not found"), (peerInfo)->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800924 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 Lokere531ca702013-04-01 13:24:23 -0700931 ("TX complete failure for Teardown ")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800932
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 Lokere531ca702013-04-01 13:24:23 -0700969 ("TX complete SUCCESS for Teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800970 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700971 ("Prev State = %d"), (peerInfo)->tdls_prev_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -0800972 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 V1ccee932012-12-12 14:49:46 -0800996 return status ;
997}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800998#endif
Kiran V1ccee932012-12-12 14:49:46 -0800999
1000/*
Kiet Lam770920c2013-10-21 12:49:30 +05301001 * 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 */
1005static 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 Kondabattinib554d292015-02-11 14:37:25 +05301013 /* 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 Lam770920c2013-10-21 12:49:30 +05301026 htCap->present = 1;
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05301027 htCap->supportedChannelWidthSet = 1; // hardcode it to max
Kiet Lam770920c2013-10-21 12:49:30 +05301028 }
1029 else
1030 {
1031 htCap->present = 0;
1032 }
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05301033 limLog(pMac, LOG1, FL("HT present = %hu, Chan Width = %hu"),
1034 htCap->present, htCap->supportedChannelWidthSet);
Kiet Lam770920c2013-10-21 12:49:30 +05301035#ifdef WLAN_FEATURE_11AC
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05301036 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1037 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
Kiet Lam770920c2013-10-21 12:49:30 +05301038 {
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05301039 /* Include VHT Capability IE */
1040 PopulateDot11fVHTCaps( pMac, vhtCap, eSIR_FALSE );
Kiet Lam770920c2013-10-21 12:49:30 +05301041 }
1042 else
1043 {
Kiet Lam770920c2013-10-21 12:49:30 +05301044 vhtCap->present = 0;
1045 }
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05301046 limLog(pMac, LOG1, FL("VHT present = %hu"),
1047 vhtCap->present);
Kiet Lam770920c2013-10-21 12:49:30 +05301048#endif
1049}
1050
1051/*
Kiran V1ccee932012-12-12 14:49:46 -08001052 * Send TDLS discovery response frame on direct link.
1053 */
1054
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05301055static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
1056 tSirMacAddr peerMac, tANI_U8 dialog,
1057 tpPESession psessionEntry, tANI_U8 *addIe,
1058 tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001059{
1060 tDot11fTDLSDisRsp tdlsDisRsp ;
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301061 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001062 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 Lee4ef946b2013-04-25 18:40:20 -07001068 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 V1ccee932012-12-12 14:49:46 -08001074
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301075 /*
Kiran V1ccee932012-12-12 14:49:46 -08001076 * 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301080 vos_mem_set( ( tANI_U8* )&tdlsDisRsp,
1081 sizeof( tDot11fTDLSDisRsp ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001082
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, Narayanraddi4b359dd2015-02-03 15:49:29 +05301090 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
Kiran V1ccee932012-12-12 14:49:46 -08001091 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 Ahujab3a1a152014-11-11 22:14:10 +05301099 limLog(pMac, LOGP, FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001100 }
1101 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
1102
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301103 /* 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 V1ccee932012-12-12 14:49:46 -08001107
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301108 /* Populate extended capability IE */
Kiran V1ccee932012-12-12 14:49:46 -08001109 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
1110
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001111 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1112
Kiet Lam770920c2013-10-21 12:49:30 +05301113 /* Populate HT/VHT Capabilities */
1114 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsDisRsp.HTCaps,
1115 &tdlsDisRsp.VHTCaps, psessionEntry );
Kiran V1ccee932012-12-12 14:49:46 -08001116
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301117 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1118 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1119 &tdlsDisRsp.SuppChannels,
1120 &tdlsDisRsp.SuppOperatingClasses);
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301121
Agarwal Ashish81775962014-11-12 14:56:07 +05301122 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
1123 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24) )
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301124 {
1125 tdlsDisRsp.HT2040BSSCoexistence.present = 1;
1126 tdlsDisRsp.HT2040BSSCoexistence.infoRequest = 1;
1127 }
Kiran V1ccee932012-12-12 14:49:46 -08001128 /*
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 Ahujab3a1a152014-11-11 22:14:10 +05301134 limLog(pMac, LOGE,
1135 FL("Failed to calculate the packed size for a Discovery Response (0x%08x)."),
1136 status);
Kiran V1ccee932012-12-12 14:49:46 -08001137 /* We'll fall back on the worst case scenario: */
1138 nPayload = sizeof( tDot11fProbeRequest );
1139 }
1140 else if ( DOT11F_WARNED( status ) )
1141 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301142 limLog(pMac, LOGW,
1143 FL("There were warnings while calculating the packed size for a Discovery Response (0x%08x)."),
1144 status);
Kiran V1ccee932012-12-12 14:49:46 -08001145 }
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 Saptasagar53e9c1f2014-09-23 17:55:48 +05301154 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001155
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 Ahujab3a1a152014-11-11 22:14:10 +05301163 limLog(pMac, LOGE,
1164 FL("Failed to allocate %d bytes for a TDLS Discovery Response."),
1165 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001166 return eSIR_MEM_ALLOC_FAILED;
1167 }
1168
1169 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301170 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001171
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 Hussain24bafea2013-11-15 15:10:03 -08001201 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Rsp"),
1202 MAC_ADDR_ARRAY(tdlsDisRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001203 }
1204#endif
1205 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
1206 sizeof( tSirMacMgmtHdr ),
1207 nPayload, &nPayload );
1208
1209 if ( DOT11F_FAILED( status ) )
1210 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301211 limLog( pMac, LOGE,
1212 FL("Failed to pack a TDLS Discovery Response (0x%08x)."),
1213 status);
Kiran V1ccee932012-12-12 14:49:46 -08001214 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 Ahujab3a1a152014-11-11 22:14:10 +05301220 limLog( pMac, LOGW,
1221 FL("There were warnings while packing TDLS Discovery Request (0x%08x)."),
1222 status);
Kiran V1ccee932012-12-12 14:49:46 -08001223 }
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 Saptasagar53e9c1f2014-09-23 17:55:48 +05301238 if (0 != addIeLen)
1239 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301240 limLog(pMac, LOG1, FL("Copy Additional Ie Len = %d"), addIeLen);
Mahesh A Saptasagar53e9c1f2014-09-23 17:55:48 +05301241 vos_mem_copy(pFrame + sizeof(tSirMacMgmtHdr) + nPayload, addIe,
1242 addIeLen);
1243 }
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301244 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 V1ccee932012-12-12 14:49:46 -08001249
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 Nakkalab977a972013-02-18 19:15:09 -08001259 limMgmtTXComplete,
Kiran V1ccee932012-12-12 14:49:46 -08001260 HAL_USE_SELF_STA_REQUESTED_MASK );
1261 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1262 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001263 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301264 limLog(pMac, LOGE, FL("could not send TDLS Discovery Response frame!"));
Kiran V1ccee932012-12-12 14:49:46 -08001265 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001266 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001267 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001268
1269 return eSIR_SUCCESS;
1270
1271}
1272
1273/*
Kiet Lam770920c2013-10-21 12:49:30 +05301274 * This static function is currently used by limSendTdlsLinkSetupReqFrame and
1275 * limSendTdlsSetupRspFrame to populate the AID if device is 11ac capable.
1276 */
1277static 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 Ahujab3a1a152014-11-11 22:14:10 +05301301 limLog(pMac, LOGE, FL("pStaDs is NULL for " MAC_ADDRESS_STR),
1302 MAC_ADDR_ARRAY(peerMac));
Kiet Lam770920c2013-10-21 12:49:30 +05301303 }
1304 }
1305 }
1306 else
1307 {
1308 Aid->present = 0;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301309 limLog(pMac, LOGW, FL("Vht not enable from ini for 2.4GHz."));
Kiet Lam770920c2013-10-21 12:49:30 +05301310 }
1311}
1312
1313/*
Kiran V1ccee932012-12-12 14:49:46 -08001314 * TDLS setup Request frame on AP link
1315 */
1316
1317tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1318 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301319 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001320{
1321 tDot11fTDLSSetupReq tdlsSetupReq ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301322 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001323 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 Lee4ef946b2013-04-25 18:40:20 -07001330 uint32 selfDot11Mode;
Agarwal Ashish16020c42014-12-29 22:01:11 +05301331 tpSirMacCapabilityInfo pCapInfo;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001332// 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 V1ccee932012-12-12 14:49:46 -08001337
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301338 /*
Kiran V1ccee932012-12-12 14:49:46 -08001339 * 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301343 vos_mem_set(( tANI_U8* )&tdlsSetupReq, sizeof( tDot11fTDLSSetupReq ), 0);
Kiran V1ccee932012-12-12 14:49:46 -08001344 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 Ahujab3a1a152014-11-11 22:14:10 +05301358 limLog(pMac, LOGE, FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001359 }
Agarwal Ashish16020c42014-12-29 22:01:11 +05301360
1361 pCapInfo = (tpSirMacCapabilityInfo) &caps;
1362 /* Export QOS capability */
1363 pCapInfo->qos = 1;
1364
Kiran V1ccee932012-12-12 14:49:46 -08001365 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1366
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301367 /* populate supported rate and ext supported rate IE */
1368 PopulateDot11fRatesTdls(pMac, &tdlsSetupReq.SuppRates,
1369 &tdlsSetupReq.ExtSuppRates);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301370
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301371 /* Populate extended capability IE */
Kiran V1ccee932012-12-12 14:49:46 -08001372 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1373
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301374 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 Ahujab3a1a152014-11-11 22:14:10 +05301390 limLog(pMac, LOG1, FL("populate QOS IE in Setup Request Frame"));
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301391 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 Nakkala79ff85d2013-05-27 17:05:29 +05301399
Kiran V1ccee932012-12-12 14:49:46 -08001400 /*
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 Lee4ef946b2013-04-25 18:40:20 -07001406 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1407
Kiet Lam770920c2013-10-21 12:49:30 +05301408 /* Populate HT/VHT Capabilities */
1409 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupReq.HTCaps,
1410 &tdlsSetupReq.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001411
Kiet Lam770920c2013-10-21 12:49:30 +05301412 /* Populate AID */
1413 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1414 &tdlsSetupReq.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001415
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301416 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1417 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1418 &tdlsSetupReq.SuppChannels,
1419 &tdlsSetupReq.SuppOperatingClasses);
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301420
Agarwal Ashish81775962014-11-12 14:56:07 +05301421 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
1422 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24))
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301423 {
1424 tdlsSetupReq.HT2040BSSCoexistence.present = 1;
1425 tdlsSetupReq.HT2040BSSCoexistence.infoRequest = 1;
1426 }
1427
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301428 /*
Kiran V1ccee932012-12-12 14:49:46 -08001429 * now we pack it. First, how much space are we going to need?
1430 */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301431 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
Kiran V1ccee932012-12-12 14:49:46 -08001432 &nPayload);
1433 if ( DOT11F_FAILED( status ) )
1434 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301435 limLog(pMac, LOGE,
1436 FL("Failed to calculate the packed size for a Setup Request (0x%08x)."),
1437 status);
Kiran V1ccee932012-12-12 14:49:46 -08001438 /* We'll fall back on the worst case scenario: */
1439 nPayload = sizeof( tDot11fProbeRequest );
1440 }
1441 else if ( DOT11F_WARNED( status ) )
1442 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301443 limLog(pMac, LOGW,
1444 FL("There were warnings while calculating the packed size for a Setup Request (0x%08x)."),
1445 status);
Kiran V1ccee932012-12-12 14:49:46 -08001446 }
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 Nakkala79ff85d2013-05-27 17:05:29 +05301453 */
Kiran V1ccee932012-12-12 14:49:46 -08001454
1455
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301456 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1457 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1458 + sizeof( eth_890d_header )
1459 + PAYLOAD_TYPE_TDLS_SIZE
1460 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001461
1462 /* Ok-- try to allocate memory from MGMT PKT pool */
1463
1464 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301465 ( tANI_U16 )nBytes, ( void** ) &pFrame,
Kiran V1ccee932012-12-12 14:49:46 -08001466 ( void** ) &pPacket );
1467 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1468 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301469 limLog(pMac, LOGE,
1470 FL("Failed to allocate %d bytes for a TDLS Setup Request."),
1471 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001472 return eSIR_MEM_ALLOC_FAILED;
1473 }
1474
1475 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301476 vos_mem_set( pFrame, nBytes, 0);
Kiran V1ccee932012-12-12 14:49:46 -08001477
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301478 /*
Kiran V1ccee932012-12-12 14:49:46 -08001479 * IE formation, memory allocation is completed, Now form TDLS discovery
1480 * request frame
1481 */
1482
1483 /* fill out the buffer descriptor */
1484
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301485 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301486 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001487
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 Nakkala79ff85d2013-05-27 17:05:29 +05301492 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1493 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001494 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Req"),
1495 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001496 }
1497#endif
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301498 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 Nakkalae7cbc5d2013-03-27 21:09:23 -07001503
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301504 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001505 + header_offset, nPayload, &nPayload );
1506
1507 if ( DOT11F_FAILED( status ) )
1508 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301509 limLog(pMac, LOGE,
1510 FL("Failed to pack a TDLS Setup Request (0x%08x)."),
1511 status);
Kiran V1ccee932012-12-12 14:49:46 -08001512 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 Ahujab3a1a152014-11-11 22:14:10 +05301518 limLog(pMac, LOGW,
1519 FL("There were warnings while packing TDLS Setup Request (0x%08x)."),
1520 status);
Kiran V1ccee932012-12-12 14:49:46 -08001521 }
1522
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301523 //Copy the additional IE.
Kiran V1ccee932012-12-12 14:49:46 -08001524 //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 Ahujab3a1a152014-11-11 22:14:10 +05301529 limLog(pMac, LOG1, FL("Copy Additional Ie Len = %d"),
1530 addIeLen);
1531 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001532 }
1533
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301534 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 V1ccee932012-12-12 14:49:46 -08001538
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001539 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001540 HAL_TXRX_FRM_802_11_DATA,
1541 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301542 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001543 limTxComplete, pFrame,
1544 limMgmtTXComplete,
1545 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
1546
Kiran V1ccee932012-12-12 14:49:46 -08001547 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1548 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001549 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301550 limLog(pMac, LOGE, FL("could not send TDLS Setup Request frame!"));
Kiran V1ccee932012-12-12 14:49:46 -08001551 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001552 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001553 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001554
1555 return eSIR_SUCCESS;
1556
1557}
1558/*
1559 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1560 */
1561
1562tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08001563 tSirMacAddr peerMac, tANI_U16 reason, tANI_U8 responder, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301564 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001565{
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 Lee6c6822a2013-02-06 14:10:46 -08001574#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1575 tANI_U32 padLen = 0;
1576#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301577 /*
Kiran V1ccee932012-12-12 14:49:46 -08001578 * 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301582 vos_mem_set( ( tANI_U8* )&teardown, sizeof( tDot11fTDLSTeardown ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001583 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1584 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1585 teardown.Reason.code = reason ;
1586
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301587 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
Hoonki Leea34dd892013-02-05 22:56:02 -08001588 peerMac, (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301589 /*
Kiran V1ccee932012-12-12 14:49:46 -08001590 * 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 Ahujab3a1a152014-11-11 22:14:10 +05301595 limLog(pMac, LOGE,
1596 FL("Failed to calculate the packed size for Teardown frame (0x%08x)."),
1597 status);
Kiran V1ccee932012-12-12 14:49:46 -08001598 /* We'll fall back on the worst case scenario: */
1599 nPayload = sizeof( tDot11fProbeRequest );
1600 }
1601 else if ( DOT11F_WARNED( status ) )
1602 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301603 limLog(pMac, LOGW,
1604 FL("There were warnings while calculating the packed size for Teardown frame (0x%08x)."),
1605 status);
Kiran V1ccee932012-12-12 14:49:46 -08001606 }
Kiran V1ccee932012-12-12 14:49:46 -08001607 /*
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 Nakkala79ff85d2013-05-27 17:05:29 +05301611 */
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301612 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1613 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1614 + sizeof( eth_890d_header )
1615 + PAYLOAD_TYPE_TDLS_SIZE
1616 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001617
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001618#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 V1ccee932012-12-12 14:49:46 -08001635 /* 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 Ahujab3a1a152014-11-11 22:14:10 +05301642 limLog(pMac, LOGE,
1643 FL("Failed to allocate %d bytes for a TDLS Teardown Frame."),
1644 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001645 return eSIR_MEM_ALLOC_FAILED;
1646 }
1647
1648 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301649 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001650
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301651 /*
Kiran V1ccee932012-12-12 14:49:46 -08001652 * IE formation, memory allocation is completed, Now form TDLS discovery
1653 * request frame
1654 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301655 limLog(pMac, LOGE, FL("Reason of TDLS Teardown: %d"), reason);
Kiran V1ccee932012-12-12 14:49:46 -08001656 /* fill out the buffer descriptor */
1657
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301658 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1659 LINK_IDEN_ADDR_OFFSET(teardown),
1660 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
Gopichand Nakkala269032c2013-02-07 17:18:15 -08001661 ? TDLS_LINK_AP : TDLS_LINK_DIRECT,
1662 (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301663 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001664
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301665 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001666 + header_offset, nPayload, &nPayload );
1667
1668 if ( DOT11F_FAILED( status ) )
1669 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001670 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req (0x%08x)."),
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301671 status);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301672 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Kiran V1ccee932012-12-12 14:49:46 -08001673 ( void* ) pFrame, ( void* ) pPacket );
1674 return eSIR_FAILURE;
1675 }
1676 else if ( DOT11F_WARNED( status ) )
1677 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301678 limLog(pMac, LOGW, FL("There were warnings while packing TDLS Teardown frame (0x%08x)."),
1679 status);
Kiran V1ccee932012-12-12 14:49:46 -08001680 }
1681#if 0
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301682 if(pMac->hal.pCBackFnTxComp == NULL)
Kiran V1ccee932012-12-12 14:49:46 -08001683 {
1684 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301685 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
Kiran V1ccee932012-12-12 14:49:46 -08001686 {
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 Nakkala79ff85d2013-05-27 17:05:29 +05301698
Kiran V1ccee932012-12-12 14:49:46 -08001699 if( addIeLen != 0 )
1700 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301701 limLog(pMac, LOG1, FL("Copy Additional Ie Len = %d"), addIeLen);
1702 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001703 }
1704
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001705#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 Ahujab3a1a152014-11-11 22:14:10 +05301717 limLog(pMac, LOG1, FL("Padding Vendor Specific Ie Len = %d"), padLen);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001718
1719 /* padding zero if more than 5 bytes are required */
1720 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301721 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
1722 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001723 }
1724#endif
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301725 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 V1ccee932012-12-12 14:49:46 -08001731
1732 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1733 HAL_TXRX_FRM_802_11_DATA,
1734 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301735 TID_AC_VI,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301736 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001737 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08001738 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001739 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1740 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001741 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301742 limLog(pMac, LOGE, FL("could not send TDLS Teardown frame"));
Kiran V1ccee932012-12-12 14:49:46 -08001743 return eSIR_FAILURE;
1744
1745 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001746 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001747 return eSIR_SUCCESS;
1748
1749}
1750
1751/*
1752 * Send Setup RSP frame on AP link.
1753 */
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301754static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1755 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08001756 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1757{
1758 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1759 tANI_U32 status = 0 ;
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301760 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001761 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 Lee4ef946b2013-04-25 18:40:20 -07001767 uint32 selfDot11Mode;
Agarwal Ashish16020c42014-12-29 22:01:11 +05301768 tpSirMacCapabilityInfo pCapInfo;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001769// 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 V1ccee932012-12-12 14:49:46 -08001774
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301775 /*
Kiran V1ccee932012-12-12 14:49:46 -08001776 * 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301780 vos_mem_set( ( tANI_U8* )&tdlsSetupRsp, sizeof( tDot11fTDLSSetupRsp ),0 );
Kiran V1ccee932012-12-12 14:49:46 -08001781
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 Ahujab3a1a152014-11-11 22:14:10 +05301798 limLog(pMac, LOGE, FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001799 }
Agarwal Ashish16020c42014-12-29 22:01:11 +05301800
1801 pCapInfo = (tpSirMacCapabilityInfo) &caps;
1802 /* Export QoS capability */
1803 pCapInfo->qos = 1;
1804
Kiran V1ccee932012-12-12 14:49:46 -08001805 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1806
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301807 /* populate supported rate and ext supported rate IE */
1808 PopulateDot11fRatesTdls(pMac, &tdlsSetupRsp.SuppRates,
1809 &tdlsSetupRsp.ExtSuppRates);
Kiran V1ccee932012-12-12 14:49:46 -08001810
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301811 /* Populate extended capability IE */
Kiran V1ccee932012-12-12 14:49:46 -08001812 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1813
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301814 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 Ahujab3a1a152014-11-11 22:14:10 +05301830 limLog(pMac, LOG1, FL("populate QOS IE in Setup Response frame"));
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301831 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 V1ccee932012-12-12 14:49:46 -08001839
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001840 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1841
Kiet Lam770920c2013-10-21 12:49:30 +05301842 /* Populate HT/VHT Capabilities */
1843 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupRsp.HTCaps,
1844 &tdlsSetupRsp.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001845
Kiet Lam770920c2013-10-21 12:49:30 +05301846 /* Populate AID */
1847 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1848 &tdlsSetupRsp.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001849
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301850 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1851 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1852 &tdlsSetupRsp.SuppChannels,
1853 &tdlsSetupRsp.SuppOperatingClasses);
1854
Kiran V1ccee932012-12-12 14:49:46 -08001855 tdlsSetupRsp.Status.status = setupStatus ;
1856
Agarwal Ashish81775962014-11-12 14:56:07 +05301857 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
1858 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24))
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301859 {
1860 tdlsSetupRsp.HT2040BSSCoexistence.present = 1;
1861 tdlsSetupRsp.HT2040BSSCoexistence.infoRequest = 1;
1862 }
Kiran V1ccee932012-12-12 14:49:46 -08001863 /*
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 Ahujab3a1a152014-11-11 22:14:10 +05301870 limLog(pMac, LOGE,
1871 FL("Failed to calculate the packed size for a Setup Response (0x%08x)."),
1872 status);
Kiran V1ccee932012-12-12 14:49:46 -08001873 /* We'll fall back on the worst case scenario: */
1874 nPayload = sizeof( tDot11fProbeRequest );
1875 }
1876 else if ( DOT11F_WARNED( status ) )
1877 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301878 limLog(pMac, LOGW,
1879 FL("There were warnings while calculating the packed size for Setup Response (0x%08x)."),
1880 status);
Kiran V1ccee932012-12-12 14:49:46 -08001881 }
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 Nakkala0f3eb5c2013-05-07 16:48:38 +05301890 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1891 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1892 + sizeof( eth_890d_header )
1893 + PAYLOAD_TYPE_TDLS_SIZE
1894 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001895
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 Ahujab3a1a152014-11-11 22:14:10 +05301903 limLog(pMac, LOGE,
1904 FL("Failed to allocate %d bytes for a TDLS Setup Response."),
1905 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001906 return eSIR_MEM_ALLOC_FAILED;
1907 }
1908
1909 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301910 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001911
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 Nakkala0f3eb5c2013-05-07 16:48:38 +05301922 TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001923
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 Hussain24bafea2013-11-15 15:10:03 -08001930 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Rsp"),
1931 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001932 }
1933#endif
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301934 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 V1ccee932012-12-12 14:49:46 -08001940 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1941 + header_offset, nPayload, &nPayload );
1942
1943 if ( DOT11F_FAILED( status ) )
1944 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301945 limLog(pMac, LOGE, FL("Failed to pack a TDLS Setup Response (0x%08x)."),
1946 status);
Kiran V1ccee932012-12-12 14:49:46 -08001947 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 Ahujab3a1a152014-11-11 22:14:10 +05301953 limLog(pMac, LOGW,
1954 FL("There were warnings while packing TDLS Setup Response (0x%08x)."),
1955 status);
Kiran V1ccee932012-12-12 14:49:46 -08001956 }
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301964 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001965 }
1966
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301967 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 V1ccee932012-12-12 14:49:46 -08001972
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001973 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001974 HAL_TXRX_FRM_802_11_DATA,
1975 ANI_TXDIR_TODS,
1976 //ANI_TXDIR_IBSS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301977 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001978 limTxComplete, pFrame,
1979 limMgmtTXComplete,
1980 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001981 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1982 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001983 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301984 limLog(pMac, LOGE, FL("could not send TDLS Setup Response"));
Kiran V1ccee932012-12-12 14:49:46 -08001985 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001986 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001987 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001988
1989 return eSIR_SUCCESS;
1990
1991}
1992
1993/*
1994 * Send TDLS setup CNF frame on AP link
1995 */
1996
1997tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301998 tANI_U8 dialog, tANI_U32 peerCapability, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001999{
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 Lee426f0302013-02-08 17:35:38 -08002008#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2009 tANI_U32 padLen = 0;
2010#endif
Kiran V1ccee932012-12-12 14:49:46 -08002011
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302017 vos_mem_set( ( tANI_U8* )&tdlsSetupCnf, sizeof( tDot11fTDLSSetupCnf ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08002018
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 V1ccee932012-12-12 14:49:46 -08002026 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
2027 peerMac, TDLS_INITIATOR) ;
Kiran V1ccee932012-12-12 14:49:46 -08002028
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 POTTETIa9c80d52014-05-09 18:05:29 +05302036 /* Check self and peer WMM capable */
2037 if ((1 == pMac->lim.gLimTDLSWmmMode) && (CHECK_BIT(peerCapability, TDLS_PEER_WMM_CAP)))
2038 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302039 limLog(pMac, LOG1, FL("populate WMM praram in Setup Confirm"));
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05302040 PopulateDot11fWMMParams(pMac, &tdlsSetupCnf.WMMParams, psessionEntry);
2041 }
2042
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302043 /* Check peer is VHT capable*/
2044 if (CHECK_BIT(peerCapability, TDLS_PEER_VHT_CAP))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002045 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302046 PopulateDot11fVHTOperation( pMac, &tdlsSetupCnf.VHTOperation);
2047 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002048 }
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302049 else if (CHECK_BIT(peerCapability, TDLS_PEER_HT_CAP)) /* Check peer is HT capable */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002050 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302051 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002052 }
Kiran V1ccee932012-12-12 14:49:46 -08002053
Agarwal Ashish81775962014-11-12 14:56:07 +05302054 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
2055 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24))
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05302056 {
2057 tdlsSetupCnf.HT2040BSSCoexistence.present = 1;
2058 tdlsSetupCnf.HT2040BSSCoexistence.infoRequest = 1;
2059 }
2060
Kiran V1ccee932012-12-12 14:49:46 -08002061 /*
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 Ahujab3a1a152014-11-11 22:14:10 +05302068 limLog(pMac, LOGE,
2069 FL("Failed to calculate the packed size for Setup Confirm (0x%08x)."),
2070 status);
Kiran V1ccee932012-12-12 14:49:46 -08002071 /* We'll fall back on the worst case scenario: */
2072 nPayload = sizeof( tDot11fProbeRequest );
2073 }
2074 else if ( DOT11F_WARNED( status ) )
2075 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302076 limLog(pMac, LOGW,
2077 FL("There were warnings while calculating the packed size for Setup Confirm (0x%08x)."),
2078 status);
Kiran V1ccee932012-12-12 14:49:46 -08002079 }
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 Nakkala0f3eb5c2013-05-07 16:48:38 +05302088 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
2089 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
2090 + sizeof( eth_890d_header )
2091 + PAYLOAD_TYPE_TDLS_SIZE
2092 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08002093
Hoonki Lee426f0302013-02-08 17:35:38 -08002094#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 V1ccee932012-12-12 14:49:46 -08002112 /* 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 Ahujab3a1a152014-11-11 22:14:10 +05302119 limLog(pMac, LOGE,
2120 FL("Failed to allocate %d bytes for a TDLS Setup Confirm."),
2121 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08002122 return eSIR_MEM_ALLOC_FAILED;
2123 }
2124
2125 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302126 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08002127
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 Nakkala0f3eb5c2013-05-07 16:48:38 +05302137 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08002138
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 Lokere531ca702013-04-01 13:24:23 -07002143 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf"));
Kiran V1ccee932012-12-12 14:49:46 -08002144 }
2145#endif
2146 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
2147 + header_offset, nPayload, &nPayload );
2148
2149 if ( DOT11F_FAILED( status ) )
2150 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302151 limLog(pMac, LOGE,
2152 FL("Failed to pack a TDLS Setup Confirm (0x%08x)."),
2153 status);
Kiran V1ccee932012-12-12 14:49:46 -08002154 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 Ahujab3a1a152014-11-11 22:14:10 +05302160 limLog(pMac, LOGW,
2161 FL("There were warnings while packing TDLS Setup Confirm (0x%08x)."),
2162 status);
Kiran V1ccee932012-12-12 14:49:46 -08002163 }
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302187 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08002188 }
2189
Hoonki Lee426f0302013-02-08 17:35:38 -08002190#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 Ahujab3a1a152014-11-11 22:14:10 +05302202 limLog(pMac, LOG1, FL("Padding Vendor Specific Ie Len = %d"), padLen);
Hoonki Lee426f0302013-02-08 17:35:38 -08002203
2204 /* padding zero if more than 5 bytes are required */
2205 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302206 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
2207 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee426f0302013-02-08 17:35:38 -08002208 }
2209#endif
2210
2211
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302212 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 V1ccee932012-12-12 14:49:46 -08002217
2218 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
2219 HAL_TXRX_FRM_802_11_DATA,
2220 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302221 TID_AC_VI,
Kiran V1ccee932012-12-12 14:49:46 -08002222 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002223 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08002224 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08002225
2226
2227 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2228 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002229 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302230 limLog(pMac, LOGE, FL("could not send TDLS Setup Confirm frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002231 return eSIR_FAILURE;
2232
2233 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002234 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08002235
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302243static void limTdlsCovertHTCaps(tpAniSirGlobal pMac,
Kiran V1ccee932012-12-12 14:49:46 -08002244 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302274 vos_mem_copy( peerInfo->supportedMCSSet,
Kiran V1ccee932012-12-12 14:49:46 -08002275 HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
2276
2277 return ;
2278}
2279
2280/*
2281 * update capability info..
2282 */
2283void 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 */
2310void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac,
2311 tLimTdlsLinkSetupPeer *setupPeer,
2312 tDot11fTDLSSetupReq *setupReq)
2313{
2314
2315 /* Populate peer info of tdls discovery result */
2316
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302317 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupReq->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002318
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 Johnson0f4d0bc2013-11-03 17:48:50 -08002330 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 V1ccee932012-12-12 14:49:46 -08002334 setupReq->QOSCapsStation.qack));
2335 }
2336
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302337 if (setupReq->ExtSuppRates.present)
Kiran V1ccee932012-12-12 14:49:46 -08002338 {
2339 setupPeer->ExtRatesPresent = 1;
2340 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2341 &setupReq->ExtSuppRates );
2342 }
2343 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302344 if (setupReq->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002345 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302346 vos_mem_copy( &setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002347 &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2348 }
2349 /* Update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302350 if (setupReq->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002351 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302352 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002353 &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
2354 }
2355
2356 return ;
2357}
2358
2359/*
2360 * update peer Info recieved with TDLS setup RSP
2361 */
2362void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac,
2363 tLimTdlsLinkSetupPeer *setupPeer,
2364 tDot11fTDLSSetupRsp *setupRsp)
2365{
2366
2367 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302368 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupRsp->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002369
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 Johnson0f4d0bc2013-11-03 17:48:50 -08002381 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 V1ccee932012-12-12 14:49:46 -08002385 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302395 if (setupRsp->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002396 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302397 vos_mem_copy(&setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002398 &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2399 }
2400
2401 /* update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302402 if (setupRsp->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002403 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302404 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002405 &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
2406 }
2407
2408 return ;
2409}
2410#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002411
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302412/* This Function is similar to PopulateDot11fHTCaps, except that the HT Capabilities
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002413 * are considered from the AddStaReq rather from the cfg.dat as in PopulateDot11fHTCaps
2414 */
2415static 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 Ahujab3a1a152014-11-11 22:14:10 +05302465 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 Nakkala681989c2013-03-06 22:27:48 -08002473
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 Ahujab3a1a152014-11-11 22:14:10 +05302483 limLog(pMac, LOG1, FL("AMPDU Param: %x"), nCfgValue);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002484
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302485 vos_mem_copy( pDot11f->supportedMCSSet, pTdlsAddStaReq->htCap.suppMcsSet,
2486 SIZE_OF_SUPPORTED_MCS_SET);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002487
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 Lee66b75f32013-04-16 18:30:07 -07002528 pDot11f->present = pTdlsAddStaReq->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002529
2530 return eSIR_SUCCESS;
2531
2532}
2533
2534tSirRetStatus
2535limTdlsPopulateDot11fVHTCaps(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 Lee66b75f32013-04-16 18:30:07 -07002550 pDot11f->present = pTdlsAddStaReq->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002551
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
2596static tSirRetStatus
2597limTdlsPopulateMatchingRateSet(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 Chiralac7a12152014-02-03 11:20:14 -08002613 tempRateSet2.numRates = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002614
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302621 (tANI_U8 *) &tempRateSet.rate,
2622 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002623 {
2624 /// Could not get rateset from CFG. Log error.
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302625 limLog(pMac, LOGE, FL("could not retrieve rateset"));
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07002626 val = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002627 }
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302636 (tANI_U8 *) &tempRateSet2.rate,
2637 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002638 tempRateSet2.numRates = val;
2639 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002640
2641 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2642 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302643 limLog(pMac, LOGE, FL("more than 12 rates in CFG"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002644 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, Sushant92e6f872014-05-03 16:35:57 +05302686 if (supporteRatesLength > SIR_MAC_RATESET_EID_MAX)
2687 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302688 limLog(pMac, LOGW,
2689 FL("Supported rates length %d more than the Max limit, reset to Max"),
2690 supporteRatesLength);
Kaushik, Sushant92e6f872014-05-03 16:35:57 +05302691 supporteRatesLength = SIR_MAC_RATESET_EID_MAX;
2692 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002693 for (i = 0; i < supporteRatesLength; i++)
2694 {
2695 tempRateSet.rate[i] = pSupportedRateSet[i];
2696 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002697 tempRateSet.numRates = supporteRatesLength;
2698
2699 {
2700 tpSirSupportedRates rates = &pStaDs->supportedRates;
2701 tANI_U8 aRateIndex = 0;
2702 tANI_U8 bRateIndex = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302703 vos_mem_set( (tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002704
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, Narayanraddi2f5dd652015-03-03 22:00:44 +05302712 if ((bRateIndex >= SIR_NUM_11B_RATES) ||
2713 (aRateIndex >= SIR_NUM_11A_RATES))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002714 {
Sushant Kaushik89064d72015-02-20 14:31:25 +05302715 limLog(pMac, LOGE, FL("Invalid number of rates"
2716 "(11b->%d, 11a->%d)"),
2717 bRateIndex,aRateIndex);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002718 return eSIR_FAILURE;
2719 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002720 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 Lokere531ca702013-04-01 13:24:23 -07002748 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002749 goto error;
2750 }
2751
2752 for (i=0; i<val; i++)
2753 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2754
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302755 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap from CFG and DPH:"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002756 for (i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2757 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302758 limLog(pMac, LOG1, FL("%x %x"),
2759 mcsSet[i],
2760 pStaDs->supportedRates.supportedMCSSet[i]);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002761 }
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
2783static 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 V1ccee932012-12-12 14:49:46 -08002838/*
2839 * update HASH node entry info
2840 */
2841static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002842 tSirTdlsAddStaReq *pTdlsAddStaReq, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002843{
2844 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
2845 tDot11fIEHTCaps htCap, *htCaps;
Kiet Lam770920c2013-10-21 12:49:30 +05302846 tDot11fIEVHTCaps *pVhtCaps = NULL;
Hoonki Lee99e53782013-02-12 18:07:03 -08002847#ifdef WLAN_FEATURE_11AC
Kiet Lam770920c2013-10-21 12:49:30 +05302848 tDot11fIEVHTCaps vhtCap;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002849 tANI_U8 cbMode;
Hoonki Lee99e53782013-02-12 18:07:03 -08002850#endif
Kiran V1ccee932012-12-12 14:49:46 -08002851 tpDphHashNode pSessStaDs = NULL;
2852 tANI_U16 aid;
2853
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002854 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 V1ccee932012-12-12 14:49:46 -08002862 htCaps = &htCap;
Hoonki Lee99e53782013-02-12 18:07:03 -08002863 if (htCaps->present)
Kiran V1ccee932012-12-12 14:49:46 -08002864 {
2865 pStaDs->mlmStaContext.htCapability = 1 ;
2866 pStaDs->htGreenfield = htCaps->greenField ;
Ganesh Kondabattinidaebdff2015-02-25 17:45:06 +05302867 /* 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 V1ccee932012-12-12 14:49:46 -08002873 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 V1ccee932012-12-12 14:49:46 -08002884 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 Lee99e53782013-02-12 18:07:03 -08002891#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002892 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002893 pVhtCaps = &vhtCap;
2894 if (pVhtCaps->present)
2895 {
2896 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302897
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05302898 if (psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END)
Kiet Lam770920c2013-10-21 12:49:30 +05302899 {
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05302900 /* 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 Lam770920c2013-10-21 12:49:30 +05302906 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
2907 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05302908 limLog(pMac, LOG1,
2909 FL("vhtSupportedChannelWidthSet = %hu,"
2910 " htSupportedChannelWidthSet %hu"),
2911 pStaDs->vhtSupportedChannelWidthSet,
2912 pStaDs->htSupportedChannelWidthSet) ;
Kiet Lam770920c2013-10-21 12:49:30 +05302913 }
2914 else
2915 {
2916 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
2917 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_40MHZ ;
2918 }
2919
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002920 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2921 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2922 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002923 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2924 }
2925 else
2926 {
2927 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002928 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002929 }
2930#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002931 /*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 V1ccee932012-12-12 14:49:46 -08002942
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 Nakkala681989c2013-03-06 22:27:48 -08002950 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2951 */
2952 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002953
2954 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002955
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002956 /* 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 Lam770920c2013-10-21 12:49:30 +05302962 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002963
2964 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2965 */
2966 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002967
2968 return ;
2969}
2970
2971#ifdef FEATURE_WLAN_TDLS_INTERNAL
2972/*
2973 * find Peer in setup link list.
2974 */
2975
2976tANI_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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302985 if (vos_mem_compare((tANI_U8 *) peerMac,
2986 (tANI_U8 *) linkSetupList->peerMac,
2987 sizeof(tSirMacAddr)) )
Kiran V1ccee932012-12-12 14:49:46 -08002988 {
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 */
3004tSirTdlsPeerInfo *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 Hussain24bafea2013-11-15 15:10:03 -08003013 ("Peer in discovery list = " MAC_ADDRESS_STR),
3014 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003015
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303016 if (vos_mem_compare((tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003017 (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 */
3032static 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 Hussain24bafea2013-11-15 15:10:03 -08003042 ("peerInfo Mac = " MAC_ADDRESS_STR),
3043 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003044
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 */
3060static 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 Lokere531ca702013-04-01 13:24:23 -07003071 ("peer state = %02x"), (linkSetupList)->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08003072 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 */
3088void 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303098 if (vos_mem_compare( (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003099 (tANI_U8 *) currentNode->peerMac,
3100 sizeof(tSirMacAddr)) )
3101 {
3102 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003103 ("Del Node for Peer = " MAC_ADDRESS_STR),
3104 MAC_ADDR_ARRAY(currentNode->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003105 /* 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303114 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08003115 return ;
3116 }
3117 }
3118
3119 return ;
3120}
3121
3122
3123
3124/*
3125 * TDLS discovery request frame received from TDLS peer STA..
3126 */
3127static 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 Lokere531ca702013-04-01 13:24:23 -07003143 ("TDLS dis request dialog = %d"), tdlsDisReq.DialogToken.token);
Kiran V1ccee932012-12-12 14:49:46 -08003144
3145 if ( DOT11F_FAILED( status ) )
3146 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003147 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3148 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003149 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3150 return eSIR_FAILURE;
3151 }
3152 else if ( DOT11F_WARNED( status ) )
3153 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303154 limLog(pMac, LOGW, FL("There were warnings while unpacking a TDLS "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003155 "discovery Request frame (0x%08x, %d bytes):"),
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303156 status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003157 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003169 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003170 ("no Session entry for TDLS session (bssid "MAC_ADDR_ARRAY")"),
3171 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003172
3173 //VOS_ASSERT(0) ;
3174 return eSIR_FAILURE;
3175 }
3176
3177 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303178 status = vos_mem_compare( &psessionEntry->bssId[0],
Kiran V1ccee932012-12-12 14:49:46 -08003179 &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
3180 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003181 ("lim BSSID "MAC_ADDRESS_STR),
3182 MAC_ADDR_ARRAY( psessionEntry->bssId));
Kiran V1ccee932012-12-12 14:49:46 -08003183
3184 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003185 ("Dis req from BSSID "MAC_ADDRESS_STR),
3186 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003187 if(!status)
3188 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303189 limLog(pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003190
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303198 status = vos_mem_compare( psessionEntry->selfMacAddr,
Kiran V1ccee932012-12-12 14:49:46 -08003199 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3200 sizeof(tSirMacAddr)) ;
3201 if(status)
3202 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003203 limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003204 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303212 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003213 &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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303228 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3229 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003230 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003231 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery "
3232 "reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003233 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303244 vos_mem_copy( peerInfo->peerMac, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08003245
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 Lokere531ca702013-04-01 13:24:23 -07003278 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08003279 }
3280 swapBitField16(caps, ( tANI_U16* )&capsInfo );
3281 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303282 tdlsUpdateCapInfo(&peerInfo->capabilityInfo, &capsInfo) ;
Kiran V1ccee932012-12-12 14:49:46 -08003283
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 Lokere531ca702013-04-01 13:24:23 -07003311 limLog(pMac, LOGE, "Add STA for dis response is failed ") ;
Kiran V1ccee932012-12-12 14:49:46 -08003312 return eSIR_FAILURE ;
3313 }
3314 } /* use setup link sta ID for discovery rsp */
3315 else
3316 {
3317 peerInfo->delStaNeeded = false ;
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05303318 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog,
3319 psessionEntry, NULL, 0);
Kiran V1ccee932012-12-12 14:49:46 -08003320 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 Lokere531ca702013-04-01 13:24:23 -07003327 ("discovery procedure in progress for this peer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003328 }
3329
3330 return eSIR_SUCCESS ;
3331}
3332
3333/* Process TDLS setup Request Frame */
3334
3335static 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003354 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3355 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003356 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3357 return eSIR_FAILURE;
3358 }
3359 else if ( DOT11F_WARNED( status ) )
3360 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003361 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3362 "setup Request frame (0x%08x, %d bytes):"),
3363 status, frmLen );
Kiran V1ccee932012-12-12 14:49:46 -08003364 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003375 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003376 ("no Session entry for TDLS session (bssid "
3377 MAC_ADDRESS_STR")"),
3378 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003379
3380 //VOS_ASSERT(0) ;
3381 return eSIR_FAILURE ;
3382 }
3383 /* TODO: we don;t need this check now, varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303384 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003385 &tdlsSetupReq.LinkIdentifier.bssid[0],
3386 sizeof(tSirMacAddr)) ;
3387
3388 if(!status)
3389 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003390 limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003391
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303392 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
3393 tdlsSetupReq.DialogToken.token, psessionEntry,
3394 TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003395 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 Lokere531ca702013-04-01 13:24:23 -07003403 ("TDLS negative running: ignore TDLS Setup Req packet"));
Kiran V1ccee932012-12-12 14:49:46 -08003404 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 Lokere531ca702013-04-01 13:24:23 -07003409 ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req"));
Kiran V1ccee932012-12-12 14:49:46 -08003410 /* 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 Lokere531ca702013-04-01 13:24:23 -07003424 ("Link is already setup with this peer" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003425 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003426 ("state = %d"), tmpSetupPeer->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08003427 //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 Lokere531ca702013-04-01 13:24:23 -07003444 ("MAC comparison Rslt = %d"), macCompare ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003445 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 V1ccee932012-12-12 14:49:46 -08003479 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 Lokere531ca702013-04-01 13:24:23 -07003526 ("link Setup is Recieved in unknown state" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003527 break ;
3528 }
Kiran V1ccee932012-12-12 14:49:46 -08003529 }
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303541 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
3542 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08003543 {
3544 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003545 ( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08003546 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303558 vos_mem_copy(setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003559 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3560 sizeof(tSirMacAddr)) ;
3561
3562 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003563 ("Setup REQ MAC = " MAC_ADDRESS_STR),
3564 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003565
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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303574 vos_mem_free((void **) &setupPeer) ;
Kiran V1ccee932012-12-12 14:49:46 -08003575 return eSIR_FAILURE ;
3576 }
3577
3578 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303579 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003580 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303603 vos_mem_copy( setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003604 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3605 sizeof(tSirMacAddr)) ;
3606
3607 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003608 ("Setup REQ MAC = "MAC_ADDRESS_STR),
3609 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003610
3611 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3612 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303613 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003614 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 */
3631static 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003645 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3646 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003647 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3648 return eSIR_FAILURE;
3649 }
3650 else if ( DOT11F_WARNED( status ) )
3651 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003652 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3653 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003654 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003667 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003668 ("no Session entry for TDLS session (bssid "
3669 MAC_ADDRESS_STR")"),
3670 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003671
3672 //VOS_ASSERT(0) ;
3673 return eSIR_FAILURE;
3674 }
3675
3676 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303677 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003678 &tdlsSetupRsp.LinkIdentifier.bssid[0],
3679 sizeof(tSirMacAddr)) ;
3680
3681 if(!status)
3682 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003683 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003684
3685 VOS_ASSERT(0) ;
3686 return eSIR_FAILURE ;
3687 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303688 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003689 &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0],
3690 sizeof(tSirMacAddr)) ;
3691
3692 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003693 ("TDLS setup RSP peer = "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003694 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3695
3696 if(NULL == setupPeer)
3697 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003698 limLog( pMac, LOGE, FL("unknown setup Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003699 return eSIR_FAILURE ;
3700 }
3701
3702 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003703 ("deactivating Setup RSP timer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003704
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 Lokere531ca702013-04-01 13:24:23 -07003716 ("setup RSP with Failure Code")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003717 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 POTTETIca171f82014-03-21 14:17:35 +05303743 limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, 0, psessionEntry, NULL, 0) ;
Kiran V1ccee932012-12-12 14:49:46 -08003744
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
3760static 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003773 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3774 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003775 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3776 return eSIR_FAILURE;
3777 }
3778 else if ( DOT11F_WARNED( status ) )
3779 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003780 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3781 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003782 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003794 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003795 ("no Session entry for TDLS session (bssid "
3796 MAC_ADDRESS_STR")"),
3797 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003798
3799 //VOS_ASSERT(0) ;
3800 return eSIR_FAILURE;
3801 }
3802
3803 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303804 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003805 &tdlsSetupCnf.LinkIdentifier.bssid[0],
3806 sizeof(tSirMacAddr)) ;
3807
3808 if(!status)
3809 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003810 limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003811
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 Hussain24bafea2013-11-15 15:10:03 -08003817 ("setup Cnf peer MAc = "MAC_ADDRESS_STR),
3818 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.InitStaAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003819
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 Lokere531ca702013-04-01 13:24:23 -07003827 (" unknown setup CNF frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003828 VOS_ASSERT(0) ;
3829 return eSIR_FAILURE ;
3830 }
3831 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003832 ("setup CNF peer MAC = "MAC_ADDRESS_STR),
3833 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003834 /*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 Lokere531ca702013-04-01 13:24:23 -07003838 ("setup CNF frame not matching with setup RSP")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003839 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
3867static 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003881 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3882 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003883 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3884 return eSIR_FAILURE;
3885 }
3886 else if ( DOT11F_WARNED( status ) )
3887 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003888 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3889 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003890 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303896 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003897 &tdlsDisRsp.LinkIdentifier.bssid[0],
3898 sizeof(tSirMacAddr)) ;
3899
3900 if(!status)
3901 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003902 limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003903 return eSIR_FAILURE ;
3904 }
3905 /* TODO, do more validation */
3906
3907 if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
3908 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003909 limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003910 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303921 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3922 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003923 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003924 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003925 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303935 * When we receive DIS RSP from peer MAC,
Kiran V1ccee932012-12-12 14:49:46 -08003936 * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
3937 * will carry our MAC.
3938 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303939 vos_mem_copy( peerInfo->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003940 &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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303947 tdlsUpdateCapInfo(&peerInfo->capabilityInfo,
Kiran V1ccee932012-12-12 14:49:46 -08003948 &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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303967 vos_mem_copy( &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08003968 sizeof( tDot11fIEHTCaps ) );
3969 }
Kiran V1ccee932012-12-12 14:49:46 -08003970 } 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 */
3982static 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 Johnson0f4d0bc2013-11-03 17:48:50 -08003995 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3996 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003997 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3998 return eSIR_FAILURE;
3999 }
4000 else if ( DOT11F_WARNED( status ) )
4001 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004002 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
4003 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08004004 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 Johnson0f4d0bc2013-11-03 17:48:50 -08004017 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004018 ("no Session entry for TDLS session (bssid "
4019 MAC_ADDRESS_STR")"),
4020 MAC_ADDR_ARRAY(tdlsTeardown.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08004021
4022 //VOS_ASSERT(0) ;
4023 return eSIR_FAILURE;
4024 }
4025
4026 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304027 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08004028 &tdlsTeardown.LinkIdentifier.bssid[0],
4029 sizeof(tSirMacAddr)) ;
4030
4031
4032 if(!status)
4033 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004034 limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004035 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 Lokere531ca702013-04-01 13:24:23 -07004047 limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored") );
Kiran V1ccee932012-12-12 14:49:46 -08004048
4049 return eSIR_FAILURE ;
4050 }
4051 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004052 ("teardown for peer "MAC_ADDRESS_STR),
4053 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004054
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 Lokere531ca702013-04-01 13:24:23 -07004060 ("teardown with unspecified reason")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004061 break ;
4062 }
4063 case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
4064 {
4065 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004066 (" Teardown from AP, TDLS peer unreachable")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004067 break ;
4068 }
4069 default:
4070 {
4071 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004072 (" unknown teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004073 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 */
4113void 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 Lokere531ca702013-04-01 13:24:23 -07004127 limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored"), category );
Kiran V1ccee932012-12-12 14:49:46 -08004128 return ;
4129 }
4130
4131 frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004132 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Received TDLS action %d (%s)"),
Kiran V1ccee932012-12-12 14:49:46 -08004133 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 */
4179static 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 Hussain24bafea2013-11-15 15:10:03 -08004193 ("ADD STA peer MAC: "MAC_ADDRESS_STR),
4194 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004195
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 Lokere531ca702013-04-01 13:24:23 -07004201 (" there is hash entry for this client")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004202 status = eSIR_FAILURE ;
4203 VOS_ASSERT(0) ;
4204 return status ;
4205 }
4206
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004207 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004208
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004209 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4210 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4211
Kiran V1ccee932012-12-12 14:49:46 -08004212 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 Lokere531ca702013-04-01 13:24:23 -07004225 (" add hash entry failed")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004226 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 Lokere531ca702013-04-01 13:24:23 -07004236 ("pSta DS [%p] "), pStaDs) ;
Kiran V1ccee932012-12-12 14:49:46 -08004237 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004238 ("peerInfo->tdlsPeerSuppRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004239 (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
4240 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004241 ("peerInfo->tdlsPeerExtRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004242 (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
4243 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004244 ("peerInfo->tdlsPeerPropRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004245 (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
4246 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004247 ("peerInfo->mcs = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004248 (tANI_U8 *)peerInfo->supportedMCSSet) ;
4249 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004250 ("num of supp rates = %02x"), suppRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004251 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004252 ("num of ext rates = %01x"), extRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004253#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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304277 vos_mem_copy( pStaDs->staAddr, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08004278 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004279 ("Add STA for Peer: "MAC_ADDRESS_STR),
4280 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004281
4282
4283 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4284
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004285 status = limAddSta(pMac, pStaDs, false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004286
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 Nakkala681989c2013-03-06 22:27:48 -08004300static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
4301 tSirTdlsAddStaReq *pAddStaReq,
4302 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08004303{
4304 tpDphHashNode pStaDs = NULL ;
4305 tSirRetStatus status = eSIR_SUCCESS ;
4306 tANI_U16 aid = 0 ;
4307
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004308 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004309 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08004310 if(NULL == pStaDs)
4311 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004312 aid = limAssignPeerIdx(pMac, psessionEntry) ;
4313
4314 if( !aid )
4315 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05304316 limLog(pMac, LOGE, FL("No more free AID for peer " MAC_ADDRESS_STR),
4317 MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004318 return eSIR_FAILURE;
4319 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004320
4321 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4322 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4323
Sachin Ahujab3a1a152014-11-11 22:14:10 +05304324 limLog(pMac, LOG1, FL("Aid = %d, for peer =" MAC_ADDRESS_STR),
4325 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004326 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 Nakkala681989c2013-03-06 22:27:48 -08004334 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004335 &psessionEntry->dph.dphHashTable) ;
4336
4337 if(NULL == pStaDs)
4338 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05304339 limLog(pMac, LOGE, FL("add hash entry failed"));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004340 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004341 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004342 }
Kiran V1ccee932012-12-12 14:49:46 -08004343 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004344
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004345 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004346
4347 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4348
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004349 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004350
4351 if(eSIR_SUCCESS != status)
4352 {
4353 /* should not fail */
4354 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004355 }
Kiran V1ccee932012-12-12 14:49:46 -08004356 return status ;
4357}
4358
4359/*
4360 * Del STA, after Link is teardown or discovery response sent on direct link
4361 */
4362static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4363 tpPESession psessionEntry)
4364{
4365 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004366 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08004367 tpDphHashNode pStaDs = NULL ;
4368
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004369 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08004370 &psessionEntry->dph.dphHashTable) ;
4371
4372 if(pStaDs)
4373 {
4374
Sachin Ahujab3a1a152014-11-11 22:14:10 +05304375 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 Kumarc9e9f622014-12-11 15:40:29 +05304380 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
Ganesh Kondabattini6efefb22015-01-20 12:17:42 +05304381 eSIR_MAC_PEER_TIMEDOUT_REASON);
Kiran V1ccee932012-12-12 14:49:46 -08004382 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08004383#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -08004384 if(eSIR_SUCCESS == status)
4385 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004386 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ;
4387 limReleasePeerIdx(pMac, peerIdx, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004388 }
4389 else
4390 {
4391 VOS_ASSERT(0) ;
4392 }
Hoonki Leef63df0d2013-01-16 19:29:14 -08004393#endif
Kiran V1ccee932012-12-12 14:49:46 -08004394 }
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*/
4404static 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 Hussaina7c8e412013-11-20 11:06:42 -08004420 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 Hussain24bafea2013-11-15 15:10:03 -08004423 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004424 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 Lokere531ca702013-04-01 13:24:23 -07004433 ("limTdlsLinkEstablish: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004434 VOS_ASSERT(0) ;
4435 return eHAL_STATUS_FAILURE;
4436 }
4437
Kiet Lam842dad02014-02-18 18:44:02 -08004438
Kiran V1ccee932012-12-12 14:49:46 -08004439 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
4440 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004441 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 V1ccee932012-12-12 14:49:46 -08004445 return eSIR_FAILURE;
4446 }
4447
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304448 vos_mem_set( ( tANI_U8* )&tdlsPtiTemplate,
4449 sizeof( tDot11fTDLSPeerTrafficInd ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004450
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 V1ccee932012-12-12 14:49:46 -08004457 /* 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 Medicharla43d0f7b2015-02-12 17:07:59 +05304461#if 0
Kiran V1ccee932012-12-12 14:49:46 -08004462 /* 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 Lokere531ca702013-04-01 13:24:23 -07004478 limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004479 /* We'll fall back on the worst case scenario: */
4480 nPayload = sizeof( tdlsPtiTemplate );
4481 }
4482 else if ( DOT11F_WARNED( status ) )
4483 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004484 limLog( pMac, LOGW, FL("There were warnings while calculating the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004485 }
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 Lokere531ca702013-04-01 13:24:23 -07004498 limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64."), nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08004499 nBytes = 64;
4500 }
4501 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304502 vos_mem_set( pFrame, sizeof(pFrame), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004503
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 Johnson0f4d0bc2013-11-03 17:48:50 -08004514 limLog( pMac, LOGE, FL("Failed to pack a PTI template (0x%08x)."),
4515 status );
Kiran V1ccee932012-12-12 14:49:46 -08004516 return eSIR_FAILURE;
4517 }
4518 else if ( DOT11F_WARNED( status ) )
4519 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004520 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
4521 "Peer Traffic Indication (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004522 }
4523
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004524 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("bIsResponder=%d, header_offset=%ld, linkIdenOffset=%d, ptiBufStatusOffset=%d "),
Kiran V1ccee932012-12-12 14:49:46 -08004525 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*/
4538static 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 Hussaina7c8e412013-11-20 11:06:42 -08004548 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 V1ccee932012-12-12 14:49:46 -08004552 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 Lokere531ca702013-04-01 13:24:23 -07004561 ("limTdlsLinkTeardown: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004562 VOS_ASSERT(0) ;
4563 return eHAL_STATUS_FAILURE;
4564 }
4565
4566
Kiet Lam842dad02014-02-18 18:44:02 -08004567
Kiran V1ccee932012-12-12 14:49:46 -08004568 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
4569
4570 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004571 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 V1ccee932012-12-12 14:49:46 -08004575 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
4588static 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304602
4603 disRsp = vos_mem_malloc(disMsgRspSize);
4604 if ( NULL == disRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004605 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304606 limLog(pMac, LOGP, FL("AllocateMemory failed for DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004607 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304619 vos_mem_copy( (tANI_U8 *)peerInfo,
Kiran V1ccee932012-12-12 14:49:46 -08004620 (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo,
4621 sizeof(tSirTdlsPeerInfo));
4622
4623 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004624 ("Msg Sent to PE, peer MAC: "MAC_ADDRESS_STR),
4625 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004626 disStaCount-- ;
4627 peerInfo++ ;
4628 currentNode = tdlsDisRspList ;
4629 tdlsDisRspList = tdlsDisRspList->next ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304630 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08004631 /* boundary condition check, may be fatal */
4632 if(((!disStaCount) && (tdlsDisRspList))
4633 || ((!tdlsDisRspList) && disStaCount))
4634 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004635 limLog(pMac, LOG1, FL("mismatch in dis sta count and "
4636 "number of nodes in list")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004637 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
4652void 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304661 teardownRspMsg = vos_mem_malloc(sizeof(tSirTdlsTeardownRsp));
4662 if ( NULL == teardownRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004663 {
4664 VOS_ASSERT(0) ;
4665 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304666 vos_mem_copy( teardownRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004667 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 */
4680void 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304691 setupRspMsg = vos_mem_malloc(sizeof(tSirTdlsLinksetupRsp));
4692 if ( NULL == setupRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004693 {
4694 VOS_ASSERT(0) ;
4695 }
4696
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304697 vos_mem_copy( setupRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004698 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 */
4710void 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 Lokere531ca702013-04-01 13:24:23 -07004723 ("no of TDLS STA discovered: %d"), tdlsStaCount) ;
Kiran V1ccee932012-12-12 14:49:46 -08004724 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
4725
4726 if(tdlsDisRsp)
4727 {
4728 tdlsDisRsp->numDisSta = tdlsStaCount ;
4729 }
4730 else
4731 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004732 limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004733 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 */
4755static 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304761
4762 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4763 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004764 {
4765 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4766 return eSIR_FAILURE;
4767 }
4768
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304769 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004770 (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 */
4788static 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304794
4795 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4796 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004797 {
4798 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4799 return eSIR_FAILURE;
4800 }
4801
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304802 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004803 (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 */
4823static 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304830 setupInd = vos_mem_malloc(sizeof(tSirTdlsLinkSetupInd));
4831 if ( NULL == setupInd )
Kiran V1ccee932012-12-12 14:49:46 -08004832 {
4833 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4834 return eSIR_FAILURE;
4835 }
4836
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304837 vos_mem_copy( setupInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004838 (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 */
4852void 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 Lokere531ca702013-04-01 13:24:23 -07004867 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004868 msg.type, statusCode);
4869 return ;
4870}
4871
4872/*
4873 * Link setup CNF timer
4874 */
4875void 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 Lokere531ca702013-04-01 13:24:23 -07004890 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004891 msg.type, statusCode);
4892 return ;
4893}
4894
4895/*
4896 * start TDLS timer
4897 */
4898void 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 Lokere531ca702013-04-01 13:24:23 -07004919 FL("could not create TDLS discovery response wait timer"));
Kiran V1ccee932012-12-12 14:49:46 -08004920 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 Lokere531ca702013-04-01 13:24:23 -07004930 limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!"));
Kiran V1ccee932012-12-12 14:49:46 -08004931 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 */
4942static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004943 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
4944 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08004945{
4946 tSirMsgQ mmhMsg = {0} ;
4947 tSirTdlsAddStaRsp *addStaRsp = NULL ;
4948 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304949
4950 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
4951 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004952 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05304953 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Kiran V1ccee932012-12-12 14:49:46 -08004954 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304967 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004968 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4969 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004970 if (updateSta)
4971 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
4972 else
4973 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
4974
Kiran V1ccee932012-12-12 14:49:46 -08004975 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 */
4988eHalStatus 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 Ahujab3a1a152014-11-11 22:14:10 +05304997 limLog(pMac, LOG1, FL("staIdx=%d, staMac="MAC_ADDRESS_STR),
4998 pAddStaParams->staIdx,
4999 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08005000
5001 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
5002 {
5003 VOS_ASSERT(0) ;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305004 limLog(pMac, LOGE, FL("Add sta failed "));
Kiran V1ccee932012-12-12 14:49:46 -08005005 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 Ahujab3a1a152014-11-11 22:14:10 +05305013 limLog(pMac, LOGE, FL("pStaDs is NULL "));
Kiran V1ccee932012-12-12 14:49:46 -08005014 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 Lokere531ca702013-04-01 13:24:23 -07005030 ("Peer IND msg to SME failed")) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305031 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08005032 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 Saptasagar9be00d72014-08-28 16:04:43 +05305054 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog,
5055 psessionEntry, NULL, 0);
Kiran V1ccee932012-12-12 14:49:46 -08005056 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
5057 }
5058 } while(0) ;
Kiran V1ccee932012-12-12 14:49:46 -08005059#endif
5060add_sta_error:
5061 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005062 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305063 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08005064 return status ;
5065}
5066
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305067void 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 POTTETI1571b4f2015-02-18 15:34:26 +05305074 tANI_U8 i, j;
Atul Mittalb849d5a2014-07-29 12:08:39 +05305075 tANI_U8 op_class;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305076 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 Ahujab3a1a152014-11-11 22:14:10 +05305083 limLog(pMac, LOGE, FL("could not retrieve valid channel list"));
Sushant Kaushik5b4c8212015-02-20 14:54:25 +05305084 return;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305085 }
5086 suppChannels->num_bands = (tANI_U8) numChans;
5087
Masti, Narayanraddi2f5dd652015-03-03 22:00:44 +05305088 for ( i = 0U, j = 0U; i < suppChannels->num_bands &&
5089 j < LIM_MAX_BANDS; i++)
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305090 {
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05305091 /* 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 Jayarambc62ba42014-02-12 21:39:14 +05305097 }
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05305098 /* update the channel list with new length */
5099 suppChannels->num_bands = j;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305100 suppChannels->present = 1 ;
Atul Mittalb849d5a2014-07-29 12:08:39 +05305101 /*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 Ahujab3a1a152014-11-11 22:14:10 +05305108 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 Mittalb849d5a2014-07-29 12:08:39 +05305113 }
5114 else
5115 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305116 limLog(pMac, LOG1,
5117 FL("Present Operating channel=%d offset=%d class=%d"),
5118 psessionEntry->currentOperChannel,
5119 psessionEntry->htSecondaryChannelOffset,
5120 op_class);
Atul Mittalb849d5a2014-07-29 12:08:39 +05305121 }
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 Jayarambc62ba42014-02-12 21:39:14 +05305133 return ;
5134}
5135
5136
Kiran V1ccee932012-12-12 14:49:46 -08005137/*
5138 * FUNCTION: Populate Link Identifier element IE
5139 *
5140 */
5141
Atul Mittalb849d5a2014-07-29 12:08:39 +05305142
Kiran V1ccee932012-12-12 14:49:46 -08005143void 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305155 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08005156 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
5157
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305158 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08005159 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
5160
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305161 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005162 sizeof( tSirMacAddr ));
5163
5164 linkIden->present = 1 ;
5165 return ;
5166
5167}
5168
5169void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
5170 tDot11fIEExtCap *extCapability)
5171{
5172 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305173 extCapability->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305174 extCapability->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
Kiran V1ccee932012-12-12 14:49:46 -08005175 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 */
5189void 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
5200eHalStatus 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305212
5213 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5214 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08005215 {
5216 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005217 FL( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08005218 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305233 vos_mem_copy(setupPeer->peerMac, peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005234 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 */
5258tSirRetStatus 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 Ahujab3a1a152014-11-11 22:14:10 +05305267 limLog(pMac, LOG1, FL("Send Mgmt Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08005268
5269 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
5270 == NULL)
5271 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305272 limLog(pMac, LOGE,
5273 FL("PE Session does not exist for given sme sessionId %d"),
5274 pSendMgmtReq->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08005275 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 Lokere531ca702013-04-01 13:24:23 -07005282 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005283 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 Ahujab3a1a152014-11-11 22:14:10 +05305295 limLog(pMac, LOGE, FL("send mgmt received in invalid LIMsme state (%d)"),
5296 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005297 goto lim_tdls_send_mgmt_error;
5298 }
5299
5300 switch( pSendMgmtReq->reqType )
5301 {
5302 case SIR_MAC_TDLS_DIS_REQ:
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305303 limLog(pMac, LOG1, FL("Transmit Discovery Request Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08005304 /* 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 Ahujab3a1a152014-11-11 22:14:10 +05305311 limLog(pMac, LOG1, FL("Transmit Discovery Response Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08005312 //Send a response mgmt action frame
5313 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05305314 pSendMgmtReq->dialog, psessionEntry,
5315 &pSendMgmtReq->addIe[0],
5316 (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
Kiran V1ccee932012-12-12 14:49:46 -08005317 resultCode = eSIR_SME_SUCCESS;
5318 }
5319 break;
5320 case SIR_MAC_TDLS_SETUP_REQ:
5321 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305322 limLog(pMac, LOG1, FL("Transmit Setup Request Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08005323 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 Ahujab3a1a152014-11-11 22:14:10 +05305331 limLog(pMac, LOG1, FL("Transmit Setup Response Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08005332 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 Ahujab3a1a152014-11-11 22:14:10 +05305340 limLog(pMac, LOG1, FL("Transmit Setup Confirm Frame"));
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05305341 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, pSendMgmtReq->peerCapability,
Kiran V1ccee932012-12-12 14:49:46 -08005342 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5343 resultCode = eSIR_SME_SUCCESS;
5344 }
5345 break;
5346 case SIR_MAC_TDLS_TEARDOWN:
5347 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305348 limLog(pMac, LOG1, FL("Transmit Teardown Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08005349 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08005350 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08005351 &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
5375lim_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 Nakkala79ff85d2013-05-27 17:05:29 +05305384 * Send Response to Link Establish Request to SME
5385 */
5386void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
5387 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5388 tANI_U8 status)
5389{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305390 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305391
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305392 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305393
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305394 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
5395 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305396 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305397 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305398 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305399 }
5400 pTdlsLinkEstablishReqRsp->statusCode = status ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305401 if ( peerMac )
5402 {
5403 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
5404 }
5405 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305406 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305407 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305408 mmhMsg.bodyval = 0;
5409 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5410 return ;
5411
5412
5413}
5414
5415/*
Atul Mittal60bd4292014-08-14 12:19:27 +05305416 * Send Response to Chan Switch Request to SME
5417 */
5418void 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 V1ccee932012-12-12 14:49:46 -08005447 * Once link is teardown, send Del Peer Ind to SME
5448 */
5449static 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 Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305456
5457 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
5458 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08005459 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305460 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Kiran V1ccee932012-12-12 14:49:46 -08005461 return eSIR_FAILURE;
5462 }
5463
5464 pDelSta->sessionId = sessionId;
5465 pDelSta->statusCode = status ;
5466 if( pStaDs )
5467 {
5468 pDelSta->staId = pStaDs->staIndex ;
5469 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005470 else
5471 pDelSta->staId = HAL_STA_INVALID_IDX;
5472
Kiran V1ccee932012-12-12 14:49:46 -08005473 if( peerMac )
5474 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305475 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08005476 }
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 */
5492tSirRetStatus 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 V1ccee932012-12-12 14:49:46 -08005499
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305500 limLog(pMac, LOG1, FL("TDLS Add STA Request Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08005501
5502 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
5503 == NULL)
5504 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305505 limLog(pMac, LOGE,
5506 FL("PE Session does not exist for given sme sessionId %d"),
5507 pAddStaReq->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08005508 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 Lokere531ca702013-04-01 13:24:23 -07005515 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005516 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 Ahujab3a1a152014-11-11 22:14:10 +05305528 limLog(pMac, LOGE,
5529 FL("Add STA received in invalid LIMsme state (%d)"),
5530 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005531 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 Nakkala681989c2013-03-06 22:27:48 -08005537 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08005538 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305539 limLog(pMac, LOGE, FL("Add TDLS Station request failed"));
Kiran V1ccee932012-12-12 14:49:46 -08005540 goto lim_tdls_add_sta_error;
5541 }
5542 return eSIR_SUCCESS;
5543lim_tdls_add_sta_error:
5544 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005545 pAddStaReq->sessionId, pAddStaReq->peerMac,
5546 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08005547
5548 return eSIR_SUCCESS;
5549}
5550/*
5551 * Process Del Sta Request from SME .
5552 */
5553tSirRetStatus 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 Ahujab3a1a152014-11-11 22:14:10 +05305562 limLog(pMac, LOG1, FL("TDLS Delete STA Request Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08005563
5564 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
5565 == NULL)
5566 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305567 limLog(pMac, LOGE,
5568 FL("PE Session does not exist for given sme sessionId %d"),
5569 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005570 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005571 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 Lokere531ca702013-04-01 13:24:23 -07005579 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005580 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 Ahujab3a1a152014-11-11 22:14:10 +05305592 limLog(pMac, LOGE, FL("Del Sta received in invalid LIMsme state (%d)"),
5593 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005594 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 Nakkala2a0a1572013-02-10 21:39:16 -08005605 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08005606
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005607 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
5608 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005609 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
5610
Kiran V1ccee932012-12-12 14:49:46 -08005611 return eSIR_SUCCESS;
5612
5613 }
5614
5615lim_tdls_del_sta_error:
5616 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5617 NULL, eSIR_FAILURE) ;
5618
5619 return eSIR_SUCCESS;
5620}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005621
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305622/* Intersects the two input arrays and outputs an array */
5623/* For now the array length of tANI_U8 suffices */
5624static 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 POTTETI7e6de8d2014-07-18 17:24:19 +05305629
5630 if (input1_length > WNI_CFG_VALID_CHANNEL_LIST_LEN)
5631 {
5632 input1_length = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5633 }
5634
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305635 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 Nakkala79ff85d2013-05-27 17:05:29 +05305654/*
5655 * Process Link Establishment Request from SME .
5656 */
5657tSirRetStatus 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 Ahujab3a1a152014-11-11 22:14:10 +05305669 limLog(pMac, LOG1, FL("Link Establish Request Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305670
5671 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
5672 == NULL)
5673 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305674 limLog(pMac, LOGE,
5675 FL("PE Session does not exist for given sme sessionId %d"),
5676 pTdlsLinkEstablishReq->sessionId);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305677 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 Johnson0f4d0bc2013-11-03 17:48:50 -08005686 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305687 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 Ahujab3a1a152014-11-11 22:14:10 +05305699 limLog(pMac, LOGE,
5700 FL("TDLS Link Establish Request received in invalid LIMsme state (%d)"),
5701 psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305702 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 Ahujab3a1a152014-11-11 22:14:10 +05305709 limLog(pMac, LOGE, FL( "pStaDs is NULL"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305710 goto lim_tdls_link_establish_error;
5711
5712 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305713 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
5714 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305715 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305716 limLog(pMac, LOGE,
5717 FL("Unable to allocate memory TDLS Link Establish Request"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305718 return eSIR_MEM_ALLOC_FAILED;
5719 }
5720
Girish Gowlicf762742014-07-02 13:54:09 +05305721 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305722
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05305723 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 Kondabattiniebf56a12015-02-19 16:22:42 +05305728
Atul Mittalbceb4a12014-11-27 18:50:19 +05305729 if (psessionEntry->tdlsChanSwitProhibited)
5730 {
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05305731 /* 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 Mittalbceb4a12014-11-27 18:50:19 +05305738 limLog(pMac, LOG1, FL("Channel Switch Prohibited by AP"));
5739 }
5740 else
5741 {
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05305742 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
5743 pTdlsLinkEstablishReq->isOffChannelSupported;
Atul Mittalbceb4a12014-11-27 18:50:19 +05305744 }
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05305745
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05305746 if ((pTdlsLinkEstablishReq->supportedChannelsLen > 0) &&
5747 (pTdlsLinkEstablishReq->supportedChannelsLen <= SIR_MAC_MAX_SUPP_CHANNELS))
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305748 {
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 Ahujab3a1a152014-11-11 22:14:10 +05305758 limLog(pMac, LOGE,
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305759 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 Nakkala79ff85d2013-05-27 17:05:29 +05305772 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 Johnson0f4d0bc2013-11-03 17:48:50 -08005778 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305779 goto lim_tdls_link_establish_error;
5780 }
5781 return eSIR_SUCCESS;
5782lim_tdls_link_establish_error:
5783 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
5784 NULL, eSIR_FAILURE) ;
5785
5786 return eSIR_SUCCESS;
5787}
5788
5789
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005790/* Delete all the TDLS peer connected before leaving the BSS */
5791tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
5792{
5793 tpDphHashNode pStaDs = NULL ;
5794 int i, aid;
5795
5796 if (NULL == psessionEntry)
5797 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05305798 limLog(pMac, LOGE, FL("NULL psessionEntry"));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005799 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 Ahujab3a1a152014-11-11 22:14:10 +05305814 limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
5815 MAC_ADDR_ARRAY(pStaDs->staAddr));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005816
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 Mittalb849d5a2014-07-29 12:08:39 +05305830
5831
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05305832tANI_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 Mittalb849d5a2014-07-29 12:08:39 +05305879tANI_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 POTTETIe8bd41a2015-01-29 14:52:43 +05305908 for (i=0; (i < 25 && class->channels[i]); i++)
Atul Mittalb849d5a2014-07-29 12:08:39 +05305909 {
5910 if (channel == class->channels[i])
5911 return class->op_class;
5912 }
5913 }
5914 class++;
5915 }
5916 return 0;
5917}
5918
5919tANI_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
5937void 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 V1ccee932012-12-12 14:49:46 -08006039#endif
Atul Mittalc0f739f2014-07-31 13:47:47 +05306040// tdlsoffchan
6041/*
6042 * Process Channel Switch from SME.
6043 */
6044tSirRetStatus 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 Mittal60bd4292014-08-14 12:19:27 +05306068 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
6069 pTdlsChanSwitch->peerMac,
6070 NULL, eSIR_FAILURE) ;
Atul Mittalc0f739f2014-07-31 13:47:47 +05306071 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 POTTETIe8bd41a2015-01-29 14:52:43 +05306114 /* 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 Mittalc0f739f2014-07-31 13:47:47 +05306142 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 POTTETIe8bd41a2015-01-29 14:52:43 +05306150
Atul Mittalc0f739f2014-07-31 13:47:47 +05306151 if(pMsgTdlsChanSwitch->operClass == 0)
6152 {
6153
6154 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
6155 "Invalid Operating class 0 !!!");
Kaushik, Sushant651a5342014-10-31 18:31:45 +05306156 vos_mem_free(pMsgTdlsChanSwitch);
Atul Mittalc0f739f2014-07-31 13:47:47 +05306157 goto lim_tdls_chan_switch_error;
6158 }
6159 else
6160 {
6161
6162 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05306163 "%s: TDLS Channel Switch params: staIdx %d class %d ch %d bw %d"
6164 " mode %d country code %c%c",
Atul Mittalc0f739f2014-07-31 13:47:47 +05306165 __func__,
6166 pMsgTdlsChanSwitch->staIdx,
6167 pMsgTdlsChanSwitch->operClass,
6168 pMsgTdlsChanSwitch->tdlsOffCh,
6169 pMsgTdlsChanSwitch->tdlsOffChBwOffset,
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05306170 pMsgTdlsChanSwitch->tdlsSwMode,
6171 pMac->scan.countryCodeCurrent[0],
6172 pMac->scan.countryCodeCurrent[1]);
Atul Mittalc0f739f2014-07-31 13:47:47 +05306173 }
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, Sushant651a5342014-10-31 18:31:45 +05306182 vos_mem_free(pMsgTdlsChanSwitch);
Atul Mittalc0f739f2014-07-31 13:47:47 +05306183 goto lim_tdls_chan_switch_error;
6184 }
6185
6186 return eSIR_SUCCESS;
6187
6188lim_tdls_chan_switch_error:
Atul Mittal60bd4292014-08-14 12:19:27 +05306189 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
6190 pTdlsChanSwitch->peerMac,
6191 NULL, eSIR_FAILURE);
Atul Mittalc0f739f2014-07-31 13:47:47 +05306192 return eSIR_FAILURE;
6193}
6194