blob: b4758ccaa0753968d3de2942ee53599888224eee [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
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +0530182/* These maps to Kernel TDLS peer capability
183 * flags and should get changed as and when necessary
184 */
185enum tdls_peer_capability {
186 TDLS_PEER_HT_CAP = 0,
187 TDLS_PEER_VHT_CAP = 1,
188 TDLS_PEER_WMM_CAP = 2
189} eTdlsPeerCapability;
190
Kiran V1ccee932012-12-12 14:49:46 -0800191/* some local defines */
192#define LINK_IDEN_BSSID_OFFSET (0)
193#define PEER_MAC_OFFSET (12)
194#define STA_MAC_OFFSET (6)
195#define LINK_IDEN_ELE_ID (101)
196//#define LINK_IDEN_LENGTH (18)
197#define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier)
198#define PTI_LINK_IDEN_OFFSET (5)
199#define PTI_BUF_STATUS_OFFSET (25)
200
201/* TODO, Move this parameters to configuration */
202#define PEER_PSM_SUPPORT (0)
Hoonki Lee93e67ff2013-03-19 15:49:25 -0700203#define PEER_BUFFER_STA_SUPPORT (0)
Kiran V1ccee932012-12-12 14:49:46 -0800204#define CH_SWITCH_SUPPORT (0)
205#define TDLS_SUPPORT (1)
206#define TDLS_PROHIBITED (0)
207#define TDLS_CH_SWITCH_PROHIBITED (1)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800208/** @brief Set bit manipulation macro */
209#define SET_BIT(value,mask) ((value) |= (1 << (mask)))
210/** @brief Clear bit manipulation macro */
211#define CLEAR_BIT(value,mask) ((value) &= ~(1 << (mask)))
212/** @brief Check bit manipulation macro */
213#define CHECK_BIT(value, mask) ((value) & (1 << (mask)))
214
215#define SET_PEER_AID_BITMAP(peer_bitmap, aid) \
216 if ((aid) < (sizeof(tANI_U32) << 3)) \
217 SET_BIT(peer_bitmap[0], (aid)); \
218 else if ((aid) < (sizeof(tANI_U32) << 4)) \
219 SET_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
220
221#define CLEAR_PEER_AID_BITMAP(peer_bitmap, aid) \
222 if ((aid) < (sizeof(tANI_U32) << 3)) \
223 CLEAR_BIT(peer_bitmap[0], (aid)); \
224 else if ((aid) < (sizeof(tANI_U32) << 4)) \
225 CLEAR_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
226
Kiran V1ccee932012-12-12 14:49:46 -0800227
228#ifdef LIM_DEBUG_TDLS
Kiran V1ccee932012-12-12 14:49:46 -0800229
230#ifdef FEATURE_WLAN_TDLS
231#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100)
232#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800)
233#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200)
234#endif
235
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530236#define IS_QOS_ENABLED(psessionEntry) ((((psessionEntry)->limQosEnabled) && \
237 SIR_MAC_GET_QOS((psessionEntry)->limCurrentBssCaps)) || \
238 (((psessionEntry)->limWmeEnabled ) && \
239 LIM_BSS_CAPS_GET(WME, (psessionEntry)->limCurrentBssQosCaps)))
240
241#define TID_AC_VI 4
242#define TID_AC_BK 1
243
Kiran V1ccee932012-12-12 14:49:46 -0800244const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
245{
246 switch( tdlsActionCode )
247 {
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530248 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
249 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
250 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
251 CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
252 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
253 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
254 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
255 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
256 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
257 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
Kiran V1ccee932012-12-12 14:49:46 -0800258 }
259 return (const tANI_U8*)"UNKNOWN";
260}
261#endif
262#if 0
263static void printMacAddr(tSirMacAddr macAddr)
264{
265 int i = 0 ;
266 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
267
268 for(i = 0 ; i < 6; i++)
269 {
270 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
271 (" %02x "), macAddr[i]);
272 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700273 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (""));
Kiran V1ccee932012-12-12 14:49:46 -0800274 return ;
275}
276#endif
Kiran V1ccee932012-12-12 14:49:46 -0800277/*
278 * initialize TDLS setup list and related data structures.
279 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800280void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800281{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800282#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800283 pMac->lim.gLimTdlsDisResultList = NULL ;
284 pMac->lim.gLimTdlsDisStaCount = 0 ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530285 vos_mem_set(&pMac->lim.gLimTdlsDisReq, sizeof(tSirTdlsDisReq), 0);
286 vos_mem_set(&pMac->lim.gLimTdlsLinkSetupInfo, sizeof(tLimTdlsLinkSetupInfo), 0);
Kiran V1ccee932012-12-12 14:49:46 -0800287 pMac->lim.gAddStaDisRspWait = 0 ;
288
289#ifdef FEATURE_WLAN_TDLS_NEGATIVE
290 /* when reassociated, negative behavior will not be kept */
291 /* you have to explicitly enable negative behavior per (re)association */
292 pMac->lim.gLimTdlsNegativeBehavior = 0;
293#endif
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800294#endif
295 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800296
297 return ;
298}
Kiran V1ccee932012-12-12 14:49:46 -0800299#ifdef FEATURE_WLAN_TDLS_NEGATIVE
300void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
301{
302 if(on) {
303 if(value == 255)
304 pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
305 else
306 pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
307 }
308 else {
309 if(value == 255)
310 pMac->lim.gLimTdlsNegativeBehavior = 0;
311 else
312 pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
313 }
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800314 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 -0800315 value, on, pMac->lim.gLimTdlsNegativeBehavior));
316}
317#endif
318#if 0
319/*
320 * This function is used for creating TDLS public Action frame to
321 * transmit on Direct link
322 */
323static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
324 tANI_U8 type, tANI_U8 subType,
325 tANI_U8 *link_iden )
326{
327 tpSirMacMgmtHdr pMacHdr ;
328 tANI_U8 *bssid = link_iden ;
329#if 0
330 tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
331 tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
332#else
333 tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
334 tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
335#endif
336 tANI_U8 toDs = ANI_TXDIR_IBSS ;
337
338 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
339
340 /*
341 * prepare 802.11 header
342 */
343 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
344 pMacHdr->fc.type = type ;
345 pMacHdr->fc.subType = subType ;
346 /*
347 * TL is not setting up below fields, so we are doing it here
348 */
349 pMacHdr->fc.toDS = toDs ;
350 pMacHdr->fc.powerMgmt = 0 ;
351
352
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530353 vos_mem_copy( (tANI_U8 *) pMacHdr->da, peerMac, sizeof( tSirMacAddr ));
354 vos_mem_copy( (tANI_U8 *) pMacHdr->sa,
Kiran V1ccee932012-12-12 14:49:46 -0800355 staMac, sizeof( tSirMacAddr ));
356
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530357 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Kiran V1ccee932012-12-12 14:49:46 -0800358 bssid, sizeof( tSirMacAddr ));
359
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800360 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"),
361 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5],
362 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5],
363 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2],
Kiran V1ccee932012-12-12 14:49:46 -0800364 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
365
366 return ;
367}
368#endif
369/*
370 * prepare TDLS frame header, it includes
371 * | | | |
372 * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
373 * | | | |
374 */
375static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530376 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType,
377 tANI_U8 tid, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800378{
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530379 tpSirMacDataHdr3a pMacHdr ;
Kiran V1ccee932012-12-12 14:49:46 -0800380 tANI_U32 header_offset = 0 ;
381 tANI_U8 *addr1 = NULL ;
382 tANI_U8 *addr3 = NULL ;
383 tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP)
384 ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ;
385 tANI_U8 *peerMac = (reqType == TDLS_INITIATOR)
386 ? link_iden->RespStaAddr : link_iden->InitStaAddr;
387 tANI_U8 *staMac = (reqType == TDLS_INITIATOR)
388 ? link_iden->InitStaAddr : link_iden->RespStaAddr;
389
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530390 pMacHdr = (tpSirMacDataHdr3a) (pFrame);
Kiran V1ccee932012-12-12 14:49:46 -0800391
392 /*
393 * if TDLS frame goes through the AP link, it follows normal address
394 * pattern, if TDLS frame goes thorugh the direct link, then
395 * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
396 */
397 (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
398 (addr3 = (peerMac)))
399 : ((addr1 = (peerMac)),
400 (addr3 = (link_iden->bssid))) ;
401 /*
402 * prepare 802.11 header
403 */
404 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
405 pMacHdr->fc.type = SIR_MAC_DATA_FRAME ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530406 pMacHdr->fc.subType = IS_QOS_ENABLED(psessionEntry) ? SIR_MAC_DATA_QOS_DATA : SIR_MAC_DATA_DATA;
407
Kiran V1ccee932012-12-12 14:49:46 -0800408 /*
409 * TL is not setting up below fields, so we are doing it here
410 */
411 pMacHdr->fc.toDS = toDs ;
412 pMacHdr->fc.powerMgmt = 0 ;
413 pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
414
415
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530416 vos_mem_copy( (tANI_U8 *) pMacHdr->addr1,
417 (tANI_U8 *)addr1,
418 sizeof( tSirMacAddr ));
419 vos_mem_copy( (tANI_U8 *) pMacHdr->addr2,
420 (tANI_U8 *) staMac,
421 sizeof( tSirMacAddr ));
Kiran V1ccee932012-12-12 14:49:46 -0800422
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530423 vos_mem_copy( (tANI_U8 *) pMacHdr->addr3,
424 (tANI_U8 *) (addr3),
425 sizeof( tSirMacAddr ));
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530426
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800427 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"),
428 (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD",
429 pMacHdr->addr1[0], pMacHdr->addr1[1], pMacHdr->addr1[2], pMacHdr->addr1[3], pMacHdr->addr1[4], pMacHdr->addr1[5],
430 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 +0530431 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 -0800432
433 //printMacAddr(pMacHdr->bssId) ;
434 //printMacAddr(pMacHdr->sa) ;
435 //printMacAddr(pMacHdr->da) ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530436
437 if (IS_QOS_ENABLED(psessionEntry))
438 {
439 pMacHdr->qosControl.tid = tid;
440 header_offset += sizeof(tSirMacDataHdr3a);
441 }
442 else
443 header_offset += sizeof(tSirMacMgmtHdr);
444
Kiran V1ccee932012-12-12 14:49:46 -0800445 /*
446 * Now form RFC1042 header
447 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530448 vos_mem_copy((tANI_U8 *)(pFrame + header_offset),
449 (tANI_U8 *)eth_890d_header, sizeof(eth_890d_header)) ;
Kiran V1ccee932012-12-12 14:49:46 -0800450
451 header_offset += sizeof(eth_890d_header) ;
452
453 /* add payload type as TDLS */
454 *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
455
456 return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ;
457}
458
459/*
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800460 * TX Complete for Management frames
461 */
462 eHalStatus limMgmtTXComplete(tpAniSirGlobal pMac,
463 tANI_U32 txCompleteSuccess)
464{
465 tpPESession psessionEntry = NULL ;
466
467 if (0xff != pMac->lim.mgmtFrameSessionId)
468 {
469 psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.mgmtFrameSessionId);
470 if (NULL == psessionEntry)
471 {
472 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
473 ("%s: sessionID %d is not found"), __func__, pMac->lim.mgmtFrameSessionId);
474 return eHAL_STATUS_FAILURE;
475 }
476 limSendSmeMgmtTXCompletion(pMac, psessionEntry, txCompleteSuccess);
477 pMac->lim.mgmtFrameSessionId = 0xff;
478 }
479 return eHAL_STATUS_SUCCESS;
480}
481
482/*
Kiran V1ccee932012-12-12 14:49:46 -0800483 * This function can be used for bacst or unicast discovery request
484 * We are not differentiating it here, it will all depnds on peer MAC address,
485 */
486tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
487 tANI_U8 dialog, tpPESession psessionEntry)
488{
489 tDot11fTDLSDisReq tdlsDisReq ;
490 tANI_U32 status = 0 ;
491 tANI_U32 nPayload = 0 ;
492 tANI_U32 size = 0 ;
493 tANI_U32 nBytes = 0 ;
494 tANI_U32 header_offset = 0 ;
495 tANI_U8 *pFrame;
496 void *pPacket;
497 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800498#ifndef NO_PAD_TDLS_MIN_8023_SIZE
499 tANI_U32 padLen = 0;
500#endif
Kiran V1ccee932012-12-12 14:49:46 -0800501
502 /*
503 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
504 * and then hand it off to 'dot11fPackProbeRequest' (for
505 * serialization). We start by zero-initializing the structure:
506 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530507 vos_mem_set( (tANI_U8*)&tdlsDisReq,
508 sizeof( tDot11fTDLSDisReq ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800509
510 /*
511 * setup Fixed fields,
512 */
513 tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
514 tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ;
515 tdlsDisReq.DialogToken.token = dialog ;
516
517
518 size = sizeof(tSirMacAddr) ;
519
520 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier,
521 peer_mac, TDLS_INITIATOR) ;
522
523 /*
524 * now we pack it. First, how much space are we going to need?
525 */
526 status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
527 if ( DOT11F_FAILED( status ) )
528 {
529 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700530 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800531 /* We'll fall back on the worst case scenario: */
532 nPayload = sizeof( tDot11fTDLSDisReq );
533 }
534 else if ( DOT11F_WARNED( status ) )
535 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800536 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -0800537 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700538 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800539 }
540
541 /*
542 * This frame is going out from PE as data frames with special ethertype
543 * 89-0d.
544 * 8 bytes of RFC 1042 header
545 */
546
547
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530548 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
549 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
550 + sizeof( eth_890d_header )
551 + PAYLOAD_TYPE_TDLS_SIZE ;
Kiran V1ccee932012-12-12 14:49:46 -0800552
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800553#ifndef NO_PAD_TDLS_MIN_8023_SIZE
554 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
555 Hence AP itself padding some bytes, which caused teardown packet is dropped at
556 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
557 */
558 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
559 {
560 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
561
562 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
563 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
564 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
565
566 nBytes += padLen;
567 }
568#endif
569
Kiran V1ccee932012-12-12 14:49:46 -0800570 /* Ok-- try to allocate memory from MGMT PKT pool */
571
572 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
573 ( tANI_U16 )nBytes, ( void** ) &pFrame,
574 ( void** ) &pPacket );
575 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
576 {
577 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700578 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -0800579 return eSIR_MEM_ALLOC_FAILED;
580 }
581
582 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530583 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800584
585 /*
586 * IE formation, memory allocation is completed, Now form TDLS discovery
587 * request frame
588 */
589
590 /* fill out the buffer descriptor */
591
592 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530593 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800594
595#ifdef FEATURE_WLAN_TDLS_NEGATIVE
596 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
597 {
598 tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
599 tdlsDisReq.LinkIdentifier.bssid[5] = 0xad;
600 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800601 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Req"),
602 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800603 }
604#endif
605 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
606 + header_offset, nPayload, &nPayload );
607
608 if ( DOT11F_FAILED( status ) )
609 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800610 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
611 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800612 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
613 ( void* ) pFrame, ( void* ) pPacket );
614 return eSIR_FAILURE;
615 }
616 else if ( DOT11F_WARNED( status ) )
617 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800618 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
619 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800620 }
621
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800622#ifndef NO_PAD_TDLS_MIN_8023_SIZE
623 if (padLen != 0)
624 {
625 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
626 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload;
627 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
628 padVendorSpecific[0] = 221;
629 padVendorSpecific[1] = padLen - 2;
630 padVendorSpecific[2] = 0x00;
631 padVendorSpecific[3] = 0xA0;
632 padVendorSpecific[4] = 0xC6;
633
634 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
635 padLen ));
636
637 /* padding zero if more than 5 bytes are required */
638 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530639 vos_mem_set( pFrame + header_offset + nPayload + MIN_VENDOR_SPECIFIC_IE_SIZE,
640 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800641 }
642#endif
Kiran V1ccee932012-12-12 14:49:46 -0800643
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800644 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 -0800645 SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) ));
646
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800647 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -0800648 HAL_TXRX_FRM_802_11_DATA,
649 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530650 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800651 limTxComplete, pFrame,
652 limMgmtTXComplete,
653 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME);
Kiran V1ccee932012-12-12 14:49:46 -0800654 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
655 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800656 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700657 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -0800658 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -0800659 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800660 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -0800661
662 return eSIR_SUCCESS;
663
664}
665
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800666#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800667/*
668 * Once Discovery response is sent successfully (or failure) on air, now send
669 * response to PE and send del STA to HAL.
670 */
671eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac,
672 tANI_U32 txCompleteSuccess)
673{
674 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800675 tpDphHashNode pStaDs = NULL ;
676 tSirTdlsPeerInfo *peerInfo = 0 ;
677
678 /* find peer by looking into the list by expected state */
679 peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ;
680
681 if(NULL == peerInfo)
682 {
683 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700684 ("DisRspTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800685 VOS_ASSERT(0) ;
686 return eHAL_STATUS_FAILURE;
687 }
688
689 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ;
690
691 if(peerInfo->delStaNeeded)
692 {
693 tpPESession psessionEntry;
694
695 peerInfo->delStaNeeded = false ;
696 psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId);
697
698 if(NULL == psessionEntry)
699 {
700 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700701 ("DisRspTxComplete: sessionID %d is not found"), peerInfo->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800702 return eHAL_STATUS_FAILURE;
703 }
704 /* send del STA to remove context for this TDLS STA */
705 pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ;
706
707 /* now send indication to SME-->HDD->TL to remove STA from TL */
708 if(pStaDs)
709 {
710 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
711 pStaDs, eSIR_SUCCESS) ;
712 }
713 else
714 {
715 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800716 ("DisRspTxComplete: staDs not found for " MAC_ADDRESS_STR),
717 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800718 VOS_ASSERT(0) ;
719 return eHAL_STATUS_FAILURE;
720 }
721 }
722
723 if(!txCompleteSuccess)
724 {
725 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
726 ("TX complete failure for Dis RSP"));
727 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
728 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
729 status = eHAL_STATUS_FAILURE;
730 }
731 else
732 {
733 limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS,
734 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
735 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
736 ("TX complete Success for Dis RSP"));
737 status = eHAL_STATUS_SUCCESS ;
738 }
739 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800740 return status ;
741
742}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800743#endif
744
745#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800746/*
747 * Once setup CNF is sent successfully (or failure) on air, now send
748 * response to PE and send del STA to HAL.
749 */
750eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
751 tANI_U32 txCompleteSuccess)
752{
753 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800754 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
755 /* find peer by looking into the list by expected state */
756 limTdlsFindSetupPeerByState(pMac,
757 TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ;
758
759 if(NULL == peerInfo)
760 {
761 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700762 ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800763 VOS_ASSERT(0) ;
764 return eHAL_STATUS_FAILURE;
765 }
766
767 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
768 (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
769
770 if(!txCompleteSuccess)
771 {
772 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
773 ("TX complete Failure for setup CNF"));
774 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac,
775 eWNI_SME_TDLS_LINK_START_RSP) ;
776 status = eHAL_STATUS_FAILURE;
777 }
778 else
779 {
780 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800781 ("RSP-->SME peer MAC = " MAC_ADDRESS_STR),
782 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800783
784 limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
785 eWNI_SME_TDLS_LINK_START_RSP) ;
786
787 /* tdls_hklee: prepare PTI template and send it to HAL */
788 limTdlsLinkEstablish(pMac, (peerInfo)->peerMac);
789
790 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
791 ("TX complete Success for setup CNF"));
792 status = eHAL_STATUS_SUCCESS ;
793 }
794 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800795 return status ;
Kiran V1ccee932012-12-12 14:49:46 -0800796}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800797#endif
Kiran V1ccee932012-12-12 14:49:46 -0800798
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800799#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800800/*
801 * Tx Complete for Teardown frame
802 */
803eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
804 tANI_U32 txCompleteSuccess)
805{
806 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800807 tpDphHashNode pStaDs = NULL ;
808 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
809 tpPESession psessionEntry = NULL ;
810 //tANI_U16 msgType = 0 ;
811
812 //tSirMacAddr peerMac = {0} ;
813 /* find peer by looking into the list by expected state */
814 limTdlsFindSetupPeerByState(pMac,
815 TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ;
816
817 if(NULL == peerInfo)
818 {
819 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700820 ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800821 VOS_ASSERT(0) ;
822 return eHAL_STATUS_FAILURE;
823 }
824
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530825 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800826 ("teardown peer Mac = " MAC_ADDRESS_STR),
827 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800828
829
830 //pMac->hal.pCBackFnTxComp = NULL ;
831
832 psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId);
833
834 if(NULL == psessionEntry)
835 {
836 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700837 ("limTdlsTeardownTxComplete: sessionID %d is not found"), (peerInfo)->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800838 VOS_ASSERT(0) ;
839 return eHAL_STATUS_FAILURE;
840 }
841
842 if(!txCompleteSuccess)
843 {
844 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700845 ("TX complete failure for Teardown ")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800846
847 /*
848 * we should be sending Teradown to AP with status code
849 * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if
850 * that is delivered or not, any way we removing this peer STA from our
851 * list
852 */
853 if(NULL != psessionEntry)
854 {
855 limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac,
856 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ;
857 }
858 }
859
860 if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state)
861 {
862 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
863 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
864 /* send del STA to remove context for this TDLS STA */
865 if(NULL != psessionEntry)
866 {
867 /* tdls_hklee: send message to HAL before it is deleted */
868 limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ;
869
870 pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ;
871 }
872
873 /* now send indication to SME-->HDD->TL to remove STA from TL */
874 if(!pStaDs)
875 {
876 VOS_ASSERT(0) ;
877 return eSIR_FAILURE ;
878 }
879 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
880 pStaDs, eSIR_SUCCESS) ;
881
882 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700883 ("TX complete SUCCESS for Teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800884 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700885 ("Prev State = %d"), (peerInfo)->tdls_prev_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -0800886 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
887 eWNI_SME_TDLS_TEARDOWN_RSP) ;
888 /* Delete Peer for Link Peer List */
889 limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ;
890 }
891 else
892 {
893 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
894 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
895 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
896 eWNI_SME_TDLS_TEARDOWN_IND) ;
897 }
898
899
900#if 0
901 /* if previous state is link restart, then restart link setup again */
902 if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state)
903 {
904 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
905 limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37,
906 peerMac, psessionEntry) ;
907 }
908#endif
909 status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800910 return status ;
911}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800912#endif
Kiran V1ccee932012-12-12 14:49:46 -0800913
914/*
Kiet Lam770920c2013-10-21 12:49:30 +0530915 * This static function is consistent with any kind of TDLS management
916 * frames we are sending. Currently it is being used by limSendTdlsDisRspFrame,
917 * limSendTdlsLinkSetupReqFrame and limSendTdlsSetupRspFrame
918 */
919static void PopulateDot11fTdlsHtVhtCap(tpAniSirGlobal pMac, uint32 selfDot11Mode,
920 tDot11fIEHTCaps *htCap, tDot11fIEVHTCaps *vhtCap,
921 tpPESession psessionEntry)
922{
923 if (IS_DOT11_MODE_HT(selfDot11Mode))
924 {
925 /* Include HT Capability IE */
926 PopulateDot11fHTCaps( pMac, NULL, htCap );
927 htCap->present = 1;
928 if (psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END)
929 {
930 /* hardcode NO channel bonding in 2.4Ghz */
931 htCap->supportedChannelWidthSet = 0;
932 }
933 else
934 {
935 //Placeholder to support different channel bonding mode of TDLS than AP.
936 //wlan_cfgGetInt(pMac,WNI_CFG_TDLS_CHANNEL_BONDING_MODE,&tdlsChannelBondingMode);
937 //htCap->supportedChannelWidthSet = tdlsChannelBondingMode ? 1 : 0;
938 htCap->supportedChannelWidthSet = 1; // hardcode it to max
939 }
940 }
941 else
942 {
943 htCap->present = 0;
944 }
945#ifdef WLAN_FEATURE_11AC
946 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
947 pMac->roam.configParam.enableVhtFor24GHz) ||
948 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
949 {
950 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
951 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
952 {
953 /* Include VHT Capability IE */
954 PopulateDot11fVHTCaps( pMac, vhtCap );
955 }
956 else
957 {
958 vhtCap->present = 0;
959 }
960 }
961 else
962 {
963 /* Vht Disable from ini in 2.4 GHz */
964 vhtCap->present = 0;
965 }
966#endif
967}
968
969/*
Kiran V1ccee932012-12-12 14:49:46 -0800970 * Send TDLS discovery response frame on direct link.
971 */
972
973static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
974 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry)
975{
976 tDot11fTDLSDisRsp tdlsDisRsp ;
977 tANI_U16 caps = 0 ;
978 tANI_U32 status = 0 ;
979 tANI_U32 nPayload = 0 ;
980 tANI_U32 nBytes = 0 ;
981 tANI_U8 *pFrame;
982 void *pPacket;
983 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -0700984 uint32 selfDot11Mode;
985// Placeholder to support different channel bonding mode of TDLS than AP.
986// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
987// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
988// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
989// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -0800990
991 /*
992 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
993 * and then hand it off to 'dot11fPackProbeRequest' (for
994 * serialization). We start by zero-initializing the structure:
995 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530996 vos_mem_set( ( tANI_U8* )&tdlsDisRsp,
997 sizeof( tDot11fTDLSDisRsp ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800998
999 /*
1000 * setup Fixed fields,
1001 */
1002 tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
1003 tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ;
1004 tdlsDisRsp.DialogToken.token = dialog ;
1005
1006 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
1007 peerMac, TDLS_RESPONDER) ;
1008
1009 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1010 {
1011 /*
1012 * Could not get Capabilities value
1013 * from CFG. Log error.
1014 */
1015 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001016 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001017 }
1018 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
1019
1020 /* populate supported rate IE */
1021 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1022 &tdlsDisRsp.SuppRates, psessionEntry );
1023
1024 /* Populate extended supported rates */
1025 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1026 &tdlsDisRsp.ExtSuppRates, psessionEntry );
1027
1028 /* Populate extended supported rates */
1029 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
1030
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001031 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1032
Kiet Lam770920c2013-10-21 12:49:30 +05301033 /* Populate HT/VHT Capabilities */
1034 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsDisRsp.HTCaps,
1035 &tdlsDisRsp.VHTCaps, psessionEntry );
Kiran V1ccee932012-12-12 14:49:46 -08001036
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301037 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1038 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1039 &tdlsDisRsp.SuppChannels,
1040 &tdlsDisRsp.SuppOperatingClasses);
Kiran V1ccee932012-12-12 14:49:46 -08001041 /*
1042 * now we pack it. First, how much space are we going to need?
1043 */
1044 status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
1045 if ( DOT11F_FAILED( status ) )
1046 {
1047 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001048 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001049 /* We'll fall back on the worst case scenario: */
1050 nPayload = sizeof( tDot11fProbeRequest );
1051 }
1052 else if ( DOT11F_WARNED( status ) )
1053 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001054 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001055 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001056 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001057 }
1058
1059 /*
1060 * This frame is going out from PE as data frames with special ethertype
1061 * 89-0d.
1062 * 8 bytes of RFC 1042 header
1063 */
1064
1065
1066 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ;
1067
1068 /* Ok-- try to allocate memory from MGMT PKT pool */
1069
1070 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1071 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1072 ( void** ) &pPacket );
1073 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1074 {
1075 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001076 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001077 return eSIR_MEM_ALLOC_FAILED;
1078 }
1079
1080 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301081 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001082
1083 /*
1084 * IE formation, memory allocation is completed, Now form TDLS discovery
1085 * response frame
1086 */
1087
1088 /* Make public Action Frame */
1089
1090#if 0
1091 limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1092 SIR_MAC_MGMT_ACTION,
1093 LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
1094#endif
1095 limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1096 SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
1097
1098 {
1099 tpSirMacMgmtHdr pMacHdr;
1100 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1101 pMacHdr->fc.toDS = ANI_TXDIR_IBSS;
1102 pMacHdr->fc.powerMgmt = 0 ;
1103 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1104 }
1105
1106#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1107 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
1108 {
1109 tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
1110 tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad;
1111 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001112 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Rsp"),
1113 MAC_ADDR_ARRAY(tdlsDisRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001114 }
1115#endif
1116 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
1117 sizeof( tSirMacMgmtHdr ),
1118 nPayload, &nPayload );
1119
1120 if ( DOT11F_FAILED( status ) )
1121 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001122 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1123 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001124 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1125 ( void* ) pFrame, ( void* ) pPacket );
1126 return eSIR_FAILURE;
1127 }
1128 else if ( DOT11F_WARNED( status ) )
1129 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001130 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1131 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001132 }
1133
1134#if 0
1135 if(pMac->hal.pCBackFnTxComp == NULL)
1136 {
1137 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
1138
1139 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
1140 {
1141 status = eHAL_STATUS_FAILURE;
1142 return status;
1143
1144 }
1145 }
1146#endif
1147 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001148 ("transmitting Discovery response on direct link")) ;
Kiran V1ccee932012-12-12 14:49:46 -08001149
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001150 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 -08001151 SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) ));
1152
1153
1154 /*
1155 * Transmit Discovery response and watch if this is delivered to
1156 * peer STA.
1157 */
1158 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1159 HAL_TXRX_FRM_802_11_DATA,
1160 ANI_TXDIR_IBSS,
1161 0,
1162 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001163 limMgmtTXComplete,
Kiran V1ccee932012-12-12 14:49:46 -08001164 HAL_USE_SELF_STA_REQUESTED_MASK );
1165 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1166 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001167 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001168 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001169 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001170 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001171 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001172
1173 return eSIR_SUCCESS;
1174
1175}
1176
1177/*
Kiet Lam770920c2013-10-21 12:49:30 +05301178 * This static function is currently used by limSendTdlsLinkSetupReqFrame and
1179 * limSendTdlsSetupRspFrame to populate the AID if device is 11ac capable.
1180 */
1181static void PopulateDotfTdlsVhtAID(tpAniSirGlobal pMac, uint32 selfDot11Mode,
1182 tSirMacAddr peerMac, tDot11fIEAID *Aid,
1183 tpPESession psessionEntry)
1184{
1185 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
1186 pMac->roam.configParam.enableVhtFor24GHz) ||
1187 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
1188 {
1189 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1190 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1191 {
1192
1193 tANI_U16 aid;
1194 tpDphHashNode pStaDs;
1195
1196 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
1197 if (NULL != pStaDs)
1198 {
1199 Aid->present = 1;
1200 Aid->assocId = aid | LIM_AID_MASK; // set bit 14 and 15 1's
1201 }
1202 else
1203 {
1204 Aid->present = 0;
1205 limLog( pMac, LOGE, FL("pStaDs is NULL for " MAC_ADDRESS_STR ),
1206 MAC_ADDR_ARRAY(peerMac));
1207 }
1208 }
1209 }
1210 else
1211 {
1212 Aid->present = 0;
1213 limLog( pMac, LOGW, FL("Vht not enable from ini for 2.4GHz."));
1214 }
1215}
1216
1217/*
Kiran V1ccee932012-12-12 14:49:46 -08001218 * TDLS setup Request frame on AP link
1219 */
1220
1221tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1222 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301223 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001224{
1225 tDot11fTDLSSetupReq tdlsSetupReq ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301226 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001227 tANI_U32 status = 0 ;
1228 tANI_U32 nPayload = 0 ;
1229 tANI_U32 nBytes = 0 ;
1230 tANI_U32 header_offset = 0 ;
1231 tANI_U8 *pFrame;
1232 void *pPacket;
1233 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001234 uint32 selfDot11Mode;
1235// Placeholder to support different channel bonding mode of TDLS than AP.
1236// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1237// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1238// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1239// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001240
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301241 /*
Kiran V1ccee932012-12-12 14:49:46 -08001242 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1243 * and then hand it off to 'dot11fPackProbeRequest' (for
1244 * serialization). We start by zero-initializing the structure:
1245 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301246 vos_mem_set(( tANI_U8* )&tdlsSetupReq, sizeof( tDot11fTDLSSetupReq ), 0);
Kiran V1ccee932012-12-12 14:49:46 -08001247 tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
1248 tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ;
1249 tdlsSetupReq.DialogToken.token = dialog ;
1250
1251
1252 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
1253 peerMac, TDLS_INITIATOR) ;
1254
1255 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1256 {
1257 /*
1258 * Could not get Capabilities value
1259 * from CFG. Log error.
1260 */
1261 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001262 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001263 }
1264 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1265
1266 /* populate supported rate IE */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301267 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Kiran V1ccee932012-12-12 14:49:46 -08001268 &tdlsSetupReq.SuppRates, psessionEntry );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301269
Kiran V1ccee932012-12-12 14:49:46 -08001270 /* Populate extended supported rates */
1271 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1272 &tdlsSetupReq.ExtSuppRates, psessionEntry );
1273
1274 /* Populate extended supported rates */
1275 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1276
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301277 /*
Kiran V1ccee932012-12-12 14:49:46 -08001278 * TODO: we need to see if we have to support conditions where we have
1279 * EDCA parameter info element is needed a) if we need different QOS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301280 * parameters for off channel operations or QOS is not supported on
Kiran V1ccee932012-12-12 14:49:46 -08001281 * AP link and we wanted to QOS on direct link.
1282 */
1283 /* Populate QOS info, needed for Peer U-APSD session */
1284 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1285 TDLS doesn't want to depend on AP's capability */
1286 tdlsSetupReq.QOSCapsStation.present = 1;
1287 tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
1288 tdlsSetupReq.QOSCapsStation.qack = 0;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301289 tdlsSetupReq.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3) ;
1290 tdlsSetupReq.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04)>> 2);
1291 tdlsSetupReq.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02)>> 1);
1292 tdlsSetupReq.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1293
Kiran V1ccee932012-12-12 14:49:46 -08001294 /*
1295 * we will always try to init TDLS link with 11n capabilities
1296 * let TDLS setup response to come, and we will set our caps based
1297 * of peer caps
1298 */
1299
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001300 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1301
Kiet Lam770920c2013-10-21 12:49:30 +05301302 /* Populate HT/VHT Capabilities */
1303 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupReq.HTCaps,
1304 &tdlsSetupReq.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001305
Kiet Lam770920c2013-10-21 12:49:30 +05301306 /* Populate AID */
1307 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1308 &tdlsSetupReq.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001309
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301310 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1311 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1312 &tdlsSetupReq.SuppChannels,
1313 &tdlsSetupReq.SuppOperatingClasses);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301314 /*
Kiran V1ccee932012-12-12 14:49:46 -08001315 * now we pack it. First, how much space are we going to need?
1316 */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301317 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
Kiran V1ccee932012-12-12 14:49:46 -08001318 &nPayload);
1319 if ( DOT11F_FAILED( status ) )
1320 {
1321 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001322 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001323 /* We'll fall back on the worst case scenario: */
1324 nPayload = sizeof( tDot11fProbeRequest );
1325 }
1326 else if ( DOT11F_WARNED( status ) )
1327 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001328 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001329 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001330 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001331 }
1332
1333
1334 /*
1335 * This frame is going out from PE as data frames with special ethertype
1336 * 89-0d.
1337 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301338 */
Kiran V1ccee932012-12-12 14:49:46 -08001339
1340
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301341 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1342 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1343 + sizeof( eth_890d_header )
1344 + PAYLOAD_TYPE_TDLS_SIZE
1345 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001346
1347 /* Ok-- try to allocate memory from MGMT PKT pool */
1348
1349 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301350 ( tANI_U16 )nBytes, ( void** ) &pFrame,
Kiran V1ccee932012-12-12 14:49:46 -08001351 ( void** ) &pPacket );
1352 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1353 {
1354 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001355 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001356 return eSIR_MEM_ALLOC_FAILED;
1357 }
1358
1359 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301360 vos_mem_set( pFrame, nBytes, 0);
Kiran V1ccee932012-12-12 14:49:46 -08001361
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301362 /*
Kiran V1ccee932012-12-12 14:49:46 -08001363 * IE formation, memory allocation is completed, Now form TDLS discovery
1364 * request frame
1365 */
1366
1367 /* fill out the buffer descriptor */
1368
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301369 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301370 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001371
1372#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1373 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
1374 {
1375 tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301376 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1377 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001378 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Req"),
1379 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001380 }
1381#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001382 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1383 __func__, tdlsSetupReq.VHTCaps.supportedChannelWidthSet, tdlsSetupReq.VHTCaps.rxMCSMap,
1384 tdlsSetupReq.VHTCaps.txMCSMap, tdlsSetupReq.VHTCaps.txSupDataRate );
1385
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301386 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001387 + header_offset, nPayload, &nPayload );
1388
1389 if ( DOT11F_FAILED( status ) )
1390 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001391 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1392 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001393 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1394 ( void* ) pFrame, ( void* ) pPacket );
1395 return eSIR_FAILURE;
1396 }
1397 else if ( DOT11F_WARNED( status ) )
1398 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001399 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1400 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001401 }
1402
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301403 //Copy the additional IE.
Kiran V1ccee932012-12-12 14:49:46 -08001404 //TODO : addIe is added at the end of the frame. This means it doesnt
1405 //follow the order. This should be ok, but we should consider changing this
1406 //if there is any IOT issue.
1407 if( addIeLen != 0 )
1408 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001409 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 -08001410 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301411 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001412 }
1413
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001414 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 -08001415 SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) ));
1416
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001417 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001418 HAL_TXRX_FRM_802_11_DATA,
1419 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301420 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001421 limTxComplete, pFrame,
1422 limMgmtTXComplete,
1423 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
1424
Kiran V1ccee932012-12-12 14:49:46 -08001425 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1426 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001427 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001428 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001429 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001430 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001431 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001432
1433 return eSIR_SUCCESS;
1434
1435}
1436/*
1437 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1438 */
1439
1440tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08001441 tSirMacAddr peerMac, tANI_U16 reason, tANI_U8 responder, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301442 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001443{
1444 tDot11fTDLSTeardown teardown ;
1445 tANI_U32 status = 0 ;
1446 tANI_U32 nPayload = 0 ;
1447 tANI_U32 nBytes = 0 ;
1448 tANI_U32 header_offset = 0 ;
1449 tANI_U8 *pFrame;
1450 void *pPacket;
1451 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001452#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1453 tANI_U32 padLen = 0;
1454#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301455 /*
Kiran V1ccee932012-12-12 14:49:46 -08001456 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1457 * and then hand it off to 'dot11fPackProbeRequest' (for
1458 * serialization). We start by zero-initializing the structure:
1459 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301460 vos_mem_set( ( tANI_U8* )&teardown, sizeof( tDot11fTDLSTeardown ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001461 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1462 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1463 teardown.Reason.code = reason ;
1464
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301465 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
Hoonki Leea34dd892013-02-05 22:56:02 -08001466 peerMac, (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR) ;
Kiran V1ccee932012-12-12 14:49:46 -08001467
1468
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301469 /*
Kiran V1ccee932012-12-12 14:49:46 -08001470 * now we pack it. First, how much space are we going to need?
1471 */
1472 status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
1473 if ( DOT11F_FAILED( status ) )
1474 {
1475 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001476 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001477 /* We'll fall back on the worst case scenario: */
1478 nPayload = sizeof( tDot11fProbeRequest );
1479 }
1480 else if ( DOT11F_WARNED( status ) )
1481 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001482 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001483 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001484 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001485 }
1486
1487
1488 /*
1489 * This frame is going out from PE as data frames with special ethertype
1490 * 89-0d.
1491 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301492 */
Kiran V1ccee932012-12-12 14:49:46 -08001493
1494
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301495 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1496 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1497 + sizeof( eth_890d_header )
1498 + PAYLOAD_TYPE_TDLS_SIZE
1499 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001500
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001501#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1502 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1503 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1504 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1505 */
1506 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1507 {
1508 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1509
1510 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1511 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1512 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1513
1514 nBytes += padLen;
1515 }
1516#endif
1517
Kiran V1ccee932012-12-12 14:49:46 -08001518 /* Ok-- try to allocate memory from MGMT PKT pool */
1519
1520 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1521 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1522 ( void** ) &pPacket );
1523 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1524 {
1525 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001526 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001527 return eSIR_MEM_ALLOC_FAILED;
1528 }
1529
1530 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301531 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001532
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301533 /*
Kiran V1ccee932012-12-12 14:49:46 -08001534 * IE formation, memory allocation is completed, Now form TDLS discovery
1535 * request frame
1536 */
1537
1538 /* fill out the buffer descriptor */
1539
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301540 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1541 LINK_IDEN_ADDR_OFFSET(teardown),
1542 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
Gopichand Nakkala269032c2013-02-07 17:18:15 -08001543 ? TDLS_LINK_AP : TDLS_LINK_DIRECT,
1544 (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301545 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001546
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301547 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001548 + header_offset, nPayload, &nPayload );
1549
1550 if ( DOT11F_FAILED( status ) )
1551 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001552 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req (0x%08x)."),
1553 status );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301554 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Kiran V1ccee932012-12-12 14:49:46 -08001555 ( void* ) pFrame, ( void* ) pPacket );
1556 return eSIR_FAILURE;
1557 }
1558 else if ( DOT11F_WARNED( status ) )
1559 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001560 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1561 "Teardown Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001562 }
1563#if 0
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301564 if(pMac->hal.pCBackFnTxComp == NULL)
Kiran V1ccee932012-12-12 14:49:46 -08001565 {
1566 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301567 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
Kiran V1ccee932012-12-12 14:49:46 -08001568 {
1569 status = eHAL_STATUS_FAILURE;
1570 return status;
1571
1572 }
1573 }
1574 else
1575 {
1576 VOS_ASSERT(0) ;
1577 return status ;
1578 }
1579#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301580
Kiran V1ccee932012-12-12 14:49:46 -08001581 if( addIeLen != 0 )
1582 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001583 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 -08001584 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301585 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001586 }
1587
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001588#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1589 if (padLen != 0)
1590 {
1591 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
1592 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
1593 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
1594 padVendorSpecific[0] = 221;
1595 padVendorSpecific[1] = padLen - 2;
1596 padVendorSpecific[2] = 0x00;
1597 padVendorSpecific[3] = 0xA0;
1598 padVendorSpecific[4] = 0xC6;
1599
1600 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
1601 padLen ));
1602
1603 /* padding zero if more than 5 bytes are required */
1604 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301605 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
1606 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001607 }
1608#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001609 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -%s-> OTA"),
1610 SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN),
1611 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ? "AP": "DIRECT" ));
Kiran V1ccee932012-12-12 14:49:46 -08001612
1613 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1614 HAL_TXRX_FRM_802_11_DATA,
1615 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301616 TID_AC_VI,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301617 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001618 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08001619 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001620 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1621 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001622 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001623 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001624 return eSIR_FAILURE;
1625
1626 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001627 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001628 return eSIR_SUCCESS;
1629
1630}
1631
1632/*
1633 * Send Setup RSP frame on AP link.
1634 */
1635static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1636 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
1637 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1638{
1639 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1640 tANI_U32 status = 0 ;
1641 tANI_U16 caps = 0 ;
1642 tANI_U32 nPayload = 0 ;
1643 tANI_U32 header_offset = 0 ;
1644 tANI_U32 nBytes = 0 ;
1645 tANI_U8 *pFrame;
1646 void *pPacket;
1647 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001648 uint32 selfDot11Mode;
1649// Placeholder to support different channel bonding mode of TDLS than AP.
1650// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1651// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1652// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1653// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001654
1655 /*
1656 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1657 * and then hand it off to 'dot11fPackProbeRequest' (for
1658 * serialization). We start by zero-initializing the structure:
1659 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301660 vos_mem_set( ( tANI_U8* )&tdlsSetupRsp, sizeof( tDot11fTDLSSetupRsp ),0 );
Kiran V1ccee932012-12-12 14:49:46 -08001661
1662 /*
1663 * setup Fixed fields,
1664 */
1665 tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
1666 tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ;
1667 tdlsSetupRsp.DialogToken.token = dialog;
1668
1669 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
1670 peerMac, TDLS_RESPONDER) ;
1671
1672 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1673 {
1674 /*
1675 * Could not get Capabilities value
1676 * from CFG. Log error.
1677 */
1678 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001679 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001680 }
1681 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1682
1683 /* ipopulate supported rate IE */
1684 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1685 &tdlsSetupRsp.SuppRates, psessionEntry );
1686
1687 /* Populate extended supported rates */
1688 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1689 &tdlsSetupRsp.ExtSuppRates, psessionEntry );
1690
1691 /* Populate extended supported rates */
1692 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1693
1694 /*
1695 * TODO: we need to see if we have to support conditions where we have
1696 * EDCA parameter info element is needed a) if we need different QOS
1697 * parameters for off channel operations or QOS is not supported on
1698 * AP link and we wanted to QOS on direct link.
1699 */
1700 /* Populate QOS info, needed for Peer U-APSD session */
1701 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1702 TDLS doesn't want to depend on AP's capability */
1703 tdlsSetupRsp.QOSCapsStation.present = 1;
1704 tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
1705 tdlsSetupRsp.QOSCapsStation.qack = 0;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301706 tdlsSetupRsp.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1707 tdlsSetupRsp.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1708 tdlsSetupRsp.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1709 tdlsSetupRsp.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
Kiran V1ccee932012-12-12 14:49:46 -08001710
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001711 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1712
Kiet Lam770920c2013-10-21 12:49:30 +05301713 /* Populate HT/VHT Capabilities */
1714 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupRsp.HTCaps,
1715 &tdlsSetupRsp.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001716
Kiet Lam770920c2013-10-21 12:49:30 +05301717 /* Populate AID */
1718 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1719 &tdlsSetupRsp.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001720
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301721 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1722 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1723 &tdlsSetupRsp.SuppChannels,
1724 &tdlsSetupRsp.SuppOperatingClasses);
1725
Kiran V1ccee932012-12-12 14:49:46 -08001726 tdlsSetupRsp.Status.status = setupStatus ;
1727
1728 /*
1729 * now we pack it. First, how much space are we going to need?
1730 */
1731 status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp,
1732 &nPayload);
1733 if ( DOT11F_FAILED( status ) )
1734 {
1735 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001736 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001737 /* We'll fall back on the worst case scenario: */
1738 nPayload = sizeof( tDot11fProbeRequest );
1739 }
1740 else if ( DOT11F_WARNED( status ) )
1741 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001742 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001743 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001744 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001745 }
1746
1747 /*
1748 * This frame is going out from PE as data frames with special ethertype
1749 * 89-0d.
1750 * 8 bytes of RFC 1042 header
1751 */
1752
1753
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301754 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1755 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1756 + sizeof( eth_890d_header )
1757 + PAYLOAD_TYPE_TDLS_SIZE
1758 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001759
1760 /* Ok-- try to allocate memory from MGMT PKT pool */
1761
1762 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1763 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1764 ( void** ) &pPacket );
1765 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1766 {
1767 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001768 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001769 return eSIR_MEM_ALLOC_FAILED;
1770 }
1771
1772 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301773 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001774
1775 /*
1776 * IE formation, memory allocation is completed, Now form TDLS discovery
1777 * request frame
1778 */
1779
1780 /* fill out the buffer descriptor */
1781
1782 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1783 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp),
1784 TDLS_LINK_AP, TDLS_RESPONDER,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301785 TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001786
1787#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1788 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
1789 {
1790 tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
1791 tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad;
1792 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001793 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Rsp"),
1794 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001795 }
1796#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001797 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1798 __func__, tdlsSetupRsp.VHTCaps.supportedChannelWidthSet, tdlsSetupRsp.VHTCaps.rxMCSMap,
1799 tdlsSetupRsp.VHTCaps.txMCSMap, tdlsSetupRsp.VHTCaps.txSupDataRate );
Kiran V1ccee932012-12-12 14:49:46 -08001800 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1801 + header_offset, nPayload, &nPayload );
1802
1803 if ( DOT11F_FAILED( status ) )
1804 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001805 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1806 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001807 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1808 ( void* ) pFrame, ( void* ) pPacket );
1809 return eSIR_FAILURE;
1810 }
1811 else if ( DOT11F_WARNED( status ) )
1812 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001813 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1814 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001815 }
1816
1817 //Copy the additional IE.
1818 //TODO : addIe is added at the end of the frame. This means it doesnt
1819 //follow the order. This should be ok, but we should consider changing this
1820 //if there is any IOT issue.
1821 if( addIeLen != 0 )
1822 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301823 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001824 }
1825
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001826 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 -08001827 SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) ));
1828
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001829 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001830 HAL_TXRX_FRM_802_11_DATA,
1831 ANI_TXDIR_TODS,
1832 //ANI_TXDIR_IBSS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301833 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001834 limTxComplete, pFrame,
1835 limMgmtTXComplete,
1836 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001837 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1838 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001839 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001840 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001841 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001842 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001843 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001844
1845 return eSIR_SUCCESS;
1846
1847}
1848
1849/*
1850 * Send TDLS setup CNF frame on AP link
1851 */
1852
1853tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301854 tANI_U8 dialog, tANI_U32 peerCapability, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001855{
1856 tDot11fTDLSSetupCnf tdlsSetupCnf ;
1857 tANI_U32 status = 0 ;
1858 tANI_U32 nPayload = 0 ;
1859 tANI_U32 nBytes = 0 ;
1860 tANI_U32 header_offset = 0 ;
1861 tANI_U8 *pFrame;
1862 void *pPacket;
1863 eHalStatus halstatus;
Hoonki Lee426f0302013-02-08 17:35:38 -08001864#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1865 tANI_U32 padLen = 0;
1866#endif
Kiran V1ccee932012-12-12 14:49:46 -08001867
1868 /*
1869 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1870 * and then hand it off to 'dot11fPackProbeRequest' (for
1871 * serialization). We start by zero-initializing the structure:
1872 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301873 vos_mem_set( ( tANI_U8* )&tdlsSetupCnf, sizeof( tDot11fTDLSSetupCnf ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001874
1875 /*
1876 * setup Fixed fields,
1877 */
1878 tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
1879 tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ;
1880 tdlsSetupCnf.DialogToken.token = dialog ;
1881
1882#if 1
1883 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
1884 peerMac, TDLS_INITIATOR) ;
1885#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301886 vos_mem_copy( (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier,
1887 (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ;
Kiran V1ccee932012-12-12 14:49:46 -08001888#endif
1889
1890 /*
1891 * TODO: we need to see if we have to support conditions where we have
1892 * EDCA parameter info element is needed a) if we need different QOS
1893 * parameters for off channel operations or QOS is not supported on
1894 * AP link and we wanted to QOS on direct link.
1895 */
1896
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301897 /* Check peer is VHT capable*/
1898 if (CHECK_BIT(peerCapability, TDLS_PEER_VHT_CAP))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001899 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301900 PopulateDot11fVHTOperation( pMac, &tdlsSetupCnf.VHTOperation);
1901 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001902 }
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301903 else if (CHECK_BIT(peerCapability, TDLS_PEER_HT_CAP)) /* Check peer is HT capable */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001904 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301905 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001906 }
Kiran V1ccee932012-12-12 14:49:46 -08001907
1908 /*
1909 * now we pack it. First, how much space are we going to need?
1910 */
1911 status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf,
1912 &nPayload);
1913 if ( DOT11F_FAILED( status ) )
1914 {
1915 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001916 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001917 /* We'll fall back on the worst case scenario: */
1918 nPayload = sizeof( tDot11fProbeRequest );
1919 }
1920 else if ( DOT11F_WARNED( status ) )
1921 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001922 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001923 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001924 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001925 }
1926
1927 /*
1928 * This frame is going out from PE as data frames with special ethertype
1929 * 89-0d.
1930 * 8 bytes of RFC 1042 header
1931 */
1932
1933
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301934 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1935 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1936 + sizeof( eth_890d_header )
1937 + PAYLOAD_TYPE_TDLS_SIZE
1938 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001939
Hoonki Lee426f0302013-02-08 17:35:38 -08001940#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1941 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1942 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1943 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1944 */
1945 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1946 {
1947 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1948
1949 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1950 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1951 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1952
1953 nBytes += padLen;
1954 }
1955#endif
1956
1957
Kiran V1ccee932012-12-12 14:49:46 -08001958 /* Ok-- try to allocate memory from MGMT PKT pool */
1959
1960 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1961 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1962 ( void** ) &pPacket );
1963 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1964 {
1965 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001966 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001967 return eSIR_MEM_ALLOC_FAILED;
1968 }
1969
1970 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301971 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001972
1973 /*
1974 * IE formation, memory allocation is completed, Now form TDLS discovery
1975 * request frame
1976 */
1977
1978 /* fill out the buffer descriptor */
1979
1980 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1981 LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301982 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001983
1984#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1985 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
1986 tdlsSetupCnf.StatusCode.statusCode = 37;
1987 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001988 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf"));
Kiran V1ccee932012-12-12 14:49:46 -08001989 }
1990#endif
1991 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
1992 + header_offset, nPayload, &nPayload );
1993
1994 if ( DOT11F_FAILED( status ) )
1995 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001996 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1997 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001998 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1999 ( void* ) pFrame, ( void* ) pPacket );
2000 return eSIR_FAILURE;
2001 }
2002 else if ( DOT11F_WARNED( status ) )
2003 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002004 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
2005 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08002006 }
2007#if 0
2008 if(pMac->hal.pCBackFnTxComp == NULL)
2009 {
2010 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
2011 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
2012 {
2013 status = eHAL_STATUS_FAILURE;
2014 return status;
2015
2016 }
2017 }
2018 else
2019 {
2020 VOS_ASSERT(0) ;
2021 return status ;
2022 }
2023#endif
2024 //Copy the additional IE.
2025 //TODO : addIe is added at the end of the frame. This means it doesnt
2026 //follow the order. This should be ok, but we should consider changing this
2027 //if there is any IOT issue.
2028 if( addIeLen != 0 )
2029 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302030 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08002031 }
2032
Hoonki Lee426f0302013-02-08 17:35:38 -08002033#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2034 if (padLen != 0)
2035 {
2036 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
2037 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
2038 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
2039 padVendorSpecific[0] = 221;
2040 padVendorSpecific[1] = padLen - 2;
2041 padVendorSpecific[2] = 0x00;
2042 padVendorSpecific[3] = 0xA0;
2043 padVendorSpecific[4] = 0xC6;
2044
2045 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
2046 padLen ));
2047
2048 /* padding zero if more than 5 bytes are required */
2049 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302050 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
2051 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee426f0302013-02-08 17:35:38 -08002052 }
2053#endif
2054
2055
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002056 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 -08002057 SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) ));
2058
2059 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
2060 HAL_TXRX_FRM_802_11_DATA,
2061 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302062 TID_AC_VI,
Kiran V1ccee932012-12-12 14:49:46 -08002063 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002064 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08002065 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08002066
2067
2068 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2069 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002070 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002071 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08002072 return eSIR_FAILURE;
2073
2074 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002075 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08002076
2077 return eSIR_SUCCESS;
2078}
2079
2080#ifdef FEATURE_WLAN_TDLS_INTERNAL
2081/*
2082 * Convert HT caps to lim based HT caps
2083 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302084static void limTdlsCovertHTCaps(tpAniSirGlobal pMac,
Kiran V1ccee932012-12-12 14:49:46 -08002085 tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps)
2086{
2087
2088 /* HT Capability Info */
2089 peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ;
2090 peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet =
2091 HTCaps->supportedChannelWidthSet ;
2092 peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ;
2093 peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ;
2094 peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ;
2095 peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ;
2096 peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ;
2097 peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ;
2098 peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA;
2099 peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ;
2100 peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ;
2101 peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ;
2102 peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ;
2103 peerInfo->tdlsPeerHtCaps.lsigTXOPProtection =
2104 HTCaps->lsigTXOPProtection ;
2105
2106 /* HT Capa parameters */
2107 peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ;
2108 peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ;
2109 peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ;
2110
2111 /* Extended HT caps */
2112 peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ;
2113 peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ;
2114 peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302115 vos_mem_copy( peerInfo->supportedMCSSet,
Kiran V1ccee932012-12-12 14:49:46 -08002116 HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
2117
2118 return ;
2119}
2120
2121/*
2122 * update capability info..
2123 */
2124void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo,
2125 tDot11fFfCapabilities *Capabilities)
2126{
2127
2128 capabilityInfo->ess = Capabilities->ess;
2129 capabilityInfo->ibss = Capabilities->ibss;
2130 capabilityInfo->cfPollable = Capabilities->cfPollable;
2131 capabilityInfo->cfPollReq = Capabilities->cfPollReq;
2132 capabilityInfo->privacy = Capabilities->privacy;
2133 capabilityInfo->shortPreamble = Capabilities->shortPreamble;
2134 capabilityInfo->pbcc = Capabilities->pbcc;
2135 capabilityInfo->channelAgility = Capabilities->channelAgility;
2136 capabilityInfo->spectrumMgt = Capabilities->spectrumMgt;
2137 capabilityInfo->qos = Capabilities->qos;
2138 capabilityInfo->shortSlotTime = Capabilities->shortSlotTime;
2139 capabilityInfo->apsd = Capabilities->apsd;
2140 capabilityInfo->rrm = Capabilities->rrm;
2141 capabilityInfo->dsssOfdm = Capabilities->dsssOfdm;
2142 capabilityInfo->immediateBA = Capabilities->immediateBA;
2143
2144 return ;
2145}
2146
2147/*
2148 * update Peer info from the link request frame recieved from Peer..
2149 * in list of STA participating in TDLS link setup
2150 */
2151void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac,
2152 tLimTdlsLinkSetupPeer *setupPeer,
2153 tDot11fTDLSSetupReq *setupReq)
2154{
2155
2156 /* Populate peer info of tdls discovery result */
2157
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302158 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupReq->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002159
2160 if(setupReq->SuppRates.present)
2161 {
2162 ConvertSuppRates( pMac, &setupPeer->supportedRates,
2163 &setupReq->SuppRates );
2164 }
2165
2166 /* update QOS info, needed for Peer U-APSD session */
2167 if(setupReq->QOSCapsStation.present)
2168 {
2169 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2170 &setupReq->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002171 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."),
2172 setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd,
2173 setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd,
2174 setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002175 setupReq->QOSCapsStation.qack));
2176 }
2177
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302178 if (setupReq->ExtSuppRates.present)
Kiran V1ccee932012-12-12 14:49:46 -08002179 {
2180 setupPeer->ExtRatesPresent = 1;
2181 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2182 &setupReq->ExtSuppRates );
2183 }
2184 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302185 if (setupReq->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002186 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302187 vos_mem_copy( &setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002188 &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2189 }
2190 /* Update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302191 if (setupReq->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002192 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302193 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002194 &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
2195 }
2196
2197 return ;
2198}
2199
2200/*
2201 * update peer Info recieved with TDLS setup RSP
2202 */
2203void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac,
2204 tLimTdlsLinkSetupPeer *setupPeer,
2205 tDot11fTDLSSetupRsp *setupRsp)
2206{
2207
2208 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302209 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupRsp->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002210
2211 if(setupRsp->SuppRates.present)
2212 {
2213 tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ;
2214 ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates);
2215 }
2216
2217 /* update QOS info, needed for Peer U-APSD session */
2218 if(setupRsp->QOSCapsStation.present)
2219 {
2220 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2221 &setupRsp->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002222 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."),
2223 setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd,
2224 setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd,
2225 setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002226 setupRsp->QOSCapsStation.qack));
2227 }
2228
2229 if(setupRsp->ExtSuppRates.present)
2230 {
2231 setupPeer->ExtRatesPresent = 1;
2232 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2233 &setupRsp->ExtSuppRates );
2234 }
2235 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302236 if (setupRsp->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002237 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302238 vos_mem_copy(&setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002239 &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2240 }
2241
2242 /* update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302243 if (setupRsp->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002244 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302245 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002246 &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
2247 }
2248
2249 return ;
2250}
2251#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002252
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302253/* This Function is similar to PopulateDot11fHTCaps, except that the HT Capabilities
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002254 * are considered from the AddStaReq rather from the cfg.dat as in PopulateDot11fHTCaps
2255 */
2256static tSirRetStatus limTdlsPopulateDot11fHTCaps(tpAniSirGlobal pMac, tpPESession psessionEntry,
2257 tSirTdlsAddStaReq *pTdlsAddStaReq, tDot11fIEHTCaps *pDot11f)
2258{
2259 tANI_U32 nCfgValue;
2260 tANI_U8 nCfgValue8;
2261 tSirMacHTParametersInfo *pHTParametersInfo;
2262 union {
2263 tANI_U16 nCfgValue16;
2264 tSirMacHTCapabilityInfo htCapInfo;
2265 tSirMacExtendedHTCapabilityInfo extHtCapInfo;
2266 } uHTCapabilityInfo;
2267
2268 tSirMacTxBFCapabilityInfo *pTxBFCapabilityInfo;
2269 tSirMacASCapabilityInfo *pASCapabilityInfo;
2270
2271 nCfgValue = pTdlsAddStaReq->htCap.capInfo;
2272
2273 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2274
2275 pDot11f->advCodingCap = uHTCapabilityInfo.htCapInfo.advCodingCap;
2276 pDot11f->mimoPowerSave = uHTCapabilityInfo.htCapInfo.mimoPowerSave;
2277 pDot11f->greenField = uHTCapabilityInfo.htCapInfo.greenField;
2278 pDot11f->shortGI20MHz = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
2279 pDot11f->shortGI40MHz = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
2280 pDot11f->txSTBC = uHTCapabilityInfo.htCapInfo.txSTBC;
2281 pDot11f->rxSTBC = uHTCapabilityInfo.htCapInfo.rxSTBC;
2282 pDot11f->delayedBA = uHTCapabilityInfo.htCapInfo.delayedBA;
2283 pDot11f->maximalAMSDUsize = uHTCapabilityInfo.htCapInfo.maximalAMSDUsize;
2284 pDot11f->dsssCckMode40MHz = uHTCapabilityInfo.htCapInfo.dsssCckMode40MHz;
2285 pDot11f->psmp = uHTCapabilityInfo.htCapInfo.psmp;
2286 pDot11f->stbcControlFrame = uHTCapabilityInfo.htCapInfo.stbcControlFrame;
2287 pDot11f->lsigTXOPProtection = uHTCapabilityInfo.htCapInfo.lsigTXOPProtection;
2288
2289 // All sessionized entries will need the check below
2290 if (psessionEntry == NULL) // Only in case of NO session
2291 {
2292 pDot11f->supportedChannelWidthSet = uHTCapabilityInfo.htCapInfo.supportedChannelWidthSet;
2293 }
2294 else
2295 {
2296 pDot11f->supportedChannelWidthSet = psessionEntry->htSupportedChannelWidthSet;
2297 }
2298
2299 /* Ensure that shortGI40MHz is Disabled if supportedChannelWidthSet is
2300 eHT_CHANNEL_WIDTH_20MHZ */
2301 if(pDot11f->supportedChannelWidthSet == eHT_CHANNEL_WIDTH_20MHZ)
2302 {
2303 pDot11f->shortGI40MHz = 0;
2304 }
2305
2306 dot11fLog(pMac, LOG2, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, shortGI20:%d, shortGI40: %d, dsssCck: %d"),
2307 pDot11f->supportedChannelWidthSet, pDot11f->mimoPowerSave, pDot11f->greenField,
2308 pDot11f->shortGI20MHz, pDot11f->shortGI40MHz, pDot11f->dsssCckMode40MHz);
2309
2310 nCfgValue = pTdlsAddStaReq->htCap.ampduParamsInfo;
2311
2312 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2313 pHTParametersInfo = ( tSirMacHTParametersInfo* ) &nCfgValue8;
2314
2315 pDot11f->maxRxAMPDUFactor = pHTParametersInfo->maxRxAMPDUFactor;
2316 pDot11f->mpduDensity = pHTParametersInfo->mpduDensity;
2317 pDot11f->reserved1 = pHTParametersInfo->reserved;
2318
2319 dot11fLog( pMac, LOG2, FL( "AMPDU Param: %x" ), nCfgValue);
2320
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302321 vos_mem_copy( pDot11f->supportedMCSSet, pTdlsAddStaReq->htCap.suppMcsSet,
2322 SIZE_OF_SUPPORTED_MCS_SET);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002323
2324 nCfgValue = pTdlsAddStaReq->htCap.extendedHtCapInfo;
2325
2326 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2327
2328 pDot11f->pco = uHTCapabilityInfo.extHtCapInfo.pco;
2329 pDot11f->transitionTime = uHTCapabilityInfo.extHtCapInfo.transitionTime;
2330 pDot11f->mcsFeedback = uHTCapabilityInfo.extHtCapInfo.mcsFeedback;
2331
2332 nCfgValue = pTdlsAddStaReq->htCap.txBFCapInfo;
2333
2334 pTxBFCapabilityInfo = ( tSirMacTxBFCapabilityInfo* ) &nCfgValue;
2335 pDot11f->txBF = pTxBFCapabilityInfo->txBF;
2336 pDot11f->rxStaggeredSounding = pTxBFCapabilityInfo->rxStaggeredSounding;
2337 pDot11f->txStaggeredSounding = pTxBFCapabilityInfo->txStaggeredSounding;
2338 pDot11f->rxZLF = pTxBFCapabilityInfo->rxZLF;
2339 pDot11f->txZLF = pTxBFCapabilityInfo->txZLF;
2340 pDot11f->implicitTxBF = pTxBFCapabilityInfo->implicitTxBF;
2341 pDot11f->calibration = pTxBFCapabilityInfo->calibration;
2342 pDot11f->explicitCSITxBF = pTxBFCapabilityInfo->explicitCSITxBF;
2343 pDot11f->explicitUncompressedSteeringMatrix = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrix;
2344 pDot11f->explicitBFCSIFeedback = pTxBFCapabilityInfo->explicitBFCSIFeedback;
2345 pDot11f->explicitUncompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrixFeedback;
2346 pDot11f->explicitCompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitCompressedSteeringMatrixFeedback;
2347 pDot11f->csiNumBFAntennae = pTxBFCapabilityInfo->csiNumBFAntennae;
2348 pDot11f->uncompressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->uncompressedSteeringMatrixBFAntennae;
2349 pDot11f->compressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->compressedSteeringMatrixBFAntennae;
2350
2351 nCfgValue = pTdlsAddStaReq->htCap.antennaSelectionInfo;
2352
2353 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2354
2355 pASCapabilityInfo = ( tSirMacASCapabilityInfo* ) &nCfgValue8;
2356 pDot11f->antennaSelection = pASCapabilityInfo->antennaSelection;
2357 pDot11f->explicitCSIFeedbackTx = pASCapabilityInfo->explicitCSIFeedbackTx;
2358 pDot11f->antennaIndicesFeedbackTx = pASCapabilityInfo->antennaIndicesFeedbackTx;
2359 pDot11f->explicitCSIFeedback = pASCapabilityInfo->explicitCSIFeedback;
2360 pDot11f->antennaIndicesFeedback = pASCapabilityInfo->antennaIndicesFeedback;
2361 pDot11f->rxAS = pASCapabilityInfo->rxAS;
2362 pDot11f->txSoundingPPDUs = pASCapabilityInfo->txSoundingPPDUs;
2363
Hoonki Lee66b75f32013-04-16 18:30:07 -07002364 pDot11f->present = pTdlsAddStaReq->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002365
2366 return eSIR_SUCCESS;
2367
2368}
2369
2370tSirRetStatus
2371limTdlsPopulateDot11fVHTCaps(tpAniSirGlobal pMac,
2372 tSirTdlsAddStaReq *pTdlsAddStaReq,
2373 tDot11fIEVHTCaps *pDot11f)
2374{
2375 tANI_U32 nCfgValue=0;
2376 union {
2377 tANI_U32 nCfgValue32;
2378 tSirMacVHTCapabilityInfo vhtCapInfo;
2379 } uVHTCapabilityInfo;
2380 union {
2381 tANI_U16 nCfgValue16;
2382 tSirMacVHTTxSupDataRateInfo vhtTxSupDataRateInfo;
2383 tSirMacVHTRxSupDataRateInfo vhtRxsupDataRateInfo;
2384 } uVHTSupDataRateInfo;
2385
Hoonki Lee66b75f32013-04-16 18:30:07 -07002386 pDot11f->present = pTdlsAddStaReq->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002387
2388 nCfgValue = pTdlsAddStaReq->vhtCap.vhtCapInfo;
2389 uVHTCapabilityInfo.nCfgValue32 = nCfgValue;
2390
2391 pDot11f->maxMPDULen = uVHTCapabilityInfo.vhtCapInfo.maxMPDULen;
2392 pDot11f->supportedChannelWidthSet = uVHTCapabilityInfo.vhtCapInfo.supportedChannelWidthSet;
2393 pDot11f->ldpcCodingCap = uVHTCapabilityInfo.vhtCapInfo.ldpcCodingCap;
2394 pDot11f->shortGI80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI80MHz;
2395 pDot11f->shortGI160and80plus80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI160and80plus80MHz;
2396 pDot11f->txSTBC = uVHTCapabilityInfo.vhtCapInfo.txSTBC;
2397 pDot11f->rxSTBC = uVHTCapabilityInfo.vhtCapInfo.rxSTBC;
2398 pDot11f->suBeamFormerCap = uVHTCapabilityInfo.vhtCapInfo.suBeamFormerCap;
2399 pDot11f->suBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.suBeamformeeCap;
2400 pDot11f->csnofBeamformerAntSup = uVHTCapabilityInfo.vhtCapInfo.csnofBeamformerAntSup;
2401 pDot11f->numSoundingDim = uVHTCapabilityInfo.vhtCapInfo.numSoundingDim;
2402 pDot11f->muBeamformerCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformerCap;
2403 pDot11f->muBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformeeCap;
2404 pDot11f->vhtTXOPPS = uVHTCapabilityInfo.vhtCapInfo.vhtTXOPPS;
2405 pDot11f->htcVHTCap = uVHTCapabilityInfo.vhtCapInfo.htcVHTCap;
2406 pDot11f->maxAMPDULenExp = uVHTCapabilityInfo.vhtCapInfo.maxAMPDULenExp;
2407 pDot11f->vhtLinkAdaptCap = uVHTCapabilityInfo.vhtCapInfo.vhtLinkAdaptCap;
2408 pDot11f->rxAntPattern = uVHTCapabilityInfo.vhtCapInfo.rxAntPattern;
2409 pDot11f->txAntPattern = uVHTCapabilityInfo.vhtCapInfo.txAntPattern;
2410 pDot11f->reserved1= uVHTCapabilityInfo.vhtCapInfo.reserved1;
2411
2412 pDot11f->rxMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.rxMcsMap;
2413
2414 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.rxHighest;
2415 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2416 pDot11f->rxHighSupDataRate = uVHTSupDataRateInfo.vhtRxsupDataRateInfo.rxSupDataRate;
2417
2418 pDot11f->txMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.txMcsMap;
2419
2420 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.txHighest;
2421 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2422 pDot11f->txSupDataRate = uVHTSupDataRateInfo.vhtTxSupDataRateInfo.txSupDataRate;
2423
2424 pDot11f->reserved3= uVHTSupDataRateInfo.vhtTxSupDataRateInfo.reserved;
2425
2426 limLogVHTCap(pMac, pDot11f);
2427
2428 return eSIR_SUCCESS;
2429
2430}
2431
2432static tSirRetStatus
2433limTdlsPopulateMatchingRateSet(tpAniSirGlobal pMac,
2434 tpDphHashNode pStaDs,
2435 tANI_U8 *pSupportedRateSet,
2436 tANI_U8 supporteRatesLength,
2437 tANI_U8* pSupportedMCSSet,
2438 tSirMacPropRateSet *pAniLegRateSet,
2439 tpPESession psessionEntry,
2440 tDot11fIEVHTCaps *pVHTCaps)
2441
2442{
2443 tSirMacRateSet tempRateSet;
2444 tANI_U32 i,j,val,min,isArate;
2445 tSirMacRateSet tempRateSet2;
2446 tANI_U32 phyMode;
2447 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2448 isArate=0;
Leela Venkata Kiran Kumar Reddy Chiralac7a12152014-02-03 11:20:14 -08002449 tempRateSet2.numRates = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002450
2451 // limGetPhyMode(pMac, &phyMode);
2452 limGetPhyMode(pMac, &phyMode, NULL);
2453
2454 // get own rate set
2455 val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2456 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302457 (tANI_U8 *) &tempRateSet.rate,
2458 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002459 {
2460 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002461 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07002462 val = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002463 }
2464 tempRateSet.numRates = val;
2465
2466 if (phyMode == WNI_CFG_PHY_MODE_11G)
2467 {
2468
2469 // get own extended rate set
2470 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2471 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302472 (tANI_U8 *) &tempRateSet2.rate,
2473 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002474 tempRateSet2.numRates = val;
2475 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002476
2477 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2478 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002479 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002480 goto error;
2481 }
2482
2483 /**
2484 * Handling of the rate set IEs is the following:
2485 * - keep only rates that we support and that the station supports
2486 * - sort and the rates into the pSta->rate array
2487 */
2488
2489 // Copy all rates in tempRateSet, there are 12 rates max
2490 for (i = 0; i < tempRateSet2.numRates; i++)
2491 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
2492
2493 tempRateSet.numRates += tempRateSet2.numRates;
2494
2495 /**
2496 * Sort rates in tempRateSet (they are likely to be already sorted)
2497 * put the result in tempRateSet2
2498 */
2499 tempRateSet2.numRates = 0;
2500
2501 for (i = 0;i < tempRateSet.numRates; i++)
2502 {
2503 min = 0;
2504 val = 0xff;
2505
2506 for(j = 0;j < tempRateSet.numRates; j++)
2507 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2508 {
2509 val = tempRateSet.rate[j] & 0x7f;
2510 min = j;
2511 }
2512
2513 tempRateSet2.rate[tempRateSet2.numRates++] = tempRateSet.rate[min];
2514 tempRateSet.rate[min] = 0xff;
2515 }
2516
2517 /**
2518 * Copy received rates in tempRateSet, the parser has ensured
2519 * unicity of the rates so there cannot be more than 12 . Need to Check this
2520 * TODO Sunil.
2521 */
Kaushik, Sushant92e6f872014-05-03 16:35:57 +05302522 if (supporteRatesLength > SIR_MAC_RATESET_EID_MAX)
2523 {
2524 limLog( pMac, LOGW, FL("Supported rates length %d more than "
2525 "the Max limit, reset to Max"),
2526 supporteRatesLength);
2527 supporteRatesLength = SIR_MAC_RATESET_EID_MAX;
2528 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002529 for (i = 0; i < supporteRatesLength; i++)
2530 {
2531 tempRateSet.rate[i] = pSupportedRateSet[i];
2532 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002533 tempRateSet.numRates = supporteRatesLength;
2534
2535 {
2536 tpSirSupportedRates rates = &pStaDs->supportedRates;
2537 tANI_U8 aRateIndex = 0;
2538 tANI_U8 bRateIndex = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302539 vos_mem_set( (tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002540
2541 for (i = 0;i < tempRateSet2.numRates; i++)
2542 {
2543 for (j = 0;j < tempRateSet.numRates; j++)
2544 {
2545 if ((tempRateSet2.rate[i] & 0x7F) ==
2546 (tempRateSet.rate[j] & 0x7F))
2547 {
2548#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2549 if ((bRateIndex > HAL_NUM_11B_RATES) || (aRateIndex > HAL_NUM_11A_RATES))
2550 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002551 limLog(pMac, LOGE, FL("Invalid number of rates (11b->%d, 11a->%d)"),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002552 bRateIndex, aRateIndex);
2553 return eSIR_FAILURE;
2554 }
2555#endif
2556 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2557 {
2558 isArate=1;
2559 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
2560 }
2561 else
2562 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2563 break;
2564 }
2565 }
2566 }
2567 }
2568
2569
2570 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
2571#ifdef FEATURE_WLAN_TDLS
2572 if (pStaDs->mlmStaContext.htCapability)
2573#else
2574 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2575 (pStaDs->mlmStaContext.htCapability))
2576#endif
2577 {
2578 val = SIZE_OF_SUPPORTED_MCS_SET;
2579 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2580 mcsSet,
2581 &val) != eSIR_SUCCESS)
2582 {
2583 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002584 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002585 goto error;
2586 }
2587
2588 for (i=0; i<val; i++)
2589 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2590
2591 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH :"));)
2592 for (i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2593 {
2594 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2595 }
2596 }
2597
2598#ifdef WLAN_FEATURE_11AC
2599 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2600#endif
2601 /**
2602 * Set the erpEnabled bit iff the phy is in G mode and at least
2603 * one A rate is supported
2604 */
2605 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2606 pStaDs->erpEnabled = eHAL_SET;
2607
2608
2609
2610 return eSIR_SUCCESS;
2611
2612 error:
2613
2614 return eSIR_FAILURE;
2615}
2616
2617static int limTdlsSelectCBMode(tDphHashNode *pStaDs, tpPESession psessionEntry)
2618{
2619 tANI_U8 channel = psessionEntry->currentOperChannel;
2620
2621 if ( pStaDs->mlmStaContext.vhtCapability )
2622 {
2623 if ( channel== 36 || channel == 52 || channel == 100 ||
2624 channel == 116 || channel == 149 )
2625 {
2626 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
2627 }
2628 else if ( channel == 40 || channel == 56 || channel == 104 ||
2629 channel == 120 || channel == 153 )
2630 {
2631 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
2632 }
2633 else if ( channel == 44 || channel == 60 || channel == 108 ||
2634 channel == 124 || channel == 157 )
2635 {
2636 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
2637 }
2638 else if ( channel == 48 || channel == 64 || channel == 112 ||
2639 channel == 128 || channel == 161 )
2640 {
2641 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
2642 }
2643 else if ( channel == 165 )
2644 {
2645 return 0;
2646 }
2647 }
2648 else if ( pStaDs->mlmStaContext.htCapability )
2649 {
2650 if ( channel== 40 || channel == 48 || channel == 56 ||
2651 channel == 64 || channel == 104 || channel == 112 ||
2652 channel == 120 || channel == 128 || channel == 136 ||
2653 channel == 144 || channel == 153 || channel == 161 )
2654 {
2655 return 1;
2656 }
2657 else if ( channel== 36 || channel == 44 || channel == 52 ||
2658 channel == 60 || channel == 100 || channel == 108 ||
2659 channel == 116 || channel == 124 || channel == 132 ||
2660 channel == 140 || channel == 149 || channel == 157 )
2661 {
2662 return 2;
2663 }
2664 else if ( channel == 165 )
2665 {
2666 return 0;
2667 }
2668 }
2669 return 0;
2670}
2671
Kiran V1ccee932012-12-12 14:49:46 -08002672/*
2673 * update HASH node entry info
2674 */
2675static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002676 tSirTdlsAddStaReq *pTdlsAddStaReq, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002677{
2678 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
2679 tDot11fIEHTCaps htCap, *htCaps;
Kiet Lam770920c2013-10-21 12:49:30 +05302680 tDot11fIEVHTCaps *pVhtCaps = NULL;
Hoonki Lee99e53782013-02-12 18:07:03 -08002681#ifdef WLAN_FEATURE_11AC
Kiet Lam770920c2013-10-21 12:49:30 +05302682 tDot11fIEVHTCaps vhtCap;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002683 tANI_U8 cbMode;
Hoonki Lee99e53782013-02-12 18:07:03 -08002684#endif
Kiran V1ccee932012-12-12 14:49:46 -08002685 tpDphHashNode pSessStaDs = NULL;
2686 tANI_U16 aid;
2687
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002688 if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_ADD)
2689 {
2690 PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
2691 }
2692 else if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE)
2693 {
2694 limTdlsPopulateDot11fHTCaps(pMac, NULL, pTdlsAddStaReq, &htCap);
2695 }
Kiran V1ccee932012-12-12 14:49:46 -08002696 htCaps = &htCap;
Hoonki Lee99e53782013-02-12 18:07:03 -08002697 if (htCaps->present)
Kiran V1ccee932012-12-12 14:49:46 -08002698 {
2699 pStaDs->mlmStaContext.htCapability = 1 ;
2700 pStaDs->htGreenfield = htCaps->greenField ;
2701 pStaDs->htSupportedChannelWidthSet = htCaps->supportedChannelWidthSet ;
2702 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
2703 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
2704 pStaDs->htAMpduDensity = htCaps->mpduDensity;
2705 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
2706 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
2707 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
2708 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
2709 limFillRxHighestSupportedRate(pMac,
2710 &pStaDs->supportedRates.rxHighestDataRate,
2711 htCaps->supportedMCSSet);
2712 pStaDs->baPolicyFlag = 0xFF;
Kiran V1ccee932012-12-12 14:49:46 -08002713 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
2714 }
2715 else
2716 {
2717 pStaDs->mlmStaContext.htCapability = 0 ;
2718 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
2719 }
Hoonki Lee99e53782013-02-12 18:07:03 -08002720#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002721 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002722 pVhtCaps = &vhtCap;
2723 if (pVhtCaps->present)
2724 {
2725 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302726
2727 if ((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
2728 pMac->roam.configParam.enableVhtFor24GHz)
2729 {
2730 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
2731 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
2732 }
2733 else
2734 {
2735 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
2736 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_40MHZ ;
2737 }
2738
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002739 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2740 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2741 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002742 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2743 }
2744 else
2745 {
2746 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002747 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002748 }
2749#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002750 /*Calculate the Secondary Coannel Offset */
2751 cbMode = limTdlsSelectCBMode(pStaDs, psessionEntry);
2752
2753 pStaDs->htSecondaryChannelOffset = cbMode;
2754
2755#ifdef WLAN_FEATURE_11AC
2756 if ( pStaDs->mlmStaContext.vhtCapability )
2757 {
2758 pStaDs->htSecondaryChannelOffset = limGetHTCBState(cbMode);
2759 }
2760#endif
Kiran V1ccee932012-12-12 14:49:46 -08002761
2762 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
2763 &psessionEntry->dph.dphHashTable) ;
2764
2765 /* Lets enable QOS parameter */
2766 pStaDs->qosMode = 1;
2767 pStaDs->wmeEnabled = 1;
2768 pStaDs->lleEnabled = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002769 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2770 */
2771 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002772
2773 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002774
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002775 /* TDLS Dummy AddSTA does not have HTCap,VHTCap,Rates info , is it OK ??
2776 */
2777 limTdlsPopulateMatchingRateSet(pMac, pStaDs, pTdlsAddStaReq->supported_rates,
2778 pTdlsAddStaReq->supported_rates_length,
2779 (tANI_U8 *)pTdlsAddStaReq->htCap.suppMcsSet,
2780 &pStaDs->mlmStaContext.propRateSet,
Kiet Lam770920c2013-10-21 12:49:30 +05302781 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002782
2783 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2784 */
2785 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002786
2787 return ;
2788}
2789
2790#ifdef FEATURE_WLAN_TDLS_INTERNAL
2791/*
2792 * find Peer in setup link list.
2793 */
2794
2795tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2796 tLimTdlsLinkSetupPeer **setupPeer)
2797{
2798 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2799 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2800 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2801
2802 while (linkSetupList != NULL)
2803 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302804 if (vos_mem_compare((tANI_U8 *) peerMac,
2805 (tANI_U8 *) linkSetupList->peerMac,
2806 sizeof(tSirMacAddr)) )
Kiran V1ccee932012-12-12 14:49:46 -08002807 {
2808 checkNode = TDLS_NODE_FOUND ;
2809 *setupPeer = linkSetupList ;
2810 break ;
2811 }
2812 linkSetupList = linkSetupList->next;
2813 }
2814
2815 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ;
2816}
2817
2818/*
2819 * find peer in Discovery list.
2820 * Dicovery list get populated in two instances, a) Recieved responses in reply
2821 * to discovery request b) If discover request is received from TDLS peer STA
2822 */
2823tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2824{
2825 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2826 tSirTdlsPeerInfo *peerInfo = NULL ;
2827
2828 while (discoveryList != NULL)
2829 {
2830 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2831 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002832 ("Peer in discovery list = " MAC_ADDRESS_STR),
2833 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002834
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302835 if (vos_mem_compare((tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002836 (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) )
2837 {
2838 break ;
2839 }
2840 discoveryList = discoveryList->next;
2841 }
2842
2843 return peerInfo ;
2844}
2845
2846/*
2847 * find peer in Discovery list by looking into peer state.
2848 * Dicovery list get populated in two instances, a) Recieved responses in reply
2849 * to discovery request b) If discover request is received from TDLS peer STA
2850 */
2851static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
2852 tANI_U8 state)
2853{
2854 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2855 tSirTdlsPeerInfo *peerInfo = NULL ;
2856
2857 while (discoveryList != NULL)
2858 {
2859 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2860 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002861 ("peerInfo Mac = " MAC_ADDRESS_STR),
2862 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002863
2864 if (peerInfo->tdlsPeerState == state)
2865 {
2866 break ;
2867 }
2868 discoveryList = discoveryList->next;
2869 }
2870
2871 return peerInfo ;
2872}
2873
2874/*
2875 * find peer in Setup list by looking into peer state.
2876 * setup list get populated in two instances, a) Recieved responses in reply
2877 * to setup request b) If discover request is received from TDLS peer STA
2878 */
2879static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
2880 tLimTdlsLinkSetupPeer **setupPeer)
2881{
2882
2883 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2884 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2885 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2886
2887 while (linkSetupList != NULL)
2888 {
2889 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002890 ("peer state = %02x"), (linkSetupList)->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08002891 if((linkSetupList)->tdls_link_state == state)
2892 {
2893 checkNode = TDLS_NODE_FOUND ;
2894 *setupPeer = linkSetupList ;
2895 break ;
2896 }
2897 linkSetupList = (linkSetupList)->next;
2898 }
2899
2900 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ;
2901}
2902
2903
2904/*
2905 * delete Peer from Setup Link
2906 */
2907void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2908{
2909 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2910 tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ;
2911 tLimTdlsLinkSetupPeer *currentNode = NULL ;
2912 tLimTdlsLinkSetupPeer *prevNode = NULL ;
2913
2914 for(currentNode = *linkSetupList ; currentNode != NULL ;
2915 prevNode = currentNode, currentNode = currentNode->next)
2916 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302917 if (vos_mem_compare( (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002918 (tANI_U8 *) currentNode->peerMac,
2919 sizeof(tSirMacAddr)) )
2920 {
2921 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002922 ("Del Node for Peer = " MAC_ADDRESS_STR),
2923 MAC_ADDR_ARRAY(currentNode->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002924 /* if it's first Node */
2925 if(NULL == prevNode)
2926 {
2927 *linkSetupList = currentNode->next ;
2928 }
2929 else
2930 {
2931 prevNode->next = currentNode->next ;
2932 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302933 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08002934 return ;
2935 }
2936 }
2937
2938 return ;
2939}
2940
2941
2942
2943/*
2944 * TDLS discovery request frame received from TDLS peer STA..
2945 */
2946static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac,
2947 tANI_U8 *pBody, tANI_U32 frmLen )
2948{
2949 tDot11fTDLSDisReq tdlsDisReq = {{0}} ;
2950 tANI_U32 status = 0 ;
2951 tLimDisResultList *tdlsDisResult = NULL ;
2952 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
2953 tSirMacAddr peerMac = {0} ;
2954 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2955 tSirTdlsPeerInfo *peerInfo = NULL ;
2956 tpPESession psessionEntry = NULL ;
2957 tANI_U8 sessionId = 0 ;
2958
2959 status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ;
2960
2961 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002962 ("TDLS dis request dialog = %d"), tdlsDisReq.DialogToken.token);
Kiran V1ccee932012-12-12 14:49:46 -08002963
2964 if ( DOT11F_FAILED( status ) )
2965 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002966 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
2967 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08002968 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2969 return eSIR_FAILURE;
2970 }
2971 else if ( DOT11F_WARNED( status ) )
2972 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002973 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
2974 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08002975 status, frmLen );
2976 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2977 }
2978
2979 /*
2980 * find session entry using BSSID in link identifier, not using MAC
2981 * header beacuse, there is cases in TDLS, there may be BSSID will not
2982 * be present in header
2983 */
2984 psessionEntry = peFindSessionByBssid(pMac,
2985 &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ;
2986 if(NULL == psessionEntry)
2987 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002988 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08002989 ("no Session entry for TDLS session (bssid "MAC_ADDR_ARRAY")"),
2990 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08002991
2992 //VOS_ASSERT(0) ;
2993 return eSIR_FAILURE;
2994 }
2995
2996 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302997 status = vos_mem_compare( &psessionEntry->bssId[0],
Kiran V1ccee932012-12-12 14:49:46 -08002998 &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
2999 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003000 ("lim BSSID "MAC_ADDRESS_STR),
3001 MAC_ADDR_ARRAY( psessionEntry->bssId));
Kiran V1ccee932012-12-12 14:49:46 -08003002
3003 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003004 ("Dis req from BSSID "MAC_ADDRESS_STR),
3005 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003006 if(!status)
3007 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003008 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003009
3010 return eSIR_FAILURE ;
3011 }
3012
3013 /*
3014 * check if this is echo of our transmitted discovery request
3015 * drop it here, TODO: better to drop this in TL.
3016 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303017 status = vos_mem_compare( psessionEntry->selfMacAddr,
Kiran V1ccee932012-12-12 14:49:46 -08003018 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3019 sizeof(tSirMacAddr)) ;
3020 if(status)
3021 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003022 limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003023 return eSIR_FAILURE ;
3024 }
3025
3026 /*
3027 * while processing Discovery request from Peer,
3028 * STA_MAC--> MAC of TDLS discovery initiator
3029 * STA_PEER_MAC--> MAC of TDLS discovery responder.
3030 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303031 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003032 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3033 sizeof(tSirMacAddr)) ;
3034 /* TODO, do more validation */
3035
3036 /* see if discovery is already in progress */
3037 peerInfo = limTdlsFindDisPeer(pMac, peerMac) ;
3038
3039 if(NULL == peerInfo)
3040 {
3041 /*
3042 * we are allocating peer info for individual peers found in TDLS
3043 * discovery, we need to keep adding TDLS peers till we have timed
3044 * out. We are freeing this memory at the time we are sending this
3045 * collected peer info to SME.
3046 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303047 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3048 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003049 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003050 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery "
3051 "reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003052 return eSIR_FAILURE ;
3053 }
3054
3055
3056 peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3057 peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ;
3058 peerInfo->dialog = tdlsDisReq.DialogToken.token ;
3059
3060 peerInfo->sessionId = psessionEntry->peSessionId;
3061
3062 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303063 vos_mem_copy( peerInfo->peerMac, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08003064
3065 /*
3066 * Now, as per D13, there will not be any Supp rates, ext Supp rates
3067 * info in Discovery request frames, so we are populating this info
3068 * locally to pass it to ADD STA.
3069 */
3070 do
3071 {
3072 tDot11fIESuppRates suppRates = {0} ;
3073 tDot11fIEExtSuppRates extSuppRates = {0} ;
3074 tANI_U16 caps = 0 ;
3075 tDot11fFfCapabilities capsInfo = {0} ;
3076 tDot11fIEHTCaps HTCaps = {0} ;
3077 /* populate supported rate IE */
3078 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3079 &suppRates, psessionEntry );
3080 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3081 &suppRates);
3082 /* Populate extended supported rates */
3083 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3084 &extSuppRates, psessionEntry );
3085
3086 peerInfo->ExtRatesPresent = 1;
3087 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3088 &extSuppRates);
3089
3090 if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
3091 {
3092 /*
3093 * Could not get Capabilities value
3094 * from CFG. Log error.
3095 */
3096 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003097 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08003098 }
3099 swapBitField16(caps, ( tANI_U16* )&capsInfo );
3100 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303101 tdlsUpdateCapInfo(&peerInfo->capabilityInfo, &capsInfo) ;
Kiran V1ccee932012-12-12 14:49:46 -08003102
3103 PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps );
3104 limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ;
3105
3106 } while (0) ;
3107
3108 /* now add this new found discovery node into tdls discovery list */
3109 tdlsDisResult->next = *disResultList ;
3110 *disResultList = tdlsDisResult ;
3111 pMac->lim.gLimTdlsDisStaCount++ ;
3112
3113 /* See if for this peer already entry in setup Link */
3114 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3115
3116 /*
3117 * if there is no entry for this peer in setup list, we need to
3118 * do add sta for this peer to transmit discovery rsp.
3119 */
3120 if(NULL == setupPeer)
3121 {
3122 /* To start with, send add STA request to HAL */
3123 pMac->lim.gLimAddStaTdls = true ;
3124 peerInfo->delStaNeeded = true ;
3125
3126 if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac,
3127 peerInfo, psessionEntry))
3128 {
3129 VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003130 limLog(pMac, LOGE, "Add STA for dis response is failed ") ;
Kiran V1ccee932012-12-12 14:49:46 -08003131 return eSIR_FAILURE ;
3132 }
3133 } /* use setup link sta ID for discovery rsp */
3134 else
3135 {
3136 peerInfo->delStaNeeded = false ;
3137 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
3138 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
3139 }
3140
3141 }
3142 else
3143 {
3144 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003145 ("discovery procedure in progress for this peer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003146 }
3147
3148 return eSIR_SUCCESS ;
3149}
3150
3151/* Process TDLS setup Request Frame */
3152
3153static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac,
3154 tANI_U8 *pBody, tANI_U32 frmLen)
3155{
3156
3157 tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ;
3158 tANI_U32 status = 0 ;
3159 tpPESession psessionEntry = NULL ;
3160 tANI_U8 sessionId = 0 ;
3161 tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ;
3162 tANI_U8 previousState = TDLS_LINK_IDLE_STATE ;
3163 /* create node for Link setup */
3164 tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
3165 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3166 tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ;
3167
3168 status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ;
3169
3170 if ( DOT11F_FAILED( status ) )
3171 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003172 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3173 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003174 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3175 return eSIR_FAILURE;
3176 }
3177 else if ( DOT11F_WARNED( status ) )
3178 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003179 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3180 "setup Request frame (0x%08x, %d bytes):"),
3181 status, frmLen );
Kiran V1ccee932012-12-12 14:49:46 -08003182 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3183 }
3184 /*
3185 * find session entry using BSSID in link identifier, not using MAC
3186 * header beacuse, there is cases in TDLS, there may be BSSID will not
3187 * be present in header
3188 */
3189 psessionEntry = peFindSessionByBssid(pMac,
3190 &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ;
3191 if(NULL == psessionEntry)
3192 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003193 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003194 ("no Session entry for TDLS session (bssid "
3195 MAC_ADDRESS_STR")"),
3196 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003197
3198 //VOS_ASSERT(0) ;
3199 return eSIR_FAILURE ;
3200 }
3201 /* TODO: we don;t need this check now, varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303202 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003203 &tdlsSetupReq.LinkIdentifier.bssid[0],
3204 sizeof(tSirMacAddr)) ;
3205
3206 if(!status)
3207 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003208 limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003209
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303210 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
3211 tdlsSetupReq.DialogToken.token, psessionEntry,
3212 TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003213 return eSIR_FAILURE ;
3214 }
3215
3216#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3217 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ)
3218 {
3219 /* simply ignore this setup request packet */
3220 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003221 ("TDLS negative running: ignore TDLS Setup Req packet"));
Kiran V1ccee932012-12-12 14:49:46 -08003222 return eSIR_SUCCESS ;
3223 }
3224 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3225 {
3226 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003227 ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req"));
Kiran V1ccee932012-12-12 14:49:46 -08003228 /* format TDLS discovery request frame and transmit it */
3229 limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry,
3230 NULL, 0) ;
3231 }
3232#endif
3233 /* TODO, do more validation */
3234
3235 if(!limTdlsFindLinkPeer(pMac,
3236 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3237 &tmpSetupPeer))
3238 {
3239 tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3240
3241 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003242 ("Link is already setup with this peer" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003243 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003244 ("state = %d"), tmpSetupPeer->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08003245 //return eSIR_FAILURE ;
3246
3247 if(tmpSetupPeer == NULL)
3248 {
3249 VOS_ASSERT(0) ;
3250 return eSIR_FAILURE ;
3251
3252 }
3253 switch(tmpSetupPeer->tdls_link_state)
3254 {
3255
3256 case TDLS_LINK_SETUP_START_STATE:
3257 {
3258 v_SINT_t macCompare = 0 ;
3259 macCompare= vos_mem_compare2(tmpSetupPeer->peerMac,
3260 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
3261 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003262 ("MAC comparison Rslt = %d"), macCompare ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003263 if(0 > macCompare)
3264 {
3265 /*
3266 * Delete our Setup Request/Peer info and honour Peer
3267 * Setup Request, go ahead and respond for this
3268 */
3269 /* Deactivate the timer */
3270 tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ;
3271#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3272 if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3273 != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3274#endif
3275 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE,
3276 tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP);
3277
3278 limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ;
3279 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3280 }
3281 else if(0 < macCompare)
3282 {
3283 /*
3284 * Go ahead with current setup as peer is going to
3285 * respond for setup request
3286 */
3287 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3288 }
3289 else
3290 {
3291 /* same MAC, not possible */
3292 VOS_ASSERT(0) ;
3293 }
3294
3295 break ;
3296 }
3297#if 1
3298 case TDLS_LINK_SETUP_DONE_STATE:
3299 {
3300 tpDphHashNode pStaDs = NULL ;
3301
3302 previousState = TDLS_LINK_SETUP_WAIT_STATE ;
3303 currentState = TDLS_LINK_TEARDOWN_START_STATE ;
3304 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3305 ("link Setup Done state " )) ;
3306 tmpSetupPeer->tdls_prev_link_state = previousState ;
3307 tmpSetupPeer->tdls_link_state = currentState ;
3308 setupPeer = tmpSetupPeer ;
3309#if 0
3310 /* Send Teardown to this Peer and Initiate new TDLS Setup */
3311 limSendTdlsTeardownFrame(pMac,
3312 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3313 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ;
3314#else
3315
3316 /* tdls_hklee: send message to HAL before it is deleted, cause */
3317 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3318
3319 /* send del STA to remove context for this TDLS STA */
3320 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3321
3322 /* now send indication to SME-->HDD->TL to remove STA from TL */
3323
3324 if(pStaDs)
3325 {
3326 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3327 pStaDs, eSIR_SUCCESS) ;
3328
3329 /* send Teardown Ind to SME */
3330 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3331 eWNI_SME_TDLS_TEARDOWN_IND) ;
3332 /* remove node from setup list */
3333 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3334 }
3335#endif
3336 //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE;
3337 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3338 break ;
3339
3340 }
3341 default:
3342 {
3343 VOS_ASSERT(0) ;
3344 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003345 ("link Setup is Recieved in unknown state" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003346 break ;
3347 }
3348#endif
3349 }
3350 if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE)
3351 return eSIR_FAILURE ;
3352 }
3353
3354 if(currentState != TDLS_LINK_TEARDOWN_START_STATE)
3355 {
3356 /*
3357 * Now we are sure to send discovery response frame to TDLS discovery
3358 * initiator, we don't care, if this request is unicast ro broadcast,
3359 * we simply, send discovery response frame on direct link.
3360 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303361 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
3362 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08003363 {
3364 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003365 ( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08003366 return eSIR_MEM_ALLOC_FAILED;
3367 }
3368
3369 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3370 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3371 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3372 setupPeer->tdls_prev_link_state = previousState ;
3373 setupPeer->tdls_link_state = currentState ;
3374 /* TDLS_sessionize: remember sessionId for future */
3375 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3376 setupPeer->tdls_bIsResponder = 0;
3377
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303378 vos_mem_copy(setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003379 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3380 sizeof(tSirMacAddr)) ;
3381
3382 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003383 ("Setup REQ MAC = " MAC_ADDRESS_STR),
3384 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003385
3386 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3387 pMac->lim.gLimAddStaTdls = true ;
3388
3389 /* To start with, send add STA request to HAL */
3390 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac,
3391 setupPeer, psessionEntry))
3392 {
3393 VOS_ASSERT(0) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303394 vos_mem_free((void **) &setupPeer) ;
Kiran V1ccee932012-12-12 14:49:46 -08003395 return eSIR_FAILURE ;
3396 }
3397
3398 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303399 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003400 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3401
3402 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3403 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3404 (tANI_U32)setupPeer->peerMac,
3405 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3406 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3407
3408 /* update setup peer list */
3409 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
3410 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
3411 }
3412 else
3413 {
3414 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3415 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3416 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3417 setupPeer->tdls_prev_link_state = previousState ;
3418 setupPeer->tdls_link_state = currentState ;
3419 /* TDLS_sessionize: remember sessionId for future */
3420 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3421 setupPeer->tdls_bIsResponder = 0;
3422
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303423 vos_mem_copy( setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003424 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3425 sizeof(tSirMacAddr)) ;
3426
3427 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003428 ("Setup REQ MAC = "MAC_ADDRESS_STR),
3429 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003430
3431 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3432 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303433 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003434 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3435
3436 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3437 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3438 (tANI_U32)setupPeer->peerMac,
3439 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3440 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3441 }
3442
3443
3444 return eSIR_SUCCESS ;
3445
3446}
3447
3448/*
3449 * TDLS discovery request frame received from TDLS peer STA..
3450 */
3451static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac,
3452 tANI_U8 *pBody, tANI_U32 frmLen )
3453{
3454 tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ;
3455 tANI_U32 status = 0 ;
3456 tSirMacAddr peerMac = {0} ;
3457 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3458 tpPESession psessionEntry = NULL ;
3459 tANI_U8 sessionId = 0 ;
3460
3461 status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ;
3462
3463 if ( DOT11F_FAILED( status ) )
3464 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003465 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3466 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003467 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3468 return eSIR_FAILURE;
3469 }
3470 else if ( DOT11F_WARNED( status ) )
3471 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003472 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3473 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003474 status, frmLen );
3475 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3476 }
3477
3478 /*
3479 * find session entry using BSSID in link identifier, not using MAC
3480 * header beacuse, there is cases in TDLS, there may be BSSID will not
3481 * be present in header
3482 */
3483 psessionEntry = peFindSessionByBssid(pMac,
3484 &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ;
3485 if(NULL == psessionEntry)
3486 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003487 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003488 ("no Session entry for TDLS session (bssid "
3489 MAC_ADDRESS_STR")"),
3490 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003491
3492 //VOS_ASSERT(0) ;
3493 return eSIR_FAILURE;
3494 }
3495
3496 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303497 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003498 &tdlsSetupRsp.LinkIdentifier.bssid[0],
3499 sizeof(tSirMacAddr)) ;
3500
3501 if(!status)
3502 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003503 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003504
3505 VOS_ASSERT(0) ;
3506 return eSIR_FAILURE ;
3507 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303508 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003509 &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0],
3510 sizeof(tSirMacAddr)) ;
3511
3512 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003513 ("TDLS setup RSP peer = "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003514 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3515
3516 if(NULL == setupPeer)
3517 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003518 limLog( pMac, LOGE, FL("unknown setup Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003519 return eSIR_FAILURE ;
3520 }
3521
3522 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003523 ("deactivating Setup RSP timer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003524
3525 /* Deactivate the timer */
3526 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ;
3527
3528 /*
3529 * TDLS Setup RSP is recieved with Failure, Delete this STA entry
3530 * don't respond with TDLS CNF frame.
3531 */
3532 if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status)
3533 {
3534 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3535 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003536 ("setup RSP with Failure Code")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003537 return eSIR_FAILURE ;
3538 }
3539
3540 /* update Link Info */
3541 limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ;
3542
3543 /* TODO, do more validation */
3544
3545
3546 /*
3547 * Now we are sure to send link setup CNF frame to TDLS link setup
3548 * reponded, now we will create dph hash entry and send add STA to HAL
3549 */
3550
3551 pMac->lim.gLimAddStaTdls = true ;
3552 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac,
3553 setupPeer, psessionEntry))
3554 {
3555 /* through error */
3556 VOS_ASSERT(0) ;
3557 return eSIR_FAILURE ;
3558 }
3559 /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */
3560
3561
3562 /* send TDLS confim frame to TDLS Peer STA */
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05303563 limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, 0, psessionEntry, NULL, 0) ;
Kiran V1ccee932012-12-12 14:49:46 -08003564
3565 /*
3566 * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and
3567 * wait for Setup CNF transmission on air, once we receive tx complete
3568 * message, we will change the peer state and send message to SME
3569 * callback..
3570 */
3571 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3572 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ;
3573
3574 return eSIR_SUCCESS ;
3575}
3576/*
3577 * TDLS setup CNF frame processing ..
3578 */
3579
3580static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac,
3581 tANI_U8 *pBody, tANI_U32 frmLen)
3582{
3583 tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ;
3584 tANI_U32 status = 0 ;
3585 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3586 tpPESession psessionEntry = NULL ;
3587 tANI_U8 sessionId = 0 ;
3588
3589 status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ;
3590
3591 if ( DOT11F_FAILED( status ) )
3592 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003593 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3594 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003595 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3596 return eSIR_FAILURE;
3597 }
3598 else if ( DOT11F_WARNED( status ) )
3599 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003600 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3601 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003602 status, frmLen );
3603 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3604 }
3605 /*
3606 * find session entry using BSSID in link identifier, not using MAC
3607 * header beacuse, there is cases in TDLS, there may be BSSID will not
3608 * be present in header
3609 */
3610 psessionEntry = peFindSessionByBssid(pMac,
3611 &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ;
3612 if(NULL == psessionEntry)
3613 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003614 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003615 ("no Session entry for TDLS session (bssid "
3616 MAC_ADDRESS_STR")"),
3617 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003618
3619 //VOS_ASSERT(0) ;
3620 return eSIR_FAILURE;
3621 }
3622
3623 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303624 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003625 &tdlsSetupCnf.LinkIdentifier.bssid[0],
3626 sizeof(tSirMacAddr)) ;
3627
3628 if(!status)
3629 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003630 limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003631
3632 VOS_ASSERT(0) ;
3633 return eSIR_FAILURE ;
3634 }
3635 /* TODO, do more validation */
3636 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003637 ("setup Cnf peer MAc = "MAC_ADDRESS_STR),
3638 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.InitStaAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003639
3640 limTdlsFindLinkPeer(pMac,
3641 &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
3642 &setupPeer) ;
3643
3644 if(NULL == setupPeer)
3645 {
3646 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003647 (" unknown setup CNF frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003648 VOS_ASSERT(0) ;
3649 return eSIR_FAILURE ;
3650 }
3651 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003652 ("setup CNF peer MAC = "MAC_ADDRESS_STR),
3653 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003654 /*T match dialog token, before proceeding further */
3655 if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token)
3656 {
3657 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003658 ("setup CNF frame not matching with setup RSP")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003659 VOS_ASSERT(0) ;
3660 return eSIR_FAILURE ;
3661 }
3662
3663 /*
3664 * Now we are sure that, this set CNF is for us, now stop
3665 * the running timer..
3666 */
3667 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ;
3668
3669 /* change TDLS peer State */
3670 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3671 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
3672
3673 /* send indication to SME that, new link is setup */
3674 limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ;
3675
3676 /* tdls_hklee: prepare PTI template and send it to HAL */
3677 limTdlsLinkEstablish(pMac, (setupPeer)->peerMac);
3678
3679 return eSIR_SUCCESS ;
3680
3681}
3682
3683/*
3684 * TDLS discovery response frame processing ..
3685 */
3686
3687static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac,
3688 tANI_U8 *pBody, tANI_U32 frmLen,
3689 tANI_S8 rssi, tpPESession psessionEntry)
3690{
3691 tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ;
3692 tANI_U32 status = 0 ;
3693 tLimDisResultList *tdlsDisResult = NULL ;
3694 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
3695 tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ;
3696
3697 status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ;
3698
3699 if ( DOT11F_FAILED( status ) )
3700 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003701 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3702 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003703 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3704 return eSIR_FAILURE;
3705 }
3706 else if ( DOT11F_WARNED( status ) )
3707 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003708 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3709 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003710 status, frmLen );
3711 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);)
3712 }
3713 /*TODO: match dialog token, before proceeding further */
3714
3715 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303716 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003717 &tdlsDisRsp.LinkIdentifier.bssid[0],
3718 sizeof(tSirMacAddr)) ;
3719
3720 if(!status)
3721 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003722 limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003723 return eSIR_FAILURE ;
3724 }
3725 /* TODO, do more validation */
3726
3727 if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
3728 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003729 limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003730 return eSIR_FAILURE ;
3731 }
3732
3733 pMac->lim.gLimTdlsDisStaCount++ ;
3734
3735 /*
3736 * we are allocating peer info for individual peers found in TDLS
3737 * discovery, we need to keep adding TDLS peers till we have timed
3738 * out. We are freeing this memory at the time we are sending this
3739 * collected peer info to SME.
3740 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303741 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3742 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003743 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003744 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003745 return eSIR_FAILURE ;
3746 }
3747
3748 do
3749 {
3750 tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3751
3752 /* Populate peer info of tdls discovery result */
3753 peerInfo->sessionId = psessionEntry->peSessionId;
3754 /*
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303755 * When we receive DIS RSP from peer MAC,
Kiran V1ccee932012-12-12 14:49:46 -08003756 * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
3757 * will carry our MAC.
3758 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303759 vos_mem_copy( peerInfo->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003760 &tdlsDisRsp.LinkIdentifier.RespStaAddr[0],
3761 sizeof(tSirMacAddr)) ;
3762
3763 /* update RSSI for this TDLS peer STA */
3764 peerInfo->tdlsPeerRssi = rssi ;
3765
3766 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303767 tdlsUpdateCapInfo(&peerInfo->capabilityInfo,
Kiran V1ccee932012-12-12 14:49:46 -08003768 &tdlsDisRsp.Capabilities) ;
3769
3770 /* update Supp rates */
3771 if(tdlsDisRsp.SuppRates.present)
3772 {
3773 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3774 &tdlsDisRsp.SuppRates );
3775 }
3776
3777 /* update EXT supp rates */
3778 if(tdlsDisRsp.ExtSuppRates.present)
3779 {
3780 peerInfo->ExtRatesPresent = 1;
3781 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3782 &tdlsDisRsp.ExtSuppRates );
3783 }
3784 /* update HT caps */
3785 if (tdlsDisRsp.HTCaps.present)
3786 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303787 vos_mem_copy( &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08003788 sizeof( tDot11fIEHTCaps ) );
3789 }
Kiran V1ccee932012-12-12 14:49:46 -08003790 } while(0) ;
3791
3792 /* now add this new found discovery node into tdls discovery list */
3793 tdlsDisResult->next = *disResultList ;
3794 *disResultList = tdlsDisResult ;
3795
3796 return eSIR_SUCCESS ;
3797}
3798
3799/*
3800 * Process TDLS Teardown request frame from TDLS peer STA
3801 */
3802static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac,
3803 tANI_U8 *pBody, tANI_U32 frmLen )
3804{
3805 tDot11fTDLSTeardown tdlsTeardown = {{0}} ;
3806 tANI_U32 status = 0 ;
3807 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3808 tpPESession psessionEntry = NULL ;
3809 tANI_U8 sessionId = 0 ;
3810
3811 status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ;
3812
3813 if ( DOT11F_FAILED( status ) )
3814 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003815 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3816 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003817 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3818 return eSIR_FAILURE;
3819 }
3820 else if ( DOT11F_WARNED( status ) )
3821 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003822 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3823 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003824 status, frmLen );
3825 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3826 }
3827
3828 /*
3829 * find session entry using BSSID in link identifier, not using MAC
3830 * header beacuse, there is cases in TDLS, there may be BSSID will not
3831 * be present in header
3832 */
3833 psessionEntry = peFindSessionByBssid(pMac,
3834 &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ;
3835 if(NULL == psessionEntry)
3836 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003837 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003838 ("no Session entry for TDLS session (bssid "
3839 MAC_ADDRESS_STR")"),
3840 MAC_ADDR_ARRAY(tdlsTeardown.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003841
3842 //VOS_ASSERT(0) ;
3843 return eSIR_FAILURE;
3844 }
3845
3846 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303847 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003848 &tdlsTeardown.LinkIdentifier.bssid[0],
3849 sizeof(tSirMacAddr)) ;
3850
3851
3852 if(!status)
3853 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003854 limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003855 VOS_ASSERT(0) ;
3856 return eSIR_FAILURE ;
3857 }
3858
3859 limTdlsFindLinkPeer(pMac,
3860 &tdlsTeardown.LinkIdentifier.InitStaAddr[0],
3861 &setupPeer) ;
3862
3863 if(NULL == setupPeer)
3864 {
3865 //ignore
3866 //VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003867 limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored") );
Kiran V1ccee932012-12-12 14:49:46 -08003868
3869 return eSIR_FAILURE ;
3870 }
3871 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003872 ("teardown for peer "MAC_ADDRESS_STR),
3873 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003874
3875 switch(tdlsTeardown.Reason.code)
3876 {
3877 case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON:
3878 {
3879 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003880 ("teardown with unspecified reason")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003881 break ;
3882 }
3883 case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
3884 {
3885 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003886 (" Teardown from AP, TDLS peer unreachable")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003887 break ;
3888 }
3889 default:
3890 {
3891 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003892 (" unknown teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003893 break ;
3894 }
3895 }
3896
3897 /* change TDLS peer State */
3898 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3899 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
3900
3901 do
3902 {
3903 tpDphHashNode pStaDs = NULL ;
3904
3905 /* tdls_hklee: send message to HAL before it is deleted, cause */
3906 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3907
3908 /* send del STA to remove context for this TDLS STA */
3909 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3910
3911 /* now send indication to SME-->HDD->TL to remove STA from TL */
3912
3913 if(pStaDs)
3914 {
3915 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3916 pStaDs, eSIR_SUCCESS) ;
3917
3918 /* send Teardown Ind to SME */
3919 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3920 eWNI_SME_TDLS_TEARDOWN_IND) ;
3921 /* remove node from setup list */
3922 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3923 }
3924
3925 }while(0) ;
3926
3927 return status ;
3928}
3929
3930/*
3931 * Common processing of TDLS action frames recieved
3932 */
3933void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd)
3934{
3935 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd);
3936 tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd))
3937 ? (( sizeof( eth_890d_header ))) :(0)) ;
3938
3939 tANI_U8 category = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ;
3940 tANI_U8 action = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ;
3941 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
3942 tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
3943 //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd);
3944
3945 if(category != SIR_MAC_ACTION_TDLS)
3946 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003947 limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored"), category );
Kiran V1ccee932012-12-12 14:49:46 -08003948 return ;
3949 }
3950
3951 frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003952 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 -08003953 action, limTraceTdlsActionString(action) ));
3954
3955 switch(action)
3956 {
3957
3958 case SIR_MAC_TDLS_SETUP_REQ:
3959 {
3960 limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ;
3961 break ;
3962 }
3963 case SIR_MAC_TDLS_SETUP_RSP:
3964 {
3965 limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ;
3966 break ;
3967 }
3968 case SIR_MAC_TDLS_SETUP_CNF:
3969 {
3970 limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ;
3971 break ;
3972 }
3973 case SIR_MAC_TDLS_TEARDOWN:
3974 {
3975 limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ;
3976 break ;
3977 }
3978 case SIR_MAC_TDLS_DIS_REQ:
3979 {
3980 limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ;
3981 break ;
3982 }
3983 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
3984 case SIR_MAC_TDLS_CH_SWITCH_REQ:
3985 case SIR_MAC_TDLS_CH_SWITCH_RSP:
3986 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
3987 default:
3988 {
3989 break ;
3990 }
3991 }
3992
3993 return ;
3994}
3995
3996/*
3997 * ADD sta for dis response fame sent on direct link
3998 */
3999static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4000 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry)
4001{
4002 tpDphHashNode pStaDs = NULL ;
4003 tSirRetStatus status = eSIR_SUCCESS ;
4004 tANI_U16 aid = 0 ;
4005
4006 if(NULL == peerInfo)
4007 {
4008 VOS_ASSERT(0) ;
4009 return status ;
4010
4011 }
4012 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004013 ("ADD STA peer MAC: "MAC_ADDRESS_STR),
4014 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004015
4016
4017 if(NULL != dphLookupHashEntry(pMac, peerMac,
4018 &aid, &psessionEntry->dph.dphHashTable))
4019 {
4020 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004021 (" there is hash entry for this client")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004022 status = eSIR_FAILURE ;
4023 VOS_ASSERT(0) ;
4024 return status ;
4025 }
4026
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004027 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004028
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004029 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4030 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4031
Kiran V1ccee932012-12-12 14:49:46 -08004032 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4033
4034 if (pStaDs)
4035 {
4036 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4037 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4038 }
4039 pStaDs = dphAddHashEntry(pMac, peerMac, aid,
4040 &psessionEntry->dph.dphHashTable) ;
4041
4042 if(NULL == pStaDs)
4043 {
4044 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004045 (" add hash entry failed")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004046 status = eSIR_FAILURE ;
4047 VOS_ASSERT(0) ;
4048 return status;
4049 }
4050 if(eSIR_SUCCESS == status)
4051 {
4052#ifdef TDLS_RATE_DEBUG
4053 tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ;
4054 tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ;
4055 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004056 ("pSta DS [%p] "), pStaDs) ;
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 ("peerInfo->tdlsPeerSuppRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004059 (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
4060 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004061 ("peerInfo->tdlsPeerExtRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004062 (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
4063 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004064 ("peerInfo->tdlsPeerPropRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004065 (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
4066 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004067 ("peerInfo->mcs = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004068 (tANI_U8 *)peerInfo->supportedMCSSet) ;
4069 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004070 ("num of supp rates = %02x"), suppRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004071 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004072 ("num of ext rates = %01x"), extRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004073#endif
4074
4075 /* Populate matching rate set */
4076#ifdef WLAN_FEATURE_11AC
4077 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4078 &peerInfo->tdlsPeerSuppRates,
4079 &peerInfo->tdlsPeerExtRates,
4080 peerInfo->supportedMCSSet,
4081 &pStaDs->mlmStaContext.propRateSet,
4082 psessionEntry, NULL))
4083#else
4084 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4085 &peerInfo->tdlsPeerSuppRates,
4086 &peerInfo->tdlsPeerExtRates,
4087 peerInfo->supportedMCSSet,
4088 &pStaDs->mlmStaContext.propRateSet,
4089 psessionEntry))
4090#endif
4091 {
4092 VOS_ASSERT(0) ;
4093 }
4094
4095
4096 pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304097 vos_mem_copy( pStaDs->staAddr, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08004098 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004099 ("Add STA for Peer: "MAC_ADDRESS_STR),
4100 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004101
4102
4103 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4104
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004105 status = limAddSta(pMac, pStaDs, false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004106
4107 if(eSIR_SUCCESS != status)
4108 {
4109 /* should not fail */
4110 VOS_ASSERT(0) ;
4111 }
4112 }
4113
4114 return status ;
4115}
4116#endif
4117/*
4118 * Add STA for TDLS setup procedure
4119 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004120static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
4121 tSirTdlsAddStaReq *pAddStaReq,
4122 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08004123{
4124 tpDphHashNode pStaDs = NULL ;
4125 tSirRetStatus status = eSIR_SUCCESS ;
4126 tANI_U16 aid = 0 ;
4127
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004128 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004129 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08004130 if(NULL == pStaDs)
4131 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004132 aid = limAssignPeerIdx(pMac, psessionEntry) ;
4133
4134 if( !aid )
4135 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004136 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004137 ("%s: No more free AID for peer " MAC_ADDRESS_STR),
4138 __func__, MAC_ADDR_ARRAY(pAddStaReq->peerMac)) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004139 return eSIR_FAILURE;
4140 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004141
4142 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4143 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4144
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004145 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004146 ("limTdlsSetupAddSta: Aid = %d, for peer =" MAC_ADDRESS_STR),
4147 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004148 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4149
4150 if (pStaDs)
4151 {
4152 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4153 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4154 }
4155
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004156 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004157 &psessionEntry->dph.dphHashTable) ;
4158
4159 if(NULL == pStaDs)
4160 {
4161 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004162 (" add hash entry failed")) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004163 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004164 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004165 }
Kiran V1ccee932012-12-12 14:49:46 -08004166 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004167
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004168 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004169
4170 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4171
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004172 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004173
4174 if(eSIR_SUCCESS != status)
4175 {
4176 /* should not fail */
4177 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004178 }
Kiran V1ccee932012-12-12 14:49:46 -08004179 return status ;
4180}
4181
4182/*
4183 * Del STA, after Link is teardown or discovery response sent on direct link
4184 */
4185static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4186 tpPESession psessionEntry)
4187{
4188 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004189 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08004190 tpDphHashNode pStaDs = NULL ;
4191
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004192 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08004193 &psessionEntry->dph.dphHashTable) ;
4194
4195 if(pStaDs)
4196 {
4197
4198 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004199 ("DEL STA peer MAC: "MAC_ADDRESS_STR),
4200 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004201
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004202 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004203 ("limTdlsDelSta: STA type = %x, sta idx = %x"),pStaDs->staType,
Kiran V1ccee932012-12-12 14:49:46 -08004204 pStaDs->staIndex) ;
4205
4206 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08004207#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -08004208 if(eSIR_SUCCESS == status)
4209 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004210 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ;
4211 limReleasePeerIdx(pMac, peerIdx, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004212 }
4213 else
4214 {
4215 VOS_ASSERT(0) ;
4216 }
Hoonki Leef63df0d2013-01-16 19:29:14 -08004217#endif
Kiran V1ccee932012-12-12 14:49:46 -08004218 }
4219
4220 return pStaDs ;
4221}
4222
4223#ifdef FEATURE_WLAN_TDLS_INTERNAL
4224/*
4225* Prepare link establish message for HAL, construct PTI template.
4226*
4227*/
4228static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4229{
4230 tANI_U8 pFrame[64] ;
4231 tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ;
4232 tANI_U32 status = 0 ;
4233 tANI_U32 nPayload = 0 ;
4234 tANI_U32 nBytes = 0 ;
4235 tANI_U32 header_offset = 0 ;
4236 tANI_U16 aid = 0 ;
4237 tDphHashNode *pStaDs = NULL ;
4238 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4239 tpPESession psessionEntry = NULL ;
4240
4241
4242 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4243 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004244 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4245 ("limTdlsLinkEstablish: cannot find peer mac "
4246 "in tdls linksetup list: "MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -08004247 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004248 return eSIR_FAILURE;
4249 }
4250
4251 psessionEntry = peFindSessionBySessionId(pMac,
4252 setupPeer->tdls_sessionId) ;
4253
4254 if(NULL == psessionEntry)
4255 {
4256 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004257 ("limTdlsLinkEstablish: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004258 VOS_ASSERT(0) ;
4259 return eHAL_STATUS_FAILURE;
4260 }
4261
Kiet Lam842dad02014-02-18 18:44:02 -08004262
Kiran V1ccee932012-12-12 14:49:46 -08004263 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
4264 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004265 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4266 ("limTdlsLinkEstablish: cannot find peer mac "
4267 "in tdls linksetup list: "MAC_ADDRESS_STR),
4268 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004269 return eSIR_FAILURE;
4270 }
4271
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304272 vos_mem_set( ( tANI_U8* )&tdlsPtiTemplate,
4273 sizeof( tDot11fTDLSPeerTrafficInd ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004274
4275 /*
4276 * setup Fixed fields,
4277 */
4278 tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS;
4279 tdlsPtiTemplate.Action.action = SIR_MAC_TDLS_PEER_TRAFFIC_IND;
4280 tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */
4281#if 1
4282 /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address,
4283 then below code makes such an way */
4284 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4285 peerMac, !setupPeer->tdls_bIsResponder) ;
4286#else
4287 /* below code will make PTI's linkIdentifier's initiator address be selfAddr */
4288 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4289 peerMac, TDLS_INITIATOR) ;
4290#endif
4291
4292 /* PUBufferStatus will be filled by firmware at the time of transmission */
4293 tdlsPtiTemplate.PUBufferStatus.present = 1;
4294
4295 /* TODO: get ExtendedCapabilities IE */
4296
4297 /*
4298 * now we pack it. First, how much space are we going to need?
4299 */
4300 status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload);
4301 if ( DOT11F_FAILED( status ) )
4302 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004303 limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004304 /* We'll fall back on the worst case scenario: */
4305 nPayload = sizeof( tdlsPtiTemplate );
4306 }
4307 else if ( DOT11F_WARNED( status ) )
4308 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004309 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 -08004310 }
4311
4312 /*
4313 * This frame is going out from PE as data frames with special ethertype
4314 * 89-0d.
4315 * 8 bytes of RFC 1042 header
4316 */
4317
4318 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
4319 + sizeof( eth_890d_header )
4320 + PAYLOAD_TYPE_TDLS_SIZE ;
4321
4322 if(nBytes > 64) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004323 limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64."), nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08004324 nBytes = 64;
4325 }
4326 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304327 vos_mem_set( pFrame, sizeof(pFrame), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004328
4329 /* fill out the buffer descriptor */
4330
4331 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
4332 LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ;
4333
4334 status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame
4335 + header_offset, nPayload, &nPayload );
4336
4337 if ( DOT11F_FAILED( status ) )
4338 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004339 limLog( pMac, LOGE, FL("Failed to pack a PTI template (0x%08x)."),
4340 status );
Kiran V1ccee932012-12-12 14:49:46 -08004341 return eSIR_FAILURE;
4342 }
4343 else if ( DOT11F_WARNED( status ) )
4344 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004345 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
4346 "Peer Traffic Indication (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004347 }
4348
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004349 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 -08004350 setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET));
4351
4352 limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder,
4353 header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET,
4354 nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps);
4355
4356 return eSIR_SUCCESS;
4357}
4358
4359/*
4360* Prepare link teardown message for HAL from peer_mac
4361*
4362*/
4363static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4364{
4365 tDphHashNode *pStaDs = NULL ;
4366 tANI_U16 aid = 0 ;
4367 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4368 tpPESession psessionEntry = NULL ;
4369
4370
4371 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4372 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004373 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4374 ("limTdlsLinkTeardown: cannot find peer mac "
4375 "in tdls linksetup list: "
4376 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004377 return eSIR_FAILURE;
4378 }
4379
4380 psessionEntry = peFindSessionBySessionId(pMac,
4381 setupPeer->tdls_sessionId) ;
4382
4383 if(NULL == psessionEntry)
4384 {
4385 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004386 ("limTdlsLinkTeardown: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004387 VOS_ASSERT(0) ;
4388 return eHAL_STATUS_FAILURE;
4389 }
4390
4391
Kiet Lam842dad02014-02-18 18:44:02 -08004392
Kiran V1ccee932012-12-12 14:49:46 -08004393 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
4394
4395 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004396 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4397 ("limTdlsLinkTeardown: cannot find peer mac "
4398 "in hash table: "
4399 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004400 return eSIR_FAILURE;
4401 }
4402
4403 limSendTdlsLinkTeardown(pMac, pStaDs->staIndex);
4404
4405 return eSIR_SUCCESS;
4406}
4407
4408/*
4409 * Prepare Discovery RSP message for SME, collect peerINfo for all the
4410 * peers discovered and delete/clean discovery lists in PE.
4411 */
4412
4413static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac,
4414 tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount)
4415{
4416 tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp);
4417 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4418
4419 /*
4420 * allocate memory for tdls discovery response, allocated memory should
4421 * be alloc_mem = tdlsStaCount * sizeof(peerinfo)
4422 * + siezeof tSirTdlsDisRsp.
4423 */
4424 disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo));
4425
4426 /* now allocate memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304427
4428 disRsp = vos_mem_malloc(disMsgRspSize);
4429 if ( NULL == disRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004430 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304431 limLog(pMac, LOGP, FL("AllocateMemory failed for DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004432 return NULL ;
4433 }
4434
4435 if(disStaCount)
4436 {
4437 tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ;
4438 tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ;
4439
4440 tLimDisResultList *currentNode = tdlsDisRspList ;
4441 while(tdlsDisRspList != NULL)
4442 {
4443
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304444 vos_mem_copy( (tANI_U8 *)peerInfo,
Kiran V1ccee932012-12-12 14:49:46 -08004445 (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo,
4446 sizeof(tSirTdlsPeerInfo));
4447
4448 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004449 ("Msg Sent to PE, peer MAC: "MAC_ADDRESS_STR),
4450 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004451 disStaCount-- ;
4452 peerInfo++ ;
4453 currentNode = tdlsDisRspList ;
4454 tdlsDisRspList = tdlsDisRspList->next ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304455 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08004456 /* boundary condition check, may be fatal */
4457 if(((!disStaCount) && (tdlsDisRspList))
4458 || ((!tdlsDisRspList) && disStaCount))
4459 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004460 limLog(pMac, LOG1, FL("mismatch in dis sta count and "
4461 "number of nodes in list")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004462 VOS_ASSERT(0) ;
4463 return NULL ;
4464 }
4465 } /* end of while */
4466
4467 /* All discovery STA processed */
4468 pMac->lim.gLimTdlsDisResultList = NULL ;
4469
4470 } /* end of if dis STA count */
4471
4472 return (disRsp) ;
4473}
4474
4475/* Send Teardown response back to PE */
4476
4477void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4478 tSirMacAddr peerMac, tANI_U16 msgType)
4479{
4480 tSirMsgQ mmhMsg = {0} ;
4481 tSirTdlsTeardownRsp *teardownRspMsg = NULL ;
4482 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4483
4484 mmhMsg.type = msgType ;
4485
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304486 teardownRspMsg = vos_mem_malloc(sizeof(tSirTdlsTeardownRsp));
4487 if ( NULL == teardownRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004488 {
4489 VOS_ASSERT(0) ;
4490 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304491 vos_mem_copy( teardownRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004492 sizeof(tSirMacAddr)) ;
4493 teardownRspMsg->statusCode = statusCode ;
4494 mmhMsg.bodyptr = teardownRspMsg ;
4495 mmhMsg.bodyval = 0;
4496 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4497
4498 return ;
4499
4500}
4501
4502/*
4503 * Send Link start RSP back to SME after link is setup or failed
4504 */
4505void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac,
4506 tSirResultCodes statusCode,
4507 tSirMacAddr peerMac,
4508 tANI_U16 msgType)
4509{
4510 tSirMsgQ mmhMsg = {0} ;
4511 tSirTdlsLinksetupRsp *setupRspMsg = NULL ;
4512 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4513
4514 mmhMsg.type = msgType ;
4515
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304516 setupRspMsg = vos_mem_malloc(sizeof(tSirTdlsLinksetupRsp));
4517 if ( NULL == setupRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004518 {
4519 VOS_ASSERT(0) ;
4520 }
4521
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304522 vos_mem_copy( setupRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004523 sizeof(tSirMacAddr)) ;
4524 setupRspMsg->statusCode = statusCode ;
4525 mmhMsg.bodyptr = setupRspMsg ;
4526 mmhMsg.bodyval = 0;
4527 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4528
4529 return ;
4530}
4531
4532/*
4533 * Send TDLS discovery RSP back to SME
4534 */
4535void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4536 tANI_U16 msgType)
4537{
4538 tSirMsgQ mmhMsg = {0} ;
4539 tSirTdlsDisRsp *tdlsDisRsp = NULL ;
4540
4541 mmhMsg.type = msgType ;
4542
4543 if(eSIR_SME_SUCCESS == statusCode)
4544 {
4545 tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ;
4546
4547 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004548 ("no of TDLS STA discovered: %d"), tdlsStaCount) ;
Kiran V1ccee932012-12-12 14:49:46 -08004549 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
4550
4551 if(tdlsDisRsp)
4552 {
4553 tdlsDisRsp->numDisSta = tdlsStaCount ;
4554 }
4555 else
4556 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004557 limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004558 VOS_ASSERT(0) ;
4559 return ;
4560 }
4561 /* all Discovery STA is processed */
4562 pMac->lim.gLimTdlsDisStaCount = 0 ;
4563 }
4564 else
4565 {
4566 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ;
4567 }
4568
4569 tdlsDisRsp->statusCode = statusCode ;
4570 mmhMsg.bodyptr = tdlsDisRsp ;
4571 mmhMsg.bodyval = 0;
4572 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4573
4574 return ;
4575}
4576
4577/*
4578 * Once Link is setup with PEER, send Add STA ind to SME
4579 */
4580static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac,
4581 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4582{
4583 tSirMsgQ mmhMsg = {0} ;
4584 tSirTdlsPeerInd *peerInd = NULL ;
4585 mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304586
4587 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4588 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004589 {
4590 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4591 return eSIR_FAILURE;
4592 }
4593
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304594 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004595 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4596 peerInd->sessionId = sessionId;
4597 peerInd->staId = pStaDs->staIndex ;
4598 peerInd->ucastSig = pStaDs->ucUcastSig ;
4599 peerInd->bcastSig = pStaDs->ucBcastSig ;
4600 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4601
4602 mmhMsg.bodyptr = peerInd ;
4603 mmhMsg.bodyval = 0;
4604 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4605
4606 return eSIR_SUCCESS ;
4607
4608}
4609
4610/*
4611 * Once link is teardown, send Del Peer Ind to SME
4612 */
4613static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
4614 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4615{
4616 tSirMsgQ mmhMsg = {0} ;
4617 tSirTdlsPeerInd *peerInd = NULL ;
4618 mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304619
4620 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4621 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004622 {
4623 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4624 return eSIR_FAILURE;
4625 }
4626
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304627 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004628 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4629 peerInd->sessionId = sessionId;
4630 peerInd->staId = pStaDs->staIndex ;
4631 peerInd->ucastSig = pStaDs->ucUcastSig ;
4632 peerInd->bcastSig = pStaDs->ucBcastSig ;
4633 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4634
4635 mmhMsg.bodyptr = peerInd ;
4636
4637 //peerInd->statusCode = status ;
4638 mmhMsg.bodyval = 0;
4639 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4640 return eSIR_SUCCESS ;
4641
4642}
4643
4644/*
4645 * Send Link setup Ind to SME, This is the case where, link setup is
4646 * initiated by peer STA
4647 */
4648static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
4649 tSirMacAddr peerMac, tANI_U8 status)
4650{
4651 tSirMsgQ mmhMsg = {0} ;
4652 tSirTdlsLinkSetupInd *setupInd = NULL ;
4653
4654 mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304655 setupInd = vos_mem_malloc(sizeof(tSirTdlsLinkSetupInd));
4656 if ( NULL == setupInd )
Kiran V1ccee932012-12-12 14:49:46 -08004657 {
4658 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4659 return eSIR_FAILURE;
4660 }
4661
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304662 vos_mem_copy( setupInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004663 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4664 setupInd->length = sizeof(tSirTdlsLinkSetupInd);
4665 setupInd->statusCode = status ;
4666 mmhMsg.bodyptr = setupInd ;
4667 mmhMsg.bodyval = 0;
4668 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4669
4670 return eSIR_SUCCESS ;
4671
4672}
4673
4674/*
4675 * Setup RSP timer handler
4676 */
4677void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4678{
4679
4680 tANI_U32 statusCode;
4681 tSirMsgQ msg;
4682 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4683
4684 /* Prepare and post message to LIM Message Queue */
4685
4686 msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT;
4687 msg.bodyptr = NULL ;
4688 msg.bodyval = timerId ;
4689
4690 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4691 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004692 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004693 msg.type, statusCode);
4694 return ;
4695}
4696
4697/*
4698 * Link setup CNF timer
4699 */
4700void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4701{
4702
4703 tANI_U32 statusCode;
4704 tSirMsgQ msg;
4705 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4706
4707 // Prepare and post message to LIM Message Queue
4708
4709 msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT;
4710 msg.bodyptr = NULL ;
4711 msg.bodyval = timerId ;
4712
4713 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4714 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004715 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004716 msg.type, statusCode);
4717 return ;
4718}
4719
4720/*
4721 * start TDLS timer
4722 */
4723void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer,
4724 tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg)
4725{
4726 tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4727 ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT
4728 : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ;
4729
4730 void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4731 ? (limTdlsLinkSetupRspTimerHandler)
4732 : limTdlsLinkSetupCnfTimerHandler ;
4733
4734 /* TODO: Read timer vals from CFG */
4735
4736 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4737 /*
4738 * create TDLS discovery response wait timer and activate it
4739 */
4740 if (tx_timer_create(timer, "TDLS link setup timers", timerFunc,
4741 timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS)
4742 {
4743 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004744 FL("could not create TDLS discovery response wait timer"));
Kiran V1ccee932012-12-12 14:49:46 -08004745 return;
4746 }
4747
4748 //assign appropriate sessionId to the timer object
4749 timer->sessionId = sessionId;
4750
4751 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4752 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4753 if (tx_timer_activate(timer) != TX_SUCCESS)
4754 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004755 limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!"));
Kiran V1ccee932012-12-12 14:49:46 -08004756 return ;
4757 }
4758
4759 return ;
4760
4761}
4762#endif
4763
4764/*
4765 * Once Link is setup with PEER, send Add STA ind to SME
4766 */
4767static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004768 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
4769 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08004770{
4771 tSirMsgQ mmhMsg = {0} ;
4772 tSirTdlsAddStaRsp *addStaRsp = NULL ;
4773 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304774
4775 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
4776 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004777 {
4778 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4779 return eSIR_FAILURE;
4780 }
4781
4782 addStaRsp->sessionId = sessionId;
4783 addStaRsp->statusCode = status;
4784 if( pStaDs )
4785 {
4786 addStaRsp->staId = pStaDs->staIndex ;
4787 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
4788 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
4789 }
4790 if( peerMac )
4791 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304792 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004793 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4794 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004795 if (updateSta)
4796 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
4797 else
4798 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
4799
Kiran V1ccee932012-12-12 14:49:46 -08004800 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
4801 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
4802
4803 mmhMsg.bodyptr = addStaRsp;
4804 mmhMsg.bodyval = 0;
4805 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4806
4807 return eSIR_SUCCESS ;
4808
4809}
4810/*
4811 * STA RSP received from HAL
4812 */
4813eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
4814 tpPESession psessionEntry)
4815{
4816 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
4817 tANI_U8 status = eSIR_SUCCESS ;
4818 tDphHashNode *pStaDs = NULL ;
4819 tANI_U16 aid = 0 ;
4820
4821 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004822 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Arif Hussain24bafea2013-11-15 15:10:03 -08004823 ("limTdlsAddStaRsp: staIdx=%d, staMac="MAC_ADDRESS_STR), pAddStaParams->staIdx,
4824 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08004825
4826 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
4827 {
4828 VOS_ASSERT(0) ;
4829 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004830 ("Add sta failed ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004831 status = eSIR_FAILURE;
4832 goto add_sta_error;
4833 }
4834
4835 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
4836 &psessionEntry->dph.dphHashTable);
4837 if(NULL == pStaDs)
4838 {
4839 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004840 ("pStaDs is NULL ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004841 status = eSIR_FAILURE;
4842 goto add_sta_error;
4843 }
4844
4845 pStaDs->bssId = pAddStaParams->bssIdx;
4846 pStaDs->staIndex = pAddStaParams->staIdx;
4847 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
4848 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
4849 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4850 pStaDs->valid = 1 ;
4851#ifdef FEATURE_WLAN_TDLS_INTERNAL
4852 status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId,
4853 pStaDs, eSIR_SUCCESS ) ;
4854 if(eSIR_FAILURE == status)
4855 {
4856 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004857 ("Peer IND msg to SME failed")) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304858 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004859 return eSIR_FAILURE ;
4860 }
4861
4862 /*
4863 * Now, there is two things a) ADD STA RSP for ADD STA request sent
4864 * after recieving discovery request from Peer.
4865 * now we have to send discovery response, if there is any pending
4866 * discovery equest..
4867 */
4868 do
4869 {
4870 tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac,
4871 pAddStaParams->staMac) ;
4872
4873
4874 if(peerInfo)
4875 {
4876 /*
4877 * send TDLS discovery response frame on direct link, state machine
4878 * is rolling.., once discovery response is get Acked, we will
4879 * send response to SME based on TxComplete callback results
4880 */
4881 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
4882 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
4883 }
4884 } while(0) ;
Kiran V1ccee932012-12-12 14:49:46 -08004885#endif
4886add_sta_error:
4887 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004888 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304889 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004890 return status ;
4891}
4892
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304893void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
4894 tpPESession psessionEntry,
4895 tDot11fIESuppChannels *suppChannels,
4896 tDot11fIESuppOperatingClasses *suppOperClasses)
4897{
4898 tANI_U32 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4899 tANI_U8 validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4900 tANI_U8 i;
4901 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
4902 validChan, &numChans) != eSIR_SUCCESS)
4903 {
4904 /**
4905 * Could not get Valid channel list from CFG.
4906 * Log error.
4907 */
4908 limLog(pMac, LOGP,
4909 FL("could not retrieve Valid channel list"));
4910 }
4911 suppChannels->num_bands = (tANI_U8) numChans;
4912
4913 for ( i = 0U; i < suppChannels->num_bands; i++)
4914 {
4915 suppChannels->bands[i][0] = validChan[i];
4916 suppChannels->bands[i][1] = 1;
4917 }
4918 suppChannels->present = 1 ;
4919 return ;
4920}
4921
4922
Kiran V1ccee932012-12-12 14:49:46 -08004923/*
4924 * FUNCTION: Populate Link Identifier element IE
4925 *
4926 */
4927
4928
4929void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
4930 tDot11fIELinkIdentifier *linkIden,
4931 tSirMacAddr peerMac, tANI_U8 reqType)
4932{
4933 //tANI_U32 size = sizeof(tSirMacAddr) ;
4934 tANI_U8 *initStaAddr = NULL ;
4935 tANI_U8 *respStaAddr = NULL ;
4936
4937 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
4938 (respStaAddr = linkIden->RespStaAddr))
4939 : ((respStaAddr = linkIden->InitStaAddr ),
4940 (initStaAddr = linkIden->RespStaAddr)) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304941 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08004942 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
4943
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304944 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08004945 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
4946
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304947 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004948 sizeof( tSirMacAddr ));
4949
4950 linkIden->present = 1 ;
4951 return ;
4952
4953}
4954
4955void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
4956 tDot11fIEExtCap *extCapability)
4957{
4958 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05304959 extCapability->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304960 extCapability->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
Kiran V1ccee932012-12-12 14:49:46 -08004961 extCapability->TDLSSupport = TDLS_SUPPORT ;
4962 extCapability->TDLSProhibited = TDLS_PROHIBITED ;
4963 extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
4964 extCapability->present = 1 ;
4965 return ;
4966}
4967
4968#ifdef FEATURE_WLAN_TDLS_INTERNAL
4969/*
4970 * Public Action frame common processing
4971 * This Function will be moved/merged to appropriate place
4972 * once other public action frames (particularly 802.11k)
4973 * is in place
4974 */
4975void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd,
4976 tpPESession psessionEntry)
4977{
4978 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
4979 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ;
4980 tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ;
4981
4982 limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ;
4983 return ;
4984}
4985
4986eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac,
4987 tLimTdlsLinkSetupInfo *linkSetupInfo,
4988 tANI_U8 dialog, tSirMacAddr peerMac,
4989 tpPESession psessionEntry)
4990{
4991 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4992
4993 /*
4994 * we allocate the TDLS setup Peer Memory here, we will free'd this
4995 * memory after teardown, if the link is successfully setup or
4996 * free this memory if any timeout is happen in link setup procedure
4997 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304998
4999 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5000 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08005001 {
5002 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005003 FL( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08005004 VOS_ASSERT(0) ;
5005 return eSIR_MEM_ALLOC_FAILED;
5006 }
5007 setupPeer->dialog = dialog ;
5008 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
5009 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
5010
5011 /* TDLS_sessionize: remember sessionId for future */
5012 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5013 setupPeer->tdls_bIsResponder = 1;
5014
5015 /*
5016 * we only populate peer MAC, so it can assit us to find the
5017 * TDLS peer after response/or after response timeout
5018 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305019 vos_mem_copy(setupPeer->peerMac, peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005020 sizeof(tSirMacAddr)) ;
5021 /* format TDLS discovery request frame and transmit it */
5022 limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ;
5023
5024 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5025 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5026 (tANI_U32)setupPeer->peerMac,
5027 WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5028 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5029 /* update setup peer list */
5030 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5031 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5032
5033 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to
5034 * SME later when TDLS setup cnf TX complete is successful. --> see
5035 * limTdlsSetupCnfTxComplete()
5036 */
5037 return eSIR_SUCCESS ;
5038}
5039#endif
5040
5041/*
5042 * Process Send Mgmt Request from SME and transmit to AP.
5043 */
5044tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
5045 tANI_U32 *pMsgBuf)
5046{
5047 /* get all discovery request parameters */
5048 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
5049 tpPESession psessionEntry;
5050 tANI_U8 sessionId;
5051 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
5052
5053 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005054 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005055
5056 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
5057 == NULL)
5058 {
5059 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005060 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005061 pSendMgmtReq->sessionId);
5062 goto lim_tdls_send_mgmt_error;
5063 }
5064
5065 /* check if we are in proper state to work as TDLS client */
5066 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5067 {
5068 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005069 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005070 psessionEntry->limSystemRole);
5071 goto lim_tdls_send_mgmt_error;
5072 }
5073
5074 /*
5075 * if we are still good, go ahead and check if we are in proper state to
5076 * do TDLS discovery req/rsp/....frames.
5077 */
5078 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5079 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5080 {
5081
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005082 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5083 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005084 goto lim_tdls_send_mgmt_error;
5085 }
5086
5087 switch( pSendMgmtReq->reqType )
5088 {
5089 case SIR_MAC_TDLS_DIS_REQ:
5090 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005091 "Transmit Discovery Request Frame") ;
Kiran V1ccee932012-12-12 14:49:46 -08005092 /* format TDLS discovery request frame and transmit it */
5093 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
5094 psessionEntry) ;
5095 resultCode = eSIR_SME_SUCCESS;
5096 break;
5097 case SIR_MAC_TDLS_DIS_RSP:
5098 {
5099 //Send a response mgmt action frame
5100 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
5101 pSendMgmtReq->dialog, psessionEntry) ;
5102 resultCode = eSIR_SME_SUCCESS;
5103 }
5104 break;
5105 case SIR_MAC_TDLS_SETUP_REQ:
5106 {
5107 limSendTdlsLinkSetupReqFrame(pMac,
5108 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
5109 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5110 resultCode = eSIR_SME_SUCCESS;
5111 }
5112 break;
5113 case SIR_MAC_TDLS_SETUP_RSP:
5114 {
5115 limSendTdlsSetupRspFrame(pMac,
5116 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
5117 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5118 resultCode = eSIR_SME_SUCCESS;
5119 }
5120 break;
5121 case SIR_MAC_TDLS_SETUP_CNF:
5122 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05305123 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, pSendMgmtReq->peerCapability,
Kiran V1ccee932012-12-12 14:49:46 -08005124 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5125 resultCode = eSIR_SME_SUCCESS;
5126 }
5127 break;
5128 case SIR_MAC_TDLS_TEARDOWN:
5129 {
5130 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08005131 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08005132 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5133 resultCode = eSIR_SME_SUCCESS;
5134 }
5135 break;
5136 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
5137 {
5138 }
5139 break;
5140 case SIR_MAC_TDLS_CH_SWITCH_REQ:
5141 {
5142 }
5143 break;
5144 case SIR_MAC_TDLS_CH_SWITCH_RSP:
5145 {
5146 }
5147 break;
5148 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
5149 {
5150 }
5151 break;
5152 default:
5153 break;
5154 }
5155
5156lim_tdls_send_mgmt_error:
5157
5158 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
5159 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
5160
5161 return eSIR_SUCCESS;
5162}
5163
5164/*
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305165 * Send Response to Link Establish Request to SME
5166 */
5167void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
5168 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5169 tANI_U8 status)
5170{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305171 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305172
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305173 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305174
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305175 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
5176 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305177 {
5178 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305179 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305180 }
5181 pTdlsLinkEstablishReqRsp->statusCode = status ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305182 if ( peerMac )
5183 {
5184 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
5185 }
5186 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305187 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305188 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305189 mmhMsg.bodyval = 0;
5190 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5191 return ;
5192
5193
5194}
5195
5196/*
Kiran V1ccee932012-12-12 14:49:46 -08005197 * Once link is teardown, send Del Peer Ind to SME
5198 */
5199static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
5200 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5201 tANI_U8 status)
5202{
5203 tSirMsgQ mmhMsg = {0} ;
5204 tSirTdlsDelStaRsp *pDelSta = NULL ;
5205 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305206
5207 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
5208 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08005209 {
5210 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
5211 return eSIR_FAILURE;
5212 }
5213
5214 pDelSta->sessionId = sessionId;
5215 pDelSta->statusCode = status ;
5216 if( pStaDs )
5217 {
5218 pDelSta->staId = pStaDs->staIndex ;
5219 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005220 else
5221 pDelSta->staId = HAL_STA_INVALID_IDX;
5222
Kiran V1ccee932012-12-12 14:49:46 -08005223 if( peerMac )
5224 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305225 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08005226 }
5227
5228 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
5229 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
5230
5231 mmhMsg.bodyptr = pDelSta;
5232
5233 mmhMsg.bodyval = 0;
5234 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5235 return eSIR_SUCCESS ;
5236
5237}
5238
5239/*
5240 * Process Send Mgmt Request from SME and transmit to AP.
5241 */
5242tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
5243 tANI_U32 *pMsgBuf)
5244{
5245 /* get all discovery request parameters */
5246 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
5247 tpPESession psessionEntry;
5248 tANI_U8 sessionId;
Kiran V1ccee932012-12-12 14:49:46 -08005249
5250 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005251 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005252
5253 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
5254 == NULL)
5255 {
5256 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005257 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005258 pAddStaReq->sessionId);
5259 goto lim_tdls_add_sta_error;
5260 }
5261
5262 /* check if we are in proper state to work as TDLS client */
5263 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5264 {
5265 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005266 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005267 psessionEntry->limSystemRole);
5268 goto lim_tdls_add_sta_error;
5269 }
5270
5271 /*
5272 * if we are still good, go ahead and check if we are in proper state to
5273 * do TDLS discovery req/rsp/....frames.
5274 */
5275 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5276 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5277 {
5278
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005279 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5280 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005281 goto lim_tdls_add_sta_error;
5282 }
5283
5284 pMac->lim.gLimAddStaTdls = true ;
5285
5286 /* To start with, send add STA request to HAL */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005287 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08005288 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005289 limLog(pMac, LOGE, "%s: Add TDLS Station request failed ", __func__);
Kiran V1ccee932012-12-12 14:49:46 -08005290 goto lim_tdls_add_sta_error;
5291 }
5292 return eSIR_SUCCESS;
5293lim_tdls_add_sta_error:
5294 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005295 pAddStaReq->sessionId, pAddStaReq->peerMac,
5296 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08005297
5298 return eSIR_SUCCESS;
5299}
5300/*
5301 * Process Del Sta Request from SME .
5302 */
5303tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
5304 tANI_U32 *pMsgBuf)
5305{
5306 /* get all discovery request parameters */
5307 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
5308 tpPESession psessionEntry;
5309 tANI_U8 sessionId;
5310 tpDphHashNode pStaDs = NULL ;
5311
5312 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005313 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005314
5315 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
5316 == NULL)
5317 {
5318 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005319 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005320 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005321 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005322 NULL, eSIR_FAILURE) ;
5323 return eSIR_FAILURE;
5324 }
5325
5326 /* check if we are in proper state to work as TDLS client */
5327 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5328 {
5329 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005330 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005331 psessionEntry->limSystemRole);
5332 goto lim_tdls_del_sta_error;
5333 }
5334
5335 /*
5336 * if we are still good, go ahead and check if we are in proper state to
5337 * do TDLS discovery req/rsp/....frames.
5338 */
5339 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5340 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5341 {
5342
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005343 limLog(pMac, LOGE, "Del Sta received in invalid LIMsme state (%d)",
5344 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005345 goto lim_tdls_del_sta_error;
5346 }
5347
5348 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
5349
5350 /* now send indication to SME-->HDD->TL to remove STA from TL */
5351
5352 if(pStaDs)
5353 {
5354 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5355 pStaDs, eSIR_SUCCESS) ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005356 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08005357
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005358 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
5359 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005360 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
5361
Kiran V1ccee932012-12-12 14:49:46 -08005362 return eSIR_SUCCESS;
5363
5364 }
5365
5366lim_tdls_del_sta_error:
5367 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5368 NULL, eSIR_FAILURE) ;
5369
5370 return eSIR_SUCCESS;
5371}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005372
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305373/* Intersects the two input arrays and outputs an array */
5374/* For now the array length of tANI_U8 suffices */
5375static void limTdlsGetIntersection(tANI_U8 *input_array1,tANI_U8 input1_length,
5376 tANI_U8 *input_array2,tANI_U8 input2_length,
5377 tANI_U8 *output_array,tANI_U8 *output_length)
5378{
5379 tANI_U8 i,j,k=0,flag=0;
5380 for(i=0;i<input1_length;i++)
5381 {
5382 flag=0;
5383 for(j=0;j<input2_length;j++)
5384 {
5385 if(input_array1[i]==input_array2[j])
5386 {
5387 flag=1;
5388 break;
5389 }
5390 }
5391 if(flag==1)
5392 {
5393 output_array[k]=input_array1[i];
5394 k++;
5395 }
5396 }
5397 *output_length = k;
5398}
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305399/*
5400 * Process Link Establishment Request from SME .
5401 */
5402tSirRetStatus limProcesSmeTdlsLinkEstablishReq(tpAniSirGlobal pMac,
5403 tANI_U32 *pMsgBuf)
5404{
5405 /* get all discovery request parameters */
5406 tSirTdlsLinkEstablishReq *pTdlsLinkEstablishReq = (tSirTdlsLinkEstablishReq*) pMsgBuf ;
5407 tpPESession psessionEntry;
5408 tANI_U8 sessionId;
5409 tpTdlsLinkEstablishParams pMsgTdlsLinkEstablishReq;
5410 tSirMsgQ msg;
5411 tANI_U16 peerIdx = 0 ;
5412 tpDphHashNode pStaDs = NULL ;
5413
5414 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005415 ("Send Mgmt Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305416
5417 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
5418 == NULL)
5419 {
5420 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005421 "PE Session does not exist for given sme sessionId %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305422 pTdlsLinkEstablishReq->sessionId);
5423 limSendSmeTdlsLinkEstablishReqRsp(pMac, pTdlsLinkEstablishReq->sessionId, pTdlsLinkEstablishReq->peerMac,
5424 NULL, eSIR_FAILURE) ;
5425 return eSIR_FAILURE;
5426 }
5427
5428 /* check if we are in proper state to work as TDLS client */
5429 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5430 {
5431 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005432 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305433 psessionEntry->limSystemRole);
5434 goto lim_tdls_link_establish_error;
5435 }
5436
5437 /*
5438 * if we are still good, go ahead and check if we are in proper state to
5439 * do TDLS discovery req/rsp/....frames.
5440 */
5441 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5442 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5443 {
5444
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005445 limLog(pMac, LOGE, "TDLS Link Establish Request received in "
5446 "invalid LIMsme state (%d)", psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305447 goto lim_tdls_link_establish_error;
5448 }
5449 /*TODO Sunil , TDLSPeer Entry has the STA ID , Use it */
5450 pStaDs = dphLookupHashEntry(pMac, pTdlsLinkEstablishReq->peerMac, &peerIdx,
5451 &psessionEntry->dph.dphHashTable) ;
5452 if ( NULL == pStaDs )
5453 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005454 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305455 goto lim_tdls_link_establish_error;
5456
5457 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305458 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
5459 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305460 {
5461 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005462 FL( "Unable to allocate memory TDLS Link Establish Request" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305463 return eSIR_MEM_ALLOC_FAILED;
5464 }
5465
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305466 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tpTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305467
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05305468 pMsgTdlsLinkEstablishReq->staIdx = pStaDs->staIndex;
5469 pMsgTdlsLinkEstablishReq->isResponder = pTdlsLinkEstablishReq->isResponder;
5470 pMsgTdlsLinkEstablishReq->uapsdQueues = pTdlsLinkEstablishReq->uapsdQueues;
5471 pMsgTdlsLinkEstablishReq->maxSp = pTdlsLinkEstablishReq->maxSp;
5472 pMsgTdlsLinkEstablishReq->isBufsta = pTdlsLinkEstablishReq->isBufSta;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305473 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
5474 pTdlsLinkEstablishReq->isOffChannelSupported;
5475 pMsgTdlsLinkEstablishReq->isOffChannelSupported = 1;
5476
5477 if ( 0 != pTdlsLinkEstablishReq->supportedChannelsLen)
5478 {
5479 tANI_U32 selfNumChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5480 tANI_U8 selfSupportedChannels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5481 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
5482 selfSupportedChannels, &selfNumChans) != eSIR_SUCCESS)
5483 {
5484 /**
5485 * Could not get Valid channel list from CFG.
5486 * Log error.
5487 */
5488 limLog(pMac, LOGP,
5489 FL("could not retrieve Valid channel list"));
5490 }
5491 limTdlsGetIntersection(selfSupportedChannels, selfNumChans,
5492 pTdlsLinkEstablishReq->supportedChannels,
5493 pTdlsLinkEstablishReq->supportedChannelsLen,
5494 pMsgTdlsLinkEstablishReq->validChannels,
5495 &pMsgTdlsLinkEstablishReq->validChannelsLen);
5496 }
5497 vos_mem_copy(pMsgTdlsLinkEstablishReq->validOperClasses,
5498 pTdlsLinkEstablishReq->supportedOperClasses, pTdlsLinkEstablishReq->supportedOperClassesLen);
5499 pMsgTdlsLinkEstablishReq->validOperClassesLen =
5500 pTdlsLinkEstablishReq->supportedOperClassesLen;
5501
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305502 msg.type = WDA_SET_TDLS_LINK_ESTABLISH_REQ;
5503 msg.reserved = 0;
5504 msg.bodyptr = pMsgTdlsLinkEstablishReq;
5505 msg.bodyval = 0;
5506 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5507 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005508 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305509 goto lim_tdls_link_establish_error;
5510 }
5511 return eSIR_SUCCESS;
5512lim_tdls_link_establish_error:
5513 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
5514 NULL, eSIR_FAILURE) ;
5515
5516 return eSIR_SUCCESS;
5517}
5518
5519
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005520/* Delete all the TDLS peer connected before leaving the BSS */
5521tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
5522{
5523 tpDphHashNode pStaDs = NULL ;
5524 int i, aid;
5525
5526 if (NULL == psessionEntry)
5527 {
5528 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
5529 return eSIR_FAILURE;
5530 }
5531
5532 /* Check all the set bit in peerAIDBitmap and delete the peer (with that aid) entry
5533 from the hash table and add the aid in free pool */
5534 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
5535 {
5536 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
5537 {
5538 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
5539 {
5540 pStaDs = dphGetHashEntry(pMac, (aid + i*(sizeof(tANI_U32) << 3)), &psessionEntry->dph.dphHashTable);
5541
5542 if (NULL != pStaDs)
5543 {
Arif Hussain24bafea2013-11-15 15:10:03 -08005544 PELOGE(limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
5545 MAC_ADDR_ARRAY(pStaDs->staAddr)););
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005546
5547 limSendDeauthMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
5548 pStaDs->staAddr, psessionEntry, FALSE);
5549 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, &psessionEntry->dph.dphHashTable);
5550 }
5551 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)), psessionEntry) ;
5552 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
5553 }
5554 }
5555 }
5556 limSendSmeTDLSDeleteAllPeerInd(pMac, psessionEntry);
5557
5558 return eSIR_SUCCESS;
5559}
Kiran V1ccee932012-12-12 14:49:46 -08005560#endif