blob: a49f39a35df1c01a24c0d7416f20de507b8ccdc9 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Kiet 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
Hoonki Lee1090c6a2013-01-16 17:40:54 -080095#ifdef WLAN_FEATURE_TDLS_DEBUG
96#define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
97#else
98#define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_INFO
99#endif
Kiran V1ccee932012-12-12 14:49:46 -0800100
101#ifdef FEATURE_WLAN_TDLS_INTERNAL
102/* forword declarations */
103static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
104 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) ;
105static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
106 tSirMacAddr peerMac, tANI_U8 status);
107static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
108 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) ;
109static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
110 tANI_U8 state);
111static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
112 tLimTdlsLinkSetupPeer **setupPeer) ;
113static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
114
115static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
116static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
117 tpPESession psessionEntry) ;
118
119#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800120static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
121 tSirTdlsAddStaReq *pAddStaReq,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530122 tpPESession psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800123void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
124 tDot11fIELinkIdentifier *linkIden,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530125 tSirMacAddr peerMac, tANI_U8 reqType) ;
Kiran V1ccee932012-12-12 14:49:46 -0800126void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
127 tDot11fIEExtCap *extCapability) ;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800128
Naresh Jayarambc62ba42014-02-12 21:39:14 +0530129void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
130 tpPESession psessionEntry,
131 tDot11fIESuppChannels *suppChannels,
132 tDot11fIESuppOperatingClasses *suppOperClasses);
133
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800134void limLogVHTCap(tpAniSirGlobal pMac,
135 tDot11fIEVHTCaps *pDot11f);
136tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
137 tpSirSupportedRates pRates,
138 tDot11fIEVHTCaps *pPeerVHTCaps,
139 tpPESession psessionEntry);
140ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode);
Kiran V1ccee932012-12-12 14:49:46 -0800141/*
142 * TDLS data frames will go out/come in as non-qos data.
143 * so, eth_890d_header will be aligned access..
144 */
145static const tANI_U8 eth_890d_header[] =
146{
147 0xaa, 0xaa, 0x03, 0x00,
148 0x00, 0x00, 0x89, 0x0d,
149} ;
150
151/*
152 * type of links used in TDLS
153 */
154enum tdlsLinks
155{
156 TDLS_LINK_AP,
157 TDLS_LINK_DIRECT
158} eTdlsLink ;
159
160/*
161 * node status in node searching
162 */
163enum tdlsLinkNodeStatus
164{
165 TDLS_NODE_NOT_FOUND,
166 TDLS_NODE_FOUND
167} eTdlsLinkNodeStatus ;
168
169
170enum tdlsReqType
171{
172 TDLS_INITIATOR,
173 TDLS_RESPONDER
174} eTdlsReqType ;
175
176typedef enum tdlsLinkSetupStatus
177{
178 TDLS_SETUP_STATUS_SUCCESS = 0,
179 TDLS_SETUP_STATUS_FAILURE = 37
180}etdlsLinkSetupStatus ;
181
182/* some local defines */
183#define LINK_IDEN_BSSID_OFFSET (0)
184#define PEER_MAC_OFFSET (12)
185#define STA_MAC_OFFSET (6)
186#define LINK_IDEN_ELE_ID (101)
187//#define LINK_IDEN_LENGTH (18)
188#define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier)
189#define PTI_LINK_IDEN_OFFSET (5)
190#define PTI_BUF_STATUS_OFFSET (25)
191
192/* TODO, Move this parameters to configuration */
193#define PEER_PSM_SUPPORT (0)
Hoonki Lee93e67ff2013-03-19 15:49:25 -0700194#define PEER_BUFFER_STA_SUPPORT (0)
Kiran V1ccee932012-12-12 14:49:46 -0800195#define CH_SWITCH_SUPPORT (0)
196#define TDLS_SUPPORT (1)
197#define TDLS_PROHIBITED (0)
198#define TDLS_CH_SWITCH_PROHIBITED (1)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800199/** @brief Set bit manipulation macro */
200#define SET_BIT(value,mask) ((value) |= (1 << (mask)))
201/** @brief Clear bit manipulation macro */
202#define CLEAR_BIT(value,mask) ((value) &= ~(1 << (mask)))
203/** @brief Check bit manipulation macro */
204#define CHECK_BIT(value, mask) ((value) & (1 << (mask)))
205
206#define SET_PEER_AID_BITMAP(peer_bitmap, aid) \
207 if ((aid) < (sizeof(tANI_U32) << 3)) \
208 SET_BIT(peer_bitmap[0], (aid)); \
209 else if ((aid) < (sizeof(tANI_U32) << 4)) \
210 SET_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
211
212#define CLEAR_PEER_AID_BITMAP(peer_bitmap, aid) \
213 if ((aid) < (sizeof(tANI_U32) << 3)) \
214 CLEAR_BIT(peer_bitmap[0], (aid)); \
215 else if ((aid) < (sizeof(tANI_U32) << 4)) \
216 CLEAR_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
217
Kiran V1ccee932012-12-12 14:49:46 -0800218
219#ifdef LIM_DEBUG_TDLS
220#define TDLS_CASE_RETURN_STRING(x) case (x): return( ((const tANI_U8*)#x) + 8); /* 8 = remove redundant SIR_MAC_ */
221
222#ifdef FEATURE_WLAN_TDLS
223#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100)
224#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800)
225#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200)
226#endif
227
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530228#define IS_QOS_ENABLED(psessionEntry) ((((psessionEntry)->limQosEnabled) && \
229 SIR_MAC_GET_QOS((psessionEntry)->limCurrentBssCaps)) || \
230 (((psessionEntry)->limWmeEnabled ) && \
231 LIM_BSS_CAPS_GET(WME, (psessionEntry)->limCurrentBssQosCaps)))
232
233#define TID_AC_VI 4
234#define TID_AC_BK 1
235
Kiran V1ccee932012-12-12 14:49:46 -0800236const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
237{
238 switch( tdlsActionCode )
239 {
240 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
241 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
242 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
243 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
244 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
245 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
246 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
247 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
248 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
249 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
250 }
251 return (const tANI_U8*)"UNKNOWN";
252}
253#endif
254#if 0
255static void printMacAddr(tSirMacAddr macAddr)
256{
257 int i = 0 ;
258 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
259
260 for(i = 0 ; i < 6; i++)
261 {
262 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
263 (" %02x "), macAddr[i]);
264 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700265 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (""));
Kiran V1ccee932012-12-12 14:49:46 -0800266 return ;
267}
268#endif
Kiran V1ccee932012-12-12 14:49:46 -0800269/*
270 * initialize TDLS setup list and related data structures.
271 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800272void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800273{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800274#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800275 pMac->lim.gLimTdlsDisResultList = NULL ;
276 pMac->lim.gLimTdlsDisStaCount = 0 ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530277 vos_mem_set(&pMac->lim.gLimTdlsDisReq, sizeof(tSirTdlsDisReq), 0);
278 vos_mem_set(&pMac->lim.gLimTdlsLinkSetupInfo, sizeof(tLimTdlsLinkSetupInfo), 0);
Kiran V1ccee932012-12-12 14:49:46 -0800279 pMac->lim.gAddStaDisRspWait = 0 ;
280
281#ifdef FEATURE_WLAN_TDLS_NEGATIVE
282 /* when reassociated, negative behavior will not be kept */
283 /* you have to explicitly enable negative behavior per (re)association */
284 pMac->lim.gLimTdlsNegativeBehavior = 0;
285#endif
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800286#endif
287 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800288
289 return ;
290}
Kiran V1ccee932012-12-12 14:49:46 -0800291#ifdef FEATURE_WLAN_TDLS_NEGATIVE
292void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
293{
294 if(on) {
295 if(value == 255)
296 pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
297 else
298 pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
299 }
300 else {
301 if(value == 255)
302 pMac->lim.gLimTdlsNegativeBehavior = 0;
303 else
304 pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
305 }
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800306 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 -0800307 value, on, pMac->lim.gLimTdlsNegativeBehavior));
308}
309#endif
310#if 0
311/*
312 * This function is used for creating TDLS public Action frame to
313 * transmit on Direct link
314 */
315static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
316 tANI_U8 type, tANI_U8 subType,
317 tANI_U8 *link_iden )
318{
319 tpSirMacMgmtHdr pMacHdr ;
320 tANI_U8 *bssid = link_iden ;
321#if 0
322 tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
323 tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
324#else
325 tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
326 tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
327#endif
328 tANI_U8 toDs = ANI_TXDIR_IBSS ;
329
330 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
331
332 /*
333 * prepare 802.11 header
334 */
335 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
336 pMacHdr->fc.type = type ;
337 pMacHdr->fc.subType = subType ;
338 /*
339 * TL is not setting up below fields, so we are doing it here
340 */
341 pMacHdr->fc.toDS = toDs ;
342 pMacHdr->fc.powerMgmt = 0 ;
343
344
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530345 vos_mem_copy( (tANI_U8 *) pMacHdr->da, peerMac, sizeof( tSirMacAddr ));
346 vos_mem_copy( (tANI_U8 *) pMacHdr->sa,
Kiran V1ccee932012-12-12 14:49:46 -0800347 staMac, sizeof( tSirMacAddr ));
348
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530349 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Kiran V1ccee932012-12-12 14:49:46 -0800350 bssid, sizeof( tSirMacAddr ));
351
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800352 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"),
353 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5],
354 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5],
355 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2],
Kiran V1ccee932012-12-12 14:49:46 -0800356 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
357
358 return ;
359}
360#endif
361/*
362 * prepare TDLS frame header, it includes
363 * | | | |
364 * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
365 * | | | |
366 */
367static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530368 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType,
369 tANI_U8 tid, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800370{
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530371 tpSirMacDataHdr3a pMacHdr ;
Kiran V1ccee932012-12-12 14:49:46 -0800372 tANI_U32 header_offset = 0 ;
373 tANI_U8 *addr1 = NULL ;
374 tANI_U8 *addr3 = NULL ;
375 tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP)
376 ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ;
377 tANI_U8 *peerMac = (reqType == TDLS_INITIATOR)
378 ? link_iden->RespStaAddr : link_iden->InitStaAddr;
379 tANI_U8 *staMac = (reqType == TDLS_INITIATOR)
380 ? link_iden->InitStaAddr : link_iden->RespStaAddr;
381
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530382 pMacHdr = (tpSirMacDataHdr3a) (pFrame);
Kiran V1ccee932012-12-12 14:49:46 -0800383
384 /*
385 * if TDLS frame goes through the AP link, it follows normal address
386 * pattern, if TDLS frame goes thorugh the direct link, then
387 * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
388 */
389 (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
390 (addr3 = (peerMac)))
391 : ((addr1 = (peerMac)),
392 (addr3 = (link_iden->bssid))) ;
393 /*
394 * prepare 802.11 header
395 */
396 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
397 pMacHdr->fc.type = SIR_MAC_DATA_FRAME ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530398 pMacHdr->fc.subType = IS_QOS_ENABLED(psessionEntry) ? SIR_MAC_DATA_QOS_DATA : SIR_MAC_DATA_DATA;
399
Kiran V1ccee932012-12-12 14:49:46 -0800400 /*
401 * TL is not setting up below fields, so we are doing it here
402 */
403 pMacHdr->fc.toDS = toDs ;
404 pMacHdr->fc.powerMgmt = 0 ;
405 pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
406
407
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530408 vos_mem_copy( (tANI_U8 *) pMacHdr->addr1,
409 (tANI_U8 *)addr1,
410 sizeof( tSirMacAddr ));
411 vos_mem_copy( (tANI_U8 *) pMacHdr->addr2,
412 (tANI_U8 *) staMac,
413 sizeof( tSirMacAddr ));
Kiran V1ccee932012-12-12 14:49:46 -0800414
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530415 vos_mem_copy( (tANI_U8 *) pMacHdr->addr3,
416 (tANI_U8 *) (addr3),
417 sizeof( tSirMacAddr ));
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530418
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800419 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, ("Preparing TDLS frame header to %s\n%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x"),
420 (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD",
421 pMacHdr->addr1[0], pMacHdr->addr1[1], pMacHdr->addr1[2], pMacHdr->addr1[3], pMacHdr->addr1[4], pMacHdr->addr1[5],
422 pMacHdr->addr2[0], pMacHdr->addr2[1], pMacHdr->addr2[2], pMacHdr->addr2[3], pMacHdr->addr2[4], pMacHdr->addr2[5],
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530423 pMacHdr->addr3[0], pMacHdr->addr3[1], pMacHdr->addr3[2], pMacHdr->addr3[3], pMacHdr->addr3[4], pMacHdr->addr3[5]));
Kiran V1ccee932012-12-12 14:49:46 -0800424
425 //printMacAddr(pMacHdr->bssId) ;
426 //printMacAddr(pMacHdr->sa) ;
427 //printMacAddr(pMacHdr->da) ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530428
429 if (IS_QOS_ENABLED(psessionEntry))
430 {
431 pMacHdr->qosControl.tid = tid;
432 header_offset += sizeof(tSirMacDataHdr3a);
433 }
434 else
435 header_offset += sizeof(tSirMacMgmtHdr);
436
Kiran V1ccee932012-12-12 14:49:46 -0800437 /*
438 * Now form RFC1042 header
439 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530440 vos_mem_copy((tANI_U8 *)(pFrame + header_offset),
441 (tANI_U8 *)eth_890d_header, sizeof(eth_890d_header)) ;
Kiran V1ccee932012-12-12 14:49:46 -0800442
443 header_offset += sizeof(eth_890d_header) ;
444
445 /* add payload type as TDLS */
446 *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
447
448 return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ;
449}
450
451/*
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800452 * TX Complete for Management frames
453 */
454 eHalStatus limMgmtTXComplete(tpAniSirGlobal pMac,
455 tANI_U32 txCompleteSuccess)
456{
457 tpPESession psessionEntry = NULL ;
458
459 if (0xff != pMac->lim.mgmtFrameSessionId)
460 {
461 psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.mgmtFrameSessionId);
462 if (NULL == psessionEntry)
463 {
464 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
465 ("%s: sessionID %d is not found"), __func__, pMac->lim.mgmtFrameSessionId);
466 return eHAL_STATUS_FAILURE;
467 }
468 limSendSmeMgmtTXCompletion(pMac, psessionEntry, txCompleteSuccess);
469 pMac->lim.mgmtFrameSessionId = 0xff;
470 }
471 return eHAL_STATUS_SUCCESS;
472}
473
474/*
Kiran V1ccee932012-12-12 14:49:46 -0800475 * This function can be used for bacst or unicast discovery request
476 * We are not differentiating it here, it will all depnds on peer MAC address,
477 */
478tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
479 tANI_U8 dialog, tpPESession psessionEntry)
480{
481 tDot11fTDLSDisReq tdlsDisReq ;
482 tANI_U32 status = 0 ;
483 tANI_U32 nPayload = 0 ;
484 tANI_U32 size = 0 ;
485 tANI_U32 nBytes = 0 ;
486 tANI_U32 header_offset = 0 ;
487 tANI_U8 *pFrame;
488 void *pPacket;
489 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800490#ifndef NO_PAD_TDLS_MIN_8023_SIZE
491 tANI_U32 padLen = 0;
492#endif
Kiran V1ccee932012-12-12 14:49:46 -0800493
494 /*
495 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
496 * and then hand it off to 'dot11fPackProbeRequest' (for
497 * serialization). We start by zero-initializing the structure:
498 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530499 vos_mem_set( (tANI_U8*)&tdlsDisReq,
500 sizeof( tDot11fTDLSDisReq ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800501
502 /*
503 * setup Fixed fields,
504 */
505 tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
506 tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ;
507 tdlsDisReq.DialogToken.token = dialog ;
508
509
510 size = sizeof(tSirMacAddr) ;
511
512 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier,
513 peer_mac, TDLS_INITIATOR) ;
514
515 /*
516 * now we pack it. First, how much space are we going to need?
517 */
518 status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
519 if ( DOT11F_FAILED( status ) )
520 {
521 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700522 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800523 /* We'll fall back on the worst case scenario: */
524 nPayload = sizeof( tDot11fTDLSDisReq );
525 }
526 else if ( DOT11F_WARNED( status ) )
527 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800528 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -0800529 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700530 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800531 }
532
533 /*
534 * This frame is going out from PE as data frames with special ethertype
535 * 89-0d.
536 * 8 bytes of RFC 1042 header
537 */
538
539
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530540 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
541 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
542 + sizeof( eth_890d_header )
543 + PAYLOAD_TYPE_TDLS_SIZE ;
Kiran V1ccee932012-12-12 14:49:46 -0800544
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800545#ifndef NO_PAD_TDLS_MIN_8023_SIZE
546 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
547 Hence AP itself padding some bytes, which caused teardown packet is dropped at
548 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
549 */
550 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
551 {
552 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
553
554 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
555 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
556 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
557
558 nBytes += padLen;
559 }
560#endif
561
Kiran V1ccee932012-12-12 14:49:46 -0800562 /* Ok-- try to allocate memory from MGMT PKT pool */
563
564 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
565 ( tANI_U16 )nBytes, ( void** ) &pFrame,
566 ( void** ) &pPacket );
567 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
568 {
569 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700570 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -0800571 return eSIR_MEM_ALLOC_FAILED;
572 }
573
574 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530575 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800576
577 /*
578 * IE formation, memory allocation is completed, Now form TDLS discovery
579 * request frame
580 */
581
582 /* fill out the buffer descriptor */
583
584 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530585 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800586
587#ifdef FEATURE_WLAN_TDLS_NEGATIVE
588 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
589 {
590 tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
591 tdlsDisReq.LinkIdentifier.bssid[5] = 0xad;
592 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800593 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Req"),
594 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800595 }
596#endif
597 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
598 + header_offset, nPayload, &nPayload );
599
600 if ( DOT11F_FAILED( status ) )
601 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800602 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
603 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800604 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
605 ( void* ) pFrame, ( void* ) pPacket );
606 return eSIR_FAILURE;
607 }
608 else if ( DOT11F_WARNED( status ) )
609 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800610 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
611 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800612 }
613
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800614#ifndef NO_PAD_TDLS_MIN_8023_SIZE
615 if (padLen != 0)
616 {
617 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
618 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload;
619 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
620 padVendorSpecific[0] = 221;
621 padVendorSpecific[1] = padLen - 2;
622 padVendorSpecific[2] = 0x00;
623 padVendorSpecific[3] = 0xA0;
624 padVendorSpecific[4] = 0xC6;
625
626 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
627 padLen ));
628
629 /* padding zero if more than 5 bytes are required */
630 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530631 vos_mem_set( pFrame + header_offset + nPayload + MIN_VENDOR_SPECIFIC_IE_SIZE,
632 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800633 }
634#endif
Kiran V1ccee932012-12-12 14:49:46 -0800635
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800636 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA "),
Kiran V1ccee932012-12-12 14:49:46 -0800637 SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) ));
638
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800639 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -0800640 HAL_TXRX_FRM_802_11_DATA,
641 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530642 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800643 limTxComplete, pFrame,
644 limMgmtTXComplete,
645 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME);
Kiran V1ccee932012-12-12 14:49:46 -0800646 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
647 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800648 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700649 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -0800650 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -0800651 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800652 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -0800653
654 return eSIR_SUCCESS;
655
656}
657
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800658#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800659/*
660 * Once Discovery response is sent successfully (or failure) on air, now send
661 * response to PE and send del STA to HAL.
662 */
663eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac,
664 tANI_U32 txCompleteSuccess)
665{
666 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800667 tpDphHashNode pStaDs = NULL ;
668 tSirTdlsPeerInfo *peerInfo = 0 ;
669
670 /* find peer by looking into the list by expected state */
671 peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ;
672
673 if(NULL == peerInfo)
674 {
675 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700676 ("DisRspTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800677 VOS_ASSERT(0) ;
678 return eHAL_STATUS_FAILURE;
679 }
680
681 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ;
682
683 if(peerInfo->delStaNeeded)
684 {
685 tpPESession psessionEntry;
686
687 peerInfo->delStaNeeded = false ;
688 psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId);
689
690 if(NULL == psessionEntry)
691 {
692 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700693 ("DisRspTxComplete: sessionID %d is not found"), peerInfo->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800694 return eHAL_STATUS_FAILURE;
695 }
696 /* send del STA to remove context for this TDLS STA */
697 pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ;
698
699 /* now send indication to SME-->HDD->TL to remove STA from TL */
700 if(pStaDs)
701 {
702 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
703 pStaDs, eSIR_SUCCESS) ;
704 }
705 else
706 {
707 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800708 ("DisRspTxComplete: staDs not found for " MAC_ADDRESS_STR),
709 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800710 VOS_ASSERT(0) ;
711 return eHAL_STATUS_FAILURE;
712 }
713 }
714
715 if(!txCompleteSuccess)
716 {
717 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
718 ("TX complete failure for Dis RSP"));
719 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
720 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
721 status = eHAL_STATUS_FAILURE;
722 }
723 else
724 {
725 limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS,
726 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
727 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
728 ("TX complete Success for Dis RSP"));
729 status = eHAL_STATUS_SUCCESS ;
730 }
731 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800732 return status ;
733
734}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800735#endif
736
737#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800738/*
739 * Once setup CNF is sent successfully (or failure) on air, now send
740 * response to PE and send del STA to HAL.
741 */
742eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
743 tANI_U32 txCompleteSuccess)
744{
745 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800746 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
747 /* find peer by looking into the list by expected state */
748 limTdlsFindSetupPeerByState(pMac,
749 TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ;
750
751 if(NULL == peerInfo)
752 {
753 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700754 ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800755 VOS_ASSERT(0) ;
756 return eHAL_STATUS_FAILURE;
757 }
758
759 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
760 (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
761
762 if(!txCompleteSuccess)
763 {
764 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
765 ("TX complete Failure for setup CNF"));
766 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac,
767 eWNI_SME_TDLS_LINK_START_RSP) ;
768 status = eHAL_STATUS_FAILURE;
769 }
770 else
771 {
772 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800773 ("RSP-->SME peer MAC = " MAC_ADDRESS_STR),
774 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800775
776 limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
777 eWNI_SME_TDLS_LINK_START_RSP) ;
778
779 /* tdls_hklee: prepare PTI template and send it to HAL */
780 limTdlsLinkEstablish(pMac, (peerInfo)->peerMac);
781
782 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
783 ("TX complete Success for setup CNF"));
784 status = eHAL_STATUS_SUCCESS ;
785 }
786 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800787 return status ;
Kiran V1ccee932012-12-12 14:49:46 -0800788}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800789#endif
Kiran V1ccee932012-12-12 14:49:46 -0800790
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800791#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800792/*
793 * Tx Complete for Teardown frame
794 */
795eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
796 tANI_U32 txCompleteSuccess)
797{
798 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800799 tpDphHashNode pStaDs = NULL ;
800 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
801 tpPESession psessionEntry = NULL ;
802 //tANI_U16 msgType = 0 ;
803
804 //tSirMacAddr peerMac = {0} ;
805 /* find peer by looking into the list by expected state */
806 limTdlsFindSetupPeerByState(pMac,
807 TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ;
808
809 if(NULL == peerInfo)
810 {
811 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700812 ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800813 VOS_ASSERT(0) ;
814 return eHAL_STATUS_FAILURE;
815 }
816
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530817 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800818 ("teardown peer Mac = " MAC_ADDRESS_STR),
819 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800820
821
822 //pMac->hal.pCBackFnTxComp = NULL ;
823
824 psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId);
825
826 if(NULL == psessionEntry)
827 {
828 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700829 ("limTdlsTeardownTxComplete: sessionID %d is not found"), (peerInfo)->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800830 VOS_ASSERT(0) ;
831 return eHAL_STATUS_FAILURE;
832 }
833
834 if(!txCompleteSuccess)
835 {
836 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700837 ("TX complete failure for Teardown ")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800838
839 /*
840 * we should be sending Teradown to AP with status code
841 * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if
842 * that is delivered or not, any way we removing this peer STA from our
843 * list
844 */
845 if(NULL != psessionEntry)
846 {
847 limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac,
848 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ;
849 }
850 }
851
852 if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state)
853 {
854 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
855 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
856 /* send del STA to remove context for this TDLS STA */
857 if(NULL != psessionEntry)
858 {
859 /* tdls_hklee: send message to HAL before it is deleted */
860 limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ;
861
862 pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ;
863 }
864
865 /* now send indication to SME-->HDD->TL to remove STA from TL */
866 if(!pStaDs)
867 {
868 VOS_ASSERT(0) ;
869 return eSIR_FAILURE ;
870 }
871 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
872 pStaDs, eSIR_SUCCESS) ;
873
874 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700875 ("TX complete SUCCESS for Teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800876 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700877 ("Prev State = %d"), (peerInfo)->tdls_prev_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -0800878 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
879 eWNI_SME_TDLS_TEARDOWN_RSP) ;
880 /* Delete Peer for Link Peer List */
881 limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ;
882 }
883 else
884 {
885 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
886 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
887 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
888 eWNI_SME_TDLS_TEARDOWN_IND) ;
889 }
890
891
892#if 0
893 /* if previous state is link restart, then restart link setup again */
894 if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state)
895 {
896 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
897 limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37,
898 peerMac, psessionEntry) ;
899 }
900#endif
901 status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800902 return status ;
903}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800904#endif
Kiran V1ccee932012-12-12 14:49:46 -0800905
906/*
Kiet Lam770920c2013-10-21 12:49:30 +0530907 * This static function is consistent with any kind of TDLS management
908 * frames we are sending. Currently it is being used by limSendTdlsDisRspFrame,
909 * limSendTdlsLinkSetupReqFrame and limSendTdlsSetupRspFrame
910 */
911static void PopulateDot11fTdlsHtVhtCap(tpAniSirGlobal pMac, uint32 selfDot11Mode,
912 tDot11fIEHTCaps *htCap, tDot11fIEVHTCaps *vhtCap,
913 tpPESession psessionEntry)
914{
915 if (IS_DOT11_MODE_HT(selfDot11Mode))
916 {
917 /* Include HT Capability IE */
918 PopulateDot11fHTCaps( pMac, NULL, htCap );
919 htCap->present = 1;
920 if (psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END)
921 {
922 /* hardcode NO channel bonding in 2.4Ghz */
923 htCap->supportedChannelWidthSet = 0;
924 }
925 else
926 {
927 //Placeholder to support different channel bonding mode of TDLS than AP.
928 //wlan_cfgGetInt(pMac,WNI_CFG_TDLS_CHANNEL_BONDING_MODE,&tdlsChannelBondingMode);
929 //htCap->supportedChannelWidthSet = tdlsChannelBondingMode ? 1 : 0;
930 htCap->supportedChannelWidthSet = 1; // hardcode it to max
931 }
932 }
933 else
934 {
935 htCap->present = 0;
936 }
937#ifdef WLAN_FEATURE_11AC
938 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
939 pMac->roam.configParam.enableVhtFor24GHz) ||
940 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
941 {
942 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
943 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
944 {
945 /* Include VHT Capability IE */
946 PopulateDot11fVHTCaps( pMac, vhtCap );
947 }
948 else
949 {
950 vhtCap->present = 0;
951 }
952 }
953 else
954 {
955 /* Vht Disable from ini in 2.4 GHz */
956 vhtCap->present = 0;
957 }
958#endif
959}
960
961/*
Kiran V1ccee932012-12-12 14:49:46 -0800962 * Send TDLS discovery response frame on direct link.
963 */
964
965static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
966 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry)
967{
968 tDot11fTDLSDisRsp tdlsDisRsp ;
969 tANI_U16 caps = 0 ;
970 tANI_U32 status = 0 ;
971 tANI_U32 nPayload = 0 ;
972 tANI_U32 nBytes = 0 ;
973 tANI_U8 *pFrame;
974 void *pPacket;
975 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -0700976 uint32 selfDot11Mode;
977// Placeholder to support different channel bonding mode of TDLS than AP.
978// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
979// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
980// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
981// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -0800982
983 /*
984 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
985 * and then hand it off to 'dot11fPackProbeRequest' (for
986 * serialization). We start by zero-initializing the structure:
987 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530988 vos_mem_set( ( tANI_U8* )&tdlsDisRsp,
989 sizeof( tDot11fTDLSDisRsp ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800990
991 /*
992 * setup Fixed fields,
993 */
994 tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
995 tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ;
996 tdlsDisRsp.DialogToken.token = dialog ;
997
998 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
999 peerMac, TDLS_RESPONDER) ;
1000
1001 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1002 {
1003 /*
1004 * Could not get Capabilities value
1005 * from CFG. Log error.
1006 */
1007 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001008 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001009 }
1010 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
1011
1012 /* populate supported rate IE */
1013 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1014 &tdlsDisRsp.SuppRates, psessionEntry );
1015
1016 /* Populate extended supported rates */
1017 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1018 &tdlsDisRsp.ExtSuppRates, psessionEntry );
1019
1020 /* Populate extended supported rates */
1021 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
1022
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001023 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1024
Kiet Lam770920c2013-10-21 12:49:30 +05301025 /* Populate HT/VHT Capabilities */
1026 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsDisRsp.HTCaps,
1027 &tdlsDisRsp.VHTCaps, psessionEntry );
Kiran V1ccee932012-12-12 14:49:46 -08001028
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301029 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1030 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1031 &tdlsDisRsp.SuppChannels,
1032 &tdlsDisRsp.SuppOperatingClasses);
Kiran V1ccee932012-12-12 14:49:46 -08001033 /*
1034 * now we pack it. First, how much space are we going to need?
1035 */
1036 status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
1037 if ( DOT11F_FAILED( status ) )
1038 {
1039 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001040 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001041 /* We'll fall back on the worst case scenario: */
1042 nPayload = sizeof( tDot11fProbeRequest );
1043 }
1044 else if ( DOT11F_WARNED( status ) )
1045 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001046 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001047 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001048 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001049 }
1050
1051 /*
1052 * This frame is going out from PE as data frames with special ethertype
1053 * 89-0d.
1054 * 8 bytes of RFC 1042 header
1055 */
1056
1057
1058 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ;
1059
1060 /* Ok-- try to allocate memory from MGMT PKT pool */
1061
1062 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1063 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1064 ( void** ) &pPacket );
1065 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1066 {
1067 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001068 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001069 return eSIR_MEM_ALLOC_FAILED;
1070 }
1071
1072 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301073 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001074
1075 /*
1076 * IE formation, memory allocation is completed, Now form TDLS discovery
1077 * response frame
1078 */
1079
1080 /* Make public Action Frame */
1081
1082#if 0
1083 limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1084 SIR_MAC_MGMT_ACTION,
1085 LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
1086#endif
1087 limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1088 SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
1089
1090 {
1091 tpSirMacMgmtHdr pMacHdr;
1092 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1093 pMacHdr->fc.toDS = ANI_TXDIR_IBSS;
1094 pMacHdr->fc.powerMgmt = 0 ;
1095 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1096 }
1097
1098#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1099 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
1100 {
1101 tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
1102 tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad;
1103 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001104 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Rsp"),
1105 MAC_ADDR_ARRAY(tdlsDisRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001106 }
1107#endif
1108 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
1109 sizeof( tSirMacMgmtHdr ),
1110 nPayload, &nPayload );
1111
1112 if ( DOT11F_FAILED( status ) )
1113 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001114 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1115 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1117 ( void* ) pFrame, ( void* ) pPacket );
1118 return eSIR_FAILURE;
1119 }
1120 else if ( DOT11F_WARNED( status ) )
1121 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001122 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1123 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001124 }
1125
1126#if 0
1127 if(pMac->hal.pCBackFnTxComp == NULL)
1128 {
1129 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
1130
1131 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
1132 {
1133 status = eHAL_STATUS_FAILURE;
1134 return status;
1135
1136 }
1137 }
1138#endif
1139 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001140 ("transmitting Discovery response on direct link")) ;
Kiran V1ccee932012-12-12 14:49:46 -08001141
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001142 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -DIRECT-> OTA"),
Kiran V1ccee932012-12-12 14:49:46 -08001143 SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) ));
1144
1145
1146 /*
1147 * Transmit Discovery response and watch if this is delivered to
1148 * peer STA.
1149 */
1150 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1151 HAL_TXRX_FRM_802_11_DATA,
1152 ANI_TXDIR_IBSS,
1153 0,
1154 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001155 limMgmtTXComplete,
Kiran V1ccee932012-12-12 14:49:46 -08001156 HAL_USE_SELF_STA_REQUESTED_MASK );
1157 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1158 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001159 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001160 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001161 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001162 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001163 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001164
1165 return eSIR_SUCCESS;
1166
1167}
1168
1169/*
Kiet Lam770920c2013-10-21 12:49:30 +05301170 * This static function is currently used by limSendTdlsLinkSetupReqFrame and
1171 * limSendTdlsSetupRspFrame to populate the AID if device is 11ac capable.
1172 */
1173static void PopulateDotfTdlsVhtAID(tpAniSirGlobal pMac, uint32 selfDot11Mode,
1174 tSirMacAddr peerMac, tDot11fIEAID *Aid,
1175 tpPESession psessionEntry)
1176{
1177 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
1178 pMac->roam.configParam.enableVhtFor24GHz) ||
1179 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
1180 {
1181 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1182 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1183 {
1184
1185 tANI_U16 aid;
1186 tpDphHashNode pStaDs;
1187
1188 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
1189 if (NULL != pStaDs)
1190 {
1191 Aid->present = 1;
1192 Aid->assocId = aid | LIM_AID_MASK; // set bit 14 and 15 1's
1193 }
1194 else
1195 {
1196 Aid->present = 0;
1197 limLog( pMac, LOGE, FL("pStaDs is NULL for " MAC_ADDRESS_STR ),
1198 MAC_ADDR_ARRAY(peerMac));
1199 }
1200 }
1201 }
1202 else
1203 {
1204 Aid->present = 0;
1205 limLog( pMac, LOGW, FL("Vht not enable from ini for 2.4GHz."));
1206 }
1207}
1208
1209/*
Kiran V1ccee932012-12-12 14:49:46 -08001210 * TDLS setup Request frame on AP link
1211 */
1212
1213tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1214 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301215 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001216{
1217 tDot11fTDLSSetupReq tdlsSetupReq ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301218 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001219 tANI_U32 status = 0 ;
1220 tANI_U32 nPayload = 0 ;
1221 tANI_U32 nBytes = 0 ;
1222 tANI_U32 header_offset = 0 ;
1223 tANI_U8 *pFrame;
1224 void *pPacket;
1225 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001226 uint32 selfDot11Mode;
1227// Placeholder to support different channel bonding mode of TDLS than AP.
1228// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1229// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1230// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1231// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001232
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301233 /*
Kiran V1ccee932012-12-12 14:49:46 -08001234 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1235 * and then hand it off to 'dot11fPackProbeRequest' (for
1236 * serialization). We start by zero-initializing the structure:
1237 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301238 vos_mem_set(( tANI_U8* )&tdlsSetupReq, sizeof( tDot11fTDLSSetupReq ), 0);
Kiran V1ccee932012-12-12 14:49:46 -08001239 tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
1240 tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ;
1241 tdlsSetupReq.DialogToken.token = dialog ;
1242
1243
1244 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
1245 peerMac, TDLS_INITIATOR) ;
1246
1247 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1248 {
1249 /*
1250 * Could not get Capabilities value
1251 * from CFG. Log error.
1252 */
1253 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001254 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001255 }
1256 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1257
1258 /* populate supported rate IE */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301259 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Kiran V1ccee932012-12-12 14:49:46 -08001260 &tdlsSetupReq.SuppRates, psessionEntry );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301261
Kiran V1ccee932012-12-12 14:49:46 -08001262 /* Populate extended supported rates */
1263 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1264 &tdlsSetupReq.ExtSuppRates, psessionEntry );
1265
1266 /* Populate extended supported rates */
1267 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1268
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301269 /*
Kiran V1ccee932012-12-12 14:49:46 -08001270 * TODO: we need to see if we have to support conditions where we have
1271 * EDCA parameter info element is needed a) if we need different QOS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301272 * parameters for off channel operations or QOS is not supported on
Kiran V1ccee932012-12-12 14:49:46 -08001273 * AP link and we wanted to QOS on direct link.
1274 */
1275 /* Populate QOS info, needed for Peer U-APSD session */
1276 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1277 TDLS doesn't want to depend on AP's capability */
1278 tdlsSetupReq.QOSCapsStation.present = 1;
1279 tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
1280 tdlsSetupReq.QOSCapsStation.qack = 0;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301281 tdlsSetupReq.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3) ;
1282 tdlsSetupReq.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04)>> 2);
1283 tdlsSetupReq.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02)>> 1);
1284 tdlsSetupReq.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1285
Kiran V1ccee932012-12-12 14:49:46 -08001286
1287 /*
1288 * we will always try to init TDLS link with 11n capabilities
1289 * let TDLS setup response to come, and we will set our caps based
1290 * of peer caps
1291 */
1292
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001293 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1294
Kiet Lam770920c2013-10-21 12:49:30 +05301295 /* Populate HT/VHT Capabilities */
1296 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupReq.HTCaps,
1297 &tdlsSetupReq.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001298
Kiet Lam770920c2013-10-21 12:49:30 +05301299 /* Populate AID */
1300 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1301 &tdlsSetupReq.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001302
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301303 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1304 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1305 &tdlsSetupReq.SuppChannels,
1306 &tdlsSetupReq.SuppOperatingClasses);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301307 /*
Kiran V1ccee932012-12-12 14:49:46 -08001308 * now we pack it. First, how much space are we going to need?
1309 */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301310 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
Kiran V1ccee932012-12-12 14:49:46 -08001311 &nPayload);
1312 if ( DOT11F_FAILED( status ) )
1313 {
1314 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001315 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001316 /* We'll fall back on the worst case scenario: */
1317 nPayload = sizeof( tDot11fProbeRequest );
1318 }
1319 else if ( DOT11F_WARNED( status ) )
1320 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001321 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001322 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001323 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001324 }
1325
1326
1327 /*
1328 * This frame is going out from PE as data frames with special ethertype
1329 * 89-0d.
1330 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301331 */
Kiran V1ccee932012-12-12 14:49:46 -08001332
1333
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301334 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1335 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1336 + sizeof( eth_890d_header )
1337 + PAYLOAD_TYPE_TDLS_SIZE
1338 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001339
1340 /* Ok-- try to allocate memory from MGMT PKT pool */
1341
1342 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301343 ( tANI_U16 )nBytes, ( void** ) &pFrame,
Kiran V1ccee932012-12-12 14:49:46 -08001344 ( void** ) &pPacket );
1345 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1346 {
1347 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001348 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001349 return eSIR_MEM_ALLOC_FAILED;
1350 }
1351
1352 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301353 vos_mem_set( pFrame, nBytes, 0);
Kiran V1ccee932012-12-12 14:49:46 -08001354
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301355 /*
Kiran V1ccee932012-12-12 14:49:46 -08001356 * IE formation, memory allocation is completed, Now form TDLS discovery
1357 * request frame
1358 */
1359
1360 /* fill out the buffer descriptor */
1361
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301362 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301363 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001364
1365#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1366 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
1367 {
1368 tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301369 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1370 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001371 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Req"),
1372 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001373 }
1374#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001375 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1376 __func__, tdlsSetupReq.VHTCaps.supportedChannelWidthSet, tdlsSetupReq.VHTCaps.rxMCSMap,
1377 tdlsSetupReq.VHTCaps.txMCSMap, tdlsSetupReq.VHTCaps.txSupDataRate );
1378
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301379 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001380 + header_offset, nPayload, &nPayload );
1381
1382 if ( DOT11F_FAILED( status ) )
1383 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001384 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1385 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001386 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1387 ( void* ) pFrame, ( void* ) pPacket );
1388 return eSIR_FAILURE;
1389 }
1390 else if ( DOT11F_WARNED( status ) )
1391 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001392 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1393 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001394 }
1395
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301396 //Copy the additional IE.
Kiran V1ccee932012-12-12 14:49:46 -08001397 //TODO : addIe is added at the end of the frame. This means it doesnt
1398 //follow the order. This should be ok, but we should consider changing this
1399 //if there is any IOT issue.
1400 if( addIeLen != 0 )
1401 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001402 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),
Kiran V1ccee932012-12-12 14:49:46 -08001403 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301404 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001405 }
1406
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001407 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA"),
Kiran V1ccee932012-12-12 14:49:46 -08001408 SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) ));
1409
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001410 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001411 HAL_TXRX_FRM_802_11_DATA,
1412 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301413 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001414 limTxComplete, pFrame,
1415 limMgmtTXComplete,
1416 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
1417
Kiran V1ccee932012-12-12 14:49:46 -08001418 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1419 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001420 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001421 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001422 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001423 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001424 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001425
1426 return eSIR_SUCCESS;
1427
1428}
1429/*
1430 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1431 */
1432
1433tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08001434 tSirMacAddr peerMac, tANI_U16 reason, tANI_U8 responder, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301435 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001436{
1437 tDot11fTDLSTeardown teardown ;
1438 tANI_U32 status = 0 ;
1439 tANI_U32 nPayload = 0 ;
1440 tANI_U32 nBytes = 0 ;
1441 tANI_U32 header_offset = 0 ;
1442 tANI_U8 *pFrame;
1443 void *pPacket;
1444 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001445#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1446 tANI_U32 padLen = 0;
1447#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301448 /*
Kiran V1ccee932012-12-12 14:49:46 -08001449 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1450 * and then hand it off to 'dot11fPackProbeRequest' (for
1451 * serialization). We start by zero-initializing the structure:
1452 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301453 vos_mem_set( ( tANI_U8* )&teardown, sizeof( tDot11fTDLSTeardown ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001454 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1455 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1456 teardown.Reason.code = reason ;
1457
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301458 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
Hoonki Leea34dd892013-02-05 22:56:02 -08001459 peerMac, (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR) ;
Kiran V1ccee932012-12-12 14:49:46 -08001460
1461
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301462 /*
Kiran V1ccee932012-12-12 14:49:46 -08001463 * now we pack it. First, how much space are we going to need?
1464 */
1465 status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
1466 if ( DOT11F_FAILED( status ) )
1467 {
1468 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001469 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001470 /* We'll fall back on the worst case scenario: */
1471 nPayload = sizeof( tDot11fProbeRequest );
1472 }
1473 else if ( DOT11F_WARNED( status ) )
1474 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001475 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001476 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001477 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001478 }
1479
1480
1481 /*
1482 * This frame is going out from PE as data frames with special ethertype
1483 * 89-0d.
1484 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301485 */
Kiran V1ccee932012-12-12 14:49:46 -08001486
1487
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301488 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1489 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1490 + sizeof( eth_890d_header )
1491 + PAYLOAD_TYPE_TDLS_SIZE
1492 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001493
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001494#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1495 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1496 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1497 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1498 */
1499 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1500 {
1501 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1502
1503 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1504 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1505 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1506
1507 nBytes += padLen;
1508 }
1509#endif
1510
Kiran V1ccee932012-12-12 14:49:46 -08001511 /* Ok-- try to allocate memory from MGMT PKT pool */
1512
1513 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1514 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1515 ( void** ) &pPacket );
1516 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1517 {
1518 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001519 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001520 return eSIR_MEM_ALLOC_FAILED;
1521 }
1522
1523 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301524 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001525
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301526 /*
Kiran V1ccee932012-12-12 14:49:46 -08001527 * IE formation, memory allocation is completed, Now form TDLS discovery
1528 * request frame
1529 */
1530
1531 /* fill out the buffer descriptor */
1532
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301533 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1534 LINK_IDEN_ADDR_OFFSET(teardown),
1535 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
Gopichand Nakkala269032c2013-02-07 17:18:15 -08001536 ? TDLS_LINK_AP : TDLS_LINK_DIRECT,
1537 (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301538 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001539
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301540 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001541 + header_offset, nPayload, &nPayload );
1542
1543 if ( DOT11F_FAILED( status ) )
1544 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001545 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req (0x%08x)."),
1546 status );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301547 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Kiran V1ccee932012-12-12 14:49:46 -08001548 ( void* ) pFrame, ( void* ) pPacket );
1549 return eSIR_FAILURE;
1550 }
1551 else if ( DOT11F_WARNED( status ) )
1552 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001553 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1554 "Teardown Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001555 }
1556#if 0
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301557 if(pMac->hal.pCBackFnTxComp == NULL)
Kiran V1ccee932012-12-12 14:49:46 -08001558 {
1559 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301560 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
Kiran V1ccee932012-12-12 14:49:46 -08001561 {
1562 status = eHAL_STATUS_FAILURE;
1563 return status;
1564
1565 }
1566 }
1567 else
1568 {
1569 VOS_ASSERT(0) ;
1570 return status ;
1571 }
1572#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301573
Kiran V1ccee932012-12-12 14:49:46 -08001574 if( addIeLen != 0 )
1575 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001576 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),
Kiran V1ccee932012-12-12 14:49:46 -08001577 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301578 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001579 }
1580
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001581#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1582 if (padLen != 0)
1583 {
1584 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
1585 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
1586 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
1587 padVendorSpecific[0] = 221;
1588 padVendorSpecific[1] = padLen - 2;
1589 padVendorSpecific[2] = 0x00;
1590 padVendorSpecific[3] = 0xA0;
1591 padVendorSpecific[4] = 0xC6;
1592
1593 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
1594 padLen ));
1595
1596 /* padding zero if more than 5 bytes are required */
1597 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301598 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
1599 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001600 }
1601#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001602 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -%s-> OTA"),
1603 SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN),
1604 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ? "AP": "DIRECT" ));
Kiran V1ccee932012-12-12 14:49:46 -08001605
1606 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1607 HAL_TXRX_FRM_802_11_DATA,
1608 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301609 TID_AC_VI,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301610 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001611 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08001612 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001613 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1614 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001615 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001616 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001617 return eSIR_FAILURE;
1618
1619 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001620 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001621 return eSIR_SUCCESS;
1622
1623}
1624
1625/*
1626 * Send Setup RSP frame on AP link.
1627 */
1628static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1629 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
1630 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1631{
1632 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1633 tANI_U32 status = 0 ;
1634 tANI_U16 caps = 0 ;
1635 tANI_U32 nPayload = 0 ;
1636 tANI_U32 header_offset = 0 ;
1637 tANI_U32 nBytes = 0 ;
1638 tANI_U8 *pFrame;
1639 void *pPacket;
1640 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001641 uint32 selfDot11Mode;
1642// Placeholder to support different channel bonding mode of TDLS than AP.
1643// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1644// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1645// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1646// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001647
1648 /*
1649 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1650 * and then hand it off to 'dot11fPackProbeRequest' (for
1651 * serialization). We start by zero-initializing the structure:
1652 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301653 vos_mem_set( ( tANI_U8* )&tdlsSetupRsp, sizeof( tDot11fTDLSSetupRsp ),0 );
Kiran V1ccee932012-12-12 14:49:46 -08001654
1655 /*
1656 * setup Fixed fields,
1657 */
1658 tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
1659 tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ;
1660 tdlsSetupRsp.DialogToken.token = dialog;
1661
1662 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
1663 peerMac, TDLS_RESPONDER) ;
1664
1665 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1666 {
1667 /*
1668 * Could not get Capabilities value
1669 * from CFG. Log error.
1670 */
1671 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001672 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001673 }
1674 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1675
1676 /* ipopulate supported rate IE */
1677 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1678 &tdlsSetupRsp.SuppRates, psessionEntry );
1679
1680 /* Populate extended supported rates */
1681 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1682 &tdlsSetupRsp.ExtSuppRates, psessionEntry );
1683
1684 /* Populate extended supported rates */
1685 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1686
1687 /*
1688 * TODO: we need to see if we have to support conditions where we have
1689 * EDCA parameter info element is needed a) if we need different QOS
1690 * parameters for off channel operations or QOS is not supported on
1691 * AP link and we wanted to QOS on direct link.
1692 */
1693 /* Populate QOS info, needed for Peer U-APSD session */
1694 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1695 TDLS doesn't want to depend on AP's capability */
1696 tdlsSetupRsp.QOSCapsStation.present = 1;
1697 tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
1698 tdlsSetupRsp.QOSCapsStation.qack = 0;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301699 tdlsSetupRsp.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1700 tdlsSetupRsp.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1701 tdlsSetupRsp.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1702 tdlsSetupRsp.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
Kiran V1ccee932012-12-12 14:49:46 -08001703
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001704 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1705
Kiet Lam770920c2013-10-21 12:49:30 +05301706 /* Populate HT/VHT Capabilities */
1707 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupRsp.HTCaps,
1708 &tdlsSetupRsp.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001709
Kiet Lam770920c2013-10-21 12:49:30 +05301710 /* Populate AID */
1711 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1712 &tdlsSetupRsp.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001713
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301714 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1715 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1716 &tdlsSetupRsp.SuppChannels,
1717 &tdlsSetupRsp.SuppOperatingClasses);
1718
Kiran V1ccee932012-12-12 14:49:46 -08001719 tdlsSetupRsp.Status.status = setupStatus ;
1720
1721 /*
1722 * now we pack it. First, how much space are we going to need?
1723 */
1724 status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp,
1725 &nPayload);
1726 if ( DOT11F_FAILED( status ) )
1727 {
1728 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001729 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001730 /* We'll fall back on the worst case scenario: */
1731 nPayload = sizeof( tDot11fProbeRequest );
1732 }
1733 else if ( DOT11F_WARNED( status ) )
1734 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001735 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001736 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001737 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001738 }
1739
1740 /*
1741 * This frame is going out from PE as data frames with special ethertype
1742 * 89-0d.
1743 * 8 bytes of RFC 1042 header
1744 */
1745
1746
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301747 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1748 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1749 + sizeof( eth_890d_header )
1750 + PAYLOAD_TYPE_TDLS_SIZE
1751 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001752
1753 /* Ok-- try to allocate memory from MGMT PKT pool */
1754
1755 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1756 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1757 ( void** ) &pPacket );
1758 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1759 {
1760 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001761 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001762 return eSIR_MEM_ALLOC_FAILED;
1763 }
1764
1765 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301766 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001767
1768 /*
1769 * IE formation, memory allocation is completed, Now form TDLS discovery
1770 * request frame
1771 */
1772
1773 /* fill out the buffer descriptor */
1774
1775 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1776 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp),
1777 TDLS_LINK_AP, TDLS_RESPONDER,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301778 TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001779
1780#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1781 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
1782 {
1783 tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
1784 tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad;
1785 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001786 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Rsp"),
1787 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001788 }
1789#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001790 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1791 __func__, tdlsSetupRsp.VHTCaps.supportedChannelWidthSet, tdlsSetupRsp.VHTCaps.rxMCSMap,
1792 tdlsSetupRsp.VHTCaps.txMCSMap, tdlsSetupRsp.VHTCaps.txSupDataRate );
Kiran V1ccee932012-12-12 14:49:46 -08001793 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1794 + header_offset, nPayload, &nPayload );
1795
1796 if ( DOT11F_FAILED( status ) )
1797 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001798 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1799 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001800 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1801 ( void* ) pFrame, ( void* ) pPacket );
1802 return eSIR_FAILURE;
1803 }
1804 else if ( DOT11F_WARNED( status ) )
1805 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001806 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1807 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001808 }
1809
1810 //Copy the additional IE.
1811 //TODO : addIe is added at the end of the frame. This means it doesnt
1812 //follow the order. This should be ok, but we should consider changing this
1813 //if there is any IOT issue.
1814 if( addIeLen != 0 )
1815 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301816 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001817 }
1818
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001819 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA"),
Kiran V1ccee932012-12-12 14:49:46 -08001820 SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) ));
1821
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001822 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001823 HAL_TXRX_FRM_802_11_DATA,
1824 ANI_TXDIR_TODS,
1825 //ANI_TXDIR_IBSS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301826 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001827 limTxComplete, pFrame,
1828 limMgmtTXComplete,
1829 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001830 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1831 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001832 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001833 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001834 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001835 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001836 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001837
1838 return eSIR_SUCCESS;
1839
1840}
1841
1842/*
1843 * Send TDLS setup CNF frame on AP link
1844 */
1845
1846tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
1847 tANI_U8 dialog, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
1848{
1849 tDot11fTDLSSetupCnf tdlsSetupCnf ;
1850 tANI_U32 status = 0 ;
1851 tANI_U32 nPayload = 0 ;
1852 tANI_U32 nBytes = 0 ;
1853 tANI_U32 header_offset = 0 ;
1854 tANI_U8 *pFrame;
1855 void *pPacket;
1856 eHalStatus halstatus;
Hoonki Lee426f0302013-02-08 17:35:38 -08001857#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1858 tANI_U32 padLen = 0;
1859#endif
Kiran V1ccee932012-12-12 14:49:46 -08001860
1861 /*
1862 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1863 * and then hand it off to 'dot11fPackProbeRequest' (for
1864 * serialization). We start by zero-initializing the structure:
1865 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301866 vos_mem_set( ( tANI_U8* )&tdlsSetupCnf, sizeof( tDot11fTDLSSetupCnf ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001867
1868 /*
1869 * setup Fixed fields,
1870 */
1871 tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
1872 tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ;
1873 tdlsSetupCnf.DialogToken.token = dialog ;
1874
1875#if 1
1876 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
1877 peerMac, TDLS_INITIATOR) ;
1878#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301879 vos_mem_copy( (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier,
1880 (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ;
Kiran V1ccee932012-12-12 14:49:46 -08001881#endif
1882
1883 /*
1884 * TODO: we need to see if we have to support conditions where we have
1885 * EDCA parameter info element is needed a) if we need different QOS
1886 * parameters for off channel operations or QOS is not supported on
1887 * AP link and we wanted to QOS on direct link.
1888 */
1889
1890 /* Include HT Info IE */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001891 /* Need to also check the Self Capability ??? TODO Sunil */
1892 if ( true == psessionEntry->htCapability)
1893 {
1894 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
1895 }
1896 if ( true == psessionEntry->vhtCapability)
1897 {
1898 PopulateDot11fVHTOperation( pMac, &tdlsSetupCnf.VHTOperation);
1899 }
Kiran V1ccee932012-12-12 14:49:46 -08001900
1901 /*
1902 * now we pack it. First, how much space are we going to need?
1903 */
1904 status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf,
1905 &nPayload);
1906 if ( DOT11F_FAILED( status ) )
1907 {
1908 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001909 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001910 /* We'll fall back on the worst case scenario: */
1911 nPayload = sizeof( tDot11fProbeRequest );
1912 }
1913 else if ( DOT11F_WARNED( status ) )
1914 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001915 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001916 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001917 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001918 }
1919
1920 /*
1921 * This frame is going out from PE as data frames with special ethertype
1922 * 89-0d.
1923 * 8 bytes of RFC 1042 header
1924 */
1925
1926
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301927 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1928 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1929 + sizeof( eth_890d_header )
1930 + PAYLOAD_TYPE_TDLS_SIZE
1931 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001932
Hoonki Lee426f0302013-02-08 17:35:38 -08001933#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1934 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1935 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1936 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1937 */
1938 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1939 {
1940 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1941
1942 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1943 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1944 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1945
1946 nBytes += padLen;
1947 }
1948#endif
1949
1950
Kiran V1ccee932012-12-12 14:49:46 -08001951 /* Ok-- try to allocate memory from MGMT PKT pool */
1952
1953 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1954 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1955 ( void** ) &pPacket );
1956 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1957 {
1958 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001959 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001960 return eSIR_MEM_ALLOC_FAILED;
1961 }
1962
1963 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301964 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001965
1966 /*
1967 * IE formation, memory allocation is completed, Now form TDLS discovery
1968 * request frame
1969 */
1970
1971 /* fill out the buffer descriptor */
1972
1973 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1974 LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301975 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001976
1977#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1978 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
1979 tdlsSetupCnf.StatusCode.statusCode = 37;
1980 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001981 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf"));
Kiran V1ccee932012-12-12 14:49:46 -08001982 }
1983#endif
1984 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
1985 + header_offset, nPayload, &nPayload );
1986
1987 if ( DOT11F_FAILED( status ) )
1988 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001989 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1990 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001991 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1992 ( void* ) pFrame, ( void* ) pPacket );
1993 return eSIR_FAILURE;
1994 }
1995 else if ( DOT11F_WARNED( status ) )
1996 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001997 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1998 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001999 }
2000#if 0
2001 if(pMac->hal.pCBackFnTxComp == NULL)
2002 {
2003 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
2004 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
2005 {
2006 status = eHAL_STATUS_FAILURE;
2007 return status;
2008
2009 }
2010 }
2011 else
2012 {
2013 VOS_ASSERT(0) ;
2014 return status ;
2015 }
2016#endif
2017 //Copy the additional IE.
2018 //TODO : addIe is added at the end of the frame. This means it doesnt
2019 //follow the order. This should be ok, but we should consider changing this
2020 //if there is any IOT issue.
2021 if( addIeLen != 0 )
2022 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302023 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08002024 }
2025
Hoonki Lee426f0302013-02-08 17:35:38 -08002026#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2027 if (padLen != 0)
2028 {
2029 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
2030 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
2031 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
2032 padVendorSpecific[0] = 221;
2033 padVendorSpecific[1] = padLen - 2;
2034 padVendorSpecific[2] = 0x00;
2035 padVendorSpecific[3] = 0xA0;
2036 padVendorSpecific[4] = 0xC6;
2037
2038 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
2039 padLen ));
2040
2041 /* padding zero if more than 5 bytes are required */
2042 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302043 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
2044 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee426f0302013-02-08 17:35:38 -08002045 }
2046#endif
2047
2048
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002049 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -AP-> OTA"),
Kiran V1ccee932012-12-12 14:49:46 -08002050 SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) ));
2051
2052 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
2053 HAL_TXRX_FRM_802_11_DATA,
2054 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302055 TID_AC_VI,
Kiran V1ccee932012-12-12 14:49:46 -08002056 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002057 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08002058 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08002059
2060
2061 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2062 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002063 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002064 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08002065 return eSIR_FAILURE;
2066
2067 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002068 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08002069
2070 return eSIR_SUCCESS;
2071}
2072
2073#ifdef FEATURE_WLAN_TDLS_INTERNAL
2074/*
2075 * Convert HT caps to lim based HT caps
2076 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302077static void limTdlsCovertHTCaps(tpAniSirGlobal pMac,
Kiran V1ccee932012-12-12 14:49:46 -08002078 tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps)
2079{
2080
2081 /* HT Capability Info */
2082 peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ;
2083 peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet =
2084 HTCaps->supportedChannelWidthSet ;
2085 peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ;
2086 peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ;
2087 peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ;
2088 peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ;
2089 peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ;
2090 peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ;
2091 peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA;
2092 peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ;
2093 peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ;
2094 peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ;
2095 peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ;
2096 peerInfo->tdlsPeerHtCaps.lsigTXOPProtection =
2097 HTCaps->lsigTXOPProtection ;
2098
2099 /* HT Capa parameters */
2100 peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ;
2101 peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ;
2102 peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ;
2103
2104 /* Extended HT caps */
2105 peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ;
2106 peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ;
2107 peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302108 vos_mem_copy( peerInfo->supportedMCSSet,
Kiran V1ccee932012-12-12 14:49:46 -08002109 HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
2110
2111 return ;
2112}
2113
2114/*
2115 * update capability info..
2116 */
2117void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo,
2118 tDot11fFfCapabilities *Capabilities)
2119{
2120
2121 capabilityInfo->ess = Capabilities->ess;
2122 capabilityInfo->ibss = Capabilities->ibss;
2123 capabilityInfo->cfPollable = Capabilities->cfPollable;
2124 capabilityInfo->cfPollReq = Capabilities->cfPollReq;
2125 capabilityInfo->privacy = Capabilities->privacy;
2126 capabilityInfo->shortPreamble = Capabilities->shortPreamble;
2127 capabilityInfo->pbcc = Capabilities->pbcc;
2128 capabilityInfo->channelAgility = Capabilities->channelAgility;
2129 capabilityInfo->spectrumMgt = Capabilities->spectrumMgt;
2130 capabilityInfo->qos = Capabilities->qos;
2131 capabilityInfo->shortSlotTime = Capabilities->shortSlotTime;
2132 capabilityInfo->apsd = Capabilities->apsd;
2133 capabilityInfo->rrm = Capabilities->rrm;
2134 capabilityInfo->dsssOfdm = Capabilities->dsssOfdm;
2135 capabilityInfo->immediateBA = Capabilities->immediateBA;
2136
2137 return ;
2138}
2139
2140/*
2141 * update Peer info from the link request frame recieved from Peer..
2142 * in list of STA participating in TDLS link setup
2143 */
2144void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac,
2145 tLimTdlsLinkSetupPeer *setupPeer,
2146 tDot11fTDLSSetupReq *setupReq)
2147{
2148
2149 /* Populate peer info of tdls discovery result */
2150
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302151 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupReq->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002152
2153 if(setupReq->SuppRates.present)
2154 {
2155 ConvertSuppRates( pMac, &setupPeer->supportedRates,
2156 &setupReq->SuppRates );
2157 }
2158
2159 /* update QOS info, needed for Peer U-APSD session */
2160 if(setupReq->QOSCapsStation.present)
2161 {
2162 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2163 &setupReq->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002164 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."),
2165 setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd,
2166 setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd,
2167 setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002168 setupReq->QOSCapsStation.qack));
2169 }
2170
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302171 if (setupReq->ExtSuppRates.present)
Kiran V1ccee932012-12-12 14:49:46 -08002172 {
2173 setupPeer->ExtRatesPresent = 1;
2174 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2175 &setupReq->ExtSuppRates );
2176 }
2177 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302178 if (setupReq->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002179 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302180 vos_mem_copy( &setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002181 &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2182 }
2183 /* Update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302184 if (setupReq->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002185 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302186 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002187 &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
2188 }
2189
2190 return ;
2191}
2192
2193/*
2194 * update peer Info recieved with TDLS setup RSP
2195 */
2196void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac,
2197 tLimTdlsLinkSetupPeer *setupPeer,
2198 tDot11fTDLSSetupRsp *setupRsp)
2199{
2200
2201 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302202 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupRsp->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002203
2204 if(setupRsp->SuppRates.present)
2205 {
2206 tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ;
2207 ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates);
2208 }
2209
2210 /* update QOS info, needed for Peer U-APSD session */
2211 if(setupRsp->QOSCapsStation.present)
2212 {
2213 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2214 &setupRsp->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002215 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."),
2216 setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd,
2217 setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd,
2218 setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002219 setupRsp->QOSCapsStation.qack));
2220 }
2221
2222 if(setupRsp->ExtSuppRates.present)
2223 {
2224 setupPeer->ExtRatesPresent = 1;
2225 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2226 &setupRsp->ExtSuppRates );
2227 }
2228 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302229 if (setupRsp->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002230 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302231 vos_mem_copy(&setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002232 &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2233 }
2234
2235 /* update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302236 if (setupRsp->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002237 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302238 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002239 &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
2240 }
2241
2242 return ;
2243}
2244#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002245
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302246/* This Function is similar to PopulateDot11fHTCaps, except that the HT Capabilities
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002247 * are considered from the AddStaReq rather from the cfg.dat as in PopulateDot11fHTCaps
2248 */
2249static tSirRetStatus limTdlsPopulateDot11fHTCaps(tpAniSirGlobal pMac, tpPESession psessionEntry,
2250 tSirTdlsAddStaReq *pTdlsAddStaReq, tDot11fIEHTCaps *pDot11f)
2251{
2252 tANI_U32 nCfgValue;
2253 tANI_U8 nCfgValue8;
2254 tSirMacHTParametersInfo *pHTParametersInfo;
2255 union {
2256 tANI_U16 nCfgValue16;
2257 tSirMacHTCapabilityInfo htCapInfo;
2258 tSirMacExtendedHTCapabilityInfo extHtCapInfo;
2259 } uHTCapabilityInfo;
2260
2261 tSirMacTxBFCapabilityInfo *pTxBFCapabilityInfo;
2262 tSirMacASCapabilityInfo *pASCapabilityInfo;
2263
2264 nCfgValue = pTdlsAddStaReq->htCap.capInfo;
2265
2266 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2267
2268 pDot11f->advCodingCap = uHTCapabilityInfo.htCapInfo.advCodingCap;
2269 pDot11f->mimoPowerSave = uHTCapabilityInfo.htCapInfo.mimoPowerSave;
2270 pDot11f->greenField = uHTCapabilityInfo.htCapInfo.greenField;
2271 pDot11f->shortGI20MHz = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
2272 pDot11f->shortGI40MHz = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
2273 pDot11f->txSTBC = uHTCapabilityInfo.htCapInfo.txSTBC;
2274 pDot11f->rxSTBC = uHTCapabilityInfo.htCapInfo.rxSTBC;
2275 pDot11f->delayedBA = uHTCapabilityInfo.htCapInfo.delayedBA;
2276 pDot11f->maximalAMSDUsize = uHTCapabilityInfo.htCapInfo.maximalAMSDUsize;
2277 pDot11f->dsssCckMode40MHz = uHTCapabilityInfo.htCapInfo.dsssCckMode40MHz;
2278 pDot11f->psmp = uHTCapabilityInfo.htCapInfo.psmp;
2279 pDot11f->stbcControlFrame = uHTCapabilityInfo.htCapInfo.stbcControlFrame;
2280 pDot11f->lsigTXOPProtection = uHTCapabilityInfo.htCapInfo.lsigTXOPProtection;
2281
2282 // All sessionized entries will need the check below
2283 if (psessionEntry == NULL) // Only in case of NO session
2284 {
2285 pDot11f->supportedChannelWidthSet = uHTCapabilityInfo.htCapInfo.supportedChannelWidthSet;
2286 }
2287 else
2288 {
2289 pDot11f->supportedChannelWidthSet = psessionEntry->htSupportedChannelWidthSet;
2290 }
2291
2292 /* Ensure that shortGI40MHz is Disabled if supportedChannelWidthSet is
2293 eHT_CHANNEL_WIDTH_20MHZ */
2294 if(pDot11f->supportedChannelWidthSet == eHT_CHANNEL_WIDTH_20MHZ)
2295 {
2296 pDot11f->shortGI40MHz = 0;
2297 }
2298
2299 dot11fLog(pMac, LOG2, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, shortGI20:%d, shortGI40: %d, dsssCck: %d"),
2300 pDot11f->supportedChannelWidthSet, pDot11f->mimoPowerSave, pDot11f->greenField,
2301 pDot11f->shortGI20MHz, pDot11f->shortGI40MHz, pDot11f->dsssCckMode40MHz);
2302
2303 nCfgValue = pTdlsAddStaReq->htCap.ampduParamsInfo;
2304
2305 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2306 pHTParametersInfo = ( tSirMacHTParametersInfo* ) &nCfgValue8;
2307
2308 pDot11f->maxRxAMPDUFactor = pHTParametersInfo->maxRxAMPDUFactor;
2309 pDot11f->mpduDensity = pHTParametersInfo->mpduDensity;
2310 pDot11f->reserved1 = pHTParametersInfo->reserved;
2311
2312 dot11fLog( pMac, LOG2, FL( "AMPDU Param: %x" ), nCfgValue);
2313
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302314 vos_mem_copy( pDot11f->supportedMCSSet, pTdlsAddStaReq->htCap.suppMcsSet,
2315 SIZE_OF_SUPPORTED_MCS_SET);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002316
2317 nCfgValue = pTdlsAddStaReq->htCap.extendedHtCapInfo;
2318
2319 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2320
2321 pDot11f->pco = uHTCapabilityInfo.extHtCapInfo.pco;
2322 pDot11f->transitionTime = uHTCapabilityInfo.extHtCapInfo.transitionTime;
2323 pDot11f->mcsFeedback = uHTCapabilityInfo.extHtCapInfo.mcsFeedback;
2324
2325 nCfgValue = pTdlsAddStaReq->htCap.txBFCapInfo;
2326
2327 pTxBFCapabilityInfo = ( tSirMacTxBFCapabilityInfo* ) &nCfgValue;
2328 pDot11f->txBF = pTxBFCapabilityInfo->txBF;
2329 pDot11f->rxStaggeredSounding = pTxBFCapabilityInfo->rxStaggeredSounding;
2330 pDot11f->txStaggeredSounding = pTxBFCapabilityInfo->txStaggeredSounding;
2331 pDot11f->rxZLF = pTxBFCapabilityInfo->rxZLF;
2332 pDot11f->txZLF = pTxBFCapabilityInfo->txZLF;
2333 pDot11f->implicitTxBF = pTxBFCapabilityInfo->implicitTxBF;
2334 pDot11f->calibration = pTxBFCapabilityInfo->calibration;
2335 pDot11f->explicitCSITxBF = pTxBFCapabilityInfo->explicitCSITxBF;
2336 pDot11f->explicitUncompressedSteeringMatrix = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrix;
2337 pDot11f->explicitBFCSIFeedback = pTxBFCapabilityInfo->explicitBFCSIFeedback;
2338 pDot11f->explicitUncompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrixFeedback;
2339 pDot11f->explicitCompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitCompressedSteeringMatrixFeedback;
2340 pDot11f->csiNumBFAntennae = pTxBFCapabilityInfo->csiNumBFAntennae;
2341 pDot11f->uncompressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->uncompressedSteeringMatrixBFAntennae;
2342 pDot11f->compressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->compressedSteeringMatrixBFAntennae;
2343
2344 nCfgValue = pTdlsAddStaReq->htCap.antennaSelectionInfo;
2345
2346 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2347
2348 pASCapabilityInfo = ( tSirMacASCapabilityInfo* ) &nCfgValue8;
2349 pDot11f->antennaSelection = pASCapabilityInfo->antennaSelection;
2350 pDot11f->explicitCSIFeedbackTx = pASCapabilityInfo->explicitCSIFeedbackTx;
2351 pDot11f->antennaIndicesFeedbackTx = pASCapabilityInfo->antennaIndicesFeedbackTx;
2352 pDot11f->explicitCSIFeedback = pASCapabilityInfo->explicitCSIFeedback;
2353 pDot11f->antennaIndicesFeedback = pASCapabilityInfo->antennaIndicesFeedback;
2354 pDot11f->rxAS = pASCapabilityInfo->rxAS;
2355 pDot11f->txSoundingPPDUs = pASCapabilityInfo->txSoundingPPDUs;
2356
Hoonki Lee66b75f32013-04-16 18:30:07 -07002357 pDot11f->present = pTdlsAddStaReq->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002358
2359 return eSIR_SUCCESS;
2360
2361}
2362
2363tSirRetStatus
2364limTdlsPopulateDot11fVHTCaps(tpAniSirGlobal pMac,
2365 tSirTdlsAddStaReq *pTdlsAddStaReq,
2366 tDot11fIEVHTCaps *pDot11f)
2367{
2368 tANI_U32 nCfgValue=0;
2369 union {
2370 tANI_U32 nCfgValue32;
2371 tSirMacVHTCapabilityInfo vhtCapInfo;
2372 } uVHTCapabilityInfo;
2373 union {
2374 tANI_U16 nCfgValue16;
2375 tSirMacVHTTxSupDataRateInfo vhtTxSupDataRateInfo;
2376 tSirMacVHTRxSupDataRateInfo vhtRxsupDataRateInfo;
2377 } uVHTSupDataRateInfo;
2378
Hoonki Lee66b75f32013-04-16 18:30:07 -07002379 pDot11f->present = pTdlsAddStaReq->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002380
2381 nCfgValue = pTdlsAddStaReq->vhtCap.vhtCapInfo;
2382 uVHTCapabilityInfo.nCfgValue32 = nCfgValue;
2383
2384 pDot11f->maxMPDULen = uVHTCapabilityInfo.vhtCapInfo.maxMPDULen;
2385 pDot11f->supportedChannelWidthSet = uVHTCapabilityInfo.vhtCapInfo.supportedChannelWidthSet;
2386 pDot11f->ldpcCodingCap = uVHTCapabilityInfo.vhtCapInfo.ldpcCodingCap;
2387 pDot11f->shortGI80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI80MHz;
2388 pDot11f->shortGI160and80plus80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI160and80plus80MHz;
2389 pDot11f->txSTBC = uVHTCapabilityInfo.vhtCapInfo.txSTBC;
2390 pDot11f->rxSTBC = uVHTCapabilityInfo.vhtCapInfo.rxSTBC;
2391 pDot11f->suBeamFormerCap = uVHTCapabilityInfo.vhtCapInfo.suBeamFormerCap;
2392 pDot11f->suBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.suBeamformeeCap;
2393 pDot11f->csnofBeamformerAntSup = uVHTCapabilityInfo.vhtCapInfo.csnofBeamformerAntSup;
2394 pDot11f->numSoundingDim = uVHTCapabilityInfo.vhtCapInfo.numSoundingDim;
2395 pDot11f->muBeamformerCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformerCap;
2396 pDot11f->muBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformeeCap;
2397 pDot11f->vhtTXOPPS = uVHTCapabilityInfo.vhtCapInfo.vhtTXOPPS;
2398 pDot11f->htcVHTCap = uVHTCapabilityInfo.vhtCapInfo.htcVHTCap;
2399 pDot11f->maxAMPDULenExp = uVHTCapabilityInfo.vhtCapInfo.maxAMPDULenExp;
2400 pDot11f->vhtLinkAdaptCap = uVHTCapabilityInfo.vhtCapInfo.vhtLinkAdaptCap;
2401 pDot11f->rxAntPattern = uVHTCapabilityInfo.vhtCapInfo.rxAntPattern;
2402 pDot11f->txAntPattern = uVHTCapabilityInfo.vhtCapInfo.txAntPattern;
2403 pDot11f->reserved1= uVHTCapabilityInfo.vhtCapInfo.reserved1;
2404
2405 pDot11f->rxMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.rxMcsMap;
2406
2407 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.rxHighest;
2408 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2409 pDot11f->rxHighSupDataRate = uVHTSupDataRateInfo.vhtRxsupDataRateInfo.rxSupDataRate;
2410
2411 pDot11f->txMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.txMcsMap;
2412
2413 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.txHighest;
2414 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2415 pDot11f->txSupDataRate = uVHTSupDataRateInfo.vhtTxSupDataRateInfo.txSupDataRate;
2416
2417 pDot11f->reserved3= uVHTSupDataRateInfo.vhtTxSupDataRateInfo.reserved;
2418
2419 limLogVHTCap(pMac, pDot11f);
2420
2421 return eSIR_SUCCESS;
2422
2423}
2424
2425static tSirRetStatus
2426limTdlsPopulateMatchingRateSet(tpAniSirGlobal pMac,
2427 tpDphHashNode pStaDs,
2428 tANI_U8 *pSupportedRateSet,
2429 tANI_U8 supporteRatesLength,
2430 tANI_U8* pSupportedMCSSet,
2431 tSirMacPropRateSet *pAniLegRateSet,
2432 tpPESession psessionEntry,
2433 tDot11fIEVHTCaps *pVHTCaps)
2434
2435{
2436 tSirMacRateSet tempRateSet;
2437 tANI_U32 i,j,val,min,isArate;
2438 tSirMacRateSet tempRateSet2;
2439 tANI_U32 phyMode;
2440 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2441 isArate=0;
Leela Venkata Kiran Kumar Reddy Chiralac7a12152014-02-03 11:20:14 -08002442 tempRateSet2.numRates = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002443
2444 // limGetPhyMode(pMac, &phyMode);
2445 limGetPhyMode(pMac, &phyMode, NULL);
2446
2447 // get own rate set
2448 val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2449 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302450 (tANI_U8 *) &tempRateSet.rate,
2451 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002452 {
2453 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002454 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07002455 val = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002456 }
2457 tempRateSet.numRates = val;
2458
2459 if (phyMode == WNI_CFG_PHY_MODE_11G)
2460 {
2461
2462 // get own extended rate set
2463 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2464 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302465 (tANI_U8 *) &tempRateSet2.rate,
2466 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002467 tempRateSet2.numRates = val;
2468 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002469
2470 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2471 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002472 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002473 goto error;
2474 }
2475
2476 /**
2477 * Handling of the rate set IEs is the following:
2478 * - keep only rates that we support and that the station supports
2479 * - sort and the rates into the pSta->rate array
2480 */
2481
2482 // Copy all rates in tempRateSet, there are 12 rates max
2483 for (i = 0; i < tempRateSet2.numRates; i++)
2484 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
2485
2486 tempRateSet.numRates += tempRateSet2.numRates;
2487
2488 /**
2489 * Sort rates in tempRateSet (they are likely to be already sorted)
2490 * put the result in tempRateSet2
2491 */
2492 tempRateSet2.numRates = 0;
2493
2494 for (i = 0;i < tempRateSet.numRates; i++)
2495 {
2496 min = 0;
2497 val = 0xff;
2498
2499 for(j = 0;j < tempRateSet.numRates; j++)
2500 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2501 {
2502 val = tempRateSet.rate[j] & 0x7f;
2503 min = j;
2504 }
2505
2506 tempRateSet2.rate[tempRateSet2.numRates++] = tempRateSet.rate[min];
2507 tempRateSet.rate[min] = 0xff;
2508 }
2509
2510 /**
2511 * Copy received rates in tempRateSet, the parser has ensured
2512 * unicity of the rates so there cannot be more than 12 . Need to Check this
2513 * TODO Sunil.
2514 */
2515 for (i = 0; i < supporteRatesLength; i++)
2516 {
2517 tempRateSet.rate[i] = pSupportedRateSet[i];
2518 }
2519
2520 tempRateSet.numRates = supporteRatesLength;
2521
2522 {
2523 tpSirSupportedRates rates = &pStaDs->supportedRates;
2524 tANI_U8 aRateIndex = 0;
2525 tANI_U8 bRateIndex = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302526 vos_mem_set( (tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002527
2528 for (i = 0;i < tempRateSet2.numRates; i++)
2529 {
2530 for (j = 0;j < tempRateSet.numRates; j++)
2531 {
2532 if ((tempRateSet2.rate[i] & 0x7F) ==
2533 (tempRateSet.rate[j] & 0x7F))
2534 {
2535#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2536 if ((bRateIndex > HAL_NUM_11B_RATES) || (aRateIndex > HAL_NUM_11A_RATES))
2537 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002538 limLog(pMac, LOGE, FL("Invalid number of rates (11b->%d, 11a->%d)"),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002539 bRateIndex, aRateIndex);
2540 return eSIR_FAILURE;
2541 }
2542#endif
2543 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2544 {
2545 isArate=1;
2546 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
2547 }
2548 else
2549 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2550 break;
2551 }
2552 }
2553 }
2554 }
2555
2556
2557 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
2558#ifdef FEATURE_WLAN_TDLS
2559 if (pStaDs->mlmStaContext.htCapability)
2560#else
2561 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2562 (pStaDs->mlmStaContext.htCapability))
2563#endif
2564 {
2565 val = SIZE_OF_SUPPORTED_MCS_SET;
2566 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2567 mcsSet,
2568 &val) != eSIR_SUCCESS)
2569 {
2570 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002571 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002572 goto error;
2573 }
2574
2575 for (i=0; i<val; i++)
2576 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2577
2578 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH :"));)
2579 for (i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2580 {
2581 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2582 }
2583 }
2584
2585#ifdef WLAN_FEATURE_11AC
2586 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2587#endif
2588 /**
2589 * Set the erpEnabled bit iff the phy is in G mode and at least
2590 * one A rate is supported
2591 */
2592 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2593 pStaDs->erpEnabled = eHAL_SET;
2594
2595
2596
2597 return eSIR_SUCCESS;
2598
2599 error:
2600
2601 return eSIR_FAILURE;
2602}
2603
2604static int limTdlsSelectCBMode(tDphHashNode *pStaDs, tpPESession psessionEntry)
2605{
2606 tANI_U8 channel = psessionEntry->currentOperChannel;
2607
2608 if ( pStaDs->mlmStaContext.vhtCapability )
2609 {
2610 if ( channel== 36 || channel == 52 || channel == 100 ||
2611 channel == 116 || channel == 149 )
2612 {
2613 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
2614 }
2615 else if ( channel == 40 || channel == 56 || channel == 104 ||
2616 channel == 120 || channel == 153 )
2617 {
2618 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
2619 }
2620 else if ( channel == 44 || channel == 60 || channel == 108 ||
2621 channel == 124 || channel == 157 )
2622 {
2623 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
2624 }
2625 else if ( channel == 48 || channel == 64 || channel == 112 ||
2626 channel == 128 || channel == 161 )
2627 {
2628 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
2629 }
2630 else if ( channel == 165 )
2631 {
2632 return 0;
2633 }
2634 }
2635 else if ( pStaDs->mlmStaContext.htCapability )
2636 {
2637 if ( channel== 40 || channel == 48 || channel == 56 ||
2638 channel == 64 || channel == 104 || channel == 112 ||
2639 channel == 120 || channel == 128 || channel == 136 ||
2640 channel == 144 || channel == 153 || channel == 161 )
2641 {
2642 return 1;
2643 }
2644 else if ( channel== 36 || channel == 44 || channel == 52 ||
2645 channel == 60 || channel == 100 || channel == 108 ||
2646 channel == 116 || channel == 124 || channel == 132 ||
2647 channel == 140 || channel == 149 || channel == 157 )
2648 {
2649 return 2;
2650 }
2651 else if ( channel == 165 )
2652 {
2653 return 0;
2654 }
2655 }
2656 return 0;
2657}
2658
Kiran V1ccee932012-12-12 14:49:46 -08002659/*
2660 * update HASH node entry info
2661 */
2662static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002663 tSirTdlsAddStaReq *pTdlsAddStaReq, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002664{
2665 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
2666 tDot11fIEHTCaps htCap, *htCaps;
Kiet Lam770920c2013-10-21 12:49:30 +05302667 tDot11fIEVHTCaps *pVhtCaps = NULL;
Hoonki Lee99e53782013-02-12 18:07:03 -08002668#ifdef WLAN_FEATURE_11AC
Kiet Lam770920c2013-10-21 12:49:30 +05302669 tDot11fIEVHTCaps vhtCap;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002670 tANI_U8 cbMode;
Hoonki Lee99e53782013-02-12 18:07:03 -08002671#endif
Kiran V1ccee932012-12-12 14:49:46 -08002672 tpDphHashNode pSessStaDs = NULL;
2673 tANI_U16 aid;
2674
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002675 if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_ADD)
2676 {
2677 PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
2678 }
2679 else if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE)
2680 {
2681 limTdlsPopulateDot11fHTCaps(pMac, NULL, pTdlsAddStaReq, &htCap);
2682 }
Kiran V1ccee932012-12-12 14:49:46 -08002683 htCaps = &htCap;
Hoonki Lee99e53782013-02-12 18:07:03 -08002684 if (htCaps->present)
Kiran V1ccee932012-12-12 14:49:46 -08002685 {
2686 pStaDs->mlmStaContext.htCapability = 1 ;
2687 pStaDs->htGreenfield = htCaps->greenField ;
2688 pStaDs->htSupportedChannelWidthSet = htCaps->supportedChannelWidthSet ;
2689 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
2690 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
2691 pStaDs->htAMpduDensity = htCaps->mpduDensity;
2692 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
2693 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
2694 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
2695 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
2696 limFillRxHighestSupportedRate(pMac,
2697 &pStaDs->supportedRates.rxHighestDataRate,
2698 htCaps->supportedMCSSet);
2699 pStaDs->baPolicyFlag = 0xFF;
Kiran V1ccee932012-12-12 14:49:46 -08002700 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
2701 }
2702 else
2703 {
2704 pStaDs->mlmStaContext.htCapability = 0 ;
2705 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
2706 }
Hoonki Lee99e53782013-02-12 18:07:03 -08002707#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002708 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002709 pVhtCaps = &vhtCap;
2710 if (pVhtCaps->present)
2711 {
2712 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302713
2714 if ((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
2715 pMac->roam.configParam.enableVhtFor24GHz)
2716 {
2717 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
2718 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
2719 }
2720 else
2721 {
2722 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
2723 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_40MHZ ;
2724 }
2725
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002726 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2727 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2728 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002729 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2730 }
2731 else
2732 {
2733 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002734 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002735 }
2736#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002737 /*Calculate the Secondary Coannel Offset */
2738 cbMode = limTdlsSelectCBMode(pStaDs, psessionEntry);
2739
2740 pStaDs->htSecondaryChannelOffset = cbMode;
2741
2742#ifdef WLAN_FEATURE_11AC
2743 if ( pStaDs->mlmStaContext.vhtCapability )
2744 {
2745 pStaDs->htSecondaryChannelOffset = limGetHTCBState(cbMode);
2746 }
2747#endif
Kiran V1ccee932012-12-12 14:49:46 -08002748
2749 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
2750 &psessionEntry->dph.dphHashTable) ;
2751
2752 /* Lets enable QOS parameter */
2753 pStaDs->qosMode = 1;
2754 pStaDs->wmeEnabled = 1;
2755 pStaDs->lleEnabled = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002756 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2757 */
2758 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002759
2760 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002761
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002762 /* TDLS Dummy AddSTA does not have HTCap,VHTCap,Rates info , is it OK ??
2763 */
2764 limTdlsPopulateMatchingRateSet(pMac, pStaDs, pTdlsAddStaReq->supported_rates,
2765 pTdlsAddStaReq->supported_rates_length,
2766 (tANI_U8 *)pTdlsAddStaReq->htCap.suppMcsSet,
2767 &pStaDs->mlmStaContext.propRateSet,
Kiet Lam770920c2013-10-21 12:49:30 +05302768 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002769
2770 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2771 */
2772 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002773
2774 return ;
2775}
2776
2777#ifdef FEATURE_WLAN_TDLS_INTERNAL
2778/*
2779 * find Peer in setup link list.
2780 */
2781
2782tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2783 tLimTdlsLinkSetupPeer **setupPeer)
2784{
2785 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2786 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2787 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2788
2789 while (linkSetupList != NULL)
2790 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302791 if (vos_mem_compare((tANI_U8 *) peerMac,
2792 (tANI_U8 *) linkSetupList->peerMac,
2793 sizeof(tSirMacAddr)) )
Kiran V1ccee932012-12-12 14:49:46 -08002794 {
2795 checkNode = TDLS_NODE_FOUND ;
2796 *setupPeer = linkSetupList ;
2797 break ;
2798 }
2799 linkSetupList = linkSetupList->next;
2800 }
2801
2802 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ;
2803}
2804
2805/*
2806 * find peer in Discovery list.
2807 * Dicovery list get populated in two instances, a) Recieved responses in reply
2808 * to discovery request b) If discover request is received from TDLS peer STA
2809 */
2810tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2811{
2812 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2813 tSirTdlsPeerInfo *peerInfo = NULL ;
2814
2815 while (discoveryList != NULL)
2816 {
2817 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2818 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002819 ("Peer in discovery list = " MAC_ADDRESS_STR),
2820 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002821
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302822 if (vos_mem_compare((tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002823 (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) )
2824 {
2825 break ;
2826 }
2827 discoveryList = discoveryList->next;
2828 }
2829
2830 return peerInfo ;
2831}
2832
2833/*
2834 * find peer in Discovery list by looking into peer state.
2835 * Dicovery list get populated in two instances, a) Recieved responses in reply
2836 * to discovery request b) If discover request is received from TDLS peer STA
2837 */
2838static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
2839 tANI_U8 state)
2840{
2841 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2842 tSirTdlsPeerInfo *peerInfo = NULL ;
2843
2844 while (discoveryList != NULL)
2845 {
2846 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2847 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002848 ("peerInfo Mac = " MAC_ADDRESS_STR),
2849 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002850
2851 if (peerInfo->tdlsPeerState == state)
2852 {
2853 break ;
2854 }
2855 discoveryList = discoveryList->next;
2856 }
2857
2858 return peerInfo ;
2859}
2860
2861/*
2862 * find peer in Setup list by looking into peer state.
2863 * setup list get populated in two instances, a) Recieved responses in reply
2864 * to setup request b) If discover request is received from TDLS peer STA
2865 */
2866static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
2867 tLimTdlsLinkSetupPeer **setupPeer)
2868{
2869
2870 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2871 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2872 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2873
2874 while (linkSetupList != NULL)
2875 {
2876 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002877 ("peer state = %02x"), (linkSetupList)->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08002878 if((linkSetupList)->tdls_link_state == state)
2879 {
2880 checkNode = TDLS_NODE_FOUND ;
2881 *setupPeer = linkSetupList ;
2882 break ;
2883 }
2884 linkSetupList = (linkSetupList)->next;
2885 }
2886
2887 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ;
2888}
2889
2890
2891/*
2892 * delete Peer from Setup Link
2893 */
2894void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2895{
2896 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2897 tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ;
2898 tLimTdlsLinkSetupPeer *currentNode = NULL ;
2899 tLimTdlsLinkSetupPeer *prevNode = NULL ;
2900
2901 for(currentNode = *linkSetupList ; currentNode != NULL ;
2902 prevNode = currentNode, currentNode = currentNode->next)
2903 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302904 if (vos_mem_compare( (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002905 (tANI_U8 *) currentNode->peerMac,
2906 sizeof(tSirMacAddr)) )
2907 {
2908 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002909 ("Del Node for Peer = " MAC_ADDRESS_STR),
2910 MAC_ADDR_ARRAY(currentNode->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002911 /* if it's first Node */
2912 if(NULL == prevNode)
2913 {
2914 *linkSetupList = currentNode->next ;
2915 }
2916 else
2917 {
2918 prevNode->next = currentNode->next ;
2919 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302920 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08002921 return ;
2922 }
2923 }
2924
2925 return ;
2926}
2927
2928
2929
2930/*
2931 * TDLS discovery request frame received from TDLS peer STA..
2932 */
2933static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac,
2934 tANI_U8 *pBody, tANI_U32 frmLen )
2935{
2936 tDot11fTDLSDisReq tdlsDisReq = {{0}} ;
2937 tANI_U32 status = 0 ;
2938 tLimDisResultList *tdlsDisResult = NULL ;
2939 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
2940 tSirMacAddr peerMac = {0} ;
2941 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2942 tSirTdlsPeerInfo *peerInfo = NULL ;
2943 tpPESession psessionEntry = NULL ;
2944 tANI_U8 sessionId = 0 ;
2945
2946 status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ;
2947
2948 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002949 ("TDLS dis request dialog = %d"), tdlsDisReq.DialogToken.token);
Kiran V1ccee932012-12-12 14:49:46 -08002950
2951 if ( DOT11F_FAILED( status ) )
2952 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002953 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
2954 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08002955 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2956 return eSIR_FAILURE;
2957 }
2958 else if ( DOT11F_WARNED( status ) )
2959 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002960 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
2961 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08002962 status, frmLen );
2963 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2964 }
2965
2966 /*
2967 * find session entry using BSSID in link identifier, not using MAC
2968 * header beacuse, there is cases in TDLS, there may be BSSID will not
2969 * be present in header
2970 */
2971 psessionEntry = peFindSessionByBssid(pMac,
2972 &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ;
2973 if(NULL == psessionEntry)
2974 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002975 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08002976 ("no Session entry for TDLS session (bssid "MAC_ADDR_ARRAY")"),
2977 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08002978
2979 //VOS_ASSERT(0) ;
2980 return eSIR_FAILURE;
2981 }
2982
2983 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302984 status = vos_mem_compare( &psessionEntry->bssId[0],
Kiran V1ccee932012-12-12 14:49:46 -08002985 &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
2986 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002987 ("lim BSSID "MAC_ADDRESS_STR),
2988 MAC_ADDR_ARRAY( psessionEntry->bssId));
Kiran V1ccee932012-12-12 14:49:46 -08002989
2990 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002991 ("Dis req from BSSID "MAC_ADDRESS_STR),
2992 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08002993 if(!status)
2994 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002995 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08002996
2997 return eSIR_FAILURE ;
2998 }
2999
3000 /*
3001 * check if this is echo of our transmitted discovery request
3002 * drop it here, TODO: better to drop this in TL.
3003 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303004 status = vos_mem_compare( psessionEntry->selfMacAddr,
Kiran V1ccee932012-12-12 14:49:46 -08003005 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3006 sizeof(tSirMacAddr)) ;
3007 if(status)
3008 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003009 limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003010 return eSIR_FAILURE ;
3011 }
3012
3013 /*
3014 * while processing Discovery request from Peer,
3015 * STA_MAC--> MAC of TDLS discovery initiator
3016 * STA_PEER_MAC--> MAC of TDLS discovery responder.
3017 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303018 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003019 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3020 sizeof(tSirMacAddr)) ;
3021 /* TODO, do more validation */
3022
3023 /* see if discovery is already in progress */
3024 peerInfo = limTdlsFindDisPeer(pMac, peerMac) ;
3025
3026 if(NULL == peerInfo)
3027 {
3028 /*
3029 * we are allocating peer info for individual peers found in TDLS
3030 * discovery, we need to keep adding TDLS peers till we have timed
3031 * out. We are freeing this memory at the time we are sending this
3032 * collected peer info to SME.
3033 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303034 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3035 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003036 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003037 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery "
3038 "reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003039 return eSIR_FAILURE ;
3040 }
3041
3042
3043 peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3044 peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ;
3045 peerInfo->dialog = tdlsDisReq.DialogToken.token ;
3046
3047 peerInfo->sessionId = psessionEntry->peSessionId;
3048
3049 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303050 vos_mem_copy( peerInfo->peerMac, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08003051
3052 /*
3053 * Now, as per D13, there will not be any Supp rates, ext Supp rates
3054 * info in Discovery request frames, so we are populating this info
3055 * locally to pass it to ADD STA.
3056 */
3057 do
3058 {
3059 tDot11fIESuppRates suppRates = {0} ;
3060 tDot11fIEExtSuppRates extSuppRates = {0} ;
3061 tANI_U16 caps = 0 ;
3062 tDot11fFfCapabilities capsInfo = {0} ;
3063 tDot11fIEHTCaps HTCaps = {0} ;
3064 /* populate supported rate IE */
3065 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3066 &suppRates, psessionEntry );
3067 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3068 &suppRates);
3069 /* Populate extended supported rates */
3070 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3071 &extSuppRates, psessionEntry );
3072
3073 peerInfo->ExtRatesPresent = 1;
3074 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3075 &extSuppRates);
3076
3077 if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
3078 {
3079 /*
3080 * Could not get Capabilities value
3081 * from CFG. Log error.
3082 */
3083 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003084 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08003085 }
3086 swapBitField16(caps, ( tANI_U16* )&capsInfo );
3087 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303088 tdlsUpdateCapInfo(&peerInfo->capabilityInfo, &capsInfo) ;
Kiran V1ccee932012-12-12 14:49:46 -08003089
3090 PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps );
3091 limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ;
3092
3093 } while (0) ;
3094
3095 /* now add this new found discovery node into tdls discovery list */
3096 tdlsDisResult->next = *disResultList ;
3097 *disResultList = tdlsDisResult ;
3098 pMac->lim.gLimTdlsDisStaCount++ ;
3099
3100 /* See if for this peer already entry in setup Link */
3101 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3102
3103 /*
3104 * if there is no entry for this peer in setup list, we need to
3105 * do add sta for this peer to transmit discovery rsp.
3106 */
3107 if(NULL == setupPeer)
3108 {
3109 /* To start with, send add STA request to HAL */
3110 pMac->lim.gLimAddStaTdls = true ;
3111 peerInfo->delStaNeeded = true ;
3112
3113 if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac,
3114 peerInfo, psessionEntry))
3115 {
3116 VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003117 limLog(pMac, LOGE, "Add STA for dis response is failed ") ;
Kiran V1ccee932012-12-12 14:49:46 -08003118 return eSIR_FAILURE ;
3119 }
3120 } /* use setup link sta ID for discovery rsp */
3121 else
3122 {
3123 peerInfo->delStaNeeded = false ;
3124 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
3125 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
3126 }
3127
3128 }
3129 else
3130 {
3131 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003132 ("discovery procedure in progress for this peer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003133 }
3134
3135 return eSIR_SUCCESS ;
3136}
3137
3138/* Process TDLS setup Request Frame */
3139
3140static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac,
3141 tANI_U8 *pBody, tANI_U32 frmLen)
3142{
3143
3144 tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ;
3145 tANI_U32 status = 0 ;
3146 tpPESession psessionEntry = NULL ;
3147 tANI_U8 sessionId = 0 ;
3148 tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ;
3149 tANI_U8 previousState = TDLS_LINK_IDLE_STATE ;
3150 /* create node for Link setup */
3151 tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
3152 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3153 tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ;
3154
3155 status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ;
3156
3157 if ( DOT11F_FAILED( status ) )
3158 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003159 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3160 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003161 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3162 return eSIR_FAILURE;
3163 }
3164 else if ( DOT11F_WARNED( status ) )
3165 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003166 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3167 "setup Request frame (0x%08x, %d bytes):"),
3168 status, frmLen );
Kiran V1ccee932012-12-12 14:49:46 -08003169 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3170 }
3171 /*
3172 * find session entry using BSSID in link identifier, not using MAC
3173 * header beacuse, there is cases in TDLS, there may be BSSID will not
3174 * be present in header
3175 */
3176 psessionEntry = peFindSessionByBssid(pMac,
3177 &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ;
3178 if(NULL == psessionEntry)
3179 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003180 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003181 ("no Session entry for TDLS session (bssid "
3182 MAC_ADDRESS_STR")"),
3183 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003184
3185 //VOS_ASSERT(0) ;
3186 return eSIR_FAILURE ;
3187 }
3188 /* TODO: we don;t need this check now, varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303189 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003190 &tdlsSetupReq.LinkIdentifier.bssid[0],
3191 sizeof(tSirMacAddr)) ;
3192
3193 if(!status)
3194 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003195 limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003196
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303197 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
3198 tdlsSetupReq.DialogToken.token, psessionEntry,
3199 TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003200 return eSIR_FAILURE ;
3201 }
3202
3203#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3204 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ)
3205 {
3206 /* simply ignore this setup request packet */
3207 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003208 ("TDLS negative running: ignore TDLS Setup Req packet"));
Kiran V1ccee932012-12-12 14:49:46 -08003209 return eSIR_SUCCESS ;
3210 }
3211 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3212 {
3213 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003214 ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req"));
Kiran V1ccee932012-12-12 14:49:46 -08003215 /* format TDLS discovery request frame and transmit it */
3216 limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry,
3217 NULL, 0) ;
3218 }
3219#endif
3220 /* TODO, do more validation */
3221
3222 if(!limTdlsFindLinkPeer(pMac,
3223 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3224 &tmpSetupPeer))
3225 {
3226 tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3227
3228 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003229 ("Link is already setup with this peer" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003230 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003231 ("state = %d"), tmpSetupPeer->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08003232 //return eSIR_FAILURE ;
3233
3234 if(tmpSetupPeer == NULL)
3235 {
3236 VOS_ASSERT(0) ;
3237 return eSIR_FAILURE ;
3238
3239 }
3240 switch(tmpSetupPeer->tdls_link_state)
3241 {
3242
3243 case TDLS_LINK_SETUP_START_STATE:
3244 {
3245 v_SINT_t macCompare = 0 ;
3246 macCompare= vos_mem_compare2(tmpSetupPeer->peerMac,
3247 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
3248 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003249 ("MAC comparison Rslt = %d"), macCompare ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003250 if(0 > macCompare)
3251 {
3252 /*
3253 * Delete our Setup Request/Peer info and honour Peer
3254 * Setup Request, go ahead and respond for this
3255 */
3256 /* Deactivate the timer */
3257 tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ;
3258#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3259 if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3260 != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3261#endif
3262 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE,
3263 tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP);
3264
3265 limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ;
3266 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3267 }
3268 else if(0 < macCompare)
3269 {
3270 /*
3271 * Go ahead with current setup as peer is going to
3272 * respond for setup request
3273 */
3274 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3275 }
3276 else
3277 {
3278 /* same MAC, not possible */
3279 VOS_ASSERT(0) ;
3280 }
3281
3282 break ;
3283 }
3284#if 1
3285 case TDLS_LINK_SETUP_DONE_STATE:
3286 {
3287 tpDphHashNode pStaDs = NULL ;
3288
3289 previousState = TDLS_LINK_SETUP_WAIT_STATE ;
3290 currentState = TDLS_LINK_TEARDOWN_START_STATE ;
3291 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3292 ("link Setup Done state " )) ;
3293 tmpSetupPeer->tdls_prev_link_state = previousState ;
3294 tmpSetupPeer->tdls_link_state = currentState ;
3295 setupPeer = tmpSetupPeer ;
3296#if 0
3297 /* Send Teardown to this Peer and Initiate new TDLS Setup */
3298 limSendTdlsTeardownFrame(pMac,
3299 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3300 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ;
3301#else
3302
3303 /* tdls_hklee: send message to HAL before it is deleted, cause */
3304 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3305
3306 /* send del STA to remove context for this TDLS STA */
3307 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3308
3309 /* now send indication to SME-->HDD->TL to remove STA from TL */
3310
3311 if(pStaDs)
3312 {
3313 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3314 pStaDs, eSIR_SUCCESS) ;
3315
3316 /* send Teardown Ind to SME */
3317 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3318 eWNI_SME_TDLS_TEARDOWN_IND) ;
3319 /* remove node from setup list */
3320 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3321 }
3322#endif
3323 //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE;
3324 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3325 break ;
3326
3327 }
3328 default:
3329 {
3330 VOS_ASSERT(0) ;
3331 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003332 ("link Setup is Recieved in unknown state" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003333 break ;
3334 }
3335#endif
3336 }
3337 if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE)
3338 return eSIR_FAILURE ;
3339 }
3340
3341 if(currentState != TDLS_LINK_TEARDOWN_START_STATE)
3342 {
3343 /*
3344 * Now we are sure to send discovery response frame to TDLS discovery
3345 * initiator, we don't care, if this request is unicast ro broadcast,
3346 * we simply, send discovery response frame on direct link.
3347 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303348 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
3349 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08003350 {
3351 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003352 ( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08003353 return eSIR_MEM_ALLOC_FAILED;
3354 }
3355
3356 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3357 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3358 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3359 setupPeer->tdls_prev_link_state = previousState ;
3360 setupPeer->tdls_link_state = currentState ;
3361 /* TDLS_sessionize: remember sessionId for future */
3362 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3363 setupPeer->tdls_bIsResponder = 0;
3364
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303365 vos_mem_copy(setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003366 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3367 sizeof(tSirMacAddr)) ;
3368
3369 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003370 ("Setup REQ MAC = " MAC_ADDRESS_STR),
3371 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003372
3373 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3374 pMac->lim.gLimAddStaTdls = true ;
3375
3376 /* To start with, send add STA request to HAL */
3377 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac,
3378 setupPeer, psessionEntry))
3379 {
3380 VOS_ASSERT(0) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303381 vos_mem_free((void **) &setupPeer) ;
Kiran V1ccee932012-12-12 14:49:46 -08003382 return eSIR_FAILURE ;
3383 }
3384
3385 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303386 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003387 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3388
3389 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3390 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3391 (tANI_U32)setupPeer->peerMac,
3392 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3393 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3394
3395 /* update setup peer list */
3396 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
3397 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
3398 }
3399 else
3400 {
3401 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3402 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3403 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3404 setupPeer->tdls_prev_link_state = previousState ;
3405 setupPeer->tdls_link_state = currentState ;
3406 /* TDLS_sessionize: remember sessionId for future */
3407 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3408 setupPeer->tdls_bIsResponder = 0;
3409
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303410 vos_mem_copy( setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003411 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3412 sizeof(tSirMacAddr)) ;
3413
3414 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003415 ("Setup REQ MAC = "MAC_ADDRESS_STR),
3416 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003417
3418 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3419 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303420 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003421 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3422
3423 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3424 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3425 (tANI_U32)setupPeer->peerMac,
3426 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3427 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3428 }
3429
3430
3431 return eSIR_SUCCESS ;
3432
3433}
3434
3435/*
3436 * TDLS discovery request frame received from TDLS peer STA..
3437 */
3438static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac,
3439 tANI_U8 *pBody, tANI_U32 frmLen )
3440{
3441 tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ;
3442 tANI_U32 status = 0 ;
3443 tSirMacAddr peerMac = {0} ;
3444 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3445 tpPESession psessionEntry = NULL ;
3446 tANI_U8 sessionId = 0 ;
3447
3448 status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ;
3449
3450 if ( DOT11F_FAILED( status ) )
3451 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003452 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3453 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003454 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3455 return eSIR_FAILURE;
3456 }
3457 else if ( DOT11F_WARNED( status ) )
3458 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003459 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3460 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003461 status, frmLen );
3462 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3463 }
3464
3465 /*
3466 * find session entry using BSSID in link identifier, not using MAC
3467 * header beacuse, there is cases in TDLS, there may be BSSID will not
3468 * be present in header
3469 */
3470 psessionEntry = peFindSessionByBssid(pMac,
3471 &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ;
3472 if(NULL == psessionEntry)
3473 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003474 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003475 ("no Session entry for TDLS session (bssid "
3476 MAC_ADDRESS_STR")"),
3477 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003478
3479 //VOS_ASSERT(0) ;
3480 return eSIR_FAILURE;
3481 }
3482
3483 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303484 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003485 &tdlsSetupRsp.LinkIdentifier.bssid[0],
3486 sizeof(tSirMacAddr)) ;
3487
3488 if(!status)
3489 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003490 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003491
3492 VOS_ASSERT(0) ;
3493 return eSIR_FAILURE ;
3494 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303495 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003496 &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0],
3497 sizeof(tSirMacAddr)) ;
3498
3499 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003500 ("TDLS setup RSP peer = "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003501 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3502
3503 if(NULL == setupPeer)
3504 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003505 limLog( pMac, LOGE, FL("unknown setup Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003506 return eSIR_FAILURE ;
3507 }
3508
3509 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003510 ("deactivating Setup RSP timer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003511
3512 /* Deactivate the timer */
3513 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ;
3514
3515 /*
3516 * TDLS Setup RSP is recieved with Failure, Delete this STA entry
3517 * don't respond with TDLS CNF frame.
3518 */
3519 if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status)
3520 {
3521 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3522 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003523 ("setup RSP with Failure Code")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003524 return eSIR_FAILURE ;
3525 }
3526
3527 /* update Link Info */
3528 limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ;
3529
3530 /* TODO, do more validation */
3531
3532
3533 /*
3534 * Now we are sure to send link setup CNF frame to TDLS link setup
3535 * reponded, now we will create dph hash entry and send add STA to HAL
3536 */
3537
3538 pMac->lim.gLimAddStaTdls = true ;
3539 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac,
3540 setupPeer, psessionEntry))
3541 {
3542 /* through error */
3543 VOS_ASSERT(0) ;
3544 return eSIR_FAILURE ;
3545 }
3546 /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */
3547
3548
3549 /* send TDLS confim frame to TDLS Peer STA */
3550 limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, psessionEntry, NULL, 0) ;
3551
3552 /*
3553 * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and
3554 * wait for Setup CNF transmission on air, once we receive tx complete
3555 * message, we will change the peer state and send message to SME
3556 * callback..
3557 */
3558 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3559 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ;
3560
3561 return eSIR_SUCCESS ;
3562}
3563/*
3564 * TDLS setup CNF frame processing ..
3565 */
3566
3567static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac,
3568 tANI_U8 *pBody, tANI_U32 frmLen)
3569{
3570 tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ;
3571 tANI_U32 status = 0 ;
3572 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3573 tpPESession psessionEntry = NULL ;
3574 tANI_U8 sessionId = 0 ;
3575
3576 status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ;
3577
3578 if ( DOT11F_FAILED( status ) )
3579 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003580 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3581 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003582 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3583 return eSIR_FAILURE;
3584 }
3585 else if ( DOT11F_WARNED( status ) )
3586 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003587 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3588 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003589 status, frmLen );
3590 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3591 }
3592 /*
3593 * find session entry using BSSID in link identifier, not using MAC
3594 * header beacuse, there is cases in TDLS, there may be BSSID will not
3595 * be present in header
3596 */
3597 psessionEntry = peFindSessionByBssid(pMac,
3598 &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ;
3599 if(NULL == psessionEntry)
3600 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003601 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003602 ("no Session entry for TDLS session (bssid "
3603 MAC_ADDRESS_STR")"),
3604 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003605
3606 //VOS_ASSERT(0) ;
3607 return eSIR_FAILURE;
3608 }
3609
3610 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303611 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003612 &tdlsSetupCnf.LinkIdentifier.bssid[0],
3613 sizeof(tSirMacAddr)) ;
3614
3615 if(!status)
3616 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003617 limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003618
3619 VOS_ASSERT(0) ;
3620 return eSIR_FAILURE ;
3621 }
3622 /* TODO, do more validation */
3623 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003624 ("setup Cnf peer MAc = "MAC_ADDRESS_STR),
3625 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.InitStaAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003626
3627 limTdlsFindLinkPeer(pMac,
3628 &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
3629 &setupPeer) ;
3630
3631 if(NULL == setupPeer)
3632 {
3633 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003634 (" unknown setup CNF frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003635 VOS_ASSERT(0) ;
3636 return eSIR_FAILURE ;
3637 }
3638 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003639 ("setup CNF peer MAC = "MAC_ADDRESS_STR),
3640 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003641 /*T match dialog token, before proceeding further */
3642 if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token)
3643 {
3644 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003645 ("setup CNF frame not matching with setup RSP")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003646 VOS_ASSERT(0) ;
3647 return eSIR_FAILURE ;
3648 }
3649
3650 /*
3651 * Now we are sure that, this set CNF is for us, now stop
3652 * the running timer..
3653 */
3654 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ;
3655
3656 /* change TDLS peer State */
3657 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3658 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
3659
3660 /* send indication to SME that, new link is setup */
3661 limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ;
3662
3663 /* tdls_hklee: prepare PTI template and send it to HAL */
3664 limTdlsLinkEstablish(pMac, (setupPeer)->peerMac);
3665
3666 return eSIR_SUCCESS ;
3667
3668}
3669
3670/*
3671 * TDLS discovery response frame processing ..
3672 */
3673
3674static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac,
3675 tANI_U8 *pBody, tANI_U32 frmLen,
3676 tANI_S8 rssi, tpPESession psessionEntry)
3677{
3678 tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ;
3679 tANI_U32 status = 0 ;
3680 tLimDisResultList *tdlsDisResult = NULL ;
3681 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
3682 tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ;
3683
3684 status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ;
3685
3686 if ( DOT11F_FAILED( status ) )
3687 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003688 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3689 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003690 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3691 return eSIR_FAILURE;
3692 }
3693 else if ( DOT11F_WARNED( status ) )
3694 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003695 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3696 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003697 status, frmLen );
3698 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);)
3699 }
3700 /*TODO: match dialog token, before proceeding further */
3701
3702 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303703 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003704 &tdlsDisRsp.LinkIdentifier.bssid[0],
3705 sizeof(tSirMacAddr)) ;
3706
3707 if(!status)
3708 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003709 limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003710 return eSIR_FAILURE ;
3711 }
3712 /* TODO, do more validation */
3713
3714 if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
3715 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003716 limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003717 return eSIR_FAILURE ;
3718 }
3719
3720 pMac->lim.gLimTdlsDisStaCount++ ;
3721
3722 /*
3723 * we are allocating peer info for individual peers found in TDLS
3724 * discovery, we need to keep adding TDLS peers till we have timed
3725 * out. We are freeing this memory at the time we are sending this
3726 * collected peer info to SME.
3727 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303728 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3729 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003730 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003731 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003732 return eSIR_FAILURE ;
3733 }
3734
3735 do
3736 {
3737 tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3738
3739 /* Populate peer info of tdls discovery result */
3740 peerInfo->sessionId = psessionEntry->peSessionId;
3741 /*
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303742 * When we receive DIS RSP from peer MAC,
Kiran V1ccee932012-12-12 14:49:46 -08003743 * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
3744 * will carry our MAC.
3745 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303746 vos_mem_copy( peerInfo->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003747 &tdlsDisRsp.LinkIdentifier.RespStaAddr[0],
3748 sizeof(tSirMacAddr)) ;
3749
3750 /* update RSSI for this TDLS peer STA */
3751 peerInfo->tdlsPeerRssi = rssi ;
3752
3753 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303754 tdlsUpdateCapInfo(&peerInfo->capabilityInfo,
Kiran V1ccee932012-12-12 14:49:46 -08003755 &tdlsDisRsp.Capabilities) ;
3756
3757 /* update Supp rates */
3758 if(tdlsDisRsp.SuppRates.present)
3759 {
3760 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3761 &tdlsDisRsp.SuppRates );
3762 }
3763
3764 /* update EXT supp rates */
3765 if(tdlsDisRsp.ExtSuppRates.present)
3766 {
3767 peerInfo->ExtRatesPresent = 1;
3768 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3769 &tdlsDisRsp.ExtSuppRates );
3770 }
3771 /* update HT caps */
3772 if (tdlsDisRsp.HTCaps.present)
3773 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303774 vos_mem_copy( &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08003775 sizeof( tDot11fIEHTCaps ) );
3776 }
Kiran V1ccee932012-12-12 14:49:46 -08003777 } while(0) ;
3778
3779 /* now add this new found discovery node into tdls discovery list */
3780 tdlsDisResult->next = *disResultList ;
3781 *disResultList = tdlsDisResult ;
3782
3783 return eSIR_SUCCESS ;
3784}
3785
3786/*
3787 * Process TDLS Teardown request frame from TDLS peer STA
3788 */
3789static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac,
3790 tANI_U8 *pBody, tANI_U32 frmLen )
3791{
3792 tDot11fTDLSTeardown tdlsTeardown = {{0}} ;
3793 tANI_U32 status = 0 ;
3794 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3795 tpPESession psessionEntry = NULL ;
3796 tANI_U8 sessionId = 0 ;
3797
3798 status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ;
3799
3800 if ( DOT11F_FAILED( status ) )
3801 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003802 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3803 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003804 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3805 return eSIR_FAILURE;
3806 }
3807 else if ( DOT11F_WARNED( status ) )
3808 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003809 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3810 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003811 status, frmLen );
3812 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3813 }
3814
3815 /*
3816 * find session entry using BSSID in link identifier, not using MAC
3817 * header beacuse, there is cases in TDLS, there may be BSSID will not
3818 * be present in header
3819 */
3820 psessionEntry = peFindSessionByBssid(pMac,
3821 &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ;
3822 if(NULL == psessionEntry)
3823 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003824 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003825 ("no Session entry for TDLS session (bssid "
3826 MAC_ADDRESS_STR")"),
3827 MAC_ADDR_ARRAY(tdlsTeardown.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003828
3829 //VOS_ASSERT(0) ;
3830 return eSIR_FAILURE;
3831 }
3832
3833 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303834 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003835 &tdlsTeardown.LinkIdentifier.bssid[0],
3836 sizeof(tSirMacAddr)) ;
3837
3838
3839 if(!status)
3840 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003841 limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003842 VOS_ASSERT(0) ;
3843 return eSIR_FAILURE ;
3844 }
3845
3846 limTdlsFindLinkPeer(pMac,
3847 &tdlsTeardown.LinkIdentifier.InitStaAddr[0],
3848 &setupPeer) ;
3849
3850 if(NULL == setupPeer)
3851 {
3852 //ignore
3853 //VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003854 limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored") );
Kiran V1ccee932012-12-12 14:49:46 -08003855
3856 return eSIR_FAILURE ;
3857 }
3858 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003859 ("teardown for peer "MAC_ADDRESS_STR),
3860 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003861
3862 switch(tdlsTeardown.Reason.code)
3863 {
3864 case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON:
3865 {
3866 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003867 ("teardown with unspecified reason")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003868 break ;
3869 }
3870 case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
3871 {
3872 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003873 (" Teardown from AP, TDLS peer unreachable")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003874 break ;
3875 }
3876 default:
3877 {
3878 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003879 (" unknown teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003880 break ;
3881 }
3882 }
3883
3884 /* change TDLS peer State */
3885 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3886 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
3887
3888 do
3889 {
3890 tpDphHashNode pStaDs = NULL ;
3891
3892 /* tdls_hklee: send message to HAL before it is deleted, cause */
3893 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3894
3895 /* send del STA to remove context for this TDLS STA */
3896 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3897
3898 /* now send indication to SME-->HDD->TL to remove STA from TL */
3899
3900 if(pStaDs)
3901 {
3902 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3903 pStaDs, eSIR_SUCCESS) ;
3904
3905 /* send Teardown Ind to SME */
3906 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3907 eWNI_SME_TDLS_TEARDOWN_IND) ;
3908 /* remove node from setup list */
3909 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3910 }
3911
3912 }while(0) ;
3913
3914 return status ;
3915}
3916
3917/*
3918 * Common processing of TDLS action frames recieved
3919 */
3920void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd)
3921{
3922 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd);
3923 tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd))
3924 ? (( sizeof( eth_890d_header ))) :(0)) ;
3925
3926 tANI_U8 category = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ;
3927 tANI_U8 action = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ;
3928 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
3929 tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
3930 //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd);
3931
3932 if(category != SIR_MAC_ACTION_TDLS)
3933 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003934 limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored"), category );
Kiran V1ccee932012-12-12 14:49:46 -08003935 return ;
3936 }
3937
3938 frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003939 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 -08003940 action, limTraceTdlsActionString(action) ));
3941
3942 switch(action)
3943 {
3944
3945 case SIR_MAC_TDLS_SETUP_REQ:
3946 {
3947 limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ;
3948 break ;
3949 }
3950 case SIR_MAC_TDLS_SETUP_RSP:
3951 {
3952 limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ;
3953 break ;
3954 }
3955 case SIR_MAC_TDLS_SETUP_CNF:
3956 {
3957 limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ;
3958 break ;
3959 }
3960 case SIR_MAC_TDLS_TEARDOWN:
3961 {
3962 limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ;
3963 break ;
3964 }
3965 case SIR_MAC_TDLS_DIS_REQ:
3966 {
3967 limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ;
3968 break ;
3969 }
3970 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
3971 case SIR_MAC_TDLS_CH_SWITCH_REQ:
3972 case SIR_MAC_TDLS_CH_SWITCH_RSP:
3973 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
3974 default:
3975 {
3976 break ;
3977 }
3978 }
3979
3980 return ;
3981}
3982
3983/*
3984 * ADD sta for dis response fame sent on direct link
3985 */
3986static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
3987 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry)
3988{
3989 tpDphHashNode pStaDs = NULL ;
3990 tSirRetStatus status = eSIR_SUCCESS ;
3991 tANI_U16 aid = 0 ;
3992
3993 if(NULL == peerInfo)
3994 {
3995 VOS_ASSERT(0) ;
3996 return status ;
3997
3998 }
3999 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004000 ("ADD STA peer MAC: "MAC_ADDRESS_STR),
4001 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004002
4003
4004 if(NULL != dphLookupHashEntry(pMac, peerMac,
4005 &aid, &psessionEntry->dph.dphHashTable))
4006 {
4007 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004008 (" there is hash entry for this client")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004009 status = eSIR_FAILURE ;
4010 VOS_ASSERT(0) ;
4011 return status ;
4012 }
4013
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004014 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004015
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004016 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4017 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4018
Kiran V1ccee932012-12-12 14:49:46 -08004019 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4020
4021 if (pStaDs)
4022 {
4023 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4024 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4025 }
4026 pStaDs = dphAddHashEntry(pMac, peerMac, aid,
4027 &psessionEntry->dph.dphHashTable) ;
4028
4029 if(NULL == pStaDs)
4030 {
4031 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004032 (" add hash entry failed")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004033 status = eSIR_FAILURE ;
4034 VOS_ASSERT(0) ;
4035 return status;
4036 }
4037 if(eSIR_SUCCESS == status)
4038 {
4039#ifdef TDLS_RATE_DEBUG
4040 tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ;
4041 tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ;
4042 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004043 ("pSta DS [%p] "), pStaDs) ;
Kiran V1ccee932012-12-12 14:49:46 -08004044 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004045 ("peerInfo->tdlsPeerSuppRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004046 (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
4047 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004048 ("peerInfo->tdlsPeerExtRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004049 (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
4050 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004051 ("peerInfo->tdlsPeerPropRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004052 (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
4053 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004054 ("peerInfo->mcs = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004055 (tANI_U8 *)peerInfo->supportedMCSSet) ;
4056 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004057 ("num of supp rates = %02x"), suppRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004058 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004059 ("num of ext rates = %01x"), extRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004060#endif
4061
4062 /* Populate matching rate set */
4063#ifdef WLAN_FEATURE_11AC
4064 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4065 &peerInfo->tdlsPeerSuppRates,
4066 &peerInfo->tdlsPeerExtRates,
4067 peerInfo->supportedMCSSet,
4068 &pStaDs->mlmStaContext.propRateSet,
4069 psessionEntry, NULL))
4070#else
4071 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4072 &peerInfo->tdlsPeerSuppRates,
4073 &peerInfo->tdlsPeerExtRates,
4074 peerInfo->supportedMCSSet,
4075 &pStaDs->mlmStaContext.propRateSet,
4076 psessionEntry))
4077#endif
4078 {
4079 VOS_ASSERT(0) ;
4080 }
4081
4082
4083 pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304084 vos_mem_copy( pStaDs->staAddr, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08004085 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004086 ("Add STA for Peer: "MAC_ADDRESS_STR),
4087 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004088
4089
4090 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4091
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004092 status = limAddSta(pMac, pStaDs, false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004093
4094 if(eSIR_SUCCESS != status)
4095 {
4096 /* should not fail */
4097 VOS_ASSERT(0) ;
4098 }
4099 }
4100
4101 return status ;
4102}
4103#endif
4104/*
4105 * Add STA for TDLS setup procedure
4106 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004107static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
4108 tSirTdlsAddStaReq *pAddStaReq,
4109 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08004110{
4111 tpDphHashNode pStaDs = NULL ;
4112 tSirRetStatus status = eSIR_SUCCESS ;
4113 tANI_U16 aid = 0 ;
4114
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004115 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004116 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08004117 if(NULL == pStaDs)
4118 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004119 aid = limAssignPeerIdx(pMac, psessionEntry) ;
4120
4121 if( !aid )
4122 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004123 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004124 ("%s: No more free AID for peer " MAC_ADDRESS_STR),
4125 __func__, MAC_ADDR_ARRAY(pAddStaReq->peerMac)) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004126 return eSIR_FAILURE;
4127 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004128
4129 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4130 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4131
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004132 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004133 ("limTdlsSetupAddSta: Aid = %d, for peer =" MAC_ADDRESS_STR),
4134 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004135 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4136
4137 if (pStaDs)
4138 {
4139 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4140 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4141 }
4142
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004143 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004144 &psessionEntry->dph.dphHashTable) ;
4145
4146 if(NULL == pStaDs)
4147 {
4148 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004149 (" add hash entry failed")) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004150 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004151 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004152 }
Kiran V1ccee932012-12-12 14:49:46 -08004153 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004154
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004155 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004156
4157 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4158
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004159 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004160
4161 if(eSIR_SUCCESS != status)
4162 {
4163 /* should not fail */
4164 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004165 }
Kiran V1ccee932012-12-12 14:49:46 -08004166 return status ;
4167}
4168
4169/*
4170 * Del STA, after Link is teardown or discovery response sent on direct link
4171 */
4172static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4173 tpPESession psessionEntry)
4174{
4175 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004176 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08004177 tpDphHashNode pStaDs = NULL ;
4178
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004179 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08004180 &psessionEntry->dph.dphHashTable) ;
4181
4182 if(pStaDs)
4183 {
4184
4185 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004186 ("DEL STA peer MAC: "MAC_ADDRESS_STR),
4187 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004188
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004189 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004190 ("limTdlsDelSta: STA type = %x, sta idx = %x"),pStaDs->staType,
Kiran V1ccee932012-12-12 14:49:46 -08004191 pStaDs->staIndex) ;
4192
4193 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08004194#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -08004195 if(eSIR_SUCCESS == status)
4196 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004197 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ;
4198 limReleasePeerIdx(pMac, peerIdx, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004199 }
4200 else
4201 {
4202 VOS_ASSERT(0) ;
4203 }
Hoonki Leef63df0d2013-01-16 19:29:14 -08004204#endif
Kiran V1ccee932012-12-12 14:49:46 -08004205 }
4206
4207 return pStaDs ;
4208}
4209
4210#ifdef FEATURE_WLAN_TDLS_INTERNAL
4211/*
4212* Prepare link establish message for HAL, construct PTI template.
4213*
4214*/
4215static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4216{
4217 tANI_U8 pFrame[64] ;
4218 tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ;
4219 tANI_U32 status = 0 ;
4220 tANI_U32 nPayload = 0 ;
4221 tANI_U32 nBytes = 0 ;
4222 tANI_U32 header_offset = 0 ;
4223 tANI_U16 aid = 0 ;
4224 tDphHashNode *pStaDs = NULL ;
4225 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4226 tpPESession psessionEntry = NULL ;
4227
4228
4229 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4230 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004231 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4232 ("limTdlsLinkEstablish: cannot find peer mac "
4233 "in tdls linksetup list: "MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -08004234 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004235 return eSIR_FAILURE;
4236 }
4237
4238 psessionEntry = peFindSessionBySessionId(pMac,
4239 setupPeer->tdls_sessionId) ;
4240
4241 if(NULL == psessionEntry)
4242 {
4243 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004244 ("limTdlsLinkEstablish: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004245 VOS_ASSERT(0) ;
4246 return eHAL_STATUS_FAILURE;
4247 }
4248
Kiet Lam842dad02014-02-18 18:44:02 -08004249
Kiran V1ccee932012-12-12 14:49:46 -08004250 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
4251 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004252 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4253 ("limTdlsLinkEstablish: cannot find peer mac "
4254 "in tdls linksetup list: "MAC_ADDRESS_STR),
4255 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004256 return eSIR_FAILURE;
4257 }
4258
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304259 vos_mem_set( ( tANI_U8* )&tdlsPtiTemplate,
4260 sizeof( tDot11fTDLSPeerTrafficInd ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004261
4262 /*
4263 * setup Fixed fields,
4264 */
4265 tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS;
4266 tdlsPtiTemplate.Action.action = SIR_MAC_TDLS_PEER_TRAFFIC_IND;
4267 tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */
4268#if 1
4269 /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address,
4270 then below code makes such an way */
4271 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4272 peerMac, !setupPeer->tdls_bIsResponder) ;
4273#else
4274 /* below code will make PTI's linkIdentifier's initiator address be selfAddr */
4275 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4276 peerMac, TDLS_INITIATOR) ;
4277#endif
4278
4279 /* PUBufferStatus will be filled by firmware at the time of transmission */
4280 tdlsPtiTemplate.PUBufferStatus.present = 1;
4281
4282 /* TODO: get ExtendedCapabilities IE */
4283
4284 /*
4285 * now we pack it. First, how much space are we going to need?
4286 */
4287 status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload);
4288 if ( DOT11F_FAILED( status ) )
4289 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004290 limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004291 /* We'll fall back on the worst case scenario: */
4292 nPayload = sizeof( tdlsPtiTemplate );
4293 }
4294 else if ( DOT11F_WARNED( status ) )
4295 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004296 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 -08004297 }
4298
4299 /*
4300 * This frame is going out from PE as data frames with special ethertype
4301 * 89-0d.
4302 * 8 bytes of RFC 1042 header
4303 */
4304
4305 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
4306 + sizeof( eth_890d_header )
4307 + PAYLOAD_TYPE_TDLS_SIZE ;
4308
4309 if(nBytes > 64) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004310 limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64."), nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08004311 nBytes = 64;
4312 }
4313 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304314 vos_mem_set( pFrame, sizeof(pFrame), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004315
4316 /* fill out the buffer descriptor */
4317
4318 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
4319 LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ;
4320
4321 status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame
4322 + header_offset, nPayload, &nPayload );
4323
4324 if ( DOT11F_FAILED( status ) )
4325 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004326 limLog( pMac, LOGE, FL("Failed to pack a PTI template (0x%08x)."),
4327 status );
Kiran V1ccee932012-12-12 14:49:46 -08004328 return eSIR_FAILURE;
4329 }
4330 else if ( DOT11F_WARNED( status ) )
4331 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004332 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
4333 "Peer Traffic Indication (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004334 }
4335
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004336 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 -08004337 setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET));
4338
4339 limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder,
4340 header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET,
4341 nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps);
4342
4343 return eSIR_SUCCESS;
4344}
4345
4346/*
4347* Prepare link teardown message for HAL from peer_mac
4348*
4349*/
4350static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4351{
4352 tDphHashNode *pStaDs = NULL ;
4353 tANI_U16 aid = 0 ;
4354 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4355 tpPESession psessionEntry = NULL ;
4356
4357
4358 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4359 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004360 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4361 ("limTdlsLinkTeardown: cannot find peer mac "
4362 "in tdls linksetup list: "
4363 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004364 return eSIR_FAILURE;
4365 }
4366
4367 psessionEntry = peFindSessionBySessionId(pMac,
4368 setupPeer->tdls_sessionId) ;
4369
4370 if(NULL == psessionEntry)
4371 {
4372 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004373 ("limTdlsLinkTeardown: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004374 VOS_ASSERT(0) ;
4375 return eHAL_STATUS_FAILURE;
4376 }
4377
4378
Kiet Lam842dad02014-02-18 18:44:02 -08004379
Kiran V1ccee932012-12-12 14:49:46 -08004380 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
4381
4382 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004383 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4384 ("limTdlsLinkTeardown: cannot find peer mac "
4385 "in hash table: "
4386 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004387 return eSIR_FAILURE;
4388 }
4389
4390 limSendTdlsLinkTeardown(pMac, pStaDs->staIndex);
4391
4392 return eSIR_SUCCESS;
4393}
4394
4395/*
4396 * Prepare Discovery RSP message for SME, collect peerINfo for all the
4397 * peers discovered and delete/clean discovery lists in PE.
4398 */
4399
4400static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac,
4401 tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount)
4402{
4403 tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp);
4404 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4405
4406 /*
4407 * allocate memory for tdls discovery response, allocated memory should
4408 * be alloc_mem = tdlsStaCount * sizeof(peerinfo)
4409 * + siezeof tSirTdlsDisRsp.
4410 */
4411 disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo));
4412
4413 /* now allocate memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304414
4415 disRsp = vos_mem_malloc(disMsgRspSize);
4416 if ( NULL == disRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004417 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304418 limLog(pMac, LOGP, FL("AllocateMemory failed for DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004419 return NULL ;
4420 }
4421
4422 if(disStaCount)
4423 {
4424 tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ;
4425 tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ;
4426
4427 tLimDisResultList *currentNode = tdlsDisRspList ;
4428 while(tdlsDisRspList != NULL)
4429 {
4430
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304431 vos_mem_copy( (tANI_U8 *)peerInfo,
Kiran V1ccee932012-12-12 14:49:46 -08004432 (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo,
4433 sizeof(tSirTdlsPeerInfo));
4434
4435 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004436 ("Msg Sent to PE, peer MAC: "MAC_ADDRESS_STR),
4437 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004438 disStaCount-- ;
4439 peerInfo++ ;
4440 currentNode = tdlsDisRspList ;
4441 tdlsDisRspList = tdlsDisRspList->next ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304442 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08004443 /* boundary condition check, may be fatal */
4444 if(((!disStaCount) && (tdlsDisRspList))
4445 || ((!tdlsDisRspList) && disStaCount))
4446 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004447 limLog(pMac, LOG1, FL("mismatch in dis sta count and "
4448 "number of nodes in list")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004449 VOS_ASSERT(0) ;
4450 return NULL ;
4451 }
4452 } /* end of while */
4453
4454 /* All discovery STA processed */
4455 pMac->lim.gLimTdlsDisResultList = NULL ;
4456
4457 } /* end of if dis STA count */
4458
4459 return (disRsp) ;
4460}
4461
4462/* Send Teardown response back to PE */
4463
4464void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4465 tSirMacAddr peerMac, tANI_U16 msgType)
4466{
4467 tSirMsgQ mmhMsg = {0} ;
4468 tSirTdlsTeardownRsp *teardownRspMsg = NULL ;
4469 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4470
4471 mmhMsg.type = msgType ;
4472
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304473 teardownRspMsg = vos_mem_malloc(sizeof(tSirTdlsTeardownRsp));
4474 if ( NULL == teardownRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004475 {
4476 VOS_ASSERT(0) ;
4477 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304478 vos_mem_copy( teardownRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004479 sizeof(tSirMacAddr)) ;
4480 teardownRspMsg->statusCode = statusCode ;
4481 mmhMsg.bodyptr = teardownRspMsg ;
4482 mmhMsg.bodyval = 0;
4483 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4484
4485 return ;
4486
4487}
4488
4489/*
4490 * Send Link start RSP back to SME after link is setup or failed
4491 */
4492void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac,
4493 tSirResultCodes statusCode,
4494 tSirMacAddr peerMac,
4495 tANI_U16 msgType)
4496{
4497 tSirMsgQ mmhMsg = {0} ;
4498 tSirTdlsLinksetupRsp *setupRspMsg = NULL ;
4499 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4500
4501 mmhMsg.type = msgType ;
4502
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304503 setupRspMsg = vos_mem_malloc(sizeof(tSirTdlsLinksetupRsp));
4504 if ( NULL == setupRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004505 {
4506 VOS_ASSERT(0) ;
4507 }
4508
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304509 vos_mem_copy( setupRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004510 sizeof(tSirMacAddr)) ;
4511 setupRspMsg->statusCode = statusCode ;
4512 mmhMsg.bodyptr = setupRspMsg ;
4513 mmhMsg.bodyval = 0;
4514 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4515
4516 return ;
4517}
4518
4519/*
4520 * Send TDLS discovery RSP back to SME
4521 */
4522void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4523 tANI_U16 msgType)
4524{
4525 tSirMsgQ mmhMsg = {0} ;
4526 tSirTdlsDisRsp *tdlsDisRsp = NULL ;
4527
4528 mmhMsg.type = msgType ;
4529
4530 if(eSIR_SME_SUCCESS == statusCode)
4531 {
4532 tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ;
4533
4534 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004535 ("no of TDLS STA discovered: %d"), tdlsStaCount) ;
Kiran V1ccee932012-12-12 14:49:46 -08004536 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
4537
4538 if(tdlsDisRsp)
4539 {
4540 tdlsDisRsp->numDisSta = tdlsStaCount ;
4541 }
4542 else
4543 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004544 limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004545 VOS_ASSERT(0) ;
4546 return ;
4547 }
4548 /* all Discovery STA is processed */
4549 pMac->lim.gLimTdlsDisStaCount = 0 ;
4550 }
4551 else
4552 {
4553 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ;
4554 }
4555
4556 tdlsDisRsp->statusCode = statusCode ;
4557 mmhMsg.bodyptr = tdlsDisRsp ;
4558 mmhMsg.bodyval = 0;
4559 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4560
4561 return ;
4562}
4563
4564/*
4565 * Once Link is setup with PEER, send Add STA ind to SME
4566 */
4567static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac,
4568 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4569{
4570 tSirMsgQ mmhMsg = {0} ;
4571 tSirTdlsPeerInd *peerInd = NULL ;
4572 mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304573
4574 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4575 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004576 {
4577 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4578 return eSIR_FAILURE;
4579 }
4580
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304581 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004582 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4583 peerInd->sessionId = sessionId;
4584 peerInd->staId = pStaDs->staIndex ;
4585 peerInd->ucastSig = pStaDs->ucUcastSig ;
4586 peerInd->bcastSig = pStaDs->ucBcastSig ;
4587 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4588
4589 mmhMsg.bodyptr = peerInd ;
4590 mmhMsg.bodyval = 0;
4591 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4592
4593 return eSIR_SUCCESS ;
4594
4595}
4596
4597/*
4598 * Once link is teardown, send Del Peer Ind to SME
4599 */
4600static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
4601 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4602{
4603 tSirMsgQ mmhMsg = {0} ;
4604 tSirTdlsPeerInd *peerInd = NULL ;
4605 mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304606
4607 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4608 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004609 {
4610 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4611 return eSIR_FAILURE;
4612 }
4613
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304614 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004615 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4616 peerInd->sessionId = sessionId;
4617 peerInd->staId = pStaDs->staIndex ;
4618 peerInd->ucastSig = pStaDs->ucUcastSig ;
4619 peerInd->bcastSig = pStaDs->ucBcastSig ;
4620 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4621
4622 mmhMsg.bodyptr = peerInd ;
4623
4624 //peerInd->statusCode = status ;
4625 mmhMsg.bodyval = 0;
4626 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4627 return eSIR_SUCCESS ;
4628
4629}
4630
4631/*
4632 * Send Link setup Ind to SME, This is the case where, link setup is
4633 * initiated by peer STA
4634 */
4635static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
4636 tSirMacAddr peerMac, tANI_U8 status)
4637{
4638 tSirMsgQ mmhMsg = {0} ;
4639 tSirTdlsLinkSetupInd *setupInd = NULL ;
4640
4641 mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304642 setupInd = vos_mem_malloc(sizeof(tSirTdlsLinkSetupInd));
4643 if ( NULL == setupInd )
Kiran V1ccee932012-12-12 14:49:46 -08004644 {
4645 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4646 return eSIR_FAILURE;
4647 }
4648
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304649 vos_mem_copy( setupInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004650 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4651 setupInd->length = sizeof(tSirTdlsLinkSetupInd);
4652 setupInd->statusCode = status ;
4653 mmhMsg.bodyptr = setupInd ;
4654 mmhMsg.bodyval = 0;
4655 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4656
4657 return eSIR_SUCCESS ;
4658
4659}
4660
4661/*
4662 * Setup RSP timer handler
4663 */
4664void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4665{
4666
4667 tANI_U32 statusCode;
4668 tSirMsgQ msg;
4669 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4670
4671 /* Prepare and post message to LIM Message Queue */
4672
4673 msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT;
4674 msg.bodyptr = NULL ;
4675 msg.bodyval = timerId ;
4676
4677 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4678 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004679 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004680 msg.type, statusCode);
4681 return ;
4682}
4683
4684/*
4685 * Link setup CNF timer
4686 */
4687void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4688{
4689
4690 tANI_U32 statusCode;
4691 tSirMsgQ msg;
4692 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4693
4694 // Prepare and post message to LIM Message Queue
4695
4696 msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT;
4697 msg.bodyptr = NULL ;
4698 msg.bodyval = timerId ;
4699
4700 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4701 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004702 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004703 msg.type, statusCode);
4704 return ;
4705}
4706
4707/*
4708 * start TDLS timer
4709 */
4710void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer,
4711 tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg)
4712{
4713 tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4714 ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT
4715 : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ;
4716
4717 void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4718 ? (limTdlsLinkSetupRspTimerHandler)
4719 : limTdlsLinkSetupCnfTimerHandler ;
4720
4721 /* TODO: Read timer vals from CFG */
4722
4723 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4724 /*
4725 * create TDLS discovery response wait timer and activate it
4726 */
4727 if (tx_timer_create(timer, "TDLS link setup timers", timerFunc,
4728 timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS)
4729 {
4730 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004731 FL("could not create TDLS discovery response wait timer"));
Kiran V1ccee932012-12-12 14:49:46 -08004732 return;
4733 }
4734
4735 //assign appropriate sessionId to the timer object
4736 timer->sessionId = sessionId;
4737
4738 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4739 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4740 if (tx_timer_activate(timer) != TX_SUCCESS)
4741 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004742 limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!"));
Kiran V1ccee932012-12-12 14:49:46 -08004743 return ;
4744 }
4745
4746 return ;
4747
4748}
4749#endif
4750
4751/*
4752 * Once Link is setup with PEER, send Add STA ind to SME
4753 */
4754static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004755 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
4756 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08004757{
4758 tSirMsgQ mmhMsg = {0} ;
4759 tSirTdlsAddStaRsp *addStaRsp = NULL ;
4760 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304761
4762 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
4763 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004764 {
4765 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4766 return eSIR_FAILURE;
4767 }
4768
4769 addStaRsp->sessionId = sessionId;
4770 addStaRsp->statusCode = status;
4771 if( pStaDs )
4772 {
4773 addStaRsp->staId = pStaDs->staIndex ;
4774 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
4775 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
4776 }
4777 if( peerMac )
4778 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304779 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004780 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4781 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004782 if (updateSta)
4783 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
4784 else
4785 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
4786
Kiran V1ccee932012-12-12 14:49:46 -08004787 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
4788 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
4789
4790 mmhMsg.bodyptr = addStaRsp;
4791 mmhMsg.bodyval = 0;
4792 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4793
4794 return eSIR_SUCCESS ;
4795
4796}
4797/*
4798 * STA RSP received from HAL
4799 */
4800eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
4801 tpPESession psessionEntry)
4802{
4803 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
4804 tANI_U8 status = eSIR_SUCCESS ;
4805 tDphHashNode *pStaDs = NULL ;
4806 tANI_U16 aid = 0 ;
4807
4808 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004809 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Arif Hussain24bafea2013-11-15 15:10:03 -08004810 ("limTdlsAddStaRsp: staIdx=%d, staMac="MAC_ADDRESS_STR), pAddStaParams->staIdx,
4811 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08004812
4813 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
4814 {
4815 VOS_ASSERT(0) ;
4816 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004817 ("Add sta failed ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004818 status = eSIR_FAILURE;
4819 goto add_sta_error;
4820 }
4821
4822 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
4823 &psessionEntry->dph.dphHashTable);
4824 if(NULL == pStaDs)
4825 {
4826 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004827 ("pStaDs is NULL ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004828 status = eSIR_FAILURE;
4829 goto add_sta_error;
4830 }
4831
4832 pStaDs->bssId = pAddStaParams->bssIdx;
4833 pStaDs->staIndex = pAddStaParams->staIdx;
4834 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
4835 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
4836 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4837 pStaDs->valid = 1 ;
4838#ifdef FEATURE_WLAN_TDLS_INTERNAL
4839 status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId,
4840 pStaDs, eSIR_SUCCESS ) ;
4841 if(eSIR_FAILURE == status)
4842 {
4843 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004844 ("Peer IND msg to SME failed")) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304845 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004846 return eSIR_FAILURE ;
4847 }
4848
4849 /*
4850 * Now, there is two things a) ADD STA RSP for ADD STA request sent
4851 * after recieving discovery request from Peer.
4852 * now we have to send discovery response, if there is any pending
4853 * discovery equest..
4854 */
4855 do
4856 {
4857 tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac,
4858 pAddStaParams->staMac) ;
4859
4860
4861 if(peerInfo)
4862 {
4863 /*
4864 * send TDLS discovery response frame on direct link, state machine
4865 * is rolling.., once discovery response is get Acked, we will
4866 * send response to SME based on TxComplete callback results
4867 */
4868 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
4869 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
4870 }
4871 } while(0) ;
Kiran V1ccee932012-12-12 14:49:46 -08004872#endif
4873add_sta_error:
4874 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004875 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304876 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004877 return status ;
4878}
4879
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304880void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
4881 tpPESession psessionEntry,
4882 tDot11fIESuppChannels *suppChannels,
4883 tDot11fIESuppOperatingClasses *suppOperClasses)
4884{
4885 tANI_U32 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4886 tANI_U8 validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4887 tANI_U8 i;
4888 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
4889 validChan, &numChans) != eSIR_SUCCESS)
4890 {
4891 /**
4892 * Could not get Valid channel list from CFG.
4893 * Log error.
4894 */
4895 limLog(pMac, LOGP,
4896 FL("could not retrieve Valid channel list"));
4897 }
4898 suppChannels->num_bands = (tANI_U8) numChans;
4899
4900 for ( i = 0U; i < suppChannels->num_bands; i++)
4901 {
4902 suppChannels->bands[i][0] = validChan[i];
4903 suppChannels->bands[i][1] = 1;
4904 }
4905 suppChannels->present = 1 ;
4906 return ;
4907}
4908
4909
Kiran V1ccee932012-12-12 14:49:46 -08004910/*
4911 * FUNCTION: Populate Link Identifier element IE
4912 *
4913 */
4914
4915
4916void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
4917 tDot11fIELinkIdentifier *linkIden,
4918 tSirMacAddr peerMac, tANI_U8 reqType)
4919{
4920 //tANI_U32 size = sizeof(tSirMacAddr) ;
4921 tANI_U8 *initStaAddr = NULL ;
4922 tANI_U8 *respStaAddr = NULL ;
4923
4924 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
4925 (respStaAddr = linkIden->RespStaAddr))
4926 : ((respStaAddr = linkIden->InitStaAddr ),
4927 (initStaAddr = linkIden->RespStaAddr)) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304928 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08004929 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
4930
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304931 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08004932 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
4933
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304934 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004935 sizeof( tSirMacAddr ));
4936
4937 linkIden->present = 1 ;
4938 return ;
4939
4940}
4941
4942void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
4943 tDot11fIEExtCap *extCapability)
4944{
4945 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05304946 extCapability->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304947 extCapability->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
Kiran V1ccee932012-12-12 14:49:46 -08004948 extCapability->TDLSSupport = TDLS_SUPPORT ;
4949 extCapability->TDLSProhibited = TDLS_PROHIBITED ;
4950 extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
4951 extCapability->present = 1 ;
4952 return ;
4953}
4954
4955#ifdef FEATURE_WLAN_TDLS_INTERNAL
4956/*
4957 * Public Action frame common processing
4958 * This Function will be moved/merged to appropriate place
4959 * once other public action frames (particularly 802.11k)
4960 * is in place
4961 */
4962void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd,
4963 tpPESession psessionEntry)
4964{
4965 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
4966 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ;
4967 tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ;
4968
4969 limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ;
4970 return ;
4971}
4972
4973eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac,
4974 tLimTdlsLinkSetupInfo *linkSetupInfo,
4975 tANI_U8 dialog, tSirMacAddr peerMac,
4976 tpPESession psessionEntry)
4977{
4978 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4979
4980 /*
4981 * we allocate the TDLS setup Peer Memory here, we will free'd this
4982 * memory after teardown, if the link is successfully setup or
4983 * free this memory if any timeout is happen in link setup procedure
4984 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304985
4986 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
4987 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08004988 {
4989 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004990 FL( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08004991 VOS_ASSERT(0) ;
4992 return eSIR_MEM_ALLOC_FAILED;
4993 }
4994 setupPeer->dialog = dialog ;
4995 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
4996 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
4997
4998 /* TDLS_sessionize: remember sessionId for future */
4999 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5000 setupPeer->tdls_bIsResponder = 1;
5001
5002 /*
5003 * we only populate peer MAC, so it can assit us to find the
5004 * TDLS peer after response/or after response timeout
5005 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305006 vos_mem_copy(setupPeer->peerMac, peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005007 sizeof(tSirMacAddr)) ;
5008 /* format TDLS discovery request frame and transmit it */
5009 limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ;
5010
5011 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5012 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5013 (tANI_U32)setupPeer->peerMac,
5014 WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5015 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5016 /* update setup peer list */
5017 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5018 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5019
5020 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to
5021 * SME later when TDLS setup cnf TX complete is successful. --> see
5022 * limTdlsSetupCnfTxComplete()
5023 */
5024 return eSIR_SUCCESS ;
5025}
5026#endif
5027
5028/*
5029 * Process Send Mgmt Request from SME and transmit to AP.
5030 */
5031tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
5032 tANI_U32 *pMsgBuf)
5033{
5034 /* get all discovery request parameters */
5035 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
5036 tpPESession psessionEntry;
5037 tANI_U8 sessionId;
5038 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
5039
5040 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005041 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005042
5043 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
5044 == NULL)
5045 {
5046 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005047 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005048 pSendMgmtReq->sessionId);
5049 goto lim_tdls_send_mgmt_error;
5050 }
5051
5052 /* check if we are in proper state to work as TDLS client */
5053 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5054 {
5055 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005056 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005057 psessionEntry->limSystemRole);
5058 goto lim_tdls_send_mgmt_error;
5059 }
5060
5061 /*
5062 * if we are still good, go ahead and check if we are in proper state to
5063 * do TDLS discovery req/rsp/....frames.
5064 */
5065 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5066 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5067 {
5068
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005069 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5070 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005071 goto lim_tdls_send_mgmt_error;
5072 }
5073
5074 switch( pSendMgmtReq->reqType )
5075 {
5076 case SIR_MAC_TDLS_DIS_REQ:
5077 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005078 "Transmit Discovery Request Frame") ;
Kiran V1ccee932012-12-12 14:49:46 -08005079 /* format TDLS discovery request frame and transmit it */
5080 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
5081 psessionEntry) ;
5082 resultCode = eSIR_SME_SUCCESS;
5083 break;
5084 case SIR_MAC_TDLS_DIS_RSP:
5085 {
5086 //Send a response mgmt action frame
5087 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
5088 pSendMgmtReq->dialog, psessionEntry) ;
5089 resultCode = eSIR_SME_SUCCESS;
5090 }
5091 break;
5092 case SIR_MAC_TDLS_SETUP_REQ:
5093 {
5094 limSendTdlsLinkSetupReqFrame(pMac,
5095 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
5096 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5097 resultCode = eSIR_SME_SUCCESS;
5098 }
5099 break;
5100 case SIR_MAC_TDLS_SETUP_RSP:
5101 {
5102 limSendTdlsSetupRspFrame(pMac,
5103 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
5104 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5105 resultCode = eSIR_SME_SUCCESS;
5106 }
5107 break;
5108 case SIR_MAC_TDLS_SETUP_CNF:
5109 {
5110 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
5111 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5112 resultCode = eSIR_SME_SUCCESS;
5113 }
5114 break;
5115 case SIR_MAC_TDLS_TEARDOWN:
5116 {
5117 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08005118 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08005119 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5120 resultCode = eSIR_SME_SUCCESS;
5121 }
5122 break;
5123 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
5124 {
5125 }
5126 break;
5127 case SIR_MAC_TDLS_CH_SWITCH_REQ:
5128 {
5129 }
5130 break;
5131 case SIR_MAC_TDLS_CH_SWITCH_RSP:
5132 {
5133 }
5134 break;
5135 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
5136 {
5137 }
5138 break;
5139 default:
5140 break;
5141 }
5142
5143lim_tdls_send_mgmt_error:
5144
5145 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
5146 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
5147
5148 return eSIR_SUCCESS;
5149}
5150
5151/*
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305152 * Send Response to Link Establish Request to SME
5153 */
5154void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
5155 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5156 tANI_U8 status)
5157{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305158 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305159
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305160 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305161
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305162 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
5163 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305164 {
5165 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305166 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305167 }
5168 pTdlsLinkEstablishReqRsp->statusCode = status ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305169 if ( peerMac )
5170 {
5171 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
5172 }
5173 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305174 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305175 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305176 mmhMsg.bodyval = 0;
5177 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5178 return ;
5179
5180
5181}
5182
5183/*
Kiran V1ccee932012-12-12 14:49:46 -08005184 * Once link is teardown, send Del Peer Ind to SME
5185 */
5186static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
5187 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5188 tANI_U8 status)
5189{
5190 tSirMsgQ mmhMsg = {0} ;
5191 tSirTdlsDelStaRsp *pDelSta = NULL ;
5192 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305193
5194 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
5195 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08005196 {
5197 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
5198 return eSIR_FAILURE;
5199 }
5200
5201 pDelSta->sessionId = sessionId;
5202 pDelSta->statusCode = status ;
5203 if( pStaDs )
5204 {
5205 pDelSta->staId = pStaDs->staIndex ;
5206 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005207 else
5208 pDelSta->staId = HAL_STA_INVALID_IDX;
5209
Kiran V1ccee932012-12-12 14:49:46 -08005210 if( peerMac )
5211 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305212 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08005213 }
5214
5215 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
5216 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
5217
5218 mmhMsg.bodyptr = pDelSta;
5219
5220 mmhMsg.bodyval = 0;
5221 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5222 return eSIR_SUCCESS ;
5223
5224}
5225
5226/*
5227 * Process Send Mgmt Request from SME and transmit to AP.
5228 */
5229tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
5230 tANI_U32 *pMsgBuf)
5231{
5232 /* get all discovery request parameters */
5233 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
5234 tpPESession psessionEntry;
5235 tANI_U8 sessionId;
Kiran V1ccee932012-12-12 14:49:46 -08005236
5237 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005238 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005239
5240 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
5241 == NULL)
5242 {
5243 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005244 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005245 pAddStaReq->sessionId);
5246 goto lim_tdls_add_sta_error;
5247 }
5248
5249 /* check if we are in proper state to work as TDLS client */
5250 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5251 {
5252 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005253 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005254 psessionEntry->limSystemRole);
5255 goto lim_tdls_add_sta_error;
5256 }
5257
5258 /*
5259 * if we are still good, go ahead and check if we are in proper state to
5260 * do TDLS discovery req/rsp/....frames.
5261 */
5262 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5263 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5264 {
5265
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005266 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5267 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005268 goto lim_tdls_add_sta_error;
5269 }
5270
5271 pMac->lim.gLimAddStaTdls = true ;
5272
5273 /* To start with, send add STA request to HAL */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005274 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08005275 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005276 limLog(pMac, LOGE, "%s: Add TDLS Station request failed ", __func__);
Kiran V1ccee932012-12-12 14:49:46 -08005277 goto lim_tdls_add_sta_error;
5278 }
5279 return eSIR_SUCCESS;
5280lim_tdls_add_sta_error:
5281 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005282 pAddStaReq->sessionId, pAddStaReq->peerMac,
5283 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08005284
5285 return eSIR_SUCCESS;
5286}
5287/*
5288 * Process Del Sta Request from SME .
5289 */
5290tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
5291 tANI_U32 *pMsgBuf)
5292{
5293 /* get all discovery request parameters */
5294 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
5295 tpPESession psessionEntry;
5296 tANI_U8 sessionId;
5297 tpDphHashNode pStaDs = NULL ;
5298
5299 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005300 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005301
5302 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
5303 == NULL)
5304 {
5305 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005306 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005307 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005308 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005309 NULL, eSIR_FAILURE) ;
5310 return eSIR_FAILURE;
5311 }
5312
5313 /* check if we are in proper state to work as TDLS client */
5314 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5315 {
5316 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005317 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005318 psessionEntry->limSystemRole);
5319 goto lim_tdls_del_sta_error;
5320 }
5321
5322 /*
5323 * if we are still good, go ahead and check if we are in proper state to
5324 * do TDLS discovery req/rsp/....frames.
5325 */
5326 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5327 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5328 {
5329
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005330 limLog(pMac, LOGE, "Del Sta received in invalid LIMsme state (%d)",
5331 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005332 goto lim_tdls_del_sta_error;
5333 }
5334
5335 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
5336
5337 /* now send indication to SME-->HDD->TL to remove STA from TL */
5338
5339 if(pStaDs)
5340 {
5341 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5342 pStaDs, eSIR_SUCCESS) ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005343 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08005344
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005345 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
5346 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005347 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
5348
Kiran V1ccee932012-12-12 14:49:46 -08005349 return eSIR_SUCCESS;
5350
5351 }
5352
5353lim_tdls_del_sta_error:
5354 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5355 NULL, eSIR_FAILURE) ;
5356
5357 return eSIR_SUCCESS;
5358}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005359
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305360/* Intersects the two input arrays and outputs an array */
5361/* For now the array length of tANI_U8 suffices */
5362static void limTdlsGetIntersection(tANI_U8 *input_array1,tANI_U8 input1_length,
5363 tANI_U8 *input_array2,tANI_U8 input2_length,
5364 tANI_U8 *output_array,tANI_U8 *output_length)
5365{
5366 tANI_U8 i,j,k=0,flag=0;
5367 for(i=0;i<input1_length;i++)
5368 {
5369 flag=0;
5370 for(j=0;j<input2_length;j++)
5371 {
5372 if(input_array1[i]==input_array2[j])
5373 {
5374 flag=1;
5375 break;
5376 }
5377 }
5378 if(flag==1)
5379 {
5380 output_array[k]=input_array1[i];
5381 k++;
5382 }
5383 }
5384 *output_length = k;
5385}
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305386/*
5387 * Process Link Establishment Request from SME .
5388 */
5389tSirRetStatus limProcesSmeTdlsLinkEstablishReq(tpAniSirGlobal pMac,
5390 tANI_U32 *pMsgBuf)
5391{
5392 /* get all discovery request parameters */
5393 tSirTdlsLinkEstablishReq *pTdlsLinkEstablishReq = (tSirTdlsLinkEstablishReq*) pMsgBuf ;
5394 tpPESession psessionEntry;
5395 tANI_U8 sessionId;
5396 tpTdlsLinkEstablishParams pMsgTdlsLinkEstablishReq;
5397 tSirMsgQ msg;
5398 tANI_U16 peerIdx = 0 ;
5399 tpDphHashNode pStaDs = NULL ;
5400
5401 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005402 ("Send Mgmt Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305403
5404 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
5405 == NULL)
5406 {
5407 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005408 "PE Session does not exist for given sme sessionId %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305409 pTdlsLinkEstablishReq->sessionId);
5410 limSendSmeTdlsLinkEstablishReqRsp(pMac, pTdlsLinkEstablishReq->sessionId, pTdlsLinkEstablishReq->peerMac,
5411 NULL, eSIR_FAILURE) ;
5412 return eSIR_FAILURE;
5413 }
5414
5415 /* check if we are in proper state to work as TDLS client */
5416 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5417 {
5418 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005419 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305420 psessionEntry->limSystemRole);
5421 goto lim_tdls_link_establish_error;
5422 }
5423
5424 /*
5425 * if we are still good, go ahead and check if we are in proper state to
5426 * do TDLS discovery req/rsp/....frames.
5427 */
5428 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5429 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5430 {
5431
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005432 limLog(pMac, LOGE, "TDLS Link Establish Request received in "
5433 "invalid LIMsme state (%d)", psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305434 goto lim_tdls_link_establish_error;
5435 }
5436 /*TODO Sunil , TDLSPeer Entry has the STA ID , Use it */
5437 pStaDs = dphLookupHashEntry(pMac, pTdlsLinkEstablishReq->peerMac, &peerIdx,
5438 &psessionEntry->dph.dphHashTable) ;
5439 if ( NULL == pStaDs )
5440 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005441 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305442 goto lim_tdls_link_establish_error;
5443
5444 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305445 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
5446 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305447 {
5448 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005449 FL( "Unable to allocate memory TDLS Link Establish Request" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305450 return eSIR_MEM_ALLOC_FAILED;
5451 }
5452
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305453 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tpTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305454
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05305455 pMsgTdlsLinkEstablishReq->staIdx = pStaDs->staIndex;
5456 pMsgTdlsLinkEstablishReq->isResponder = pTdlsLinkEstablishReq->isResponder;
5457 pMsgTdlsLinkEstablishReq->uapsdQueues = pTdlsLinkEstablishReq->uapsdQueues;
5458 pMsgTdlsLinkEstablishReq->maxSp = pTdlsLinkEstablishReq->maxSp;
5459 pMsgTdlsLinkEstablishReq->isBufsta = pTdlsLinkEstablishReq->isBufSta;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305460 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
5461 pTdlsLinkEstablishReq->isOffChannelSupported;
5462 pMsgTdlsLinkEstablishReq->isOffChannelSupported = 1;
5463
5464 if ( 0 != pTdlsLinkEstablishReq->supportedChannelsLen)
5465 {
5466 tANI_U32 selfNumChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5467 tANI_U8 selfSupportedChannels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5468 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
5469 selfSupportedChannels, &selfNumChans) != eSIR_SUCCESS)
5470 {
5471 /**
5472 * Could not get Valid channel list from CFG.
5473 * Log error.
5474 */
5475 limLog(pMac, LOGP,
5476 FL("could not retrieve Valid channel list"));
5477 }
5478 limTdlsGetIntersection(selfSupportedChannels, selfNumChans,
5479 pTdlsLinkEstablishReq->supportedChannels,
5480 pTdlsLinkEstablishReq->supportedChannelsLen,
5481 pMsgTdlsLinkEstablishReq->validChannels,
5482 &pMsgTdlsLinkEstablishReq->validChannelsLen);
5483 }
5484 vos_mem_copy(pMsgTdlsLinkEstablishReq->validOperClasses,
5485 pTdlsLinkEstablishReq->supportedOperClasses, pTdlsLinkEstablishReq->supportedOperClassesLen);
5486 pMsgTdlsLinkEstablishReq->validOperClassesLen =
5487 pTdlsLinkEstablishReq->supportedOperClassesLen;
5488
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305489 msg.type = WDA_SET_TDLS_LINK_ESTABLISH_REQ;
5490 msg.reserved = 0;
5491 msg.bodyptr = pMsgTdlsLinkEstablishReq;
5492 msg.bodyval = 0;
5493 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5494 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005495 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305496 goto lim_tdls_link_establish_error;
5497 }
5498 return eSIR_SUCCESS;
5499lim_tdls_link_establish_error:
5500 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
5501 NULL, eSIR_FAILURE) ;
5502
5503 return eSIR_SUCCESS;
5504}
5505
5506
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005507/* Delete all the TDLS peer connected before leaving the BSS */
5508tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
5509{
5510 tpDphHashNode pStaDs = NULL ;
5511 int i, aid;
5512
5513 if (NULL == psessionEntry)
5514 {
5515 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
5516 return eSIR_FAILURE;
5517 }
5518
5519 /* Check all the set bit in peerAIDBitmap and delete the peer (with that aid) entry
5520 from the hash table and add the aid in free pool */
5521 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
5522 {
5523 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
5524 {
5525 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
5526 {
5527 pStaDs = dphGetHashEntry(pMac, (aid + i*(sizeof(tANI_U32) << 3)), &psessionEntry->dph.dphHashTable);
5528
5529 if (NULL != pStaDs)
5530 {
Arif Hussain24bafea2013-11-15 15:10:03 -08005531 PELOGE(limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
5532 MAC_ADDR_ARRAY(pStaDs->staAddr)););
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005533
5534 limSendDeauthMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
5535 pStaDs->staAddr, psessionEntry, FALSE);
5536 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, &psessionEntry->dph.dphHashTable);
5537 }
5538 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)), psessionEntry) ;
5539 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
5540 }
5541 }
5542 }
5543 limSendSmeTDLSDeleteAllPeerInd(pMac, psessionEntry);
5544
5545 return eSIR_SUCCESS;
5546}
Kiran V1ccee932012-12-12 14:49:46 -08005547#endif