blob: 72d6fbe325c4301d0f008911611904a84ca13bb1 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Gopichand Nakkala0c1331e2013-01-07 22:49:07 -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.
20 */
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080021/*
22 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
23 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Kiran V1ccee932012-12-12 14:49:46 -080041
42/*===========================================================================
43
44 limProcessTdls.c
45
46 OVERVIEW:
47
48 DEPENDENCIES:
49
50 Are listed for each API below.
51
Gopichand Nakkalabd9fa2d2013-01-08 13:16:22 -080052
53 Copyright (c) 2010 QUALCOMM Incorporated.
54 All Rights Reserved.
55 Qualcomm Confidential and Proprietary
Kiran V1ccee932012-12-12 14:49:46 -080056===========================================================================*/
57
58/*===========================================================================
59
60 EDIT HISTORY FOR FILE
61
62
63 This section contains comments describing changes made to the module.
64 Notice that changes are listed in reverse chronological order.
65
66
67 $Header$$DateTime$$Author$
68
69
70 when who what, where, why
71---------- --- --------------------------------------------------------
7205/05/2010 Ashwani Initial Creation, added TDLS action frame functionality,
73 TDLS message exchange with SME..etc..
74
75===========================================================================*/
76
77
78/**
79 * \file limProcessTdls.c
80 *
81 * \brief Code for preparing,processing and sending 802.11z action frames
82 *
83 */
84
85#ifdef FEATURE_WLAN_TDLS
86
87#include "sirApi.h"
88#include "aniGlobal.h"
89#include "sirMacProtDef.h"
90#include "cfgApi.h"
91#include "utilsApi.h"
92#include "limTypes.h"
93#include "limUtils.h"
94#include "limSecurityUtils.h"
95#include "dot11f.h"
96#include "limStaHashApi.h"
97#include "schApi.h"
98#include "limSendMessages.h"
99#include "utilsParser.h"
100#include "limAssocUtils.h"
101#include "dphHashTable.h"
102#include "wlan_qct_wda.h"
103
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800104#ifdef WLAN_FEATURE_TDLS_DEBUG
105#define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
106#else
107#define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_INFO
108#endif
Kiran V1ccee932012-12-12 14:49:46 -0800109
110#ifdef FEATURE_WLAN_TDLS_INTERNAL
111/* forword declarations */
112static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
113 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) ;
114static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
115 tSirMacAddr peerMac, tANI_U8 status);
116static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
117 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) ;
118static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
119 tANI_U8 state);
120static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
121 tLimTdlsLinkSetupPeer **setupPeer) ;
122static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
123
124static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
125static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
126 tpPESession psessionEntry) ;
127
128#endif
129static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac, tSirMacAddr,
130 tLimTdlsLinkSetupPeer *setupPeer, tpPESession psessionEntry) ;
131void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
132 tDot11fIELinkIdentifier *linkIden,
133 tSirMacAddr peerMac , tANI_U8 reqType) ;
134void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
135 tDot11fIEExtCap *extCapability) ;
136/*
137 * TDLS data frames will go out/come in as non-qos data.
138 * so, eth_890d_header will be aligned access..
139 */
140static const tANI_U8 eth_890d_header[] =
141{
142 0xaa, 0xaa, 0x03, 0x00,
143 0x00, 0x00, 0x89, 0x0d,
144} ;
145
146/*
147 * type of links used in TDLS
148 */
149enum tdlsLinks
150{
151 TDLS_LINK_AP,
152 TDLS_LINK_DIRECT
153} eTdlsLink ;
154
155/*
156 * node status in node searching
157 */
158enum tdlsLinkNodeStatus
159{
160 TDLS_NODE_NOT_FOUND,
161 TDLS_NODE_FOUND
162} eTdlsLinkNodeStatus ;
163
164
165enum tdlsReqType
166{
167 TDLS_INITIATOR,
168 TDLS_RESPONDER
169} eTdlsReqType ;
170
171typedef enum tdlsLinkSetupStatus
172{
173 TDLS_SETUP_STATUS_SUCCESS = 0,
174 TDLS_SETUP_STATUS_FAILURE = 37
175}etdlsLinkSetupStatus ;
176
177/* some local defines */
178#define LINK_IDEN_BSSID_OFFSET (0)
179#define PEER_MAC_OFFSET (12)
180#define STA_MAC_OFFSET (6)
181#define LINK_IDEN_ELE_ID (101)
182//#define LINK_IDEN_LENGTH (18)
183#define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier)
184#define PTI_LINK_IDEN_OFFSET (5)
185#define PTI_BUF_STATUS_OFFSET (25)
186
187/* TODO, Move this parameters to configuration */
188#define PEER_PSM_SUPPORT (0)
189#define PEER_BUFFER_STA_SUPPORT (1)
190#define CH_SWITCH_SUPPORT (0)
191#define TDLS_SUPPORT (1)
192#define TDLS_PROHIBITED (0)
193#define TDLS_CH_SWITCH_PROHIBITED (1)
194
195#ifdef LIM_DEBUG_TDLS
196#define TDLS_CASE_RETURN_STRING(x) case (x): return( ((const tANI_U8*)#x) + 8); /* 8 = remove redundant SIR_MAC_ */
197
198#ifdef FEATURE_WLAN_TDLS
199#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100)
200#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800)
201#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200)
202#endif
203
204const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
205{
206 switch( tdlsActionCode )
207 {
208 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
209 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
210 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
211 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
212 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
213 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
214 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
215 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
216 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
217 TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
218 }
219 return (const tANI_U8*)"UNKNOWN";
220}
221#endif
222#if 0
223static void printMacAddr(tSirMacAddr macAddr)
224{
225 int i = 0 ;
226 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
227
228 for(i = 0 ; i < 6; i++)
229 {
230 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
231 (" %02x "), macAddr[i]);
232 }
233 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("\n"));
234 return ;
235}
236#endif
Kiran V1ccee932012-12-12 14:49:46 -0800237/*
238 * initialize TDLS setup list and related data structures.
239 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800240void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800241{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800242#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800243 pMac->lim.gLimTdlsDisResultList = NULL ;
244 pMac->lim.gLimTdlsDisStaCount = 0 ;
245 palZeroMemory(pMac->hHdd, &pMac->lim.gLimTdlsDisReq,
246 sizeof(tSirTdlsDisReq));
247 palZeroMemory(pMac->hHdd, &pMac->lim.gLimTdlsLinkSetupInfo,
248 sizeof(tLimTdlsLinkSetupInfo));
249 pMac->lim.gAddStaDisRspWait = 0 ;
250
251#ifdef FEATURE_WLAN_TDLS_NEGATIVE
252 /* when reassociated, negative behavior will not be kept */
253 /* you have to explicitly enable negative behavior per (re)association */
254 pMac->lim.gLimTdlsNegativeBehavior = 0;
255#endif
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800256#endif
257 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800258
259 return ;
260}
Kiran V1ccee932012-12-12 14:49:46 -0800261#ifdef FEATURE_WLAN_TDLS_NEGATIVE
262void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
263{
264 if(on) {
265 if(value == 255)
266 pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
267 else
268 pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
269 }
270 else {
271 if(value == 255)
272 pMac->lim.gLimTdlsNegativeBehavior = 0;
273 else
274 pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
275 }
276 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("%d %d -> gLimTdlsNegativeBehavior= 0x%lx\n"), \
277 value, on, pMac->lim.gLimTdlsNegativeBehavior));
278}
279#endif
280#if 0
281/*
282 * This function is used for creating TDLS public Action frame to
283 * transmit on Direct link
284 */
285static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
286 tANI_U8 type, tANI_U8 subType,
287 tANI_U8 *link_iden )
288{
289 tpSirMacMgmtHdr pMacHdr ;
290 tANI_U8 *bssid = link_iden ;
291#if 0
292 tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
293 tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
294#else
295 tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
296 tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
297#endif
298 tANI_U8 toDs = ANI_TXDIR_IBSS ;
299
300 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
301
302 /*
303 * prepare 802.11 header
304 */
305 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
306 pMacHdr->fc.type = type ;
307 pMacHdr->fc.subType = subType ;
308 /*
309 * TL is not setting up below fields, so we are doing it here
310 */
311 pMacHdr->fc.toDS = toDs ;
312 pMacHdr->fc.powerMgmt = 0 ;
313
314
315 palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->da, peerMac,
316 sizeof( tSirMacAddr ));
317 palCopyMemory( pMac->hHdd,
318 (tANI_U8 *) pMacHdr->sa,
319 staMac, sizeof( tSirMacAddr ));
320
321 palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->bssId,
322 bssid, sizeof( tSirMacAddr ));
323
324 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\n"), \
325 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5], \
326 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5], \
327 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2], \
328 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
329
330 return ;
331}
332#endif
333/*
334 * prepare TDLS frame header, it includes
335 * | | | |
336 * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
337 * | | | |
338 */
339static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
340 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType, tpPESession psessionEntry )
341{
342 tpSirMacMgmtHdr pMacHdr ;
343 tANI_U32 header_offset = 0 ;
344 tANI_U8 *addr1 = NULL ;
345 tANI_U8 *addr3 = NULL ;
346 tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP)
347 ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ;
348 tANI_U8 *peerMac = (reqType == TDLS_INITIATOR)
349 ? link_iden->RespStaAddr : link_iden->InitStaAddr;
350 tANI_U8 *staMac = (reqType == TDLS_INITIATOR)
351 ? link_iden->InitStaAddr : link_iden->RespStaAddr;
352
353 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
354
355 /*
356 * if TDLS frame goes through the AP link, it follows normal address
357 * pattern, if TDLS frame goes thorugh the direct link, then
358 * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
359 */
360 (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
361 (addr3 = (peerMac)))
362 : ((addr1 = (peerMac)),
363 (addr3 = (link_iden->bssid))) ;
364 /*
365 * prepare 802.11 header
366 */
367 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
368 pMacHdr->fc.type = SIR_MAC_DATA_FRAME ;
369 pMacHdr->fc.subType = SIR_MAC_DATA_DATA ;
370 /*
371 * TL is not setting up below fields, so we are doing it here
372 */
373 pMacHdr->fc.toDS = toDs ;
374 pMacHdr->fc.powerMgmt = 0 ;
375 pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
376
377
378 palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->da, (tANI_U8 *)addr1,
379 sizeof( tSirMacAddr ));
380 palCopyMemory( pMac->hHdd,
381 (tANI_U8 *) pMacHdr->sa,
382 (tANI_U8 *) staMac,
383 sizeof( tSirMacAddr ));
384
385 palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->bssId,
386 (tANI_U8 *) (addr3), sizeof( tSirMacAddr ));
387
388 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\n"), \
389 (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD", \
390 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5], \
391 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5], \
392 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2], \
393 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
394
395 //printMacAddr(pMacHdr->bssId) ;
396 //printMacAddr(pMacHdr->sa) ;
397 //printMacAddr(pMacHdr->da) ;
398
399 header_offset += sizeof(tSirMacMgmtHdr) ;
400 /*
401 * Now form RFC1042 header
402 */
403 palCopyMemory(pMac->hHdd, (tANI_U8 *)(pFrame + header_offset),
404 (tANI_U8 *)eth_890d_header , sizeof(eth_890d_header)) ;
405
406 header_offset += sizeof(eth_890d_header) ;
407
408 /* add payload type as TDLS */
409 *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
410
411 return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ;
412}
413
414/*
415 * This function can be used for bacst or unicast discovery request
416 * We are not differentiating it here, it will all depnds on peer MAC address,
417 */
418tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
419 tANI_U8 dialog, tpPESession psessionEntry)
420{
421 tDot11fTDLSDisReq tdlsDisReq ;
422 tANI_U32 status = 0 ;
423 tANI_U32 nPayload = 0 ;
424 tANI_U32 size = 0 ;
425 tANI_U32 nBytes = 0 ;
426 tANI_U32 header_offset = 0 ;
427 tANI_U8 *pFrame;
428 void *pPacket;
429 eHalStatus halstatus;
430
431 /*
432 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
433 * and then hand it off to 'dot11fPackProbeRequest' (for
434 * serialization). We start by zero-initializing the structure:
435 */
436 palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsDisReq,
437 sizeof( tDot11fTDLSDisReq ) );
438
439 /*
440 * setup Fixed fields,
441 */
442 tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
443 tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ;
444 tdlsDisReq.DialogToken.token = dialog ;
445
446
447 size = sizeof(tSirMacAddr) ;
448
449 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier,
450 peer_mac, TDLS_INITIATOR) ;
451
452 /*
453 * now we pack it. First, how much space are we going to need?
454 */
455 status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
456 if ( DOT11F_FAILED( status ) )
457 {
458 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
459 "or a discovery Request (0x%08x).\n"), status );
460 /* We'll fall back on the worst case scenario: */
461 nPayload = sizeof( tDot11fTDLSDisReq );
462 }
463 else if ( DOT11F_WARNED( status ) )
464 {
465 limLog( pMac, LOGW, FL("There were warnings while calculating"
466 "the packed size for a discovery Request ("
467 "0x%08x).\n"), status );
468 }
469
470 /*
471 * This frame is going out from PE as data frames with special ethertype
472 * 89-0d.
473 * 8 bytes of RFC 1042 header
474 */
475
476
477 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
478 + sizeof( eth_890d_header )
479 + PAYLOAD_TYPE_TDLS_SIZE ;
480
481 /* Ok-- try to allocate memory from MGMT PKT pool */
482
483 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
484 ( tANI_U16 )nBytes, ( void** ) &pFrame,
485 ( void** ) &pPacket );
486 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
487 {
488 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
489 "Discovery Request.\n"), nBytes );
490 return eSIR_MEM_ALLOC_FAILED;
491 }
492
493 /* zero out the memory */
494 palZeroMemory( pMac->hHdd, pFrame, nBytes );
495
496 /*
497 * IE formation, memory allocation is completed, Now form TDLS discovery
498 * request frame
499 */
500
501 /* fill out the buffer descriptor */
502
503 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
504 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, psessionEntry) ;
505
506#ifdef FEATURE_WLAN_TDLS_NEGATIVE
507 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
508 {
509 tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
510 tdlsDisReq.LinkIdentifier.bssid[5] = 0xad;
511 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
512 ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Discovery Req\n"), \
513 tdlsDisReq.LinkIdentifier.bssid[0],
514 tdlsDisReq.LinkIdentifier.bssid[1],
515 tdlsDisReq.LinkIdentifier.bssid[2],
516 tdlsDisReq.LinkIdentifier.bssid[3],
517 tdlsDisReq.LinkIdentifier.bssid[4],
518 tdlsDisReq.LinkIdentifier.bssid[5]);
519 }
520#endif
521 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
522 + header_offset, nPayload, &nPayload );
523
524 if ( DOT11F_FAILED( status ) )
525 {
526 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
527 (0x%08x).\n"), status );
528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
529 ( void* ) pFrame, ( void* ) pPacket );
530 return eSIR_FAILURE;
531 }
532 else if ( DOT11F_WARNED( status ) )
533 {
534 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
535 "Discovery Request (0x%08x).\n") );
536 }
537
538
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800539 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 -0800540 SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) ));
541
542 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
543 HAL_TXRX_FRM_802_11_DATA,
544 ANI_TXDIR_TODS,
545 7,
546 limTxComplete, pFrame, 0 );
547 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
548 {
549 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
550 return eSIR_FAILURE;
551
552 }
553
554 return eSIR_SUCCESS;
555
556}
557
558/*
559 * Once Discovery response is sent successfully (or failure) on air, now send
560 * response to PE and send del STA to HAL.
561 */
562eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac,
563 tANI_U32 txCompleteSuccess)
564{
565 eHalStatus status = eHAL_STATUS_SUCCESS ;
566#ifdef FEATURE_WLAN_TDLS_INTERNAL
567 tpDphHashNode pStaDs = NULL ;
568 tSirTdlsPeerInfo *peerInfo = 0 ;
569
570 /* find peer by looking into the list by expected state */
571 peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ;
572
573 if(NULL == peerInfo)
574 {
575 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
576 ("DisRspTxComplete: No TDLS state machine waits for this event\n"));
577 VOS_ASSERT(0) ;
578 return eHAL_STATUS_FAILURE;
579 }
580
581 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ;
582
583 if(peerInfo->delStaNeeded)
584 {
585 tpPESession psessionEntry;
586
587 peerInfo->delStaNeeded = false ;
588 psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId);
589
590 if(NULL == psessionEntry)
591 {
592 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
593 ("DisRspTxComplete: sessionID %d is not found\n"), peerInfo->sessionId);
594 return eHAL_STATUS_FAILURE;
595 }
596 /* send del STA to remove context for this TDLS STA */
597 pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ;
598
599 /* now send indication to SME-->HDD->TL to remove STA from TL */
600 if(pStaDs)
601 {
602 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
603 pStaDs, eSIR_SUCCESS) ;
604 }
605 else
606 {
607 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
608 ("DisRspTxComplete: staDs not found for %02x:%02x:%02x:%02x:%02x:%02x\n"),
609 (peerInfo)->peerMac[0],
610 (peerInfo)->peerMac[1],
611 (peerInfo)->peerMac[2],
612 (peerInfo)->peerMac[3],
613 (peerInfo)->peerMac[4],
614 (peerInfo)->peerMac[5]) ;
615 VOS_ASSERT(0) ;
616 return eHAL_STATUS_FAILURE;
617 }
618 }
619
620 if(!txCompleteSuccess)
621 {
622 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
623 ("TX complete failure for Dis RSP"));
624 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
625 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
626 status = eHAL_STATUS_FAILURE;
627 }
628 else
629 {
630 limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS,
631 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
632 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
633 ("TX complete Success for Dis RSP"));
634 status = eHAL_STATUS_SUCCESS ;
635 }
636 //pMac->hal.pCBackFnTxComp = NULL ;
637#endif
638 return status ;
639
640}
641/*
642 * Once setup CNF is sent successfully (or failure) on air, now send
643 * response to PE and send del STA to HAL.
644 */
645eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
646 tANI_U32 txCompleteSuccess)
647{
648 eHalStatus status = eHAL_STATUS_SUCCESS ;
649#ifdef FEATURE_WLAN_TDLS_INTERNAL
650 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
651 /* find peer by looking into the list by expected state */
652 limTdlsFindSetupPeerByState(pMac,
653 TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ;
654
655 if(NULL == peerInfo)
656 {
657 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
658 ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event\n"));
659 VOS_ASSERT(0) ;
660 return eHAL_STATUS_FAILURE;
661 }
662
663 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
664 (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
665
666 if(!txCompleteSuccess)
667 {
668 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
669 ("TX complete Failure for setup CNF"));
670 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac,
671 eWNI_SME_TDLS_LINK_START_RSP) ;
672 status = eHAL_STATUS_FAILURE;
673 }
674 else
675 {
676 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
677 ("RSP-->SME peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"),
678 (peerInfo)->peerMac[0],
679 (peerInfo)->peerMac[1],
680 (peerInfo)->peerMac[2],
681 (peerInfo)->peerMac[3],
682 (peerInfo)->peerMac[4],
683 (peerInfo)->peerMac[5]) ;
684
685 limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
686 eWNI_SME_TDLS_LINK_START_RSP) ;
687
688 /* tdls_hklee: prepare PTI template and send it to HAL */
689 limTdlsLinkEstablish(pMac, (peerInfo)->peerMac);
690
691 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
692 ("TX complete Success for setup CNF"));
693 status = eHAL_STATUS_SUCCESS ;
694 }
695 //pMac->hal.pCBackFnTxComp = NULL ;
696#endif
697 return status ;
698
699}
700
701/*
702 * Tx Complete for Teardown frame
703 */
704eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
705 tANI_U32 txCompleteSuccess)
706{
707 eHalStatus status = eHAL_STATUS_SUCCESS ;
708#ifdef FEATURE_WLAN_TDLS_INTERNAL
709 tpDphHashNode pStaDs = NULL ;
710 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
711 tpPESession psessionEntry = NULL ;
712 //tANI_U16 msgType = 0 ;
713
714 //tSirMacAddr peerMac = {0} ;
715 /* find peer by looking into the list by expected state */
716 limTdlsFindSetupPeerByState(pMac,
717 TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ;
718
719 if(NULL == peerInfo)
720 {
721 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
722 ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event\n"));
723 VOS_ASSERT(0) ;
724 return eHAL_STATUS_FAILURE;
725 }
726
727 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
728 ("teardown peer Mac = %02x,%02x,%02x,%02x,%02x,%02x\n"),
729 (peerInfo)->peerMac[0] ,
730 (peerInfo)->peerMac[1] ,
731 (peerInfo)->peerMac[2] ,
732 (peerInfo)->peerMac[3] ,
733 (peerInfo)->peerMac[4] ,
734 (peerInfo)->peerMac[5] ) ;
735
736
737 //pMac->hal.pCBackFnTxComp = NULL ;
738
739 psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId);
740
741 if(NULL == psessionEntry)
742 {
743 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
744 ("limTdlsTeardownTxComplete: sessionID %d is not found\n"), (peerInfo)->tdls_sessionId);
745 VOS_ASSERT(0) ;
746 return eHAL_STATUS_FAILURE;
747 }
748
749 if(!txCompleteSuccess)
750 {
751 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
752 ("TX complete failure for Teardown \n")) ;
753
754 /*
755 * we should be sending Teradown to AP with status code
756 * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if
757 * that is delivered or not, any way we removing this peer STA from our
758 * list
759 */
760 if(NULL != psessionEntry)
761 {
762 limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac,
763 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ;
764 }
765 }
766
767 if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state)
768 {
769 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
770 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
771 /* send del STA to remove context for this TDLS STA */
772 if(NULL != psessionEntry)
773 {
774 /* tdls_hklee: send message to HAL before it is deleted */
775 limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ;
776
777 pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ;
778 }
779
780 /* now send indication to SME-->HDD->TL to remove STA from TL */
781 if(!pStaDs)
782 {
783 VOS_ASSERT(0) ;
784 return eSIR_FAILURE ;
785 }
786 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
787 pStaDs, eSIR_SUCCESS) ;
788
789 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
790 ("TX complete SUCCESS for Teardown\n")) ;
791 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
792 ("Prev State = %d\n"), (peerInfo)->tdls_prev_link_state) ;
793 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
794 eWNI_SME_TDLS_TEARDOWN_RSP) ;
795 /* Delete Peer for Link Peer List */
796 limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ;
797 }
798 else
799 {
800 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
801 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
802 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
803 eWNI_SME_TDLS_TEARDOWN_IND) ;
804 }
805
806
807#if 0
808 /* if previous state is link restart, then restart link setup again */
809 if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state)
810 {
811 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
812 limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37,
813 peerMac, psessionEntry) ;
814 }
815#endif
816 status = eHAL_STATUS_SUCCESS ;
817#endif
818 return status ;
819}
820
821/*
822 * Send TDLS discovery response frame on direct link.
823 */
824
825static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
826 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry)
827{
828 tDot11fTDLSDisRsp tdlsDisRsp ;
829 tANI_U16 caps = 0 ;
830 tANI_U32 status = 0 ;
831 tANI_U32 nPayload = 0 ;
832 tANI_U32 nBytes = 0 ;
833 tANI_U8 *pFrame;
834 void *pPacket;
835 eHalStatus halstatus;
836
837 /*
838 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
839 * and then hand it off to 'dot11fPackProbeRequest' (for
840 * serialization). We start by zero-initializing the structure:
841 */
842 palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsDisRsp,
843 sizeof( tDot11fTDLSDisRsp ) );
844
845 /*
846 * setup Fixed fields,
847 */
848 tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
849 tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ;
850 tdlsDisRsp.DialogToken.token = dialog ;
851
852 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
853 peerMac, TDLS_RESPONDER) ;
854
855 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
856 {
857 /*
858 * Could not get Capabilities value
859 * from CFG. Log error.
860 */
861 limLog(pMac, LOGP,
862 FL("could not retrieve Capabilities value\n"));
863 }
864 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
865
866 /* populate supported rate IE */
867 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
868 &tdlsDisRsp.SuppRates, psessionEntry );
869
870 /* Populate extended supported rates */
871 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
872 &tdlsDisRsp.ExtSuppRates, psessionEntry );
873
874 /* Populate extended supported rates */
875 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
876
877 /* Include HT Capability IE */
878 //This does not depend on peer capabilities. If it is supported then it should be included
879 PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsDisRsp.HTCaps );
880
881 /*
882 * now we pack it. First, how much space are we going to need?
883 */
884 status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
885 if ( DOT11F_FAILED( status ) )
886 {
887 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
888 "or a discovery Request (0x%08x).\n"), status );
889 /* We'll fall back on the worst case scenario: */
890 nPayload = sizeof( tDot11fProbeRequest );
891 }
892 else if ( DOT11F_WARNED( status ) )
893 {
894 limLog( pMac, LOGW, FL("There were warnings while calculating"
895 "the packed size for a discovery Request ("
896 "0x%08x).\n"), status );
897 }
898
899 /*
900 * This frame is going out from PE as data frames with special ethertype
901 * 89-0d.
902 * 8 bytes of RFC 1042 header
903 */
904
905
906 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ;
907
908 /* Ok-- try to allocate memory from MGMT PKT pool */
909
910 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
911 ( tANI_U16 )nBytes, ( void** ) &pFrame,
912 ( void** ) &pPacket );
913 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
914 {
915 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
916 "Discovery Request.\n"), nBytes );
917 return eSIR_MEM_ALLOC_FAILED;
918 }
919
920 /* zero out the memory */
921 palZeroMemory( pMac->hHdd, pFrame, nBytes );
922
923 /*
924 * IE formation, memory allocation is completed, Now form TDLS discovery
925 * response frame
926 */
927
928 /* Make public Action Frame */
929
930#if 0
931 limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
932 SIR_MAC_MGMT_ACTION,
933 LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
934#endif
935 limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
936 SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
937
938 {
939 tpSirMacMgmtHdr pMacHdr;
940 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
941 pMacHdr->fc.toDS = ANI_TXDIR_IBSS;
942 pMacHdr->fc.powerMgmt = 0 ;
943 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
944 }
945
946#ifdef FEATURE_WLAN_TDLS_NEGATIVE
947 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
948 {
949 tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
950 tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad;
951 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
952 ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Discovery Rsp\n"), \
953 tdlsDisRsp.LinkIdentifier.bssid[0],
954 tdlsDisRsp.LinkIdentifier.bssid[1],
955 tdlsDisRsp.LinkIdentifier.bssid[2],
956 tdlsDisRsp.LinkIdentifier.bssid[3],
957 tdlsDisRsp.LinkIdentifier.bssid[4],
958 tdlsDisRsp.LinkIdentifier.bssid[5]);
959 }
960#endif
961 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
962 sizeof( tSirMacMgmtHdr ),
963 nPayload, &nPayload );
964
965 if ( DOT11F_FAILED( status ) )
966 {
967 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
968 (0x%08x).\n"), status );
969 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
970 ( void* ) pFrame, ( void* ) pPacket );
971 return eSIR_FAILURE;
972 }
973 else if ( DOT11F_WARNED( status ) )
974 {
975 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
976 "Discovery Request (0x%08x).\n") );
977 }
978
979#if 0
980 if(pMac->hal.pCBackFnTxComp == NULL)
981 {
982 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
983
984 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
985 {
986 status = eHAL_STATUS_FAILURE;
987 return status;
988
989 }
990 }
991#endif
992 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
993 ("transmitting Discovery response on direct link\n")) ;
994
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800995 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 -0800996 SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) ));
997
998
999 /*
1000 * Transmit Discovery response and watch if this is delivered to
1001 * peer STA.
1002 */
1003 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1004 HAL_TXRX_FRM_802_11_DATA,
1005 ANI_TXDIR_IBSS,
1006 0,
1007 limTxComplete, pFrame,
1008 limTdlsDisRspTxComplete,
1009 HAL_USE_SELF_STA_REQUESTED_MASK );
1010 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1011 {
1012 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
1013 return eSIR_FAILURE;
1014
1015 }
1016
1017 return eSIR_SUCCESS;
1018
1019}
1020
1021/*
1022 * TDLS setup Request frame on AP link
1023 */
1024
1025tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1026 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
1027 tANI_U8 *addIe, tANI_U16 addIeLen)
1028{
1029 tDot11fTDLSSetupReq tdlsSetupReq ;
1030 tANI_U16 caps = 0 ;
1031 tANI_U32 status = 0 ;
1032 tANI_U32 nPayload = 0 ;
1033 tANI_U32 nBytes = 0 ;
1034 tANI_U32 header_offset = 0 ;
1035 tANI_U8 *pFrame;
1036 void *pPacket;
1037 eHalStatus halstatus;
1038
1039 /*
1040 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1041 * and then hand it off to 'dot11fPackProbeRequest' (for
1042 * serialization). We start by zero-initializing the structure:
1043 */
1044 palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupReq,
1045 sizeof( tDot11fTDLSSetupReq ) );
1046 tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
1047 tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ;
1048 tdlsSetupReq.DialogToken.token = dialog ;
1049
1050
1051 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
1052 peerMac, TDLS_INITIATOR) ;
1053
1054 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1055 {
1056 /*
1057 * Could not get Capabilities value
1058 * from CFG. Log error.
1059 */
1060 limLog(pMac, LOGP,
1061 FL("could not retrieve Capabilities value\n"));
1062 }
1063 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1064
1065 /* populate supported rate IE */
1066 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1067 &tdlsSetupReq.SuppRates, psessionEntry );
1068
1069 /* Populate extended supported rates */
1070 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1071 &tdlsSetupReq.ExtSuppRates, psessionEntry );
1072
1073 /* Populate extended supported rates */
1074 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1075
1076 /*
1077 * TODO: we need to see if we have to support conditions where we have
1078 * EDCA parameter info element is needed a) if we need different QOS
1079 * parameters for off channel operations or QOS is not supported on
1080 * AP link and we wanted to QOS on direct link.
1081 */
1082 /* Populate QOS info, needed for Peer U-APSD session */
1083 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1084 TDLS doesn't want to depend on AP's capability */
1085 tdlsSetupReq.QOSCapsStation.present = 1;
1086 tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
1087 tdlsSetupReq.QOSCapsStation.qack = 0;
1088 tdlsSetupReq.QOSCapsStation.acbe_uapsd = 0;
1089 tdlsSetupReq.QOSCapsStation.acbk_uapsd = 0;
1090 tdlsSetupReq.QOSCapsStation.acvi_uapsd = 0;
1091 tdlsSetupReq.QOSCapsStation.acvo_uapsd = 0;
1092
1093
1094 /*
1095 * we will always try to init TDLS link with 11n capabilities
1096 * let TDLS setup response to come, and we will set our caps based
1097 * of peer caps
1098 */
1099
1100 /* Include HT Capability IE */
1101 PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsSetupReq.HTCaps );
1102
1103 /*
1104 * now we pack it. First, how much space are we going to need?
1105 */
1106 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
1107 &nPayload);
1108 if ( DOT11F_FAILED( status ) )
1109 {
1110 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1111 "or a discovery Request (0x%08x).\n"), status );
1112 /* We'll fall back on the worst case scenario: */
1113 nPayload = sizeof( tDot11fProbeRequest );
1114 }
1115 else if ( DOT11F_WARNED( status ) )
1116 {
1117 limLog( pMac, LOGW, FL("There were warnings while calculating"
1118 "the packed size for a discovery Request ("
1119 "0x%08x).\n"), status );
1120 }
1121
1122
1123 /*
1124 * This frame is going out from PE as data frames with special ethertype
1125 * 89-0d.
1126 * 8 bytes of RFC 1042 header
1127 */
1128
1129
1130 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
1131 + sizeof( eth_890d_header )
1132 + PAYLOAD_TYPE_TDLS_SIZE
1133 + addIeLen;
1134
1135 /* Ok-- try to allocate memory from MGMT PKT pool */
1136
1137 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1138 ( tANI_U16 )nBytes , ( void** ) &pFrame,
1139 ( void** ) &pPacket );
1140 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1141 {
1142 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
1143 "Discovery Request.\n"), nBytes );
1144 return eSIR_MEM_ALLOC_FAILED;
1145 }
1146
1147 /* zero out the memory */
1148 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1149
1150 /*
1151 * IE formation, memory allocation is completed, Now form TDLS discovery
1152 * request frame
1153 */
1154
1155 /* fill out the buffer descriptor */
1156
1157 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1158 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, psessionEntry) ;
1159
1160#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1161 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
1162 {
1163 tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
1164 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1165 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
1166 ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Setup Req\n"), \
1167 tdlsSetupReq.LinkIdentifier.bssid[0],
1168 tdlsSetupReq.LinkIdentifier.bssid[1],
1169 tdlsSetupReq.LinkIdentifier.bssid[2],
1170 tdlsSetupReq.LinkIdentifier.bssid[3],
1171 tdlsSetupReq.LinkIdentifier.bssid[4],
1172 tdlsSetupReq.LinkIdentifier.bssid[5]);
1173 }
1174#endif
1175 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
1176 + header_offset, nPayload, &nPayload );
1177
1178 if ( DOT11F_FAILED( status ) )
1179 {
1180 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
1181 (0x%08x).\n"), status );
1182 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1183 ( void* ) pFrame, ( void* ) pPacket );
1184 return eSIR_FAILURE;
1185 }
1186 else if ( DOT11F_WARNED( status ) )
1187 {
1188 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
1189 "Discovery Request (0x%08x).\n") );
1190 }
1191
1192 //Copy the additional IE.
1193 //TODO : addIe is added at the end of the frame. This means it doesnt
1194 //follow the order. This should be ok, but we should consider changing this
1195 //if there is any IOT issue.
1196 if( addIeLen != 0 )
1197 {
1198 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),
1199 addIeLen ));
1200 palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen );
1201 }
1202
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001203 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 -08001204 SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) ));
1205
1206 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1207 HAL_TXRX_FRM_802_11_DATA,
1208 ANI_TXDIR_TODS,
1209 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1210 limTxComplete, pFrame, 0 );
1211 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1212 {
1213 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
1214 return eSIR_FAILURE;
1215
1216 }
1217
1218 return eSIR_SUCCESS;
1219
1220}
1221/*
1222 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1223 */
1224
1225tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
1226 tSirMacAddr peerMac, tANI_U16 reason, tpPESession psessionEntry,
1227 tANI_U8 *addIe, tANI_U16 addIeLen)
1228{
1229 tDot11fTDLSTeardown teardown ;
1230 tANI_U32 status = 0 ;
1231 tANI_U32 nPayload = 0 ;
1232 tANI_U32 nBytes = 0 ;
1233 tANI_U32 header_offset = 0 ;
1234 tANI_U8 *pFrame;
1235 void *pPacket;
1236 eHalStatus halstatus;
1237
1238 /*
1239 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1240 * and then hand it off to 'dot11fPackProbeRequest' (for
1241 * serialization). We start by zero-initializing the structure:
1242 */
1243 palZeroMemory( pMac->hHdd, ( tANI_U8* )&teardown,
1244 sizeof( tDot11fTDLSTeardown ) );
1245 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1246 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1247 teardown.Reason.code = reason ;
1248
1249 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
1250 peerMac, TDLS_INITIATOR) ;
1251
1252
1253 /*
1254 * now we pack it. First, how much space are we going to need?
1255 */
1256 status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
1257 if ( DOT11F_FAILED( status ) )
1258 {
1259 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1260 "or a discovery Request (0x%08x).\n"), status );
1261 /* We'll fall back on the worst case scenario: */
1262 nPayload = sizeof( tDot11fProbeRequest );
1263 }
1264 else if ( DOT11F_WARNED( status ) )
1265 {
1266 limLog( pMac, LOGW, FL("There were warnings while calculating"
1267 "the packed size for a discovery Request ("
1268 "0x%08x).\n"), status );
1269 }
1270
1271
1272 /*
1273 * This frame is going out from PE as data frames with special ethertype
1274 * 89-0d.
1275 * 8 bytes of RFC 1042 header
1276 */
1277
1278
1279 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
1280 + sizeof( eth_890d_header )
1281 + PAYLOAD_TYPE_TDLS_SIZE
1282 + addIeLen;
1283
1284 /* Ok-- try to allocate memory from MGMT PKT pool */
1285
1286 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1287 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1288 ( void** ) &pPacket );
1289 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1290 {
1291 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
1292 "Discovery Request.\n"), nBytes );
1293 return eSIR_MEM_ALLOC_FAILED;
1294 }
1295
1296 /* zero out the memory */
1297 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1298
1299 /*
1300 * IE formation, memory allocation is completed, Now form TDLS discovery
1301 * request frame
1302 */
1303
1304 /* fill out the buffer descriptor */
1305
1306 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1307 LINK_IDEN_ADDR_OFFSET(teardown),
1308 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
1309 ? TDLS_LINK_AP : TDLS_LINK_DIRECT, TDLS_INITIATOR,
1310 psessionEntry) ;
1311
1312 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
1313 + header_offset, nPayload, &nPayload );
1314
1315 if ( DOT11F_FAILED( status ) )
1316 {
1317 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req \
1318 (0x%08x).\n"), status );
1319 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1320 ( void* ) pFrame, ( void* ) pPacket );
1321 return eSIR_FAILURE;
1322 }
1323 else if ( DOT11F_WARNED( status ) )
1324 {
1325 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
1326 "Teardown Request (0x%08x).\n") );
1327 }
1328#if 0
1329 if(pMac->hal.pCBackFnTxComp == NULL)
1330 {
1331 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
1332 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
1333 {
1334 status = eHAL_STATUS_FAILURE;
1335 return status;
1336
1337 }
1338 }
1339 else
1340 {
1341 VOS_ASSERT(0) ;
1342 return status ;
1343 }
1344#endif
1345
1346 if( addIeLen != 0 )
1347 {
1348 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),
1349 addIeLen ));
1350 palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen );
1351 }
1352
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001353 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -%s-> OTA"),
1354 SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN),
1355 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ? "AP": "DIRECT" ));
Kiran V1ccee932012-12-12 14:49:46 -08001356
1357 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1358 HAL_TXRX_FRM_802_11_DATA,
1359 ANI_TXDIR_TODS,
1360 7,
1361 limTxComplete, pFrame,
1362 limTdlsTeardownTxComplete,
1363 0 );
1364 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1365 {
1366 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
1367 return eSIR_FAILURE;
1368
1369 }
1370 return eSIR_SUCCESS;
1371
1372}
1373
1374/*
1375 * Send Setup RSP frame on AP link.
1376 */
1377static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1378 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
1379 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1380{
1381 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1382 tANI_U32 status = 0 ;
1383 tANI_U16 caps = 0 ;
1384 tANI_U32 nPayload = 0 ;
1385 tANI_U32 header_offset = 0 ;
1386 tANI_U32 nBytes = 0 ;
1387 tANI_U8 *pFrame;
1388 void *pPacket;
1389 eHalStatus halstatus;
1390
1391 /*
1392 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1393 * and then hand it off to 'dot11fPackProbeRequest' (for
1394 * serialization). We start by zero-initializing the structure:
1395 */
1396 palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupRsp,
1397 sizeof( tDot11fTDLSSetupRsp ) );
1398
1399 /*
1400 * setup Fixed fields,
1401 */
1402 tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
1403 tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ;
1404 tdlsSetupRsp.DialogToken.token = dialog;
1405
1406 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
1407 peerMac, TDLS_RESPONDER) ;
1408
1409 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1410 {
1411 /*
1412 * Could not get Capabilities value
1413 * from CFG. Log error.
1414 */
1415 limLog(pMac, LOGP,
1416 FL("could not retrieve Capabilities value\n"));
1417 }
1418 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1419
1420 /* ipopulate supported rate IE */
1421 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1422 &tdlsSetupRsp.SuppRates, psessionEntry );
1423
1424 /* Populate extended supported rates */
1425 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1426 &tdlsSetupRsp.ExtSuppRates, psessionEntry );
1427
1428 /* Populate extended supported rates */
1429 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1430
1431 /*
1432 * TODO: we need to see if we have to support conditions where we have
1433 * EDCA parameter info element is needed a) if we need different QOS
1434 * parameters for off channel operations or QOS is not supported on
1435 * AP link and we wanted to QOS on direct link.
1436 */
1437 /* Populate QOS info, needed for Peer U-APSD session */
1438 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1439 TDLS doesn't want to depend on AP's capability */
1440 tdlsSetupRsp.QOSCapsStation.present = 1;
1441 tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
1442 tdlsSetupRsp.QOSCapsStation.qack = 0;
1443 tdlsSetupRsp.QOSCapsStation.acbe_uapsd = 1;
1444 tdlsSetupRsp.QOSCapsStation.acbk_uapsd = 1;
1445 tdlsSetupRsp.QOSCapsStation.acvi_uapsd = 1;
1446 tdlsSetupRsp.QOSCapsStation.acvo_uapsd = 1;
1447
1448 /* Include HT Info IE */
1449// if ( setupReq->HTCaps.present)
1450// {
1451 PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsSetupRsp.HTCaps );
1452// }
1453
1454 tdlsSetupRsp.Status.status = setupStatus ;
1455
1456 /*
1457 * now we pack it. First, how much space are we going to need?
1458 */
1459 status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp,
1460 &nPayload);
1461 if ( DOT11F_FAILED( status ) )
1462 {
1463 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1464 "or a discovery Request (0x%08x).\n"), status );
1465 /* We'll fall back on the worst case scenario: */
1466 nPayload = sizeof( tDot11fProbeRequest );
1467 }
1468 else if ( DOT11F_WARNED( status ) )
1469 {
1470 limLog( pMac, LOGW, FL("There were warnings while calculating"
1471 "the packed size for a discovery Request ("
1472 "0x%08x).\n"), status );
1473 }
1474
1475 /*
1476 * This frame is going out from PE as data frames with special ethertype
1477 * 89-0d.
1478 * 8 bytes of RFC 1042 header
1479 */
1480
1481
1482 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
1483 + sizeof( eth_890d_header )
1484 + PAYLOAD_TYPE_TDLS_SIZE
1485 + addIeLen;
1486
1487 /* Ok-- try to allocate memory from MGMT PKT pool */
1488
1489 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1490 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1491 ( void** ) &pPacket );
1492 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1493 {
1494 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
1495 "Discovery Request.\n"), nBytes );
1496 return eSIR_MEM_ALLOC_FAILED;
1497 }
1498
1499 /* zero out the memory */
1500 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1501
1502 /*
1503 * IE formation, memory allocation is completed, Now form TDLS discovery
1504 * request frame
1505 */
1506
1507 /* fill out the buffer descriptor */
1508
1509 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1510 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp),
1511 TDLS_LINK_AP, TDLS_RESPONDER,
1512 psessionEntry) ;
1513
1514#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1515 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
1516 {
1517 tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
1518 tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad;
1519 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
1520 ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Setup Rsp\n"), \
1521 tdlsSetupRsp.LinkIdentifier.bssid[0],
1522 tdlsSetupRsp.LinkIdentifier.bssid[1],
1523 tdlsSetupRsp.LinkIdentifier.bssid[2],
1524 tdlsSetupRsp.LinkIdentifier.bssid[3],
1525 tdlsSetupRsp.LinkIdentifier.bssid[4],
1526 tdlsSetupRsp.LinkIdentifier.bssid[5]);
1527 }
1528#endif
1529 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1530 + header_offset, nPayload, &nPayload );
1531
1532 if ( DOT11F_FAILED( status ) )
1533 {
1534 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
1535 (0x%08x).\n"), status );
1536 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1537 ( void* ) pFrame, ( void* ) pPacket );
1538 return eSIR_FAILURE;
1539 }
1540 else if ( DOT11F_WARNED( status ) )
1541 {
1542 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
1543 "Discovery Request (0x%08x).\n") );
1544 }
1545
1546 //Copy the additional IE.
1547 //TODO : addIe is added at the end of the frame. This means it doesnt
1548 //follow the order. This should be ok, but we should consider changing this
1549 //if there is any IOT issue.
1550 if( addIeLen != 0 )
1551 {
1552 palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen );
1553 }
1554
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001555 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 -08001556 SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) ));
1557
1558 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1559 HAL_TXRX_FRM_802_11_DATA,
1560 ANI_TXDIR_TODS,
1561 //ANI_TXDIR_IBSS,
1562 7,
1563 limTxComplete, pFrame, 0 );
1564 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1565 {
1566 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
1567 return eSIR_FAILURE;
1568
1569 }
1570
1571 return eSIR_SUCCESS;
1572
1573}
1574
1575/*
1576 * Send TDLS setup CNF frame on AP link
1577 */
1578
1579tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
1580 tANI_U8 dialog, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
1581{
1582 tDot11fTDLSSetupCnf tdlsSetupCnf ;
1583 tANI_U32 status = 0 ;
1584 tANI_U32 nPayload = 0 ;
1585 tANI_U32 nBytes = 0 ;
1586 tANI_U32 header_offset = 0 ;
1587 tANI_U8 *pFrame;
1588 void *pPacket;
1589 eHalStatus halstatus;
1590
1591 /*
1592 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1593 * and then hand it off to 'dot11fPackProbeRequest' (for
1594 * serialization). We start by zero-initializing the structure:
1595 */
1596 palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupCnf,
1597 sizeof( tDot11fTDLSSetupCnf ) );
1598
1599 /*
1600 * setup Fixed fields,
1601 */
1602 tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
1603 tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ;
1604 tdlsSetupCnf.DialogToken.token = dialog ;
1605
1606#if 1
1607 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
1608 peerMac, TDLS_INITIATOR) ;
1609#else
1610 palCopyMemory( pMac->hHdd, (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier,
1611 (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ;
1612#endif
1613
1614 /*
1615 * TODO: we need to see if we have to support conditions where we have
1616 * EDCA parameter info element is needed a) if we need different QOS
1617 * parameters for off channel operations or QOS is not supported on
1618 * AP link and we wanted to QOS on direct link.
1619 */
1620
1621 /* Include HT Info IE */
1622 //if ( tdlsSetupCnf.HTCaps.present)
1623 //{
1624 // PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
1625 // }
1626
1627 /*
1628 * now we pack it. First, how much space are we going to need?
1629 */
1630 status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf,
1631 &nPayload);
1632 if ( DOT11F_FAILED( status ) )
1633 {
1634 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
1635 "or a discovery Request (0x%08x).\n"), status );
1636 /* We'll fall back on the worst case scenario: */
1637 nPayload = sizeof( tDot11fProbeRequest );
1638 }
1639 else if ( DOT11F_WARNED( status ) )
1640 {
1641 limLog( pMac, LOGW, FL("There were warnings while calculating"
1642 "the packed size for a discovery Request ("
1643 "0x%08x).\n"), status );
1644 }
1645
1646 /*
1647 * This frame is going out from PE as data frames with special ethertype
1648 * 89-0d.
1649 * 8 bytes of RFC 1042 header
1650 */
1651
1652
1653 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
1654 + sizeof( eth_890d_header )
1655 + PAYLOAD_TYPE_TDLS_SIZE
1656 + addIeLen;
1657
1658 /* Ok-- try to allocate memory from MGMT PKT pool */
1659
1660 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1661 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1662 ( void** ) &pPacket );
1663 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1664 {
1665 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
1666 "Discovery Request.\n"), nBytes );
1667 return eSIR_MEM_ALLOC_FAILED;
1668 }
1669
1670 /* zero out the memory */
1671 palZeroMemory( pMac->hHdd, pFrame, nBytes );
1672
1673 /*
1674 * IE formation, memory allocation is completed, Now form TDLS discovery
1675 * request frame
1676 */
1677
1678 /* fill out the buffer descriptor */
1679
1680 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1681 LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
1682 psessionEntry) ;
1683
1684#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1685 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
1686 tdlsSetupCnf.StatusCode.statusCode = 37;
1687 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
1688 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf\n"));
1689 }
1690#endif
1691 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
1692 + header_offset, nPayload, &nPayload );
1693
1694 if ( DOT11F_FAILED( status ) )
1695 {
1696 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
1697 (0x%08x).\n"), status );
1698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1699 ( void* ) pFrame, ( void* ) pPacket );
1700 return eSIR_FAILURE;
1701 }
1702 else if ( DOT11F_WARNED( status ) )
1703 {
1704 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
1705 "Discovery Request (0x%08x).\n") );
1706 }
1707#if 0
1708 if(pMac->hal.pCBackFnTxComp == NULL)
1709 {
1710 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
1711 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
1712 {
1713 status = eHAL_STATUS_FAILURE;
1714 return status;
1715
1716 }
1717 }
1718 else
1719 {
1720 VOS_ASSERT(0) ;
1721 return status ;
1722 }
1723#endif
1724 //Copy the additional IE.
1725 //TODO : addIe is added at the end of the frame. This means it doesnt
1726 //follow the order. This should be ok, but we should consider changing this
1727 //if there is any IOT issue.
1728 if( addIeLen != 0 )
1729 {
1730 palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen );
1731 }
1732
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001733 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 -08001734 SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) ));
1735
1736 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1737 HAL_TXRX_FRM_802_11_DATA,
1738 ANI_TXDIR_TODS,
1739 7,
1740 limTxComplete, pFrame,
1741 limTdlsSetupCnfTxComplete,
1742 0 );
1743
1744
1745 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1746 {
1747 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
1748 return eSIR_FAILURE;
1749
1750 }
1751
1752 return eSIR_SUCCESS;
1753}
1754
1755#ifdef FEATURE_WLAN_TDLS_INTERNAL
1756/*
1757 * Convert HT caps to lim based HT caps
1758 */
1759static void limTdlsCovertHTCaps(tpAniSirGlobal pMac ,
1760 tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps)
1761{
1762
1763 /* HT Capability Info */
1764 peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ;
1765 peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet =
1766 HTCaps->supportedChannelWidthSet ;
1767 peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ;
1768 peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ;
1769 peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ;
1770 peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ;
1771 peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ;
1772 peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ;
1773 peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA;
1774 peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ;
1775 peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ;
1776 peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ;
1777 peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ;
1778 peerInfo->tdlsPeerHtCaps.lsigTXOPProtection =
1779 HTCaps->lsigTXOPProtection ;
1780
1781 /* HT Capa parameters */
1782 peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ;
1783 peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ;
1784 peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ;
1785
1786 /* Extended HT caps */
1787 peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ;
1788 peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ;
1789 peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ;
1790 palCopyMemory(pMac->hHdd, peerInfo->supportedMCSSet,
1791 HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
1792
1793 return ;
1794}
1795
1796/*
1797 * update capability info..
1798 */
1799void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo,
1800 tDot11fFfCapabilities *Capabilities)
1801{
1802
1803 capabilityInfo->ess = Capabilities->ess;
1804 capabilityInfo->ibss = Capabilities->ibss;
1805 capabilityInfo->cfPollable = Capabilities->cfPollable;
1806 capabilityInfo->cfPollReq = Capabilities->cfPollReq;
1807 capabilityInfo->privacy = Capabilities->privacy;
1808 capabilityInfo->shortPreamble = Capabilities->shortPreamble;
1809 capabilityInfo->pbcc = Capabilities->pbcc;
1810 capabilityInfo->channelAgility = Capabilities->channelAgility;
1811 capabilityInfo->spectrumMgt = Capabilities->spectrumMgt;
1812 capabilityInfo->qos = Capabilities->qos;
1813 capabilityInfo->shortSlotTime = Capabilities->shortSlotTime;
1814 capabilityInfo->apsd = Capabilities->apsd;
1815 capabilityInfo->rrm = Capabilities->rrm;
1816 capabilityInfo->dsssOfdm = Capabilities->dsssOfdm;
1817 capabilityInfo->immediateBA = Capabilities->immediateBA;
1818
1819 return ;
1820}
1821
1822/*
1823 * update Peer info from the link request frame recieved from Peer..
1824 * in list of STA participating in TDLS link setup
1825 */
1826void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac,
1827 tLimTdlsLinkSetupPeer *setupPeer,
1828 tDot11fTDLSSetupReq *setupReq)
1829{
1830
1831 /* Populate peer info of tdls discovery result */
1832
1833 tdlsUpdateCapInfo(&setupPeer->capabilityInfo , &setupReq->Capabilities) ;
1834
1835 if(setupReq->SuppRates.present)
1836 {
1837 ConvertSuppRates( pMac, &setupPeer->supportedRates,
1838 &setupReq->SuppRates );
1839 }
1840
1841 /* update QOS info, needed for Peer U-APSD session */
1842 if(setupReq->QOSCapsStation.present)
1843 {
1844 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
1845 &setupReq->QOSCapsStation) ;
1846 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.\n"), \
1847 setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd, \
1848 setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd, \
1849 setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack, \
1850 setupReq->QOSCapsStation.qack));
1851 }
1852
1853 if(setupReq->ExtSuppRates.present)
1854 {
1855 setupPeer->ExtRatesPresent = 1;
1856 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
1857 &setupReq->ExtSuppRates );
1858 }
1859 /* update HT caps */
1860 if(setupReq->HTCaps.present)
1861 {
1862 palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerHTCaps,
1863 &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
1864 }
1865 /* Update EXT caps */
1866 if(setupReq->ExtCap.present)
1867 {
1868 palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerExtCaps,
1869 &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
1870 }
1871
1872 return ;
1873}
1874
1875/*
1876 * update peer Info recieved with TDLS setup RSP
1877 */
1878void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac,
1879 tLimTdlsLinkSetupPeer *setupPeer,
1880 tDot11fTDLSSetupRsp *setupRsp)
1881{
1882
1883 /* Populate peer info of tdls discovery result */
1884 tdlsUpdateCapInfo(&setupPeer->capabilityInfo , &setupRsp->Capabilities) ;
1885
1886 if(setupRsp->SuppRates.present)
1887 {
1888 tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ;
1889 ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates);
1890 }
1891
1892 /* update QOS info, needed for Peer U-APSD session */
1893 if(setupRsp->QOSCapsStation.present)
1894 {
1895 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
1896 &setupRsp->QOSCapsStation) ;
1897 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.\n"), \
1898 setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd, \
1899 setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd, \
1900 setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack, \
1901 setupRsp->QOSCapsStation.qack));
1902 }
1903
1904 if(setupRsp->ExtSuppRates.present)
1905 {
1906 setupPeer->ExtRatesPresent = 1;
1907 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
1908 &setupRsp->ExtSuppRates );
1909 }
1910 /* update HT caps */
1911 if(setupRsp->HTCaps.present)
1912 {
1913 palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerHTCaps,
1914 &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
1915 }
1916
1917 /* update EXT caps */
1918 if(setupRsp->ExtCap.present)
1919 {
1920 palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerExtCaps,
1921 &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
1922 }
1923
1924 return ;
1925}
1926#endif
1927/*
1928 * update HASH node entry info
1929 */
1930static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
1931 tLimTdlsLinkSetupPeer *setupPeerInfo, tpPESession psessionEntry)
1932{
1933 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
1934 tDot11fIEHTCaps htCap, *htCaps;
1935 tpDphHashNode pSessStaDs = NULL;
1936 tANI_U16 aid;
1937
1938 //HACK- to get the session's htcaps.
1939 PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
1940 htCaps = &htCap;
1941 if(htCaps->present)
1942 {
1943 pStaDs->mlmStaContext.htCapability = 1 ;
1944 pStaDs->htGreenfield = htCaps->greenField ;
1945 pStaDs->htSupportedChannelWidthSet = htCaps->supportedChannelWidthSet ;
1946 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
1947 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
1948 pStaDs->htAMpduDensity = htCaps->mpduDensity;
1949 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
1950 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
1951 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
1952 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
1953 limFillRxHighestSupportedRate(pMac,
1954 &pStaDs->supportedRates.rxHighestDataRate,
1955 htCaps->supportedMCSSet);
1956 pStaDs->baPolicyFlag = 0xFF;
1957
1958 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
1959 }
1960 else
1961 {
1962 pStaDs->mlmStaContext.htCapability = 0 ;
1963 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
1964 }
1965
1966 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
1967 &psessionEntry->dph.dphHashTable) ;
1968
1969 /* Lets enable QOS parameter */
1970 pStaDs->qosMode = 1;
1971 pStaDs->wmeEnabled = 1;
1972 pStaDs->lleEnabled = 0;
1973 pStaDs->qos.capability.qosInfo = pSessStaDs->qos.capability.qosInfo; //setupPeerInfo->qosCaps.qosInfo;
1974
1975 /* populate matching rate set */
1976#if 0
1977#ifdef WLAN_FEATURE_11AC
1978 limPopulateMatchingRateSet(pMac, pStaDs, &setupPeerInfo->supportedRates,
1979 &setupPeerInfo->extendedRates,
1980 (tANI_U8 *)setupPeerInfo->tdlsPeerHTCaps.supportedMCSSet,
1981 &pStaDs->mlmStaContext.propRateSet, psessionEntry, NULL);
1982#else
1983 limPopulateMatchingRateSet(pMac, pStaDs, &setupPeerInfo->supportedRates,
1984 &setupPeerInfo->extendedRates,
1985 (tANI_U8 *)setupPeerInfo->tdlsPeerHTCaps.supportedMCSSet,
1986 &pStaDs->mlmStaContext.propRateSet, psessionEntry);
1987#endif
1988#else
1989 palCopyMemory( pMac->hHdd, &pStaDs->supportedRates, &pSessStaDs->supportedRates, sizeof(pStaDs->supportedRates));
1990#endif
1991
1992 pStaDs->mlmStaContext.capabilityInfo = pSessStaDs->mlmStaContext.capabilityInfo;// setupPeerInfo->capabilityInfo;
1993
1994 return ;
1995}
1996
1997#ifdef FEATURE_WLAN_TDLS_INTERNAL
1998/*
1999 * find Peer in setup link list.
2000 */
2001
2002tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2003 tLimTdlsLinkSetupPeer **setupPeer)
2004{
2005 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2006 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2007 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2008
2009 while (linkSetupList != NULL)
2010 {
2011 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac,
2012 (tANI_U8 *) linkSetupList->peerMac,
2013 sizeof(tSirMacAddr)) )
2014 {
2015 checkNode = TDLS_NODE_FOUND ;
2016 *setupPeer = linkSetupList ;
2017 break ;
2018 }
2019 linkSetupList = linkSetupList->next;
2020 }
2021
2022 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ;
2023}
2024
2025/*
2026 * find peer in Discovery list.
2027 * Dicovery list get populated in two instances, a) Recieved responses in reply
2028 * to discovery request b) If discover request is received from TDLS peer STA
2029 */
2030tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2031{
2032 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2033 tSirTdlsPeerInfo *peerInfo = NULL ;
2034
2035 while (discoveryList != NULL)
2036 {
2037 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2038 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2039 ("Peer in discovery list = %02x, %02x, %02x, %02x, %02x, %02x \n"),
2040 peerInfo->peerMac[0],
2041 peerInfo->peerMac[1],
2042 peerInfo->peerMac[2],
2043 peerInfo->peerMac[3],
2044 peerInfo->peerMac[4],
2045 peerInfo->peerMac[5]) ;
2046
2047 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac,
2048 (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) )
2049 {
2050 break ;
2051 }
2052 discoveryList = discoveryList->next;
2053 }
2054
2055 return peerInfo ;
2056}
2057
2058/*
2059 * find peer in Discovery list by looking into peer state.
2060 * Dicovery list get populated in two instances, a) Recieved responses in reply
2061 * to discovery request b) If discover request is received from TDLS peer STA
2062 */
2063static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
2064 tANI_U8 state)
2065{
2066 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2067 tSirTdlsPeerInfo *peerInfo = NULL ;
2068
2069 while (discoveryList != NULL)
2070 {
2071 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2072 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2073 ("peerInfo Mac = %02x, %02x, %02x, %02x, %02x, %02x "),
2074 peerInfo->peerMac[0],
2075 peerInfo->peerMac[1],
2076 peerInfo->peerMac[2],
2077 peerInfo->peerMac[3],
2078 peerInfo->peerMac[4],
2079 peerInfo->peerMac[5]) ;
2080
2081 if (peerInfo->tdlsPeerState == state)
2082 {
2083 break ;
2084 }
2085 discoveryList = discoveryList->next;
2086 }
2087
2088 return peerInfo ;
2089}
2090
2091/*
2092 * find peer in Setup list by looking into peer state.
2093 * setup list get populated in two instances, a) Recieved responses in reply
2094 * to setup request b) If discover request is received from TDLS peer STA
2095 */
2096static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
2097 tLimTdlsLinkSetupPeer **setupPeer)
2098{
2099
2100 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2101 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2102 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2103
2104 while (linkSetupList != NULL)
2105 {
2106 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2107 ("peer state = %02x\n"), (linkSetupList)->tdls_link_state) ;
2108 if((linkSetupList)->tdls_link_state == state)
2109 {
2110 checkNode = TDLS_NODE_FOUND ;
2111 *setupPeer = linkSetupList ;
2112 break ;
2113 }
2114 linkSetupList = (linkSetupList)->next;
2115 }
2116
2117 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ;
2118}
2119
2120
2121/*
2122 * delete Peer from Setup Link
2123 */
2124void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2125{
2126 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2127 tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ;
2128 tLimTdlsLinkSetupPeer *currentNode = NULL ;
2129 tLimTdlsLinkSetupPeer *prevNode = NULL ;
2130
2131 for(currentNode = *linkSetupList ; currentNode != NULL ;
2132 prevNode = currentNode, currentNode = currentNode->next)
2133 {
2134 if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac,
2135 (tANI_U8 *) currentNode->peerMac,
2136 sizeof(tSirMacAddr)) )
2137 {
2138 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2139 ("Del Node for Peer = %02x,%02x,%02x,%02x,%02x,%02x\n"),
2140 currentNode->peerMac[0],
2141 currentNode->peerMac[1],
2142 currentNode->peerMac[2],
2143 currentNode->peerMac[3],
2144 currentNode->peerMac[4],
2145 currentNode->peerMac[5]) ;
2146 /* if it's first Node */
2147 if(NULL == prevNode)
2148 {
2149 *linkSetupList = currentNode->next ;
2150 }
2151 else
2152 {
2153 prevNode->next = currentNode->next ;
2154 }
2155 palFreeMemory(pMac, currentNode) ;
2156 return ;
2157 }
2158 }
2159
2160 return ;
2161}
2162
2163
2164
2165/*
2166 * TDLS discovery request frame received from TDLS peer STA..
2167 */
2168static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac,
2169 tANI_U8 *pBody, tANI_U32 frmLen )
2170{
2171 tDot11fTDLSDisReq tdlsDisReq = {{0}} ;
2172 tANI_U32 status = 0 ;
2173 tLimDisResultList *tdlsDisResult = NULL ;
2174 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
2175 tSirMacAddr peerMac = {0} ;
2176 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2177 tSirTdlsPeerInfo *peerInfo = NULL ;
2178 tpPESession psessionEntry = NULL ;
2179 tANI_U8 sessionId = 0 ;
2180
2181 status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ;
2182
2183 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN,
2184 ("TDLS dis request dialog = %d\n"), tdlsDisReq.DialogToken.token);
2185
2186 if ( DOT11F_FAILED( status ) )
2187 {
2188 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \
2189 frame (0x%08x, %d bytes):\n"),status, frmLen);
2190 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2191 return eSIR_FAILURE;
2192 }
2193 else if ( DOT11F_WARNED( status ) )
2194 {
2195 limLog( pMac, LOGW, FL("There were warnings while unpacking an\
2196 TDLS discovery Request frame (0x%08x," "%d bytes):\n"),
2197 status, frmLen );
2198 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2199 }
2200
2201 /*
2202 * find session entry using BSSID in link identifier, not using MAC
2203 * header beacuse, there is cases in TDLS, there may be BSSID will not
2204 * be present in header
2205 */
2206 psessionEntry = peFindSessionByBssid(pMac,
2207 &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ;
2208 if(NULL == psessionEntry)
2209 {
2210 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
2211 ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
2212 tdlsDisReq.LinkIdentifier.bssid[0],
2213 tdlsDisReq.LinkIdentifier.bssid[1],
2214 tdlsDisReq.LinkIdentifier.bssid[2],
2215 tdlsDisReq.LinkIdentifier.bssid[3],
2216 tdlsDisReq.LinkIdentifier.bssid[4],
2217 tdlsDisReq.LinkIdentifier.bssid[5]) ;
2218
2219 //VOS_ASSERT(0) ;
2220 return eSIR_FAILURE;
2221 }
2222
2223 /* varify BSSID */
2224 status = palEqualMemory(pMac->hHdd, &psessionEntry->bssId[0],
2225 &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
2226 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2227 ("lim BSSID %02x, %02x, %02x, %02x, %02x, %02x\n"),
2228 psessionEntry->bssId[0],
2229 psessionEntry->bssId[1],
2230 psessionEntry->bssId[2],
2231 psessionEntry->bssId[3],
2232 psessionEntry->bssId[4],
2233 psessionEntry->bssId[5]) ;
2234
2235 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2236 ("Dis req from BSSID %02x, %02x, %02x, %02x, %02x, %02x\n"),
2237 tdlsDisReq.LinkIdentifier.bssid[0],
2238 tdlsDisReq.LinkIdentifier.bssid[1],
2239 tdlsDisReq.LinkIdentifier.bssid[2],
2240 tdlsDisReq.LinkIdentifier.bssid[3],
2241 tdlsDisReq.LinkIdentifier.bssid[4],
2242 tdlsDisReq.LinkIdentifier.bssid[5]
2243 ) ;
2244 if(!status)
2245 {
2246 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter\n")) ;
2247
2248 return eSIR_FAILURE ;
2249 }
2250
2251 /*
2252 * check if this is echo of our transmitted discovery request
2253 * drop it here, TODO: better to drop this in TL.
2254 */
2255 status = palEqualMemory(pMac->hHdd, psessionEntry->selfMacAddr,
2256 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
2257 sizeof(tSirMacAddr)) ;
2258 if(status)
2259 {
2260 limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame\n")) ;
2261 return eSIR_FAILURE ;
2262 }
2263
2264 /*
2265 * while processing Discovery request from Peer,
2266 * STA_MAC--> MAC of TDLS discovery initiator
2267 * STA_PEER_MAC--> MAC of TDLS discovery responder.
2268 */
2269 palCopyMemory(pMac->hHdd, peerMac,
2270 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
2271 sizeof(tSirMacAddr)) ;
2272 /* TODO, do more validation */
2273
2274 /* see if discovery is already in progress */
2275 peerInfo = limTdlsFindDisPeer(pMac, peerMac) ;
2276
2277 if(NULL == peerInfo)
2278 {
2279 /*
2280 * we are allocating peer info for individual peers found in TDLS
2281 * discovery, we need to keep adding TDLS peers till we have timed
2282 * out. We are freeing this memory at the time we are sending this
2283 * collected peer info to SME.
2284 */
2285 status = palAllocateMemory(pMac->hHdd, (void **)&tdlsDisResult,
2286 sizeof(tLimDisResultList)) ;
2287
2288 if(status != eHAL_STATUS_SUCCESS)
2289 {
2290 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery \
2291 reponse info\n")) ;
2292 return eSIR_FAILURE ;
2293 }
2294
2295
2296 peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
2297 peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ;
2298 peerInfo->dialog = tdlsDisReq.DialogToken.token ;
2299
2300 peerInfo->sessionId = psessionEntry->peSessionId;
2301
2302 /* Populate peer info of tdls discovery result */
2303 status = palCopyMemory(pMac->hHdd, peerInfo->peerMac, peerMac,
2304 sizeof(tSirMacAddr)) ;
2305
2306 /*
2307 * Now, as per D13, there will not be any Supp rates, ext Supp rates
2308 * info in Discovery request frames, so we are populating this info
2309 * locally to pass it to ADD STA.
2310 */
2311 do
2312 {
2313 tDot11fIESuppRates suppRates = {0} ;
2314 tDot11fIEExtSuppRates extSuppRates = {0} ;
2315 tANI_U16 caps = 0 ;
2316 tDot11fFfCapabilities capsInfo = {0} ;
2317 tDot11fIEHTCaps HTCaps = {0} ;
2318 /* populate supported rate IE */
2319 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2320 &suppRates, psessionEntry );
2321 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
2322 &suppRates);
2323 /* Populate extended supported rates */
2324 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2325 &extSuppRates, psessionEntry );
2326
2327 peerInfo->ExtRatesPresent = 1;
2328 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
2329 &extSuppRates);
2330
2331 if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
2332 {
2333 /*
2334 * Could not get Capabilities value
2335 * from CFG. Log error.
2336 */
2337 limLog(pMac, LOGP,
2338 FL("could not retrieve Capabilities value\n"));
2339 }
2340 swapBitField16(caps, ( tANI_U16* )&capsInfo );
2341 /* update Caps Info */
2342 tdlsUpdateCapInfo(&peerInfo->capabilityInfo , &capsInfo) ;
2343
2344 PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps );
2345 limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ;
2346
2347 } while (0) ;
2348
2349 /* now add this new found discovery node into tdls discovery list */
2350 tdlsDisResult->next = *disResultList ;
2351 *disResultList = tdlsDisResult ;
2352 pMac->lim.gLimTdlsDisStaCount++ ;
2353
2354 /* See if for this peer already entry in setup Link */
2355 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
2356
2357 /*
2358 * if there is no entry for this peer in setup list, we need to
2359 * do add sta for this peer to transmit discovery rsp.
2360 */
2361 if(NULL == setupPeer)
2362 {
2363 /* To start with, send add STA request to HAL */
2364 pMac->lim.gLimAddStaTdls = true ;
2365 peerInfo->delStaNeeded = true ;
2366
2367 if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac,
2368 peerInfo, psessionEntry))
2369 {
2370 VOS_ASSERT(0) ;
2371 limLog(pMac, LOGE, "Add STA for dis response is failed \n") ;
2372 return eSIR_FAILURE ;
2373 }
2374 } /* use setup link sta ID for discovery rsp */
2375 else
2376 {
2377 peerInfo->delStaNeeded = false ;
2378 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
2379 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
2380 }
2381
2382 }
2383 else
2384 {
2385 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2386 ("discovery procedure in progress for this peer\n")) ;
2387 }
2388
2389 return eSIR_SUCCESS ;
2390}
2391
2392/* Process TDLS setup Request Frame */
2393
2394static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac,
2395 tANI_U8 *pBody, tANI_U32 frmLen)
2396{
2397
2398 tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ;
2399 tANI_U32 status = 0 ;
2400 tpPESession psessionEntry = NULL ;
2401 tANI_U8 sessionId = 0 ;
2402 tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ;
2403 tANI_U8 previousState = TDLS_LINK_IDLE_STATE ;
2404 /* create node for Link setup */
2405 tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2406 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2407 tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ;
2408
2409 status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ;
2410
2411 if ( DOT11F_FAILED( status ) )
2412 {
2413 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \
2414 frame (0x%08x, %d bytes):\n"),status, frmLen);
2415 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2416 return eSIR_FAILURE;
2417 }
2418 else if ( DOT11F_WARNED( status ) )
2419 {
2420 limLog( pMac, LOGW, FL("There were warnings while unpacking an\
2421 TDLS setup Request frame (0x%08x," "%d bytes):\n"),
2422 status, pBody );
2423 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2424 }
2425 /*
2426 * find session entry using BSSID in link identifier, not using MAC
2427 * header beacuse, there is cases in TDLS, there may be BSSID will not
2428 * be present in header
2429 */
2430 psessionEntry = peFindSessionByBssid(pMac,
2431 &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ;
2432 if(NULL == psessionEntry)
2433 {
2434 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
2435 ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
2436 tdlsSetupReq.LinkIdentifier.bssid[0],
2437 tdlsSetupReq.LinkIdentifier.bssid[1],
2438 tdlsSetupReq.LinkIdentifier.bssid[2],
2439 tdlsSetupReq.LinkIdentifier.bssid[3],
2440 tdlsSetupReq.LinkIdentifier.bssid[4],
2441 tdlsSetupReq.LinkIdentifier.bssid[5]) ;
2442
2443 //VOS_ASSERT(0) ;
2444 return eSIR_FAILURE ;
2445 }
2446 /* TODO: we don;t need this check now, varify BSSID */
2447 status = palEqualMemory(pMac->hHdd, psessionEntry->bssId,
2448 &tdlsSetupReq.LinkIdentifier.bssid[0],
2449 sizeof(tSirMacAddr)) ;
2450
2451 if(!status)
2452 {
2453 limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter\n")) ;
2454
2455 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token , psessionEntry,
2456 TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
2457 return eSIR_FAILURE ;
2458 }
2459
2460#ifdef FEATURE_WLAN_TDLS_NEGATIVE
2461 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ)
2462 {
2463 /* simply ignore this setup request packet */
2464 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2465 ("TDLS negative running: ignore TDLS Setup Req packet\n"));
2466 return eSIR_SUCCESS ;
2467 }
2468 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
2469 {
2470 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2471 ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req\n"));
2472 /* format TDLS discovery request frame and transmit it */
2473 limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry,
2474 NULL, 0) ;
2475 }
2476#endif
2477 /* TODO, do more validation */
2478
2479 if(!limTdlsFindLinkPeer(pMac,
2480 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
2481 &tmpSetupPeer))
2482 {
2483 tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
2484
2485 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2486 ("Link is already setup with this peer\n" )) ;
2487 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2488 ("state = %d\n"), tmpSetupPeer->tdls_link_state) ;
2489 //return eSIR_FAILURE ;
2490
2491 if(tmpSetupPeer == NULL)
2492 {
2493 VOS_ASSERT(0) ;
2494 return eSIR_FAILURE ;
2495
2496 }
2497 switch(tmpSetupPeer->tdls_link_state)
2498 {
2499
2500 case TDLS_LINK_SETUP_START_STATE:
2501 {
2502 v_SINT_t macCompare = 0 ;
2503 macCompare= vos_mem_compare2(tmpSetupPeer->peerMac,
2504 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
2505 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2506 ("MAC comparison Rslt = %d\n"), macCompare ) ;
2507 if(0 > macCompare)
2508 {
2509 /*
2510 * Delete our Setup Request/Peer info and honour Peer
2511 * Setup Request, go ahead and respond for this
2512 */
2513 /* Deactivate the timer */
2514 tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ;
2515#ifdef FEATURE_WLAN_TDLS_NEGATIVE
2516 if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
2517 != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
2518#endif
2519 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE,
2520 tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP);
2521
2522 limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ;
2523 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
2524 }
2525 else if(0 < macCompare)
2526 {
2527 /*
2528 * Go ahead with current setup as peer is going to
2529 * respond for setup request
2530 */
2531 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
2532 }
2533 else
2534 {
2535 /* same MAC, not possible */
2536 VOS_ASSERT(0) ;
2537 }
2538
2539 break ;
2540 }
2541#if 1
2542 case TDLS_LINK_SETUP_DONE_STATE:
2543 {
2544 tpDphHashNode pStaDs = NULL ;
2545
2546 previousState = TDLS_LINK_SETUP_WAIT_STATE ;
2547 currentState = TDLS_LINK_TEARDOWN_START_STATE ;
2548 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2549 ("link Setup Done state " )) ;
2550 tmpSetupPeer->tdls_prev_link_state = previousState ;
2551 tmpSetupPeer->tdls_link_state = currentState ;
2552 setupPeer = tmpSetupPeer ;
2553#if 0
2554 /* Send Teardown to this Peer and Initiate new TDLS Setup */
2555 limSendTdlsTeardownFrame(pMac,
2556 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
2557 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ;
2558#else
2559
2560 /* tdls_hklee: send message to HAL before it is deleted, cause */
2561 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
2562
2563 /* send del STA to remove context for this TDLS STA */
2564 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
2565
2566 /* now send indication to SME-->HDD->TL to remove STA from TL */
2567
2568 if(pStaDs)
2569 {
2570 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
2571 pStaDs, eSIR_SUCCESS) ;
2572
2573 /* send Teardown Ind to SME */
2574 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
2575 eWNI_SME_TDLS_TEARDOWN_IND) ;
2576 /* remove node from setup list */
2577 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
2578 }
2579#endif
2580 //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE;
2581 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
2582 break ;
2583
2584 }
2585 default:
2586 {
2587 VOS_ASSERT(0) ;
2588 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2589 ("link Setup is Recieved in unknown state\n" )) ;
2590 break ;
2591 }
2592#endif
2593 }
2594 if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE)
2595 return eSIR_FAILURE ;
2596 }
2597
2598 if(currentState != TDLS_LINK_TEARDOWN_START_STATE)
2599 {
2600 /*
2601 * Now we are sure to send discovery response frame to TDLS discovery
2602 * initiator, we don't care, if this request is unicast ro broadcast,
2603 * we simply, send discovery response frame on direct link.
2604 */
2605 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
2606 (void **) &setupPeer, sizeof( tLimTdlsLinkSetupPeer )))
2607 {
2608 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2609 ( "Unable to allocate memory during ADD_STA\n" ));
2610 return eSIR_MEM_ALLOC_FAILED;
2611 }
2612
2613 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
2614 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
2615 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
2616 setupPeer->tdls_prev_link_state = previousState ;
2617 setupPeer->tdls_link_state = currentState ;
2618 /* TDLS_sessionize: remember sessionId for future */
2619 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
2620 setupPeer->tdls_bIsResponder = 0;
2621
2622 palCopyMemory(pMac->hHdd, setupPeer->peerMac,
2623 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
2624 sizeof(tSirMacAddr)) ;
2625
2626 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2627 ("Setup REQ MAC = %02x,%02x, %02x, %02x, %02x, %02x\n"),
2628 setupPeer->peerMac[0],
2629 setupPeer->peerMac[1],
2630 setupPeer->peerMac[2],
2631 setupPeer->peerMac[3],
2632 setupPeer->peerMac[4],
2633 setupPeer->peerMac[5] ) ;
2634
2635 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
2636 pMac->lim.gLimAddStaTdls = true ;
2637
2638 /* To start with, send add STA request to HAL */
2639 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac,
2640 setupPeer, psessionEntry))
2641 {
2642 VOS_ASSERT(0) ;
2643 palFreeMemory(pMac->hHdd, (void **) &setupPeer) ;
2644 return eSIR_FAILURE ;
2645 }
2646
2647 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
2648 tdlsSetupReq.DialogToken.token , psessionEntry,
2649 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
2650
2651 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
2652 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
2653 (tANI_U32)setupPeer->peerMac,
2654 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
2655 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
2656
2657 /* update setup peer list */
2658 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
2659 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
2660 }
2661 else
2662 {
2663 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
2664 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
2665 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
2666 setupPeer->tdls_prev_link_state = previousState ;
2667 setupPeer->tdls_link_state = currentState ;
2668 /* TDLS_sessionize: remember sessionId for future */
2669 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
2670 setupPeer->tdls_bIsResponder = 0;
2671
2672 palCopyMemory(pMac->hHdd, setupPeer->peerMac,
2673 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
2674 sizeof(tSirMacAddr)) ;
2675
2676 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2677 ("Setup REQ MAC = %02x,%02x, %02x, %02x, %02x, %02x\n"),
2678 setupPeer->peerMac[0],
2679 setupPeer->peerMac[1],
2680 setupPeer->peerMac[2],
2681 setupPeer->peerMac[3],
2682 setupPeer->peerMac[4],
2683 setupPeer->peerMac[5] ) ;
2684
2685 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
2686 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
2687 tdlsSetupReq.DialogToken.token , psessionEntry,
2688 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
2689
2690 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
2691 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
2692 (tANI_U32)setupPeer->peerMac,
2693 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
2694 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
2695 }
2696
2697
2698 return eSIR_SUCCESS ;
2699
2700}
2701
2702/*
2703 * TDLS discovery request frame received from TDLS peer STA..
2704 */
2705static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac,
2706 tANI_U8 *pBody, tANI_U32 frmLen )
2707{
2708 tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ;
2709 tANI_U32 status = 0 ;
2710 tSirMacAddr peerMac = {0} ;
2711 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2712 tpPESession psessionEntry = NULL ;
2713 tANI_U8 sessionId = 0 ;
2714
2715 status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ;
2716
2717 if ( DOT11F_FAILED( status ) )
2718 {
2719 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \
2720 frame (0x%08x, %d bytes):\n"),status, frmLen);
2721 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2722 return eSIR_FAILURE;
2723 }
2724 else if ( DOT11F_WARNED( status ) )
2725 {
2726 limLog( pMac, LOGW, FL("There were warnings while unpacking an\
2727 TDLS discovery Request frame (0x%08x," "%d bytes):\n"),
2728 status, frmLen );
2729 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2730 }
2731
2732 /*
2733 * find session entry using BSSID in link identifier, not using MAC
2734 * header beacuse, there is cases in TDLS, there may be BSSID will not
2735 * be present in header
2736 */
2737 psessionEntry = peFindSessionByBssid(pMac,
2738 &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ;
2739 if(NULL == psessionEntry)
2740 {
2741 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
2742 ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
2743 tdlsSetupRsp.LinkIdentifier.bssid[0],
2744 tdlsSetupRsp.LinkIdentifier.bssid[1],
2745 tdlsSetupRsp.LinkIdentifier.bssid[2],
2746 tdlsSetupRsp.LinkIdentifier.bssid[3],
2747 tdlsSetupRsp.LinkIdentifier.bssid[4],
2748 tdlsSetupRsp.LinkIdentifier.bssid[5]) ;
2749
2750 //VOS_ASSERT(0) ;
2751 return eSIR_FAILURE;
2752 }
2753
2754 /* varify BSSID */
2755 status = palEqualMemory(pMac->hHdd, psessionEntry->bssId,
2756 &tdlsSetupRsp.LinkIdentifier.bssid[0],
2757 sizeof(tSirMacAddr)) ;
2758
2759 if(!status)
2760 {
2761 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter\n")) ;
2762
2763 VOS_ASSERT(0) ;
2764 return eSIR_FAILURE ;
2765 }
2766 palCopyMemory(pMac->hHdd, peerMac,
2767 &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0],
2768 sizeof(tSirMacAddr)) ;
2769
2770 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2771 ("TDLS setup RSP peer = %02x,%02x,%02x,%02x,%02x,%02x\n"),
2772 peerMac[0],
2773 peerMac[1],
2774 peerMac[2],
2775 peerMac[3],
2776 peerMac[4],
2777 peerMac[5]) ;
2778 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
2779
2780 if(NULL == setupPeer)
2781 {
2782 limLog( pMac, LOGE, FL(" unknown setup Response frame \
2783 other BSS\n")) ;
2784 return eSIR_FAILURE ;
2785 }
2786
2787 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2788 ("deactivating Setup RSP timer\n")) ;
2789
2790 /* Deactivate the timer */
2791 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ;
2792
2793 /*
2794 * TDLS Setup RSP is recieved with Failure, Delete this STA entry
2795 * don't respond with TDLS CNF frame.
2796 */
2797 if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status)
2798 {
2799 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
2800 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2801 ("setup RSP with Failure Code\n")) ;
2802 return eSIR_FAILURE ;
2803 }
2804
2805 /* update Link Info */
2806 limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ;
2807
2808 /* TODO, do more validation */
2809
2810
2811 /*
2812 * Now we are sure to send link setup CNF frame to TDLS link setup
2813 * reponded, now we will create dph hash entry and send add STA to HAL
2814 */
2815
2816 pMac->lim.gLimAddStaTdls = true ;
2817 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac,
2818 setupPeer, psessionEntry))
2819 {
2820 /* through error */
2821 VOS_ASSERT(0) ;
2822 return eSIR_FAILURE ;
2823 }
2824 /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */
2825
2826
2827 /* send TDLS confim frame to TDLS Peer STA */
2828 limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, psessionEntry, NULL, 0) ;
2829
2830 /*
2831 * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and
2832 * wait for Setup CNF transmission on air, once we receive tx complete
2833 * message, we will change the peer state and send message to SME
2834 * callback..
2835 */
2836 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
2837 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ;
2838
2839 return eSIR_SUCCESS ;
2840}
2841/*
2842 * TDLS setup CNF frame processing ..
2843 */
2844
2845static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac,
2846 tANI_U8 *pBody, tANI_U32 frmLen)
2847{
2848 tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ;
2849 tANI_U32 status = 0 ;
2850 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
2851 tpPESession psessionEntry = NULL ;
2852 tANI_U8 sessionId = 0 ;
2853
2854 status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ;
2855
2856 if ( DOT11F_FAILED( status ) )
2857 {
2858 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \
2859 frame (0x%08x, %d bytes):\n"),status, frmLen);
2860 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2861 return eSIR_FAILURE;
2862 }
2863 else if ( DOT11F_WARNED( status ) )
2864 {
2865 limLog( pMac, LOGW, FL("There were warnings while unpacking an\
2866 TDLS discovery Response frame (0x%08x," "%d bytes):\n"),
2867 status, frmLen );
2868 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2869 }
2870 /*
2871 * find session entry using BSSID in link identifier, not using MAC
2872 * header beacuse, there is cases in TDLS, there may be BSSID will not
2873 * be present in header
2874 */
2875 psessionEntry = peFindSessionByBssid(pMac,
2876 &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ;
2877 if(NULL == psessionEntry)
2878 {
2879 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
2880 ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
2881 tdlsSetupCnf.LinkIdentifier.bssid[0],
2882 tdlsSetupCnf.LinkIdentifier.bssid[1],
2883 tdlsSetupCnf.LinkIdentifier.bssid[2],
2884 tdlsSetupCnf.LinkIdentifier.bssid[3],
2885 tdlsSetupCnf.LinkIdentifier.bssid[4],
2886 tdlsSetupCnf.LinkIdentifier.bssid[5]) ;
2887
2888 //VOS_ASSERT(0) ;
2889 return eSIR_FAILURE;
2890 }
2891
2892 /* varify BSSID */
2893 status = palEqualMemory(pMac->hHdd, psessionEntry->bssId,
2894 &tdlsSetupCnf.LinkIdentifier.bssid[0],
2895 sizeof(tSirMacAddr)) ;
2896
2897 if(!status)
2898 {
2899 limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter\n")) ;
2900
2901 VOS_ASSERT(0) ;
2902 return eSIR_FAILURE ;
2903 }
2904 /* TODO, do more validation */
2905 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2906 ("setup Cnf peer MAc = %02x,%02x,%02x,%02x,%02x,%02x\n"),
2907 tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
2908 tdlsSetupCnf.LinkIdentifier.InitStaAddr[1],
2909 tdlsSetupCnf.LinkIdentifier.InitStaAddr[2],
2910 tdlsSetupCnf.LinkIdentifier.InitStaAddr[3],
2911 tdlsSetupCnf.LinkIdentifier.InitStaAddr[4],
2912 tdlsSetupCnf.LinkIdentifier.InitStaAddr[5]
2913 ) ;
2914
2915 limTdlsFindLinkPeer(pMac,
2916 &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
2917 &setupPeer) ;
2918
2919 if(NULL == setupPeer)
2920 {
2921 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2922 (" unknown setup CNF frame\n")) ;
2923 VOS_ASSERT(0) ;
2924 return eSIR_FAILURE ;
2925 }
2926 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2927 ("setup CNF peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"),
2928 (setupPeer)->peerMac[0],
2929 (setupPeer)->peerMac[1],
2930 (setupPeer)->peerMac[2],
2931 (setupPeer)->peerMac[3],
2932 (setupPeer)->peerMac[4],
2933 (setupPeer)->peerMac[5]) ;
2934 /*T match dialog token, before proceeding further */
2935 if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token)
2936 {
2937 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
2938 ("setup CNF frame not matching with setup RSP\n")) ;
2939 VOS_ASSERT(0) ;
2940 return eSIR_FAILURE ;
2941 }
2942
2943 /*
2944 * Now we are sure that, this set CNF is for us, now stop
2945 * the running timer..
2946 */
2947 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ;
2948
2949 /* change TDLS peer State */
2950 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
2951 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
2952
2953 /* send indication to SME that, new link is setup */
2954 limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ;
2955
2956 /* tdls_hklee: prepare PTI template and send it to HAL */
2957 limTdlsLinkEstablish(pMac, (setupPeer)->peerMac);
2958
2959 return eSIR_SUCCESS ;
2960
2961}
2962
2963/*
2964 * TDLS discovery response frame processing ..
2965 */
2966
2967static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac,
2968 tANI_U8 *pBody, tANI_U32 frmLen,
2969 tANI_S8 rssi, tpPESession psessionEntry)
2970{
2971 tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ;
2972 tANI_U32 status = 0 ;
2973 tLimDisResultList *tdlsDisResult = NULL ;
2974 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
2975 tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ;
2976
2977 status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ;
2978
2979 if ( DOT11F_FAILED( status ) )
2980 {
2981 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \
2982 frame (0x%08x, %d bytes):\n"),status, frmLen);
2983 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
2984 return eSIR_FAILURE;
2985 }
2986 else if ( DOT11F_WARNED( status ) )
2987 {
2988 limLog( pMac, LOGW, FL("There were warnings while unpacking an\
2989 TDLS discovery Response frame (0x%08x," "%d bytes):\n"),
2990 status, frmLen );
2991 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);)
2992 }
2993 /*TODO: match dialog token, before proceeding further */
2994
2995 /* varify BSSID */
2996 status = palEqualMemory(pMac->hHdd, psessionEntry->bssId,
2997 &tdlsDisRsp.LinkIdentifier.bssid[0],
2998 sizeof(tSirMacAddr)) ;
2999
3000 if(!status)
3001 {
3002 limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS\n")) ;
3003 return eSIR_FAILURE ;
3004 }
3005 /* TODO, do more validation */
3006
3007 if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
3008 {
3009 limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame\n")) ;
3010 return eSIR_FAILURE ;
3011 }
3012
3013 pMac->lim.gLimTdlsDisStaCount++ ;
3014
3015 /*
3016 * we are allocating peer info for individual peers found in TDLS
3017 * discovery, we need to keep adding TDLS peers till we have timed
3018 * out. We are freeing this memory at the time we are sending this
3019 * collected peer info to SME.
3020 */
3021 status = palAllocateMemory(pMac->hHdd, (void **)&tdlsDisResult,
3022 sizeof(tLimDisResultList)) ;
3023
3024 if(status != eHAL_STATUS_SUCCESS)
3025 {
3026 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info\n")) ;
3027 return eSIR_FAILURE ;
3028 }
3029
3030 do
3031 {
3032 tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3033
3034 /* Populate peer info of tdls discovery result */
3035 peerInfo->sessionId = psessionEntry->peSessionId;
3036 /*
3037 * When we receive DIS RSP from peer MAC,
3038 * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
3039 * will carry our MAC.
3040 */
3041 status = palCopyMemory(pMac->hHdd, peerInfo->peerMac,
3042 &tdlsDisRsp.LinkIdentifier.RespStaAddr[0],
3043 sizeof(tSirMacAddr)) ;
3044
3045 /* update RSSI for this TDLS peer STA */
3046 peerInfo->tdlsPeerRssi = rssi ;
3047
3048 /* update Caps Info */
3049 tdlsUpdateCapInfo(&peerInfo->capabilityInfo ,
3050 &tdlsDisRsp.Capabilities) ;
3051
3052 /* update Supp rates */
3053 if(tdlsDisRsp.SuppRates.present)
3054 {
3055 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3056 &tdlsDisRsp.SuppRates );
3057 }
3058
3059 /* update EXT supp rates */
3060 if(tdlsDisRsp.ExtSuppRates.present)
3061 {
3062 peerInfo->ExtRatesPresent = 1;
3063 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3064 &tdlsDisRsp.ExtSuppRates );
3065 }
3066 /* update HT caps */
3067 if (tdlsDisRsp.HTCaps.present)
3068 {
3069 palCopyMemory( pMac, &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps,
3070 sizeof( tDot11fIEHTCaps ) );
3071 }
3072 /* update EXT caps */
3073 if (tdlsDisRsp.ExtCap.present)
3074 {
3075 //palCopyMemory( pMac, &peerInfo->tdlsPeerExtenCaps,
3076 // &tdlsDisRsp.ExtCap,
3077 // sizeof( tDot11fIEExtCap ) );
3078 }
3079 } while(0) ;
3080
3081 /* now add this new found discovery node into tdls discovery list */
3082 tdlsDisResult->next = *disResultList ;
3083 *disResultList = tdlsDisResult ;
3084
3085 return eSIR_SUCCESS ;
3086}
3087
3088/*
3089 * Process TDLS Teardown request frame from TDLS peer STA
3090 */
3091static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac,
3092 tANI_U8 *pBody, tANI_U32 frmLen )
3093{
3094 tDot11fTDLSTeardown tdlsTeardown = {{0}} ;
3095 tANI_U32 status = 0 ;
3096 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3097 tpPESession psessionEntry = NULL ;
3098 tANI_U8 sessionId = 0 ;
3099
3100 status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ;
3101
3102 if ( DOT11F_FAILED( status ) )
3103 {
3104 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \
3105 frame (0x%08x, %d bytes):\n"),status, frmLen);
3106 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3107 return eSIR_FAILURE;
3108 }
3109 else if ( DOT11F_WARNED( status ) )
3110 {
3111 limLog( pMac, LOGW, FL("There were warnings while unpacking an\
3112 TDLS discovery Response frame (0x%08x," "%d bytes):\n"),
3113 status, frmLen );
3114 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3115 }
3116
3117 /*
3118 * find session entry using BSSID in link identifier, not using MAC
3119 * header beacuse, there is cases in TDLS, there may be BSSID will not
3120 * be present in header
3121 */
3122 psessionEntry = peFindSessionByBssid(pMac,
3123 &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ;
3124 if(NULL == psessionEntry)
3125 {
3126 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
3127 ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
3128 tdlsTeardown.LinkIdentifier.bssid[0],
3129 tdlsTeardown.LinkIdentifier.bssid[1],
3130 tdlsTeardown.LinkIdentifier.bssid[2],
3131 tdlsTeardown.LinkIdentifier.bssid[3],
3132 tdlsTeardown.LinkIdentifier.bssid[4],
3133 tdlsTeardown.LinkIdentifier.bssid[5]) ;
3134
3135 //VOS_ASSERT(0) ;
3136 return eSIR_FAILURE;
3137 }
3138
3139 /* varify BSSID */
3140 status = palEqualMemory(pMac->hHdd, psessionEntry->bssId,
3141 &tdlsTeardown.LinkIdentifier.bssid[0],
3142 sizeof(tSirMacAddr)) ;
3143
3144
3145 if(!status)
3146 {
3147 limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter\n")) ;
3148 VOS_ASSERT(0) ;
3149 return eSIR_FAILURE ;
3150 }
3151
3152 limTdlsFindLinkPeer(pMac,
3153 &tdlsTeardown.LinkIdentifier.InitStaAddr[0],
3154 &setupPeer) ;
3155
3156 if(NULL == setupPeer)
3157 {
3158 //ignore
3159 //VOS_ASSERT(0) ;
3160 limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored\n") );
3161
3162 return eSIR_FAILURE ;
3163 }
3164 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3165 ("teardown for peer %02x,%02x,%02x,%02x,%02x,%02x\n"),
3166 (setupPeer)->peerMac[0],
3167 (setupPeer)->peerMac[1],
3168 (setupPeer)->peerMac[2],
3169 (setupPeer)->peerMac[3],
3170 (setupPeer)->peerMac[4],
3171 (setupPeer)->peerMac[5]) ;
3172
3173 switch(tdlsTeardown.Reason.code)
3174 {
3175 case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON:
3176 {
3177 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3178 ("teardown with unspecified reason\n")) ;
3179 break ;
3180 }
3181 case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
3182 {
3183 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3184 (" Teardown from AP, TDLS peer unreachable\n")) ;
3185 break ;
3186 }
3187 default:
3188 {
3189 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3190 (" unknown teardown\n")) ;
3191 break ;
3192 }
3193 }
3194
3195 /* change TDLS peer State */
3196 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3197 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
3198
3199 do
3200 {
3201 tpDphHashNode pStaDs = NULL ;
3202
3203 /* tdls_hklee: send message to HAL before it is deleted, cause */
3204 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3205
3206 /* send del STA to remove context for this TDLS STA */
3207 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3208
3209 /* now send indication to SME-->HDD->TL to remove STA from TL */
3210
3211 if(pStaDs)
3212 {
3213 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3214 pStaDs, eSIR_SUCCESS) ;
3215
3216 /* send Teardown Ind to SME */
3217 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3218 eWNI_SME_TDLS_TEARDOWN_IND) ;
3219 /* remove node from setup list */
3220 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3221 }
3222
3223 }while(0) ;
3224
3225 return status ;
3226}
3227
3228/*
3229 * Common processing of TDLS action frames recieved
3230 */
3231void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd)
3232{
3233 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd);
3234 tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd))
3235 ? (( sizeof( eth_890d_header ))) :(0)) ;
3236
3237 tANI_U8 category = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ;
3238 tANI_U8 action = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ;
3239 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
3240 tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
3241 //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd);
3242
3243 if(category != SIR_MAC_ACTION_TDLS)
3244 {
3245 limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored\n"), category );
3246 return ;
3247 }
3248
3249 frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
3250 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Received TDLS action %d (%s)"), \
3251 action, limTraceTdlsActionString(action) ));
3252
3253 switch(action)
3254 {
3255
3256 case SIR_MAC_TDLS_SETUP_REQ:
3257 {
3258 limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ;
3259 break ;
3260 }
3261 case SIR_MAC_TDLS_SETUP_RSP:
3262 {
3263 limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ;
3264 break ;
3265 }
3266 case SIR_MAC_TDLS_SETUP_CNF:
3267 {
3268 limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ;
3269 break ;
3270 }
3271 case SIR_MAC_TDLS_TEARDOWN:
3272 {
3273 limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ;
3274 break ;
3275 }
3276 case SIR_MAC_TDLS_DIS_REQ:
3277 {
3278 limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ;
3279 break ;
3280 }
3281 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
3282 case SIR_MAC_TDLS_CH_SWITCH_REQ:
3283 case SIR_MAC_TDLS_CH_SWITCH_RSP:
3284 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
3285 default:
3286 {
3287 break ;
3288 }
3289 }
3290
3291 return ;
3292}
3293
3294/*
3295 * ADD sta for dis response fame sent on direct link
3296 */
3297static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
3298 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry)
3299{
3300 tpDphHashNode pStaDs = NULL ;
3301 tSirRetStatus status = eSIR_SUCCESS ;
3302 tANI_U16 aid = 0 ;
3303
3304 if(NULL == peerInfo)
3305 {
3306 VOS_ASSERT(0) ;
3307 return status ;
3308
3309 }
3310 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3311 ("ADD STA peer MAC: %02x, %02x, %02x, %02x, %02x, %02x\n"),
3312 peerMac[0],
3313 peerMac[1],
3314 peerMac[2],
3315 peerMac[3],
3316 peerMac[4],
3317 peerMac[5]) ;
3318
3319
3320 if(NULL != dphLookupHashEntry(pMac, peerMac,
3321 &aid, &psessionEntry->dph.dphHashTable))
3322 {
3323 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3324 (" there is hash entry for this client\n")) ;
3325 status = eSIR_FAILURE ;
3326 VOS_ASSERT(0) ;
3327 return status ;
3328 }
3329
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003330 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08003331
3332 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
3333
3334 if (pStaDs)
3335 {
3336 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
3337 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
3338 }
3339 pStaDs = dphAddHashEntry(pMac, peerMac, aid,
3340 &psessionEntry->dph.dphHashTable) ;
3341
3342 if(NULL == pStaDs)
3343 {
3344 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3345 (" add hash entry failed\n")) ;
3346 status = eSIR_FAILURE ;
3347 VOS_ASSERT(0) ;
3348 return status;
3349 }
3350 if(eSIR_SUCCESS == status)
3351 {
3352#ifdef TDLS_RATE_DEBUG
3353 tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ;
3354 tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ;
3355 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3356 ("pSta DS [%p] \n"), pStaDs) ;
3357 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3358 ("peerInfo->tdlsPeerSuppRates = [%p]\n"),
3359 (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
3360 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3361 ("peerInfo->tdlsPeerExtRates = [%p]\n"),
3362 (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
3363 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3364 ("peerInfo->tdlsPeerPropRates = [%p]\n"),
3365 (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
3366 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3367 ("peerInfo->mcs = [%p]\n"),
3368 (tANI_U8 *)peerInfo->supportedMCSSet) ;
3369 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3370 ("num of supp rates = %02x\n"), suppRates->numRates) ;
3371 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3372 ("num of ext rates = %01x\n"), extRates->numRates) ;
3373#endif
3374
3375 /* Populate matching rate set */
3376#ifdef WLAN_FEATURE_11AC
3377 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
3378 &peerInfo->tdlsPeerSuppRates,
3379 &peerInfo->tdlsPeerExtRates,
3380 peerInfo->supportedMCSSet,
3381 &pStaDs->mlmStaContext.propRateSet,
3382 psessionEntry, NULL))
3383#else
3384 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
3385 &peerInfo->tdlsPeerSuppRates,
3386 &peerInfo->tdlsPeerExtRates,
3387 peerInfo->supportedMCSSet,
3388 &pStaDs->mlmStaContext.propRateSet,
3389 psessionEntry))
3390#endif
3391 {
3392 VOS_ASSERT(0) ;
3393 }
3394
3395
3396 pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo;
3397 palCopyMemory(pMac->hHdd, pStaDs->staAddr, peerMac,
3398 sizeof(tSirMacAddr)) ;
3399 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3400 ("Add STA for Peer: %02x, %02x, %02x, %02x, %02x, %02x\n"),
3401 pStaDs->staAddr[0],
3402 pStaDs->staAddr[1],
3403 pStaDs->staAddr[2],
3404 pStaDs->staAddr[3],
3405 pStaDs->staAddr[4],
3406 pStaDs->staAddr[5]) ;
3407
3408
3409 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
3410
3411 status = limAddSta(pMac, pStaDs, psessionEntry);
3412
3413 if(eSIR_SUCCESS != status)
3414 {
3415 /* should not fail */
3416 VOS_ASSERT(0) ;
3417 }
3418 }
3419
3420 return status ;
3421}
3422#endif
3423/*
3424 * Add STA for TDLS setup procedure
3425 */
3426static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
3427 tSirMacAddr peerMac, tLimTdlsLinkSetupPeer *setupPeer,
3428 tpPESession psessionEntry)
3429{
3430 tpDphHashNode pStaDs = NULL ;
3431 tSirRetStatus status = eSIR_SUCCESS ;
3432 tANI_U16 aid = 0 ;
3433
3434 if(NULL != dphLookupHashEntry(pMac, peerMac, &aid,
3435 &psessionEntry->dph.dphHashTable))
3436 {
3437 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3438 (" there is hash entry for this client\n")) ;
3439 status = eSIR_FAILURE ;
3440 /* TDLS_TODO: I have seen this VOS ASSERT happened. must handle this (called from limProcessTdlsSetupReqFrame) */
3441 VOS_ASSERT(0) ;
3442 return status ;
3443 }
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003444 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08003445
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003446 if( !aid )
3447 {
3448 //Reject request.
3449 return eSIR_FAILURE;
3450 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003451 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
3452 ("limTdlsSetupAddSta: Aid = %d, for peer = %02x,%02x,%02x,%02x,%02x,%02x\n"),
Kiran V1ccee932012-12-12 14:49:46 -08003453 aid, peerMac[0],peerMac[1],peerMac[2],
3454 peerMac[3],peerMac[4],peerMac[5]) ;
3455 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
3456
3457 if (pStaDs)
3458 {
3459 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
3460 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
3461 }
3462
3463 pStaDs = dphAddHashEntry(pMac, peerMac, aid,
3464 &psessionEntry->dph.dphHashTable) ;
3465
3466 if(NULL == pStaDs)
3467 {
3468 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3469 (" add hash entry failed\n")) ;
3470 status = eSIR_FAILURE ;
3471 VOS_ASSERT(0) ;
3472 }
3473
3474 limTdlsUpdateHashNodeInfo(pMac, pStaDs, setupPeer, psessionEntry) ;
3475
3476 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
3477
3478 status = limAddSta(pMac, pStaDs, psessionEntry);
3479
3480 if(eSIR_SUCCESS != status)
3481 {
3482 /* should not fail */
3483 VOS_ASSERT(0) ;
3484 }
3485 return status ;
3486}
3487
3488/*
3489 * Del STA, after Link is teardown or discovery response sent on direct link
3490 */
3491static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
3492 tpPESession psessionEntry)
3493{
3494 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003495 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08003496 tpDphHashNode pStaDs = NULL ;
3497
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003498 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08003499 &psessionEntry->dph.dphHashTable) ;
3500
3501 if(pStaDs)
3502 {
3503
3504 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3505 ("DEL STA peer MAC: %02x, %02x, %02x, %02x, %02x, %02x \n"),
3506 pStaDs->staAddr[0],
3507 pStaDs->staAddr[1],
3508 pStaDs->staAddr[2],
3509 pStaDs->staAddr[3],
3510 pStaDs->staAddr[4],
3511 pStaDs->staAddr[5]
3512 ) ;
3513
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003514 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
3515 ("limTdlsDelSta: STA type = %x, sta idx = %x\n"),pStaDs->staType,
Kiran V1ccee932012-12-12 14:49:46 -08003516 pStaDs->staIndex) ;
3517
3518 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08003519#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -08003520 if(eSIR_SUCCESS == status)
3521 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003522 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ;
3523 limReleasePeerIdx(pMac, peerIdx, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08003524 }
3525 else
3526 {
3527 VOS_ASSERT(0) ;
3528 }
Hoonki Leef63df0d2013-01-16 19:29:14 -08003529#endif
Kiran V1ccee932012-12-12 14:49:46 -08003530 }
3531
3532 return pStaDs ;
3533}
3534
3535#ifdef FEATURE_WLAN_TDLS_INTERNAL
3536/*
3537* Prepare link establish message for HAL, construct PTI template.
3538*
3539*/
3540static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac)
3541{
3542 tANI_U8 pFrame[64] ;
3543 tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ;
3544 tANI_U32 status = 0 ;
3545 tANI_U32 nPayload = 0 ;
3546 tANI_U32 nBytes = 0 ;
3547 tANI_U32 header_offset = 0 ;
3548 tANI_U16 aid = 0 ;
3549 tDphHashNode *pStaDs = NULL ;
3550 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3551 tpPESession psessionEntry = NULL ;
3552
3553
3554 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3555 if(NULL == setupPeer) {
3556 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3557 ("limTdlsLinkEstablish: cannot find peer mac in tdls linksetup list: %02X %02X %02X %02X %02X %02X\n"), \
3558 peerMac[0], peerMac[1], peerMac[2], \
3559 peerMac[3], peerMac[4], peerMac[5]);
3560 return eSIR_FAILURE;
3561 }
3562
3563 psessionEntry = peFindSessionBySessionId(pMac,
3564 setupPeer->tdls_sessionId) ;
3565
3566 if(NULL == psessionEntry)
3567 {
3568 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3569 ("limTdlsLinkEstablish: sessionID %d is not found\n"), setupPeer->tdls_sessionId);
3570 VOS_ASSERT(0) ;
3571 return eHAL_STATUS_FAILURE;
3572 }
3573
3574 /* */
3575 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
3576 if(pStaDs == NULL) {
3577 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3578 ("limTdlsLinkEstablish: cannot find peer mac in hash table: %02X %02X %02X %02X %02X %02X\n"), \
3579 peerMac[0], peerMac[1], peerMac[2], \
3580 peerMac[3], peerMac[4], peerMac[5]);
3581 return eSIR_FAILURE;
3582 }
3583
3584 palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsPtiTemplate,
3585 sizeof( tDot11fTDLSPeerTrafficInd ) );
3586
3587 /*
3588 * setup Fixed fields,
3589 */
3590 tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS;
3591 tdlsPtiTemplate.Action.action = SIR_MAC_TDLS_PEER_TRAFFIC_IND;
3592 tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */
3593#if 1
3594 /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address,
3595 then below code makes such an way */
3596 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
3597 peerMac, !setupPeer->tdls_bIsResponder) ;
3598#else
3599 /* below code will make PTI's linkIdentifier's initiator address be selfAddr */
3600 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
3601 peerMac, TDLS_INITIATOR) ;
3602#endif
3603
3604 /* PUBufferStatus will be filled by firmware at the time of transmission */
3605 tdlsPtiTemplate.PUBufferStatus.present = 1;
3606
3607 /* TODO: get ExtendedCapabilities IE */
3608
3609 /*
3610 * now we pack it. First, how much space are we going to need?
3611 */
3612 status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload);
3613 if ( DOT11F_FAILED( status ) )
3614 {
3615 limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x).\n"), status );
3616 /* We'll fall back on the worst case scenario: */
3617 nPayload = sizeof( tdlsPtiTemplate );
3618 }
3619 else if ( DOT11F_WARNED( status ) )
3620 {
3621 limLog( pMac, LOGW, FL("There were warnings while calculating the packed size for a PTI template (0x%08x).\n"), status );
3622 }
3623
3624 /*
3625 * This frame is going out from PE as data frames with special ethertype
3626 * 89-0d.
3627 * 8 bytes of RFC 1042 header
3628 */
3629
3630 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
3631 + sizeof( eth_890d_header )
3632 + PAYLOAD_TYPE_TDLS_SIZE ;
3633
3634 if(nBytes > 64) {
3635 limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64.\n"), nBytes);
3636 nBytes = 64;
3637 }
3638 /* zero out the memory */
3639 palZeroMemory( pMac->hHdd, pFrame, sizeof(pFrame) );
3640
3641 /* fill out the buffer descriptor */
3642
3643 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
3644 LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ;
3645
3646 status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame
3647 + header_offset, nPayload, &nPayload );
3648
3649 if ( DOT11F_FAILED( status ) )
3650 {
3651 limLog( pMac, LOGE, FL("Failed to pack a PTI template \
3652 (0x%08x).\n"), status );
3653 return eSIR_FAILURE;
3654 }
3655 else if ( DOT11F_WARNED( status ) )
3656 {
3657 limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
3658 "Peer Traffic Indication (0x%08x).\n") );
3659 }
3660
3661 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("bIsResponder=%d, header_offset=%ld, linkIdenOffset=%d, ptiBufStatusOffset=%d \n"), \
3662 setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET));
3663
3664 limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder,
3665 header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET,
3666 nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps);
3667
3668 return eSIR_SUCCESS;
3669}
3670
3671/*
3672* Prepare link teardown message for HAL from peer_mac
3673*
3674*/
3675static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac)
3676{
3677 tDphHashNode *pStaDs = NULL ;
3678 tANI_U16 aid = 0 ;
3679 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3680 tpPESession psessionEntry = NULL ;
3681
3682
3683 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3684 if(NULL == setupPeer) {
3685 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3686 ("limTdlsLinkTeardown: cannot find peer mac in tdls linksetup list: %02X %02X %02X %02X %02X %02X\n"), \
3687 peerMac[0], peerMac[1], peerMac[2], \
3688 peerMac[3], peerMac[4], peerMac[5]);
3689 return eSIR_FAILURE;
3690 }
3691
3692 psessionEntry = peFindSessionBySessionId(pMac,
3693 setupPeer->tdls_sessionId) ;
3694
3695 if(NULL == psessionEntry)
3696 {
3697 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3698 ("limTdlsLinkTeardown: sessionID %d is not found\n"), setupPeer->tdls_sessionId);
3699 VOS_ASSERT(0) ;
3700 return eHAL_STATUS_FAILURE;
3701 }
3702
3703
3704 /* */
3705 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
3706
3707 if(pStaDs == NULL) {
3708 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3709 ("limTdlsLinkTeardown: cannot find peer mac in hash table: %02X %02X %02X %02X %02X %02X\n"), \
3710 peerMac[0], peerMac[1], peerMac[2], \
3711 peerMac[3], peerMac[4], peerMac[5]);
3712 return eSIR_FAILURE;
3713 }
3714
3715 limSendTdlsLinkTeardown(pMac, pStaDs->staIndex);
3716
3717 return eSIR_SUCCESS;
3718}
3719
3720/*
3721 * Prepare Discovery RSP message for SME, collect peerINfo for all the
3722 * peers discovered and delete/clean discovery lists in PE.
3723 */
3724
3725static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac,
3726 tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount)
3727{
3728 tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp);
3729 tANI_U8 status = eHAL_STATUS_SUCCESS ;
3730
3731 /*
3732 * allocate memory for tdls discovery response, allocated memory should
3733 * be alloc_mem = tdlsStaCount * sizeof(peerinfo)
3734 * + siezeof tSirTdlsDisRsp.
3735 */
3736 disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo));
3737
3738 /* now allocate memory */
3739 status = palAllocateMemory( pMac->hHdd, (void **)&disRsp, disMsgRspSize ) ;
3740
3741 if(eHAL_STATUS_FAILURE == status)
3742 {
3743 limLog(pMac, LOGP, FL("palAllocateMemory failed for DIS RSP"));
3744 return NULL ;
3745 }
3746
3747 if(disStaCount)
3748 {
3749 tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ;
3750 tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ;
3751
3752 tLimDisResultList *currentNode = tdlsDisRspList ;
3753 while(tdlsDisRspList != NULL)
3754 {
3755
3756 palCopyMemory( pMac->hHdd, (tANI_U8 *)peerInfo,
3757 (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo,
3758 sizeof(tSirTdlsPeerInfo));
3759
3760 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3761 ("Msg Sent to PE, peer MAC: %02x, %02x, %02x, %02x, %02x, %02x\n"),
3762 peerInfo->peerMac[0] ,
3763 peerInfo->peerMac[1] ,
3764 peerInfo->peerMac[2] ,
3765 peerInfo->peerMac[3] ,
3766 peerInfo->peerMac[4] ,
3767 peerInfo->peerMac[5]) ;
3768 disStaCount-- ;
3769 peerInfo++ ;
3770 currentNode = tdlsDisRspList ;
3771 tdlsDisRspList = tdlsDisRspList->next ;
3772 palFreeMemory(pMac->hHdd, currentNode) ;
3773 /* boundary condition check, may be fatal */
3774 if(((!disStaCount) && (tdlsDisRspList))
3775 || ((!tdlsDisRspList) && disStaCount))
3776 {
3777 limLog(pMac, LOG1, FL("mismatch in dis sta count and\
3778 and number of nodes in list\n")) ;
3779 VOS_ASSERT(0) ;
3780 return NULL ;
3781 }
3782 } /* end of while */
3783
3784 /* All discovery STA processed */
3785 pMac->lim.gLimTdlsDisResultList = NULL ;
3786
3787 } /* end of if dis STA count */
3788
3789 return (disRsp) ;
3790}
3791
3792/* Send Teardown response back to PE */
3793
3794void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
3795 tSirMacAddr peerMac, tANI_U16 msgType)
3796{
3797 tSirMsgQ mmhMsg = {0} ;
3798 tSirTdlsTeardownRsp *teardownRspMsg = NULL ;
3799 tANI_U8 status = eHAL_STATUS_SUCCESS ;
3800
3801 mmhMsg.type = msgType ;
3802
3803 status = palAllocateMemory( pMac->hHdd, (void **)&teardownRspMsg,
3804 sizeof(tSirTdlsTeardownRsp)) ;
3805
3806 if(eHAL_STATUS_SUCCESS != status)
3807 {
3808 VOS_ASSERT(0) ;
3809 }
3810 palCopyMemory( pMac->hHdd, teardownRspMsg->peerMac, (tANI_U8 *)peerMac,
3811 sizeof(tSirMacAddr)) ;
3812 teardownRspMsg->statusCode = statusCode ;
3813 mmhMsg.bodyptr = teardownRspMsg ;
3814 mmhMsg.bodyval = 0;
3815 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3816
3817 return ;
3818
3819}
3820
3821/*
3822 * Send Link start RSP back to SME after link is setup or failed
3823 */
3824void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac,
3825 tSirResultCodes statusCode,
3826 tSirMacAddr peerMac,
3827 tANI_U16 msgType)
3828{
3829 tSirMsgQ mmhMsg = {0} ;
3830 tSirTdlsLinksetupRsp *setupRspMsg = NULL ;
3831 tANI_U8 status = eHAL_STATUS_SUCCESS ;
3832
3833 mmhMsg.type = msgType ;
3834
3835 status = palAllocateMemory( pMac->hHdd, (void **)&setupRspMsg,
3836 sizeof(tSirTdlsLinksetupRsp)) ;
3837
3838 if(eHAL_STATUS_SUCCESS != status)
3839 {
3840 VOS_ASSERT(0) ;
3841 }
3842
3843 palCopyMemory( pMac->hHdd, setupRspMsg->peerMac, (tANI_U8 *)peerMac,
3844 sizeof(tSirMacAddr)) ;
3845 setupRspMsg->statusCode = statusCode ;
3846 mmhMsg.bodyptr = setupRspMsg ;
3847 mmhMsg.bodyval = 0;
3848 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3849
3850 return ;
3851}
3852
3853/*
3854 * Send TDLS discovery RSP back to SME
3855 */
3856void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
3857 tANI_U16 msgType)
3858{
3859 tSirMsgQ mmhMsg = {0} ;
3860 tSirTdlsDisRsp *tdlsDisRsp = NULL ;
3861
3862 mmhMsg.type = msgType ;
3863
3864 if(eSIR_SME_SUCCESS == statusCode)
3865 {
3866 tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ;
3867
3868 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3869 ("no of TDLS STA discovered: %d\n"), tdlsStaCount) ;
3870 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
3871
3872 if(tdlsDisRsp)
3873 {
3874 tdlsDisRsp->numDisSta = tdlsStaCount ;
3875 }
3876 else
3877 {
3878 limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP\n"));
3879 VOS_ASSERT(0) ;
3880 return ;
3881 }
3882 /* all Discovery STA is processed */
3883 pMac->lim.gLimTdlsDisStaCount = 0 ;
3884 }
3885 else
3886 {
3887 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ;
3888 }
3889
3890 tdlsDisRsp->statusCode = statusCode ;
3891 mmhMsg.bodyptr = tdlsDisRsp ;
3892 mmhMsg.bodyval = 0;
3893 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3894
3895 return ;
3896}
3897
3898/*
3899 * Once Link is setup with PEER, send Add STA ind to SME
3900 */
3901static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac,
3902 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
3903{
3904 tSirMsgQ mmhMsg = {0} ;
3905 tSirTdlsPeerInd *peerInd = NULL ;
3906 mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ;
3907 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &peerInd,
3908 (sizeof(tSirTdlsPeerInd))))
3909 {
3910 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
3911 return eSIR_FAILURE;
3912 }
3913
3914 palCopyMemory( pMac->hHdd, peerInd->peerMac,
3915 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
3916 peerInd->sessionId = sessionId;
3917 peerInd->staId = pStaDs->staIndex ;
3918 peerInd->ucastSig = pStaDs->ucUcastSig ;
3919 peerInd->bcastSig = pStaDs->ucBcastSig ;
3920 peerInd->length = sizeof(tSmeIbssPeerInd) ;
3921
3922 mmhMsg.bodyptr = peerInd ;
3923 mmhMsg.bodyval = 0;
3924 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3925
3926 return eSIR_SUCCESS ;
3927
3928}
3929
3930/*
3931 * Once link is teardown, send Del Peer Ind to SME
3932 */
3933static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
3934 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
3935{
3936 tSirMsgQ mmhMsg = {0} ;
3937 tSirTdlsPeerInd *peerInd = NULL ;
3938 mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ;
3939 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &peerInd,
3940 (sizeof(tSirTdlsPeerInd))))
3941 {
3942 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
3943 return eSIR_FAILURE;
3944 }
3945
3946 palCopyMemory( pMac->hHdd, peerInd->peerMac,
3947 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
3948 peerInd->sessionId = sessionId;
3949 peerInd->staId = pStaDs->staIndex ;
3950 peerInd->ucastSig = pStaDs->ucUcastSig ;
3951 peerInd->bcastSig = pStaDs->ucBcastSig ;
3952 peerInd->length = sizeof(tSmeIbssPeerInd) ;
3953
3954 mmhMsg.bodyptr = peerInd ;
3955
3956 //peerInd->statusCode = status ;
3957 mmhMsg.bodyval = 0;
3958 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3959 return eSIR_SUCCESS ;
3960
3961}
3962
3963/*
3964 * Send Link setup Ind to SME, This is the case where, link setup is
3965 * initiated by peer STA
3966 */
3967static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
3968 tSirMacAddr peerMac, tANI_U8 status)
3969{
3970 tSirMsgQ mmhMsg = {0} ;
3971 tSirTdlsLinkSetupInd *setupInd = NULL ;
3972
3973 mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ;
3974 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &setupInd,
3975 (sizeof(tSirTdlsLinkSetupInd))))
3976 {
3977 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
3978 return eSIR_FAILURE;
3979 }
3980
3981 palCopyMemory( pMac->hHdd, setupInd->peerMac,
3982 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
3983 setupInd->length = sizeof(tSirTdlsLinkSetupInd);
3984 setupInd->statusCode = status ;
3985 mmhMsg.bodyptr = setupInd ;
3986 mmhMsg.bodyval = 0;
3987 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3988
3989 return eSIR_SUCCESS ;
3990
3991}
3992
3993/*
3994 * Setup RSP timer handler
3995 */
3996void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId)
3997{
3998
3999 tANI_U32 statusCode;
4000 tSirMsgQ msg;
4001 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4002
4003 /* Prepare and post message to LIM Message Queue */
4004
4005 msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT;
4006 msg.bodyptr = NULL ;
4007 msg.bodyval = timerId ;
4008
4009 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4010 limLog(pMac, LOGE,
4011 FL("posting message %X to LIM failed, reason=%d\n"),
4012 msg.type, statusCode);
4013 return ;
4014}
4015
4016/*
4017 * Link setup CNF timer
4018 */
4019void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4020{
4021
4022 tANI_U32 statusCode;
4023 tSirMsgQ msg;
4024 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4025
4026 // Prepare and post message to LIM Message Queue
4027
4028 msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT;
4029 msg.bodyptr = NULL ;
4030 msg.bodyval = timerId ;
4031
4032 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4033 limLog(pMac, LOGE,
4034 FL("posting message %X to LIM failed, reason=%d\n"),
4035 msg.type, statusCode);
4036 return ;
4037}
4038
4039/*
4040 * start TDLS timer
4041 */
4042void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer,
4043 tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg)
4044{
4045 tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4046 ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT
4047 : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ;
4048
4049 void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4050 ? (limTdlsLinkSetupRspTimerHandler)
4051 : limTdlsLinkSetupCnfTimerHandler ;
4052
4053 /* TODO: Read timer vals from CFG */
4054
4055 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4056 /*
4057 * create TDLS discovery response wait timer and activate it
4058 */
4059 if (tx_timer_create(timer, "TDLS link setup timers", timerFunc,
4060 timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS)
4061 {
4062 limLog(pMac, LOGP,
4063 FL("could not create TDLS discovery response wait timer\n"));
4064 return;
4065 }
4066
4067 //assign appropriate sessionId to the timer object
4068 timer->sessionId = sessionId;
4069
4070 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4071 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4072 if (tx_timer_activate(timer) != TX_SUCCESS)
4073 {
4074 limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!\n"));
4075 return ;
4076 }
4077
4078 return ;
4079
4080}
4081#endif
4082
4083/*
4084 * Once Link is setup with PEER, send Add STA ind to SME
4085 */
4086static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
4087 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
4088 tANI_U8 status)
4089{
4090 tSirMsgQ mmhMsg = {0} ;
4091 tSirTdlsAddStaRsp *addStaRsp = NULL ;
4092 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
4093 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &addStaRsp,
4094 (sizeof(tSirTdlsAddStaRsp))))
4095 {
4096 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4097 return eSIR_FAILURE;
4098 }
4099
4100 addStaRsp->sessionId = sessionId;
4101 addStaRsp->statusCode = status;
4102 if( pStaDs )
4103 {
4104 addStaRsp->staId = pStaDs->staIndex ;
4105 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
4106 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
4107 }
4108 if( peerMac )
4109 {
4110 palCopyMemory( pMac->hHdd, addStaRsp->peerMac,
4111 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4112 }
4113 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
4114 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
4115
4116 mmhMsg.bodyptr = addStaRsp;
4117 mmhMsg.bodyval = 0;
4118 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4119
4120 return eSIR_SUCCESS ;
4121
4122}
4123/*
4124 * STA RSP received from HAL
4125 */
4126eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
4127 tpPESession psessionEntry)
4128{
4129 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
4130 tANI_U8 status = eSIR_SUCCESS ;
4131 tDphHashNode *pStaDs = NULL ;
4132 tANI_U16 aid = 0 ;
4133
4134 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004135 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
4136 ("limTdlsAddStaRsp: staIdx=%d, staMac=%02x:%02x:%02x:%02x:%02x:%02x"), pAddStaParams->staIdx, \
Kiran V1ccee932012-12-12 14:49:46 -08004137 pAddStaParams->staMac[0],
4138 pAddStaParams->staMac[1],
4139 pAddStaParams->staMac[2],
4140 pAddStaParams->staMac[3],
4141 pAddStaParams->staMac[4],
4142 pAddStaParams->staMac[5] ) ;
4143
4144 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
4145 {
4146 VOS_ASSERT(0) ;
4147 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4148 ("Add sta failed \n")) ;
4149 status = eSIR_FAILURE;
4150 goto add_sta_error;
4151 }
4152
4153 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
4154 &psessionEntry->dph.dphHashTable);
4155 if(NULL == pStaDs)
4156 {
4157 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4158 ("pStaDs is NULL \n")) ;
4159 status = eSIR_FAILURE;
4160 goto add_sta_error;
4161 }
4162
4163 pStaDs->bssId = pAddStaParams->bssIdx;
4164 pStaDs->staIndex = pAddStaParams->staIdx;
4165 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
4166 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
4167 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4168 pStaDs->valid = 1 ;
4169#ifdef FEATURE_WLAN_TDLS_INTERNAL
4170 status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId,
4171 pStaDs, eSIR_SUCCESS ) ;
4172 if(eSIR_FAILURE == status)
4173 {
4174 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4175 ("Peer IND msg to SME failed\n")) ;
4176 palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
4177 return eSIR_FAILURE ;
4178 }
4179
4180 /*
4181 * Now, there is two things a) ADD STA RSP for ADD STA request sent
4182 * after recieving discovery request from Peer.
4183 * now we have to send discovery response, if there is any pending
4184 * discovery equest..
4185 */
4186 do
4187 {
4188 tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac,
4189 pAddStaParams->staMac) ;
4190
4191
4192 if(peerInfo)
4193 {
4194 /*
4195 * send TDLS discovery response frame on direct link, state machine
4196 * is rolling.., once discovery response is get Acked, we will
4197 * send response to SME based on TxComplete callback results
4198 */
4199 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
4200 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
4201 }
4202 } while(0) ;
Kiran V1ccee932012-12-12 14:49:46 -08004203#endif
4204add_sta_error:
4205 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Hoonki Leef63df0d2013-01-16 19:29:14 -08004206 pAddStaParams->staMac, pStaDs, status) ;
Kiran V1ccee932012-12-12 14:49:46 -08004207 palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
4208 return status ;
4209}
4210
4211/*
4212 * FUNCTION: Populate Link Identifier element IE
4213 *
4214 */
4215
4216
4217void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
4218 tDot11fIELinkIdentifier *linkIden,
4219 tSirMacAddr peerMac, tANI_U8 reqType)
4220{
4221 //tANI_U32 size = sizeof(tSirMacAddr) ;
4222 tANI_U8 *initStaAddr = NULL ;
4223 tANI_U8 *respStaAddr = NULL ;
4224
4225 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
4226 (respStaAddr = linkIden->RespStaAddr))
4227 : ((respStaAddr = linkIden->InitStaAddr ),
4228 (initStaAddr = linkIden->RespStaAddr)) ;
4229 palCopyMemory( pMac->hHdd, (tANI_U8 *)linkIden->bssid,
4230 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
4231
4232 palCopyMemory( pMac->hHdd, (tANI_U8 *)initStaAddr,
4233 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
4234
4235 palCopyMemory( pMac->hHdd, (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
4236 sizeof( tSirMacAddr ));
4237
4238 linkIden->present = 1 ;
4239 return ;
4240
4241}
4242
4243void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
4244 tDot11fIEExtCap *extCapability)
4245{
4246 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
4247 extCapability->TDLSPeerUAPSDBufferSTA = PEER_BUFFER_STA_SUPPORT ;
4248 extCapability->TDLSChannelSwitching = CH_SWITCH_SUPPORT ;
4249 extCapability->TDLSSupport = TDLS_SUPPORT ;
4250 extCapability->TDLSProhibited = TDLS_PROHIBITED ;
4251 extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
4252 extCapability->present = 1 ;
4253 return ;
4254}
4255
4256#ifdef FEATURE_WLAN_TDLS_INTERNAL
4257/*
4258 * Public Action frame common processing
4259 * This Function will be moved/merged to appropriate place
4260 * once other public action frames (particularly 802.11k)
4261 * is in place
4262 */
4263void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd,
4264 tpPESession psessionEntry)
4265{
4266 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
4267 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ;
4268 tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ;
4269
4270 limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ;
4271 return ;
4272}
4273
4274eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac,
4275 tLimTdlsLinkSetupInfo *linkSetupInfo,
4276 tANI_U8 dialog, tSirMacAddr peerMac,
4277 tpPESession psessionEntry)
4278{
4279 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4280
4281 /*
4282 * we allocate the TDLS setup Peer Memory here, we will free'd this
4283 * memory after teardown, if the link is successfully setup or
4284 * free this memory if any timeout is happen in link setup procedure
4285 */
4286 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4287 (void **) &setupPeer, sizeof( tLimTdlsLinkSetupPeer )))
4288 {
4289 limLog( pMac, LOGP,
4290 FL( "Unable to allocate memory during ADD_STA\n" ));
4291 VOS_ASSERT(0) ;
4292 return eSIR_MEM_ALLOC_FAILED;
4293 }
4294 setupPeer->dialog = dialog ;
4295 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
4296 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
4297
4298 /* TDLS_sessionize: remember sessionId for future */
4299 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
4300 setupPeer->tdls_bIsResponder = 1;
4301
4302 /*
4303 * we only populate peer MAC, so it can assit us to find the
4304 * TDLS peer after response/or after response timeout
4305 */
4306 palCopyMemory(pMac->hHdd, setupPeer->peerMac, peerMac,
4307 sizeof(tSirMacAddr)) ;
4308 /* format TDLS discovery request frame and transmit it */
4309 limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ;
4310
4311 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
4312 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
4313 (tANI_U32)setupPeer->peerMac,
4314 WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
4315 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
4316 /* update setup peer list */
4317 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
4318 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
4319
4320 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to
4321 * SME later when TDLS setup cnf TX complete is successful. --> see
4322 * limTdlsSetupCnfTxComplete()
4323 */
4324 return eSIR_SUCCESS ;
4325}
4326#endif
4327
4328/*
4329 * Process Send Mgmt Request from SME and transmit to AP.
4330 */
4331tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
4332 tANI_U32 *pMsgBuf)
4333{
4334 /* get all discovery request parameters */
4335 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
4336 tpPESession psessionEntry;
4337 tANI_U8 sessionId;
4338 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
4339
4340 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
4341 ("Send Mgmt Recieved\n")) ;
4342
4343 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
4344 == NULL)
4345 {
4346 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4347 "PE Session does not exist for given sme sessionId %d\n",
4348 pSendMgmtReq->sessionId);
4349 goto lim_tdls_send_mgmt_error;
4350 }
4351
4352 /* check if we are in proper state to work as TDLS client */
4353 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
4354 {
4355 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4356 "send mgmt received in wrong system Role %d\n",
4357 psessionEntry->limSystemRole);
4358 goto lim_tdls_send_mgmt_error;
4359 }
4360
4361 /*
4362 * if we are still good, go ahead and check if we are in proper state to
4363 * do TDLS discovery req/rsp/....frames.
4364 */
4365 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4366 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4367 {
4368
4369 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme \
4370 state (%d)\n", psessionEntry->limSmeState);
4371 goto lim_tdls_send_mgmt_error;
4372 }
4373
4374 switch( pSendMgmtReq->reqType )
4375 {
4376 case SIR_MAC_TDLS_DIS_REQ:
4377 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
4378 "Transmit Discovery Request Frame\n") ;
4379 /* format TDLS discovery request frame and transmit it */
4380 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
4381 psessionEntry) ;
4382 resultCode = eSIR_SME_SUCCESS;
4383 break;
4384 case SIR_MAC_TDLS_DIS_RSP:
4385 {
4386 //Send a response mgmt action frame
4387 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
4388 pSendMgmtReq->dialog, psessionEntry) ;
4389 resultCode = eSIR_SME_SUCCESS;
4390 }
4391 break;
4392 case SIR_MAC_TDLS_SETUP_REQ:
4393 {
4394 limSendTdlsLinkSetupReqFrame(pMac,
4395 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
4396 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
4397 resultCode = eSIR_SME_SUCCESS;
4398 }
4399 break;
4400 case SIR_MAC_TDLS_SETUP_RSP:
4401 {
4402 limSendTdlsSetupRspFrame(pMac,
4403 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
4404 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
4405 resultCode = eSIR_SME_SUCCESS;
4406 }
4407 break;
4408 case SIR_MAC_TDLS_SETUP_CNF:
4409 {
4410 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
4411 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
4412 resultCode = eSIR_SME_SUCCESS;
4413 }
4414 break;
4415 case SIR_MAC_TDLS_TEARDOWN:
4416 {
4417 limSendTdlsTeardownFrame(pMac,
4418 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, psessionEntry,
4419 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
4420 resultCode = eSIR_SME_SUCCESS;
4421 }
4422 break;
4423 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
4424 {
4425 }
4426 break;
4427 case SIR_MAC_TDLS_CH_SWITCH_REQ:
4428 {
4429 }
4430 break;
4431 case SIR_MAC_TDLS_CH_SWITCH_RSP:
4432 {
4433 }
4434 break;
4435 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
4436 {
4437 }
4438 break;
4439 default:
4440 break;
4441 }
4442
4443lim_tdls_send_mgmt_error:
4444
4445 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
4446 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
4447
4448 return eSIR_SUCCESS;
4449}
4450
4451/*
4452 * Once link is teardown, send Del Peer Ind to SME
4453 */
4454static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
4455 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
4456 tANI_U8 status)
4457{
4458 tSirMsgQ mmhMsg = {0} ;
4459 tSirTdlsDelStaRsp *pDelSta = NULL ;
4460 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
4461 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &pDelSta,
4462 (sizeof(tSirTdlsDelStaRsp))))
4463 {
4464 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4465 return eSIR_FAILURE;
4466 }
4467
4468 pDelSta->sessionId = sessionId;
4469 pDelSta->statusCode = status ;
4470 if( pStaDs )
4471 {
4472 pDelSta->staId = pStaDs->staIndex ;
4473 }
4474 if( peerMac )
4475 {
4476 palCopyMemory(pMac->hHdd, pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
4477 }
4478
4479 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
4480 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
4481
4482 mmhMsg.bodyptr = pDelSta;
4483
4484 mmhMsg.bodyval = 0;
4485 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4486 return eSIR_SUCCESS ;
4487
4488}
4489
4490/*
4491 * Process Send Mgmt Request from SME and transmit to AP.
4492 */
4493tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
4494 tANI_U32 *pMsgBuf)
4495{
4496 /* get all discovery request parameters */
4497 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
4498 tpPESession psessionEntry;
4499 tANI_U8 sessionId;
4500 tLimTdlsLinkSetupPeer setupPeer = {0};
4501
4502 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
4503 ("Send Mgmt Recieved\n")) ;
4504
4505 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
4506 == NULL)
4507 {
4508 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4509 "PE Session does not exist for given sme sessionId %d\n",
4510 pAddStaReq->sessionId);
4511 goto lim_tdls_add_sta_error;
4512 }
4513
4514 /* check if we are in proper state to work as TDLS client */
4515 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
4516 {
4517 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4518 "send mgmt received in wrong system Role %d\n",
4519 psessionEntry->limSystemRole);
4520 goto lim_tdls_add_sta_error;
4521 }
4522
4523 /*
4524 * if we are still good, go ahead and check if we are in proper state to
4525 * do TDLS discovery req/rsp/....frames.
4526 */
4527 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4528 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4529 {
4530
4531 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme \
4532 state (%d)\n", psessionEntry->limSmeState);
4533 goto lim_tdls_add_sta_error;
4534 }
4535
4536 pMac->lim.gLimAddStaTdls = true ;
4537
4538 /* To start with, send add STA request to HAL */
4539 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq->peerMac,
4540 &setupPeer, psessionEntry))
4541 {
4542 VOS_ASSERT(0) ;
4543 goto lim_tdls_add_sta_error;
4544 }
4545 return eSIR_SUCCESS;
4546lim_tdls_add_sta_error:
4547 limSendSmeTdlsAddStaRsp(pMac,
4548 pAddStaReq->sessionId, pAddStaReq->peerMac, NULL, eSIR_FAILURE );
4549
4550 return eSIR_SUCCESS;
4551}
4552/*
4553 * Process Del Sta Request from SME .
4554 */
4555tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
4556 tANI_U32 *pMsgBuf)
4557{
4558 /* get all discovery request parameters */
4559 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
4560 tpPESession psessionEntry;
4561 tANI_U8 sessionId;
4562 tpDphHashNode pStaDs = NULL ;
4563
4564 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
4565 ("Send Mgmt Recieved\n")) ;
4566
4567 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
4568 == NULL)
4569 {
4570 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4571 "PE Session does not exist for given sme sessionId %d\n",
4572 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08004573 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004574 NULL, eSIR_FAILURE) ;
4575 return eSIR_FAILURE;
4576 }
4577
4578 /* check if we are in proper state to work as TDLS client */
4579 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
4580 {
4581 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4582 "Del sta received in wrong system Role %d\n",
4583 psessionEntry->limSystemRole);
4584 goto lim_tdls_del_sta_error;
4585 }
4586
4587 /*
4588 * if we are still good, go ahead and check if we are in proper state to
4589 * do TDLS discovery req/rsp/....frames.
4590 */
4591 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4592 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4593 {
4594
4595 limLog(pMac, LOGE, "Del Sta received in invalid LIMsme \
4596 state (%d)\n", psessionEntry->limSmeState);
4597 goto lim_tdls_del_sta_error;
4598 }
4599
4600 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
4601
4602 /* now send indication to SME-->HDD->TL to remove STA from TL */
4603
4604 if(pStaDs)
4605 {
4606 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
4607 pStaDs, eSIR_SUCCESS) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08004608
4609 limReleasePeerIdx(pMac, pStaDs->staIndex, psessionEntry) ;
4610 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
4611
Kiran V1ccee932012-12-12 14:49:46 -08004612 return eSIR_SUCCESS;
4613
4614 }
4615
4616lim_tdls_del_sta_error:
4617 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
4618 NULL, eSIR_FAILURE) ;
4619
4620 return eSIR_SUCCESS;
4621}
4622#endif