blob: a844055c62698202775cab4f315cbbd302c2c3d9 [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
Kiran V1ccee932012-12-12 14:49:46 -0800220
221#ifdef FEATURE_WLAN_TDLS
222#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100)
223#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800)
224#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200)
225#endif
226
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530227#define IS_QOS_ENABLED(psessionEntry) ((((psessionEntry)->limQosEnabled) && \
228 SIR_MAC_GET_QOS((psessionEntry)->limCurrentBssCaps)) || \
229 (((psessionEntry)->limWmeEnabled ) && \
230 LIM_BSS_CAPS_GET(WME, (psessionEntry)->limCurrentBssQosCaps)))
231
232#define TID_AC_VI 4
233#define TID_AC_BK 1
234
Kiran V1ccee932012-12-12 14:49:46 -0800235const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
236{
237 switch( tdlsActionCode )
238 {
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530239 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
240 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
241 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
242 CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
243 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
244 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
245 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
246 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
247 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
248 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
Kiran V1ccee932012-12-12 14:49:46 -0800249 }
250 return (const tANI_U8*)"UNKNOWN";
251}
252#endif
253#if 0
254static void printMacAddr(tSirMacAddr macAddr)
255{
256 int i = 0 ;
257 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
258
259 for(i = 0 ; i < 6; i++)
260 {
261 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
262 (" %02x "), macAddr[i]);
263 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700264 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (""));
Kiran V1ccee932012-12-12 14:49:46 -0800265 return ;
266}
267#endif
Kiran V1ccee932012-12-12 14:49:46 -0800268/*
269 * initialize TDLS setup list and related data structures.
270 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800271void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800272{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800273#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800274 pMac->lim.gLimTdlsDisResultList = NULL ;
275 pMac->lim.gLimTdlsDisStaCount = 0 ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530276 vos_mem_set(&pMac->lim.gLimTdlsDisReq, sizeof(tSirTdlsDisReq), 0);
277 vos_mem_set(&pMac->lim.gLimTdlsLinkSetupInfo, sizeof(tLimTdlsLinkSetupInfo), 0);
Kiran V1ccee932012-12-12 14:49:46 -0800278 pMac->lim.gAddStaDisRspWait = 0 ;
279
280#ifdef FEATURE_WLAN_TDLS_NEGATIVE
281 /* when reassociated, negative behavior will not be kept */
282 /* you have to explicitly enable negative behavior per (re)association */
283 pMac->lim.gLimTdlsNegativeBehavior = 0;
284#endif
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800285#endif
286 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800287
288 return ;
289}
Kiran V1ccee932012-12-12 14:49:46 -0800290#ifdef FEATURE_WLAN_TDLS_NEGATIVE
291void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
292{
293 if(on) {
294 if(value == 255)
295 pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
296 else
297 pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
298 }
299 else {
300 if(value == 255)
301 pMac->lim.gLimTdlsNegativeBehavior = 0;
302 else
303 pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
304 }
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800305 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 -0800306 value, on, pMac->lim.gLimTdlsNegativeBehavior));
307}
308#endif
309#if 0
310/*
311 * This function is used for creating TDLS public Action frame to
312 * transmit on Direct link
313 */
314static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
315 tANI_U8 type, tANI_U8 subType,
316 tANI_U8 *link_iden )
317{
318 tpSirMacMgmtHdr pMacHdr ;
319 tANI_U8 *bssid = link_iden ;
320#if 0
321 tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
322 tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
323#else
324 tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
325 tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
326#endif
327 tANI_U8 toDs = ANI_TXDIR_IBSS ;
328
329 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
330
331 /*
332 * prepare 802.11 header
333 */
334 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
335 pMacHdr->fc.type = type ;
336 pMacHdr->fc.subType = subType ;
337 /*
338 * TL is not setting up below fields, so we are doing it here
339 */
340 pMacHdr->fc.toDS = toDs ;
341 pMacHdr->fc.powerMgmt = 0 ;
342
343
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530344 vos_mem_copy( (tANI_U8 *) pMacHdr->da, peerMac, sizeof( tSirMacAddr ));
345 vos_mem_copy( (tANI_U8 *) pMacHdr->sa,
Kiran V1ccee932012-12-12 14:49:46 -0800346 staMac, sizeof( tSirMacAddr ));
347
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530348 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Kiran V1ccee932012-12-12 14:49:46 -0800349 bssid, sizeof( tSirMacAddr ));
350
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800351 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"),
352 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5],
353 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5],
354 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2],
Kiran V1ccee932012-12-12 14:49:46 -0800355 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
356
357 return ;
358}
359#endif
360/*
361 * prepare TDLS frame header, it includes
362 * | | | |
363 * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
364 * | | | |
365 */
366static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530367 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType,
368 tANI_U8 tid, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800369{
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530370 tpSirMacDataHdr3a pMacHdr ;
Kiran V1ccee932012-12-12 14:49:46 -0800371 tANI_U32 header_offset = 0 ;
372 tANI_U8 *addr1 = NULL ;
373 tANI_U8 *addr3 = NULL ;
374 tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP)
375 ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ;
376 tANI_U8 *peerMac = (reqType == TDLS_INITIATOR)
377 ? link_iden->RespStaAddr : link_iden->InitStaAddr;
378 tANI_U8 *staMac = (reqType == TDLS_INITIATOR)
379 ? link_iden->InitStaAddr : link_iden->RespStaAddr;
380
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530381 pMacHdr = (tpSirMacDataHdr3a) (pFrame);
Kiran V1ccee932012-12-12 14:49:46 -0800382
383 /*
384 * if TDLS frame goes through the AP link, it follows normal address
385 * pattern, if TDLS frame goes thorugh the direct link, then
386 * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
387 */
388 (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
389 (addr3 = (peerMac)))
390 : ((addr1 = (peerMac)),
391 (addr3 = (link_iden->bssid))) ;
392 /*
393 * prepare 802.11 header
394 */
395 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
396 pMacHdr->fc.type = SIR_MAC_DATA_FRAME ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530397 pMacHdr->fc.subType = IS_QOS_ENABLED(psessionEntry) ? SIR_MAC_DATA_QOS_DATA : SIR_MAC_DATA_DATA;
398
Kiran V1ccee932012-12-12 14:49:46 -0800399 /*
400 * TL is not setting up below fields, so we are doing it here
401 */
402 pMacHdr->fc.toDS = toDs ;
403 pMacHdr->fc.powerMgmt = 0 ;
404 pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
405
406
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530407 vos_mem_copy( (tANI_U8 *) pMacHdr->addr1,
408 (tANI_U8 *)addr1,
409 sizeof( tSirMacAddr ));
410 vos_mem_copy( (tANI_U8 *) pMacHdr->addr2,
411 (tANI_U8 *) staMac,
412 sizeof( tSirMacAddr ));
Kiran V1ccee932012-12-12 14:49:46 -0800413
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530414 vos_mem_copy( (tANI_U8 *) pMacHdr->addr3,
415 (tANI_U8 *) (addr3),
416 sizeof( tSirMacAddr ));
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530417
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800418 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"),
419 (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD",
420 pMacHdr->addr1[0], pMacHdr->addr1[1], pMacHdr->addr1[2], pMacHdr->addr1[3], pMacHdr->addr1[4], pMacHdr->addr1[5],
421 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 +0530422 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 -0800423
424 //printMacAddr(pMacHdr->bssId) ;
425 //printMacAddr(pMacHdr->sa) ;
426 //printMacAddr(pMacHdr->da) ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530427
428 if (IS_QOS_ENABLED(psessionEntry))
429 {
430 pMacHdr->qosControl.tid = tid;
431 header_offset += sizeof(tSirMacDataHdr3a);
432 }
433 else
434 header_offset += sizeof(tSirMacMgmtHdr);
435
Kiran V1ccee932012-12-12 14:49:46 -0800436 /*
437 * Now form RFC1042 header
438 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530439 vos_mem_copy((tANI_U8 *)(pFrame + header_offset),
440 (tANI_U8 *)eth_890d_header, sizeof(eth_890d_header)) ;
Kiran V1ccee932012-12-12 14:49:46 -0800441
442 header_offset += sizeof(eth_890d_header) ;
443
444 /* add payload type as TDLS */
445 *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
446
447 return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ;
448}
449
450/*
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800451 * TX Complete for Management frames
452 */
453 eHalStatus limMgmtTXComplete(tpAniSirGlobal pMac,
454 tANI_U32 txCompleteSuccess)
455{
456 tpPESession psessionEntry = NULL ;
457
458 if (0xff != pMac->lim.mgmtFrameSessionId)
459 {
460 psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.mgmtFrameSessionId);
461 if (NULL == psessionEntry)
462 {
463 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
464 ("%s: sessionID %d is not found"), __func__, pMac->lim.mgmtFrameSessionId);
465 return eHAL_STATUS_FAILURE;
466 }
467 limSendSmeMgmtTXCompletion(pMac, psessionEntry, txCompleteSuccess);
468 pMac->lim.mgmtFrameSessionId = 0xff;
469 }
470 return eHAL_STATUS_SUCCESS;
471}
472
473/*
Kiran V1ccee932012-12-12 14:49:46 -0800474 * This function can be used for bacst or unicast discovery request
475 * We are not differentiating it here, it will all depnds on peer MAC address,
476 */
477tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
478 tANI_U8 dialog, tpPESession psessionEntry)
479{
480 tDot11fTDLSDisReq tdlsDisReq ;
481 tANI_U32 status = 0 ;
482 tANI_U32 nPayload = 0 ;
483 tANI_U32 size = 0 ;
484 tANI_U32 nBytes = 0 ;
485 tANI_U32 header_offset = 0 ;
486 tANI_U8 *pFrame;
487 void *pPacket;
488 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800489#ifndef NO_PAD_TDLS_MIN_8023_SIZE
490 tANI_U32 padLen = 0;
491#endif
Kiran V1ccee932012-12-12 14:49:46 -0800492
493 /*
494 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
495 * and then hand it off to 'dot11fPackProbeRequest' (for
496 * serialization). We start by zero-initializing the structure:
497 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530498 vos_mem_set( (tANI_U8*)&tdlsDisReq,
499 sizeof( tDot11fTDLSDisReq ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800500
501 /*
502 * setup Fixed fields,
503 */
504 tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
505 tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ;
506 tdlsDisReq.DialogToken.token = dialog ;
507
508
509 size = sizeof(tSirMacAddr) ;
510
511 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier,
512 peer_mac, TDLS_INITIATOR) ;
513
514 /*
515 * now we pack it. First, how much space are we going to need?
516 */
517 status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
518 if ( DOT11F_FAILED( status ) )
519 {
520 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700521 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800522 /* We'll fall back on the worst case scenario: */
523 nPayload = sizeof( tDot11fTDLSDisReq );
524 }
525 else if ( DOT11F_WARNED( status ) )
526 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800527 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -0800528 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700529 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800530 }
531
532 /*
533 * This frame is going out from PE as data frames with special ethertype
534 * 89-0d.
535 * 8 bytes of RFC 1042 header
536 */
537
538
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530539 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
540 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
541 + sizeof( eth_890d_header )
542 + PAYLOAD_TYPE_TDLS_SIZE ;
Kiran V1ccee932012-12-12 14:49:46 -0800543
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800544#ifndef NO_PAD_TDLS_MIN_8023_SIZE
545 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
546 Hence AP itself padding some bytes, which caused teardown packet is dropped at
547 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
548 */
549 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
550 {
551 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
552
553 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
554 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
555 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
556
557 nBytes += padLen;
558 }
559#endif
560
Kiran V1ccee932012-12-12 14:49:46 -0800561 /* Ok-- try to allocate memory from MGMT PKT pool */
562
563 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
564 ( tANI_U16 )nBytes, ( void** ) &pFrame,
565 ( void** ) &pPacket );
566 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
567 {
568 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700569 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -0800570 return eSIR_MEM_ALLOC_FAILED;
571 }
572
573 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530574 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800575
576 /*
577 * IE formation, memory allocation is completed, Now form TDLS discovery
578 * request frame
579 */
580
581 /* fill out the buffer descriptor */
582
583 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530584 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800585
586#ifdef FEATURE_WLAN_TDLS_NEGATIVE
587 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
588 {
589 tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
590 tdlsDisReq.LinkIdentifier.bssid[5] = 0xad;
591 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800592 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Req"),
593 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800594 }
595#endif
596 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
597 + header_offset, nPayload, &nPayload );
598
599 if ( DOT11F_FAILED( status ) )
600 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800601 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
602 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800603 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
604 ( void* ) pFrame, ( void* ) pPacket );
605 return eSIR_FAILURE;
606 }
607 else if ( DOT11F_WARNED( status ) )
608 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800609 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
610 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800611 }
612
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800613#ifndef NO_PAD_TDLS_MIN_8023_SIZE
614 if (padLen != 0)
615 {
616 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
617 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload;
618 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
619 padVendorSpecific[0] = 221;
620 padVendorSpecific[1] = padLen - 2;
621 padVendorSpecific[2] = 0x00;
622 padVendorSpecific[3] = 0xA0;
623 padVendorSpecific[4] = 0xC6;
624
625 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
626 padLen ));
627
628 /* padding zero if more than 5 bytes are required */
629 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530630 vos_mem_set( pFrame + header_offset + nPayload + MIN_VENDOR_SPECIFIC_IE_SIZE,
631 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800632 }
633#endif
Kiran V1ccee932012-12-12 14:49:46 -0800634
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800635 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 -0800636 SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) ));
637
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800638 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -0800639 HAL_TXRX_FRM_802_11_DATA,
640 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530641 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800642 limTxComplete, pFrame,
643 limMgmtTXComplete,
644 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME);
Kiran V1ccee932012-12-12 14:49:46 -0800645 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
646 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800647 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700648 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -0800649 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -0800650 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800651 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -0800652
653 return eSIR_SUCCESS;
654
655}
656
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800657#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800658/*
659 * Once Discovery response is sent successfully (or failure) on air, now send
660 * response to PE and send del STA to HAL.
661 */
662eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac,
663 tANI_U32 txCompleteSuccess)
664{
665 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800666 tpDphHashNode pStaDs = NULL ;
667 tSirTdlsPeerInfo *peerInfo = 0 ;
668
669 /* find peer by looking into the list by expected state */
670 peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ;
671
672 if(NULL == peerInfo)
673 {
674 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700675 ("DisRspTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800676 VOS_ASSERT(0) ;
677 return eHAL_STATUS_FAILURE;
678 }
679
680 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ;
681
682 if(peerInfo->delStaNeeded)
683 {
684 tpPESession psessionEntry;
685
686 peerInfo->delStaNeeded = false ;
687 psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId);
688
689 if(NULL == psessionEntry)
690 {
691 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700692 ("DisRspTxComplete: sessionID %d is not found"), peerInfo->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800693 return eHAL_STATUS_FAILURE;
694 }
695 /* send del STA to remove context for this TDLS STA */
696 pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ;
697
698 /* now send indication to SME-->HDD->TL to remove STA from TL */
699 if(pStaDs)
700 {
701 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
702 pStaDs, eSIR_SUCCESS) ;
703 }
704 else
705 {
706 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800707 ("DisRspTxComplete: staDs not found for " MAC_ADDRESS_STR),
708 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800709 VOS_ASSERT(0) ;
710 return eHAL_STATUS_FAILURE;
711 }
712 }
713
714 if(!txCompleteSuccess)
715 {
716 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
717 ("TX complete failure for Dis RSP"));
718 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
719 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
720 status = eHAL_STATUS_FAILURE;
721 }
722 else
723 {
724 limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS,
725 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
726 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
727 ("TX complete Success for Dis RSP"));
728 status = eHAL_STATUS_SUCCESS ;
729 }
730 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800731 return status ;
732
733}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800734#endif
735
736#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800737/*
738 * Once setup CNF is sent successfully (or failure) on air, now send
739 * response to PE and send del STA to HAL.
740 */
741eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
742 tANI_U32 txCompleteSuccess)
743{
744 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800745 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
746 /* find peer by looking into the list by expected state */
747 limTdlsFindSetupPeerByState(pMac,
748 TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ;
749
750 if(NULL == peerInfo)
751 {
752 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700753 ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800754 VOS_ASSERT(0) ;
755 return eHAL_STATUS_FAILURE;
756 }
757
758 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
759 (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
760
761 if(!txCompleteSuccess)
762 {
763 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
764 ("TX complete Failure for setup CNF"));
765 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac,
766 eWNI_SME_TDLS_LINK_START_RSP) ;
767 status = eHAL_STATUS_FAILURE;
768 }
769 else
770 {
771 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800772 ("RSP-->SME peer MAC = " MAC_ADDRESS_STR),
773 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800774
775 limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
776 eWNI_SME_TDLS_LINK_START_RSP) ;
777
778 /* tdls_hklee: prepare PTI template and send it to HAL */
779 limTdlsLinkEstablish(pMac, (peerInfo)->peerMac);
780
781 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
782 ("TX complete Success for setup CNF"));
783 status = eHAL_STATUS_SUCCESS ;
784 }
785 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800786 return status ;
Kiran V1ccee932012-12-12 14:49:46 -0800787}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800788#endif
Kiran V1ccee932012-12-12 14:49:46 -0800789
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800790#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800791/*
792 * Tx Complete for Teardown frame
793 */
794eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
795 tANI_U32 txCompleteSuccess)
796{
797 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800798 tpDphHashNode pStaDs = NULL ;
799 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
800 tpPESession psessionEntry = NULL ;
801 //tANI_U16 msgType = 0 ;
802
803 //tSirMacAddr peerMac = {0} ;
804 /* find peer by looking into the list by expected state */
805 limTdlsFindSetupPeerByState(pMac,
806 TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ;
807
808 if(NULL == peerInfo)
809 {
810 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700811 ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800812 VOS_ASSERT(0) ;
813 return eHAL_STATUS_FAILURE;
814 }
815
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530816 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800817 ("teardown peer Mac = " MAC_ADDRESS_STR),
818 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800819
820
821 //pMac->hal.pCBackFnTxComp = NULL ;
822
823 psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId);
824
825 if(NULL == psessionEntry)
826 {
827 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700828 ("limTdlsTeardownTxComplete: sessionID %d is not found"), (peerInfo)->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800829 VOS_ASSERT(0) ;
830 return eHAL_STATUS_FAILURE;
831 }
832
833 if(!txCompleteSuccess)
834 {
835 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700836 ("TX complete failure for Teardown ")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800837
838 /*
839 * we should be sending Teradown to AP with status code
840 * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if
841 * that is delivered or not, any way we removing this peer STA from our
842 * list
843 */
844 if(NULL != psessionEntry)
845 {
846 limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac,
847 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ;
848 }
849 }
850
851 if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state)
852 {
853 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
854 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
855 /* send del STA to remove context for this TDLS STA */
856 if(NULL != psessionEntry)
857 {
858 /* tdls_hklee: send message to HAL before it is deleted */
859 limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ;
860
861 pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ;
862 }
863
864 /* now send indication to SME-->HDD->TL to remove STA from TL */
865 if(!pStaDs)
866 {
867 VOS_ASSERT(0) ;
868 return eSIR_FAILURE ;
869 }
870 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
871 pStaDs, eSIR_SUCCESS) ;
872
873 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700874 ("TX complete SUCCESS for Teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800875 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700876 ("Prev State = %d"), (peerInfo)->tdls_prev_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -0800877 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
878 eWNI_SME_TDLS_TEARDOWN_RSP) ;
879 /* Delete Peer for Link Peer List */
880 limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ;
881 }
882 else
883 {
884 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
885 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
886 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
887 eWNI_SME_TDLS_TEARDOWN_IND) ;
888 }
889
890
891#if 0
892 /* if previous state is link restart, then restart link setup again */
893 if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state)
894 {
895 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
896 limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37,
897 peerMac, psessionEntry) ;
898 }
899#endif
900 status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800901 return status ;
902}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800903#endif
Kiran V1ccee932012-12-12 14:49:46 -0800904
905/*
Kiet Lam770920c2013-10-21 12:49:30 +0530906 * This static function is consistent with any kind of TDLS management
907 * frames we are sending. Currently it is being used by limSendTdlsDisRspFrame,
908 * limSendTdlsLinkSetupReqFrame and limSendTdlsSetupRspFrame
909 */
910static void PopulateDot11fTdlsHtVhtCap(tpAniSirGlobal pMac, uint32 selfDot11Mode,
911 tDot11fIEHTCaps *htCap, tDot11fIEVHTCaps *vhtCap,
912 tpPESession psessionEntry)
913{
914 if (IS_DOT11_MODE_HT(selfDot11Mode))
915 {
916 /* Include HT Capability IE */
917 PopulateDot11fHTCaps( pMac, NULL, htCap );
918 htCap->present = 1;
919 if (psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END)
920 {
921 /* hardcode NO channel bonding in 2.4Ghz */
922 htCap->supportedChannelWidthSet = 0;
923 }
924 else
925 {
926 //Placeholder to support different channel bonding mode of TDLS than AP.
927 //wlan_cfgGetInt(pMac,WNI_CFG_TDLS_CHANNEL_BONDING_MODE,&tdlsChannelBondingMode);
928 //htCap->supportedChannelWidthSet = tdlsChannelBondingMode ? 1 : 0;
929 htCap->supportedChannelWidthSet = 1; // hardcode it to max
930 }
931 }
932 else
933 {
934 htCap->present = 0;
935 }
936#ifdef WLAN_FEATURE_11AC
937 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
938 pMac->roam.configParam.enableVhtFor24GHz) ||
939 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
940 {
941 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
942 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
943 {
944 /* Include VHT Capability IE */
945 PopulateDot11fVHTCaps( pMac, vhtCap );
946 }
947 else
948 {
949 vhtCap->present = 0;
950 }
951 }
952 else
953 {
954 /* Vht Disable from ini in 2.4 GHz */
955 vhtCap->present = 0;
956 }
957#endif
958}
959
960/*
Kiran V1ccee932012-12-12 14:49:46 -0800961 * Send TDLS discovery response frame on direct link.
962 */
963
964static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
965 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry)
966{
967 tDot11fTDLSDisRsp tdlsDisRsp ;
968 tANI_U16 caps = 0 ;
969 tANI_U32 status = 0 ;
970 tANI_U32 nPayload = 0 ;
971 tANI_U32 nBytes = 0 ;
972 tANI_U8 *pFrame;
973 void *pPacket;
974 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -0700975 uint32 selfDot11Mode;
976// Placeholder to support different channel bonding mode of TDLS than AP.
977// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
978// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
979// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
980// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -0800981
982 /*
983 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
984 * and then hand it off to 'dot11fPackProbeRequest' (for
985 * serialization). We start by zero-initializing the structure:
986 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530987 vos_mem_set( ( tANI_U8* )&tdlsDisRsp,
988 sizeof( tDot11fTDLSDisRsp ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800989
990 /*
991 * setup Fixed fields,
992 */
993 tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
994 tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ;
995 tdlsDisRsp.DialogToken.token = dialog ;
996
997 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
998 peerMac, TDLS_RESPONDER) ;
999
1000 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1001 {
1002 /*
1003 * Could not get Capabilities value
1004 * from CFG. Log error.
1005 */
1006 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001007 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001008 }
1009 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
1010
1011 /* populate supported rate IE */
1012 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1013 &tdlsDisRsp.SuppRates, psessionEntry );
1014
1015 /* Populate extended supported rates */
1016 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1017 &tdlsDisRsp.ExtSuppRates, psessionEntry );
1018
1019 /* Populate extended supported rates */
1020 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
1021
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001022 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1023
Kiet Lam770920c2013-10-21 12:49:30 +05301024 /* Populate HT/VHT Capabilities */
1025 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsDisRsp.HTCaps,
1026 &tdlsDisRsp.VHTCaps, psessionEntry );
Kiran V1ccee932012-12-12 14:49:46 -08001027
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301028 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1029 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1030 &tdlsDisRsp.SuppChannels,
1031 &tdlsDisRsp.SuppOperatingClasses);
Kiran V1ccee932012-12-12 14:49:46 -08001032 /*
1033 * now we pack it. First, how much space are we going to need?
1034 */
1035 status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
1036 if ( DOT11F_FAILED( status ) )
1037 {
1038 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001039 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001040 /* We'll fall back on the worst case scenario: */
1041 nPayload = sizeof( tDot11fProbeRequest );
1042 }
1043 else if ( DOT11F_WARNED( status ) )
1044 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001045 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001046 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001047 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001048 }
1049
1050 /*
1051 * This frame is going out from PE as data frames with special ethertype
1052 * 89-0d.
1053 * 8 bytes of RFC 1042 header
1054 */
1055
1056
1057 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ;
1058
1059 /* Ok-- try to allocate memory from MGMT PKT pool */
1060
1061 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1062 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1063 ( void** ) &pPacket );
1064 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1065 {
1066 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001067 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001068 return eSIR_MEM_ALLOC_FAILED;
1069 }
1070
1071 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301072 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001073
1074 /*
1075 * IE formation, memory allocation is completed, Now form TDLS discovery
1076 * response frame
1077 */
1078
1079 /* Make public Action Frame */
1080
1081#if 0
1082 limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1083 SIR_MAC_MGMT_ACTION,
1084 LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
1085#endif
1086 limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1087 SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
1088
1089 {
1090 tpSirMacMgmtHdr pMacHdr;
1091 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1092 pMacHdr->fc.toDS = ANI_TXDIR_IBSS;
1093 pMacHdr->fc.powerMgmt = 0 ;
1094 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1095 }
1096
1097#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1098 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
1099 {
1100 tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
1101 tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad;
1102 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001103 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Rsp"),
1104 MAC_ADDR_ARRAY(tdlsDisRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001105 }
1106#endif
1107 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
1108 sizeof( tSirMacMgmtHdr ),
1109 nPayload, &nPayload );
1110
1111 if ( DOT11F_FAILED( status ) )
1112 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001113 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1114 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001115 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1116 ( void* ) pFrame, ( void* ) pPacket );
1117 return eSIR_FAILURE;
1118 }
1119 else if ( DOT11F_WARNED( status ) )
1120 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001121 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1122 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001123 }
1124
1125#if 0
1126 if(pMac->hal.pCBackFnTxComp == NULL)
1127 {
1128 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
1129
1130 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
1131 {
1132 status = eHAL_STATUS_FAILURE;
1133 return status;
1134
1135 }
1136 }
1137#endif
1138 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001139 ("transmitting Discovery response on direct link")) ;
Kiran V1ccee932012-12-12 14:49:46 -08001140
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001141 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 -08001142 SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) ));
1143
1144
1145 /*
1146 * Transmit Discovery response and watch if this is delivered to
1147 * peer STA.
1148 */
1149 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1150 HAL_TXRX_FRM_802_11_DATA,
1151 ANI_TXDIR_IBSS,
1152 0,
1153 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001154 limMgmtTXComplete,
Kiran V1ccee932012-12-12 14:49:46 -08001155 HAL_USE_SELF_STA_REQUESTED_MASK );
1156 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1157 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001158 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001159 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001160 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001161 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001162 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001163
1164 return eSIR_SUCCESS;
1165
1166}
1167
1168/*
Kiet Lam770920c2013-10-21 12:49:30 +05301169 * This static function is currently used by limSendTdlsLinkSetupReqFrame and
1170 * limSendTdlsSetupRspFrame to populate the AID if device is 11ac capable.
1171 */
1172static void PopulateDotfTdlsVhtAID(tpAniSirGlobal pMac, uint32 selfDot11Mode,
1173 tSirMacAddr peerMac, tDot11fIEAID *Aid,
1174 tpPESession psessionEntry)
1175{
1176 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
1177 pMac->roam.configParam.enableVhtFor24GHz) ||
1178 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
1179 {
1180 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1181 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1182 {
1183
1184 tANI_U16 aid;
1185 tpDphHashNode pStaDs;
1186
1187 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
1188 if (NULL != pStaDs)
1189 {
1190 Aid->present = 1;
1191 Aid->assocId = aid | LIM_AID_MASK; // set bit 14 and 15 1's
1192 }
1193 else
1194 {
1195 Aid->present = 0;
1196 limLog( pMac, LOGE, FL("pStaDs is NULL for " MAC_ADDRESS_STR ),
1197 MAC_ADDR_ARRAY(peerMac));
1198 }
1199 }
1200 }
1201 else
1202 {
1203 Aid->present = 0;
1204 limLog( pMac, LOGW, FL("Vht not enable from ini for 2.4GHz."));
1205 }
1206}
1207
1208/*
Kiran V1ccee932012-12-12 14:49:46 -08001209 * TDLS setup Request frame on AP link
1210 */
1211
1212tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1213 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301214 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001215{
1216 tDot11fTDLSSetupReq tdlsSetupReq ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301217 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001218 tANI_U32 status = 0 ;
1219 tANI_U32 nPayload = 0 ;
1220 tANI_U32 nBytes = 0 ;
1221 tANI_U32 header_offset = 0 ;
1222 tANI_U8 *pFrame;
1223 void *pPacket;
1224 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001225 uint32 selfDot11Mode;
1226// Placeholder to support different channel bonding mode of TDLS than AP.
1227// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1228// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1229// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1230// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001231
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301232 /*
Kiran V1ccee932012-12-12 14:49:46 -08001233 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1234 * and then hand it off to 'dot11fPackProbeRequest' (for
1235 * serialization). We start by zero-initializing the structure:
1236 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301237 vos_mem_set(( tANI_U8* )&tdlsSetupReq, sizeof( tDot11fTDLSSetupReq ), 0);
Kiran V1ccee932012-12-12 14:49:46 -08001238 tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
1239 tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ;
1240 tdlsSetupReq.DialogToken.token = dialog ;
1241
1242
1243 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
1244 peerMac, TDLS_INITIATOR) ;
1245
1246 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1247 {
1248 /*
1249 * Could not get Capabilities value
1250 * from CFG. Log error.
1251 */
1252 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001253 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001254 }
1255 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1256
1257 /* populate supported rate IE */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301258 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Kiran V1ccee932012-12-12 14:49:46 -08001259 &tdlsSetupReq.SuppRates, psessionEntry );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301260
Kiran V1ccee932012-12-12 14:49:46 -08001261 /* Populate extended supported rates */
1262 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1263 &tdlsSetupReq.ExtSuppRates, psessionEntry );
1264
1265 /* Populate extended supported rates */
1266 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1267
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301268 /*
Kiran V1ccee932012-12-12 14:49:46 -08001269 * TODO: we need to see if we have to support conditions where we have
1270 * EDCA parameter info element is needed a) if we need different QOS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301271 * parameters for off channel operations or QOS is not supported on
Kiran V1ccee932012-12-12 14:49:46 -08001272 * AP link and we wanted to QOS on direct link.
1273 */
1274 /* Populate QOS info, needed for Peer U-APSD session */
1275 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1276 TDLS doesn't want to depend on AP's capability */
1277 tdlsSetupReq.QOSCapsStation.present = 1;
1278 tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
1279 tdlsSetupReq.QOSCapsStation.qack = 0;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301280 tdlsSetupReq.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3) ;
1281 tdlsSetupReq.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04)>> 2);
1282 tdlsSetupReq.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02)>> 1);
1283 tdlsSetupReq.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1284
Kiran V1ccee932012-12-12 14:49:46 -08001285
1286 /*
1287 * we will always try to init TDLS link with 11n capabilities
1288 * let TDLS setup response to come, and we will set our caps based
1289 * of peer caps
1290 */
1291
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001292 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1293
Kiet Lam770920c2013-10-21 12:49:30 +05301294 /* Populate HT/VHT Capabilities */
1295 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupReq.HTCaps,
1296 &tdlsSetupReq.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001297
Kiet Lam770920c2013-10-21 12:49:30 +05301298 /* Populate AID */
1299 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1300 &tdlsSetupReq.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001301
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301302 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1303 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1304 &tdlsSetupReq.SuppChannels,
1305 &tdlsSetupReq.SuppOperatingClasses);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301306 /*
Kiran V1ccee932012-12-12 14:49:46 -08001307 * now we pack it. First, how much space are we going to need?
1308 */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301309 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
Kiran V1ccee932012-12-12 14:49:46 -08001310 &nPayload);
1311 if ( DOT11F_FAILED( status ) )
1312 {
1313 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001314 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001315 /* We'll fall back on the worst case scenario: */
1316 nPayload = sizeof( tDot11fProbeRequest );
1317 }
1318 else if ( DOT11F_WARNED( status ) )
1319 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001320 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001321 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001322 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001323 }
1324
1325
1326 /*
1327 * This frame is going out from PE as data frames with special ethertype
1328 * 89-0d.
1329 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301330 */
Kiran V1ccee932012-12-12 14:49:46 -08001331
1332
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301333 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1334 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1335 + sizeof( eth_890d_header )
1336 + PAYLOAD_TYPE_TDLS_SIZE
1337 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001338
1339 /* Ok-- try to allocate memory from MGMT PKT pool */
1340
1341 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301342 ( tANI_U16 )nBytes, ( void** ) &pFrame,
Kiran V1ccee932012-12-12 14:49:46 -08001343 ( void** ) &pPacket );
1344 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1345 {
1346 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001347 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001348 return eSIR_MEM_ALLOC_FAILED;
1349 }
1350
1351 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301352 vos_mem_set( pFrame, nBytes, 0);
Kiran V1ccee932012-12-12 14:49:46 -08001353
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301354 /*
Kiran V1ccee932012-12-12 14:49:46 -08001355 * IE formation, memory allocation is completed, Now form TDLS discovery
1356 * request frame
1357 */
1358
1359 /* fill out the buffer descriptor */
1360
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301361 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301362 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001363
1364#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1365 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
1366 {
1367 tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301368 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1369 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001370 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Req"),
1371 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001372 }
1373#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001374 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1375 __func__, tdlsSetupReq.VHTCaps.supportedChannelWidthSet, tdlsSetupReq.VHTCaps.rxMCSMap,
1376 tdlsSetupReq.VHTCaps.txMCSMap, tdlsSetupReq.VHTCaps.txSupDataRate );
1377
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301378 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001379 + header_offset, nPayload, &nPayload );
1380
1381 if ( DOT11F_FAILED( status ) )
1382 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001383 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1384 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001385 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1386 ( void* ) pFrame, ( void* ) pPacket );
1387 return eSIR_FAILURE;
1388 }
1389 else if ( DOT11F_WARNED( status ) )
1390 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001391 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1392 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001393 }
1394
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301395 //Copy the additional IE.
Kiran V1ccee932012-12-12 14:49:46 -08001396 //TODO : addIe is added at the end of the frame. This means it doesnt
1397 //follow the order. This should be ok, but we should consider changing this
1398 //if there is any IOT issue.
1399 if( addIeLen != 0 )
1400 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001401 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 -08001402 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301403 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001404 }
1405
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001406 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 -08001407 SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) ));
1408
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001409 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001410 HAL_TXRX_FRM_802_11_DATA,
1411 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301412 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001413 limTxComplete, pFrame,
1414 limMgmtTXComplete,
1415 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
1416
Kiran V1ccee932012-12-12 14:49:46 -08001417 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1418 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001419 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001420 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001421 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001422 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001423 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001424
1425 return eSIR_SUCCESS;
1426
1427}
1428/*
1429 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1430 */
1431
1432tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08001433 tSirMacAddr peerMac, tANI_U16 reason, tANI_U8 responder, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301434 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001435{
1436 tDot11fTDLSTeardown teardown ;
1437 tANI_U32 status = 0 ;
1438 tANI_U32 nPayload = 0 ;
1439 tANI_U32 nBytes = 0 ;
1440 tANI_U32 header_offset = 0 ;
1441 tANI_U8 *pFrame;
1442 void *pPacket;
1443 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001444#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1445 tANI_U32 padLen = 0;
1446#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301447 /*
Kiran V1ccee932012-12-12 14:49:46 -08001448 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1449 * and then hand it off to 'dot11fPackProbeRequest' (for
1450 * serialization). We start by zero-initializing the structure:
1451 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301452 vos_mem_set( ( tANI_U8* )&teardown, sizeof( tDot11fTDLSTeardown ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001453 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1454 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1455 teardown.Reason.code = reason ;
1456
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301457 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
Hoonki Leea34dd892013-02-05 22:56:02 -08001458 peerMac, (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR) ;
Kiran V1ccee932012-12-12 14:49:46 -08001459
1460
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301461 /*
Kiran V1ccee932012-12-12 14:49:46 -08001462 * now we pack it. First, how much space are we going to need?
1463 */
1464 status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
1465 if ( DOT11F_FAILED( status ) )
1466 {
1467 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001468 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001469 /* We'll fall back on the worst case scenario: */
1470 nPayload = sizeof( tDot11fProbeRequest );
1471 }
1472 else if ( DOT11F_WARNED( status ) )
1473 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001474 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001475 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001476 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001477 }
1478
1479
1480 /*
1481 * This frame is going out from PE as data frames with special ethertype
1482 * 89-0d.
1483 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301484 */
Kiran V1ccee932012-12-12 14:49:46 -08001485
1486
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301487 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1488 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1489 + sizeof( eth_890d_header )
1490 + PAYLOAD_TYPE_TDLS_SIZE
1491 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001492
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001493#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1494 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1495 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1496 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1497 */
1498 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1499 {
1500 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1501
1502 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1503 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1504 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1505
1506 nBytes += padLen;
1507 }
1508#endif
1509
Kiran V1ccee932012-12-12 14:49:46 -08001510 /* Ok-- try to allocate memory from MGMT PKT pool */
1511
1512 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1513 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1514 ( void** ) &pPacket );
1515 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1516 {
1517 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001518 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001519 return eSIR_MEM_ALLOC_FAILED;
1520 }
1521
1522 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301523 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001524
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301525 /*
Kiran V1ccee932012-12-12 14:49:46 -08001526 * IE formation, memory allocation is completed, Now form TDLS discovery
1527 * request frame
1528 */
1529
1530 /* fill out the buffer descriptor */
1531
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301532 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1533 LINK_IDEN_ADDR_OFFSET(teardown),
1534 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
Gopichand Nakkala269032c2013-02-07 17:18:15 -08001535 ? TDLS_LINK_AP : TDLS_LINK_DIRECT,
1536 (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301537 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001538
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301539 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001540 + header_offset, nPayload, &nPayload );
1541
1542 if ( DOT11F_FAILED( status ) )
1543 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001544 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req (0x%08x)."),
1545 status );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301546 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Kiran V1ccee932012-12-12 14:49:46 -08001547 ( void* ) pFrame, ( void* ) pPacket );
1548 return eSIR_FAILURE;
1549 }
1550 else if ( DOT11F_WARNED( status ) )
1551 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001552 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1553 "Teardown Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001554 }
1555#if 0
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301556 if(pMac->hal.pCBackFnTxComp == NULL)
Kiran V1ccee932012-12-12 14:49:46 -08001557 {
1558 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301559 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
Kiran V1ccee932012-12-12 14:49:46 -08001560 {
1561 status = eHAL_STATUS_FAILURE;
1562 return status;
1563
1564 }
1565 }
1566 else
1567 {
1568 VOS_ASSERT(0) ;
1569 return status ;
1570 }
1571#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301572
Kiran V1ccee932012-12-12 14:49:46 -08001573 if( addIeLen != 0 )
1574 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001575 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 -08001576 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301577 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001578 }
1579
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001580#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1581 if (padLen != 0)
1582 {
1583 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
1584 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
1585 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
1586 padVendorSpecific[0] = 221;
1587 padVendorSpecific[1] = padLen - 2;
1588 padVendorSpecific[2] = 0x00;
1589 padVendorSpecific[3] = 0xA0;
1590 padVendorSpecific[4] = 0xC6;
1591
1592 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
1593 padLen ));
1594
1595 /* padding zero if more than 5 bytes are required */
1596 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301597 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
1598 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001599 }
1600#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001601 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -%s-> OTA"),
1602 SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN),
1603 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ? "AP": "DIRECT" ));
Kiran V1ccee932012-12-12 14:49:46 -08001604
1605 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1606 HAL_TXRX_FRM_802_11_DATA,
1607 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301608 TID_AC_VI,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301609 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001610 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08001611 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001612 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1613 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001614 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001615 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001616 return eSIR_FAILURE;
1617
1618 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001619 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001620 return eSIR_SUCCESS;
1621
1622}
1623
1624/*
1625 * Send Setup RSP frame on AP link.
1626 */
1627static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1628 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
1629 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1630{
1631 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1632 tANI_U32 status = 0 ;
1633 tANI_U16 caps = 0 ;
1634 tANI_U32 nPayload = 0 ;
1635 tANI_U32 header_offset = 0 ;
1636 tANI_U32 nBytes = 0 ;
1637 tANI_U8 *pFrame;
1638 void *pPacket;
1639 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001640 uint32 selfDot11Mode;
1641// Placeholder to support different channel bonding mode of TDLS than AP.
1642// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1643// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1644// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1645// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001646
1647 /*
1648 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1649 * and then hand it off to 'dot11fPackProbeRequest' (for
1650 * serialization). We start by zero-initializing the structure:
1651 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301652 vos_mem_set( ( tANI_U8* )&tdlsSetupRsp, sizeof( tDot11fTDLSSetupRsp ),0 );
Kiran V1ccee932012-12-12 14:49:46 -08001653
1654 /*
1655 * setup Fixed fields,
1656 */
1657 tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
1658 tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ;
1659 tdlsSetupRsp.DialogToken.token = dialog;
1660
1661 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
1662 peerMac, TDLS_RESPONDER) ;
1663
1664 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1665 {
1666 /*
1667 * Could not get Capabilities value
1668 * from CFG. Log error.
1669 */
1670 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001671 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001672 }
1673 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1674
1675 /* ipopulate supported rate IE */
1676 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1677 &tdlsSetupRsp.SuppRates, psessionEntry );
1678
1679 /* Populate extended supported rates */
1680 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1681 &tdlsSetupRsp.ExtSuppRates, psessionEntry );
1682
1683 /* Populate extended supported rates */
1684 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1685
1686 /*
1687 * TODO: we need to see if we have to support conditions where we have
1688 * EDCA parameter info element is needed a) if we need different QOS
1689 * parameters for off channel operations or QOS is not supported on
1690 * AP link and we wanted to QOS on direct link.
1691 */
1692 /* Populate QOS info, needed for Peer U-APSD session */
1693 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1694 TDLS doesn't want to depend on AP's capability */
1695 tdlsSetupRsp.QOSCapsStation.present = 1;
1696 tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
1697 tdlsSetupRsp.QOSCapsStation.qack = 0;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301698 tdlsSetupRsp.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1699 tdlsSetupRsp.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1700 tdlsSetupRsp.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1701 tdlsSetupRsp.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
Kiran V1ccee932012-12-12 14:49:46 -08001702
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001703 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1704
Kiet Lam770920c2013-10-21 12:49:30 +05301705 /* Populate HT/VHT Capabilities */
1706 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupRsp.HTCaps,
1707 &tdlsSetupRsp.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001708
Kiet Lam770920c2013-10-21 12:49:30 +05301709 /* Populate AID */
1710 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1711 &tdlsSetupRsp.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001712
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301713 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1714 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1715 &tdlsSetupRsp.SuppChannels,
1716 &tdlsSetupRsp.SuppOperatingClasses);
1717
Kiran V1ccee932012-12-12 14:49:46 -08001718 tdlsSetupRsp.Status.status = setupStatus ;
1719
1720 /*
1721 * now we pack it. First, how much space are we going to need?
1722 */
1723 status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp,
1724 &nPayload);
1725 if ( DOT11F_FAILED( status ) )
1726 {
1727 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001728 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001729 /* We'll fall back on the worst case scenario: */
1730 nPayload = sizeof( tDot11fProbeRequest );
1731 }
1732 else if ( DOT11F_WARNED( status ) )
1733 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001734 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001735 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001736 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001737 }
1738
1739 /*
1740 * This frame is going out from PE as data frames with special ethertype
1741 * 89-0d.
1742 * 8 bytes of RFC 1042 header
1743 */
1744
1745
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301746 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1747 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1748 + sizeof( eth_890d_header )
1749 + PAYLOAD_TYPE_TDLS_SIZE
1750 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001751
1752 /* Ok-- try to allocate memory from MGMT PKT pool */
1753
1754 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1755 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1756 ( void** ) &pPacket );
1757 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1758 {
1759 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001760 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001761 return eSIR_MEM_ALLOC_FAILED;
1762 }
1763
1764 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301765 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001766
1767 /*
1768 * IE formation, memory allocation is completed, Now form TDLS discovery
1769 * request frame
1770 */
1771
1772 /* fill out the buffer descriptor */
1773
1774 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1775 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp),
1776 TDLS_LINK_AP, TDLS_RESPONDER,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301777 TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001778
1779#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1780 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
1781 {
1782 tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
1783 tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad;
1784 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001785 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Rsp"),
1786 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001787 }
1788#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001789 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1790 __func__, tdlsSetupRsp.VHTCaps.supportedChannelWidthSet, tdlsSetupRsp.VHTCaps.rxMCSMap,
1791 tdlsSetupRsp.VHTCaps.txMCSMap, tdlsSetupRsp.VHTCaps.txSupDataRate );
Kiran V1ccee932012-12-12 14:49:46 -08001792 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1793 + header_offset, nPayload, &nPayload );
1794
1795 if ( DOT11F_FAILED( status ) )
1796 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001797 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1798 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001799 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1800 ( void* ) pFrame, ( void* ) pPacket );
1801 return eSIR_FAILURE;
1802 }
1803 else if ( DOT11F_WARNED( status ) )
1804 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001805 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1806 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001807 }
1808
1809 //Copy the additional IE.
1810 //TODO : addIe is added at the end of the frame. This means it doesnt
1811 //follow the order. This should be ok, but we should consider changing this
1812 //if there is any IOT issue.
1813 if( addIeLen != 0 )
1814 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301815 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001816 }
1817
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001818 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 -08001819 SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) ));
1820
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001821 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001822 HAL_TXRX_FRM_802_11_DATA,
1823 ANI_TXDIR_TODS,
1824 //ANI_TXDIR_IBSS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301825 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001826 limTxComplete, pFrame,
1827 limMgmtTXComplete,
1828 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001829 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1830 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001831 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001832 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001833 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001834 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001835 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001836
1837 return eSIR_SUCCESS;
1838
1839}
1840
1841/*
1842 * Send TDLS setup CNF frame on AP link
1843 */
1844
1845tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
1846 tANI_U8 dialog, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
1847{
1848 tDot11fTDLSSetupCnf tdlsSetupCnf ;
1849 tANI_U32 status = 0 ;
1850 tANI_U32 nPayload = 0 ;
1851 tANI_U32 nBytes = 0 ;
1852 tANI_U32 header_offset = 0 ;
1853 tANI_U8 *pFrame;
1854 void *pPacket;
1855 eHalStatus halstatus;
Hoonki Lee426f0302013-02-08 17:35:38 -08001856#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1857 tANI_U32 padLen = 0;
1858#endif
Kiran V1ccee932012-12-12 14:49:46 -08001859
1860 /*
1861 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1862 * and then hand it off to 'dot11fPackProbeRequest' (for
1863 * serialization). We start by zero-initializing the structure:
1864 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301865 vos_mem_set( ( tANI_U8* )&tdlsSetupCnf, sizeof( tDot11fTDLSSetupCnf ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001866
1867 /*
1868 * setup Fixed fields,
1869 */
1870 tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
1871 tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ;
1872 tdlsSetupCnf.DialogToken.token = dialog ;
1873
1874#if 1
1875 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
1876 peerMac, TDLS_INITIATOR) ;
1877#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301878 vos_mem_copy( (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier,
1879 (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ;
Kiran V1ccee932012-12-12 14:49:46 -08001880#endif
1881
1882 /*
1883 * TODO: we need to see if we have to support conditions where we have
1884 * EDCA parameter info element is needed a) if we need different QOS
1885 * parameters for off channel operations or QOS is not supported on
1886 * AP link and we wanted to QOS on direct link.
1887 */
1888
1889 /* Include HT Info IE */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001890 /* Need to also check the Self Capability ??? TODO Sunil */
1891 if ( true == psessionEntry->htCapability)
1892 {
1893 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
1894 }
1895 if ( true == psessionEntry->vhtCapability)
1896 {
1897 PopulateDot11fVHTOperation( pMac, &tdlsSetupCnf.VHTOperation);
1898 }
Kiran V1ccee932012-12-12 14:49:46 -08001899
1900 /*
1901 * now we pack it. First, how much space are we going to need?
1902 */
1903 status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf,
1904 &nPayload);
1905 if ( DOT11F_FAILED( status ) )
1906 {
1907 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001908 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001909 /* We'll fall back on the worst case scenario: */
1910 nPayload = sizeof( tDot11fProbeRequest );
1911 }
1912 else if ( DOT11F_WARNED( status ) )
1913 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001914 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001915 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001916 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001917 }
1918
1919 /*
1920 * This frame is going out from PE as data frames with special ethertype
1921 * 89-0d.
1922 * 8 bytes of RFC 1042 header
1923 */
1924
1925
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301926 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1927 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1928 + sizeof( eth_890d_header )
1929 + PAYLOAD_TYPE_TDLS_SIZE
1930 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001931
Hoonki Lee426f0302013-02-08 17:35:38 -08001932#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1933 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1934 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1935 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1936 */
1937 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1938 {
1939 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1940
1941 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1942 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1943 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1944
1945 nBytes += padLen;
1946 }
1947#endif
1948
1949
Kiran V1ccee932012-12-12 14:49:46 -08001950 /* Ok-- try to allocate memory from MGMT PKT pool */
1951
1952 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1953 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1954 ( void** ) &pPacket );
1955 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1956 {
1957 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001958 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001959 return eSIR_MEM_ALLOC_FAILED;
1960 }
1961
1962 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301963 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001964
1965 /*
1966 * IE formation, memory allocation is completed, Now form TDLS discovery
1967 * request frame
1968 */
1969
1970 /* fill out the buffer descriptor */
1971
1972 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1973 LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301974 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001975
1976#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1977 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
1978 tdlsSetupCnf.StatusCode.statusCode = 37;
1979 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001980 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf"));
Kiran V1ccee932012-12-12 14:49:46 -08001981 }
1982#endif
1983 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
1984 + header_offset, nPayload, &nPayload );
1985
1986 if ( DOT11F_FAILED( status ) )
1987 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001988 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1989 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001990 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1991 ( void* ) pFrame, ( void* ) pPacket );
1992 return eSIR_FAILURE;
1993 }
1994 else if ( DOT11F_WARNED( status ) )
1995 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001996 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1997 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001998 }
1999#if 0
2000 if(pMac->hal.pCBackFnTxComp == NULL)
2001 {
2002 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
2003 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
2004 {
2005 status = eHAL_STATUS_FAILURE;
2006 return status;
2007
2008 }
2009 }
2010 else
2011 {
2012 VOS_ASSERT(0) ;
2013 return status ;
2014 }
2015#endif
2016 //Copy the additional IE.
2017 //TODO : addIe is added at the end of the frame. This means it doesnt
2018 //follow the order. This should be ok, but we should consider changing this
2019 //if there is any IOT issue.
2020 if( addIeLen != 0 )
2021 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302022 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08002023 }
2024
Hoonki Lee426f0302013-02-08 17:35:38 -08002025#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2026 if (padLen != 0)
2027 {
2028 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
2029 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
2030 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
2031 padVendorSpecific[0] = 221;
2032 padVendorSpecific[1] = padLen - 2;
2033 padVendorSpecific[2] = 0x00;
2034 padVendorSpecific[3] = 0xA0;
2035 padVendorSpecific[4] = 0xC6;
2036
2037 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
2038 padLen ));
2039
2040 /* padding zero if more than 5 bytes are required */
2041 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302042 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
2043 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee426f0302013-02-08 17:35:38 -08002044 }
2045#endif
2046
2047
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002048 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 -08002049 SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) ));
2050
2051 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
2052 HAL_TXRX_FRM_802_11_DATA,
2053 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302054 TID_AC_VI,
Kiran V1ccee932012-12-12 14:49:46 -08002055 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002056 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08002057 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08002058
2059
2060 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2061 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002062 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002063 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08002064 return eSIR_FAILURE;
2065
2066 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002067 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08002068
2069 return eSIR_SUCCESS;
2070}
2071
2072#ifdef FEATURE_WLAN_TDLS_INTERNAL
2073/*
2074 * Convert HT caps to lim based HT caps
2075 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302076static void limTdlsCovertHTCaps(tpAniSirGlobal pMac,
Kiran V1ccee932012-12-12 14:49:46 -08002077 tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps)
2078{
2079
2080 /* HT Capability Info */
2081 peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ;
2082 peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet =
2083 HTCaps->supportedChannelWidthSet ;
2084 peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ;
2085 peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ;
2086 peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ;
2087 peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ;
2088 peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ;
2089 peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ;
2090 peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA;
2091 peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ;
2092 peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ;
2093 peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ;
2094 peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ;
2095 peerInfo->tdlsPeerHtCaps.lsigTXOPProtection =
2096 HTCaps->lsigTXOPProtection ;
2097
2098 /* HT Capa parameters */
2099 peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ;
2100 peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ;
2101 peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ;
2102
2103 /* Extended HT caps */
2104 peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ;
2105 peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ;
2106 peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302107 vos_mem_copy( peerInfo->supportedMCSSet,
Kiran V1ccee932012-12-12 14:49:46 -08002108 HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
2109
2110 return ;
2111}
2112
2113/*
2114 * update capability info..
2115 */
2116void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo,
2117 tDot11fFfCapabilities *Capabilities)
2118{
2119
2120 capabilityInfo->ess = Capabilities->ess;
2121 capabilityInfo->ibss = Capabilities->ibss;
2122 capabilityInfo->cfPollable = Capabilities->cfPollable;
2123 capabilityInfo->cfPollReq = Capabilities->cfPollReq;
2124 capabilityInfo->privacy = Capabilities->privacy;
2125 capabilityInfo->shortPreamble = Capabilities->shortPreamble;
2126 capabilityInfo->pbcc = Capabilities->pbcc;
2127 capabilityInfo->channelAgility = Capabilities->channelAgility;
2128 capabilityInfo->spectrumMgt = Capabilities->spectrumMgt;
2129 capabilityInfo->qos = Capabilities->qos;
2130 capabilityInfo->shortSlotTime = Capabilities->shortSlotTime;
2131 capabilityInfo->apsd = Capabilities->apsd;
2132 capabilityInfo->rrm = Capabilities->rrm;
2133 capabilityInfo->dsssOfdm = Capabilities->dsssOfdm;
2134 capabilityInfo->immediateBA = Capabilities->immediateBA;
2135
2136 return ;
2137}
2138
2139/*
2140 * update Peer info from the link request frame recieved from Peer..
2141 * in list of STA participating in TDLS link setup
2142 */
2143void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac,
2144 tLimTdlsLinkSetupPeer *setupPeer,
2145 tDot11fTDLSSetupReq *setupReq)
2146{
2147
2148 /* Populate peer info of tdls discovery result */
2149
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302150 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupReq->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002151
2152 if(setupReq->SuppRates.present)
2153 {
2154 ConvertSuppRates( pMac, &setupPeer->supportedRates,
2155 &setupReq->SuppRates );
2156 }
2157
2158 /* update QOS info, needed for Peer U-APSD session */
2159 if(setupReq->QOSCapsStation.present)
2160 {
2161 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2162 &setupReq->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002163 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."),
2164 setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd,
2165 setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd,
2166 setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002167 setupReq->QOSCapsStation.qack));
2168 }
2169
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302170 if (setupReq->ExtSuppRates.present)
Kiran V1ccee932012-12-12 14:49:46 -08002171 {
2172 setupPeer->ExtRatesPresent = 1;
2173 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2174 &setupReq->ExtSuppRates );
2175 }
2176 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302177 if (setupReq->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002178 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302179 vos_mem_copy( &setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002180 &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2181 }
2182 /* Update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302183 if (setupReq->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002184 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302185 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002186 &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
2187 }
2188
2189 return ;
2190}
2191
2192/*
2193 * update peer Info recieved with TDLS setup RSP
2194 */
2195void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac,
2196 tLimTdlsLinkSetupPeer *setupPeer,
2197 tDot11fTDLSSetupRsp *setupRsp)
2198{
2199
2200 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302201 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupRsp->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002202
2203 if(setupRsp->SuppRates.present)
2204 {
2205 tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ;
2206 ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates);
2207 }
2208
2209 /* update QOS info, needed for Peer U-APSD session */
2210 if(setupRsp->QOSCapsStation.present)
2211 {
2212 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2213 &setupRsp->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002214 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."),
2215 setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd,
2216 setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd,
2217 setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002218 setupRsp->QOSCapsStation.qack));
2219 }
2220
2221 if(setupRsp->ExtSuppRates.present)
2222 {
2223 setupPeer->ExtRatesPresent = 1;
2224 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2225 &setupRsp->ExtSuppRates );
2226 }
2227 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302228 if (setupRsp->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002229 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302230 vos_mem_copy(&setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002231 &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2232 }
2233
2234 /* update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302235 if (setupRsp->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002236 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302237 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002238 &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
2239 }
2240
2241 return ;
2242}
2243#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002244
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302245/* This Function is similar to PopulateDot11fHTCaps, except that the HT Capabilities
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002246 * are considered from the AddStaReq rather from the cfg.dat as in PopulateDot11fHTCaps
2247 */
2248static tSirRetStatus limTdlsPopulateDot11fHTCaps(tpAniSirGlobal pMac, tpPESession psessionEntry,
2249 tSirTdlsAddStaReq *pTdlsAddStaReq, tDot11fIEHTCaps *pDot11f)
2250{
2251 tANI_U32 nCfgValue;
2252 tANI_U8 nCfgValue8;
2253 tSirMacHTParametersInfo *pHTParametersInfo;
2254 union {
2255 tANI_U16 nCfgValue16;
2256 tSirMacHTCapabilityInfo htCapInfo;
2257 tSirMacExtendedHTCapabilityInfo extHtCapInfo;
2258 } uHTCapabilityInfo;
2259
2260 tSirMacTxBFCapabilityInfo *pTxBFCapabilityInfo;
2261 tSirMacASCapabilityInfo *pASCapabilityInfo;
2262
2263 nCfgValue = pTdlsAddStaReq->htCap.capInfo;
2264
2265 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2266
2267 pDot11f->advCodingCap = uHTCapabilityInfo.htCapInfo.advCodingCap;
2268 pDot11f->mimoPowerSave = uHTCapabilityInfo.htCapInfo.mimoPowerSave;
2269 pDot11f->greenField = uHTCapabilityInfo.htCapInfo.greenField;
2270 pDot11f->shortGI20MHz = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
2271 pDot11f->shortGI40MHz = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
2272 pDot11f->txSTBC = uHTCapabilityInfo.htCapInfo.txSTBC;
2273 pDot11f->rxSTBC = uHTCapabilityInfo.htCapInfo.rxSTBC;
2274 pDot11f->delayedBA = uHTCapabilityInfo.htCapInfo.delayedBA;
2275 pDot11f->maximalAMSDUsize = uHTCapabilityInfo.htCapInfo.maximalAMSDUsize;
2276 pDot11f->dsssCckMode40MHz = uHTCapabilityInfo.htCapInfo.dsssCckMode40MHz;
2277 pDot11f->psmp = uHTCapabilityInfo.htCapInfo.psmp;
2278 pDot11f->stbcControlFrame = uHTCapabilityInfo.htCapInfo.stbcControlFrame;
2279 pDot11f->lsigTXOPProtection = uHTCapabilityInfo.htCapInfo.lsigTXOPProtection;
2280
2281 // All sessionized entries will need the check below
2282 if (psessionEntry == NULL) // Only in case of NO session
2283 {
2284 pDot11f->supportedChannelWidthSet = uHTCapabilityInfo.htCapInfo.supportedChannelWidthSet;
2285 }
2286 else
2287 {
2288 pDot11f->supportedChannelWidthSet = psessionEntry->htSupportedChannelWidthSet;
2289 }
2290
2291 /* Ensure that shortGI40MHz is Disabled if supportedChannelWidthSet is
2292 eHT_CHANNEL_WIDTH_20MHZ */
2293 if(pDot11f->supportedChannelWidthSet == eHT_CHANNEL_WIDTH_20MHZ)
2294 {
2295 pDot11f->shortGI40MHz = 0;
2296 }
2297
2298 dot11fLog(pMac, LOG2, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, shortGI20:%d, shortGI40: %d, dsssCck: %d"),
2299 pDot11f->supportedChannelWidthSet, pDot11f->mimoPowerSave, pDot11f->greenField,
2300 pDot11f->shortGI20MHz, pDot11f->shortGI40MHz, pDot11f->dsssCckMode40MHz);
2301
2302 nCfgValue = pTdlsAddStaReq->htCap.ampduParamsInfo;
2303
2304 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2305 pHTParametersInfo = ( tSirMacHTParametersInfo* ) &nCfgValue8;
2306
2307 pDot11f->maxRxAMPDUFactor = pHTParametersInfo->maxRxAMPDUFactor;
2308 pDot11f->mpduDensity = pHTParametersInfo->mpduDensity;
2309 pDot11f->reserved1 = pHTParametersInfo->reserved;
2310
2311 dot11fLog( pMac, LOG2, FL( "AMPDU Param: %x" ), nCfgValue);
2312
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302313 vos_mem_copy( pDot11f->supportedMCSSet, pTdlsAddStaReq->htCap.suppMcsSet,
2314 SIZE_OF_SUPPORTED_MCS_SET);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002315
2316 nCfgValue = pTdlsAddStaReq->htCap.extendedHtCapInfo;
2317
2318 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2319
2320 pDot11f->pco = uHTCapabilityInfo.extHtCapInfo.pco;
2321 pDot11f->transitionTime = uHTCapabilityInfo.extHtCapInfo.transitionTime;
2322 pDot11f->mcsFeedback = uHTCapabilityInfo.extHtCapInfo.mcsFeedback;
2323
2324 nCfgValue = pTdlsAddStaReq->htCap.txBFCapInfo;
2325
2326 pTxBFCapabilityInfo = ( tSirMacTxBFCapabilityInfo* ) &nCfgValue;
2327 pDot11f->txBF = pTxBFCapabilityInfo->txBF;
2328 pDot11f->rxStaggeredSounding = pTxBFCapabilityInfo->rxStaggeredSounding;
2329 pDot11f->txStaggeredSounding = pTxBFCapabilityInfo->txStaggeredSounding;
2330 pDot11f->rxZLF = pTxBFCapabilityInfo->rxZLF;
2331 pDot11f->txZLF = pTxBFCapabilityInfo->txZLF;
2332 pDot11f->implicitTxBF = pTxBFCapabilityInfo->implicitTxBF;
2333 pDot11f->calibration = pTxBFCapabilityInfo->calibration;
2334 pDot11f->explicitCSITxBF = pTxBFCapabilityInfo->explicitCSITxBF;
2335 pDot11f->explicitUncompressedSteeringMatrix = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrix;
2336 pDot11f->explicitBFCSIFeedback = pTxBFCapabilityInfo->explicitBFCSIFeedback;
2337 pDot11f->explicitUncompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrixFeedback;
2338 pDot11f->explicitCompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitCompressedSteeringMatrixFeedback;
2339 pDot11f->csiNumBFAntennae = pTxBFCapabilityInfo->csiNumBFAntennae;
2340 pDot11f->uncompressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->uncompressedSteeringMatrixBFAntennae;
2341 pDot11f->compressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->compressedSteeringMatrixBFAntennae;
2342
2343 nCfgValue = pTdlsAddStaReq->htCap.antennaSelectionInfo;
2344
2345 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2346
2347 pASCapabilityInfo = ( tSirMacASCapabilityInfo* ) &nCfgValue8;
2348 pDot11f->antennaSelection = pASCapabilityInfo->antennaSelection;
2349 pDot11f->explicitCSIFeedbackTx = pASCapabilityInfo->explicitCSIFeedbackTx;
2350 pDot11f->antennaIndicesFeedbackTx = pASCapabilityInfo->antennaIndicesFeedbackTx;
2351 pDot11f->explicitCSIFeedback = pASCapabilityInfo->explicitCSIFeedback;
2352 pDot11f->antennaIndicesFeedback = pASCapabilityInfo->antennaIndicesFeedback;
2353 pDot11f->rxAS = pASCapabilityInfo->rxAS;
2354 pDot11f->txSoundingPPDUs = pASCapabilityInfo->txSoundingPPDUs;
2355
Hoonki Lee66b75f32013-04-16 18:30:07 -07002356 pDot11f->present = pTdlsAddStaReq->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002357
2358 return eSIR_SUCCESS;
2359
2360}
2361
2362tSirRetStatus
2363limTdlsPopulateDot11fVHTCaps(tpAniSirGlobal pMac,
2364 tSirTdlsAddStaReq *pTdlsAddStaReq,
2365 tDot11fIEVHTCaps *pDot11f)
2366{
2367 tANI_U32 nCfgValue=0;
2368 union {
2369 tANI_U32 nCfgValue32;
2370 tSirMacVHTCapabilityInfo vhtCapInfo;
2371 } uVHTCapabilityInfo;
2372 union {
2373 tANI_U16 nCfgValue16;
2374 tSirMacVHTTxSupDataRateInfo vhtTxSupDataRateInfo;
2375 tSirMacVHTRxSupDataRateInfo vhtRxsupDataRateInfo;
2376 } uVHTSupDataRateInfo;
2377
Hoonki Lee66b75f32013-04-16 18:30:07 -07002378 pDot11f->present = pTdlsAddStaReq->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002379
2380 nCfgValue = pTdlsAddStaReq->vhtCap.vhtCapInfo;
2381 uVHTCapabilityInfo.nCfgValue32 = nCfgValue;
2382
2383 pDot11f->maxMPDULen = uVHTCapabilityInfo.vhtCapInfo.maxMPDULen;
2384 pDot11f->supportedChannelWidthSet = uVHTCapabilityInfo.vhtCapInfo.supportedChannelWidthSet;
2385 pDot11f->ldpcCodingCap = uVHTCapabilityInfo.vhtCapInfo.ldpcCodingCap;
2386 pDot11f->shortGI80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI80MHz;
2387 pDot11f->shortGI160and80plus80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI160and80plus80MHz;
2388 pDot11f->txSTBC = uVHTCapabilityInfo.vhtCapInfo.txSTBC;
2389 pDot11f->rxSTBC = uVHTCapabilityInfo.vhtCapInfo.rxSTBC;
2390 pDot11f->suBeamFormerCap = uVHTCapabilityInfo.vhtCapInfo.suBeamFormerCap;
2391 pDot11f->suBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.suBeamformeeCap;
2392 pDot11f->csnofBeamformerAntSup = uVHTCapabilityInfo.vhtCapInfo.csnofBeamformerAntSup;
2393 pDot11f->numSoundingDim = uVHTCapabilityInfo.vhtCapInfo.numSoundingDim;
2394 pDot11f->muBeamformerCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformerCap;
2395 pDot11f->muBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformeeCap;
2396 pDot11f->vhtTXOPPS = uVHTCapabilityInfo.vhtCapInfo.vhtTXOPPS;
2397 pDot11f->htcVHTCap = uVHTCapabilityInfo.vhtCapInfo.htcVHTCap;
2398 pDot11f->maxAMPDULenExp = uVHTCapabilityInfo.vhtCapInfo.maxAMPDULenExp;
2399 pDot11f->vhtLinkAdaptCap = uVHTCapabilityInfo.vhtCapInfo.vhtLinkAdaptCap;
2400 pDot11f->rxAntPattern = uVHTCapabilityInfo.vhtCapInfo.rxAntPattern;
2401 pDot11f->txAntPattern = uVHTCapabilityInfo.vhtCapInfo.txAntPattern;
2402 pDot11f->reserved1= uVHTCapabilityInfo.vhtCapInfo.reserved1;
2403
2404 pDot11f->rxMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.rxMcsMap;
2405
2406 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.rxHighest;
2407 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2408 pDot11f->rxHighSupDataRate = uVHTSupDataRateInfo.vhtRxsupDataRateInfo.rxSupDataRate;
2409
2410 pDot11f->txMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.txMcsMap;
2411
2412 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.txHighest;
2413 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2414 pDot11f->txSupDataRate = uVHTSupDataRateInfo.vhtTxSupDataRateInfo.txSupDataRate;
2415
2416 pDot11f->reserved3= uVHTSupDataRateInfo.vhtTxSupDataRateInfo.reserved;
2417
2418 limLogVHTCap(pMac, pDot11f);
2419
2420 return eSIR_SUCCESS;
2421
2422}
2423
2424static tSirRetStatus
2425limTdlsPopulateMatchingRateSet(tpAniSirGlobal pMac,
2426 tpDphHashNode pStaDs,
2427 tANI_U8 *pSupportedRateSet,
2428 tANI_U8 supporteRatesLength,
2429 tANI_U8* pSupportedMCSSet,
2430 tSirMacPropRateSet *pAniLegRateSet,
2431 tpPESession psessionEntry,
2432 tDot11fIEVHTCaps *pVHTCaps)
2433
2434{
2435 tSirMacRateSet tempRateSet;
2436 tANI_U32 i,j,val,min,isArate;
2437 tSirMacRateSet tempRateSet2;
2438 tANI_U32 phyMode;
2439 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2440 isArate=0;
Leela Venkata Kiran Kumar Reddy Chiralac7a12152014-02-03 11:20:14 -08002441 tempRateSet2.numRates = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002442
2443 // limGetPhyMode(pMac, &phyMode);
2444 limGetPhyMode(pMac, &phyMode, NULL);
2445
2446 // get own rate set
2447 val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2448 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302449 (tANI_U8 *) &tempRateSet.rate,
2450 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002451 {
2452 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002453 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07002454 val = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002455 }
2456 tempRateSet.numRates = val;
2457
2458 if (phyMode == WNI_CFG_PHY_MODE_11G)
2459 {
2460
2461 // get own extended rate set
2462 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2463 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302464 (tANI_U8 *) &tempRateSet2.rate,
2465 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002466 tempRateSet2.numRates = val;
2467 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002468
2469 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2470 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002471 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002472 goto error;
2473 }
2474
2475 /**
2476 * Handling of the rate set IEs is the following:
2477 * - keep only rates that we support and that the station supports
2478 * - sort and the rates into the pSta->rate array
2479 */
2480
2481 // Copy all rates in tempRateSet, there are 12 rates max
2482 for (i = 0; i < tempRateSet2.numRates; i++)
2483 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
2484
2485 tempRateSet.numRates += tempRateSet2.numRates;
2486
2487 /**
2488 * Sort rates in tempRateSet (they are likely to be already sorted)
2489 * put the result in tempRateSet2
2490 */
2491 tempRateSet2.numRates = 0;
2492
2493 for (i = 0;i < tempRateSet.numRates; i++)
2494 {
2495 min = 0;
2496 val = 0xff;
2497
2498 for(j = 0;j < tempRateSet.numRates; j++)
2499 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2500 {
2501 val = tempRateSet.rate[j] & 0x7f;
2502 min = j;
2503 }
2504
2505 tempRateSet2.rate[tempRateSet2.numRates++] = tempRateSet.rate[min];
2506 tempRateSet.rate[min] = 0xff;
2507 }
2508
2509 /**
2510 * Copy received rates in tempRateSet, the parser has ensured
2511 * unicity of the rates so there cannot be more than 12 . Need to Check this
2512 * TODO Sunil.
2513 */
2514 for (i = 0; i < supporteRatesLength; i++)
2515 {
2516 tempRateSet.rate[i] = pSupportedRateSet[i];
2517 }
2518
2519 tempRateSet.numRates = supporteRatesLength;
2520
2521 {
2522 tpSirSupportedRates rates = &pStaDs->supportedRates;
2523 tANI_U8 aRateIndex = 0;
2524 tANI_U8 bRateIndex = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302525 vos_mem_set( (tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002526
2527 for (i = 0;i < tempRateSet2.numRates; i++)
2528 {
2529 for (j = 0;j < tempRateSet.numRates; j++)
2530 {
2531 if ((tempRateSet2.rate[i] & 0x7F) ==
2532 (tempRateSet.rate[j] & 0x7F))
2533 {
2534#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2535 if ((bRateIndex > HAL_NUM_11B_RATES) || (aRateIndex > HAL_NUM_11A_RATES))
2536 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002537 limLog(pMac, LOGE, FL("Invalid number of rates (11b->%d, 11a->%d)"),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002538 bRateIndex, aRateIndex);
2539 return eSIR_FAILURE;
2540 }
2541#endif
2542 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2543 {
2544 isArate=1;
2545 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
2546 }
2547 else
2548 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2549 break;
2550 }
2551 }
2552 }
2553 }
2554
2555
2556 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
2557#ifdef FEATURE_WLAN_TDLS
2558 if (pStaDs->mlmStaContext.htCapability)
2559#else
2560 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2561 (pStaDs->mlmStaContext.htCapability))
2562#endif
2563 {
2564 val = SIZE_OF_SUPPORTED_MCS_SET;
2565 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2566 mcsSet,
2567 &val) != eSIR_SUCCESS)
2568 {
2569 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002570 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002571 goto error;
2572 }
2573
2574 for (i=0; i<val; i++)
2575 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2576
2577 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH :"));)
2578 for (i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2579 {
2580 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2581 }
2582 }
2583
2584#ifdef WLAN_FEATURE_11AC
2585 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2586#endif
2587 /**
2588 * Set the erpEnabled bit iff the phy is in G mode and at least
2589 * one A rate is supported
2590 */
2591 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2592 pStaDs->erpEnabled = eHAL_SET;
2593
2594
2595
2596 return eSIR_SUCCESS;
2597
2598 error:
2599
2600 return eSIR_FAILURE;
2601}
2602
2603static int limTdlsSelectCBMode(tDphHashNode *pStaDs, tpPESession psessionEntry)
2604{
2605 tANI_U8 channel = psessionEntry->currentOperChannel;
2606
2607 if ( pStaDs->mlmStaContext.vhtCapability )
2608 {
2609 if ( channel== 36 || channel == 52 || channel == 100 ||
2610 channel == 116 || channel == 149 )
2611 {
2612 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
2613 }
2614 else if ( channel == 40 || channel == 56 || channel == 104 ||
2615 channel == 120 || channel == 153 )
2616 {
2617 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
2618 }
2619 else if ( channel == 44 || channel == 60 || channel == 108 ||
2620 channel == 124 || channel == 157 )
2621 {
2622 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
2623 }
2624 else if ( channel == 48 || channel == 64 || channel == 112 ||
2625 channel == 128 || channel == 161 )
2626 {
2627 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
2628 }
2629 else if ( channel == 165 )
2630 {
2631 return 0;
2632 }
2633 }
2634 else if ( pStaDs->mlmStaContext.htCapability )
2635 {
2636 if ( channel== 40 || channel == 48 || channel == 56 ||
2637 channel == 64 || channel == 104 || channel == 112 ||
2638 channel == 120 || channel == 128 || channel == 136 ||
2639 channel == 144 || channel == 153 || channel == 161 )
2640 {
2641 return 1;
2642 }
2643 else if ( channel== 36 || channel == 44 || channel == 52 ||
2644 channel == 60 || channel == 100 || channel == 108 ||
2645 channel == 116 || channel == 124 || channel == 132 ||
2646 channel == 140 || channel == 149 || channel == 157 )
2647 {
2648 return 2;
2649 }
2650 else if ( channel == 165 )
2651 {
2652 return 0;
2653 }
2654 }
2655 return 0;
2656}
2657
Kiran V1ccee932012-12-12 14:49:46 -08002658/*
2659 * update HASH node entry info
2660 */
2661static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002662 tSirTdlsAddStaReq *pTdlsAddStaReq, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002663{
2664 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
2665 tDot11fIEHTCaps htCap, *htCaps;
Kiet Lam770920c2013-10-21 12:49:30 +05302666 tDot11fIEVHTCaps *pVhtCaps = NULL;
Hoonki Lee99e53782013-02-12 18:07:03 -08002667#ifdef WLAN_FEATURE_11AC
Kiet Lam770920c2013-10-21 12:49:30 +05302668 tDot11fIEVHTCaps vhtCap;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002669 tANI_U8 cbMode;
Hoonki Lee99e53782013-02-12 18:07:03 -08002670#endif
Kiran V1ccee932012-12-12 14:49:46 -08002671 tpDphHashNode pSessStaDs = NULL;
2672 tANI_U16 aid;
2673
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002674 if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_ADD)
2675 {
2676 PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
2677 }
2678 else if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE)
2679 {
2680 limTdlsPopulateDot11fHTCaps(pMac, NULL, pTdlsAddStaReq, &htCap);
2681 }
Kiran V1ccee932012-12-12 14:49:46 -08002682 htCaps = &htCap;
Hoonki Lee99e53782013-02-12 18:07:03 -08002683 if (htCaps->present)
Kiran V1ccee932012-12-12 14:49:46 -08002684 {
2685 pStaDs->mlmStaContext.htCapability = 1 ;
2686 pStaDs->htGreenfield = htCaps->greenField ;
2687 pStaDs->htSupportedChannelWidthSet = htCaps->supportedChannelWidthSet ;
2688 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
2689 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
2690 pStaDs->htAMpduDensity = htCaps->mpduDensity;
2691 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
2692 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
2693 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
2694 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
2695 limFillRxHighestSupportedRate(pMac,
2696 &pStaDs->supportedRates.rxHighestDataRate,
2697 htCaps->supportedMCSSet);
2698 pStaDs->baPolicyFlag = 0xFF;
Kiran V1ccee932012-12-12 14:49:46 -08002699 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
2700 }
2701 else
2702 {
2703 pStaDs->mlmStaContext.htCapability = 0 ;
2704 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
2705 }
Hoonki Lee99e53782013-02-12 18:07:03 -08002706#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002707 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002708 pVhtCaps = &vhtCap;
2709 if (pVhtCaps->present)
2710 {
2711 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302712
2713 if ((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
2714 pMac->roam.configParam.enableVhtFor24GHz)
2715 {
2716 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
2717 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
2718 }
2719 else
2720 {
2721 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
2722 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_40MHZ ;
2723 }
2724
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002725 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2726 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2727 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002728 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2729 }
2730 else
2731 {
2732 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002733 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002734 }
2735#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002736 /*Calculate the Secondary Coannel Offset */
2737 cbMode = limTdlsSelectCBMode(pStaDs, psessionEntry);
2738
2739 pStaDs->htSecondaryChannelOffset = cbMode;
2740
2741#ifdef WLAN_FEATURE_11AC
2742 if ( pStaDs->mlmStaContext.vhtCapability )
2743 {
2744 pStaDs->htSecondaryChannelOffset = limGetHTCBState(cbMode);
2745 }
2746#endif
Kiran V1ccee932012-12-12 14:49:46 -08002747
2748 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
2749 &psessionEntry->dph.dphHashTable) ;
2750
2751 /* Lets enable QOS parameter */
2752 pStaDs->qosMode = 1;
2753 pStaDs->wmeEnabled = 1;
2754 pStaDs->lleEnabled = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002755 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2756 */
2757 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002758
2759 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002760
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002761 /* TDLS Dummy AddSTA does not have HTCap,VHTCap,Rates info , is it OK ??
2762 */
2763 limTdlsPopulateMatchingRateSet(pMac, pStaDs, pTdlsAddStaReq->supported_rates,
2764 pTdlsAddStaReq->supported_rates_length,
2765 (tANI_U8 *)pTdlsAddStaReq->htCap.suppMcsSet,
2766 &pStaDs->mlmStaContext.propRateSet,
Kiet Lam770920c2013-10-21 12:49:30 +05302767 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002768
2769 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2770 */
2771 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002772
2773 return ;
2774}
2775
2776#ifdef FEATURE_WLAN_TDLS_INTERNAL
2777/*
2778 * find Peer in setup link list.
2779 */
2780
2781tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2782 tLimTdlsLinkSetupPeer **setupPeer)
2783{
2784 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2785 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2786 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2787
2788 while (linkSetupList != NULL)
2789 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302790 if (vos_mem_compare((tANI_U8 *) peerMac,
2791 (tANI_U8 *) linkSetupList->peerMac,
2792 sizeof(tSirMacAddr)) )
Kiran V1ccee932012-12-12 14:49:46 -08002793 {
2794 checkNode = TDLS_NODE_FOUND ;
2795 *setupPeer = linkSetupList ;
2796 break ;
2797 }
2798 linkSetupList = linkSetupList->next;
2799 }
2800
2801 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ;
2802}
2803
2804/*
2805 * find peer in Discovery list.
2806 * Dicovery list get populated in two instances, a) Recieved responses in reply
2807 * to discovery request b) If discover request is received from TDLS peer STA
2808 */
2809tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2810{
2811 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2812 tSirTdlsPeerInfo *peerInfo = NULL ;
2813
2814 while (discoveryList != NULL)
2815 {
2816 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2817 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002818 ("Peer in discovery list = " MAC_ADDRESS_STR),
2819 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002820
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302821 if (vos_mem_compare((tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002822 (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) )
2823 {
2824 break ;
2825 }
2826 discoveryList = discoveryList->next;
2827 }
2828
2829 return peerInfo ;
2830}
2831
2832/*
2833 * find peer in Discovery list by looking into peer state.
2834 * Dicovery list get populated in two instances, a) Recieved responses in reply
2835 * to discovery request b) If discover request is received from TDLS peer STA
2836 */
2837static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
2838 tANI_U8 state)
2839{
2840 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2841 tSirTdlsPeerInfo *peerInfo = NULL ;
2842
2843 while (discoveryList != NULL)
2844 {
2845 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2846 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002847 ("peerInfo Mac = " MAC_ADDRESS_STR),
2848 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002849
2850 if (peerInfo->tdlsPeerState == state)
2851 {
2852 break ;
2853 }
2854 discoveryList = discoveryList->next;
2855 }
2856
2857 return peerInfo ;
2858}
2859
2860/*
2861 * find peer in Setup list by looking into peer state.
2862 * setup list get populated in two instances, a) Recieved responses in reply
2863 * to setup request b) If discover request is received from TDLS peer STA
2864 */
2865static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
2866 tLimTdlsLinkSetupPeer **setupPeer)
2867{
2868
2869 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2870 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2871 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2872
2873 while (linkSetupList != NULL)
2874 {
2875 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002876 ("peer state = %02x"), (linkSetupList)->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08002877 if((linkSetupList)->tdls_link_state == state)
2878 {
2879 checkNode = TDLS_NODE_FOUND ;
2880 *setupPeer = linkSetupList ;
2881 break ;
2882 }
2883 linkSetupList = (linkSetupList)->next;
2884 }
2885
2886 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ;
2887}
2888
2889
2890/*
2891 * delete Peer from Setup Link
2892 */
2893void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2894{
2895 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2896 tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ;
2897 tLimTdlsLinkSetupPeer *currentNode = NULL ;
2898 tLimTdlsLinkSetupPeer *prevNode = NULL ;
2899
2900 for(currentNode = *linkSetupList ; currentNode != NULL ;
2901 prevNode = currentNode, currentNode = currentNode->next)
2902 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302903 if (vos_mem_compare( (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002904 (tANI_U8 *) currentNode->peerMac,
2905 sizeof(tSirMacAddr)) )
2906 {
2907 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002908 ("Del Node for Peer = " MAC_ADDRESS_STR),
2909 MAC_ADDR_ARRAY(currentNode->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002910 /* if it's first Node */
2911 if(NULL == prevNode)
2912 {
2913 *linkSetupList = currentNode->next ;
2914 }
2915 else
2916 {
2917 prevNode->next = currentNode->next ;
2918 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302919 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08002920 return ;
2921 }
2922 }
2923
2924 return ;
2925}
2926
2927
2928
2929/*
2930 * TDLS discovery request frame received from TDLS peer STA..
2931 */
2932static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac,
2933 tANI_U8 *pBody, tANI_U32 frmLen )
2934{
2935 tDot11fTDLSDisReq tdlsDisReq = {{0}} ;
2936 tANI_U32 status = 0 ;
2937 tLimDisResultList *tdlsDisResult = NULL ;
2938 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
2939 tSirMacAddr peerMac = {0} ;
2940 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2941 tSirTdlsPeerInfo *peerInfo = NULL ;
2942 tpPESession psessionEntry = NULL ;
2943 tANI_U8 sessionId = 0 ;
2944
2945 status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ;
2946
2947 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002948 ("TDLS dis request dialog = %d"), tdlsDisReq.DialogToken.token);
Kiran V1ccee932012-12-12 14:49:46 -08002949
2950 if ( DOT11F_FAILED( status ) )
2951 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002952 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
2953 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08002954 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2955 return eSIR_FAILURE;
2956 }
2957 else if ( DOT11F_WARNED( status ) )
2958 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002959 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
2960 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08002961 status, frmLen );
2962 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2963 }
2964
2965 /*
2966 * find session entry using BSSID in link identifier, not using MAC
2967 * header beacuse, there is cases in TDLS, there may be BSSID will not
2968 * be present in header
2969 */
2970 psessionEntry = peFindSessionByBssid(pMac,
2971 &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ;
2972 if(NULL == psessionEntry)
2973 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002974 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08002975 ("no Session entry for TDLS session (bssid "MAC_ADDR_ARRAY")"),
2976 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08002977
2978 //VOS_ASSERT(0) ;
2979 return eSIR_FAILURE;
2980 }
2981
2982 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302983 status = vos_mem_compare( &psessionEntry->bssId[0],
Kiran V1ccee932012-12-12 14:49:46 -08002984 &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
2985 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002986 ("lim BSSID "MAC_ADDRESS_STR),
2987 MAC_ADDR_ARRAY( psessionEntry->bssId));
Kiran V1ccee932012-12-12 14:49:46 -08002988
2989 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002990 ("Dis req from BSSID "MAC_ADDRESS_STR),
2991 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08002992 if(!status)
2993 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002994 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08002995
2996 return eSIR_FAILURE ;
2997 }
2998
2999 /*
3000 * check if this is echo of our transmitted discovery request
3001 * drop it here, TODO: better to drop this in TL.
3002 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303003 status = vos_mem_compare( psessionEntry->selfMacAddr,
Kiran V1ccee932012-12-12 14:49:46 -08003004 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3005 sizeof(tSirMacAddr)) ;
3006 if(status)
3007 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003008 limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003009 return eSIR_FAILURE ;
3010 }
3011
3012 /*
3013 * while processing Discovery request from Peer,
3014 * STA_MAC--> MAC of TDLS discovery initiator
3015 * STA_PEER_MAC--> MAC of TDLS discovery responder.
3016 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303017 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003018 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3019 sizeof(tSirMacAddr)) ;
3020 /* TODO, do more validation */
3021
3022 /* see if discovery is already in progress */
3023 peerInfo = limTdlsFindDisPeer(pMac, peerMac) ;
3024
3025 if(NULL == peerInfo)
3026 {
3027 /*
3028 * we are allocating peer info for individual peers found in TDLS
3029 * discovery, we need to keep adding TDLS peers till we have timed
3030 * out. We are freeing this memory at the time we are sending this
3031 * collected peer info to SME.
3032 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303033 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3034 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003035 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003036 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery "
3037 "reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003038 return eSIR_FAILURE ;
3039 }
3040
3041
3042 peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3043 peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ;
3044 peerInfo->dialog = tdlsDisReq.DialogToken.token ;
3045
3046 peerInfo->sessionId = psessionEntry->peSessionId;
3047
3048 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303049 vos_mem_copy( peerInfo->peerMac, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08003050
3051 /*
3052 * Now, as per D13, there will not be any Supp rates, ext Supp rates
3053 * info in Discovery request frames, so we are populating this info
3054 * locally to pass it to ADD STA.
3055 */
3056 do
3057 {
3058 tDot11fIESuppRates suppRates = {0} ;
3059 tDot11fIEExtSuppRates extSuppRates = {0} ;
3060 tANI_U16 caps = 0 ;
3061 tDot11fFfCapabilities capsInfo = {0} ;
3062 tDot11fIEHTCaps HTCaps = {0} ;
3063 /* populate supported rate IE */
3064 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3065 &suppRates, psessionEntry );
3066 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3067 &suppRates);
3068 /* Populate extended supported rates */
3069 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3070 &extSuppRates, psessionEntry );
3071
3072 peerInfo->ExtRatesPresent = 1;
3073 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3074 &extSuppRates);
3075
3076 if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
3077 {
3078 /*
3079 * Could not get Capabilities value
3080 * from CFG. Log error.
3081 */
3082 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003083 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08003084 }
3085 swapBitField16(caps, ( tANI_U16* )&capsInfo );
3086 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303087 tdlsUpdateCapInfo(&peerInfo->capabilityInfo, &capsInfo) ;
Kiran V1ccee932012-12-12 14:49:46 -08003088
3089 PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps );
3090 limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ;
3091
3092 } while (0) ;
3093
3094 /* now add this new found discovery node into tdls discovery list */
3095 tdlsDisResult->next = *disResultList ;
3096 *disResultList = tdlsDisResult ;
3097 pMac->lim.gLimTdlsDisStaCount++ ;
3098
3099 /* See if for this peer already entry in setup Link */
3100 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3101
3102 /*
3103 * if there is no entry for this peer in setup list, we need to
3104 * do add sta for this peer to transmit discovery rsp.
3105 */
3106 if(NULL == setupPeer)
3107 {
3108 /* To start with, send add STA request to HAL */
3109 pMac->lim.gLimAddStaTdls = true ;
3110 peerInfo->delStaNeeded = true ;
3111
3112 if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac,
3113 peerInfo, psessionEntry))
3114 {
3115 VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003116 limLog(pMac, LOGE, "Add STA for dis response is failed ") ;
Kiran V1ccee932012-12-12 14:49:46 -08003117 return eSIR_FAILURE ;
3118 }
3119 } /* use setup link sta ID for discovery rsp */
3120 else
3121 {
3122 peerInfo->delStaNeeded = false ;
3123 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
3124 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
3125 }
3126
3127 }
3128 else
3129 {
3130 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003131 ("discovery procedure in progress for this peer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003132 }
3133
3134 return eSIR_SUCCESS ;
3135}
3136
3137/* Process TDLS setup Request Frame */
3138
3139static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac,
3140 tANI_U8 *pBody, tANI_U32 frmLen)
3141{
3142
3143 tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ;
3144 tANI_U32 status = 0 ;
3145 tpPESession psessionEntry = NULL ;
3146 tANI_U8 sessionId = 0 ;
3147 tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ;
3148 tANI_U8 previousState = TDLS_LINK_IDLE_STATE ;
3149 /* create node for Link setup */
3150 tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
3151 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3152 tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ;
3153
3154 status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ;
3155
3156 if ( DOT11F_FAILED( status ) )
3157 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003158 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3159 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003160 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3161 return eSIR_FAILURE;
3162 }
3163 else if ( DOT11F_WARNED( status ) )
3164 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003165 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3166 "setup Request frame (0x%08x, %d bytes):"),
3167 status, frmLen );
Kiran V1ccee932012-12-12 14:49:46 -08003168 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3169 }
3170 /*
3171 * find session entry using BSSID in link identifier, not using MAC
3172 * header beacuse, there is cases in TDLS, there may be BSSID will not
3173 * be present in header
3174 */
3175 psessionEntry = peFindSessionByBssid(pMac,
3176 &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ;
3177 if(NULL == psessionEntry)
3178 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003179 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003180 ("no Session entry for TDLS session (bssid "
3181 MAC_ADDRESS_STR")"),
3182 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003183
3184 //VOS_ASSERT(0) ;
3185 return eSIR_FAILURE ;
3186 }
3187 /* TODO: we don;t need this check now, varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303188 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003189 &tdlsSetupReq.LinkIdentifier.bssid[0],
3190 sizeof(tSirMacAddr)) ;
3191
3192 if(!status)
3193 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003194 limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003195
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303196 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
3197 tdlsSetupReq.DialogToken.token, psessionEntry,
3198 TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003199 return eSIR_FAILURE ;
3200 }
3201
3202#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3203 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ)
3204 {
3205 /* simply ignore this setup request packet */
3206 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003207 ("TDLS negative running: ignore TDLS Setup Req packet"));
Kiran V1ccee932012-12-12 14:49:46 -08003208 return eSIR_SUCCESS ;
3209 }
3210 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3211 {
3212 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003213 ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req"));
Kiran V1ccee932012-12-12 14:49:46 -08003214 /* format TDLS discovery request frame and transmit it */
3215 limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry,
3216 NULL, 0) ;
3217 }
3218#endif
3219 /* TODO, do more validation */
3220
3221 if(!limTdlsFindLinkPeer(pMac,
3222 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3223 &tmpSetupPeer))
3224 {
3225 tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3226
3227 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003228 ("Link is already setup with this peer" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003229 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003230 ("state = %d"), tmpSetupPeer->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08003231 //return eSIR_FAILURE ;
3232
3233 if(tmpSetupPeer == NULL)
3234 {
3235 VOS_ASSERT(0) ;
3236 return eSIR_FAILURE ;
3237
3238 }
3239 switch(tmpSetupPeer->tdls_link_state)
3240 {
3241
3242 case TDLS_LINK_SETUP_START_STATE:
3243 {
3244 v_SINT_t macCompare = 0 ;
3245 macCompare= vos_mem_compare2(tmpSetupPeer->peerMac,
3246 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
3247 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003248 ("MAC comparison Rslt = %d"), macCompare ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003249 if(0 > macCompare)
3250 {
3251 /*
3252 * Delete our Setup Request/Peer info and honour Peer
3253 * Setup Request, go ahead and respond for this
3254 */
3255 /* Deactivate the timer */
3256 tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ;
3257#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3258 if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3259 != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3260#endif
3261 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE,
3262 tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP);
3263
3264 limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ;
3265 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3266 }
3267 else if(0 < macCompare)
3268 {
3269 /*
3270 * Go ahead with current setup as peer is going to
3271 * respond for setup request
3272 */
3273 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3274 }
3275 else
3276 {
3277 /* same MAC, not possible */
3278 VOS_ASSERT(0) ;
3279 }
3280
3281 break ;
3282 }
3283#if 1
3284 case TDLS_LINK_SETUP_DONE_STATE:
3285 {
3286 tpDphHashNode pStaDs = NULL ;
3287
3288 previousState = TDLS_LINK_SETUP_WAIT_STATE ;
3289 currentState = TDLS_LINK_TEARDOWN_START_STATE ;
3290 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3291 ("link Setup Done state " )) ;
3292 tmpSetupPeer->tdls_prev_link_state = previousState ;
3293 tmpSetupPeer->tdls_link_state = currentState ;
3294 setupPeer = tmpSetupPeer ;
3295#if 0
3296 /* Send Teardown to this Peer and Initiate new TDLS Setup */
3297 limSendTdlsTeardownFrame(pMac,
3298 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3299 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ;
3300#else
3301
3302 /* tdls_hklee: send message to HAL before it is deleted, cause */
3303 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3304
3305 /* send del STA to remove context for this TDLS STA */
3306 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3307
3308 /* now send indication to SME-->HDD->TL to remove STA from TL */
3309
3310 if(pStaDs)
3311 {
3312 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3313 pStaDs, eSIR_SUCCESS) ;
3314
3315 /* send Teardown Ind to SME */
3316 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3317 eWNI_SME_TDLS_TEARDOWN_IND) ;
3318 /* remove node from setup list */
3319 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3320 }
3321#endif
3322 //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE;
3323 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3324 break ;
3325
3326 }
3327 default:
3328 {
3329 VOS_ASSERT(0) ;
3330 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003331 ("link Setup is Recieved in unknown state" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003332 break ;
3333 }
3334#endif
3335 }
3336 if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE)
3337 return eSIR_FAILURE ;
3338 }
3339
3340 if(currentState != TDLS_LINK_TEARDOWN_START_STATE)
3341 {
3342 /*
3343 * Now we are sure to send discovery response frame to TDLS discovery
3344 * initiator, we don't care, if this request is unicast ro broadcast,
3345 * we simply, send discovery response frame on direct link.
3346 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303347 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
3348 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08003349 {
3350 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003351 ( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08003352 return eSIR_MEM_ALLOC_FAILED;
3353 }
3354
3355 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3356 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3357 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3358 setupPeer->tdls_prev_link_state = previousState ;
3359 setupPeer->tdls_link_state = currentState ;
3360 /* TDLS_sessionize: remember sessionId for future */
3361 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3362 setupPeer->tdls_bIsResponder = 0;
3363
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303364 vos_mem_copy(setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003365 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3366 sizeof(tSirMacAddr)) ;
3367
3368 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003369 ("Setup REQ MAC = " MAC_ADDRESS_STR),
3370 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003371
3372 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3373 pMac->lim.gLimAddStaTdls = true ;
3374
3375 /* To start with, send add STA request to HAL */
3376 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac,
3377 setupPeer, psessionEntry))
3378 {
3379 VOS_ASSERT(0) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303380 vos_mem_free((void **) &setupPeer) ;
Kiran V1ccee932012-12-12 14:49:46 -08003381 return eSIR_FAILURE ;
3382 }
3383
3384 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303385 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003386 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3387
3388 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3389 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3390 (tANI_U32)setupPeer->peerMac,
3391 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3392 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3393
3394 /* update setup peer list */
3395 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
3396 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
3397 }
3398 else
3399 {
3400 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3401 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3402 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3403 setupPeer->tdls_prev_link_state = previousState ;
3404 setupPeer->tdls_link_state = currentState ;
3405 /* TDLS_sessionize: remember sessionId for future */
3406 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3407 setupPeer->tdls_bIsResponder = 0;
3408
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303409 vos_mem_copy( setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003410 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3411 sizeof(tSirMacAddr)) ;
3412
3413 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003414 ("Setup REQ MAC = "MAC_ADDRESS_STR),
3415 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003416
3417 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3418 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303419 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003420 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3421
3422 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3423 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3424 (tANI_U32)setupPeer->peerMac,
3425 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3426 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3427 }
3428
3429
3430 return eSIR_SUCCESS ;
3431
3432}
3433
3434/*
3435 * TDLS discovery request frame received from TDLS peer STA..
3436 */
3437static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac,
3438 tANI_U8 *pBody, tANI_U32 frmLen )
3439{
3440 tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ;
3441 tANI_U32 status = 0 ;
3442 tSirMacAddr peerMac = {0} ;
3443 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3444 tpPESession psessionEntry = NULL ;
3445 tANI_U8 sessionId = 0 ;
3446
3447 status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ;
3448
3449 if ( DOT11F_FAILED( status ) )
3450 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003451 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3452 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003453 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3454 return eSIR_FAILURE;
3455 }
3456 else if ( DOT11F_WARNED( status ) )
3457 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003458 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3459 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003460 status, frmLen );
3461 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3462 }
3463
3464 /*
3465 * find session entry using BSSID in link identifier, not using MAC
3466 * header beacuse, there is cases in TDLS, there may be BSSID will not
3467 * be present in header
3468 */
3469 psessionEntry = peFindSessionByBssid(pMac,
3470 &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ;
3471 if(NULL == psessionEntry)
3472 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003473 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003474 ("no Session entry for TDLS session (bssid "
3475 MAC_ADDRESS_STR")"),
3476 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003477
3478 //VOS_ASSERT(0) ;
3479 return eSIR_FAILURE;
3480 }
3481
3482 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303483 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003484 &tdlsSetupRsp.LinkIdentifier.bssid[0],
3485 sizeof(tSirMacAddr)) ;
3486
3487 if(!status)
3488 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003489 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003490
3491 VOS_ASSERT(0) ;
3492 return eSIR_FAILURE ;
3493 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303494 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003495 &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0],
3496 sizeof(tSirMacAddr)) ;
3497
3498 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003499 ("TDLS setup RSP peer = "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003500 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3501
3502 if(NULL == setupPeer)
3503 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003504 limLog( pMac, LOGE, FL("unknown setup Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003505 return eSIR_FAILURE ;
3506 }
3507
3508 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003509 ("deactivating Setup RSP timer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003510
3511 /* Deactivate the timer */
3512 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ;
3513
3514 /*
3515 * TDLS Setup RSP is recieved with Failure, Delete this STA entry
3516 * don't respond with TDLS CNF frame.
3517 */
3518 if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status)
3519 {
3520 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3521 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003522 ("setup RSP with Failure Code")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003523 return eSIR_FAILURE ;
3524 }
3525
3526 /* update Link Info */
3527 limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ;
3528
3529 /* TODO, do more validation */
3530
3531
3532 /*
3533 * Now we are sure to send link setup CNF frame to TDLS link setup
3534 * reponded, now we will create dph hash entry and send add STA to HAL
3535 */
3536
3537 pMac->lim.gLimAddStaTdls = true ;
3538 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac,
3539 setupPeer, psessionEntry))
3540 {
3541 /* through error */
3542 VOS_ASSERT(0) ;
3543 return eSIR_FAILURE ;
3544 }
3545 /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */
3546
3547
3548 /* send TDLS confim frame to TDLS Peer STA */
3549 limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, psessionEntry, NULL, 0) ;
3550
3551 /*
3552 * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and
3553 * wait for Setup CNF transmission on air, once we receive tx complete
3554 * message, we will change the peer state and send message to SME
3555 * callback..
3556 */
3557 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3558 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ;
3559
3560 return eSIR_SUCCESS ;
3561}
3562/*
3563 * TDLS setup CNF frame processing ..
3564 */
3565
3566static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac,
3567 tANI_U8 *pBody, tANI_U32 frmLen)
3568{
3569 tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ;
3570 tANI_U32 status = 0 ;
3571 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3572 tpPESession psessionEntry = NULL ;
3573 tANI_U8 sessionId = 0 ;
3574
3575 status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ;
3576
3577 if ( DOT11F_FAILED( status ) )
3578 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003579 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3580 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003581 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3582 return eSIR_FAILURE;
3583 }
3584 else if ( DOT11F_WARNED( status ) )
3585 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003586 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3587 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003588 status, frmLen );
3589 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3590 }
3591 /*
3592 * find session entry using BSSID in link identifier, not using MAC
3593 * header beacuse, there is cases in TDLS, there may be BSSID will not
3594 * be present in header
3595 */
3596 psessionEntry = peFindSessionByBssid(pMac,
3597 &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ;
3598 if(NULL == psessionEntry)
3599 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003600 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003601 ("no Session entry for TDLS session (bssid "
3602 MAC_ADDRESS_STR")"),
3603 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003604
3605 //VOS_ASSERT(0) ;
3606 return eSIR_FAILURE;
3607 }
3608
3609 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303610 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003611 &tdlsSetupCnf.LinkIdentifier.bssid[0],
3612 sizeof(tSirMacAddr)) ;
3613
3614 if(!status)
3615 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003616 limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003617
3618 VOS_ASSERT(0) ;
3619 return eSIR_FAILURE ;
3620 }
3621 /* TODO, do more validation */
3622 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003623 ("setup Cnf peer MAc = "MAC_ADDRESS_STR),
3624 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.InitStaAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003625
3626 limTdlsFindLinkPeer(pMac,
3627 &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
3628 &setupPeer) ;
3629
3630 if(NULL == setupPeer)
3631 {
3632 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003633 (" unknown setup CNF frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003634 VOS_ASSERT(0) ;
3635 return eSIR_FAILURE ;
3636 }
3637 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003638 ("setup CNF peer MAC = "MAC_ADDRESS_STR),
3639 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003640 /*T match dialog token, before proceeding further */
3641 if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token)
3642 {
3643 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003644 ("setup CNF frame not matching with setup RSP")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003645 VOS_ASSERT(0) ;
3646 return eSIR_FAILURE ;
3647 }
3648
3649 /*
3650 * Now we are sure that, this set CNF is for us, now stop
3651 * the running timer..
3652 */
3653 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ;
3654
3655 /* change TDLS peer State */
3656 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3657 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
3658
3659 /* send indication to SME that, new link is setup */
3660 limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ;
3661
3662 /* tdls_hklee: prepare PTI template and send it to HAL */
3663 limTdlsLinkEstablish(pMac, (setupPeer)->peerMac);
3664
3665 return eSIR_SUCCESS ;
3666
3667}
3668
3669/*
3670 * TDLS discovery response frame processing ..
3671 */
3672
3673static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac,
3674 tANI_U8 *pBody, tANI_U32 frmLen,
3675 tANI_S8 rssi, tpPESession psessionEntry)
3676{
3677 tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ;
3678 tANI_U32 status = 0 ;
3679 tLimDisResultList *tdlsDisResult = NULL ;
3680 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
3681 tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ;
3682
3683 status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ;
3684
3685 if ( DOT11F_FAILED( status ) )
3686 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003687 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3688 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003689 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3690 return eSIR_FAILURE;
3691 }
3692 else if ( DOT11F_WARNED( status ) )
3693 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003694 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3695 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003696 status, frmLen );
3697 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);)
3698 }
3699 /*TODO: match dialog token, before proceeding further */
3700
3701 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303702 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003703 &tdlsDisRsp.LinkIdentifier.bssid[0],
3704 sizeof(tSirMacAddr)) ;
3705
3706 if(!status)
3707 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003708 limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003709 return eSIR_FAILURE ;
3710 }
3711 /* TODO, do more validation */
3712
3713 if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
3714 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003715 limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003716 return eSIR_FAILURE ;
3717 }
3718
3719 pMac->lim.gLimTdlsDisStaCount++ ;
3720
3721 /*
3722 * we are allocating peer info for individual peers found in TDLS
3723 * discovery, we need to keep adding TDLS peers till we have timed
3724 * out. We are freeing this memory at the time we are sending this
3725 * collected peer info to SME.
3726 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303727 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3728 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003729 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003730 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003731 return eSIR_FAILURE ;
3732 }
3733
3734 do
3735 {
3736 tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3737
3738 /* Populate peer info of tdls discovery result */
3739 peerInfo->sessionId = psessionEntry->peSessionId;
3740 /*
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303741 * When we receive DIS RSP from peer MAC,
Kiran V1ccee932012-12-12 14:49:46 -08003742 * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
3743 * will carry our MAC.
3744 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303745 vos_mem_copy( peerInfo->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003746 &tdlsDisRsp.LinkIdentifier.RespStaAddr[0],
3747 sizeof(tSirMacAddr)) ;
3748
3749 /* update RSSI for this TDLS peer STA */
3750 peerInfo->tdlsPeerRssi = rssi ;
3751
3752 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303753 tdlsUpdateCapInfo(&peerInfo->capabilityInfo,
Kiran V1ccee932012-12-12 14:49:46 -08003754 &tdlsDisRsp.Capabilities) ;
3755
3756 /* update Supp rates */
3757 if(tdlsDisRsp.SuppRates.present)
3758 {
3759 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3760 &tdlsDisRsp.SuppRates );
3761 }
3762
3763 /* update EXT supp rates */
3764 if(tdlsDisRsp.ExtSuppRates.present)
3765 {
3766 peerInfo->ExtRatesPresent = 1;
3767 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3768 &tdlsDisRsp.ExtSuppRates );
3769 }
3770 /* update HT caps */
3771 if (tdlsDisRsp.HTCaps.present)
3772 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303773 vos_mem_copy( &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08003774 sizeof( tDot11fIEHTCaps ) );
3775 }
Kiran V1ccee932012-12-12 14:49:46 -08003776 } while(0) ;
3777
3778 /* now add this new found discovery node into tdls discovery list */
3779 tdlsDisResult->next = *disResultList ;
3780 *disResultList = tdlsDisResult ;
3781
3782 return eSIR_SUCCESS ;
3783}
3784
3785/*
3786 * Process TDLS Teardown request frame from TDLS peer STA
3787 */
3788static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac,
3789 tANI_U8 *pBody, tANI_U32 frmLen )
3790{
3791 tDot11fTDLSTeardown tdlsTeardown = {{0}} ;
3792 tANI_U32 status = 0 ;
3793 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3794 tpPESession psessionEntry = NULL ;
3795 tANI_U8 sessionId = 0 ;
3796
3797 status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ;
3798
3799 if ( DOT11F_FAILED( status ) )
3800 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003801 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3802 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003803 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3804 return eSIR_FAILURE;
3805 }
3806 else if ( DOT11F_WARNED( status ) )
3807 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003808 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3809 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003810 status, frmLen );
3811 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3812 }
3813
3814 /*
3815 * find session entry using BSSID in link identifier, not using MAC
3816 * header beacuse, there is cases in TDLS, there may be BSSID will not
3817 * be present in header
3818 */
3819 psessionEntry = peFindSessionByBssid(pMac,
3820 &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ;
3821 if(NULL == psessionEntry)
3822 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003823 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003824 ("no Session entry for TDLS session (bssid "
3825 MAC_ADDRESS_STR")"),
3826 MAC_ADDR_ARRAY(tdlsTeardown.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003827
3828 //VOS_ASSERT(0) ;
3829 return eSIR_FAILURE;
3830 }
3831
3832 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303833 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003834 &tdlsTeardown.LinkIdentifier.bssid[0],
3835 sizeof(tSirMacAddr)) ;
3836
3837
3838 if(!status)
3839 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003840 limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003841 VOS_ASSERT(0) ;
3842 return eSIR_FAILURE ;
3843 }
3844
3845 limTdlsFindLinkPeer(pMac,
3846 &tdlsTeardown.LinkIdentifier.InitStaAddr[0],
3847 &setupPeer) ;
3848
3849 if(NULL == setupPeer)
3850 {
3851 //ignore
3852 //VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003853 limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored") );
Kiran V1ccee932012-12-12 14:49:46 -08003854
3855 return eSIR_FAILURE ;
3856 }
3857 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003858 ("teardown for peer "MAC_ADDRESS_STR),
3859 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003860
3861 switch(tdlsTeardown.Reason.code)
3862 {
3863 case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON:
3864 {
3865 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003866 ("teardown with unspecified reason")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003867 break ;
3868 }
3869 case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
3870 {
3871 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003872 (" Teardown from AP, TDLS peer unreachable")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003873 break ;
3874 }
3875 default:
3876 {
3877 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003878 (" unknown teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003879 break ;
3880 }
3881 }
3882
3883 /* change TDLS peer State */
3884 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3885 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
3886
3887 do
3888 {
3889 tpDphHashNode pStaDs = NULL ;
3890
3891 /* tdls_hklee: send message to HAL before it is deleted, cause */
3892 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3893
3894 /* send del STA to remove context for this TDLS STA */
3895 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3896
3897 /* now send indication to SME-->HDD->TL to remove STA from TL */
3898
3899 if(pStaDs)
3900 {
3901 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3902 pStaDs, eSIR_SUCCESS) ;
3903
3904 /* send Teardown Ind to SME */
3905 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3906 eWNI_SME_TDLS_TEARDOWN_IND) ;
3907 /* remove node from setup list */
3908 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3909 }
3910
3911 }while(0) ;
3912
3913 return status ;
3914}
3915
3916/*
3917 * Common processing of TDLS action frames recieved
3918 */
3919void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd)
3920{
3921 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd);
3922 tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd))
3923 ? (( sizeof( eth_890d_header ))) :(0)) ;
3924
3925 tANI_U8 category = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ;
3926 tANI_U8 action = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ;
3927 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
3928 tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
3929 //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd);
3930
3931 if(category != SIR_MAC_ACTION_TDLS)
3932 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003933 limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored"), category );
Kiran V1ccee932012-12-12 14:49:46 -08003934 return ;
3935 }
3936
3937 frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003938 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 -08003939 action, limTraceTdlsActionString(action) ));
3940
3941 switch(action)
3942 {
3943
3944 case SIR_MAC_TDLS_SETUP_REQ:
3945 {
3946 limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ;
3947 break ;
3948 }
3949 case SIR_MAC_TDLS_SETUP_RSP:
3950 {
3951 limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ;
3952 break ;
3953 }
3954 case SIR_MAC_TDLS_SETUP_CNF:
3955 {
3956 limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ;
3957 break ;
3958 }
3959 case SIR_MAC_TDLS_TEARDOWN:
3960 {
3961 limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ;
3962 break ;
3963 }
3964 case SIR_MAC_TDLS_DIS_REQ:
3965 {
3966 limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ;
3967 break ;
3968 }
3969 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
3970 case SIR_MAC_TDLS_CH_SWITCH_REQ:
3971 case SIR_MAC_TDLS_CH_SWITCH_RSP:
3972 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
3973 default:
3974 {
3975 break ;
3976 }
3977 }
3978
3979 return ;
3980}
3981
3982/*
3983 * ADD sta for dis response fame sent on direct link
3984 */
3985static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
3986 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry)
3987{
3988 tpDphHashNode pStaDs = NULL ;
3989 tSirRetStatus status = eSIR_SUCCESS ;
3990 tANI_U16 aid = 0 ;
3991
3992 if(NULL == peerInfo)
3993 {
3994 VOS_ASSERT(0) ;
3995 return status ;
3996
3997 }
3998 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003999 ("ADD STA peer MAC: "MAC_ADDRESS_STR),
4000 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004001
4002
4003 if(NULL != dphLookupHashEntry(pMac, peerMac,
4004 &aid, &psessionEntry->dph.dphHashTable))
4005 {
4006 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004007 (" there is hash entry for this client")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004008 status = eSIR_FAILURE ;
4009 VOS_ASSERT(0) ;
4010 return status ;
4011 }
4012
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004013 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004014
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004015 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4016 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4017
Kiran V1ccee932012-12-12 14:49:46 -08004018 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4019
4020 if (pStaDs)
4021 {
4022 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4023 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4024 }
4025 pStaDs = dphAddHashEntry(pMac, peerMac, aid,
4026 &psessionEntry->dph.dphHashTable) ;
4027
4028 if(NULL == pStaDs)
4029 {
4030 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004031 (" add hash entry failed")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004032 status = eSIR_FAILURE ;
4033 VOS_ASSERT(0) ;
4034 return status;
4035 }
4036 if(eSIR_SUCCESS == status)
4037 {
4038#ifdef TDLS_RATE_DEBUG
4039 tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ;
4040 tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ;
4041 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004042 ("pSta DS [%p] "), pStaDs) ;
Kiran V1ccee932012-12-12 14:49:46 -08004043 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004044 ("peerInfo->tdlsPeerSuppRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004045 (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
4046 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004047 ("peerInfo->tdlsPeerExtRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004048 (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
4049 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004050 ("peerInfo->tdlsPeerPropRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004051 (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
4052 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004053 ("peerInfo->mcs = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004054 (tANI_U8 *)peerInfo->supportedMCSSet) ;
4055 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004056 ("num of supp rates = %02x"), suppRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004057 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004058 ("num of ext rates = %01x"), extRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004059#endif
4060
4061 /* Populate matching rate set */
4062#ifdef WLAN_FEATURE_11AC
4063 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4064 &peerInfo->tdlsPeerSuppRates,
4065 &peerInfo->tdlsPeerExtRates,
4066 peerInfo->supportedMCSSet,
4067 &pStaDs->mlmStaContext.propRateSet,
4068 psessionEntry, NULL))
4069#else
4070 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4071 &peerInfo->tdlsPeerSuppRates,
4072 &peerInfo->tdlsPeerExtRates,
4073 peerInfo->supportedMCSSet,
4074 &pStaDs->mlmStaContext.propRateSet,
4075 psessionEntry))
4076#endif
4077 {
4078 VOS_ASSERT(0) ;
4079 }
4080
4081
4082 pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304083 vos_mem_copy( pStaDs->staAddr, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08004084 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004085 ("Add STA for Peer: "MAC_ADDRESS_STR),
4086 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004087
4088
4089 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4090
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004091 status = limAddSta(pMac, pStaDs, false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004092
4093 if(eSIR_SUCCESS != status)
4094 {
4095 /* should not fail */
4096 VOS_ASSERT(0) ;
4097 }
4098 }
4099
4100 return status ;
4101}
4102#endif
4103/*
4104 * Add STA for TDLS setup procedure
4105 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004106static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
4107 tSirTdlsAddStaReq *pAddStaReq,
4108 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08004109{
4110 tpDphHashNode pStaDs = NULL ;
4111 tSirRetStatus status = eSIR_SUCCESS ;
4112 tANI_U16 aid = 0 ;
4113
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004114 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004115 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08004116 if(NULL == pStaDs)
4117 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004118 aid = limAssignPeerIdx(pMac, psessionEntry) ;
4119
4120 if( !aid )
4121 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004122 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004123 ("%s: No more free AID for peer " MAC_ADDRESS_STR),
4124 __func__, MAC_ADDR_ARRAY(pAddStaReq->peerMac)) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004125 return eSIR_FAILURE;
4126 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004127
4128 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4129 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4130
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004131 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004132 ("limTdlsSetupAddSta: Aid = %d, for peer =" MAC_ADDRESS_STR),
4133 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004134 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4135
4136 if (pStaDs)
4137 {
4138 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4139 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4140 }
4141
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004142 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004143 &psessionEntry->dph.dphHashTable) ;
4144
4145 if(NULL == pStaDs)
4146 {
4147 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004148 (" add hash entry failed")) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004149 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004150 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004151 }
Kiran V1ccee932012-12-12 14:49:46 -08004152 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004153
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004154 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004155
4156 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4157
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004158 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004159
4160 if(eSIR_SUCCESS != status)
4161 {
4162 /* should not fail */
4163 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004164 }
Kiran V1ccee932012-12-12 14:49:46 -08004165 return status ;
4166}
4167
4168/*
4169 * Del STA, after Link is teardown or discovery response sent on direct link
4170 */
4171static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4172 tpPESession psessionEntry)
4173{
4174 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004175 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08004176 tpDphHashNode pStaDs = NULL ;
4177
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004178 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08004179 &psessionEntry->dph.dphHashTable) ;
4180
4181 if(pStaDs)
4182 {
4183
4184 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004185 ("DEL STA peer MAC: "MAC_ADDRESS_STR),
4186 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004187
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004188 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004189 ("limTdlsDelSta: STA type = %x, sta idx = %x"),pStaDs->staType,
Kiran V1ccee932012-12-12 14:49:46 -08004190 pStaDs->staIndex) ;
4191
4192 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08004193#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -08004194 if(eSIR_SUCCESS == status)
4195 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004196 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ;
4197 limReleasePeerIdx(pMac, peerIdx, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004198 }
4199 else
4200 {
4201 VOS_ASSERT(0) ;
4202 }
Hoonki Leef63df0d2013-01-16 19:29:14 -08004203#endif
Kiran V1ccee932012-12-12 14:49:46 -08004204 }
4205
4206 return pStaDs ;
4207}
4208
4209#ifdef FEATURE_WLAN_TDLS_INTERNAL
4210/*
4211* Prepare link establish message for HAL, construct PTI template.
4212*
4213*/
4214static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4215{
4216 tANI_U8 pFrame[64] ;
4217 tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ;
4218 tANI_U32 status = 0 ;
4219 tANI_U32 nPayload = 0 ;
4220 tANI_U32 nBytes = 0 ;
4221 tANI_U32 header_offset = 0 ;
4222 tANI_U16 aid = 0 ;
4223 tDphHashNode *pStaDs = NULL ;
4224 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4225 tpPESession psessionEntry = NULL ;
4226
4227
4228 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4229 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004230 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4231 ("limTdlsLinkEstablish: cannot find peer mac "
4232 "in tdls linksetup list: "MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -08004233 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004234 return eSIR_FAILURE;
4235 }
4236
4237 psessionEntry = peFindSessionBySessionId(pMac,
4238 setupPeer->tdls_sessionId) ;
4239
4240 if(NULL == psessionEntry)
4241 {
4242 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004243 ("limTdlsLinkEstablish: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004244 VOS_ASSERT(0) ;
4245 return eHAL_STATUS_FAILURE;
4246 }
4247
Kiet Lam842dad02014-02-18 18:44:02 -08004248
Kiran V1ccee932012-12-12 14:49:46 -08004249 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
4250 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004251 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4252 ("limTdlsLinkEstablish: cannot find peer mac "
4253 "in tdls linksetup list: "MAC_ADDRESS_STR),
4254 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004255 return eSIR_FAILURE;
4256 }
4257
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304258 vos_mem_set( ( tANI_U8* )&tdlsPtiTemplate,
4259 sizeof( tDot11fTDLSPeerTrafficInd ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004260
4261 /*
4262 * setup Fixed fields,
4263 */
4264 tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS;
4265 tdlsPtiTemplate.Action.action = SIR_MAC_TDLS_PEER_TRAFFIC_IND;
4266 tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */
4267#if 1
4268 /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address,
4269 then below code makes such an way */
4270 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4271 peerMac, !setupPeer->tdls_bIsResponder) ;
4272#else
4273 /* below code will make PTI's linkIdentifier's initiator address be selfAddr */
4274 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4275 peerMac, TDLS_INITIATOR) ;
4276#endif
4277
4278 /* PUBufferStatus will be filled by firmware at the time of transmission */
4279 tdlsPtiTemplate.PUBufferStatus.present = 1;
4280
4281 /* TODO: get ExtendedCapabilities IE */
4282
4283 /*
4284 * now we pack it. First, how much space are we going to need?
4285 */
4286 status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload);
4287 if ( DOT11F_FAILED( status ) )
4288 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004289 limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004290 /* We'll fall back on the worst case scenario: */
4291 nPayload = sizeof( tdlsPtiTemplate );
4292 }
4293 else if ( DOT11F_WARNED( status ) )
4294 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004295 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 -08004296 }
4297
4298 /*
4299 * This frame is going out from PE as data frames with special ethertype
4300 * 89-0d.
4301 * 8 bytes of RFC 1042 header
4302 */
4303
4304 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
4305 + sizeof( eth_890d_header )
4306 + PAYLOAD_TYPE_TDLS_SIZE ;
4307
4308 if(nBytes > 64) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004309 limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64."), nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08004310 nBytes = 64;
4311 }
4312 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304313 vos_mem_set( pFrame, sizeof(pFrame), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004314
4315 /* fill out the buffer descriptor */
4316
4317 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
4318 LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ;
4319
4320 status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame
4321 + header_offset, nPayload, &nPayload );
4322
4323 if ( DOT11F_FAILED( status ) )
4324 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004325 limLog( pMac, LOGE, FL("Failed to pack a PTI template (0x%08x)."),
4326 status );
Kiran V1ccee932012-12-12 14:49:46 -08004327 return eSIR_FAILURE;
4328 }
4329 else if ( DOT11F_WARNED( status ) )
4330 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004331 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
4332 "Peer Traffic Indication (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004333 }
4334
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004335 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 -08004336 setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET));
4337
4338 limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder,
4339 header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET,
4340 nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps);
4341
4342 return eSIR_SUCCESS;
4343}
4344
4345/*
4346* Prepare link teardown message for HAL from peer_mac
4347*
4348*/
4349static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4350{
4351 tDphHashNode *pStaDs = NULL ;
4352 tANI_U16 aid = 0 ;
4353 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4354 tpPESession psessionEntry = NULL ;
4355
4356
4357 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4358 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004359 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4360 ("limTdlsLinkTeardown: cannot find peer mac "
4361 "in tdls linksetup list: "
4362 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004363 return eSIR_FAILURE;
4364 }
4365
4366 psessionEntry = peFindSessionBySessionId(pMac,
4367 setupPeer->tdls_sessionId) ;
4368
4369 if(NULL == psessionEntry)
4370 {
4371 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004372 ("limTdlsLinkTeardown: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004373 VOS_ASSERT(0) ;
4374 return eHAL_STATUS_FAILURE;
4375 }
4376
4377
Kiet Lam842dad02014-02-18 18:44:02 -08004378
Kiran V1ccee932012-12-12 14:49:46 -08004379 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
4380
4381 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004382 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4383 ("limTdlsLinkTeardown: cannot find peer mac "
4384 "in hash table: "
4385 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004386 return eSIR_FAILURE;
4387 }
4388
4389 limSendTdlsLinkTeardown(pMac, pStaDs->staIndex);
4390
4391 return eSIR_SUCCESS;
4392}
4393
4394/*
4395 * Prepare Discovery RSP message for SME, collect peerINfo for all the
4396 * peers discovered and delete/clean discovery lists in PE.
4397 */
4398
4399static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac,
4400 tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount)
4401{
4402 tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp);
4403 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4404
4405 /*
4406 * allocate memory for tdls discovery response, allocated memory should
4407 * be alloc_mem = tdlsStaCount * sizeof(peerinfo)
4408 * + siezeof tSirTdlsDisRsp.
4409 */
4410 disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo));
4411
4412 /* now allocate memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304413
4414 disRsp = vos_mem_malloc(disMsgRspSize);
4415 if ( NULL == disRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004416 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304417 limLog(pMac, LOGP, FL("AllocateMemory failed for DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004418 return NULL ;
4419 }
4420
4421 if(disStaCount)
4422 {
4423 tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ;
4424 tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ;
4425
4426 tLimDisResultList *currentNode = tdlsDisRspList ;
4427 while(tdlsDisRspList != NULL)
4428 {
4429
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304430 vos_mem_copy( (tANI_U8 *)peerInfo,
Kiran V1ccee932012-12-12 14:49:46 -08004431 (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo,
4432 sizeof(tSirTdlsPeerInfo));
4433
4434 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004435 ("Msg Sent to PE, peer MAC: "MAC_ADDRESS_STR),
4436 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004437 disStaCount-- ;
4438 peerInfo++ ;
4439 currentNode = tdlsDisRspList ;
4440 tdlsDisRspList = tdlsDisRspList->next ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304441 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08004442 /* boundary condition check, may be fatal */
4443 if(((!disStaCount) && (tdlsDisRspList))
4444 || ((!tdlsDisRspList) && disStaCount))
4445 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004446 limLog(pMac, LOG1, FL("mismatch in dis sta count and "
4447 "number of nodes in list")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004448 VOS_ASSERT(0) ;
4449 return NULL ;
4450 }
4451 } /* end of while */
4452
4453 /* All discovery STA processed */
4454 pMac->lim.gLimTdlsDisResultList = NULL ;
4455
4456 } /* end of if dis STA count */
4457
4458 return (disRsp) ;
4459}
4460
4461/* Send Teardown response back to PE */
4462
4463void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4464 tSirMacAddr peerMac, tANI_U16 msgType)
4465{
4466 tSirMsgQ mmhMsg = {0} ;
4467 tSirTdlsTeardownRsp *teardownRspMsg = NULL ;
4468 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4469
4470 mmhMsg.type = msgType ;
4471
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304472 teardownRspMsg = vos_mem_malloc(sizeof(tSirTdlsTeardownRsp));
4473 if ( NULL == teardownRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004474 {
4475 VOS_ASSERT(0) ;
4476 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304477 vos_mem_copy( teardownRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004478 sizeof(tSirMacAddr)) ;
4479 teardownRspMsg->statusCode = statusCode ;
4480 mmhMsg.bodyptr = teardownRspMsg ;
4481 mmhMsg.bodyval = 0;
4482 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4483
4484 return ;
4485
4486}
4487
4488/*
4489 * Send Link start RSP back to SME after link is setup or failed
4490 */
4491void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac,
4492 tSirResultCodes statusCode,
4493 tSirMacAddr peerMac,
4494 tANI_U16 msgType)
4495{
4496 tSirMsgQ mmhMsg = {0} ;
4497 tSirTdlsLinksetupRsp *setupRspMsg = NULL ;
4498 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4499
4500 mmhMsg.type = msgType ;
4501
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304502 setupRspMsg = vos_mem_malloc(sizeof(tSirTdlsLinksetupRsp));
4503 if ( NULL == setupRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004504 {
4505 VOS_ASSERT(0) ;
4506 }
4507
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304508 vos_mem_copy( setupRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004509 sizeof(tSirMacAddr)) ;
4510 setupRspMsg->statusCode = statusCode ;
4511 mmhMsg.bodyptr = setupRspMsg ;
4512 mmhMsg.bodyval = 0;
4513 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4514
4515 return ;
4516}
4517
4518/*
4519 * Send TDLS discovery RSP back to SME
4520 */
4521void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4522 tANI_U16 msgType)
4523{
4524 tSirMsgQ mmhMsg = {0} ;
4525 tSirTdlsDisRsp *tdlsDisRsp = NULL ;
4526
4527 mmhMsg.type = msgType ;
4528
4529 if(eSIR_SME_SUCCESS == statusCode)
4530 {
4531 tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ;
4532
4533 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004534 ("no of TDLS STA discovered: %d"), tdlsStaCount) ;
Kiran V1ccee932012-12-12 14:49:46 -08004535 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
4536
4537 if(tdlsDisRsp)
4538 {
4539 tdlsDisRsp->numDisSta = tdlsStaCount ;
4540 }
4541 else
4542 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004543 limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004544 VOS_ASSERT(0) ;
4545 return ;
4546 }
4547 /* all Discovery STA is processed */
4548 pMac->lim.gLimTdlsDisStaCount = 0 ;
4549 }
4550 else
4551 {
4552 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ;
4553 }
4554
4555 tdlsDisRsp->statusCode = statusCode ;
4556 mmhMsg.bodyptr = tdlsDisRsp ;
4557 mmhMsg.bodyval = 0;
4558 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4559
4560 return ;
4561}
4562
4563/*
4564 * Once Link is setup with PEER, send Add STA ind to SME
4565 */
4566static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac,
4567 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4568{
4569 tSirMsgQ mmhMsg = {0} ;
4570 tSirTdlsPeerInd *peerInd = NULL ;
4571 mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304572
4573 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4574 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004575 {
4576 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4577 return eSIR_FAILURE;
4578 }
4579
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304580 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004581 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4582 peerInd->sessionId = sessionId;
4583 peerInd->staId = pStaDs->staIndex ;
4584 peerInd->ucastSig = pStaDs->ucUcastSig ;
4585 peerInd->bcastSig = pStaDs->ucBcastSig ;
4586 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4587
4588 mmhMsg.bodyptr = peerInd ;
4589 mmhMsg.bodyval = 0;
4590 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4591
4592 return eSIR_SUCCESS ;
4593
4594}
4595
4596/*
4597 * Once link is teardown, send Del Peer Ind to SME
4598 */
4599static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
4600 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4601{
4602 tSirMsgQ mmhMsg = {0} ;
4603 tSirTdlsPeerInd *peerInd = NULL ;
4604 mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304605
4606 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4607 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004608 {
4609 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4610 return eSIR_FAILURE;
4611 }
4612
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304613 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004614 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4615 peerInd->sessionId = sessionId;
4616 peerInd->staId = pStaDs->staIndex ;
4617 peerInd->ucastSig = pStaDs->ucUcastSig ;
4618 peerInd->bcastSig = pStaDs->ucBcastSig ;
4619 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4620
4621 mmhMsg.bodyptr = peerInd ;
4622
4623 //peerInd->statusCode = status ;
4624 mmhMsg.bodyval = 0;
4625 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4626 return eSIR_SUCCESS ;
4627
4628}
4629
4630/*
4631 * Send Link setup Ind to SME, This is the case where, link setup is
4632 * initiated by peer STA
4633 */
4634static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
4635 tSirMacAddr peerMac, tANI_U8 status)
4636{
4637 tSirMsgQ mmhMsg = {0} ;
4638 tSirTdlsLinkSetupInd *setupInd = NULL ;
4639
4640 mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304641 setupInd = vos_mem_malloc(sizeof(tSirTdlsLinkSetupInd));
4642 if ( NULL == setupInd )
Kiran V1ccee932012-12-12 14:49:46 -08004643 {
4644 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4645 return eSIR_FAILURE;
4646 }
4647
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304648 vos_mem_copy( setupInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004649 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4650 setupInd->length = sizeof(tSirTdlsLinkSetupInd);
4651 setupInd->statusCode = status ;
4652 mmhMsg.bodyptr = setupInd ;
4653 mmhMsg.bodyval = 0;
4654 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4655
4656 return eSIR_SUCCESS ;
4657
4658}
4659
4660/*
4661 * Setup RSP timer handler
4662 */
4663void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4664{
4665
4666 tANI_U32 statusCode;
4667 tSirMsgQ msg;
4668 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4669
4670 /* Prepare and post message to LIM Message Queue */
4671
4672 msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT;
4673 msg.bodyptr = NULL ;
4674 msg.bodyval = timerId ;
4675
4676 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4677 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004678 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004679 msg.type, statusCode);
4680 return ;
4681}
4682
4683/*
4684 * Link setup CNF timer
4685 */
4686void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4687{
4688
4689 tANI_U32 statusCode;
4690 tSirMsgQ msg;
4691 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4692
4693 // Prepare and post message to LIM Message Queue
4694
4695 msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT;
4696 msg.bodyptr = NULL ;
4697 msg.bodyval = timerId ;
4698
4699 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4700 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004701 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004702 msg.type, statusCode);
4703 return ;
4704}
4705
4706/*
4707 * start TDLS timer
4708 */
4709void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer,
4710 tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg)
4711{
4712 tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4713 ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT
4714 : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ;
4715
4716 void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4717 ? (limTdlsLinkSetupRspTimerHandler)
4718 : limTdlsLinkSetupCnfTimerHandler ;
4719
4720 /* TODO: Read timer vals from CFG */
4721
4722 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4723 /*
4724 * create TDLS discovery response wait timer and activate it
4725 */
4726 if (tx_timer_create(timer, "TDLS link setup timers", timerFunc,
4727 timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS)
4728 {
4729 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004730 FL("could not create TDLS discovery response wait timer"));
Kiran V1ccee932012-12-12 14:49:46 -08004731 return;
4732 }
4733
4734 //assign appropriate sessionId to the timer object
4735 timer->sessionId = sessionId;
4736
4737 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4738 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4739 if (tx_timer_activate(timer) != TX_SUCCESS)
4740 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004741 limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!"));
Kiran V1ccee932012-12-12 14:49:46 -08004742 return ;
4743 }
4744
4745 return ;
4746
4747}
4748#endif
4749
4750/*
4751 * Once Link is setup with PEER, send Add STA ind to SME
4752 */
4753static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004754 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
4755 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08004756{
4757 tSirMsgQ mmhMsg = {0} ;
4758 tSirTdlsAddStaRsp *addStaRsp = NULL ;
4759 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304760
4761 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
4762 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004763 {
4764 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4765 return eSIR_FAILURE;
4766 }
4767
4768 addStaRsp->sessionId = sessionId;
4769 addStaRsp->statusCode = status;
4770 if( pStaDs )
4771 {
4772 addStaRsp->staId = pStaDs->staIndex ;
4773 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
4774 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
4775 }
4776 if( peerMac )
4777 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304778 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004779 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4780 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004781 if (updateSta)
4782 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
4783 else
4784 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
4785
Kiran V1ccee932012-12-12 14:49:46 -08004786 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
4787 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
4788
4789 mmhMsg.bodyptr = addStaRsp;
4790 mmhMsg.bodyval = 0;
4791 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4792
4793 return eSIR_SUCCESS ;
4794
4795}
4796/*
4797 * STA RSP received from HAL
4798 */
4799eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
4800 tpPESession psessionEntry)
4801{
4802 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
4803 tANI_U8 status = eSIR_SUCCESS ;
4804 tDphHashNode *pStaDs = NULL ;
4805 tANI_U16 aid = 0 ;
4806
4807 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004808 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Arif Hussain24bafea2013-11-15 15:10:03 -08004809 ("limTdlsAddStaRsp: staIdx=%d, staMac="MAC_ADDRESS_STR), pAddStaParams->staIdx,
4810 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08004811
4812 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
4813 {
4814 VOS_ASSERT(0) ;
4815 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004816 ("Add sta failed ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004817 status = eSIR_FAILURE;
4818 goto add_sta_error;
4819 }
4820
4821 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
4822 &psessionEntry->dph.dphHashTable);
4823 if(NULL == pStaDs)
4824 {
4825 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004826 ("pStaDs is NULL ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004827 status = eSIR_FAILURE;
4828 goto add_sta_error;
4829 }
4830
4831 pStaDs->bssId = pAddStaParams->bssIdx;
4832 pStaDs->staIndex = pAddStaParams->staIdx;
4833 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
4834 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
4835 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4836 pStaDs->valid = 1 ;
4837#ifdef FEATURE_WLAN_TDLS_INTERNAL
4838 status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId,
4839 pStaDs, eSIR_SUCCESS ) ;
4840 if(eSIR_FAILURE == status)
4841 {
4842 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004843 ("Peer IND msg to SME failed")) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304844 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004845 return eSIR_FAILURE ;
4846 }
4847
4848 /*
4849 * Now, there is two things a) ADD STA RSP for ADD STA request sent
4850 * after recieving discovery request from Peer.
4851 * now we have to send discovery response, if there is any pending
4852 * discovery equest..
4853 */
4854 do
4855 {
4856 tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac,
4857 pAddStaParams->staMac) ;
4858
4859
4860 if(peerInfo)
4861 {
4862 /*
4863 * send TDLS discovery response frame on direct link, state machine
4864 * is rolling.., once discovery response is get Acked, we will
4865 * send response to SME based on TxComplete callback results
4866 */
4867 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
4868 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
4869 }
4870 } while(0) ;
Kiran V1ccee932012-12-12 14:49:46 -08004871#endif
4872add_sta_error:
4873 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004874 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304875 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004876 return status ;
4877}
4878
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304879void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
4880 tpPESession psessionEntry,
4881 tDot11fIESuppChannels *suppChannels,
4882 tDot11fIESuppOperatingClasses *suppOperClasses)
4883{
4884 tANI_U32 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4885 tANI_U8 validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4886 tANI_U8 i;
4887 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
4888 validChan, &numChans) != eSIR_SUCCESS)
4889 {
4890 /**
4891 * Could not get Valid channel list from CFG.
4892 * Log error.
4893 */
4894 limLog(pMac, LOGP,
4895 FL("could not retrieve Valid channel list"));
4896 }
4897 suppChannels->num_bands = (tANI_U8) numChans;
4898
4899 for ( i = 0U; i < suppChannels->num_bands; i++)
4900 {
4901 suppChannels->bands[i][0] = validChan[i];
4902 suppChannels->bands[i][1] = 1;
4903 }
4904 suppChannels->present = 1 ;
4905 return ;
4906}
4907
4908
Kiran V1ccee932012-12-12 14:49:46 -08004909/*
4910 * FUNCTION: Populate Link Identifier element IE
4911 *
4912 */
4913
4914
4915void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
4916 tDot11fIELinkIdentifier *linkIden,
4917 tSirMacAddr peerMac, tANI_U8 reqType)
4918{
4919 //tANI_U32 size = sizeof(tSirMacAddr) ;
4920 tANI_U8 *initStaAddr = NULL ;
4921 tANI_U8 *respStaAddr = NULL ;
4922
4923 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
4924 (respStaAddr = linkIden->RespStaAddr))
4925 : ((respStaAddr = linkIden->InitStaAddr ),
4926 (initStaAddr = linkIden->RespStaAddr)) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304927 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08004928 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
4929
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304930 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08004931 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
4932
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304933 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004934 sizeof( tSirMacAddr ));
4935
4936 linkIden->present = 1 ;
4937 return ;
4938
4939}
4940
4941void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
4942 tDot11fIEExtCap *extCapability)
4943{
4944 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05304945 extCapability->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304946 extCapability->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
Kiran V1ccee932012-12-12 14:49:46 -08004947 extCapability->TDLSSupport = TDLS_SUPPORT ;
4948 extCapability->TDLSProhibited = TDLS_PROHIBITED ;
4949 extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
4950 extCapability->present = 1 ;
4951 return ;
4952}
4953
4954#ifdef FEATURE_WLAN_TDLS_INTERNAL
4955/*
4956 * Public Action frame common processing
4957 * This Function will be moved/merged to appropriate place
4958 * once other public action frames (particularly 802.11k)
4959 * is in place
4960 */
4961void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd,
4962 tpPESession psessionEntry)
4963{
4964 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
4965 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ;
4966 tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ;
4967
4968 limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ;
4969 return ;
4970}
4971
4972eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac,
4973 tLimTdlsLinkSetupInfo *linkSetupInfo,
4974 tANI_U8 dialog, tSirMacAddr peerMac,
4975 tpPESession psessionEntry)
4976{
4977 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4978
4979 /*
4980 * we allocate the TDLS setup Peer Memory here, we will free'd this
4981 * memory after teardown, if the link is successfully setup or
4982 * free this memory if any timeout is happen in link setup procedure
4983 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304984
4985 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
4986 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08004987 {
4988 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004989 FL( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08004990 VOS_ASSERT(0) ;
4991 return eSIR_MEM_ALLOC_FAILED;
4992 }
4993 setupPeer->dialog = dialog ;
4994 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
4995 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
4996
4997 /* TDLS_sessionize: remember sessionId for future */
4998 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
4999 setupPeer->tdls_bIsResponder = 1;
5000
5001 /*
5002 * we only populate peer MAC, so it can assit us to find the
5003 * TDLS peer after response/or after response timeout
5004 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305005 vos_mem_copy(setupPeer->peerMac, peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005006 sizeof(tSirMacAddr)) ;
5007 /* format TDLS discovery request frame and transmit it */
5008 limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ;
5009
5010 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5011 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5012 (tANI_U32)setupPeer->peerMac,
5013 WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5014 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5015 /* update setup peer list */
5016 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5017 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5018
5019 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to
5020 * SME later when TDLS setup cnf TX complete is successful. --> see
5021 * limTdlsSetupCnfTxComplete()
5022 */
5023 return eSIR_SUCCESS ;
5024}
5025#endif
5026
5027/*
5028 * Process Send Mgmt Request from SME and transmit to AP.
5029 */
5030tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
5031 tANI_U32 *pMsgBuf)
5032{
5033 /* get all discovery request parameters */
5034 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
5035 tpPESession psessionEntry;
5036 tANI_U8 sessionId;
5037 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
5038
5039 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005040 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005041
5042 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
5043 == NULL)
5044 {
5045 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005046 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005047 pSendMgmtReq->sessionId);
5048 goto lim_tdls_send_mgmt_error;
5049 }
5050
5051 /* check if we are in proper state to work as TDLS client */
5052 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5053 {
5054 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005055 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005056 psessionEntry->limSystemRole);
5057 goto lim_tdls_send_mgmt_error;
5058 }
5059
5060 /*
5061 * if we are still good, go ahead and check if we are in proper state to
5062 * do TDLS discovery req/rsp/....frames.
5063 */
5064 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5065 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5066 {
5067
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005068 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5069 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005070 goto lim_tdls_send_mgmt_error;
5071 }
5072
5073 switch( pSendMgmtReq->reqType )
5074 {
5075 case SIR_MAC_TDLS_DIS_REQ:
5076 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005077 "Transmit Discovery Request Frame") ;
Kiran V1ccee932012-12-12 14:49:46 -08005078 /* format TDLS discovery request frame and transmit it */
5079 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
5080 psessionEntry) ;
5081 resultCode = eSIR_SME_SUCCESS;
5082 break;
5083 case SIR_MAC_TDLS_DIS_RSP:
5084 {
5085 //Send a response mgmt action frame
5086 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
5087 pSendMgmtReq->dialog, psessionEntry) ;
5088 resultCode = eSIR_SME_SUCCESS;
5089 }
5090 break;
5091 case SIR_MAC_TDLS_SETUP_REQ:
5092 {
5093 limSendTdlsLinkSetupReqFrame(pMac,
5094 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
5095 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5096 resultCode = eSIR_SME_SUCCESS;
5097 }
5098 break;
5099 case SIR_MAC_TDLS_SETUP_RSP:
5100 {
5101 limSendTdlsSetupRspFrame(pMac,
5102 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
5103 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5104 resultCode = eSIR_SME_SUCCESS;
5105 }
5106 break;
5107 case SIR_MAC_TDLS_SETUP_CNF:
5108 {
5109 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
5110 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5111 resultCode = eSIR_SME_SUCCESS;
5112 }
5113 break;
5114 case SIR_MAC_TDLS_TEARDOWN:
5115 {
5116 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08005117 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08005118 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5119 resultCode = eSIR_SME_SUCCESS;
5120 }
5121 break;
5122 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
5123 {
5124 }
5125 break;
5126 case SIR_MAC_TDLS_CH_SWITCH_REQ:
5127 {
5128 }
5129 break;
5130 case SIR_MAC_TDLS_CH_SWITCH_RSP:
5131 {
5132 }
5133 break;
5134 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
5135 {
5136 }
5137 break;
5138 default:
5139 break;
5140 }
5141
5142lim_tdls_send_mgmt_error:
5143
5144 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
5145 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
5146
5147 return eSIR_SUCCESS;
5148}
5149
5150/*
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305151 * Send Response to Link Establish Request to SME
5152 */
5153void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
5154 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5155 tANI_U8 status)
5156{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305157 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305158
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305159 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305160
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305161 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
5162 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305163 {
5164 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305165 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305166 }
5167 pTdlsLinkEstablishReqRsp->statusCode = status ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305168 if ( peerMac )
5169 {
5170 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
5171 }
5172 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305173 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305174 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305175 mmhMsg.bodyval = 0;
5176 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5177 return ;
5178
5179
5180}
5181
5182/*
Kiran V1ccee932012-12-12 14:49:46 -08005183 * Once link is teardown, send Del Peer Ind to SME
5184 */
5185static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
5186 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5187 tANI_U8 status)
5188{
5189 tSirMsgQ mmhMsg = {0} ;
5190 tSirTdlsDelStaRsp *pDelSta = NULL ;
5191 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305192
5193 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
5194 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08005195 {
5196 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
5197 return eSIR_FAILURE;
5198 }
5199
5200 pDelSta->sessionId = sessionId;
5201 pDelSta->statusCode = status ;
5202 if( pStaDs )
5203 {
5204 pDelSta->staId = pStaDs->staIndex ;
5205 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005206 else
5207 pDelSta->staId = HAL_STA_INVALID_IDX;
5208
Kiran V1ccee932012-12-12 14:49:46 -08005209 if( peerMac )
5210 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305211 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08005212 }
5213
5214 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
5215 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
5216
5217 mmhMsg.bodyptr = pDelSta;
5218
5219 mmhMsg.bodyval = 0;
5220 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5221 return eSIR_SUCCESS ;
5222
5223}
5224
5225/*
5226 * Process Send Mgmt Request from SME and transmit to AP.
5227 */
5228tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
5229 tANI_U32 *pMsgBuf)
5230{
5231 /* get all discovery request parameters */
5232 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
5233 tpPESession psessionEntry;
5234 tANI_U8 sessionId;
Kiran V1ccee932012-12-12 14:49:46 -08005235
5236 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005237 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005238
5239 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
5240 == NULL)
5241 {
5242 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005243 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005244 pAddStaReq->sessionId);
5245 goto lim_tdls_add_sta_error;
5246 }
5247
5248 /* check if we are in proper state to work as TDLS client */
5249 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5250 {
5251 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005252 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005253 psessionEntry->limSystemRole);
5254 goto lim_tdls_add_sta_error;
5255 }
5256
5257 /*
5258 * if we are still good, go ahead and check if we are in proper state to
5259 * do TDLS discovery req/rsp/....frames.
5260 */
5261 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5262 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5263 {
5264
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005265 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5266 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005267 goto lim_tdls_add_sta_error;
5268 }
5269
5270 pMac->lim.gLimAddStaTdls = true ;
5271
5272 /* To start with, send add STA request to HAL */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005273 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08005274 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005275 limLog(pMac, LOGE, "%s: Add TDLS Station request failed ", __func__);
Kiran V1ccee932012-12-12 14:49:46 -08005276 goto lim_tdls_add_sta_error;
5277 }
5278 return eSIR_SUCCESS;
5279lim_tdls_add_sta_error:
5280 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005281 pAddStaReq->sessionId, pAddStaReq->peerMac,
5282 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08005283
5284 return eSIR_SUCCESS;
5285}
5286/*
5287 * Process Del Sta Request from SME .
5288 */
5289tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
5290 tANI_U32 *pMsgBuf)
5291{
5292 /* get all discovery request parameters */
5293 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
5294 tpPESession psessionEntry;
5295 tANI_U8 sessionId;
5296 tpDphHashNode pStaDs = NULL ;
5297
5298 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005299 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005300
5301 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
5302 == NULL)
5303 {
5304 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005305 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005306 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005307 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005308 NULL, eSIR_FAILURE) ;
5309 return eSIR_FAILURE;
5310 }
5311
5312 /* check if we are in proper state to work as TDLS client */
5313 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5314 {
5315 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005316 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005317 psessionEntry->limSystemRole);
5318 goto lim_tdls_del_sta_error;
5319 }
5320
5321 /*
5322 * if we are still good, go ahead and check if we are in proper state to
5323 * do TDLS discovery req/rsp/....frames.
5324 */
5325 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5326 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5327 {
5328
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005329 limLog(pMac, LOGE, "Del Sta received in invalid LIMsme state (%d)",
5330 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005331 goto lim_tdls_del_sta_error;
5332 }
5333
5334 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
5335
5336 /* now send indication to SME-->HDD->TL to remove STA from TL */
5337
5338 if(pStaDs)
5339 {
5340 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5341 pStaDs, eSIR_SUCCESS) ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005342 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08005343
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005344 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
5345 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005346 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
5347
Kiran V1ccee932012-12-12 14:49:46 -08005348 return eSIR_SUCCESS;
5349
5350 }
5351
5352lim_tdls_del_sta_error:
5353 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5354 NULL, eSIR_FAILURE) ;
5355
5356 return eSIR_SUCCESS;
5357}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005358
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305359/* Intersects the two input arrays and outputs an array */
5360/* For now the array length of tANI_U8 suffices */
5361static void limTdlsGetIntersection(tANI_U8 *input_array1,tANI_U8 input1_length,
5362 tANI_U8 *input_array2,tANI_U8 input2_length,
5363 tANI_U8 *output_array,tANI_U8 *output_length)
5364{
5365 tANI_U8 i,j,k=0,flag=0;
5366 for(i=0;i<input1_length;i++)
5367 {
5368 flag=0;
5369 for(j=0;j<input2_length;j++)
5370 {
5371 if(input_array1[i]==input_array2[j])
5372 {
5373 flag=1;
5374 break;
5375 }
5376 }
5377 if(flag==1)
5378 {
5379 output_array[k]=input_array1[i];
5380 k++;
5381 }
5382 }
5383 *output_length = k;
5384}
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305385/*
5386 * Process Link Establishment Request from SME .
5387 */
5388tSirRetStatus limProcesSmeTdlsLinkEstablishReq(tpAniSirGlobal pMac,
5389 tANI_U32 *pMsgBuf)
5390{
5391 /* get all discovery request parameters */
5392 tSirTdlsLinkEstablishReq *pTdlsLinkEstablishReq = (tSirTdlsLinkEstablishReq*) pMsgBuf ;
5393 tpPESession psessionEntry;
5394 tANI_U8 sessionId;
5395 tpTdlsLinkEstablishParams pMsgTdlsLinkEstablishReq;
5396 tSirMsgQ msg;
5397 tANI_U16 peerIdx = 0 ;
5398 tpDphHashNode pStaDs = NULL ;
5399
5400 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005401 ("Send Mgmt Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305402
5403 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
5404 == NULL)
5405 {
5406 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005407 "PE Session does not exist for given sme sessionId %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305408 pTdlsLinkEstablishReq->sessionId);
5409 limSendSmeTdlsLinkEstablishReqRsp(pMac, pTdlsLinkEstablishReq->sessionId, pTdlsLinkEstablishReq->peerMac,
5410 NULL, eSIR_FAILURE) ;
5411 return eSIR_FAILURE;
5412 }
5413
5414 /* check if we are in proper state to work as TDLS client */
5415 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5416 {
5417 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005418 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305419 psessionEntry->limSystemRole);
5420 goto lim_tdls_link_establish_error;
5421 }
5422
5423 /*
5424 * if we are still good, go ahead and check if we are in proper state to
5425 * do TDLS discovery req/rsp/....frames.
5426 */
5427 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5428 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5429 {
5430
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005431 limLog(pMac, LOGE, "TDLS Link Establish Request received in "
5432 "invalid LIMsme state (%d)", psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305433 goto lim_tdls_link_establish_error;
5434 }
5435 /*TODO Sunil , TDLSPeer Entry has the STA ID , Use it */
5436 pStaDs = dphLookupHashEntry(pMac, pTdlsLinkEstablishReq->peerMac, &peerIdx,
5437 &psessionEntry->dph.dphHashTable) ;
5438 if ( NULL == pStaDs )
5439 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005440 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305441 goto lim_tdls_link_establish_error;
5442
5443 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305444 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
5445 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305446 {
5447 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005448 FL( "Unable to allocate memory TDLS Link Establish Request" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305449 return eSIR_MEM_ALLOC_FAILED;
5450 }
5451
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305452 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tpTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305453
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05305454 pMsgTdlsLinkEstablishReq->staIdx = pStaDs->staIndex;
5455 pMsgTdlsLinkEstablishReq->isResponder = pTdlsLinkEstablishReq->isResponder;
5456 pMsgTdlsLinkEstablishReq->uapsdQueues = pTdlsLinkEstablishReq->uapsdQueues;
5457 pMsgTdlsLinkEstablishReq->maxSp = pTdlsLinkEstablishReq->maxSp;
5458 pMsgTdlsLinkEstablishReq->isBufsta = pTdlsLinkEstablishReq->isBufSta;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305459 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
5460 pTdlsLinkEstablishReq->isOffChannelSupported;
5461 pMsgTdlsLinkEstablishReq->isOffChannelSupported = 1;
5462
5463 if ( 0 != pTdlsLinkEstablishReq->supportedChannelsLen)
5464 {
5465 tANI_U32 selfNumChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5466 tANI_U8 selfSupportedChannels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5467 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
5468 selfSupportedChannels, &selfNumChans) != eSIR_SUCCESS)
5469 {
5470 /**
5471 * Could not get Valid channel list from CFG.
5472 * Log error.
5473 */
5474 limLog(pMac, LOGP,
5475 FL("could not retrieve Valid channel list"));
5476 }
5477 limTdlsGetIntersection(selfSupportedChannels, selfNumChans,
5478 pTdlsLinkEstablishReq->supportedChannels,
5479 pTdlsLinkEstablishReq->supportedChannelsLen,
5480 pMsgTdlsLinkEstablishReq->validChannels,
5481 &pMsgTdlsLinkEstablishReq->validChannelsLen);
5482 }
5483 vos_mem_copy(pMsgTdlsLinkEstablishReq->validOperClasses,
5484 pTdlsLinkEstablishReq->supportedOperClasses, pTdlsLinkEstablishReq->supportedOperClassesLen);
5485 pMsgTdlsLinkEstablishReq->validOperClassesLen =
5486 pTdlsLinkEstablishReq->supportedOperClassesLen;
5487
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305488 msg.type = WDA_SET_TDLS_LINK_ESTABLISH_REQ;
5489 msg.reserved = 0;
5490 msg.bodyptr = pMsgTdlsLinkEstablishReq;
5491 msg.bodyval = 0;
5492 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5493 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005494 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305495 goto lim_tdls_link_establish_error;
5496 }
5497 return eSIR_SUCCESS;
5498lim_tdls_link_establish_error:
5499 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
5500 NULL, eSIR_FAILURE) ;
5501
5502 return eSIR_SUCCESS;
5503}
5504
5505
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005506/* Delete all the TDLS peer connected before leaving the BSS */
5507tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
5508{
5509 tpDphHashNode pStaDs = NULL ;
5510 int i, aid;
5511
5512 if (NULL == psessionEntry)
5513 {
5514 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
5515 return eSIR_FAILURE;
5516 }
5517
5518 /* Check all the set bit in peerAIDBitmap and delete the peer (with that aid) entry
5519 from the hash table and add the aid in free pool */
5520 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
5521 {
5522 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
5523 {
5524 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
5525 {
5526 pStaDs = dphGetHashEntry(pMac, (aid + i*(sizeof(tANI_U32) << 3)), &psessionEntry->dph.dphHashTable);
5527
5528 if (NULL != pStaDs)
5529 {
Arif Hussain24bafea2013-11-15 15:10:03 -08005530 PELOGE(limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
5531 MAC_ADDR_ARRAY(pStaDs->staAddr)););
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005532
5533 limSendDeauthMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
5534 pStaDs->staAddr, psessionEntry, FALSE);
5535 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, &psessionEntry->dph.dphHashTable);
5536 }
5537 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)), psessionEntry) ;
5538 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
5539 }
5540 }
5541 }
5542 limSendSmeTDLSDeleteAllPeerInd(pMac, psessionEntry);
5543
5544 return eSIR_SUCCESS;
5545}
Kiran V1ccee932012-12-12 14:49:46 -08005546#endif