blob: ff9bb9eaa510f9eb33b39129550c1eed749b50d0 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Kiet Lamaa8e15a2014-02-11 23:30:06 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Kiran V1ccee932012-12-12 14:49:46 -080028/*===========================================================================
29
30 limProcessTdls.c
31
32 OVERVIEW:
33
34 DEPENDENCIES:
35
36 Are listed for each API below.
Kiran V1ccee932012-12-12 14:49:46 -080037===========================================================================*/
38
39/*===========================================================================
40
41 EDIT HISTORY FOR FILE
42
43
44 This section contains comments describing changes made to the module.
45 Notice that changes are listed in reverse chronological order.
46
47
48 $Header$$DateTime$$Author$
49
50
51 when who what, where, why
52---------- --- --------------------------------------------------------
5305/05/2010 Ashwani Initial Creation, added TDLS action frame functionality,
54 TDLS message exchange with SME..etc..
55
56===========================================================================*/
57
58
59/**
60 * \file limProcessTdls.c
61 *
62 * \brief Code for preparing,processing and sending 802.11z action frames
63 *
64 */
65
66#ifdef FEATURE_WLAN_TDLS
67
68#include "sirApi.h"
69#include "aniGlobal.h"
70#include "sirMacProtDef.h"
71#include "cfgApi.h"
72#include "utilsApi.h"
73#include "limTypes.h"
74#include "limUtils.h"
75#include "limSecurityUtils.h"
76#include "dot11f.h"
77#include "limStaHashApi.h"
78#include "schApi.h"
79#include "limSendMessages.h"
80#include "utilsParser.h"
81#include "limAssocUtils.h"
82#include "dphHashTable.h"
83#include "wlan_qct_wda.h"
84
Hoonki Lee6c6822a2013-02-06 14:10:46 -080085/* define NO_PAD_TDLS_MIN_8023_SIZE to NOT padding: See CR#447630
86There was IOT issue with cisco 1252 open mode, where it pads
87discovery req/teardown frame with some junk value up to min size.
88To avoid this issue, we pad QCOM_VENDOR_IE.
89If there is other IOT issue because of this bandage, define NO_PAD...
90*/
91#ifndef NO_PAD_TDLS_MIN_8023_SIZE
92#define MIN_IEEE_8023_SIZE 46
93#define MIN_VENDOR_SPECIFIC_IE_SIZE 5
94#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -080095#ifdef WLAN_FEATURE_TDLS_DEBUG
96#define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
97#else
98#define TDLS_DEBUG_LOG_LEVEL VOS_TRACE_LEVEL_INFO
99#endif
Kiran V1ccee932012-12-12 14:49:46 -0800100
101#ifdef FEATURE_WLAN_TDLS_INTERNAL
102/* forword declarations */
103static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
104 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) ;
105static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
106 tSirMacAddr peerMac, tANI_U8 status);
107static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
108 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status) ;
109static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
110 tANI_U8 state);
111static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
112 tLimTdlsLinkSetupPeer **setupPeer) ;
113static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
114
115static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
116static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
117 tpPESession psessionEntry) ;
118
119#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800120static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
121 tSirTdlsAddStaReq *pAddStaReq,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530122 tpPESession psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800123void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
124 tDot11fIELinkIdentifier *linkIden,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530125 tSirMacAddr peerMac, tANI_U8 reqType) ;
Kiran V1ccee932012-12-12 14:49:46 -0800126void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
127 tDot11fIEExtCap *extCapability) ;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800128
Naresh Jayarambc62ba42014-02-12 21:39:14 +0530129void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
130 tpPESession psessionEntry,
131 tDot11fIESuppChannels *suppChannels,
132 tDot11fIESuppOperatingClasses *suppOperClasses);
133
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800134void limLogVHTCap(tpAniSirGlobal pMac,
135 tDot11fIEVHTCaps *pDot11f);
136tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
137 tpSirSupportedRates pRates,
138 tDot11fIEVHTCaps *pPeerVHTCaps,
139 tpPESession psessionEntry);
140ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode);
Atul Mittalb849d5a2014-07-29 12:08:39 +0530141/*only 31 op classes are available, 1 entry for current op class*/
142static tDot11fIESuppOperatingClasses op_classes = {0};
143
144op_class_map_t global_op_class[] = {
145 {81, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}},
146 {82, 25, BW20, {14}},
147 {83, 40, BW40PLUS, {1, 2, 3, 4, 5, 6, 7, 8, 9}},
148 {84, 40, BW40MINUS, {5, 6, 7, 8, 9, 10, 11, 12, 13}},
149 {115, 20, BW20, {36, 40, 44, 48}},
150 {116, 40, BW40PLUS, {36, 44}},
151 {117, 40, BW40MINUS, {40, 48}},
152 {118, 20, BW20, {52, 56, 60, 64}},
153 {119, 40, BW40PLUS, {52, 60}},
154 {120, 40, BW40MINUS, {56, 64}},
155 {121, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
156 {122, 40, BW40PLUS, {100, 108, 116, 124, 132}},
157 {123, 40, BW40MINUS, {104, 112, 120, 128, 136}},
158 {125, 20, BW20, {149, 153, 157, 161, 165, 169}},
159 {126, 40, BW40PLUS, {149, 157}},
160 {127, 40, BW40MINUS, {153, 161}},
161 {0, 0, 0, {0}},
162
163};/*end global_op_class*/
164
165op_class_map_t us_op_class[] = {
166 {1, 20, BW20, {36, 40, 44, 48}},
167 {2, 20, BW20, {52, 56, 60, 64}},
168 {4, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
169 {5, 20, BW20, {149, 153, 157, 161, 165}},
170 {22, 40, BW40PLUS, {36, 44}},
171 {23, 40, BW40PLUS, {52, 60}},
172 {24, 40, BW40PLUS, {100, 108, 116, 124, 132}},
173 {26, 40, BW40PLUS, {149, 157}},
174 {27, 40, BW40MINUS, {40, 48}},
175 {28, 40, BW40MINUS, {56, 64}},
176 {29, 40, BW40MINUS, {104, 112, 120, 128, 136}},
177 {31, 40, BW40MINUS, {153, 161}},
178 {32, 40, BW40PLUS, {1, 2, 3, 4, 5, 6, 7}},
179 {33, 40, BW40MINUS, {5, 6, 7, 8, 9, 10, 11}},
180 {0, 0, 0, {0}},
181};/*end us_op_class*/
182
183op_class_map_t euro_op_class[] = {
184 {1, 20, BW20, {36, 40, 44, 48}},
185 {2, 20, BW20, {52, 56, 60, 64}},
186 {3, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
187 {4, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}},
188 {5, 40, BW40PLUS, {36, 44}},
189 {6, 40, BW40PLUS, {52, 60}},
190 {7, 40, BW40PLUS, {100, 108, 116, 124, 132}},
191 {8, 40, BW40MINUS, {40, 48}},
192 {9, 40, BW40MINUS, {56, 64}},
193 {10, 40, BW40MINUS, {104, 112, 120, 128, 136}},
194 {11, 40, BW40PLUS, {1, 2, 3, 4, 5, 6, 7, 8, 9}},
195 {12, 40, BW40MINUS, {5, 6, 7, 8, 9, 10, 11, 12, 13}},
196 {17, 20, BW20, {149, 153, 157, 161, 165, 169}},
197 {0, 0, 0, {0}},
198};/*end euro_op_class*/
199
200op_class_map_t japan_op_class[] = {
201 {1, 20, BW20, {36, 40, 44, 48}},
202 {30, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}},
203 {31, 25, BW20, {14}},
204 {32, 20, BW20, {52, 56, 60, 64}},
205 {34, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
206 {36, 40, BW40PLUS, {36, 44}},
207 {37, 40, BW40PLUS, {52, 60}},
208 {39, 40, BW40PLUS, {100, 108, 116, 124, 132}},
209 {41, 40, BW40MINUS, {40, 48}},
210 {42, 40, BW40MINUS, {56, 64}},
211 {44, 40, BW40MINUS, {104, 112, 120, 128, 136}},
212 {0, 0, 0, {0}},
213};/*end japan_op_class*/
214
Kiran V1ccee932012-12-12 14:49:46 -0800215/*
216 * TDLS data frames will go out/come in as non-qos data.
217 * so, eth_890d_header will be aligned access..
218 */
219static const tANI_U8 eth_890d_header[] =
220{
221 0xaa, 0xaa, 0x03, 0x00,
222 0x00, 0x00, 0x89, 0x0d,
223} ;
224
225/*
226 * type of links used in TDLS
227 */
228enum tdlsLinks
229{
230 TDLS_LINK_AP,
231 TDLS_LINK_DIRECT
232} eTdlsLink ;
233
234/*
235 * node status in node searching
236 */
237enum tdlsLinkNodeStatus
238{
239 TDLS_NODE_NOT_FOUND,
240 TDLS_NODE_FOUND
241} eTdlsLinkNodeStatus ;
242
243
244enum tdlsReqType
245{
246 TDLS_INITIATOR,
247 TDLS_RESPONDER
248} eTdlsReqType ;
249
250typedef enum tdlsLinkSetupStatus
251{
252 TDLS_SETUP_STATUS_SUCCESS = 0,
253 TDLS_SETUP_STATUS_FAILURE = 37
254}etdlsLinkSetupStatus ;
255
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +0530256/* These maps to Kernel TDLS peer capability
257 * flags and should get changed as and when necessary
258 */
259enum tdls_peer_capability {
260 TDLS_PEER_HT_CAP = 0,
261 TDLS_PEER_VHT_CAP = 1,
262 TDLS_PEER_WMM_CAP = 2
263} eTdlsPeerCapability;
264
Kiran V1ccee932012-12-12 14:49:46 -0800265/* some local defines */
266#define LINK_IDEN_BSSID_OFFSET (0)
267#define PEER_MAC_OFFSET (12)
268#define STA_MAC_OFFSET (6)
269#define LINK_IDEN_ELE_ID (101)
270//#define LINK_IDEN_LENGTH (18)
271#define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier)
272#define PTI_LINK_IDEN_OFFSET (5)
273#define PTI_BUF_STATUS_OFFSET (25)
274
275/* TODO, Move this parameters to configuration */
276#define PEER_PSM_SUPPORT (0)
Hoonki Lee93e67ff2013-03-19 15:49:25 -0700277#define PEER_BUFFER_STA_SUPPORT (0)
Kiran V1ccee932012-12-12 14:49:46 -0800278#define CH_SWITCH_SUPPORT (0)
279#define TDLS_SUPPORT (1)
280#define TDLS_PROHIBITED (0)
281#define TDLS_CH_SWITCH_PROHIBITED (1)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800282/** @brief Set bit manipulation macro */
283#define SET_BIT(value,mask) ((value) |= (1 << (mask)))
284/** @brief Clear bit manipulation macro */
285#define CLEAR_BIT(value,mask) ((value) &= ~(1 << (mask)))
286/** @brief Check bit manipulation macro */
287#define CHECK_BIT(value, mask) ((value) & (1 << (mask)))
288
289#define SET_PEER_AID_BITMAP(peer_bitmap, aid) \
290 if ((aid) < (sizeof(tANI_U32) << 3)) \
291 SET_BIT(peer_bitmap[0], (aid)); \
292 else if ((aid) < (sizeof(tANI_U32) << 4)) \
293 SET_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
294
295#define CLEAR_PEER_AID_BITMAP(peer_bitmap, aid) \
296 if ((aid) < (sizeof(tANI_U32) << 3)) \
297 CLEAR_BIT(peer_bitmap[0], (aid)); \
298 else if ((aid) < (sizeof(tANI_U32) << 4)) \
299 CLEAR_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
300
Kiran V1ccee932012-12-12 14:49:46 -0800301
302#ifdef LIM_DEBUG_TDLS
Kiran V1ccee932012-12-12 14:49:46 -0800303
304#ifdef FEATURE_WLAN_TDLS
305#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100)
306#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800)
307#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200)
308#endif
309
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530310#define IS_QOS_ENABLED(psessionEntry) ((((psessionEntry)->limQosEnabled) && \
311 SIR_MAC_GET_QOS((psessionEntry)->limCurrentBssCaps)) || \
312 (((psessionEntry)->limWmeEnabled ) && \
313 LIM_BSS_CAPS_GET(WME, (psessionEntry)->limCurrentBssQosCaps)))
314
315#define TID_AC_VI 4
316#define TID_AC_BK 1
317
Kiran V1ccee932012-12-12 14:49:46 -0800318const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
319{
320 switch( tdlsActionCode )
321 {
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530322 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
323 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
324 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
325 CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
326 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
327 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
328 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
329 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
330 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
331 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
Kiran V1ccee932012-12-12 14:49:46 -0800332 }
333 return (const tANI_U8*)"UNKNOWN";
334}
335#endif
336#if 0
337static void printMacAddr(tSirMacAddr macAddr)
338{
339 int i = 0 ;
340 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
341
342 for(i = 0 ; i < 6; i++)
343 {
344 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
345 (" %02x "), macAddr[i]);
346 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700347 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (""));
Kiran V1ccee932012-12-12 14:49:46 -0800348 return ;
349}
350#endif
Kiran V1ccee932012-12-12 14:49:46 -0800351/*
352 * initialize TDLS setup list and related data structures.
353 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800354void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800355{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800356#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800357 pMac->lim.gLimTdlsDisResultList = NULL ;
358 pMac->lim.gLimTdlsDisStaCount = 0 ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530359 vos_mem_set(&pMac->lim.gLimTdlsDisReq, sizeof(tSirTdlsDisReq), 0);
360 vos_mem_set(&pMac->lim.gLimTdlsLinkSetupInfo, sizeof(tLimTdlsLinkSetupInfo), 0);
Kiran V1ccee932012-12-12 14:49:46 -0800361 pMac->lim.gAddStaDisRspWait = 0 ;
362
363#ifdef FEATURE_WLAN_TDLS_NEGATIVE
364 /* when reassociated, negative behavior will not be kept */
365 /* you have to explicitly enable negative behavior per (re)association */
366 pMac->lim.gLimTdlsNegativeBehavior = 0;
367#endif
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800368#endif
369 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800370
371 return ;
372}
Kiran V1ccee932012-12-12 14:49:46 -0800373#ifdef FEATURE_WLAN_TDLS_NEGATIVE
374void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
375{
376 if(on) {
377 if(value == 255)
378 pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
379 else
380 pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
381 }
382 else {
383 if(value == 255)
384 pMac->lim.gLimTdlsNegativeBehavior = 0;
385 else
386 pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
387 }
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800388 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("%d %d -> gLimTdlsNegativeBehavior= 0x%lx"),
Kiran V1ccee932012-12-12 14:49:46 -0800389 value, on, pMac->lim.gLimTdlsNegativeBehavior));
390}
391#endif
392#if 0
393/*
394 * This function is used for creating TDLS public Action frame to
395 * transmit on Direct link
396 */
397static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
398 tANI_U8 type, tANI_U8 subType,
399 tANI_U8 *link_iden )
400{
401 tpSirMacMgmtHdr pMacHdr ;
402 tANI_U8 *bssid = link_iden ;
403#if 0
404 tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
405 tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
406#else
407 tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
408 tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
409#endif
410 tANI_U8 toDs = ANI_TXDIR_IBSS ;
411
412 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
413
414 /*
415 * prepare 802.11 header
416 */
417 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
418 pMacHdr->fc.type = type ;
419 pMacHdr->fc.subType = subType ;
420 /*
421 * TL is not setting up below fields, so we are doing it here
422 */
423 pMacHdr->fc.toDS = toDs ;
424 pMacHdr->fc.powerMgmt = 0 ;
425
426
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530427 vos_mem_copy( (tANI_U8 *) pMacHdr->da, peerMac, sizeof( tSirMacAddr ));
428 vos_mem_copy( (tANI_U8 *) pMacHdr->sa,
Kiran V1ccee932012-12-12 14:49:46 -0800429 staMac, sizeof( tSirMacAddr ));
430
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530431 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Kiran V1ccee932012-12-12 14:49:46 -0800432 bssid, sizeof( tSirMacAddr ));
433
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800434 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"),
435 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5],
436 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5],
437 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2],
Kiran V1ccee932012-12-12 14:49:46 -0800438 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
439
440 return ;
441}
442#endif
443/*
444 * prepare TDLS frame header, it includes
445 * | | | |
446 * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
447 * | | | |
448 */
449static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530450 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType,
451 tANI_U8 tid, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800452{
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530453 tpSirMacDataHdr3a pMacHdr ;
Kiran V1ccee932012-12-12 14:49:46 -0800454 tANI_U32 header_offset = 0 ;
455 tANI_U8 *addr1 = NULL ;
456 tANI_U8 *addr3 = NULL ;
457 tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP)
458 ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ;
459 tANI_U8 *peerMac = (reqType == TDLS_INITIATOR)
460 ? link_iden->RespStaAddr : link_iden->InitStaAddr;
461 tANI_U8 *staMac = (reqType == TDLS_INITIATOR)
462 ? link_iden->InitStaAddr : link_iden->RespStaAddr;
463
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530464 pMacHdr = (tpSirMacDataHdr3a) (pFrame);
Kiran V1ccee932012-12-12 14:49:46 -0800465
466 /*
467 * if TDLS frame goes through the AP link, it follows normal address
468 * pattern, if TDLS frame goes thorugh the direct link, then
469 * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
470 */
471 (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
472 (addr3 = (peerMac)))
473 : ((addr1 = (peerMac)),
474 (addr3 = (link_iden->bssid))) ;
475 /*
476 * prepare 802.11 header
477 */
478 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
479 pMacHdr->fc.type = SIR_MAC_DATA_FRAME ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530480 pMacHdr->fc.subType = IS_QOS_ENABLED(psessionEntry) ? SIR_MAC_DATA_QOS_DATA : SIR_MAC_DATA_DATA;
481
Kiran V1ccee932012-12-12 14:49:46 -0800482 /*
483 * TL is not setting up below fields, so we are doing it here
484 */
485 pMacHdr->fc.toDS = toDs ;
486 pMacHdr->fc.powerMgmt = 0 ;
487 pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
488
489
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530490 vos_mem_copy( (tANI_U8 *) pMacHdr->addr1,
491 (tANI_U8 *)addr1,
492 sizeof( tSirMacAddr ));
493 vos_mem_copy( (tANI_U8 *) pMacHdr->addr2,
494 (tANI_U8 *) staMac,
495 sizeof( tSirMacAddr ));
Kiran V1ccee932012-12-12 14:49:46 -0800496
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530497 vos_mem_copy( (tANI_U8 *) pMacHdr->addr3,
498 (tANI_U8 *) (addr3),
499 sizeof( tSirMacAddr ));
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530500
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800501 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"),
502 (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD",
503 pMacHdr->addr1[0], pMacHdr->addr1[1], pMacHdr->addr1[2], pMacHdr->addr1[3], pMacHdr->addr1[4], pMacHdr->addr1[5],
504 pMacHdr->addr2[0], pMacHdr->addr2[1], pMacHdr->addr2[2], pMacHdr->addr2[3], pMacHdr->addr2[4], pMacHdr->addr2[5],
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530505 pMacHdr->addr3[0], pMacHdr->addr3[1], pMacHdr->addr3[2], pMacHdr->addr3[3], pMacHdr->addr3[4], pMacHdr->addr3[5]));
Kiran V1ccee932012-12-12 14:49:46 -0800506
507 //printMacAddr(pMacHdr->bssId) ;
508 //printMacAddr(pMacHdr->sa) ;
509 //printMacAddr(pMacHdr->da) ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530510
511 if (IS_QOS_ENABLED(psessionEntry))
512 {
513 pMacHdr->qosControl.tid = tid;
514 header_offset += sizeof(tSirMacDataHdr3a);
515 }
516 else
517 header_offset += sizeof(tSirMacMgmtHdr);
518
Kiran V1ccee932012-12-12 14:49:46 -0800519 /*
520 * Now form RFC1042 header
521 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530522 vos_mem_copy((tANI_U8 *)(pFrame + header_offset),
523 (tANI_U8 *)eth_890d_header, sizeof(eth_890d_header)) ;
Kiran V1ccee932012-12-12 14:49:46 -0800524
525 header_offset += sizeof(eth_890d_header) ;
526
527 /* add payload type as TDLS */
528 *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
529
530 return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ;
531}
532
533/*
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800534 * TX Complete for Management frames
535 */
536 eHalStatus limMgmtTXComplete(tpAniSirGlobal pMac,
537 tANI_U32 txCompleteSuccess)
538{
539 tpPESession psessionEntry = NULL ;
540
541 if (0xff != pMac->lim.mgmtFrameSessionId)
542 {
543 psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.mgmtFrameSessionId);
544 if (NULL == psessionEntry)
545 {
546 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
547 ("%s: sessionID %d is not found"), __func__, pMac->lim.mgmtFrameSessionId);
548 return eHAL_STATUS_FAILURE;
549 }
550 limSendSmeMgmtTXCompletion(pMac, psessionEntry, txCompleteSuccess);
551 pMac->lim.mgmtFrameSessionId = 0xff;
552 }
553 return eHAL_STATUS_SUCCESS;
554}
555
556/*
Kiran V1ccee932012-12-12 14:49:46 -0800557 * This function can be used for bacst or unicast discovery request
558 * We are not differentiating it here, it will all depnds on peer MAC address,
559 */
560tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
561 tANI_U8 dialog, tpPESession psessionEntry)
562{
563 tDot11fTDLSDisReq tdlsDisReq ;
564 tANI_U32 status = 0 ;
565 tANI_U32 nPayload = 0 ;
566 tANI_U32 size = 0 ;
567 tANI_U32 nBytes = 0 ;
568 tANI_U32 header_offset = 0 ;
569 tANI_U8 *pFrame;
570 void *pPacket;
571 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800572#ifndef NO_PAD_TDLS_MIN_8023_SIZE
573 tANI_U32 padLen = 0;
574#endif
Kiran V1ccee932012-12-12 14:49:46 -0800575
576 /*
577 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
578 * and then hand it off to 'dot11fPackProbeRequest' (for
579 * serialization). We start by zero-initializing the structure:
580 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530581 vos_mem_set( (tANI_U8*)&tdlsDisReq,
582 sizeof( tDot11fTDLSDisReq ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800583
584 /*
585 * setup Fixed fields,
586 */
587 tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
588 tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ;
589 tdlsDisReq.DialogToken.token = dialog ;
590
591
592 size = sizeof(tSirMacAddr) ;
593
594 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier,
595 peer_mac, TDLS_INITIATOR) ;
596
597 /*
598 * now we pack it. First, how much space are we going to need?
599 */
600 status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
601 if ( DOT11F_FAILED( status ) )
602 {
603 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700604 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800605 /* We'll fall back on the worst case scenario: */
606 nPayload = sizeof( tDot11fTDLSDisReq );
607 }
608 else if ( DOT11F_WARNED( status ) )
609 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800610 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -0800611 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700612 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800613 }
614
615 /*
616 * This frame is going out from PE as data frames with special ethertype
617 * 89-0d.
618 * 8 bytes of RFC 1042 header
619 */
620
621
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530622 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
623 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
624 + sizeof( eth_890d_header )
625 + PAYLOAD_TYPE_TDLS_SIZE ;
Kiran V1ccee932012-12-12 14:49:46 -0800626
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800627#ifndef NO_PAD_TDLS_MIN_8023_SIZE
628 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
629 Hence AP itself padding some bytes, which caused teardown packet is dropped at
630 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
631 */
632 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
633 {
634 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
635
636 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
637 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
638 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
639
640 nBytes += padLen;
641 }
642#endif
643
Kiran V1ccee932012-12-12 14:49:46 -0800644 /* Ok-- try to allocate memory from MGMT PKT pool */
645
646 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
647 ( tANI_U16 )nBytes, ( void** ) &pFrame,
648 ( void** ) &pPacket );
649 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
650 {
651 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700652 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -0800653 return eSIR_MEM_ALLOC_FAILED;
654 }
655
656 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530657 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800658
659 /*
660 * IE formation, memory allocation is completed, Now form TDLS discovery
661 * request frame
662 */
663
664 /* fill out the buffer descriptor */
665
666 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530667 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800668
669#ifdef FEATURE_WLAN_TDLS_NEGATIVE
670 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
671 {
672 tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
673 tdlsDisReq.LinkIdentifier.bssid[5] = 0xad;
674 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800675 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Req"),
676 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800677 }
678#endif
679 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
680 + header_offset, nPayload, &nPayload );
681
682 if ( DOT11F_FAILED( status ) )
683 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800684 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
685 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800686 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
687 ( void* ) pFrame, ( void* ) pPacket );
688 return eSIR_FAILURE;
689 }
690 else if ( DOT11F_WARNED( status ) )
691 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800692 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
693 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -0800694 }
695
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800696#ifndef NO_PAD_TDLS_MIN_8023_SIZE
697 if (padLen != 0)
698 {
699 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
700 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload;
701 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
702 padVendorSpecific[0] = 221;
703 padVendorSpecific[1] = padLen - 2;
704 padVendorSpecific[2] = 0x00;
705 padVendorSpecific[3] = 0xA0;
706 padVendorSpecific[4] = 0xC6;
707
708 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
709 padLen ));
710
711 /* padding zero if more than 5 bytes are required */
712 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530713 vos_mem_set( pFrame + header_offset + nPayload + MIN_VENDOR_SPECIFIC_IE_SIZE,
714 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800715 }
716#endif
Kiran V1ccee932012-12-12 14:49:46 -0800717
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800718 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 -0800719 SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) ));
720
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800721 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -0800722 HAL_TXRX_FRM_802_11_DATA,
723 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530724 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800725 limTxComplete, pFrame,
726 limMgmtTXComplete,
727 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME);
Kiran V1ccee932012-12-12 14:49:46 -0800728 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
729 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800730 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700731 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -0800732 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -0800733 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800734 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -0800735
736 return eSIR_SUCCESS;
737
738}
739
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800740#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800741/*
742 * Once Discovery response is sent successfully (or failure) on air, now send
743 * response to PE and send del STA to HAL.
744 */
745eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac,
746 tANI_U32 txCompleteSuccess)
747{
748 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800749 tpDphHashNode pStaDs = NULL ;
750 tSirTdlsPeerInfo *peerInfo = 0 ;
751
752 /* find peer by looking into the list by expected state */
753 peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ;
754
755 if(NULL == peerInfo)
756 {
757 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700758 ("DisRspTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800759 VOS_ASSERT(0) ;
760 return eHAL_STATUS_FAILURE;
761 }
762
763 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ;
764
765 if(peerInfo->delStaNeeded)
766 {
767 tpPESession psessionEntry;
768
769 peerInfo->delStaNeeded = false ;
770 psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId);
771
772 if(NULL == psessionEntry)
773 {
774 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700775 ("DisRspTxComplete: sessionID %d is not found"), peerInfo->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800776 return eHAL_STATUS_FAILURE;
777 }
778 /* send del STA to remove context for this TDLS STA */
779 pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ;
780
781 /* now send indication to SME-->HDD->TL to remove STA from TL */
782 if(pStaDs)
783 {
784 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
785 pStaDs, eSIR_SUCCESS) ;
786 }
787 else
788 {
789 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800790 ("DisRspTxComplete: staDs not found for " MAC_ADDRESS_STR),
791 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800792 VOS_ASSERT(0) ;
793 return eHAL_STATUS_FAILURE;
794 }
795 }
796
797 if(!txCompleteSuccess)
798 {
799 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
800 ("TX complete failure for Dis RSP"));
801 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
802 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
803 status = eHAL_STATUS_FAILURE;
804 }
805 else
806 {
807 limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS,
808 eWNI_SME_TDLS_DISCOVERY_START_IND) ;
809 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
810 ("TX complete Success for Dis RSP"));
811 status = eHAL_STATUS_SUCCESS ;
812 }
813 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800814 return status ;
815
816}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800817#endif
818
819#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800820/*
821 * Once setup CNF is sent successfully (or failure) on air, now send
822 * response to PE and send del STA to HAL.
823 */
824eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
825 tANI_U32 txCompleteSuccess)
826{
827 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800828 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
829 /* find peer by looking into the list by expected state */
830 limTdlsFindSetupPeerByState(pMac,
831 TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ;
832
833 if(NULL == peerInfo)
834 {
835 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700836 ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800837 VOS_ASSERT(0) ;
838 return eHAL_STATUS_FAILURE;
839 }
840
841 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
842 (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
843
844 if(!txCompleteSuccess)
845 {
846 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
847 ("TX complete Failure for setup CNF"));
848 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac,
849 eWNI_SME_TDLS_LINK_START_RSP) ;
850 status = eHAL_STATUS_FAILURE;
851 }
852 else
853 {
854 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800855 ("RSP-->SME peer MAC = " MAC_ADDRESS_STR),
856 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800857
858 limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
859 eWNI_SME_TDLS_LINK_START_RSP) ;
860
861 /* tdls_hklee: prepare PTI template and send it to HAL */
862 limTdlsLinkEstablish(pMac, (peerInfo)->peerMac);
863
864 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
865 ("TX complete Success for setup CNF"));
866 status = eHAL_STATUS_SUCCESS ;
867 }
868 //pMac->hal.pCBackFnTxComp = NULL ;
Kiran V1ccee932012-12-12 14:49:46 -0800869 return status ;
Kiran V1ccee932012-12-12 14:49:46 -0800870}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800871#endif
Kiran V1ccee932012-12-12 14:49:46 -0800872
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800873#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -0800874/*
875 * Tx Complete for Teardown frame
876 */
877eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
878 tANI_U32 txCompleteSuccess)
879{
880 eHalStatus status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800881 tpDphHashNode pStaDs = NULL ;
882 tLimTdlsLinkSetupPeer *peerInfo = 0 ;
883 tpPESession psessionEntry = NULL ;
884 //tANI_U16 msgType = 0 ;
885
886 //tSirMacAddr peerMac = {0} ;
887 /* find peer by looking into the list by expected state */
888 limTdlsFindSetupPeerByState(pMac,
889 TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ;
890
891 if(NULL == peerInfo)
892 {
893 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700894 ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event"));
Kiran V1ccee932012-12-12 14:49:46 -0800895 VOS_ASSERT(0) ;
896 return eHAL_STATUS_FAILURE;
897 }
898
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530899 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -0800900 ("teardown peer Mac = " MAC_ADDRESS_STR),
901 MAC_ADDR_ARRAY((peerInfo)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -0800902
903
904 //pMac->hal.pCBackFnTxComp = NULL ;
905
906 psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId);
907
908 if(NULL == psessionEntry)
909 {
910 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700911 ("limTdlsTeardownTxComplete: sessionID %d is not found"), (peerInfo)->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -0800912 VOS_ASSERT(0) ;
913 return eHAL_STATUS_FAILURE;
914 }
915
916 if(!txCompleteSuccess)
917 {
918 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700919 ("TX complete failure for Teardown ")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800920
921 /*
922 * we should be sending Teradown to AP with status code
923 * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if
924 * that is delivered or not, any way we removing this peer STA from our
925 * list
926 */
927 if(NULL != psessionEntry)
928 {
929 limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac,
930 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ;
931 }
932 }
933
934 if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state)
935 {
936 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
937 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
938 /* send del STA to remove context for this TDLS STA */
939 if(NULL != psessionEntry)
940 {
941 /* tdls_hklee: send message to HAL before it is deleted */
942 limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ;
943
944 pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ;
945 }
946
947 /* now send indication to SME-->HDD->TL to remove STA from TL */
948 if(!pStaDs)
949 {
950 VOS_ASSERT(0) ;
951 return eSIR_FAILURE ;
952 }
953 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
954 pStaDs, eSIR_SUCCESS) ;
955
956 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700957 ("TX complete SUCCESS for Teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800958 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700959 ("Prev State = %d"), (peerInfo)->tdls_prev_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -0800960 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
961 eWNI_SME_TDLS_TEARDOWN_RSP) ;
962 /* Delete Peer for Link Peer List */
963 limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ;
964 }
965 else
966 {
967 (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
968 (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ;
969 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
970 eWNI_SME_TDLS_TEARDOWN_IND) ;
971 }
972
973
974#if 0
975 /* if previous state is link restart, then restart link setup again */
976 if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state)
977 {
978 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
979 limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37,
980 peerMac, psessionEntry) ;
981 }
982#endif
983 status = eHAL_STATUS_SUCCESS ;
Kiran V1ccee932012-12-12 14:49:46 -0800984 return status ;
985}
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800986#endif
Kiran V1ccee932012-12-12 14:49:46 -0800987
988/*
Kiet Lam770920c2013-10-21 12:49:30 +0530989 * This static function is consistent with any kind of TDLS management
990 * frames we are sending. Currently it is being used by limSendTdlsDisRspFrame,
991 * limSendTdlsLinkSetupReqFrame and limSendTdlsSetupRspFrame
992 */
993static void PopulateDot11fTdlsHtVhtCap(tpAniSirGlobal pMac, uint32 selfDot11Mode,
994 tDot11fIEHTCaps *htCap, tDot11fIEVHTCaps *vhtCap,
995 tpPESession psessionEntry)
996{
997 if (IS_DOT11_MODE_HT(selfDot11Mode))
998 {
999 /* Include HT Capability IE */
1000 PopulateDot11fHTCaps( pMac, NULL, htCap );
1001 htCap->present = 1;
1002 if (psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END)
1003 {
1004 /* hardcode NO channel bonding in 2.4Ghz */
1005 htCap->supportedChannelWidthSet = 0;
1006 }
1007 else
1008 {
1009 //Placeholder to support different channel bonding mode of TDLS than AP.
1010 //wlan_cfgGetInt(pMac,WNI_CFG_TDLS_CHANNEL_BONDING_MODE,&tdlsChannelBondingMode);
1011 //htCap->supportedChannelWidthSet = tdlsChannelBondingMode ? 1 : 0;
1012 htCap->supportedChannelWidthSet = 1; // hardcode it to max
1013 }
1014 }
1015 else
1016 {
1017 htCap->present = 0;
1018 }
1019#ifdef WLAN_FEATURE_11AC
1020 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
1021 pMac->roam.configParam.enableVhtFor24GHz) ||
1022 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
1023 {
1024 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1025 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1026 {
1027 /* Include VHT Capability IE */
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301028 PopulateDot11fVHTCaps( pMac, vhtCap, eSIR_FALSE );
Kiet Lam770920c2013-10-21 12:49:30 +05301029 }
1030 else
1031 {
1032 vhtCap->present = 0;
1033 }
1034 }
1035 else
1036 {
1037 /* Vht Disable from ini in 2.4 GHz */
1038 vhtCap->present = 0;
1039 }
1040#endif
1041}
1042
1043/*
Kiran V1ccee932012-12-12 14:49:46 -08001044 * Send TDLS discovery response frame on direct link.
1045 */
1046
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05301047static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
1048 tSirMacAddr peerMac, tANI_U8 dialog,
1049 tpPESession psessionEntry, tANI_U8 *addIe,
1050 tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001051{
1052 tDot11fTDLSDisRsp tdlsDisRsp ;
1053 tANI_U16 caps = 0 ;
1054 tANI_U32 status = 0 ;
1055 tANI_U32 nPayload = 0 ;
1056 tANI_U32 nBytes = 0 ;
1057 tANI_U8 *pFrame;
1058 void *pPacket;
1059 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001060 uint32 selfDot11Mode;
1061// Placeholder to support different channel bonding mode of TDLS than AP.
1062// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1063// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1064// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1065// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001066
1067 /*
1068 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1069 * and then hand it off to 'dot11fPackProbeRequest' (for
1070 * serialization). We start by zero-initializing the structure:
1071 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301072 vos_mem_set( ( tANI_U8* )&tdlsDisRsp,
1073 sizeof( tDot11fTDLSDisRsp ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001074
1075 /*
1076 * setup Fixed fields,
1077 */
1078 tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
1079 tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ;
1080 tdlsDisRsp.DialogToken.token = dialog ;
1081
1082 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
1083 peerMac, TDLS_RESPONDER) ;
1084
1085 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1086 {
1087 /*
1088 * Could not get Capabilities value
1089 * from CFG. Log error.
1090 */
1091 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001092 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001093 }
1094 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
1095
1096 /* populate supported rate IE */
1097 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1098 &tdlsDisRsp.SuppRates, psessionEntry );
1099
1100 /* Populate extended supported rates */
1101 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1102 &tdlsDisRsp.ExtSuppRates, psessionEntry );
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05301103 /* Populate RSN Information element */
1104 PopulateDot11fRsnIEs(pMac, &tdlsDisRsp.RSN, addIe, addIeLen);
1105
1106 /* Populate Timeout interval IE */
1107 PopulateDot11fTimeoutIEs(pMac, &tdlsDisRsp.TimeoutInterval,
1108 (&addIe[22]), (addIeLen - 22));
Kiran V1ccee932012-12-12 14:49:46 -08001109
1110 /* Populate extended supported rates */
1111 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
1112
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001113 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1114
Kiet Lam770920c2013-10-21 12:49:30 +05301115 /* Populate HT/VHT Capabilities */
1116 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsDisRsp.HTCaps,
1117 &tdlsDisRsp.VHTCaps, psessionEntry );
Kiran V1ccee932012-12-12 14:49:46 -08001118
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301119 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1120 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1121 &tdlsDisRsp.SuppChannels,
1122 &tdlsDisRsp.SuppOperatingClasses);
Kiran V1ccee932012-12-12 14:49:46 -08001123 /*
1124 * now we pack it. First, how much space are we going to need?
1125 */
1126 status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
1127 if ( DOT11F_FAILED( status ) )
1128 {
1129 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001130 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001131 /* We'll fall back on the worst case scenario: */
1132 nPayload = sizeof( tDot11fProbeRequest );
1133 }
1134 else if ( DOT11F_WARNED( status ) )
1135 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001136 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001137 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001138 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001139 }
1140
1141 /*
1142 * This frame is going out from PE as data frames with special ethertype
1143 * 89-0d.
1144 * 8 bytes of RFC 1042 header
1145 */
1146
1147
1148 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ;
1149
1150 /* Ok-- try to allocate memory from MGMT PKT pool */
1151
1152 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1153 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1154 ( void** ) &pPacket );
1155 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1156 {
1157 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001158 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001159 return eSIR_MEM_ALLOC_FAILED;
1160 }
1161
1162 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301163 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001164
1165 /*
1166 * IE formation, memory allocation is completed, Now form TDLS discovery
1167 * response frame
1168 */
1169
1170 /* Make public Action Frame */
1171
1172#if 0
1173 limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1174 SIR_MAC_MGMT_ACTION,
1175 LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
1176#endif
1177 limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1178 SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
1179
1180 {
1181 tpSirMacMgmtHdr pMacHdr;
1182 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1183 pMacHdr->fc.toDS = ANI_TXDIR_IBSS;
1184 pMacHdr->fc.powerMgmt = 0 ;
1185 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1186 }
1187
1188#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1189 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
1190 {
1191 tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
1192 tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad;
1193 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001194 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Rsp"),
1195 MAC_ADDR_ARRAY(tdlsDisRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001196 }
1197#endif
1198 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
1199 sizeof( tSirMacMgmtHdr ),
1200 nPayload, &nPayload );
1201
1202 if ( DOT11F_FAILED( status ) )
1203 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001204 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1205 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001206 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1207 ( void* ) pFrame, ( void* ) pPacket );
1208 return eSIR_FAILURE;
1209 }
1210 else if ( DOT11F_WARNED( status ) )
1211 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001212 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1213 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001214 }
1215
1216#if 0
1217 if(pMac->hal.pCBackFnTxComp == NULL)
1218 {
1219 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
1220
1221 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
1222 {
1223 status = eHAL_STATUS_FAILURE;
1224 return status;
1225
1226 }
1227 }
1228#endif
1229 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001230 ("transmitting Discovery response on direct link")) ;
Kiran V1ccee932012-12-12 14:49:46 -08001231
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001232 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 -08001233 SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) ));
1234
1235
1236 /*
1237 * Transmit Discovery response and watch if this is delivered to
1238 * peer STA.
1239 */
1240 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1241 HAL_TXRX_FRM_802_11_DATA,
1242 ANI_TXDIR_IBSS,
1243 0,
1244 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001245 limMgmtTXComplete,
Kiran V1ccee932012-12-12 14:49:46 -08001246 HAL_USE_SELF_STA_REQUESTED_MASK );
1247 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1248 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001249 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001250 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001251 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001252 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001253 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001254
1255 return eSIR_SUCCESS;
1256
1257}
1258
1259/*
Kiet Lam770920c2013-10-21 12:49:30 +05301260 * This static function is currently used by limSendTdlsLinkSetupReqFrame and
1261 * limSendTdlsSetupRspFrame to populate the AID if device is 11ac capable.
1262 */
1263static void PopulateDotfTdlsVhtAID(tpAniSirGlobal pMac, uint32 selfDot11Mode,
1264 tSirMacAddr peerMac, tDot11fIEAID *Aid,
1265 tpPESession psessionEntry)
1266{
1267 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
1268 pMac->roam.configParam.enableVhtFor24GHz) ||
1269 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
1270 {
1271 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1272 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1273 {
1274
1275 tANI_U16 aid;
1276 tpDphHashNode pStaDs;
1277
1278 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
1279 if (NULL != pStaDs)
1280 {
1281 Aid->present = 1;
1282 Aid->assocId = aid | LIM_AID_MASK; // set bit 14 and 15 1's
1283 }
1284 else
1285 {
1286 Aid->present = 0;
1287 limLog( pMac, LOGE, FL("pStaDs is NULL for " MAC_ADDRESS_STR ),
1288 MAC_ADDR_ARRAY(peerMac));
1289 }
1290 }
1291 }
1292 else
1293 {
1294 Aid->present = 0;
1295 limLog( pMac, LOGW, FL("Vht not enable from ini for 2.4GHz."));
1296 }
1297}
1298
1299/*
Kiran V1ccee932012-12-12 14:49:46 -08001300 * TDLS setup Request frame on AP link
1301 */
1302
1303tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1304 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301305 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001306{
1307 tDot11fTDLSSetupReq tdlsSetupReq ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301308 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001309 tANI_U32 status = 0 ;
1310 tANI_U32 nPayload = 0 ;
1311 tANI_U32 nBytes = 0 ;
1312 tANI_U32 header_offset = 0 ;
1313 tANI_U8 *pFrame;
1314 void *pPacket;
1315 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001316 uint32 selfDot11Mode;
1317// Placeholder to support different channel bonding mode of TDLS than AP.
1318// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1319// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1320// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1321// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001322
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301323 /*
Kiran V1ccee932012-12-12 14:49:46 -08001324 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1325 * and then hand it off to 'dot11fPackProbeRequest' (for
1326 * serialization). We start by zero-initializing the structure:
1327 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301328 vos_mem_set(( tANI_U8* )&tdlsSetupReq, sizeof( tDot11fTDLSSetupReq ), 0);
Kiran V1ccee932012-12-12 14:49:46 -08001329 tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
1330 tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ;
1331 tdlsSetupReq.DialogToken.token = dialog ;
1332
1333
1334 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
1335 peerMac, TDLS_INITIATOR) ;
1336
1337 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1338 {
1339 /*
1340 * Could not get Capabilities value
1341 * from CFG. Log error.
1342 */
1343 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001344 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001345 }
1346 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1347
1348 /* populate supported rate IE */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301349 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Kiran V1ccee932012-12-12 14:49:46 -08001350 &tdlsSetupReq.SuppRates, psessionEntry );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301351
Kiran V1ccee932012-12-12 14:49:46 -08001352 /* Populate extended supported rates */
1353 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1354 &tdlsSetupReq.ExtSuppRates, psessionEntry );
1355
1356 /* Populate extended supported rates */
1357 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1358
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301359 if ( 1 == pMac->lim.gLimTDLSWmmMode )
1360 {
1361 /* include WMM IE */
1362 PopulateDot11fWMMInfoStation( pMac, &tdlsSetupReq.WMMInfoStation );
1363 }
1364 else
1365 {
1366 /*
1367 * TODO: we need to see if we have to support conditions where we have
1368 * EDCA parameter info element is needed a) if we need different QOS
1369 * parameters for off channel operations or QOS is not supported on
1370 * AP link and we wanted to QOS on direct link.
1371 */
1372 /* Populate QOS info, needed for Peer U-APSD session */
1373 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1374 TDLS doesn't want to depend on AP's capability */
1375 tdlsSetupReq.QOSCapsStation.present = 1;
1376 tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
1377 tdlsSetupReq.QOSCapsStation.qack = 0;
1378 tdlsSetupReq.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1379 tdlsSetupReq.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1380 tdlsSetupReq.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1381 tdlsSetupReq.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1382 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301383
Kiran V1ccee932012-12-12 14:49:46 -08001384 /*
1385 * we will always try to init TDLS link with 11n capabilities
1386 * let TDLS setup response to come, and we will set our caps based
1387 * of peer caps
1388 */
1389
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001390 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1391
Kiet Lam770920c2013-10-21 12:49:30 +05301392 /* Populate HT/VHT Capabilities */
1393 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupReq.HTCaps,
1394 &tdlsSetupReq.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001395
Kiet Lam770920c2013-10-21 12:49:30 +05301396 /* Populate AID */
1397 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1398 &tdlsSetupReq.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001399
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301400 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1401 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1402 &tdlsSetupReq.SuppChannels,
1403 &tdlsSetupReq.SuppOperatingClasses);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301404 /*
Kiran V1ccee932012-12-12 14:49:46 -08001405 * now we pack it. First, how much space are we going to need?
1406 */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301407 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
Kiran V1ccee932012-12-12 14:49:46 -08001408 &nPayload);
1409 if ( DOT11F_FAILED( status ) )
1410 {
1411 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001412 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001413 /* We'll fall back on the worst case scenario: */
1414 nPayload = sizeof( tDot11fProbeRequest );
1415 }
1416 else if ( DOT11F_WARNED( status ) )
1417 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001418 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001419 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001420 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001421 }
1422
1423
1424 /*
1425 * This frame is going out from PE as data frames with special ethertype
1426 * 89-0d.
1427 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301428 */
Kiran V1ccee932012-12-12 14:49:46 -08001429
1430
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301431 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1432 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1433 + sizeof( eth_890d_header )
1434 + PAYLOAD_TYPE_TDLS_SIZE
1435 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001436
1437 /* Ok-- try to allocate memory from MGMT PKT pool */
1438
1439 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301440 ( tANI_U16 )nBytes, ( void** ) &pFrame,
Kiran V1ccee932012-12-12 14:49:46 -08001441 ( void** ) &pPacket );
1442 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1443 {
1444 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001445 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001446 return eSIR_MEM_ALLOC_FAILED;
1447 }
1448
1449 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301450 vos_mem_set( pFrame, nBytes, 0);
Kiran V1ccee932012-12-12 14:49:46 -08001451
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301452 /*
Kiran V1ccee932012-12-12 14:49:46 -08001453 * IE formation, memory allocation is completed, Now form TDLS discovery
1454 * request frame
1455 */
1456
1457 /* fill out the buffer descriptor */
1458
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301459 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301460 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001461
1462#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1463 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
1464 {
1465 tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301466 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1467 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001468 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Req"),
1469 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001470 }
1471#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001472 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1473 __func__, tdlsSetupReq.VHTCaps.supportedChannelWidthSet, tdlsSetupReq.VHTCaps.rxMCSMap,
1474 tdlsSetupReq.VHTCaps.txMCSMap, tdlsSetupReq.VHTCaps.txSupDataRate );
1475
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301476 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001477 + header_offset, nPayload, &nPayload );
1478
1479 if ( DOT11F_FAILED( status ) )
1480 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001481 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1482 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001483 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1484 ( void* ) pFrame, ( void* ) pPacket );
1485 return eSIR_FAILURE;
1486 }
1487 else if ( DOT11F_WARNED( status ) )
1488 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001489 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1490 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001491 }
1492
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301493 //Copy the additional IE.
Kiran V1ccee932012-12-12 14:49:46 -08001494 //TODO : addIe is added at the end of the frame. This means it doesnt
1495 //follow the order. This should be ok, but we should consider changing this
1496 //if there is any IOT issue.
1497 if( addIeLen != 0 )
1498 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001499 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),
Kiran V1ccee932012-12-12 14:49:46 -08001500 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301501 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001502 }
1503
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001504 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 -08001505 SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) ));
1506
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001507 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001508 HAL_TXRX_FRM_802_11_DATA,
1509 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301510 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001511 limTxComplete, pFrame,
1512 limMgmtTXComplete,
1513 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
1514
Kiran V1ccee932012-12-12 14:49:46 -08001515 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1516 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001517 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001518 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001519 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001520 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001521 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001522
1523 return eSIR_SUCCESS;
1524
1525}
1526/*
1527 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1528 */
1529
1530tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08001531 tSirMacAddr peerMac, tANI_U16 reason, tANI_U8 responder, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301532 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001533{
1534 tDot11fTDLSTeardown teardown ;
1535 tANI_U32 status = 0 ;
1536 tANI_U32 nPayload = 0 ;
1537 tANI_U32 nBytes = 0 ;
1538 tANI_U32 header_offset = 0 ;
1539 tANI_U8 *pFrame;
1540 void *pPacket;
1541 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001542#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1543 tANI_U32 padLen = 0;
1544#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301545 /*
Kiran V1ccee932012-12-12 14:49:46 -08001546 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1547 * and then hand it off to 'dot11fPackProbeRequest' (for
1548 * serialization). We start by zero-initializing the structure:
1549 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301550 vos_mem_set( ( tANI_U8* )&teardown, sizeof( tDot11fTDLSTeardown ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001551 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1552 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1553 teardown.Reason.code = reason ;
1554
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301555 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
Hoonki Leea34dd892013-02-05 22:56:02 -08001556 peerMac, (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR) ;
Kiran V1ccee932012-12-12 14:49:46 -08001557
1558
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301559 /*
Kiran V1ccee932012-12-12 14:49:46 -08001560 * now we pack it. First, how much space are we going to need?
1561 */
1562 status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
1563 if ( DOT11F_FAILED( status ) )
1564 {
1565 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001566 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001567 /* We'll fall back on the worst case scenario: */
1568 nPayload = sizeof( tDot11fProbeRequest );
1569 }
1570 else if ( DOT11F_WARNED( status ) )
1571 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001572 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001573 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001574 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001575 }
1576
1577
1578 /*
1579 * This frame is going out from PE as data frames with special ethertype
1580 * 89-0d.
1581 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301582 */
Kiran V1ccee932012-12-12 14:49:46 -08001583
1584
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301585 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1586 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1587 + sizeof( eth_890d_header )
1588 + PAYLOAD_TYPE_TDLS_SIZE
1589 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001590
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001591#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1592 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1593 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1594 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1595 */
1596 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1597 {
1598 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1599
1600 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1601 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1602 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1603
1604 nBytes += padLen;
1605 }
1606#endif
1607
Kiran V1ccee932012-12-12 14:49:46 -08001608 /* Ok-- try to allocate memory from MGMT PKT pool */
1609
1610 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1611 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1612 ( void** ) &pPacket );
1613 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1614 {
1615 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001616 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001617 return eSIR_MEM_ALLOC_FAILED;
1618 }
1619
1620 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301621 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001622
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301623 /*
Kiran V1ccee932012-12-12 14:49:46 -08001624 * IE formation, memory allocation is completed, Now form TDLS discovery
1625 * request frame
1626 */
1627
1628 /* fill out the buffer descriptor */
1629
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301630 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1631 LINK_IDEN_ADDR_OFFSET(teardown),
1632 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
Gopichand Nakkala269032c2013-02-07 17:18:15 -08001633 ? TDLS_LINK_AP : TDLS_LINK_DIRECT,
1634 (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301635 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001636
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301637 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001638 + header_offset, nPayload, &nPayload );
1639
1640 if ( DOT11F_FAILED( status ) )
1641 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001642 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req (0x%08x)."),
1643 status );
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301644 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Kiran V1ccee932012-12-12 14:49:46 -08001645 ( void* ) pFrame, ( void* ) pPacket );
1646 return eSIR_FAILURE;
1647 }
1648 else if ( DOT11F_WARNED( status ) )
1649 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001650 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1651 "Teardown Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001652 }
1653#if 0
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301654 if(pMac->hal.pCBackFnTxComp == NULL)
Kiran V1ccee932012-12-12 14:49:46 -08001655 {
1656 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301657 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
Kiran V1ccee932012-12-12 14:49:46 -08001658 {
1659 status = eHAL_STATUS_FAILURE;
1660 return status;
1661
1662 }
1663 }
1664 else
1665 {
1666 VOS_ASSERT(0) ;
1667 return status ;
1668 }
1669#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301670
Kiran V1ccee932012-12-12 14:49:46 -08001671 if( addIeLen != 0 )
1672 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001673 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),
Kiran V1ccee932012-12-12 14:49:46 -08001674 addIeLen ));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301675 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001676 }
1677
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001678#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1679 if (padLen != 0)
1680 {
1681 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
1682 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
1683 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
1684 padVendorSpecific[0] = 221;
1685 padVendorSpecific[1] = padLen - 2;
1686 padVendorSpecific[2] = 0x00;
1687 padVendorSpecific[3] = 0xA0;
1688 padVendorSpecific[4] = 0xC6;
1689
1690 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
1691 padLen ));
1692
1693 /* padding zero if more than 5 bytes are required */
1694 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301695 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
1696 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001697 }
1698#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001699 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL, ("[TDLS] action %d (%s) -%s-> OTA"),
1700 SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN),
1701 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ? "AP": "DIRECT" ));
Kiran V1ccee932012-12-12 14:49:46 -08001702
1703 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1704 HAL_TXRX_FRM_802_11_DATA,
1705 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301706 TID_AC_VI,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301707 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001708 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08001709 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001710 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1711 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001712 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001713 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001714 return eSIR_FAILURE;
1715
1716 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001717 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001718 return eSIR_SUCCESS;
1719
1720}
1721
1722/*
1723 * Send Setup RSP frame on AP link.
1724 */
1725static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1726 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
1727 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1728{
1729 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1730 tANI_U32 status = 0 ;
1731 tANI_U16 caps = 0 ;
1732 tANI_U32 nPayload = 0 ;
1733 tANI_U32 header_offset = 0 ;
1734 tANI_U32 nBytes = 0 ;
1735 tANI_U8 *pFrame;
1736 void *pPacket;
1737 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001738 uint32 selfDot11Mode;
1739// Placeholder to support different channel bonding mode of TDLS than AP.
1740// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1741// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1742// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1743// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001744
1745 /*
1746 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1747 * and then hand it off to 'dot11fPackProbeRequest' (for
1748 * serialization). We start by zero-initializing the structure:
1749 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301750 vos_mem_set( ( tANI_U8* )&tdlsSetupRsp, sizeof( tDot11fTDLSSetupRsp ),0 );
Kiran V1ccee932012-12-12 14:49:46 -08001751
1752 /*
1753 * setup Fixed fields,
1754 */
1755 tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
1756 tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ;
1757 tdlsSetupRsp.DialogToken.token = dialog;
1758
1759 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
1760 peerMac, TDLS_RESPONDER) ;
1761
1762 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1763 {
1764 /*
1765 * Could not get Capabilities value
1766 * from CFG. Log error.
1767 */
1768 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001769 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001770 }
1771 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1772
1773 /* ipopulate supported rate IE */
1774 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1775 &tdlsSetupRsp.SuppRates, psessionEntry );
1776
1777 /* Populate extended supported rates */
1778 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
1779 &tdlsSetupRsp.ExtSuppRates, psessionEntry );
1780
1781 /* Populate extended supported rates */
1782 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1783
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301784 if ( 1 == pMac->lim.gLimTDLSWmmMode )
1785 {
1786 /* include WMM IE */
1787 PopulateDot11fWMMInfoStation( pMac, &tdlsSetupRsp.WMMInfoStation );
1788 }
1789 else
1790 {
1791 /*
1792 * TODO: we need to see if we have to support conditions where we have
1793 * EDCA parameter info element is needed a) if we need different QOS
1794 * parameters for off channel operations or QOS is not supported on
1795 * AP link and we wanted to QOS on direct link.
1796 */
1797 /* Populate QOS info, needed for Peer U-APSD session */
1798 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1799 TDLS doesn't want to depend on AP's capability */
1800 tdlsSetupRsp.QOSCapsStation.present = 1;
1801 tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
1802 tdlsSetupRsp.QOSCapsStation.qack = 0;
1803 tdlsSetupRsp.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1804 tdlsSetupRsp.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1805 tdlsSetupRsp.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1806 tdlsSetupRsp.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1807 }
Kiran V1ccee932012-12-12 14:49:46 -08001808
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001809 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1810
Kiet Lam770920c2013-10-21 12:49:30 +05301811 /* Populate HT/VHT Capabilities */
1812 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupRsp.HTCaps,
1813 &tdlsSetupRsp.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001814
Kiet Lam770920c2013-10-21 12:49:30 +05301815 /* Populate AID */
1816 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1817 &tdlsSetupRsp.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001818
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301819 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1820 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1821 &tdlsSetupRsp.SuppChannels,
1822 &tdlsSetupRsp.SuppOperatingClasses);
1823
Kiran V1ccee932012-12-12 14:49:46 -08001824 tdlsSetupRsp.Status.status = setupStatus ;
1825
1826 /*
1827 * now we pack it. First, how much space are we going to need?
1828 */
1829 status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp,
1830 &nPayload);
1831 if ( DOT11F_FAILED( status ) )
1832 {
1833 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001834 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001835 /* We'll fall back on the worst case scenario: */
1836 nPayload = sizeof( tDot11fProbeRequest );
1837 }
1838 else if ( DOT11F_WARNED( status ) )
1839 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001840 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08001841 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001842 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001843 }
1844
1845 /*
1846 * This frame is going out from PE as data frames with special ethertype
1847 * 89-0d.
1848 * 8 bytes of RFC 1042 header
1849 */
1850
1851
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301852 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1853 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1854 + sizeof( eth_890d_header )
1855 + PAYLOAD_TYPE_TDLS_SIZE
1856 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001857
1858 /* Ok-- try to allocate memory from MGMT PKT pool */
1859
1860 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1861 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1862 ( void** ) &pPacket );
1863 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1864 {
1865 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001866 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08001867 return eSIR_MEM_ALLOC_FAILED;
1868 }
1869
1870 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301871 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001872
1873 /*
1874 * IE formation, memory allocation is completed, Now form TDLS discovery
1875 * request frame
1876 */
1877
1878 /* fill out the buffer descriptor */
1879
1880 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1881 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp),
1882 TDLS_LINK_AP, TDLS_RESPONDER,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301883 TID_AC_BK, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001884
1885#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1886 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
1887 {
1888 tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
1889 tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad;
1890 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001891 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Rsp"),
1892 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001893 }
1894#endif
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001895 limLog( pMac, LOGW, FL("%s: SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1896 __func__, tdlsSetupRsp.VHTCaps.supportedChannelWidthSet, tdlsSetupRsp.VHTCaps.rxMCSMap,
1897 tdlsSetupRsp.VHTCaps.txMCSMap, tdlsSetupRsp.VHTCaps.txSupDataRate );
Kiran V1ccee932012-12-12 14:49:46 -08001898 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1899 + header_offset, nPayload, &nPayload );
1900
1901 if ( DOT11F_FAILED( status ) )
1902 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001903 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
1904 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001905 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1906 ( void* ) pFrame, ( void* ) pPacket );
1907 return eSIR_FAILURE;
1908 }
1909 else if ( DOT11F_WARNED( status ) )
1910 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001911 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
1912 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08001913 }
1914
1915 //Copy the additional IE.
1916 //TODO : addIe is added at the end of the frame. This means it doesnt
1917 //follow the order. This should be ok, but we should consider changing this
1918 //if there is any IOT issue.
1919 if( addIeLen != 0 )
1920 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301921 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001922 }
1923
Hoonki Lee1090c6a2013-01-16 17:40:54 -08001924 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 -08001925 SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) ));
1926
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001927 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001928 HAL_TXRX_FRM_802_11_DATA,
1929 ANI_TXDIR_TODS,
1930 //ANI_TXDIR_IBSS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301931 TID_AC_BK,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001932 limTxComplete, pFrame,
1933 limMgmtTXComplete,
1934 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08001935 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1936 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001937 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001938 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08001939 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001940 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001941 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001942
1943 return eSIR_SUCCESS;
1944
1945}
1946
1947/*
1948 * Send TDLS setup CNF frame on AP link
1949 */
1950
1951tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301952 tANI_U8 dialog, tANI_U32 peerCapability, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001953{
1954 tDot11fTDLSSetupCnf tdlsSetupCnf ;
1955 tANI_U32 status = 0 ;
1956 tANI_U32 nPayload = 0 ;
1957 tANI_U32 nBytes = 0 ;
1958 tANI_U32 header_offset = 0 ;
1959 tANI_U8 *pFrame;
1960 void *pPacket;
1961 eHalStatus halstatus;
Hoonki Lee426f0302013-02-08 17:35:38 -08001962#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1963 tANI_U32 padLen = 0;
1964#endif
Kiran V1ccee932012-12-12 14:49:46 -08001965
1966 /*
1967 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1968 * and then hand it off to 'dot11fPackProbeRequest' (for
1969 * serialization). We start by zero-initializing the structure:
1970 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301971 vos_mem_set( ( tANI_U8* )&tdlsSetupCnf, sizeof( tDot11fTDLSSetupCnf ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001972
1973 /*
1974 * setup Fixed fields,
1975 */
1976 tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
1977 tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ;
1978 tdlsSetupCnf.DialogToken.token = dialog ;
1979
1980#if 1
1981 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
1982 peerMac, TDLS_INITIATOR) ;
1983#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301984 vos_mem_copy( (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier,
1985 (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ;
Kiran V1ccee932012-12-12 14:49:46 -08001986#endif
1987
1988 /*
1989 * TODO: we need to see if we have to support conditions where we have
1990 * EDCA parameter info element is needed a) if we need different QOS
1991 * parameters for off channel operations or QOS is not supported on
1992 * AP link and we wanted to QOS on direct link.
1993 */
1994
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301995 /* Check self and peer WMM capable */
1996 if ((1 == pMac->lim.gLimTDLSWmmMode) && (CHECK_BIT(peerCapability, TDLS_PEER_WMM_CAP)))
1997 {
1998 PopulateDot11fWMMParams(pMac, &tdlsSetupCnf.WMMParams, psessionEntry);
1999 }
2000
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302001 /* Check peer is VHT capable*/
2002 if (CHECK_BIT(peerCapability, TDLS_PEER_VHT_CAP))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002003 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302004 PopulateDot11fVHTOperation( pMac, &tdlsSetupCnf.VHTOperation);
2005 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002006 }
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302007 else if (CHECK_BIT(peerCapability, TDLS_PEER_HT_CAP)) /* Check peer is HT capable */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002008 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05302009 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002010 }
Kiran V1ccee932012-12-12 14:49:46 -08002011
2012 /*
2013 * now we pack it. First, how much space are we going to need?
2014 */
2015 status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf,
2016 &nPayload);
2017 if ( DOT11F_FAILED( status ) )
2018 {
2019 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002020 "or a discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08002021 /* We'll fall back on the worst case scenario: */
2022 nPayload = sizeof( tDot11fProbeRequest );
2023 }
2024 else if ( DOT11F_WARNED( status ) )
2025 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002026 limLog( pMac, LOGW, FL("There were warnings while calculating "
Kiran V1ccee932012-12-12 14:49:46 -08002027 "the packed size for a discovery Request ("
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002028 "0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08002029 }
2030
2031 /*
2032 * This frame is going out from PE as data frames with special ethertype
2033 * 89-0d.
2034 * 8 bytes of RFC 1042 header
2035 */
2036
2037
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302038 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
2039 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
2040 + sizeof( eth_890d_header )
2041 + PAYLOAD_TYPE_TDLS_SIZE
2042 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08002043
Hoonki Lee426f0302013-02-08 17:35:38 -08002044#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2045 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
2046 Hence AP itself padding some bytes, which caused teardown packet is dropped at
2047 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
2048 */
2049 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
2050 {
2051 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
2052
2053 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
2054 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
2055 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
2056
2057 nBytes += padLen;
2058 }
2059#endif
2060
2061
Kiran V1ccee932012-12-12 14:49:46 -08002062 /* Ok-- try to allocate memory from MGMT PKT pool */
2063
2064 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2065 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2066 ( void** ) &pPacket );
2067 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2068 {
2069 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002070 "Discovery Request."), nBytes );
Kiran V1ccee932012-12-12 14:49:46 -08002071 return eSIR_MEM_ALLOC_FAILED;
2072 }
2073
2074 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302075 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08002076
2077 /*
2078 * IE formation, memory allocation is completed, Now form TDLS discovery
2079 * request frame
2080 */
2081
2082 /* fill out the buffer descriptor */
2083
2084 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
2085 LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302086 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08002087
2088#ifdef FEATURE_WLAN_TDLS_NEGATIVE
2089 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
2090 tdlsSetupCnf.StatusCode.statusCode = 37;
2091 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002092 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf"));
Kiran V1ccee932012-12-12 14:49:46 -08002093 }
2094#endif
2095 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
2096 + header_offset, nPayload, &nPayload );
2097
2098 if ( DOT11F_FAILED( status ) )
2099 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002100 limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req "
2101 "(0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08002102 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2103 ( void* ) pFrame, ( void* ) pPacket );
2104 return eSIR_FAILURE;
2105 }
2106 else if ( DOT11F_WARNED( status ) )
2107 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002108 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
2109 "Discovery Request (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08002110 }
2111#if 0
2112 if(pMac->hal.pCBackFnTxComp == NULL)
2113 {
2114 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
2115 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
2116 {
2117 status = eHAL_STATUS_FAILURE;
2118 return status;
2119
2120 }
2121 }
2122 else
2123 {
2124 VOS_ASSERT(0) ;
2125 return status ;
2126 }
2127#endif
2128 //Copy the additional IE.
2129 //TODO : addIe is added at the end of the frame. This means it doesnt
2130 //follow the order. This should be ok, but we should consider changing this
2131 //if there is any IOT issue.
2132 if( addIeLen != 0 )
2133 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302134 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08002135 }
2136
Hoonki Lee426f0302013-02-08 17:35:38 -08002137#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2138 if (padLen != 0)
2139 {
2140 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
2141 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
2142 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
2143 padVendorSpecific[0] = 221;
2144 padVendorSpecific[1] = padLen - 2;
2145 padVendorSpecific[2] = 0x00;
2146 padVendorSpecific[3] = 0xA0;
2147 padVendorSpecific[4] = 0xC6;
2148
2149 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, ("Padding Vendor Specific Ie Len = %d"),
2150 padLen ));
2151
2152 /* padding zero if more than 5 bytes are required */
2153 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302154 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
2155 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee426f0302013-02-08 17:35:38 -08002156 }
2157#endif
2158
2159
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002160 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 -08002161 SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) ));
2162
2163 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
2164 HAL_TXRX_FRM_802_11_DATA,
2165 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302166 TID_AC_VI,
Kiran V1ccee932012-12-12 14:49:46 -08002167 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002168 limMgmtTXComplete,
Gopichand Nakkalad75b1532013-02-15 13:33:42 -08002169 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME );
Kiran V1ccee932012-12-12 14:49:46 -08002170
2171
2172 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2173 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002174 pMac->lim.mgmtFrameSessionId = 0xff;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002175 limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!" ));
Kiran V1ccee932012-12-12 14:49:46 -08002176 return eSIR_FAILURE;
2177
2178 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002179 pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08002180
2181 return eSIR_SUCCESS;
2182}
2183
2184#ifdef FEATURE_WLAN_TDLS_INTERNAL
2185/*
2186 * Convert HT caps to lim based HT caps
2187 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302188static void limTdlsCovertHTCaps(tpAniSirGlobal pMac,
Kiran V1ccee932012-12-12 14:49:46 -08002189 tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps)
2190{
2191
2192 /* HT Capability Info */
2193 peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ;
2194 peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet =
2195 HTCaps->supportedChannelWidthSet ;
2196 peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ;
2197 peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ;
2198 peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ;
2199 peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ;
2200 peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ;
2201 peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ;
2202 peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA;
2203 peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ;
2204 peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ;
2205 peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ;
2206 peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ;
2207 peerInfo->tdlsPeerHtCaps.lsigTXOPProtection =
2208 HTCaps->lsigTXOPProtection ;
2209
2210 /* HT Capa parameters */
2211 peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ;
2212 peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ;
2213 peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ;
2214
2215 /* Extended HT caps */
2216 peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ;
2217 peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ;
2218 peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302219 vos_mem_copy( peerInfo->supportedMCSSet,
Kiran V1ccee932012-12-12 14:49:46 -08002220 HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
2221
2222 return ;
2223}
2224
2225/*
2226 * update capability info..
2227 */
2228void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo,
2229 tDot11fFfCapabilities *Capabilities)
2230{
2231
2232 capabilityInfo->ess = Capabilities->ess;
2233 capabilityInfo->ibss = Capabilities->ibss;
2234 capabilityInfo->cfPollable = Capabilities->cfPollable;
2235 capabilityInfo->cfPollReq = Capabilities->cfPollReq;
2236 capabilityInfo->privacy = Capabilities->privacy;
2237 capabilityInfo->shortPreamble = Capabilities->shortPreamble;
2238 capabilityInfo->pbcc = Capabilities->pbcc;
2239 capabilityInfo->channelAgility = Capabilities->channelAgility;
2240 capabilityInfo->spectrumMgt = Capabilities->spectrumMgt;
2241 capabilityInfo->qos = Capabilities->qos;
2242 capabilityInfo->shortSlotTime = Capabilities->shortSlotTime;
2243 capabilityInfo->apsd = Capabilities->apsd;
2244 capabilityInfo->rrm = Capabilities->rrm;
2245 capabilityInfo->dsssOfdm = Capabilities->dsssOfdm;
2246 capabilityInfo->immediateBA = Capabilities->immediateBA;
2247
2248 return ;
2249}
2250
2251/*
2252 * update Peer info from the link request frame recieved from Peer..
2253 * in list of STA participating in TDLS link setup
2254 */
2255void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac,
2256 tLimTdlsLinkSetupPeer *setupPeer,
2257 tDot11fTDLSSetupReq *setupReq)
2258{
2259
2260 /* Populate peer info of tdls discovery result */
2261
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302262 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupReq->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002263
2264 if(setupReq->SuppRates.present)
2265 {
2266 ConvertSuppRates( pMac, &setupPeer->supportedRates,
2267 &setupReq->SuppRates );
2268 }
2269
2270 /* update QOS info, needed for Peer U-APSD session */
2271 if(setupReq->QOSCapsStation.present)
2272 {
2273 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2274 &setupReq->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002275 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."),
2276 setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd,
2277 setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd,
2278 setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002279 setupReq->QOSCapsStation.qack));
2280 }
2281
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302282 if (setupReq->ExtSuppRates.present)
Kiran V1ccee932012-12-12 14:49:46 -08002283 {
2284 setupPeer->ExtRatesPresent = 1;
2285 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2286 &setupReq->ExtSuppRates );
2287 }
2288 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302289 if (setupReq->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002290 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302291 vos_mem_copy( &setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002292 &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2293 }
2294 /* Update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302295 if (setupReq->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002296 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302297 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002298 &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
2299 }
2300
2301 return ;
2302}
2303
2304/*
2305 * update peer Info recieved with TDLS setup RSP
2306 */
2307void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac,
2308 tLimTdlsLinkSetupPeer *setupPeer,
2309 tDot11fTDLSSetupRsp *setupRsp)
2310{
2311
2312 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302313 tdlsUpdateCapInfo(&setupPeer->capabilityInfo, &setupRsp->Capabilities) ;
Kiran V1ccee932012-12-12 14:49:46 -08002314
2315 if(setupRsp->SuppRates.present)
2316 {
2317 tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ;
2318 ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates);
2319 }
2320
2321 /* update QOS info, needed for Peer U-APSD session */
2322 if(setupRsp->QOSCapsStation.present)
2323 {
2324 ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps,
2325 &setupRsp->QOSCapsStation) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002326 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."),
2327 setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd,
2328 setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd,
2329 setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack,
Kiran V1ccee932012-12-12 14:49:46 -08002330 setupRsp->QOSCapsStation.qack));
2331 }
2332
2333 if(setupRsp->ExtSuppRates.present)
2334 {
2335 setupPeer->ExtRatesPresent = 1;
2336 ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
2337 &setupRsp->ExtSuppRates );
2338 }
2339 /* update HT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302340 if (setupRsp->HTCaps.present)
Kiran V1ccee932012-12-12 14:49:46 -08002341 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302342 vos_mem_copy(&setupPeer->tdlsPeerHTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002343 &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
2344 }
2345
2346 /* update EXT caps */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302347 if (setupRsp->ExtCap.present)
Kiran V1ccee932012-12-12 14:49:46 -08002348 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302349 vos_mem_copy( &setupPeer->tdlsPeerExtCaps,
Kiran V1ccee932012-12-12 14:49:46 -08002350 &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
2351 }
2352
2353 return ;
2354}
2355#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002356
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302357/* This Function is similar to PopulateDot11fHTCaps, except that the HT Capabilities
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002358 * are considered from the AddStaReq rather from the cfg.dat as in PopulateDot11fHTCaps
2359 */
2360static tSirRetStatus limTdlsPopulateDot11fHTCaps(tpAniSirGlobal pMac, tpPESession psessionEntry,
2361 tSirTdlsAddStaReq *pTdlsAddStaReq, tDot11fIEHTCaps *pDot11f)
2362{
2363 tANI_U32 nCfgValue;
2364 tANI_U8 nCfgValue8;
2365 tSirMacHTParametersInfo *pHTParametersInfo;
2366 union {
2367 tANI_U16 nCfgValue16;
2368 tSirMacHTCapabilityInfo htCapInfo;
2369 tSirMacExtendedHTCapabilityInfo extHtCapInfo;
2370 } uHTCapabilityInfo;
2371
2372 tSirMacTxBFCapabilityInfo *pTxBFCapabilityInfo;
2373 tSirMacASCapabilityInfo *pASCapabilityInfo;
2374
2375 nCfgValue = pTdlsAddStaReq->htCap.capInfo;
2376
2377 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2378
2379 pDot11f->advCodingCap = uHTCapabilityInfo.htCapInfo.advCodingCap;
2380 pDot11f->mimoPowerSave = uHTCapabilityInfo.htCapInfo.mimoPowerSave;
2381 pDot11f->greenField = uHTCapabilityInfo.htCapInfo.greenField;
2382 pDot11f->shortGI20MHz = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
2383 pDot11f->shortGI40MHz = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
2384 pDot11f->txSTBC = uHTCapabilityInfo.htCapInfo.txSTBC;
2385 pDot11f->rxSTBC = uHTCapabilityInfo.htCapInfo.rxSTBC;
2386 pDot11f->delayedBA = uHTCapabilityInfo.htCapInfo.delayedBA;
2387 pDot11f->maximalAMSDUsize = uHTCapabilityInfo.htCapInfo.maximalAMSDUsize;
2388 pDot11f->dsssCckMode40MHz = uHTCapabilityInfo.htCapInfo.dsssCckMode40MHz;
2389 pDot11f->psmp = uHTCapabilityInfo.htCapInfo.psmp;
2390 pDot11f->stbcControlFrame = uHTCapabilityInfo.htCapInfo.stbcControlFrame;
2391 pDot11f->lsigTXOPProtection = uHTCapabilityInfo.htCapInfo.lsigTXOPProtection;
2392
2393 // All sessionized entries will need the check below
2394 if (psessionEntry == NULL) // Only in case of NO session
2395 {
2396 pDot11f->supportedChannelWidthSet = uHTCapabilityInfo.htCapInfo.supportedChannelWidthSet;
2397 }
2398 else
2399 {
2400 pDot11f->supportedChannelWidthSet = psessionEntry->htSupportedChannelWidthSet;
2401 }
2402
2403 /* Ensure that shortGI40MHz is Disabled if supportedChannelWidthSet is
2404 eHT_CHANNEL_WIDTH_20MHZ */
2405 if(pDot11f->supportedChannelWidthSet == eHT_CHANNEL_WIDTH_20MHZ)
2406 {
2407 pDot11f->shortGI40MHz = 0;
2408 }
2409
2410 dot11fLog(pMac, LOG2, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, shortGI20:%d, shortGI40: %d, dsssCck: %d"),
2411 pDot11f->supportedChannelWidthSet, pDot11f->mimoPowerSave, pDot11f->greenField,
2412 pDot11f->shortGI20MHz, pDot11f->shortGI40MHz, pDot11f->dsssCckMode40MHz);
2413
2414 nCfgValue = pTdlsAddStaReq->htCap.ampduParamsInfo;
2415
2416 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2417 pHTParametersInfo = ( tSirMacHTParametersInfo* ) &nCfgValue8;
2418
2419 pDot11f->maxRxAMPDUFactor = pHTParametersInfo->maxRxAMPDUFactor;
2420 pDot11f->mpduDensity = pHTParametersInfo->mpduDensity;
2421 pDot11f->reserved1 = pHTParametersInfo->reserved;
2422
2423 dot11fLog( pMac, LOG2, FL( "AMPDU Param: %x" ), nCfgValue);
2424
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302425 vos_mem_copy( pDot11f->supportedMCSSet, pTdlsAddStaReq->htCap.suppMcsSet,
2426 SIZE_OF_SUPPORTED_MCS_SET);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002427
2428 nCfgValue = pTdlsAddStaReq->htCap.extendedHtCapInfo;
2429
2430 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2431
2432 pDot11f->pco = uHTCapabilityInfo.extHtCapInfo.pco;
2433 pDot11f->transitionTime = uHTCapabilityInfo.extHtCapInfo.transitionTime;
2434 pDot11f->mcsFeedback = uHTCapabilityInfo.extHtCapInfo.mcsFeedback;
2435
2436 nCfgValue = pTdlsAddStaReq->htCap.txBFCapInfo;
2437
2438 pTxBFCapabilityInfo = ( tSirMacTxBFCapabilityInfo* ) &nCfgValue;
2439 pDot11f->txBF = pTxBFCapabilityInfo->txBF;
2440 pDot11f->rxStaggeredSounding = pTxBFCapabilityInfo->rxStaggeredSounding;
2441 pDot11f->txStaggeredSounding = pTxBFCapabilityInfo->txStaggeredSounding;
2442 pDot11f->rxZLF = pTxBFCapabilityInfo->rxZLF;
2443 pDot11f->txZLF = pTxBFCapabilityInfo->txZLF;
2444 pDot11f->implicitTxBF = pTxBFCapabilityInfo->implicitTxBF;
2445 pDot11f->calibration = pTxBFCapabilityInfo->calibration;
2446 pDot11f->explicitCSITxBF = pTxBFCapabilityInfo->explicitCSITxBF;
2447 pDot11f->explicitUncompressedSteeringMatrix = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrix;
2448 pDot11f->explicitBFCSIFeedback = pTxBFCapabilityInfo->explicitBFCSIFeedback;
2449 pDot11f->explicitUncompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrixFeedback;
2450 pDot11f->explicitCompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitCompressedSteeringMatrixFeedback;
2451 pDot11f->csiNumBFAntennae = pTxBFCapabilityInfo->csiNumBFAntennae;
2452 pDot11f->uncompressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->uncompressedSteeringMatrixBFAntennae;
2453 pDot11f->compressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->compressedSteeringMatrixBFAntennae;
2454
2455 nCfgValue = pTdlsAddStaReq->htCap.antennaSelectionInfo;
2456
2457 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2458
2459 pASCapabilityInfo = ( tSirMacASCapabilityInfo* ) &nCfgValue8;
2460 pDot11f->antennaSelection = pASCapabilityInfo->antennaSelection;
2461 pDot11f->explicitCSIFeedbackTx = pASCapabilityInfo->explicitCSIFeedbackTx;
2462 pDot11f->antennaIndicesFeedbackTx = pASCapabilityInfo->antennaIndicesFeedbackTx;
2463 pDot11f->explicitCSIFeedback = pASCapabilityInfo->explicitCSIFeedback;
2464 pDot11f->antennaIndicesFeedback = pASCapabilityInfo->antennaIndicesFeedback;
2465 pDot11f->rxAS = pASCapabilityInfo->rxAS;
2466 pDot11f->txSoundingPPDUs = pASCapabilityInfo->txSoundingPPDUs;
2467
Hoonki Lee66b75f32013-04-16 18:30:07 -07002468 pDot11f->present = pTdlsAddStaReq->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002469
2470 return eSIR_SUCCESS;
2471
2472}
2473
2474tSirRetStatus
2475limTdlsPopulateDot11fVHTCaps(tpAniSirGlobal pMac,
2476 tSirTdlsAddStaReq *pTdlsAddStaReq,
2477 tDot11fIEVHTCaps *pDot11f)
2478{
2479 tANI_U32 nCfgValue=0;
2480 union {
2481 tANI_U32 nCfgValue32;
2482 tSirMacVHTCapabilityInfo vhtCapInfo;
2483 } uVHTCapabilityInfo;
2484 union {
2485 tANI_U16 nCfgValue16;
2486 tSirMacVHTTxSupDataRateInfo vhtTxSupDataRateInfo;
2487 tSirMacVHTRxSupDataRateInfo vhtRxsupDataRateInfo;
2488 } uVHTSupDataRateInfo;
2489
Hoonki Lee66b75f32013-04-16 18:30:07 -07002490 pDot11f->present = pTdlsAddStaReq->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002491
2492 nCfgValue = pTdlsAddStaReq->vhtCap.vhtCapInfo;
2493 uVHTCapabilityInfo.nCfgValue32 = nCfgValue;
2494
2495 pDot11f->maxMPDULen = uVHTCapabilityInfo.vhtCapInfo.maxMPDULen;
2496 pDot11f->supportedChannelWidthSet = uVHTCapabilityInfo.vhtCapInfo.supportedChannelWidthSet;
2497 pDot11f->ldpcCodingCap = uVHTCapabilityInfo.vhtCapInfo.ldpcCodingCap;
2498 pDot11f->shortGI80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI80MHz;
2499 pDot11f->shortGI160and80plus80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI160and80plus80MHz;
2500 pDot11f->txSTBC = uVHTCapabilityInfo.vhtCapInfo.txSTBC;
2501 pDot11f->rxSTBC = uVHTCapabilityInfo.vhtCapInfo.rxSTBC;
2502 pDot11f->suBeamFormerCap = uVHTCapabilityInfo.vhtCapInfo.suBeamFormerCap;
2503 pDot11f->suBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.suBeamformeeCap;
2504 pDot11f->csnofBeamformerAntSup = uVHTCapabilityInfo.vhtCapInfo.csnofBeamformerAntSup;
2505 pDot11f->numSoundingDim = uVHTCapabilityInfo.vhtCapInfo.numSoundingDim;
2506 pDot11f->muBeamformerCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformerCap;
2507 pDot11f->muBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformeeCap;
2508 pDot11f->vhtTXOPPS = uVHTCapabilityInfo.vhtCapInfo.vhtTXOPPS;
2509 pDot11f->htcVHTCap = uVHTCapabilityInfo.vhtCapInfo.htcVHTCap;
2510 pDot11f->maxAMPDULenExp = uVHTCapabilityInfo.vhtCapInfo.maxAMPDULenExp;
2511 pDot11f->vhtLinkAdaptCap = uVHTCapabilityInfo.vhtCapInfo.vhtLinkAdaptCap;
2512 pDot11f->rxAntPattern = uVHTCapabilityInfo.vhtCapInfo.rxAntPattern;
2513 pDot11f->txAntPattern = uVHTCapabilityInfo.vhtCapInfo.txAntPattern;
2514 pDot11f->reserved1= uVHTCapabilityInfo.vhtCapInfo.reserved1;
2515
2516 pDot11f->rxMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.rxMcsMap;
2517
2518 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.rxHighest;
2519 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2520 pDot11f->rxHighSupDataRate = uVHTSupDataRateInfo.vhtRxsupDataRateInfo.rxSupDataRate;
2521
2522 pDot11f->txMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.txMcsMap;
2523
2524 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.txHighest;
2525 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2526 pDot11f->txSupDataRate = uVHTSupDataRateInfo.vhtTxSupDataRateInfo.txSupDataRate;
2527
2528 pDot11f->reserved3= uVHTSupDataRateInfo.vhtTxSupDataRateInfo.reserved;
2529
2530 limLogVHTCap(pMac, pDot11f);
2531
2532 return eSIR_SUCCESS;
2533
2534}
2535
2536static tSirRetStatus
2537limTdlsPopulateMatchingRateSet(tpAniSirGlobal pMac,
2538 tpDphHashNode pStaDs,
2539 tANI_U8 *pSupportedRateSet,
2540 tANI_U8 supporteRatesLength,
2541 tANI_U8* pSupportedMCSSet,
2542 tSirMacPropRateSet *pAniLegRateSet,
2543 tpPESession psessionEntry,
2544 tDot11fIEVHTCaps *pVHTCaps)
2545
2546{
2547 tSirMacRateSet tempRateSet;
2548 tANI_U32 i,j,val,min,isArate;
2549 tSirMacRateSet tempRateSet2;
2550 tANI_U32 phyMode;
2551 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2552 isArate=0;
Leela Venkata Kiran Kumar Reddy Chiralac7a12152014-02-03 11:20:14 -08002553 tempRateSet2.numRates = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002554
2555 // limGetPhyMode(pMac, &phyMode);
2556 limGetPhyMode(pMac, &phyMode, NULL);
2557
2558 // get own rate set
2559 val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2560 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302561 (tANI_U8 *) &tempRateSet.rate,
2562 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002563 {
2564 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002565 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07002566 val = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002567 }
2568 tempRateSet.numRates = val;
2569
2570 if (phyMode == WNI_CFG_PHY_MODE_11G)
2571 {
2572
2573 // get own extended rate set
2574 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2575 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302576 (tANI_U8 *) &tempRateSet2.rate,
2577 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002578 tempRateSet2.numRates = val;
2579 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002580
2581 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2582 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002583 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002584 goto error;
2585 }
2586
2587 /**
2588 * Handling of the rate set IEs is the following:
2589 * - keep only rates that we support and that the station supports
2590 * - sort and the rates into the pSta->rate array
2591 */
2592
2593 // Copy all rates in tempRateSet, there are 12 rates max
2594 for (i = 0; i < tempRateSet2.numRates; i++)
2595 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
2596
2597 tempRateSet.numRates += tempRateSet2.numRates;
2598
2599 /**
2600 * Sort rates in tempRateSet (they are likely to be already sorted)
2601 * put the result in tempRateSet2
2602 */
2603 tempRateSet2.numRates = 0;
2604
2605 for (i = 0;i < tempRateSet.numRates; i++)
2606 {
2607 min = 0;
2608 val = 0xff;
2609
2610 for(j = 0;j < tempRateSet.numRates; j++)
2611 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2612 {
2613 val = tempRateSet.rate[j] & 0x7f;
2614 min = j;
2615 }
2616
2617 tempRateSet2.rate[tempRateSet2.numRates++] = tempRateSet.rate[min];
2618 tempRateSet.rate[min] = 0xff;
2619 }
2620
2621 /**
2622 * Copy received rates in tempRateSet, the parser has ensured
2623 * unicity of the rates so there cannot be more than 12 . Need to Check this
2624 * TODO Sunil.
2625 */
Kaushik, Sushant92e6f872014-05-03 16:35:57 +05302626 if (supporteRatesLength > SIR_MAC_RATESET_EID_MAX)
2627 {
2628 limLog( pMac, LOGW, FL("Supported rates length %d more than "
2629 "the Max limit, reset to Max"),
2630 supporteRatesLength);
2631 supporteRatesLength = SIR_MAC_RATESET_EID_MAX;
2632 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002633 for (i = 0; i < supporteRatesLength; i++)
2634 {
2635 tempRateSet.rate[i] = pSupportedRateSet[i];
2636 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002637 tempRateSet.numRates = supporteRatesLength;
2638
2639 {
2640 tpSirSupportedRates rates = &pStaDs->supportedRates;
2641 tANI_U8 aRateIndex = 0;
2642 tANI_U8 bRateIndex = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302643 vos_mem_set( (tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002644
2645 for (i = 0;i < tempRateSet2.numRates; i++)
2646 {
2647 for (j = 0;j < tempRateSet.numRates; j++)
2648 {
2649 if ((tempRateSet2.rate[i] & 0x7F) ==
2650 (tempRateSet.rate[j] & 0x7F))
2651 {
2652#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2653 if ((bRateIndex > HAL_NUM_11B_RATES) || (aRateIndex > HAL_NUM_11A_RATES))
2654 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002655 limLog(pMac, LOGE, FL("Invalid number of rates (11b->%d, 11a->%d)"),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002656 bRateIndex, aRateIndex);
2657 return eSIR_FAILURE;
2658 }
2659#endif
2660 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2661 {
2662 isArate=1;
2663 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
2664 }
2665 else
2666 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2667 break;
2668 }
2669 }
2670 }
2671 }
2672
2673
2674 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
2675#ifdef FEATURE_WLAN_TDLS
2676 if (pStaDs->mlmStaContext.htCapability)
2677#else
2678 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2679 (pStaDs->mlmStaContext.htCapability))
2680#endif
2681 {
2682 val = SIZE_OF_SUPPORTED_MCS_SET;
2683 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2684 mcsSet,
2685 &val) != eSIR_SUCCESS)
2686 {
2687 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002688 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002689 goto error;
2690 }
2691
2692 for (i=0; i<val; i++)
2693 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2694
2695 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH :"));)
2696 for (i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2697 {
2698 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2699 }
2700 }
2701
2702#ifdef WLAN_FEATURE_11AC
2703 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2704#endif
2705 /**
2706 * Set the erpEnabled bit iff the phy is in G mode and at least
2707 * one A rate is supported
2708 */
2709 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2710 pStaDs->erpEnabled = eHAL_SET;
2711
2712
2713
2714 return eSIR_SUCCESS;
2715
2716 error:
2717
2718 return eSIR_FAILURE;
2719}
2720
2721static int limTdlsSelectCBMode(tDphHashNode *pStaDs, tpPESession psessionEntry)
2722{
2723 tANI_U8 channel = psessionEntry->currentOperChannel;
2724
2725 if ( pStaDs->mlmStaContext.vhtCapability )
2726 {
2727 if ( channel== 36 || channel == 52 || channel == 100 ||
2728 channel == 116 || channel == 149 )
2729 {
2730 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
2731 }
2732 else if ( channel == 40 || channel == 56 || channel == 104 ||
2733 channel == 120 || channel == 153 )
2734 {
2735 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
2736 }
2737 else if ( channel == 44 || channel == 60 || channel == 108 ||
2738 channel == 124 || channel == 157 )
2739 {
2740 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
2741 }
2742 else if ( channel == 48 || channel == 64 || channel == 112 ||
2743 channel == 128 || channel == 161 )
2744 {
2745 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
2746 }
2747 else if ( channel == 165 )
2748 {
2749 return 0;
2750 }
2751 }
2752 else if ( pStaDs->mlmStaContext.htCapability )
2753 {
2754 if ( channel== 40 || channel == 48 || channel == 56 ||
2755 channel == 64 || channel == 104 || channel == 112 ||
2756 channel == 120 || channel == 128 || channel == 136 ||
2757 channel == 144 || channel == 153 || channel == 161 )
2758 {
2759 return 1;
2760 }
2761 else if ( channel== 36 || channel == 44 || channel == 52 ||
2762 channel == 60 || channel == 100 || channel == 108 ||
2763 channel == 116 || channel == 124 || channel == 132 ||
2764 channel == 140 || channel == 149 || channel == 157 )
2765 {
2766 return 2;
2767 }
2768 else if ( channel == 165 )
2769 {
2770 return 0;
2771 }
2772 }
2773 return 0;
2774}
2775
Kiran V1ccee932012-12-12 14:49:46 -08002776/*
2777 * update HASH node entry info
2778 */
2779static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002780 tSirTdlsAddStaReq *pTdlsAddStaReq, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002781{
2782 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
2783 tDot11fIEHTCaps htCap, *htCaps;
Kiet Lam770920c2013-10-21 12:49:30 +05302784 tDot11fIEVHTCaps *pVhtCaps = NULL;
Hoonki Lee99e53782013-02-12 18:07:03 -08002785#ifdef WLAN_FEATURE_11AC
Kiet Lam770920c2013-10-21 12:49:30 +05302786 tDot11fIEVHTCaps vhtCap;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002787 tANI_U8 cbMode;
Hoonki Lee99e53782013-02-12 18:07:03 -08002788#endif
Kiran V1ccee932012-12-12 14:49:46 -08002789 tpDphHashNode pSessStaDs = NULL;
2790 tANI_U16 aid;
2791
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002792 if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_ADD)
2793 {
2794 PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
2795 }
2796 else if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE)
2797 {
2798 limTdlsPopulateDot11fHTCaps(pMac, NULL, pTdlsAddStaReq, &htCap);
2799 }
Kiran V1ccee932012-12-12 14:49:46 -08002800 htCaps = &htCap;
Hoonki Lee99e53782013-02-12 18:07:03 -08002801 if (htCaps->present)
Kiran V1ccee932012-12-12 14:49:46 -08002802 {
2803 pStaDs->mlmStaContext.htCapability = 1 ;
2804 pStaDs->htGreenfield = htCaps->greenField ;
2805 pStaDs->htSupportedChannelWidthSet = htCaps->supportedChannelWidthSet ;
2806 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
2807 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
2808 pStaDs->htAMpduDensity = htCaps->mpduDensity;
2809 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
2810 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
2811 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
2812 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
2813 limFillRxHighestSupportedRate(pMac,
2814 &pStaDs->supportedRates.rxHighestDataRate,
2815 htCaps->supportedMCSSet);
2816 pStaDs->baPolicyFlag = 0xFF;
Kiran V1ccee932012-12-12 14:49:46 -08002817 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
2818 }
2819 else
2820 {
2821 pStaDs->mlmStaContext.htCapability = 0 ;
2822 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
2823 }
Hoonki Lee99e53782013-02-12 18:07:03 -08002824#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002825 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002826 pVhtCaps = &vhtCap;
2827 if (pVhtCaps->present)
2828 {
2829 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302830
2831 if ((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
2832 pMac->roam.configParam.enableVhtFor24GHz)
2833 {
2834 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
2835 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
2836 }
2837 else
2838 {
2839 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
2840 pStaDs->htSupportedChannelWidthSet = eHT_CHANNEL_WIDTH_40MHZ ;
2841 }
2842
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002843 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2844 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2845 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002846 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2847 }
2848 else
2849 {
2850 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002851 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002852 }
2853#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002854 /*Calculate the Secondary Coannel Offset */
2855 cbMode = limTdlsSelectCBMode(pStaDs, psessionEntry);
2856
2857 pStaDs->htSecondaryChannelOffset = cbMode;
2858
2859#ifdef WLAN_FEATURE_11AC
2860 if ( pStaDs->mlmStaContext.vhtCapability )
2861 {
2862 pStaDs->htSecondaryChannelOffset = limGetHTCBState(cbMode);
2863 }
2864#endif
Kiran V1ccee932012-12-12 14:49:46 -08002865
2866 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
2867 &psessionEntry->dph.dphHashTable) ;
2868
2869 /* Lets enable QOS parameter */
2870 pStaDs->qosMode = 1;
2871 pStaDs->wmeEnabled = 1;
2872 pStaDs->lleEnabled = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002873 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2874 */
2875 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002876
2877 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002878
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002879 /* TDLS Dummy AddSTA does not have HTCap,VHTCap,Rates info , is it OK ??
2880 */
2881 limTdlsPopulateMatchingRateSet(pMac, pStaDs, pTdlsAddStaReq->supported_rates,
2882 pTdlsAddStaReq->supported_rates_length,
2883 (tANI_U8 *)pTdlsAddStaReq->htCap.suppMcsSet,
2884 &pStaDs->mlmStaContext.propRateSet,
Kiet Lam770920c2013-10-21 12:49:30 +05302885 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002886
2887 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2888 */
2889 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002890
2891 return ;
2892}
2893
2894#ifdef FEATURE_WLAN_TDLS_INTERNAL
2895/*
2896 * find Peer in setup link list.
2897 */
2898
2899tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2900 tLimTdlsLinkSetupPeer **setupPeer)
2901{
2902 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2903 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2904 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2905
2906 while (linkSetupList != NULL)
2907 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302908 if (vos_mem_compare((tANI_U8 *) peerMac,
2909 (tANI_U8 *) linkSetupList->peerMac,
2910 sizeof(tSirMacAddr)) )
Kiran V1ccee932012-12-12 14:49:46 -08002911 {
2912 checkNode = TDLS_NODE_FOUND ;
2913 *setupPeer = linkSetupList ;
2914 break ;
2915 }
2916 linkSetupList = linkSetupList->next;
2917 }
2918
2919 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ;
2920}
2921
2922/*
2923 * find peer in Discovery list.
2924 * Dicovery list get populated in two instances, a) Recieved responses in reply
2925 * to discovery request b) If discover request is received from TDLS peer STA
2926 */
2927tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
2928{
2929 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2930 tSirTdlsPeerInfo *peerInfo = NULL ;
2931
2932 while (discoveryList != NULL)
2933 {
2934 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2935 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002936 ("Peer in discovery list = " MAC_ADDRESS_STR),
2937 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002938
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302939 if (vos_mem_compare((tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002940 (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) )
2941 {
2942 break ;
2943 }
2944 discoveryList = discoveryList->next;
2945 }
2946
2947 return peerInfo ;
2948}
2949
2950/*
2951 * find peer in Discovery list by looking into peer state.
2952 * Dicovery list get populated in two instances, a) Recieved responses in reply
2953 * to discovery request b) If discover request is received from TDLS peer STA
2954 */
2955static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac,
2956 tANI_U8 state)
2957{
2958 tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
2959 tSirTdlsPeerInfo *peerInfo = NULL ;
2960
2961 while (discoveryList != NULL)
2962 {
2963 peerInfo = &discoveryList->tdlsDisPeerInfo ;
2964 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08002965 ("peerInfo Mac = " MAC_ADDRESS_STR),
2966 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002967
2968 if (peerInfo->tdlsPeerState == state)
2969 {
2970 break ;
2971 }
2972 discoveryList = discoveryList->next;
2973 }
2974
2975 return peerInfo ;
2976}
2977
2978/*
2979 * find peer in Setup list by looking into peer state.
2980 * setup list get populated in two instances, a) Recieved responses in reply
2981 * to setup request b) If discover request is received from TDLS peer STA
2982 */
2983static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state,
2984 tLimTdlsLinkSetupPeer **setupPeer)
2985{
2986
2987 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
2988 tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
2989 tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ;
2990
2991 while (linkSetupList != NULL)
2992 {
2993 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002994 ("peer state = %02x"), (linkSetupList)->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08002995 if((linkSetupList)->tdls_link_state == state)
2996 {
2997 checkNode = TDLS_NODE_FOUND ;
2998 *setupPeer = linkSetupList ;
2999 break ;
3000 }
3001 linkSetupList = (linkSetupList)->next;
3002 }
3003
3004 return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ;
3005}
3006
3007
3008/*
3009 * delete Peer from Setup Link
3010 */
3011void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
3012{
3013 tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
3014 tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ;
3015 tLimTdlsLinkSetupPeer *currentNode = NULL ;
3016 tLimTdlsLinkSetupPeer *prevNode = NULL ;
3017
3018 for(currentNode = *linkSetupList ; currentNode != NULL ;
3019 prevNode = currentNode, currentNode = currentNode->next)
3020 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303021 if (vos_mem_compare( (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003022 (tANI_U8 *) currentNode->peerMac,
3023 sizeof(tSirMacAddr)) )
3024 {
3025 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003026 ("Del Node for Peer = " MAC_ADDRESS_STR),
3027 MAC_ADDR_ARRAY(currentNode->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003028 /* if it's first Node */
3029 if(NULL == prevNode)
3030 {
3031 *linkSetupList = currentNode->next ;
3032 }
3033 else
3034 {
3035 prevNode->next = currentNode->next ;
3036 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303037 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08003038 return ;
3039 }
3040 }
3041
3042 return ;
3043}
3044
3045
3046
3047/*
3048 * TDLS discovery request frame received from TDLS peer STA..
3049 */
3050static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac,
3051 tANI_U8 *pBody, tANI_U32 frmLen )
3052{
3053 tDot11fTDLSDisReq tdlsDisReq = {{0}} ;
3054 tANI_U32 status = 0 ;
3055 tLimDisResultList *tdlsDisResult = NULL ;
3056 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
3057 tSirMacAddr peerMac = {0} ;
3058 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3059 tSirTdlsPeerInfo *peerInfo = NULL ;
3060 tpPESession psessionEntry = NULL ;
3061 tANI_U8 sessionId = 0 ;
3062
3063 status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ;
3064
3065 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003066 ("TDLS dis request dialog = %d"), tdlsDisReq.DialogToken.token);
Kiran V1ccee932012-12-12 14:49:46 -08003067
3068 if ( DOT11F_FAILED( status ) )
3069 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003070 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3071 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003072 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3073 return eSIR_FAILURE;
3074 }
3075 else if ( DOT11F_WARNED( status ) )
3076 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003077 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3078 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003079 status, frmLen );
3080 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3081 }
3082
3083 /*
3084 * find session entry using BSSID in link identifier, not using MAC
3085 * header beacuse, there is cases in TDLS, there may be BSSID will not
3086 * be present in header
3087 */
3088 psessionEntry = peFindSessionByBssid(pMac,
3089 &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ;
3090 if(NULL == psessionEntry)
3091 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003092 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003093 ("no Session entry for TDLS session (bssid "MAC_ADDR_ARRAY")"),
3094 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003095
3096 //VOS_ASSERT(0) ;
3097 return eSIR_FAILURE;
3098 }
3099
3100 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303101 status = vos_mem_compare( &psessionEntry->bssId[0],
Kiran V1ccee932012-12-12 14:49:46 -08003102 &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
3103 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003104 ("lim BSSID "MAC_ADDRESS_STR),
3105 MAC_ADDR_ARRAY( psessionEntry->bssId));
Kiran V1ccee932012-12-12 14:49:46 -08003106
3107 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003108 ("Dis req from BSSID "MAC_ADDRESS_STR),
3109 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003110 if(!status)
3111 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003112 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003113
3114 return eSIR_FAILURE ;
3115 }
3116
3117 /*
3118 * check if this is echo of our transmitted discovery request
3119 * drop it here, TODO: better to drop this in TL.
3120 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303121 status = vos_mem_compare( psessionEntry->selfMacAddr,
Kiran V1ccee932012-12-12 14:49:46 -08003122 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3123 sizeof(tSirMacAddr)) ;
3124 if(status)
3125 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003126 limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003127 return eSIR_FAILURE ;
3128 }
3129
3130 /*
3131 * while processing Discovery request from Peer,
3132 * STA_MAC--> MAC of TDLS discovery initiator
3133 * STA_PEER_MAC--> MAC of TDLS discovery responder.
3134 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303135 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003136 &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
3137 sizeof(tSirMacAddr)) ;
3138 /* TODO, do more validation */
3139
3140 /* see if discovery is already in progress */
3141 peerInfo = limTdlsFindDisPeer(pMac, peerMac) ;
3142
3143 if(NULL == peerInfo)
3144 {
3145 /*
3146 * we are allocating peer info for individual peers found in TDLS
3147 * discovery, we need to keep adding TDLS peers till we have timed
3148 * out. We are freeing this memory at the time we are sending this
3149 * collected peer info to SME.
3150 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303151 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3152 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003153 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003154 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery "
3155 "reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003156 return eSIR_FAILURE ;
3157 }
3158
3159
3160 peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3161 peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ;
3162 peerInfo->dialog = tdlsDisReq.DialogToken.token ;
3163
3164 peerInfo->sessionId = psessionEntry->peSessionId;
3165
3166 /* Populate peer info of tdls discovery result */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303167 vos_mem_copy( peerInfo->peerMac, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08003168
3169 /*
3170 * Now, as per D13, there will not be any Supp rates, ext Supp rates
3171 * info in Discovery request frames, so we are populating this info
3172 * locally to pass it to ADD STA.
3173 */
3174 do
3175 {
3176 tDot11fIESuppRates suppRates = {0} ;
3177 tDot11fIEExtSuppRates extSuppRates = {0} ;
3178 tANI_U16 caps = 0 ;
3179 tDot11fFfCapabilities capsInfo = {0} ;
3180 tDot11fIEHTCaps HTCaps = {0} ;
3181 /* populate supported rate IE */
3182 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3183 &suppRates, psessionEntry );
3184 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3185 &suppRates);
3186 /* Populate extended supported rates */
3187 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3188 &extSuppRates, psessionEntry );
3189
3190 peerInfo->ExtRatesPresent = 1;
3191 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3192 &extSuppRates);
3193
3194 if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
3195 {
3196 /*
3197 * Could not get Capabilities value
3198 * from CFG. Log error.
3199 */
3200 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003201 FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08003202 }
3203 swapBitField16(caps, ( tANI_U16* )&capsInfo );
3204 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303205 tdlsUpdateCapInfo(&peerInfo->capabilityInfo, &capsInfo) ;
Kiran V1ccee932012-12-12 14:49:46 -08003206
3207 PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps );
3208 limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ;
3209
3210 } while (0) ;
3211
3212 /* now add this new found discovery node into tdls discovery list */
3213 tdlsDisResult->next = *disResultList ;
3214 *disResultList = tdlsDisResult ;
3215 pMac->lim.gLimTdlsDisStaCount++ ;
3216
3217 /* See if for this peer already entry in setup Link */
3218 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3219
3220 /*
3221 * if there is no entry for this peer in setup list, we need to
3222 * do add sta for this peer to transmit discovery rsp.
3223 */
3224 if(NULL == setupPeer)
3225 {
3226 /* To start with, send add STA request to HAL */
3227 pMac->lim.gLimAddStaTdls = true ;
3228 peerInfo->delStaNeeded = true ;
3229
3230 if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac,
3231 peerInfo, psessionEntry))
3232 {
3233 VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003234 limLog(pMac, LOGE, "Add STA for dis response is failed ") ;
Kiran V1ccee932012-12-12 14:49:46 -08003235 return eSIR_FAILURE ;
3236 }
3237 } /* use setup link sta ID for discovery rsp */
3238 else
3239 {
3240 peerInfo->delStaNeeded = false ;
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05303241 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog,
3242 psessionEntry, NULL, 0);
Kiran V1ccee932012-12-12 14:49:46 -08003243 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
3244 }
3245
3246 }
3247 else
3248 {
3249 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003250 ("discovery procedure in progress for this peer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003251 }
3252
3253 return eSIR_SUCCESS ;
3254}
3255
3256/* Process TDLS setup Request Frame */
3257
3258static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac,
3259 tANI_U8 *pBody, tANI_U32 frmLen)
3260{
3261
3262 tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ;
3263 tANI_U32 status = 0 ;
3264 tpPESession psessionEntry = NULL ;
3265 tANI_U8 sessionId = 0 ;
3266 tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ;
3267 tANI_U8 previousState = TDLS_LINK_IDLE_STATE ;
3268 /* create node for Link setup */
3269 tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
3270 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3271 tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ;
3272
3273 status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ;
3274
3275 if ( DOT11F_FAILED( status ) )
3276 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003277 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3278 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003279 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3280 return eSIR_FAILURE;
3281 }
3282 else if ( DOT11F_WARNED( status ) )
3283 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003284 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3285 "setup Request frame (0x%08x, %d bytes):"),
3286 status, frmLen );
Kiran V1ccee932012-12-12 14:49:46 -08003287 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3288 }
3289 /*
3290 * find session entry using BSSID in link identifier, not using MAC
3291 * header beacuse, there is cases in TDLS, there may be BSSID will not
3292 * be present in header
3293 */
3294 psessionEntry = peFindSessionByBssid(pMac,
3295 &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ;
3296 if(NULL == psessionEntry)
3297 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003298 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003299 ("no Session entry for TDLS session (bssid "
3300 MAC_ADDRESS_STR")"),
3301 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003302
3303 //VOS_ASSERT(0) ;
3304 return eSIR_FAILURE ;
3305 }
3306 /* TODO: we don;t need this check now, varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303307 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003308 &tdlsSetupReq.LinkIdentifier.bssid[0],
3309 sizeof(tSirMacAddr)) ;
3310
3311 if(!status)
3312 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003313 limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003314
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303315 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
3316 tdlsSetupReq.DialogToken.token, psessionEntry,
3317 TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003318 return eSIR_FAILURE ;
3319 }
3320
3321#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3322 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ)
3323 {
3324 /* simply ignore this setup request packet */
3325 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003326 ("TDLS negative running: ignore TDLS Setup Req packet"));
Kiran V1ccee932012-12-12 14:49:46 -08003327 return eSIR_SUCCESS ;
3328 }
3329 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3330 {
3331 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003332 ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req"));
Kiran V1ccee932012-12-12 14:49:46 -08003333 /* format TDLS discovery request frame and transmit it */
3334 limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry,
3335 NULL, 0) ;
3336 }
3337#endif
3338 /* TODO, do more validation */
3339
3340 if(!limTdlsFindLinkPeer(pMac,
3341 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3342 &tmpSetupPeer))
3343 {
3344 tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3345
3346 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003347 ("Link is already setup with this peer" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003348 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003349 ("state = %d"), tmpSetupPeer->tdls_link_state) ;
Kiran V1ccee932012-12-12 14:49:46 -08003350 //return eSIR_FAILURE ;
3351
3352 if(tmpSetupPeer == NULL)
3353 {
3354 VOS_ASSERT(0) ;
3355 return eSIR_FAILURE ;
3356
3357 }
3358 switch(tmpSetupPeer->tdls_link_state)
3359 {
3360
3361 case TDLS_LINK_SETUP_START_STATE:
3362 {
3363 v_SINT_t macCompare = 0 ;
3364 macCompare= vos_mem_compare2(tmpSetupPeer->peerMac,
3365 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
3366 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003367 ("MAC comparison Rslt = %d"), macCompare ) ;
Kiran V1ccee932012-12-12 14:49:46 -08003368 if(0 > macCompare)
3369 {
3370 /*
3371 * Delete our Setup Request/Peer info and honour Peer
3372 * Setup Request, go ahead and respond for this
3373 */
3374 /* Deactivate the timer */
3375 tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ;
3376#ifdef FEATURE_WLAN_TDLS_NEGATIVE
3377 if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3378 != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
3379#endif
3380 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE,
3381 tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP);
3382
3383 limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ;
3384 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3385 }
3386 else if(0 < macCompare)
3387 {
3388 /*
3389 * Go ahead with current setup as peer is going to
3390 * respond for setup request
3391 */
3392 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
3393 }
3394 else
3395 {
3396 /* same MAC, not possible */
3397 VOS_ASSERT(0) ;
3398 }
3399
3400 break ;
3401 }
3402#if 1
3403 case TDLS_LINK_SETUP_DONE_STATE:
3404 {
3405 tpDphHashNode pStaDs = NULL ;
3406
3407 previousState = TDLS_LINK_SETUP_WAIT_STATE ;
3408 currentState = TDLS_LINK_TEARDOWN_START_STATE ;
3409 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3410 ("link Setup Done state " )) ;
3411 tmpSetupPeer->tdls_prev_link_state = previousState ;
3412 tmpSetupPeer->tdls_link_state = currentState ;
3413 setupPeer = tmpSetupPeer ;
3414#if 0
3415 /* Send Teardown to this Peer and Initiate new TDLS Setup */
3416 limSendTdlsTeardownFrame(pMac,
3417 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3418 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ;
3419#else
3420
3421 /* tdls_hklee: send message to HAL before it is deleted, cause */
3422 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
3423
3424 /* send del STA to remove context for this TDLS STA */
3425 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
3426
3427 /* now send indication to SME-->HDD->TL to remove STA from TL */
3428
3429 if(pStaDs)
3430 {
3431 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
3432 pStaDs, eSIR_SUCCESS) ;
3433
3434 /* send Teardown Ind to SME */
3435 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
3436 eWNI_SME_TDLS_TEARDOWN_IND) ;
3437 /* remove node from setup list */
3438 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3439 }
3440#endif
3441 //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE;
3442 tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
3443 break ;
3444
3445 }
3446 default:
3447 {
3448 VOS_ASSERT(0) ;
3449 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003450 ("link Setup is Recieved in unknown state" )) ;
Kiran V1ccee932012-12-12 14:49:46 -08003451 break ;
3452 }
3453#endif
3454 }
3455 if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE)
3456 return eSIR_FAILURE ;
3457 }
3458
3459 if(currentState != TDLS_LINK_TEARDOWN_START_STATE)
3460 {
3461 /*
3462 * Now we are sure to send discovery response frame to TDLS discovery
3463 * initiator, we don't care, if this request is unicast ro broadcast,
3464 * we simply, send discovery response frame on direct link.
3465 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303466 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
3467 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08003468 {
3469 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003470 ( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08003471 return eSIR_MEM_ALLOC_FAILED;
3472 }
3473
3474 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3475 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3476 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3477 setupPeer->tdls_prev_link_state = previousState ;
3478 setupPeer->tdls_link_state = currentState ;
3479 /* TDLS_sessionize: remember sessionId for future */
3480 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3481 setupPeer->tdls_bIsResponder = 0;
3482
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303483 vos_mem_copy(setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003484 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3485 sizeof(tSirMacAddr)) ;
3486
3487 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003488 ("Setup REQ MAC = " MAC_ADDRESS_STR),
3489 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003490
3491 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3492 pMac->lim.gLimAddStaTdls = true ;
3493
3494 /* To start with, send add STA request to HAL */
3495 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac,
3496 setupPeer, psessionEntry))
3497 {
3498 VOS_ASSERT(0) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303499 vos_mem_free((void **) &setupPeer) ;
Kiran V1ccee932012-12-12 14:49:46 -08003500 return eSIR_FAILURE ;
3501 }
3502
3503 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303504 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003505 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3506
3507 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3508 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3509 (tANI_U32)setupPeer->peerMac,
3510 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3511 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3512
3513 /* update setup peer list */
3514 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
3515 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
3516 }
3517 else
3518 {
3519 setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
3520 //setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
3521 //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
3522 setupPeer->tdls_prev_link_state = previousState ;
3523 setupPeer->tdls_link_state = currentState ;
3524 /* TDLS_sessionize: remember sessionId for future */
3525 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
3526 setupPeer->tdls_bIsResponder = 0;
3527
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303528 vos_mem_copy( setupPeer->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003529 &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
3530 sizeof(tSirMacAddr)) ;
3531
3532 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003533 ("Setup REQ MAC = "MAC_ADDRESS_STR),
3534 MAC_ADDR_ARRAY(setupPeer->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003535
3536 limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
3537 limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303538 tdlsSetupReq.DialogToken.token, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003539 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
3540
3541 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
3542 &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
3543 (tANI_U32)setupPeer->peerMac,
3544 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
3545 SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
3546 }
3547
3548
3549 return eSIR_SUCCESS ;
3550
3551}
3552
3553/*
3554 * TDLS discovery request frame received from TDLS peer STA..
3555 */
3556static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac,
3557 tANI_U8 *pBody, tANI_U32 frmLen )
3558{
3559 tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ;
3560 tANI_U32 status = 0 ;
3561 tSirMacAddr peerMac = {0} ;
3562 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3563 tpPESession psessionEntry = NULL ;
3564 tANI_U8 sessionId = 0 ;
3565
3566 status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ;
3567
3568 if ( DOT11F_FAILED( status ) )
3569 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003570 limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request "
3571 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003572 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3573 return eSIR_FAILURE;
3574 }
3575 else if ( DOT11F_WARNED( status ) )
3576 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003577 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3578 "discovery Request frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003579 status, frmLen );
3580 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3581 }
3582
3583 /*
3584 * find session entry using BSSID in link identifier, not using MAC
3585 * header beacuse, there is cases in TDLS, there may be BSSID will not
3586 * be present in header
3587 */
3588 psessionEntry = peFindSessionByBssid(pMac,
3589 &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ;
3590 if(NULL == psessionEntry)
3591 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003592 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003593 ("no Session entry for TDLS session (bssid "
3594 MAC_ADDRESS_STR")"),
3595 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003596
3597 //VOS_ASSERT(0) ;
3598 return eSIR_FAILURE;
3599 }
3600
3601 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303602 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003603 &tdlsSetupRsp.LinkIdentifier.bssid[0],
3604 sizeof(tSirMacAddr)) ;
3605
3606 if(!status)
3607 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003608 limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003609
3610 VOS_ASSERT(0) ;
3611 return eSIR_FAILURE ;
3612 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303613 vos_mem_copy( peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003614 &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0],
3615 sizeof(tSirMacAddr)) ;
3616
3617 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003618 ("TDLS setup RSP peer = "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003619 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
3620
3621 if(NULL == setupPeer)
3622 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003623 limLog( pMac, LOGE, FL("unknown setup Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003624 return eSIR_FAILURE ;
3625 }
3626
3627 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003628 ("deactivating Setup RSP timer")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003629
3630 /* Deactivate the timer */
3631 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ;
3632
3633 /*
3634 * TDLS Setup RSP is recieved with Failure, Delete this STA entry
3635 * don't respond with TDLS CNF frame.
3636 */
3637 if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status)
3638 {
3639 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
3640 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003641 ("setup RSP with Failure Code")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003642 return eSIR_FAILURE ;
3643 }
3644
3645 /* update Link Info */
3646 limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ;
3647
3648 /* TODO, do more validation */
3649
3650
3651 /*
3652 * Now we are sure to send link setup CNF frame to TDLS link setup
3653 * reponded, now we will create dph hash entry and send add STA to HAL
3654 */
3655
3656 pMac->lim.gLimAddStaTdls = true ;
3657 if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac,
3658 setupPeer, psessionEntry))
3659 {
3660 /* through error */
3661 VOS_ASSERT(0) ;
3662 return eSIR_FAILURE ;
3663 }
3664 /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */
3665
3666
3667 /* send TDLS confim frame to TDLS Peer STA */
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05303668 limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, 0, psessionEntry, NULL, 0) ;
Kiran V1ccee932012-12-12 14:49:46 -08003669
3670 /*
3671 * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and
3672 * wait for Setup CNF transmission on air, once we receive tx complete
3673 * message, we will change the peer state and send message to SME
3674 * callback..
3675 */
3676 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3677 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ;
3678
3679 return eSIR_SUCCESS ;
3680}
3681/*
3682 * TDLS setup CNF frame processing ..
3683 */
3684
3685static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac,
3686 tANI_U8 *pBody, tANI_U32 frmLen)
3687{
3688 tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ;
3689 tANI_U32 status = 0 ;
3690 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3691 tpPESession psessionEntry = NULL ;
3692 tANI_U8 sessionId = 0 ;
3693
3694 status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ;
3695
3696 if ( DOT11F_FAILED( status ) )
3697 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003698 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3699 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003700 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3701 return eSIR_FAILURE;
3702 }
3703 else if ( DOT11F_WARNED( status ) )
3704 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003705 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3706 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003707 status, frmLen );
3708 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3709 }
3710 /*
3711 * find session entry using BSSID in link identifier, not using MAC
3712 * header beacuse, there is cases in TDLS, there may be BSSID will not
3713 * be present in header
3714 */
3715 psessionEntry = peFindSessionByBssid(pMac,
3716 &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ;
3717 if(NULL == psessionEntry)
3718 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003719 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003720 ("no Session entry for TDLS session (bssid "
3721 MAC_ADDRESS_STR")"),
3722 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003723
3724 //VOS_ASSERT(0) ;
3725 return eSIR_FAILURE;
3726 }
3727
3728 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303729 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003730 &tdlsSetupCnf.LinkIdentifier.bssid[0],
3731 sizeof(tSirMacAddr)) ;
3732
3733 if(!status)
3734 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003735 limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003736
3737 VOS_ASSERT(0) ;
3738 return eSIR_FAILURE ;
3739 }
3740 /* TODO, do more validation */
3741 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003742 ("setup Cnf peer MAc = "MAC_ADDRESS_STR),
3743 MAC_ADDR_ARRAY(tdlsSetupCnf.LinkIdentifier.InitStaAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003744
3745 limTdlsFindLinkPeer(pMac,
3746 &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
3747 &setupPeer) ;
3748
3749 if(NULL == setupPeer)
3750 {
3751 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003752 (" unknown setup CNF frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003753 VOS_ASSERT(0) ;
3754 return eSIR_FAILURE ;
3755 }
3756 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003757 ("setup CNF peer MAC = "MAC_ADDRESS_STR),
3758 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003759 /*T match dialog token, before proceeding further */
3760 if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token)
3761 {
3762 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003763 ("setup CNF frame not matching with setup RSP")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003764 VOS_ASSERT(0) ;
3765 return eSIR_FAILURE ;
3766 }
3767
3768 /*
3769 * Now we are sure that, this set CNF is for us, now stop
3770 * the running timer..
3771 */
3772 tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ;
3773
3774 /* change TDLS peer State */
3775 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
3776 (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ;
3777
3778 /* send indication to SME that, new link is setup */
3779 limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ;
3780
3781 /* tdls_hklee: prepare PTI template and send it to HAL */
3782 limTdlsLinkEstablish(pMac, (setupPeer)->peerMac);
3783
3784 return eSIR_SUCCESS ;
3785
3786}
3787
3788/*
3789 * TDLS discovery response frame processing ..
3790 */
3791
3792static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac,
3793 tANI_U8 *pBody, tANI_U32 frmLen,
3794 tANI_S8 rssi, tpPESession psessionEntry)
3795{
3796 tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ;
3797 tANI_U32 status = 0 ;
3798 tLimDisResultList *tdlsDisResult = NULL ;
3799 tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
3800 tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ;
3801
3802 status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ;
3803
3804 if ( DOT11F_FAILED( status ) )
3805 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003806 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3807 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003808 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3809 return eSIR_FAILURE;
3810 }
3811 else if ( DOT11F_WARNED( status ) )
3812 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003813 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3814 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003815 status, frmLen );
3816 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);)
3817 }
3818 /*TODO: match dialog token, before proceeding further */
3819
3820 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303821 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003822 &tdlsDisRsp.LinkIdentifier.bssid[0],
3823 sizeof(tSirMacAddr)) ;
3824
3825 if(!status)
3826 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003827 limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003828 return eSIR_FAILURE ;
3829 }
3830 /* TODO, do more validation */
3831
3832 if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
3833 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003834 limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003835 return eSIR_FAILURE ;
3836 }
3837
3838 pMac->lim.gLimTdlsDisStaCount++ ;
3839
3840 /*
3841 * we are allocating peer info for individual peers found in TDLS
3842 * discovery, we need to keep adding TDLS peers till we have timed
3843 * out. We are freeing this memory at the time we are sending this
3844 * collected peer info to SME.
3845 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303846 tdlsDisResult = vos_mem_malloc(sizeof(tLimDisResultList));
3847 if ( NULL == tdlsDisResult )
Kiran V1ccee932012-12-12 14:49:46 -08003848 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003849 limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003850 return eSIR_FAILURE ;
3851 }
3852
3853 do
3854 {
3855 tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
3856
3857 /* Populate peer info of tdls discovery result */
3858 peerInfo->sessionId = psessionEntry->peSessionId;
3859 /*
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303860 * When we receive DIS RSP from peer MAC,
Kiran V1ccee932012-12-12 14:49:46 -08003861 * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
3862 * will carry our MAC.
3863 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303864 vos_mem_copy( peerInfo->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003865 &tdlsDisRsp.LinkIdentifier.RespStaAddr[0],
3866 sizeof(tSirMacAddr)) ;
3867
3868 /* update RSSI for this TDLS peer STA */
3869 peerInfo->tdlsPeerRssi = rssi ;
3870
3871 /* update Caps Info */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303872 tdlsUpdateCapInfo(&peerInfo->capabilityInfo,
Kiran V1ccee932012-12-12 14:49:46 -08003873 &tdlsDisRsp.Capabilities) ;
3874
3875 /* update Supp rates */
3876 if(tdlsDisRsp.SuppRates.present)
3877 {
3878 ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates,
3879 &tdlsDisRsp.SuppRates );
3880 }
3881
3882 /* update EXT supp rates */
3883 if(tdlsDisRsp.ExtSuppRates.present)
3884 {
3885 peerInfo->ExtRatesPresent = 1;
3886 ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates,
3887 &tdlsDisRsp.ExtSuppRates );
3888 }
3889 /* update HT caps */
3890 if (tdlsDisRsp.HTCaps.present)
3891 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303892 vos_mem_copy( &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps,
Kiran V1ccee932012-12-12 14:49:46 -08003893 sizeof( tDot11fIEHTCaps ) );
3894 }
Kiran V1ccee932012-12-12 14:49:46 -08003895 } while(0) ;
3896
3897 /* now add this new found discovery node into tdls discovery list */
3898 tdlsDisResult->next = *disResultList ;
3899 *disResultList = tdlsDisResult ;
3900
3901 return eSIR_SUCCESS ;
3902}
3903
3904/*
3905 * Process TDLS Teardown request frame from TDLS peer STA
3906 */
3907static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac,
3908 tANI_U8 *pBody, tANI_U32 frmLen )
3909{
3910 tDot11fTDLSTeardown tdlsTeardown = {{0}} ;
3911 tANI_U32 status = 0 ;
3912 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
3913 tpPESession psessionEntry = NULL ;
3914 tANI_U8 sessionId = 0 ;
3915
3916 status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ;
3917
3918 if ( DOT11F_FAILED( status ) )
3919 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003920 limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response "
3921 "frame (0x%08x, %d bytes):"),status, frmLen);
Kiran V1ccee932012-12-12 14:49:46 -08003922 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3923 return eSIR_FAILURE;
3924 }
3925 else if ( DOT11F_WARNED( status ) )
3926 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003927 limLog( pMac, LOGW, FL("There were warnings while unpacking a TDLS "
3928 "discovery Response frame (0x%08x, %d bytes):"),
Kiran V1ccee932012-12-12 14:49:46 -08003929 status, frmLen );
3930 PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
3931 }
3932
3933 /*
3934 * find session entry using BSSID in link identifier, not using MAC
3935 * header beacuse, there is cases in TDLS, there may be BSSID will not
3936 * be present in header
3937 */
3938 psessionEntry = peFindSessionByBssid(pMac,
3939 &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ;
3940 if(NULL == psessionEntry)
3941 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003942 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08003943 ("no Session entry for TDLS session (bssid "
3944 MAC_ADDRESS_STR")"),
3945 MAC_ADDR_ARRAY(tdlsTeardown.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08003946
3947 //VOS_ASSERT(0) ;
3948 return eSIR_FAILURE;
3949 }
3950
3951 /* varify BSSID */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303952 status = vos_mem_compare( psessionEntry->bssId,
Kiran V1ccee932012-12-12 14:49:46 -08003953 &tdlsTeardown.LinkIdentifier.bssid[0],
3954 sizeof(tSirMacAddr)) ;
3955
3956
3957 if(!status)
3958 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003959 limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003960 VOS_ASSERT(0) ;
3961 return eSIR_FAILURE ;
3962 }
3963
3964 limTdlsFindLinkPeer(pMac,
3965 &tdlsTeardown.LinkIdentifier.InitStaAddr[0],
3966 &setupPeer) ;
3967
3968 if(NULL == setupPeer)
3969 {
3970 //ignore
3971 //VOS_ASSERT(0) ;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003972 limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored") );
Kiran V1ccee932012-12-12 14:49:46 -08003973
3974 return eSIR_FAILURE ;
3975 }
3976 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08003977 ("teardown for peer "MAC_ADDRESS_STR),
3978 MAC_ADDR_ARRAY((setupPeer)->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08003979
3980 switch(tdlsTeardown.Reason.code)
3981 {
3982 case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON:
3983 {
3984 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003985 ("teardown with unspecified reason")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003986 break ;
3987 }
3988 case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
3989 {
3990 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003991 (" Teardown from AP, TDLS peer unreachable")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003992 break ;
3993 }
3994 default:
3995 {
3996 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003997 (" unknown teardown")) ;
Kiran V1ccee932012-12-12 14:49:46 -08003998 break ;
3999 }
4000 }
4001
4002 /* change TDLS peer State */
4003 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
4004 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
4005
4006 do
4007 {
4008 tpDphHashNode pStaDs = NULL ;
4009
4010 /* tdls_hklee: send message to HAL before it is deleted, cause */
4011 limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
4012
4013 /* send del STA to remove context for this TDLS STA */
4014 pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
4015
4016 /* now send indication to SME-->HDD->TL to remove STA from TL */
4017
4018 if(pStaDs)
4019 {
4020 limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
4021 pStaDs, eSIR_SUCCESS) ;
4022
4023 /* send Teardown Ind to SME */
4024 limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
4025 eWNI_SME_TDLS_TEARDOWN_IND) ;
4026 /* remove node from setup list */
4027 limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
4028 }
4029
4030 }while(0) ;
4031
4032 return status ;
4033}
4034
4035/*
4036 * Common processing of TDLS action frames recieved
4037 */
4038void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd)
4039{
4040 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd);
4041 tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd))
4042 ? (( sizeof( eth_890d_header ))) :(0)) ;
4043
4044 tANI_U8 category = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ;
4045 tANI_U8 action = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ;
4046 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
4047 tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
4048 //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd);
4049
4050 if(category != SIR_MAC_ACTION_TDLS)
4051 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004052 limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored"), category );
Kiran V1ccee932012-12-12 14:49:46 -08004053 return ;
4054 }
4055
4056 frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004057 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Received TDLS action %d (%s)"),
Kiran V1ccee932012-12-12 14:49:46 -08004058 action, limTraceTdlsActionString(action) ));
4059
4060 switch(action)
4061 {
4062
4063 case SIR_MAC_TDLS_SETUP_REQ:
4064 {
4065 limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ;
4066 break ;
4067 }
4068 case SIR_MAC_TDLS_SETUP_RSP:
4069 {
4070 limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ;
4071 break ;
4072 }
4073 case SIR_MAC_TDLS_SETUP_CNF:
4074 {
4075 limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ;
4076 break ;
4077 }
4078 case SIR_MAC_TDLS_TEARDOWN:
4079 {
4080 limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ;
4081 break ;
4082 }
4083 case SIR_MAC_TDLS_DIS_REQ:
4084 {
4085 limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ;
4086 break ;
4087 }
4088 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
4089 case SIR_MAC_TDLS_CH_SWITCH_REQ:
4090 case SIR_MAC_TDLS_CH_SWITCH_RSP:
4091 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
4092 default:
4093 {
4094 break ;
4095 }
4096 }
4097
4098 return ;
4099}
4100
4101/*
4102 * ADD sta for dis response fame sent on direct link
4103 */
4104static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4105 tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry)
4106{
4107 tpDphHashNode pStaDs = NULL ;
4108 tSirRetStatus status = eSIR_SUCCESS ;
4109 tANI_U16 aid = 0 ;
4110
4111 if(NULL == peerInfo)
4112 {
4113 VOS_ASSERT(0) ;
4114 return status ;
4115
4116 }
4117 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004118 ("ADD STA peer MAC: "MAC_ADDRESS_STR),
4119 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004120
4121
4122 if(NULL != dphLookupHashEntry(pMac, peerMac,
4123 &aid, &psessionEntry->dph.dphHashTable))
4124 {
4125 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004126 (" there is hash entry for this client")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004127 status = eSIR_FAILURE ;
4128 VOS_ASSERT(0) ;
4129 return status ;
4130 }
4131
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004132 aid = limAssignPeerIdx(pMac, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004133
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004134 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4135 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4136
Kiran V1ccee932012-12-12 14:49:46 -08004137 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4138
4139 if (pStaDs)
4140 {
4141 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4142 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4143 }
4144 pStaDs = dphAddHashEntry(pMac, peerMac, aid,
4145 &psessionEntry->dph.dphHashTable) ;
4146
4147 if(NULL == pStaDs)
4148 {
4149 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004150 (" add hash entry failed")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004151 status = eSIR_FAILURE ;
4152 VOS_ASSERT(0) ;
4153 return status;
4154 }
4155 if(eSIR_SUCCESS == status)
4156 {
4157#ifdef TDLS_RATE_DEBUG
4158 tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ;
4159 tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ;
4160 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004161 ("pSta DS [%p] "), pStaDs) ;
Kiran V1ccee932012-12-12 14:49:46 -08004162 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004163 ("peerInfo->tdlsPeerSuppRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004164 (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
4165 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004166 ("peerInfo->tdlsPeerExtRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004167 (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
4168 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004169 ("peerInfo->tdlsPeerPropRates = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004170 (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
4171 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004172 ("peerInfo->mcs = [%p]"),
Kiran V1ccee932012-12-12 14:49:46 -08004173 (tANI_U8 *)peerInfo->supportedMCSSet) ;
4174 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004175 ("num of supp rates = %02x"), suppRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004176 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004177 ("num of ext rates = %01x"), extRates->numRates) ;
Kiran V1ccee932012-12-12 14:49:46 -08004178#endif
4179
4180 /* Populate matching rate set */
4181#ifdef WLAN_FEATURE_11AC
4182 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4183 &peerInfo->tdlsPeerSuppRates,
4184 &peerInfo->tdlsPeerExtRates,
4185 peerInfo->supportedMCSSet,
4186 &pStaDs->mlmStaContext.propRateSet,
4187 psessionEntry, NULL))
4188#else
4189 if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs,
4190 &peerInfo->tdlsPeerSuppRates,
4191 &peerInfo->tdlsPeerExtRates,
4192 peerInfo->supportedMCSSet,
4193 &pStaDs->mlmStaContext.propRateSet,
4194 psessionEntry))
4195#endif
4196 {
4197 VOS_ASSERT(0) ;
4198 }
4199
4200
4201 pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304202 vos_mem_copy( pStaDs->staAddr, peerMac, sizeof(tSirMacAddr)) ;
Kiran V1ccee932012-12-12 14:49:46 -08004203 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004204 ("Add STA for Peer: "MAC_ADDRESS_STR),
4205 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004206
4207
4208 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4209
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004210 status = limAddSta(pMac, pStaDs, false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004211
4212 if(eSIR_SUCCESS != status)
4213 {
4214 /* should not fail */
4215 VOS_ASSERT(0) ;
4216 }
4217 }
4218
4219 return status ;
4220}
4221#endif
4222/*
4223 * Add STA for TDLS setup procedure
4224 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004225static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
4226 tSirTdlsAddStaReq *pAddStaReq,
4227 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08004228{
4229 tpDphHashNode pStaDs = NULL ;
4230 tSirRetStatus status = eSIR_SUCCESS ;
4231 tANI_U16 aid = 0 ;
4232
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004233 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004234 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08004235 if(NULL == pStaDs)
4236 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004237 aid = limAssignPeerIdx(pMac, psessionEntry) ;
4238
4239 if( !aid )
4240 {
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004241 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004242 ("%s: No more free AID for peer " MAC_ADDRESS_STR),
4243 __func__, MAC_ADDR_ARRAY(pAddStaReq->peerMac)) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004244 return eSIR_FAILURE;
4245 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004246
4247 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
4248 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
4249
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004250 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004251 ("limTdlsSetupAddSta: Aid = %d, for peer =" MAC_ADDRESS_STR),
4252 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004253 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
4254
4255 if (pStaDs)
4256 {
4257 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
4258 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
4259 }
4260
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004261 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004262 &psessionEntry->dph.dphHashTable) ;
4263
4264 if(NULL == pStaDs)
4265 {
4266 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004267 (" add hash entry failed")) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004268 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004269 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004270 }
Kiran V1ccee932012-12-12 14:49:46 -08004271 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004272
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004273 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004274
4275 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
4276
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004277 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08004278
4279 if(eSIR_SUCCESS != status)
4280 {
4281 /* should not fail */
4282 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08004283 }
Kiran V1ccee932012-12-12 14:49:46 -08004284 return status ;
4285}
4286
4287/*
4288 * Del STA, after Link is teardown or discovery response sent on direct link
4289 */
4290static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
4291 tpPESession psessionEntry)
4292{
4293 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004294 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08004295 tpDphHashNode pStaDs = NULL ;
4296
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004297 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08004298 &psessionEntry->dph.dphHashTable) ;
4299
4300 if(pStaDs)
4301 {
4302
4303 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004304 ("DEL STA peer MAC: "MAC_ADDRESS_STR),
4305 MAC_ADDR_ARRAY(pStaDs->staAddr));
Kiran V1ccee932012-12-12 14:49:46 -08004306
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004307 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004308 ("limTdlsDelSta: STA type = %x, sta idx = %x"),pStaDs->staType,
Kiran V1ccee932012-12-12 14:49:46 -08004309 pStaDs->staIndex) ;
4310
4311 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08004312#ifdef FEATURE_WLAN_TDLS_INTERNAL
Kiran V1ccee932012-12-12 14:49:46 -08004313 if(eSIR_SUCCESS == status)
4314 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08004315 limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx, psessionEntry) ;
4316 limReleasePeerIdx(pMac, peerIdx, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08004317 }
4318 else
4319 {
4320 VOS_ASSERT(0) ;
4321 }
Hoonki Leef63df0d2013-01-16 19:29:14 -08004322#endif
Kiran V1ccee932012-12-12 14:49:46 -08004323 }
4324
4325 return pStaDs ;
4326}
4327
4328#ifdef FEATURE_WLAN_TDLS_INTERNAL
4329/*
4330* Prepare link establish message for HAL, construct PTI template.
4331*
4332*/
4333static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4334{
4335 tANI_U8 pFrame[64] ;
4336 tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ;
4337 tANI_U32 status = 0 ;
4338 tANI_U32 nPayload = 0 ;
4339 tANI_U32 nBytes = 0 ;
4340 tANI_U32 header_offset = 0 ;
4341 tANI_U16 aid = 0 ;
4342 tDphHashNode *pStaDs = NULL ;
4343 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4344 tpPESession psessionEntry = NULL ;
4345
4346
4347 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4348 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004349 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4350 ("limTdlsLinkEstablish: cannot find peer mac "
4351 "in tdls linksetup list: "MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -08004352 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004353 return eSIR_FAILURE;
4354 }
4355
4356 psessionEntry = peFindSessionBySessionId(pMac,
4357 setupPeer->tdls_sessionId) ;
4358
4359 if(NULL == psessionEntry)
4360 {
4361 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004362 ("limTdlsLinkEstablish: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004363 VOS_ASSERT(0) ;
4364 return eHAL_STATUS_FAILURE;
4365 }
4366
Kiet Lam842dad02014-02-18 18:44:02 -08004367
Kiran V1ccee932012-12-12 14:49:46 -08004368 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
4369 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004370 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4371 ("limTdlsLinkEstablish: cannot find peer mac "
4372 "in tdls linksetup list: "MAC_ADDRESS_STR),
4373 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004374 return eSIR_FAILURE;
4375 }
4376
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304377 vos_mem_set( ( tANI_U8* )&tdlsPtiTemplate,
4378 sizeof( tDot11fTDLSPeerTrafficInd ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004379
4380 /*
4381 * setup Fixed fields,
4382 */
4383 tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS;
4384 tdlsPtiTemplate.Action.action = SIR_MAC_TDLS_PEER_TRAFFIC_IND;
4385 tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */
4386#if 1
4387 /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address,
4388 then below code makes such an way */
4389 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4390 peerMac, !setupPeer->tdls_bIsResponder) ;
4391#else
4392 /* below code will make PTI's linkIdentifier's initiator address be selfAddr */
4393 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
4394 peerMac, TDLS_INITIATOR) ;
4395#endif
4396
4397 /* PUBufferStatus will be filled by firmware at the time of transmission */
4398 tdlsPtiTemplate.PUBufferStatus.present = 1;
4399
4400 /* TODO: get ExtendedCapabilities IE */
4401
4402 /*
4403 * now we pack it. First, how much space are we going to need?
4404 */
4405 status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload);
4406 if ( DOT11F_FAILED( status ) )
4407 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004408 limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004409 /* We'll fall back on the worst case scenario: */
4410 nPayload = sizeof( tdlsPtiTemplate );
4411 }
4412 else if ( DOT11F_WARNED( status ) )
4413 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004414 limLog( pMac, LOGW, FL("There were warnings while calculating the packed size for a PTI template (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004415 }
4416
4417 /*
4418 * This frame is going out from PE as data frames with special ethertype
4419 * 89-0d.
4420 * 8 bytes of RFC 1042 header
4421 */
4422
4423 nBytes = nPayload + sizeof( tSirMacMgmtHdr )
4424 + sizeof( eth_890d_header )
4425 + PAYLOAD_TYPE_TDLS_SIZE ;
4426
4427 if(nBytes > 64) {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004428 limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64."), nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08004429 nBytes = 64;
4430 }
4431 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304432 vos_mem_set( pFrame, sizeof(pFrame), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08004433
4434 /* fill out the buffer descriptor */
4435
4436 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
4437 LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ;
4438
4439 status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame
4440 + header_offset, nPayload, &nPayload );
4441
4442 if ( DOT11F_FAILED( status ) )
4443 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004444 limLog( pMac, LOGE, FL("Failed to pack a PTI template (0x%08x)."),
4445 status );
Kiran V1ccee932012-12-12 14:49:46 -08004446 return eSIR_FAILURE;
4447 }
4448 else if ( DOT11F_WARNED( status ) )
4449 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004450 limLog( pMac, LOGW, FL("There were warnings while packing TDLS "
4451 "Peer Traffic Indication (0x%08x)."), status );
Kiran V1ccee932012-12-12 14:49:46 -08004452 }
4453
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004454 LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("bIsResponder=%d, header_offset=%ld, linkIdenOffset=%d, ptiBufStatusOffset=%d "),
Kiran V1ccee932012-12-12 14:49:46 -08004455 setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET));
4456
4457 limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder,
4458 header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET,
4459 nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps);
4460
4461 return eSIR_SUCCESS;
4462}
4463
4464/*
4465* Prepare link teardown message for HAL from peer_mac
4466*
4467*/
4468static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac)
4469{
4470 tDphHashNode *pStaDs = NULL ;
4471 tANI_U16 aid = 0 ;
4472 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
4473 tpPESession psessionEntry = NULL ;
4474
4475
4476 limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
4477 if(NULL == setupPeer) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004478 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4479 ("limTdlsLinkTeardown: cannot find peer mac "
4480 "in tdls linksetup list: "
4481 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004482 return eSIR_FAILURE;
4483 }
4484
4485 psessionEntry = peFindSessionBySessionId(pMac,
4486 setupPeer->tdls_sessionId) ;
4487
4488 if(NULL == psessionEntry)
4489 {
4490 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004491 ("limTdlsLinkTeardown: sessionID %d is not found"), setupPeer->tdls_sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08004492 VOS_ASSERT(0) ;
4493 return eHAL_STATUS_FAILURE;
4494 }
4495
4496
Kiet Lam842dad02014-02-18 18:44:02 -08004497
Kiran V1ccee932012-12-12 14:49:46 -08004498 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
4499
4500 if(pStaDs == NULL) {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004501 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
4502 ("limTdlsLinkTeardown: cannot find peer mac "
4503 "in hash table: "
4504 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004505 return eSIR_FAILURE;
4506 }
4507
4508 limSendTdlsLinkTeardown(pMac, pStaDs->staIndex);
4509
4510 return eSIR_SUCCESS;
4511}
4512
4513/*
4514 * Prepare Discovery RSP message for SME, collect peerINfo for all the
4515 * peers discovered and delete/clean discovery lists in PE.
4516 */
4517
4518static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac,
4519 tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount)
4520{
4521 tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp);
4522 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4523
4524 /*
4525 * allocate memory for tdls discovery response, allocated memory should
4526 * be alloc_mem = tdlsStaCount * sizeof(peerinfo)
4527 * + siezeof tSirTdlsDisRsp.
4528 */
4529 disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo));
4530
4531 /* now allocate memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304532
4533 disRsp = vos_mem_malloc(disMsgRspSize);
4534 if ( NULL == disRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004535 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304536 limLog(pMac, LOGP, FL("AllocateMemory failed for DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004537 return NULL ;
4538 }
4539
4540 if(disStaCount)
4541 {
4542 tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ;
4543 tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ;
4544
4545 tLimDisResultList *currentNode = tdlsDisRspList ;
4546 while(tdlsDisRspList != NULL)
4547 {
4548
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304549 vos_mem_copy( (tANI_U8 *)peerInfo,
Kiran V1ccee932012-12-12 14:49:46 -08004550 (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo,
4551 sizeof(tSirTdlsPeerInfo));
4552
4553 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08004554 ("Msg Sent to PE, peer MAC: "MAC_ADDRESS_STR),
4555 MAC_ADDR_ARRAY(peerInfo->peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08004556 disStaCount-- ;
4557 peerInfo++ ;
4558 currentNode = tdlsDisRspList ;
4559 tdlsDisRspList = tdlsDisRspList->next ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304560 vos_mem_free(currentNode) ;
Kiran V1ccee932012-12-12 14:49:46 -08004561 /* boundary condition check, may be fatal */
4562 if(((!disStaCount) && (tdlsDisRspList))
4563 || ((!tdlsDisRspList) && disStaCount))
4564 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004565 limLog(pMac, LOG1, FL("mismatch in dis sta count and "
4566 "number of nodes in list")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004567 VOS_ASSERT(0) ;
4568 return NULL ;
4569 }
4570 } /* end of while */
4571
4572 /* All discovery STA processed */
4573 pMac->lim.gLimTdlsDisResultList = NULL ;
4574
4575 } /* end of if dis STA count */
4576
4577 return (disRsp) ;
4578}
4579
4580/* Send Teardown response back to PE */
4581
4582void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4583 tSirMacAddr peerMac, tANI_U16 msgType)
4584{
4585 tSirMsgQ mmhMsg = {0} ;
4586 tSirTdlsTeardownRsp *teardownRspMsg = NULL ;
4587 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4588
4589 mmhMsg.type = msgType ;
4590
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304591 teardownRspMsg = vos_mem_malloc(sizeof(tSirTdlsTeardownRsp));
4592 if ( NULL == teardownRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004593 {
4594 VOS_ASSERT(0) ;
4595 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304596 vos_mem_copy( teardownRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004597 sizeof(tSirMacAddr)) ;
4598 teardownRspMsg->statusCode = statusCode ;
4599 mmhMsg.bodyptr = teardownRspMsg ;
4600 mmhMsg.bodyval = 0;
4601 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4602
4603 return ;
4604
4605}
4606
4607/*
4608 * Send Link start RSP back to SME after link is setup or failed
4609 */
4610void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac,
4611 tSirResultCodes statusCode,
4612 tSirMacAddr peerMac,
4613 tANI_U16 msgType)
4614{
4615 tSirMsgQ mmhMsg = {0} ;
4616 tSirTdlsLinksetupRsp *setupRspMsg = NULL ;
4617 tANI_U8 status = eHAL_STATUS_SUCCESS ;
4618
4619 mmhMsg.type = msgType ;
4620
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304621 setupRspMsg = vos_mem_malloc(sizeof(tSirTdlsLinksetupRsp));
4622 if ( NULL == setupRspMsg )
Kiran V1ccee932012-12-12 14:49:46 -08004623 {
4624 VOS_ASSERT(0) ;
4625 }
4626
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304627 vos_mem_copy( setupRspMsg->peerMac, (tANI_U8 *)peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004628 sizeof(tSirMacAddr)) ;
4629 setupRspMsg->statusCode = statusCode ;
4630 mmhMsg.bodyptr = setupRspMsg ;
4631 mmhMsg.bodyval = 0;
4632 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4633
4634 return ;
4635}
4636
4637/*
4638 * Send TDLS discovery RSP back to SME
4639 */
4640void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
4641 tANI_U16 msgType)
4642{
4643 tSirMsgQ mmhMsg = {0} ;
4644 tSirTdlsDisRsp *tdlsDisRsp = NULL ;
4645
4646 mmhMsg.type = msgType ;
4647
4648 if(eSIR_SME_SUCCESS == statusCode)
4649 {
4650 tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ;
4651
4652 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004653 ("no of TDLS STA discovered: %d"), tdlsStaCount) ;
Kiran V1ccee932012-12-12 14:49:46 -08004654 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
4655
4656 if(tdlsDisRsp)
4657 {
4658 tdlsDisRsp->numDisSta = tdlsStaCount ;
4659 }
4660 else
4661 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004662 limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP"));
Kiran V1ccee932012-12-12 14:49:46 -08004663 VOS_ASSERT(0) ;
4664 return ;
4665 }
4666 /* all Discovery STA is processed */
4667 pMac->lim.gLimTdlsDisStaCount = 0 ;
4668 }
4669 else
4670 {
4671 tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ;
4672 }
4673
4674 tdlsDisRsp->statusCode = statusCode ;
4675 mmhMsg.bodyptr = tdlsDisRsp ;
4676 mmhMsg.bodyval = 0;
4677 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4678
4679 return ;
4680}
4681
4682/*
4683 * Once Link is setup with PEER, send Add STA ind to SME
4684 */
4685static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac,
4686 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4687{
4688 tSirMsgQ mmhMsg = {0} ;
4689 tSirTdlsPeerInd *peerInd = NULL ;
4690 mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304691
4692 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4693 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004694 {
4695 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4696 return eSIR_FAILURE;
4697 }
4698
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304699 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004700 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4701 peerInd->sessionId = sessionId;
4702 peerInd->staId = pStaDs->staIndex ;
4703 peerInd->ucastSig = pStaDs->ucUcastSig ;
4704 peerInd->bcastSig = pStaDs->ucBcastSig ;
4705 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4706
4707 mmhMsg.bodyptr = peerInd ;
4708 mmhMsg.bodyval = 0;
4709 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4710
4711 return eSIR_SUCCESS ;
4712
4713}
4714
4715/*
4716 * Once link is teardown, send Del Peer Ind to SME
4717 */
4718static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac,
4719 tANI_U8 sessionId, tDphHashNode *pStaDs, tANI_U8 status)
4720{
4721 tSirMsgQ mmhMsg = {0} ;
4722 tSirTdlsPeerInd *peerInd = NULL ;
4723 mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304724
4725 peerInd = vos_mem_malloc(sizeof(tSirTdlsPeerInd));
4726 if ( NULL == peerInd )
Kiran V1ccee932012-12-12 14:49:46 -08004727 {
4728 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4729 return eSIR_FAILURE;
4730 }
4731
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304732 vos_mem_copy( peerInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004733 (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
4734 peerInd->sessionId = sessionId;
4735 peerInd->staId = pStaDs->staIndex ;
4736 peerInd->ucastSig = pStaDs->ucUcastSig ;
4737 peerInd->bcastSig = pStaDs->ucBcastSig ;
4738 peerInd->length = sizeof(tSmeIbssPeerInd) ;
4739
4740 mmhMsg.bodyptr = peerInd ;
4741
4742 //peerInd->statusCode = status ;
4743 mmhMsg.bodyval = 0;
4744 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4745 return eSIR_SUCCESS ;
4746
4747}
4748
4749/*
4750 * Send Link setup Ind to SME, This is the case where, link setup is
4751 * initiated by peer STA
4752 */
4753static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac,
4754 tSirMacAddr peerMac, tANI_U8 status)
4755{
4756 tSirMsgQ mmhMsg = {0} ;
4757 tSirTdlsLinkSetupInd *setupInd = NULL ;
4758
4759 mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304760 setupInd = vos_mem_malloc(sizeof(tSirTdlsLinkSetupInd));
4761 if ( NULL == setupInd )
Kiran V1ccee932012-12-12 14:49:46 -08004762 {
4763 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4764 return eSIR_FAILURE;
4765 }
4766
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304767 vos_mem_copy( setupInd->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004768 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4769 setupInd->length = sizeof(tSirTdlsLinkSetupInd);
4770 setupInd->statusCode = status ;
4771 mmhMsg.bodyptr = setupInd ;
4772 mmhMsg.bodyval = 0;
4773 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4774
4775 return eSIR_SUCCESS ;
4776
4777}
4778
4779/*
4780 * Setup RSP timer handler
4781 */
4782void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4783{
4784
4785 tANI_U32 statusCode;
4786 tSirMsgQ msg;
4787 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4788
4789 /* Prepare and post message to LIM Message Queue */
4790
4791 msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT;
4792 msg.bodyptr = NULL ;
4793 msg.bodyval = timerId ;
4794
4795 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4796 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004797 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004798 msg.type, statusCode);
4799 return ;
4800}
4801
4802/*
4803 * Link setup CNF timer
4804 */
4805void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId)
4806{
4807
4808 tANI_U32 statusCode;
4809 tSirMsgQ msg;
4810 tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
4811
4812 // Prepare and post message to LIM Message Queue
4813
4814 msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT;
4815 msg.bodyptr = NULL ;
4816 msg.bodyval = timerId ;
4817
4818 if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
4819 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004820 FL("posting message %X to LIM failed, reason=%d"),
Kiran V1ccee932012-12-12 14:49:46 -08004821 msg.type, statusCode);
4822 return ;
4823}
4824
4825/*
4826 * start TDLS timer
4827 */
4828void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer,
4829 tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg)
4830{
4831 tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4832 ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT
4833 : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ;
4834
4835 void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
4836 ? (limTdlsLinkSetupRspTimerHandler)
4837 : limTdlsLinkSetupCnfTimerHandler ;
4838
4839 /* TODO: Read timer vals from CFG */
4840
4841 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4842 /*
4843 * create TDLS discovery response wait timer and activate it
4844 */
4845 if (tx_timer_create(timer, "TDLS link setup timers", timerFunc,
4846 timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS)
4847 {
4848 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004849 FL("could not create TDLS discovery response wait timer"));
Kiran V1ccee932012-12-12 14:49:46 -08004850 return;
4851 }
4852
4853 //assign appropriate sessionId to the timer object
4854 timer->sessionId = sessionId;
4855
4856 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4857 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4858 if (tx_timer_activate(timer) != TX_SUCCESS)
4859 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004860 limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!"));
Kiran V1ccee932012-12-12 14:49:46 -08004861 return ;
4862 }
4863
4864 return ;
4865
4866}
4867#endif
4868
4869/*
4870 * Once Link is setup with PEER, send Add STA ind to SME
4871 */
4872static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004873 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
4874 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08004875{
4876 tSirMsgQ mmhMsg = {0} ;
4877 tSirTdlsAddStaRsp *addStaRsp = NULL ;
4878 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304879
4880 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
4881 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08004882 {
4883 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
4884 return eSIR_FAILURE;
4885 }
4886
4887 addStaRsp->sessionId = sessionId;
4888 addStaRsp->statusCode = status;
4889 if( pStaDs )
4890 {
4891 addStaRsp->staId = pStaDs->staIndex ;
4892 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
4893 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
4894 }
4895 if( peerMac )
4896 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304897 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08004898 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
4899 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004900 if (updateSta)
4901 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
4902 else
4903 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
4904
Kiran V1ccee932012-12-12 14:49:46 -08004905 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
4906 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
4907
4908 mmhMsg.bodyptr = addStaRsp;
4909 mmhMsg.bodyval = 0;
4910 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4911
4912 return eSIR_SUCCESS ;
4913
4914}
4915/*
4916 * STA RSP received from HAL
4917 */
4918eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
4919 tpPESession psessionEntry)
4920{
4921 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
4922 tANI_U8 status = eSIR_SUCCESS ;
4923 tDphHashNode *pStaDs = NULL ;
4924 tANI_U16 aid = 0 ;
4925
4926 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08004927 VOS_TRACE(VOS_MODULE_ID_PE, TDLS_DEBUG_LOG_LEVEL,
Arif Hussain24bafea2013-11-15 15:10:03 -08004928 ("limTdlsAddStaRsp: staIdx=%d, staMac="MAC_ADDRESS_STR), pAddStaParams->staIdx,
4929 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08004930
4931 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
4932 {
4933 VOS_ASSERT(0) ;
4934 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004935 ("Add sta failed ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004936 status = eSIR_FAILURE;
4937 goto add_sta_error;
4938 }
4939
4940 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
4941 &psessionEntry->dph.dphHashTable);
4942 if(NULL == pStaDs)
4943 {
4944 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004945 ("pStaDs is NULL ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08004946 status = eSIR_FAILURE;
4947 goto add_sta_error;
4948 }
4949
4950 pStaDs->bssId = pAddStaParams->bssIdx;
4951 pStaDs->staIndex = pAddStaParams->staIdx;
4952 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
4953 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
4954 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4955 pStaDs->valid = 1 ;
4956#ifdef FEATURE_WLAN_TDLS_INTERNAL
4957 status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId,
4958 pStaDs, eSIR_SUCCESS ) ;
4959 if(eSIR_FAILURE == status)
4960 {
4961 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004962 ("Peer IND msg to SME failed")) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304963 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004964 return eSIR_FAILURE ;
4965 }
4966
4967 /*
4968 * Now, there is two things a) ADD STA RSP for ADD STA request sent
4969 * after recieving discovery request from Peer.
4970 * now we have to send discovery response, if there is any pending
4971 * discovery equest..
4972 */
4973 do
4974 {
4975 tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac,
4976 pAddStaParams->staMac) ;
4977
4978
4979 if(peerInfo)
4980 {
4981 /*
4982 * send TDLS discovery response frame on direct link, state machine
4983 * is rolling.., once discovery response is get Acked, we will
4984 * send response to SME based on TxComplete callback results
4985 */
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05304986 limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog,
4987 psessionEntry, NULL, 0);
Kiran V1ccee932012-12-12 14:49:46 -08004988 peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
4989 }
4990 } while(0) ;
Kiran V1ccee932012-12-12 14:49:46 -08004991#endif
4992add_sta_error:
4993 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004994 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304995 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08004996 return status ;
4997}
4998
Naresh Jayarambc62ba42014-02-12 21:39:14 +05304999void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
5000 tpPESession psessionEntry,
5001 tDot11fIESuppChannels *suppChannels,
5002 tDot11fIESuppOperatingClasses *suppOperClasses)
5003{
5004 tANI_U32 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5005 tANI_U8 validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5006 tANI_U8 i;
Atul Mittalb849d5a2014-07-29 12:08:39 +05305007 tANI_U8 op_class;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305008 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
5009 validChan, &numChans) != eSIR_SUCCESS)
5010 {
5011 /**
5012 * Could not get Valid channel list from CFG.
5013 * Log error.
5014 */
5015 limLog(pMac, LOGP,
5016 FL("could not retrieve Valid channel list"));
5017 }
5018 suppChannels->num_bands = (tANI_U8) numChans;
5019
5020 for ( i = 0U; i < suppChannels->num_bands; i++)
5021 {
5022 suppChannels->bands[i][0] = validChan[i];
5023 suppChannels->bands[i][1] = 1;
5024 }
5025 suppChannels->present = 1 ;
Atul Mittalb849d5a2014-07-29 12:08:39 +05305026 /*Get present operating class based on current operating channel*/
5027 op_class = limGetOPClassFromChannel(
5028 pMac->scan.countryCodeCurrent,
5029 psessionEntry->currentOperChannel,
5030 psessionEntry->htSecondaryChannelOffset);
5031 if (op_class == 0)
5032 {
5033 PELOGE(limLog(pMac, LOGE, FL("Present Operating class is Wrong!!!"));)
5034 }
5035 else
5036 {
5037 PELOGE(limLog(pMac, LOG1, FL("Present Operating channel=%d offset=%d class=%d"),
5038 psessionEntry->currentOperChannel,
5039 psessionEntry->htSecondaryChannelOffset,
5040 op_class);)
5041 }
5042 suppOperClasses->present = 1;
5043 suppOperClasses->classes[0] = op_class;
5044 /*Fill operating classes from static array*/
5045 suppOperClasses->num_classes = op_classes.num_classes;
5046 for ( i = 0U; i < suppOperClasses->num_classes; i++)
5047 {
5048 suppOperClasses->classes[i+1] = op_classes.classes[i];
5049
5050 }
5051 /*increment for present operating class*/
5052 suppOperClasses->num_classes++;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305053 return ;
5054}
5055
5056
Kiran V1ccee932012-12-12 14:49:46 -08005057/*
5058 * FUNCTION: Populate Link Identifier element IE
5059 *
5060 */
5061
Atul Mittalb849d5a2014-07-29 12:08:39 +05305062
Kiran V1ccee932012-12-12 14:49:46 -08005063void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
5064 tDot11fIELinkIdentifier *linkIden,
5065 tSirMacAddr peerMac, tANI_U8 reqType)
5066{
5067 //tANI_U32 size = sizeof(tSirMacAddr) ;
5068 tANI_U8 *initStaAddr = NULL ;
5069 tANI_U8 *respStaAddr = NULL ;
5070
5071 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
5072 (respStaAddr = linkIden->RespStaAddr))
5073 : ((respStaAddr = linkIden->InitStaAddr ),
5074 (initStaAddr = linkIden->RespStaAddr)) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305075 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08005076 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
5077
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305078 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08005079 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
5080
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305081 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005082 sizeof( tSirMacAddr ));
5083
5084 linkIden->present = 1 ;
5085 return ;
5086
5087}
5088
5089void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
5090 tDot11fIEExtCap *extCapability)
5091{
5092 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305093 extCapability->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305094 extCapability->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
Kiran V1ccee932012-12-12 14:49:46 -08005095 extCapability->TDLSSupport = TDLS_SUPPORT ;
5096 extCapability->TDLSProhibited = TDLS_PROHIBITED ;
5097 extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
5098 extCapability->present = 1 ;
5099 return ;
5100}
5101
5102#ifdef FEATURE_WLAN_TDLS_INTERNAL
5103/*
5104 * Public Action frame common processing
5105 * This Function will be moved/merged to appropriate place
5106 * once other public action frames (particularly 802.11k)
5107 * is in place
5108 */
5109void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd,
5110 tpPESession psessionEntry)
5111{
5112 tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
5113 tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ;
5114 tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ;
5115
5116 limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ;
5117 return ;
5118}
5119
5120eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac,
5121 tLimTdlsLinkSetupInfo *linkSetupInfo,
5122 tANI_U8 dialog, tSirMacAddr peerMac,
5123 tpPESession psessionEntry)
5124{
5125 tLimTdlsLinkSetupPeer *setupPeer = NULL ;
5126
5127 /*
5128 * we allocate the TDLS setup Peer Memory here, we will free'd this
5129 * memory after teardown, if the link is successfully setup or
5130 * free this memory if any timeout is happen in link setup procedure
5131 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305132
5133 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5134 if ( NULL == setupPeer )
Kiran V1ccee932012-12-12 14:49:46 -08005135 {
5136 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005137 FL( "Unable to allocate memory during ADD_STA" ));
Kiran V1ccee932012-12-12 14:49:46 -08005138 VOS_ASSERT(0) ;
5139 return eSIR_MEM_ALLOC_FAILED;
5140 }
5141 setupPeer->dialog = dialog ;
5142 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
5143 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
5144
5145 /* TDLS_sessionize: remember sessionId for future */
5146 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5147 setupPeer->tdls_bIsResponder = 1;
5148
5149 /*
5150 * we only populate peer MAC, so it can assit us to find the
5151 * TDLS peer after response/or after response timeout
5152 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305153 vos_mem_copy(setupPeer->peerMac, peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005154 sizeof(tSirMacAddr)) ;
5155 /* format TDLS discovery request frame and transmit it */
5156 limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ;
5157
5158 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5159 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5160 (tANI_U32)setupPeer->peerMac,
5161 WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5162 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5163 /* update setup peer list */
5164 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5165 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5166
5167 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to
5168 * SME later when TDLS setup cnf TX complete is successful. --> see
5169 * limTdlsSetupCnfTxComplete()
5170 */
5171 return eSIR_SUCCESS ;
5172}
5173#endif
5174
5175/*
5176 * Process Send Mgmt Request from SME and transmit to AP.
5177 */
5178tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
5179 tANI_U32 *pMsgBuf)
5180{
5181 /* get all discovery request parameters */
5182 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
5183 tpPESession psessionEntry;
5184 tANI_U8 sessionId;
5185 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
5186
5187 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005188 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005189
5190 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
5191 == NULL)
5192 {
5193 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005194 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005195 pSendMgmtReq->sessionId);
5196 goto lim_tdls_send_mgmt_error;
5197 }
5198
5199 /* check if we are in proper state to work as TDLS client */
5200 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5201 {
5202 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005203 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005204 psessionEntry->limSystemRole);
5205 goto lim_tdls_send_mgmt_error;
5206 }
5207
5208 /*
5209 * if we are still good, go ahead and check if we are in proper state to
5210 * do TDLS discovery req/rsp/....frames.
5211 */
5212 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5213 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5214 {
5215
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005216 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5217 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005218 goto lim_tdls_send_mgmt_error;
5219 }
5220
5221 switch( pSendMgmtReq->reqType )
5222 {
5223 case SIR_MAC_TDLS_DIS_REQ:
5224 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005225 "Transmit Discovery Request Frame") ;
Kiran V1ccee932012-12-12 14:49:46 -08005226 /* format TDLS discovery request frame and transmit it */
5227 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
5228 psessionEntry) ;
5229 resultCode = eSIR_SME_SUCCESS;
5230 break;
5231 case SIR_MAC_TDLS_DIS_RSP:
5232 {
5233 //Send a response mgmt action frame
5234 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05305235 pSendMgmtReq->dialog, psessionEntry,
5236 &pSendMgmtReq->addIe[0],
5237 (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
Kiran V1ccee932012-12-12 14:49:46 -08005238 resultCode = eSIR_SME_SUCCESS;
5239 }
5240 break;
5241 case SIR_MAC_TDLS_SETUP_REQ:
5242 {
5243 limSendTdlsLinkSetupReqFrame(pMac,
5244 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
5245 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5246 resultCode = eSIR_SME_SUCCESS;
5247 }
5248 break;
5249 case SIR_MAC_TDLS_SETUP_RSP:
5250 {
5251 limSendTdlsSetupRspFrame(pMac,
5252 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
5253 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5254 resultCode = eSIR_SME_SUCCESS;
5255 }
5256 break;
5257 case SIR_MAC_TDLS_SETUP_CNF:
5258 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05305259 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, pSendMgmtReq->peerCapability,
Kiran V1ccee932012-12-12 14:49:46 -08005260 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5261 resultCode = eSIR_SME_SUCCESS;
5262 }
5263 break;
5264 case SIR_MAC_TDLS_TEARDOWN:
5265 {
5266 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08005267 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08005268 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
5269 resultCode = eSIR_SME_SUCCESS;
5270 }
5271 break;
5272 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
5273 {
5274 }
5275 break;
5276 case SIR_MAC_TDLS_CH_SWITCH_REQ:
5277 {
5278 }
5279 break;
5280 case SIR_MAC_TDLS_CH_SWITCH_RSP:
5281 {
5282 }
5283 break;
5284 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
5285 {
5286 }
5287 break;
5288 default:
5289 break;
5290 }
5291
5292lim_tdls_send_mgmt_error:
5293
5294 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
5295 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
5296
5297 return eSIR_SUCCESS;
5298}
5299
5300/*
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305301 * Send Response to Link Establish Request to SME
5302 */
5303void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
5304 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5305 tANI_U8 status)
5306{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305307 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305308
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305309 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305310
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305311 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
5312 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305313 {
5314 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305315 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305316 }
5317 pTdlsLinkEstablishReqRsp->statusCode = status ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305318 if ( peerMac )
5319 {
5320 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
5321 }
5322 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305323 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305324 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305325 mmhMsg.bodyval = 0;
5326 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5327 return ;
5328
5329
5330}
5331
5332/*
Atul Mittal60bd4292014-08-14 12:19:27 +05305333 * Send Response to Chan Switch Request to SME
5334 */
5335void limSendSmeTdlsChanSwitchReqRsp(tpAniSirGlobal pMac,
5336 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5337 tANI_U8 status)
5338{
5339 tSirMsgQ mmhMsg = {0} ;
5340
5341 tSirTdlsChanSwitchReqRsp *pTdlsChanSwitchReqRsp = NULL ;
5342
5343 pTdlsChanSwitchReqRsp = vos_mem_malloc(sizeof(tSirTdlsChanSwitchReqRsp));
5344 if ( NULL == pTdlsChanSwitchReqRsp )
5345 {
5346 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
5347 return ;
5348 }
5349 pTdlsChanSwitchReqRsp->statusCode = status ;
5350 if ( peerMac )
5351 {
5352 vos_mem_copy(pTdlsChanSwitchReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
5353 }
5354 pTdlsChanSwitchReqRsp->sessionId = sessionId;
5355 mmhMsg.type = eWNI_SME_TDLS_CHANNEL_SWITCH_RSP ;
5356 mmhMsg.bodyptr = pTdlsChanSwitchReqRsp;
5357 mmhMsg.bodyval = 0;
5358 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5359 return ;
5360
5361
5362}
5363/*
Kiran V1ccee932012-12-12 14:49:46 -08005364 * Once link is teardown, send Del Peer Ind to SME
5365 */
5366static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
5367 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
5368 tANI_U8 status)
5369{
5370 tSirMsgQ mmhMsg = {0} ;
5371 tSirTdlsDelStaRsp *pDelSta = NULL ;
5372 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305373
5374 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
5375 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08005376 {
5377 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
5378 return eSIR_FAILURE;
5379 }
5380
5381 pDelSta->sessionId = sessionId;
5382 pDelSta->statusCode = status ;
5383 if( pStaDs )
5384 {
5385 pDelSta->staId = pStaDs->staIndex ;
5386 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005387 else
5388 pDelSta->staId = HAL_STA_INVALID_IDX;
5389
Kiran V1ccee932012-12-12 14:49:46 -08005390 if( peerMac )
5391 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305392 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08005393 }
5394
5395 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
5396 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
5397
5398 mmhMsg.bodyptr = pDelSta;
5399
5400 mmhMsg.bodyval = 0;
5401 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
5402 return eSIR_SUCCESS ;
5403
5404}
5405
5406/*
5407 * Process Send Mgmt Request from SME and transmit to AP.
5408 */
5409tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
5410 tANI_U32 *pMsgBuf)
5411{
5412 /* get all discovery request parameters */
5413 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
5414 tpPESession psessionEntry;
5415 tANI_U8 sessionId;
Kiran V1ccee932012-12-12 14:49:46 -08005416
5417 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005418 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005419
5420 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
5421 == NULL)
5422 {
5423 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005424 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005425 pAddStaReq->sessionId);
5426 goto lim_tdls_add_sta_error;
5427 }
5428
5429 /* check if we are in proper state to work as TDLS client */
5430 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5431 {
5432 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005433 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005434 psessionEntry->limSystemRole);
5435 goto lim_tdls_add_sta_error;
5436 }
5437
5438 /*
5439 * if we are still good, go ahead and check if we are in proper state to
5440 * do TDLS discovery req/rsp/....frames.
5441 */
5442 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5443 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5444 {
5445
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005446 limLog(pMac, LOGE, "send mgmt received in invalid LIMsme "
5447 "state (%d)", psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005448 goto lim_tdls_add_sta_error;
5449 }
5450
5451 pMac->lim.gLimAddStaTdls = true ;
5452
5453 /* To start with, send add STA request to HAL */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005454 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08005455 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005456 limLog(pMac, LOGE, "%s: Add TDLS Station request failed ", __func__);
Kiran V1ccee932012-12-12 14:49:46 -08005457 goto lim_tdls_add_sta_error;
5458 }
5459 return eSIR_SUCCESS;
5460lim_tdls_add_sta_error:
5461 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005462 pAddStaReq->sessionId, pAddStaReq->peerMac,
5463 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08005464
5465 return eSIR_SUCCESS;
5466}
5467/*
5468 * Process Del Sta Request from SME .
5469 */
5470tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
5471 tANI_U32 *pMsgBuf)
5472{
5473 /* get all discovery request parameters */
5474 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
5475 tpPESession psessionEntry;
5476 tANI_U8 sessionId;
5477 tpDphHashNode pStaDs = NULL ;
5478
5479 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005480 ("Send Mgmt Recieved")) ;
Kiran V1ccee932012-12-12 14:49:46 -08005481
5482 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
5483 == NULL)
5484 {
5485 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005486 "PE Session does not exist for given sme sessionId %d",
Kiran V1ccee932012-12-12 14:49:46 -08005487 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005488 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08005489 NULL, eSIR_FAILURE) ;
5490 return eSIR_FAILURE;
5491 }
5492
5493 /* check if we are in proper state to work as TDLS client */
5494 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5495 {
5496 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005497 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08005498 psessionEntry->limSystemRole);
5499 goto lim_tdls_del_sta_error;
5500 }
5501
5502 /*
5503 * if we are still good, go ahead and check if we are in proper state to
5504 * do TDLS discovery req/rsp/....frames.
5505 */
5506 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5507 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5508 {
5509
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005510 limLog(pMac, LOGE, "Del Sta received in invalid LIMsme state (%d)",
5511 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08005512 goto lim_tdls_del_sta_error;
5513 }
5514
5515 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
5516
5517 /* now send indication to SME-->HDD->TL to remove STA from TL */
5518
5519 if(pStaDs)
5520 {
5521 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5522 pStaDs, eSIR_SUCCESS) ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005523 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08005524
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005525 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
5526 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08005527 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
5528
Kiran V1ccee932012-12-12 14:49:46 -08005529 return eSIR_SUCCESS;
5530
5531 }
5532
5533lim_tdls_del_sta_error:
5534 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
5535 NULL, eSIR_FAILURE) ;
5536
5537 return eSIR_SUCCESS;
5538}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005539
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305540/* Intersects the two input arrays and outputs an array */
5541/* For now the array length of tANI_U8 suffices */
5542static void limTdlsGetIntersection(tANI_U8 *input_array1,tANI_U8 input1_length,
5543 tANI_U8 *input_array2,tANI_U8 input2_length,
5544 tANI_U8 *output_array,tANI_U8 *output_length)
5545{
5546 tANI_U8 i,j,k=0,flag=0;
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05305547
5548 if (input1_length > WNI_CFG_VALID_CHANNEL_LIST_LEN)
5549 {
5550 input1_length = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5551 }
5552
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305553 for(i=0;i<input1_length;i++)
5554 {
5555 flag=0;
5556 for(j=0;j<input2_length;j++)
5557 {
5558 if(input_array1[i]==input_array2[j])
5559 {
5560 flag=1;
5561 break;
5562 }
5563 }
5564 if(flag==1)
5565 {
5566 output_array[k]=input_array1[i];
5567 k++;
5568 }
5569 }
5570 *output_length = k;
5571}
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305572/*
5573 * Process Link Establishment Request from SME .
5574 */
5575tSirRetStatus limProcesSmeTdlsLinkEstablishReq(tpAniSirGlobal pMac,
5576 tANI_U32 *pMsgBuf)
5577{
5578 /* get all discovery request parameters */
5579 tSirTdlsLinkEstablishReq *pTdlsLinkEstablishReq = (tSirTdlsLinkEstablishReq*) pMsgBuf ;
5580 tpPESession psessionEntry;
5581 tANI_U8 sessionId;
5582 tpTdlsLinkEstablishParams pMsgTdlsLinkEstablishReq;
5583 tSirMsgQ msg;
5584 tANI_U16 peerIdx = 0 ;
5585 tpDphHashNode pStaDs = NULL ;
5586
5587 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005588 ("Send Mgmt Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305589
5590 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
5591 == NULL)
5592 {
5593 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005594 "PE Session does not exist for given sme sessionId %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305595 pTdlsLinkEstablishReq->sessionId);
5596 limSendSmeTdlsLinkEstablishReqRsp(pMac, pTdlsLinkEstablishReq->sessionId, pTdlsLinkEstablishReq->peerMac,
5597 NULL, eSIR_FAILURE) ;
5598 return eSIR_FAILURE;
5599 }
5600
5601 /* check if we are in proper state to work as TDLS client */
5602 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5603 {
5604 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005605 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305606 psessionEntry->limSystemRole);
5607 goto lim_tdls_link_establish_error;
5608 }
5609
5610 /*
5611 * if we are still good, go ahead and check if we are in proper state to
5612 * do TDLS discovery req/rsp/....frames.
5613 */
5614 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5615 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5616 {
5617
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005618 limLog(pMac, LOGE, "TDLS Link Establish Request received in "
5619 "invalid LIMsme state (%d)", psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305620 goto lim_tdls_link_establish_error;
5621 }
5622 /*TODO Sunil , TDLSPeer Entry has the STA ID , Use it */
5623 pStaDs = dphLookupHashEntry(pMac, pTdlsLinkEstablishReq->peerMac, &peerIdx,
5624 &psessionEntry->dph.dphHashTable) ;
5625 if ( NULL == pStaDs )
5626 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005627 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305628 goto lim_tdls_link_establish_error;
5629
5630 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305631 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
5632 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305633 {
5634 limLog( pMac, LOGE,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005635 FL( "Unable to allocate memory TDLS Link Establish Request" ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305636 return eSIR_MEM_ALLOC_FAILED;
5637 }
5638
Girish Gowlicf762742014-07-02 13:54:09 +05305639 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305640
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05305641 pMsgTdlsLinkEstablishReq->staIdx = pStaDs->staIndex;
5642 pMsgTdlsLinkEstablishReq->isResponder = pTdlsLinkEstablishReq->isResponder;
5643 pMsgTdlsLinkEstablishReq->uapsdQueues = pTdlsLinkEstablishReq->uapsdQueues;
5644 pMsgTdlsLinkEstablishReq->maxSp = pTdlsLinkEstablishReq->maxSp;
5645 pMsgTdlsLinkEstablishReq->isBufsta = pTdlsLinkEstablishReq->isBufSta;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305646 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
5647 pTdlsLinkEstablishReq->isOffChannelSupported;
5648 pMsgTdlsLinkEstablishReq->isOffChannelSupported = 1;
5649
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05305650 if ((pTdlsLinkEstablishReq->supportedChannelsLen > 0) &&
5651 (pTdlsLinkEstablishReq->supportedChannelsLen <= SIR_MAC_MAX_SUPP_CHANNELS))
Naresh Jayarambc62ba42014-02-12 21:39:14 +05305652 {
5653 tANI_U32 selfNumChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5654 tANI_U8 selfSupportedChannels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5655 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
5656 selfSupportedChannels, &selfNumChans) != eSIR_SUCCESS)
5657 {
5658 /**
5659 * Could not get Valid channel list from CFG.
5660 * Log error.
5661 */
5662 limLog(pMac, LOGP,
5663 FL("could not retrieve Valid channel list"));
5664 }
5665 limTdlsGetIntersection(selfSupportedChannels, selfNumChans,
5666 pTdlsLinkEstablishReq->supportedChannels,
5667 pTdlsLinkEstablishReq->supportedChannelsLen,
5668 pMsgTdlsLinkEstablishReq->validChannels,
5669 &pMsgTdlsLinkEstablishReq->validChannelsLen);
5670 }
5671 vos_mem_copy(pMsgTdlsLinkEstablishReq->validOperClasses,
5672 pTdlsLinkEstablishReq->supportedOperClasses, pTdlsLinkEstablishReq->supportedOperClassesLen);
5673 pMsgTdlsLinkEstablishReq->validOperClassesLen =
5674 pTdlsLinkEstablishReq->supportedOperClassesLen;
5675
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305676 msg.type = WDA_SET_TDLS_LINK_ESTABLISH_REQ;
5677 msg.reserved = 0;
5678 msg.bodyptr = pMsgTdlsLinkEstablishReq;
5679 msg.bodyval = 0;
5680 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5681 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005682 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305683 goto lim_tdls_link_establish_error;
5684 }
5685 return eSIR_SUCCESS;
5686lim_tdls_link_establish_error:
5687 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
5688 NULL, eSIR_FAILURE) ;
5689
5690 return eSIR_SUCCESS;
5691}
5692
5693
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005694/* Delete all the TDLS peer connected before leaving the BSS */
5695tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
5696{
5697 tpDphHashNode pStaDs = NULL ;
5698 int i, aid;
5699
5700 if (NULL == psessionEntry)
5701 {
5702 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
5703 return eSIR_FAILURE;
5704 }
5705
5706 /* Check all the set bit in peerAIDBitmap and delete the peer (with that aid) entry
5707 from the hash table and add the aid in free pool */
5708 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
5709 {
5710 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
5711 {
5712 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
5713 {
5714 pStaDs = dphGetHashEntry(pMac, (aid + i*(sizeof(tANI_U32) << 3)), &psessionEntry->dph.dphHashTable);
5715
5716 if (NULL != pStaDs)
5717 {
Arif Hussain24bafea2013-11-15 15:10:03 -08005718 PELOGE(limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
5719 MAC_ADDR_ARRAY(pStaDs->staAddr)););
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005720
5721 limSendDeauthMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
5722 pStaDs->staAddr, psessionEntry, FALSE);
5723 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, &psessionEntry->dph.dphHashTable);
5724 }
5725 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)), psessionEntry) ;
5726 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
5727 }
5728 }
5729 }
5730 limSendSmeTDLSDeleteAllPeerInd(pMac, psessionEntry);
5731
5732 return eSIR_SUCCESS;
5733}
Atul Mittalb849d5a2014-07-29 12:08:39 +05305734
5735
5736tANI_U8 limGetOPClassFromChannel(tANI_U8 *country,
5737 tANI_U8 channel,
5738 tANI_U8 offset)
5739{
5740 op_class_map_t *class = NULL;
5741 tANI_U16 i = 0;
5742
5743 if (VOS_TRUE == vos_mem_compare(country,"US", 2)) {
5744
5745 class = us_op_class;
5746
5747 } else if (VOS_TRUE == vos_mem_compare(country,"EU", 2)) {
5748
5749 class = euro_op_class;
5750
5751 } else if (VOS_TRUE == vos_mem_compare(country,"JP", 2)) {
5752
5753 class = japan_op_class;
5754
5755 } else {
5756
5757 class = global_op_class;
5758
5759 }
5760
5761 while (class->op_class)
5762 {
5763 if ((offset == class->offset) || (offset == BWALL))
5764 {
5765 for (i=0; (i < 15 && class->channels[i]); i++)
5766 {
5767 if (channel == class->channels[i])
5768 return class->op_class;
5769 }
5770 }
5771 class++;
5772 }
5773 return 0;
5774}
5775
5776tANI_BOOLEAN CheckAndAddOP(tANI_U8 class)
5777{
5778 tANI_U8 i;
5779
5780 for (i=0; i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1); i++)
5781 {
5782 /*0 is an invalid class. If class is already present ignore*/
5783 if (class == op_classes.classes[i])
5784 return FALSE;
5785 if(op_classes.classes[i] == 0)
5786 {
5787 return TRUE;
5788 }
5789 }
5790 //limLog(pMac, LOGE, FL("No space left for class = %d"), class);
5791 return FALSE;
5792}
5793
5794void limInitOperatingClasses( tHalHandle hHal )
5795{
5796
5797 tANI_U8 Index = 0;
5798 tANI_U8 class = 0;
5799 tANI_U8 i = 0;
5800 tANI_U8 j = 0;
5801 tANI_U8 swap = 0;
5802 tANI_U8 numChannels = 0;
5803 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5804 limLog(pMac, LOG1, FL("Current Country = %c%c"),
5805 pMac->scan.countryCodeCurrent[0],
5806 pMac->scan.countryCodeCurrent[1]);
5807
5808 vos_mem_set(op_classes.classes, sizeof(op_classes.classes), 0);
5809 numChannels = pMac->scan.baseChannels.numChannels;
5810 limLog(pMac, LOG1, "Num of base ch =%d", numChannels);
5811 for ( Index = 0;
5812 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
5813 Index++)
5814 {
5815 class = limGetOPClassFromChannel(
5816 pMac->scan.countryCodeCurrent,
5817 pMac->scan.baseChannels.channelList[ Index ],
5818 BWALL);
5819 limLog(pMac, LOG4, "ch=%d <=> %d=class",
5820 pMac->scan.baseChannels.channelList[ Index ],
5821 class);
5822 if (CheckAndAddOP(class))
5823 {
5824 op_classes.classes[i]= class;
5825 i++;
5826 }
5827 }
5828
5829 numChannels = pMac->scan.base20MHzChannels.numChannels;
5830 limLog(pMac, LOG1, "Num of 20MHz ch =%d", numChannels);
5831 for ( Index = 0;
5832 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
5833 Index++)
5834 {
5835 class = limGetOPClassFromChannel(
5836 pMac->scan.countryCodeCurrent,
5837 pMac->scan.base20MHzChannels.channelList[ Index ],
5838 BWALL);
5839 limLog(pMac, LOG4, "ch=%d <=> %d=class",
5840 pMac->scan.base20MHzChannels.channelList[ Index ],
5841 class);
5842 if (CheckAndAddOP(class))
5843 {
5844 op_classes.classes[i]= class;
5845 i++;
5846 }
5847 }
5848
5849 numChannels = pMac->scan.base40MHzChannels.numChannels;
5850 limLog(pMac, LOG1, "Num of 40MHz ch =%d", numChannels);
5851 for ( Index = 0;
5852 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
5853 Index++)
5854 {
5855 class = limGetOPClassFromChannel(
5856 pMac->scan.countryCodeCurrent,
5857 pMac->scan.base40MHzChannels.channelList[ Index ],
5858 BWALL);
5859 limLog(pMac, LOG4, "ch=%d <=> %d=class",
5860 pMac->scan.base40MHzChannels.channelList[ Index ],
5861 class);
5862 if (CheckAndAddOP(class))
5863 {
5864 op_classes.classes[i]= class;
5865 i++;
5866 }
5867 }
5868
5869 op_classes.num_classes = i;
5870 limLog(pMac, LOG1, "Total number of Unique supported classes =%d",
5871 op_classes.num_classes);
5872 /*as per spec the operating classes should be in ascending order*/
5873 /*Bubble sort is fine as we don't have many classes*/
5874 for (i = 0 ; i < ( op_classes.num_classes - 1 ); i++)
5875 {
5876 for (j = 0 ; j < op_classes.num_classes - i - 1; j++)
5877 {
5878 /* For decreasing order use < */
5879 if (op_classes.classes[j] > op_classes.classes[j+1])
5880 {
5881 swap = op_classes.classes[j];
5882 op_classes.classes[j] = op_classes.classes[j+1];
5883 op_classes.classes[j+1] = swap;
5884 }
5885 }
5886 }
5887 for (i=0; i < op_classes.num_classes; i++)
5888 {
5889
5890 limLog(pMac, LOG1, "supported op_class[%d]=%d", i,
5891 op_classes.classes[i]);
5892
5893 }
5894}
5895
Kiran V1ccee932012-12-12 14:49:46 -08005896#endif
Atul Mittalc0f739f2014-07-31 13:47:47 +05305897// tdlsoffchan
5898/*
5899 * Process Channel Switch from SME.
5900 */
5901tSirRetStatus limProcesSmeTdlsChanSwitchReq(tpAniSirGlobal pMac,
5902 tANI_U32 *pMsgBuf)
5903{
5904 /* get all discovery request parameters */
5905 tSirTdlsChanSwitch *pTdlsChanSwitch = (tSirTdlsChanSwitch*) pMsgBuf ;
5906 tpPESession psessionEntry;
5907 tANI_U8 sessionId;
5908 tpTdlsChanSwitchParams pMsgTdlsChanSwitch;
5909 tSirMsgQ msg;
5910 tANI_U16 peerIdx = 0;
5911 tpDphHashNode pStaDs = NULL;
5912
5913 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
5914 ("TDLS Channel Switch Recieved on peer:" MAC_ADDRESS_STR),
5915 MAC_ADDR_ARRAY(pTdlsChanSwitch->peerMac));
5916
5917 psessionEntry = peFindSessionByBssid(pMac,
5918 pTdlsChanSwitch->bssid,
5919 &sessionId);
5920 if (psessionEntry == NULL)
5921 {
5922 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
5923 "PE Session does not exist for given sme sessionId %d",
5924 pTdlsChanSwitch->sessionId);
Atul Mittal60bd4292014-08-14 12:19:27 +05305925 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
5926 pTdlsChanSwitch->peerMac,
5927 NULL, eSIR_FAILURE) ;
Atul Mittalc0f739f2014-07-31 13:47:47 +05305928 return eSIR_FAILURE;
5929 }
5930
5931 /* check if we are in proper state to work as TDLS client */
5932 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5933 {
5934 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
5935 "TDLS Channel Switch received in wrong system Role %d",
5936 psessionEntry->limSystemRole);
5937 goto lim_tdls_chan_switch_error;
5938 }
5939
5940 /*
5941 * if we are still good, go ahead and check if we are in proper state to
5942 * do TDLS discovery req/rsp/....frames.
5943 */
5944 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5945 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5946 {
5947
5948 limLog(pMac, LOGE, "TDLS Channel Switch received in invalid LIMsme state (%d)",
5949 psessionEntry->limSmeState);
5950 goto lim_tdls_chan_switch_error;
5951 }
5952
5953 pStaDs = dphLookupHashEntry(pMac, pTdlsChanSwitch->peerMac, &peerIdx,
5954 &psessionEntry->dph.dphHashTable) ;
5955 if ( NULL == pStaDs )
5956 {
5957 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
5958 goto lim_tdls_chan_switch_error;
5959
5960 }
5961 pMsgTdlsChanSwitch = vos_mem_malloc(sizeof( tTdlsChanSwitchParams ));
5962 if ( NULL == pMsgTdlsChanSwitch )
5963 {
5964 limLog( pMac, LOGE,
5965 FL( "Unable to allocate memory TDLS Channel Switch" ));
5966 return eSIR_MEM_ALLOC_FAILED;
5967 }
5968
5969 vos_mem_set( (tANI_U8 *)pMsgTdlsChanSwitch, sizeof(tpTdlsChanSwitchParams), 0);
5970
5971 pMsgTdlsChanSwitch->staIdx = pStaDs->staIndex;
5972 pMsgTdlsChanSwitch->tdlsOffCh = pTdlsChanSwitch->tdlsOffCh;
5973 pMsgTdlsChanSwitch->tdlsOffChBwOffset = pTdlsChanSwitch->tdlsOffChBwOffset;
5974 pMsgTdlsChanSwitch->tdlsSwMode = pTdlsChanSwitch->tdlsSwMode;
5975 pMsgTdlsChanSwitch->operClass = limGetOPClassFromChannel(
5976 pMac->scan.countryCodeCurrent,
5977 pTdlsChanSwitch->tdlsOffCh,
5978 pTdlsChanSwitch->tdlsOffChBwOffset);
5979 if(pMsgTdlsChanSwitch->operClass == 0)
5980 {
5981
5982 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
5983 "Invalid Operating class 0 !!!");
5984 goto lim_tdls_chan_switch_error;
5985 }
5986 else
5987 {
5988
5989 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
5990 "%s: TDLS Channel Switch params: staIdx %d class %d ch %d bw %d mode %d",
5991 __func__,
5992 pMsgTdlsChanSwitch->staIdx,
5993 pMsgTdlsChanSwitch->operClass,
5994 pMsgTdlsChanSwitch->tdlsOffCh,
5995 pMsgTdlsChanSwitch->tdlsOffChBwOffset,
5996 pMsgTdlsChanSwitch->tdlsSwMode);
5997 }
5998
5999 msg.type = WDA_SET_TDLS_CHAN_SWITCH_REQ;
6000 msg.reserved = 0;
6001 msg.bodyptr = pMsgTdlsChanSwitch;
6002 msg.bodyval = 0;
6003 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
6004 {
6005 limLog(pMac, LOGE, FL("halPostMsgApi failed\n"));
6006 goto lim_tdls_chan_switch_error;
6007 }
6008
6009 return eSIR_SUCCESS;
6010
6011lim_tdls_chan_switch_error:
Atul Mittal60bd4292014-08-14 12:19:27 +05306012 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
6013 pTdlsChanSwitch->peerMac,
6014 NULL, eSIR_FAILURE);
Atul Mittalc0f739f2014-07-31 13:47:47 +05306015 return eSIR_FAILURE;
6016}
6017