blob: 50e04b0d4b59b14d2d29d568ecdfd004ef90ab04 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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
Kiran V1ccee932012-12-12 14:49:46 -080095
Gopichand Nakkala681989c2013-03-06 22:27:48 -080096static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
97 tSirTdlsAddStaReq *pAddStaReq,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +053098 tpPESession psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -080099void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
100 tDot11fIELinkIdentifier *linkIden,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530101 tSirMacAddr peerMac, tANI_U8 reqType) ;
Kiran V1ccee932012-12-12 14:49:46 -0800102void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
103 tDot11fIEExtCap *extCapability) ;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800104
Naresh Jayarambc62ba42014-02-12 21:39:14 +0530105void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
106 tpPESession psessionEntry,
107 tDot11fIESuppChannels *suppChannels,
108 tDot11fIESuppOperatingClasses *suppOperClasses);
109
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800110void limLogVHTCap(tpAniSirGlobal pMac,
111 tDot11fIEVHTCaps *pDot11f);
112tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
113 tpSirSupportedRates pRates,
114 tDot11fIEVHTCaps *pPeerVHTCaps,
115 tpPESession psessionEntry);
116ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode);
Atul Mittalb849d5a2014-07-29 12:08:39 +0530117/*only 31 op classes are available, 1 entry for current op class*/
118static tDot11fIESuppOperatingClasses op_classes = {0};
119
120op_class_map_t global_op_class[] = {
121 {81, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}},
122 {82, 25, BW20, {14}},
123 {83, 40, BW40PLUS, {1, 2, 3, 4, 5, 6, 7, 8, 9}},
124 {84, 40, BW40MINUS, {5, 6, 7, 8, 9, 10, 11, 12, 13}},
125 {115, 20, BW20, {36, 40, 44, 48}},
126 {116, 40, BW40PLUS, {36, 44}},
127 {117, 40, BW40MINUS, {40, 48}},
128 {118, 20, BW20, {52, 56, 60, 64}},
129 {119, 40, BW40PLUS, {52, 60}},
130 {120, 40, BW40MINUS, {56, 64}},
131 {121, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
132 {122, 40, BW40PLUS, {100, 108, 116, 124, 132}},
133 {123, 40, BW40MINUS, {104, 112, 120, 128, 136}},
134 {125, 20, BW20, {149, 153, 157, 161, 165, 169}},
135 {126, 40, BW40PLUS, {149, 157}},
136 {127, 40, BW40MINUS, {153, 161}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530137 {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
138 116, 120, 124, 128, 132, 136, 140, 144,
139 149, 153, 157, 161}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530140 {0, 0, 0, {0}},
141
142};/*end global_op_class*/
143
144op_class_map_t us_op_class[] = {
145 {1, 20, BW20, {36, 40, 44, 48}},
146 {2, 20, BW20, {52, 56, 60, 64}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530147 {4, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530148 {5, 20, BW20, {149, 153, 157, 161, 165}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530149 {12, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530150 {22, 40, BW40PLUS, {36, 44}},
151 {23, 40, BW40PLUS, {52, 60}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530152 {24, 40, BW40PLUS, {100, 108, 116, 124, 132, 140}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530153 {26, 40, BW40PLUS, {149, 157}},
154 {27, 40, BW40MINUS, {40, 48}},
155 {28, 40, BW40MINUS, {56, 64}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530156 {29, 40, BW40MINUS, {104, 112, 120, 128, 136, 144}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530157 {31, 40, BW40MINUS, {153, 161}},
158 {32, 40, BW40PLUS, {1, 2, 3, 4, 5, 6, 7}},
159 {33, 40, BW40MINUS, {5, 6, 7, 8, 9, 10, 11}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530160 {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
161 116, 120, 124, 128, 132, 136, 140, 144,
162 149, 153, 157, 161}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530163 {0, 0, 0, {0}},
164};/*end us_op_class*/
165
166op_class_map_t euro_op_class[] = {
167 {1, 20, BW20, {36, 40, 44, 48}},
168 {2, 20, BW20, {52, 56, 60, 64}},
169 {3, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
170 {4, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}},
171 {5, 40, BW40PLUS, {36, 44}},
172 {6, 40, BW40PLUS, {52, 60}},
173 {7, 40, BW40PLUS, {100, 108, 116, 124, 132}},
174 {8, 40, BW40MINUS, {40, 48}},
175 {9, 40, BW40MINUS, {56, 64}},
176 {10, 40, BW40MINUS, {104, 112, 120, 128, 136}},
177 {11, 40, BW40PLUS, {1, 2, 3, 4, 5, 6, 7, 8, 9}},
178 {12, 40, BW40MINUS, {5, 6, 7, 8, 9, 10, 11, 12, 13}},
179 {17, 20, BW20, {149, 153, 157, 161, 165, 169}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530180 {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
181 116, 120, 124, 128}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530182 {0, 0, 0, {0}},
183};/*end euro_op_class*/
184
185op_class_map_t japan_op_class[] = {
186 {1, 20, BW20, {36, 40, 44, 48}},
187 {30, 25, BW20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}},
188 {31, 25, BW20, {14}},
189 {32, 20, BW20, {52, 56, 60, 64}},
190 {34, 20, BW20, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}},
191 {36, 40, BW40PLUS, {36, 44}},
192 {37, 40, BW40PLUS, {52, 60}},
193 {39, 40, BW40PLUS, {100, 108, 116, 124, 132}},
194 {41, 40, BW40MINUS, {40, 48}},
195 {42, 40, BW40MINUS, {56, 64}},
196 {44, 40, BW40MINUS, {104, 112, 120, 128, 136}},
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530197 {128, 80, BW80, {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
198 116, 120, 124, 128}},
Atul Mittalb849d5a2014-07-29 12:08:39 +0530199 {0, 0, 0, {0}},
200};/*end japan_op_class*/
201
Kiran V1ccee932012-12-12 14:49:46 -0800202/*
203 * TDLS data frames will go out/come in as non-qos data.
204 * so, eth_890d_header will be aligned access..
205 */
206static const tANI_U8 eth_890d_header[] =
207{
208 0xaa, 0xaa, 0x03, 0x00,
209 0x00, 0x00, 0x89, 0x0d,
210} ;
211
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +0530212/* store tdls self supported channels
213 * which are non passive */
214#define LIM_TDLS_MAX_NON_DFS_CHANNELS 50
215static tANI_U8 tdlsSelfNumChans = 0;
216static tANI_U8 tdlsSelfSupportedChannels[LIM_TDLS_MAX_NON_DFS_CHANNELS] = {0};
217
Kiran V1ccee932012-12-12 14:49:46 -0800218/*
219 * type of links used in TDLS
220 */
221enum tdlsLinks
222{
223 TDLS_LINK_AP,
224 TDLS_LINK_DIRECT
225} eTdlsLink ;
226
227/*
228 * node status in node searching
229 */
230enum tdlsLinkNodeStatus
231{
232 TDLS_NODE_NOT_FOUND,
233 TDLS_NODE_FOUND
234} eTdlsLinkNodeStatus ;
235
236
237enum tdlsReqType
238{
239 TDLS_INITIATOR,
240 TDLS_RESPONDER
241} eTdlsReqType ;
242
243typedef enum tdlsLinkSetupStatus
244{
245 TDLS_SETUP_STATUS_SUCCESS = 0,
246 TDLS_SETUP_STATUS_FAILURE = 37
247}etdlsLinkSetupStatus ;
248
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +0530249/* These maps to Kernel TDLS peer capability
250 * flags and should get changed as and when necessary
251 */
252enum tdls_peer_capability {
253 TDLS_PEER_HT_CAP = 0,
254 TDLS_PEER_VHT_CAP = 1,
255 TDLS_PEER_WMM_CAP = 2
256} eTdlsPeerCapability;
257
Kiran V1ccee932012-12-12 14:49:46 -0800258/* some local defines */
259#define LINK_IDEN_BSSID_OFFSET (0)
260#define PEER_MAC_OFFSET (12)
261#define STA_MAC_OFFSET (6)
262#define LINK_IDEN_ELE_ID (101)
263//#define LINK_IDEN_LENGTH (18)
264#define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier)
265#define PTI_LINK_IDEN_OFFSET (5)
266#define PTI_BUF_STATUS_OFFSET (25)
267
268/* TODO, Move this parameters to configuration */
269#define PEER_PSM_SUPPORT (0)
Hoonki Lee93e67ff2013-03-19 15:49:25 -0700270#define PEER_BUFFER_STA_SUPPORT (0)
Kiran V1ccee932012-12-12 14:49:46 -0800271#define CH_SWITCH_SUPPORT (0)
272#define TDLS_SUPPORT (1)
273#define TDLS_PROHIBITED (0)
274#define TDLS_CH_SWITCH_PROHIBITED (1)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800275/** @brief Set bit manipulation macro */
276#define SET_BIT(value,mask) ((value) |= (1 << (mask)))
277/** @brief Clear bit manipulation macro */
278#define CLEAR_BIT(value,mask) ((value) &= ~(1 << (mask)))
279/** @brief Check bit manipulation macro */
280#define CHECK_BIT(value, mask) ((value) & (1 << (mask)))
281
282#define SET_PEER_AID_BITMAP(peer_bitmap, aid) \
283 if ((aid) < (sizeof(tANI_U32) << 3)) \
284 SET_BIT(peer_bitmap[0], (aid)); \
285 else if ((aid) < (sizeof(tANI_U32) << 4)) \
286 SET_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
287
288#define CLEAR_PEER_AID_BITMAP(peer_bitmap, aid) \
289 if ((aid) < (sizeof(tANI_U32) << 3)) \
290 CLEAR_BIT(peer_bitmap[0], (aid)); \
291 else if ((aid) < (sizeof(tANI_U32) << 4)) \
292 CLEAR_BIT(peer_bitmap[1], ((aid) - (sizeof(tANI_U32) << 3)));
293
Kiran V1ccee932012-12-12 14:49:46 -0800294
295#ifdef LIM_DEBUG_TDLS
Kiran V1ccee932012-12-12 14:49:46 -0800296
297#ifdef FEATURE_WLAN_TDLS
298#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT (100)
299#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT (800)
300#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT (200)
301#endif
302
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530303#define IS_QOS_ENABLED(psessionEntry) ((((psessionEntry)->limQosEnabled) && \
304 SIR_MAC_GET_QOS((psessionEntry)->limCurrentBssCaps)) || \
305 (((psessionEntry)->limWmeEnabled ) && \
306 LIM_BSS_CAPS_GET(WME, (psessionEntry)->limCurrentBssQosCaps)))
307
308#define TID_AC_VI 4
309#define TID_AC_BK 1
310
Kiran V1ccee932012-12-12 14:49:46 -0800311const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
312{
313 switch( tdlsActionCode )
314 {
Daram Sudha1f7e0e92013-12-17 07:52:31 +0530315 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
316 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
317 CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
318 CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
319 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
320 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
321 CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
322 CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
323 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
324 CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
Kiran V1ccee932012-12-12 14:49:46 -0800325 }
326 return (const tANI_U8*)"UNKNOWN";
327}
328#endif
329#if 0
330static void printMacAddr(tSirMacAddr macAddr)
331{
332 int i = 0 ;
333 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
334
335 for(i = 0 ; i < 6; i++)
336 {
337 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
338 (" %02x "), macAddr[i]);
339 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700340 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (""));
Kiran V1ccee932012-12-12 14:49:46 -0800341 return ;
342}
343#endif
Kiran V1ccee932012-12-12 14:49:46 -0800344/*
345 * initialize TDLS setup list and related data structures.
346 */
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800347void limInitTdlsData(tpAniSirGlobal pMac, tpPESession pSessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800348{
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800349 limInitPeerIdxpool(pMac, pSessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800350
351 return ;
352}
Kiran V1ccee932012-12-12 14:49:46 -0800353#ifdef FEATURE_WLAN_TDLS_NEGATIVE
354void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
355{
356 if(on) {
357 if(value == 255)
358 pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
359 else
360 pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
361 }
362 else {
363 if(value == 255)
364 pMac->lim.gLimTdlsNegativeBehavior = 0;
365 else
366 pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
367 }
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800368 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 -0800369 value, on, pMac->lim.gLimTdlsNegativeBehavior));
370}
371#endif
372#if 0
373/*
374 * This function is used for creating TDLS public Action frame to
375 * transmit on Direct link
376 */
377static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
378 tANI_U8 type, tANI_U8 subType,
379 tANI_U8 *link_iden )
380{
381 tpSirMacMgmtHdr pMacHdr ;
382 tANI_U8 *bssid = link_iden ;
383#if 0
384 tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
385 tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
386#else
387 tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
388 tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
389#endif
390 tANI_U8 toDs = ANI_TXDIR_IBSS ;
391
392 pMacHdr = (tpSirMacMgmtHdr) (pFrame);
393
394 /*
395 * prepare 802.11 header
396 */
397 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
398 pMacHdr->fc.type = type ;
399 pMacHdr->fc.subType = subType ;
400 /*
401 * TL is not setting up below fields, so we are doing it here
402 */
403 pMacHdr->fc.toDS = toDs ;
404 pMacHdr->fc.powerMgmt = 0 ;
405
406
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530407 vos_mem_copy( (tANI_U8 *) pMacHdr->da, peerMac, sizeof( tSirMacAddr ));
408 vos_mem_copy( (tANI_U8 *) pMacHdr->sa,
Kiran V1ccee932012-12-12 14:49:46 -0800409 staMac, sizeof( tSirMacAddr ));
410
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530411 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Kiran V1ccee932012-12-12 14:49:46 -0800412 bssid, sizeof( tSirMacAddr ));
413
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800414 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"),
415 pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5],
416 pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5],
417 pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2],
Kiran V1ccee932012-12-12 14:49:46 -0800418 pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
419
420 return ;
421}
422#endif
423/*
424 * prepare TDLS frame header, it includes
425 * | | | |
426 * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
427 * | | | |
428 */
429static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530430 tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType,
431 tANI_U8 tid, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -0800432{
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530433 tpSirMacDataHdr3a pMacHdr ;
Kiran V1ccee932012-12-12 14:49:46 -0800434 tANI_U32 header_offset = 0 ;
435 tANI_U8 *addr1 = NULL ;
436 tANI_U8 *addr3 = NULL ;
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +0530437 tpDphHashNode pStaDs = NULL;
438 tANI_U16 aid = 0;
439 tANI_U8 qosMode = 0;
440
Kiran V1ccee932012-12-12 14:49:46 -0800441 tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP)
442 ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS ;
443 tANI_U8 *peerMac = (reqType == TDLS_INITIATOR)
444 ? link_iden->RespStaAddr : link_iden->InitStaAddr;
445 tANI_U8 *staMac = (reqType == TDLS_INITIATOR)
446 ? link_iden->InitStaAddr : link_iden->RespStaAddr;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530447 pMacHdr = (tpSirMacDataHdr3a) (pFrame);
Kiran V1ccee932012-12-12 14:49:46 -0800448
449 /*
450 * if TDLS frame goes through the AP link, it follows normal address
451 * pattern, if TDLS frame goes thorugh the direct link, then
452 * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
453 */
454 (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
455 (addr3 = (peerMac)))
456 : ((addr1 = (peerMac)),
457 (addr3 = (link_iden->bssid))) ;
458 /*
459 * prepare 802.11 header
460 */
461 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
462 pMacHdr->fc.type = SIR_MAC_DATA_FRAME ;
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +0530463
464 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid,
465 &psessionEntry->dph.dphHashTable);
466 if (pStaDs)
467 {
468 qosMode = pStaDs->qosMode;
469 }
470
471 pMacHdr->fc.subType = ((IS_QOS_ENABLED(psessionEntry) &&
472 (tdlsLinkType == TDLS_LINK_AP)) ||
473 ((tdlsLinkType == TDLS_LINK_DIRECT) && qosMode))
474 ? SIR_MAC_DATA_QOS_DATA : SIR_MAC_DATA_DATA;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530475
Kiran V1ccee932012-12-12 14:49:46 -0800476 /*
477 * TL is not setting up below fields, so we are doing it here
478 */
479 pMacHdr->fc.toDS = toDs ;
480 pMacHdr->fc.powerMgmt = 0 ;
481 pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
482
483
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530484 vos_mem_copy( (tANI_U8 *) pMacHdr->addr1,
485 (tANI_U8 *)addr1,
486 sizeof( tSirMacAddr ));
487 vos_mem_copy( (tANI_U8 *) pMacHdr->addr2,
488 (tANI_U8 *) staMac,
489 sizeof( tSirMacAddr ));
Kiran V1ccee932012-12-12 14:49:46 -0800490
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530491 vos_mem_copy( (tANI_U8 *) pMacHdr->addr3,
492 (tANI_U8 *) (addr3),
493 sizeof( tSirMacAddr ));
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530494
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530495 limLog(pMac, LOG1,
496 FL("Preparing TDLS frame header to %s A1:"MAC_ADDRESS_STR", A2:"MAC_ADDRESS_STR", A3:"MAC_ADDRESS_STR),
497 (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "DIRECT",
498 MAC_ADDR_ARRAY(pMacHdr->addr1),
499 MAC_ADDR_ARRAY(pMacHdr->addr2),
500 MAC_ADDR_ARRAY(pMacHdr->addr3));
Kiran V1ccee932012-12-12 14:49:46 -0800501
502 //printMacAddr(pMacHdr->bssId) ;
503 //printMacAddr(pMacHdr->sa) ;
504 //printMacAddr(pMacHdr->da) ;
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530505
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +0530506 if (((tdlsLinkType == TDLS_LINK_AP) && (IS_QOS_ENABLED(psessionEntry))) ||
507 ((tdlsLinkType == TDLS_LINK_DIRECT) && qosMode))
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530508 {
509 pMacHdr->qosControl.tid = tid;
510 header_offset += sizeof(tSirMacDataHdr3a);
511 }
512 else
513 header_offset += sizeof(tSirMacMgmtHdr);
514
Kiran V1ccee932012-12-12 14:49:46 -0800515 /*
516 * Now form RFC1042 header
517 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530518 vos_mem_copy((tANI_U8 *)(pFrame + header_offset),
519 (tANI_U8 *)eth_890d_header, sizeof(eth_890d_header)) ;
Kiran V1ccee932012-12-12 14:49:46 -0800520
521 header_offset += sizeof(eth_890d_header) ;
522
523 /* add payload type as TDLS */
524 *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
525
526 return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ;
527}
528
529/*
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800530 * TX Complete for Management frames
531 */
532 eHalStatus limMgmtTXComplete(tpAniSirGlobal pMac,
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530533 void *pData)
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800534{
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530535 tANI_U32 txCompleteSuccess = 0;
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530536 tpSirTxBdStatus pTxBdStatus = NULL;
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +0530537
538 if (!pData)
539 {
540 limLog(pMac, LOGE, FL("pData is NULL"));
541 return eHAL_STATUS_SUCCESS;
542 }
543
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +0530544 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
545 {
546 pTxBdStatus = (tpSirTxBdStatus) pData;
547 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
548 limLog(pMac, LOG1, FL("txCompleteSuccess %u, token %u"),
549 txCompleteSuccess, pTxBdStatus->txBdToken);
550 }
551 else
552 {
553 txCompleteSuccess = *((tANI_U32*) pData);
554 limLog(pMac, LOG1, FL("txCompleteSuccess %u"), txCompleteSuccess);
555 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800556
557 if (0xff != pMac->lim.mgmtFrameSessionId)
558 {
Ganesh Kondabattiniff987022015-08-11 19:43:44 +0530559 limSendSmeMgmtTXCompletion(pMac, pMac->lim.mgmtFrameSessionId,
560 txCompleteSuccess);
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800561 pMac->lim.mgmtFrameSessionId = 0xff;
562 }
563 return eHAL_STATUS_SUCCESS;
564}
565
566/*
Kiran V1ccee932012-12-12 14:49:46 -0800567 * This function can be used for bacst or unicast discovery request
568 * We are not differentiating it here, it will all depnds on peer MAC address,
569 */
570tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
571 tANI_U8 dialog, tpPESession psessionEntry)
572{
573 tDot11fTDLSDisReq tdlsDisReq ;
574 tANI_U32 status = 0 ;
575 tANI_U32 nPayload = 0 ;
576 tANI_U32 size = 0 ;
577 tANI_U32 nBytes = 0 ;
578 tANI_U32 header_offset = 0 ;
579 tANI_U8 *pFrame;
580 void *pPacket;
581 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800582#ifndef NO_PAD_TDLS_MIN_8023_SIZE
583 tANI_U32 padLen = 0;
584#endif
Kiran V1ccee932012-12-12 14:49:46 -0800585
586 /*
587 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
588 * and then hand it off to 'dot11fPackProbeRequest' (for
589 * serialization). We start by zero-initializing the structure:
590 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530591 vos_mem_set( (tANI_U8*)&tdlsDisReq,
592 sizeof( tDot11fTDLSDisReq ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800593
594 /*
595 * setup Fixed fields,
596 */
597 tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
598 tdlsDisReq.Action.action = SIR_MAC_TDLS_DIS_REQ ;
599 tdlsDisReq.DialogToken.token = dialog ;
600
601
602 size = sizeof(tSirMacAddr) ;
603
604 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier,
605 peer_mac, TDLS_INITIATOR) ;
606
607 /*
608 * now we pack it. First, how much space are we going to need?
609 */
610 status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
611 if ( DOT11F_FAILED( status ) )
612 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530613 limLog(pMac, LOGE,
614 FL("Failed to calculate the packed size for a discovery Request (0x%08x)."),
615 status);
Kiran V1ccee932012-12-12 14:49:46 -0800616 /* We'll fall back on the worst case scenario: */
617 nPayload = sizeof( tDot11fTDLSDisReq );
618 }
619 else if ( DOT11F_WARNED( status ) )
620 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530621 limLog(pMac, LOGW,
622 FL("There were warnings while calculating the packed size for a discovery Request (0x%08x)."),
623 status);
Kiran V1ccee932012-12-12 14:49:46 -0800624 }
625
626 /*
627 * This frame is going out from PE as data frames with special ethertype
628 * 89-0d.
629 * 8 bytes of RFC 1042 header
630 */
631
632
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530633 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
634 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
635 + sizeof( eth_890d_header )
636 + PAYLOAD_TYPE_TDLS_SIZE ;
Kiran V1ccee932012-12-12 14:49:46 -0800637
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800638#ifndef NO_PAD_TDLS_MIN_8023_SIZE
639 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
640 Hence AP itself padding some bytes, which caused teardown packet is dropped at
641 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
642 */
643 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
644 {
645 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
646
647 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
648 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
649 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
650
651 nBytes += padLen;
652 }
653#endif
654
Kiran V1ccee932012-12-12 14:49:46 -0800655 /* Ok-- try to allocate memory from MGMT PKT pool */
656
657 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
658 ( tANI_U16 )nBytes, ( void** ) &pFrame,
659 ( void** ) &pPacket );
660 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
661 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530662 limLog(pMac, LOGE,
663 FL("Failed to allocate %d bytes for a TDLS Discovery Request."),
664 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -0800665 return eSIR_MEM_ALLOC_FAILED;
666 }
667
668 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530669 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800670
671 /*
672 * IE formation, memory allocation is completed, Now form TDLS discovery
673 * request frame
674 */
675
676 /* fill out the buffer descriptor */
677
678 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530679 LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -0800680
681#ifdef FEATURE_WLAN_TDLS_NEGATIVE
682 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
683 {
684 tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
685 tdlsDisReq.LinkIdentifier.bssid[5] = 0xad;
686 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800687 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Req"),
688 MAC_ADDR_ARRAY(tdlsDisReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800689 }
690#endif
691 status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame
692 + header_offset, nPayload, &nPayload );
693
694 if ( DOT11F_FAILED( status ) )
695 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530696 limLog(pMac, LOGE, FL("Failed to pack a TDLS discovery req (0x%08x)."),
697 status);
Kiran V1ccee932012-12-12 14:49:46 -0800698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
699 ( void* ) pFrame, ( void* ) pPacket );
700 return eSIR_FAILURE;
701 }
702 else if ( DOT11F_WARNED( status ) )
703 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530704 limLog(pMac, LOGW, FL("There were warnings while packing TDLS Discovery Request (0x%08x)."),
705 status);
Kiran V1ccee932012-12-12 14:49:46 -0800706 }
707
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800708#ifndef NO_PAD_TDLS_MIN_8023_SIZE
709 if (padLen != 0)
710 {
711 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
712 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload;
713 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
714 padVendorSpecific[0] = 221;
715 padVendorSpecific[1] = padLen - 2;
716 padVendorSpecific[2] = 0x00;
717 padVendorSpecific[3] = 0xA0;
718 padVendorSpecific[4] = 0xC6;
719
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530720 limLog(pMac, LOG1, FL("Padding Vendor Specific Ie Len = %d"), padLen);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800721
722 /* padding zero if more than 5 bytes are required */
723 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530724 vos_mem_set( pFrame + header_offset + nPayload + MIN_VENDOR_SPECIFIC_IE_SIZE,
725 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -0800726 }
727#endif
Kiran V1ccee932012-12-12 14:49:46 -0800728
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530729 limLog(pMac, LOG1,
730 FL("[TDLS] action %d (%s) -AP-> OTA peer="MAC_ADDRESS_STR),
731 SIR_MAC_TDLS_DIS_REQ,
732 limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ),
733 MAC_ADDR_ARRAY(peer_mac));
Kiran V1ccee932012-12-12 14:49:46 -0800734
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800735 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -0800736 HAL_TXRX_FRM_802_11_DATA,
737 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +0530738 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800739 limTxComplete, pFrame,
740 limMgmtTXComplete,
Masti, Narayanraddia12cce82016-02-02 14:10:01 +0530741 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME |
742 HAL_USE_PEER_STA_REQUESTED_MASK,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +0530743 pMac->lim.txBdToken++);
Kiran V1ccee932012-12-12 14:49:46 -0800744 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
745 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800746 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530747 limLog(pMac, LOGE, FL("could not send TDLS Discovery Request frame"));
Kiran V1ccee932012-12-12 14:49:46 -0800748 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -0800749 }
Ganesh Kondabattiniff987022015-08-11 19:43:44 +0530750 pMac->lim.mgmtFrameSessionId = psessionEntry->smeSessionId;
Kiran V1ccee932012-12-12 14:49:46 -0800751
752 return eSIR_SUCCESS;
753
754}
755
Kiran V1ccee932012-12-12 14:49:46 -0800756/*
Kiet Lam770920c2013-10-21 12:49:30 +0530757 * This static function is consistent with any kind of TDLS management
758 * frames we are sending. Currently it is being used by limSendTdlsDisRspFrame,
759 * limSendTdlsLinkSetupReqFrame and limSendTdlsSetupRspFrame
760 */
761static void PopulateDot11fTdlsHtVhtCap(tpAniSirGlobal pMac, uint32 selfDot11Mode,
762 tDot11fIEHTCaps *htCap, tDot11fIEVHTCaps *vhtCap,
763 tpPESession psessionEntry)
764{
765 if (IS_DOT11_MODE_HT(selfDot11Mode))
766 {
767 /* Include HT Capability IE */
768 PopulateDot11fHTCaps( pMac, NULL, htCap );
Ganesh Kondabattinib554d292015-02-11 14:37:25 +0530769 /* Advertize ht capability and max supported channel
770 * bandwidth when populating HT IE in TDLS Setup Request/
771 * Setup Response/Setup Confirmation frames.
772 * 11.21.6.2 Setting up a 40 MHz direct link: A 40 MHz off-channel
773 * direct link may be started if both TDLS peer STAs indicated
774 * 40 MHz support in the Supported Channel Width Set field of the
775 * HT Capabilities element (which is included in the TDLS Setup Request
776 * frame and the TDLS Setup Response frame). Switching to a 40 MHz
777 * off-channel direct link is achieved by including the following
778 * information in the TDLS Channel Switch Request
779 * 11.21.1 General: The channel width of the TDLS direct link on the
780 * base channel shall not exceed the channel width of the BSS to which
781 * the TDLS peer STAs are associated.*/
Kiet Lam770920c2013-10-21 12:49:30 +0530782 htCap->present = 1;
Ganesh Kondabattinib554d292015-02-11 14:37:25 +0530783 htCap->supportedChannelWidthSet = 1; // hardcode it to max
Kiet Lam770920c2013-10-21 12:49:30 +0530784 }
785 else
786 {
787 htCap->present = 0;
788 }
Ganesh Kondabattinib554d292015-02-11 14:37:25 +0530789 limLog(pMac, LOG1, FL("HT present = %hu, Chan Width = %hu"),
790 htCap->present, htCap->supportedChannelWidthSet);
Kiet Lam770920c2013-10-21 12:49:30 +0530791#ifdef WLAN_FEATURE_11AC
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530792 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
793 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
Kiet Lam770920c2013-10-21 12:49:30 +0530794 {
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +0530795 /* Include VHT Capability IE */
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530796 PopulateDot11fVHTCaps( pMac, vhtCap,
797 psessionEntry->currentOperChannel, eSIR_FALSE );
Kiet Lam770920c2013-10-21 12:49:30 +0530798 }
799 else
800 {
Kiet Lam770920c2013-10-21 12:49:30 +0530801 vhtCap->present = 0;
802 }
Ganesh Kondabattinib554d292015-02-11 14:37:25 +0530803 limLog(pMac, LOG1, FL("VHT present = %hu"),
804 vhtCap->present);
Kiet Lam770920c2013-10-21 12:49:30 +0530805#endif
806}
807
808/*
Kiran V1ccee932012-12-12 14:49:46 -0800809 * Send TDLS discovery response frame on direct link.
810 */
811
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +0530812static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac,
813 tSirMacAddr peerMac, tANI_U8 dialog,
814 tpPESession psessionEntry, tANI_U8 *addIe,
815 tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -0800816{
817 tDot11fTDLSDisRsp tdlsDisRsp ;
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +0530818 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -0800819 tANI_U32 status = 0 ;
820 tANI_U32 nPayload = 0 ;
821 tANI_U32 nBytes = 0 ;
822 tANI_U8 *pFrame;
823 void *pPacket;
824 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -0700825 uint32 selfDot11Mode;
826// Placeholder to support different channel bonding mode of TDLS than AP.
827// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
828// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
829// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
830// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -0800831
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +0530832 /*
Kiran V1ccee932012-12-12 14:49:46 -0800833 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
834 * and then hand it off to 'dot11fPackProbeRequest' (for
835 * serialization). We start by zero-initializing the structure:
836 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530837 vos_mem_set( ( tANI_U8* )&tdlsDisRsp,
838 sizeof( tDot11fTDLSDisRsp ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800839
840 /*
841 * setup Fixed fields,
842 */
843 tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
844 tdlsDisRsp.Action.action = SIR_MAC_TDLS_DIS_RSP ;
845 tdlsDisRsp.DialogToken.token = dialog ;
846
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +0530847 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier,
Kiran V1ccee932012-12-12 14:49:46 -0800848 peerMac, TDLS_RESPONDER) ;
849
850 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
851 {
852 /*
853 * Could not get Capabilities value
854 * from CFG. Log error.
855 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530856 limLog(pMac, LOGP, FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -0800857 }
858 swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
859
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +0530860 /* populate supported rate and ext supported rate IE */
861 if (eSIR_FAILURE == PopulateDot11fRatesTdls(pMac, &tdlsDisRsp.SuppRates,
Masti, Narayanraddicc203f62015-12-24 14:41:29 +0530862 &tdlsDisRsp.ExtSuppRates,
863 psessionEntry->currentOperChannel))
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +0530864 limLog(pMac, LOGE, FL("could not populate supported data rates"));
Kiran V1ccee932012-12-12 14:49:46 -0800865
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +0530866 /* Populate extended capability IE */
Kiran V1ccee932012-12-12 14:49:46 -0800867 PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
868
Hoonki Lee4ef946b2013-04-25 18:40:20 -0700869 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
870
Kiet Lam770920c2013-10-21 12:49:30 +0530871 /* Populate HT/VHT Capabilities */
872 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsDisRsp.HTCaps,
873 &tdlsDisRsp.VHTCaps, psessionEntry );
Kiran V1ccee932012-12-12 14:49:46 -0800874
Naresh Jayarambc62ba42014-02-12 21:39:14 +0530875 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
876 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
877 &tdlsDisRsp.SuppChannels,
878 &tdlsDisRsp.SuppOperatingClasses);
Agarwal Ashishb4891ef2014-11-10 20:08:36 +0530879
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530880 if (TRUE == pMac->lim.EnableTdls2040BSSCoexIE)
Agarwal Ashishb4891ef2014-11-10 20:08:36 +0530881 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530882 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
883 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24) )
884 {
885 tdlsDisRsp.HT2040BSSCoexistence.present = 1;
886 tdlsDisRsp.HT2040BSSCoexistence.infoRequest = 1;
887 }
Agarwal Ashishb4891ef2014-11-10 20:08:36 +0530888 }
Kiran V1ccee932012-12-12 14:49:46 -0800889 /*
890 * now we pack it. First, how much space are we going to need?
891 */
892 status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
893 if ( DOT11F_FAILED( status ) )
894 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530895 limLog(pMac, LOGE,
896 FL("Failed to calculate the packed size for a Discovery Response (0x%08x)."),
897 status);
Kiran V1ccee932012-12-12 14:49:46 -0800898 /* We'll fall back on the worst case scenario: */
899 nPayload = sizeof( tDot11fProbeRequest );
900 }
901 else if ( DOT11F_WARNED( status ) )
902 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530903 limLog(pMac, LOGW,
904 FL("There were warnings while calculating the packed size for a Discovery Response (0x%08x)."),
905 status);
Kiran V1ccee932012-12-12 14:49:46 -0800906 }
907
908 /*
909 * This frame is going out from PE as data frames with special ethertype
910 * 89-0d.
911 * 8 bytes of RFC 1042 header
912 */
913
914
Mahesh A Saptasagar53e9c1f2014-09-23 17:55:48 +0530915 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -0800916
917 /* Ok-- try to allocate memory from MGMT PKT pool */
918
919 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
920 ( tANI_U16 )nBytes, ( void** ) &pFrame,
921 ( void** ) &pPacket );
922 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
923 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530924 limLog(pMac, LOGE,
925 FL("Failed to allocate %d bytes for a TDLS Discovery Response."),
926 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -0800927 return eSIR_MEM_ALLOC_FAILED;
928 }
929
930 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530931 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -0800932
933 /*
934 * IE formation, memory allocation is completed, Now form TDLS discovery
935 * response frame
936 */
937
938 /* Make public Action Frame */
939
940#if 0
941 limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
942 SIR_MAC_MGMT_ACTION,
943 LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
944#endif
945 limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
946 SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
947
948 {
949 tpSirMacMgmtHdr pMacHdr;
950 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
951 pMacHdr->fc.toDS = ANI_TXDIR_IBSS;
952 pMacHdr->fc.powerMgmt = 0 ;
953 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
954 }
955
956#ifdef FEATURE_WLAN_TDLS_NEGATIVE
957 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
958 {
959 tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
960 tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad;
961 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -0800962 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Discovery Rsp"),
963 MAC_ADDR_ARRAY(tdlsDisRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -0800964 }
965#endif
966 status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame +
967 sizeof( tSirMacMgmtHdr ),
968 nPayload, &nPayload );
969
970 if ( DOT11F_FAILED( status ) )
971 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530972 limLog( pMac, LOGE,
973 FL("Failed to pack a TDLS Discovery Response (0x%08x)."),
974 status);
Kiran V1ccee932012-12-12 14:49:46 -0800975 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
976 ( void* ) pFrame, ( void* ) pPacket );
977 return eSIR_FAILURE;
978 }
979 else if ( DOT11F_WARNED( status ) )
980 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +0530981 limLog( pMac, LOGW,
982 FL("There were warnings while packing TDLS Discovery Request (0x%08x)."),
983 status);
Kiran V1ccee932012-12-12 14:49:46 -0800984 }
985
986#if 0
987 if(pMac->hal.pCBackFnTxComp == NULL)
988 {
989 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
990
991 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
992 {
993 status = eHAL_STATUS_FAILURE;
994 return status;
995
996 }
997 }
998#endif
Mahesh A Saptasagar53e9c1f2014-09-23 17:55:48 +0530999 if (0 != addIeLen)
1000 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301001 limLog(pMac, LOG1, FL("Copy Additional Ie Len = %d"), addIeLen);
Mahesh A Saptasagar53e9c1f2014-09-23 17:55:48 +05301002 vos_mem_copy(pFrame + sizeof(tSirMacMgmtHdr) + nPayload, addIe,
1003 addIeLen);
1004 }
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301005 limLog(pMac, LOG1,
1006 FL("[TDLS] action %d (%s) -DIRECT-> OTA peer="MAC_ADDRESS_STR),
1007 SIR_MAC_TDLS_DIS_RSP,
1008 limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP),
1009 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08001010
1011 /*
1012 * Transmit Discovery response and watch if this is delivered to
1013 * peer STA.
1014 */
1015 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1016 HAL_TXRX_FRM_802_11_DATA,
1017 ANI_TXDIR_IBSS,
1018 0,
1019 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001020 limMgmtTXComplete,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301021 HAL_USE_SELF_STA_REQUESTED_MASK,
1022 pMac->lim.txBdToken++);
Kiran V1ccee932012-12-12 14:49:46 -08001023 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1024 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001025 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301026 limLog(pMac, LOGE, FL("could not send TDLS Discovery Response frame!"));
Kiran V1ccee932012-12-12 14:49:46 -08001027 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001028 }
Ganesh Kondabattiniff987022015-08-11 19:43:44 +05301029 pMac->lim.mgmtFrameSessionId = psessionEntry->smeSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001030
1031 return eSIR_SUCCESS;
1032
1033}
1034
1035/*
Kiet Lam770920c2013-10-21 12:49:30 +05301036 * This static function is currently used by limSendTdlsLinkSetupReqFrame and
1037 * limSendTdlsSetupRspFrame to populate the AID if device is 11ac capable.
1038 */
1039static void PopulateDotfTdlsVhtAID(tpAniSirGlobal pMac, uint32 selfDot11Mode,
1040 tSirMacAddr peerMac, tDot11fIEAID *Aid,
1041 tpPESession psessionEntry)
1042{
1043 if (((psessionEntry->currentOperChannel <= SIR_11B_CHANNEL_END) &&
1044 pMac->roam.configParam.enableVhtFor24GHz) ||
1045 (psessionEntry->currentOperChannel >= SIR_11B_CHANNEL_END))
1046 {
1047 if (IS_DOT11_MODE_VHT(selfDot11Mode) &&
1048 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
1049 {
1050
1051 tANI_U16 aid;
1052 tpDphHashNode pStaDs;
1053
1054 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
1055 if (NULL != pStaDs)
1056 {
1057 Aid->present = 1;
1058 Aid->assocId = aid | LIM_AID_MASK; // set bit 14 and 15 1's
1059 }
1060 else
1061 {
1062 Aid->present = 0;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301063 limLog(pMac, LOGE, FL("pStaDs is NULL for " MAC_ADDRESS_STR),
1064 MAC_ADDR_ARRAY(peerMac));
Kiet Lam770920c2013-10-21 12:49:30 +05301065 }
1066 }
1067 }
1068 else
1069 {
1070 Aid->present = 0;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301071 limLog(pMac, LOGW, FL("Vht not enable from ini for 2.4GHz."));
Kiet Lam770920c2013-10-21 12:49:30 +05301072 }
1073}
1074
1075/*
Kiran V1ccee932012-12-12 14:49:46 -08001076 * TDLS setup Request frame on AP link
1077 */
1078
1079tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
1080 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301081 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001082{
1083 tDot11fTDLSSetupReq tdlsSetupReq ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301084 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001085 tANI_U32 status = 0 ;
1086 tANI_U32 nPayload = 0 ;
1087 tANI_U32 nBytes = 0 ;
1088 tANI_U32 header_offset = 0 ;
1089 tANI_U8 *pFrame;
1090 void *pPacket;
1091 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001092 uint32 selfDot11Mode;
Agarwal Ashish16020c42014-12-29 22:01:11 +05301093 tpSirMacCapabilityInfo pCapInfo;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001094// Placeholder to support different channel bonding mode of TDLS than AP.
1095// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1096// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1097// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1098// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001099
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301100 /*
Kiran V1ccee932012-12-12 14:49:46 -08001101 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1102 * and then hand it off to 'dot11fPackProbeRequest' (for
1103 * serialization). We start by zero-initializing the structure:
1104 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301105 vos_mem_set(( tANI_U8* )&tdlsSetupReq, sizeof( tDot11fTDLSSetupReq ), 0);
Kiran V1ccee932012-12-12 14:49:46 -08001106 tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
1107 tdlsSetupReq.Action.action = SIR_MAC_TDLS_SETUP_REQ ;
1108 tdlsSetupReq.DialogToken.token = dialog ;
1109
1110
1111 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
1112 peerMac, TDLS_INITIATOR) ;
1113
1114 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1115 {
1116 /*
1117 * Could not get Capabilities value
1118 * from CFG. Log error.
1119 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301120 limLog(pMac, LOGE, FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001121 }
Agarwal Ashish16020c42014-12-29 22:01:11 +05301122
1123 pCapInfo = (tpSirMacCapabilityInfo) &caps;
1124 /* Export QOS capability */
1125 pCapInfo->qos = 1;
1126
Kiran V1ccee932012-12-12 14:49:46 -08001127 swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
1128
Masti, Narayanraddicc203f62015-12-24 14:41:29 +05301129 limLog(pMac, LOG1, FL("Sending operating channel %d and dotl11mode %d\n"),
1130 psessionEntry->currentOperChannel,
1131 psessionEntry->dot11mode);
1132
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301133 /* populate supported rate and ext supported rate IE */
1134 PopulateDot11fRatesTdls(pMac, &tdlsSetupReq.SuppRates,
Masti, Narayanraddicc203f62015-12-24 14:41:29 +05301135 &tdlsSetupReq.ExtSuppRates,
1136 psessionEntry->currentOperChannel);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301137
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301138 /* Populate extended capability IE */
Kiran V1ccee932012-12-12 14:49:46 -08001139 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
1140
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301141 if ( 1 == pMac->lim.gLimTDLSWmmMode )
1142 {
Pradeep Reddy POTTETIf0f5fca2015-02-28 13:22:35 +05301143 tANI_U32 val = 0;
1144
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301145 /* include WMM IE */
Pradeep Reddy POTTETIf0f5fca2015-02-28 13:22:35 +05301146 tdlsSetupReq.WMMInfoStation.version = SIR_MAC_OUI_VERSION_1;
1147 tdlsSetupReq.WMMInfoStation.acvo_uapsd =
1148 (pMac->lim.gLimTDLSUapsdMask & 0x01);
1149 tdlsSetupReq.WMMInfoStation.acvi_uapsd =
1150 ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1151 tdlsSetupReq.WMMInfoStation.acbk_uapsd =
1152 ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1153 tdlsSetupReq.WMMInfoStation.acbe_uapsd =
1154 ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1155
1156 if(wlan_cfgGetInt(pMac, WNI_CFG_MAX_SP_LENGTH, &val) != eSIR_SUCCESS)
Sushant Kaushik87787972015-09-11 16:05:00 +05301157 limLog(pMac, LOGE, FL("could not retrieve Max SP Length"));
Pradeep Reddy POTTETIf0f5fca2015-02-28 13:22:35 +05301158
1159 tdlsSetupReq.WMMInfoStation.max_sp_length = (tANI_U8)val;
1160 tdlsSetupReq.WMMInfoStation.present = 1;
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301161 }
1162 else
1163 {
1164 /*
1165 * TODO: we need to see if we have to support conditions where we have
1166 * EDCA parameter info element is needed a) if we need different QOS
1167 * parameters for off channel operations or QOS is not supported on
1168 * AP link and we wanted to QOS on direct link.
1169 */
1170 /* Populate QOS info, needed for Peer U-APSD session */
1171 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1172 TDLS doesn't want to depend on AP's capability */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301173 limLog(pMac, LOG1, FL("populate QOS IE in Setup Request Frame"));
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301174 tdlsSetupReq.QOSCapsStation.present = 1;
1175 tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
1176 tdlsSetupReq.QOSCapsStation.qack = 0;
1177 tdlsSetupReq.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1178 tdlsSetupReq.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1179 tdlsSetupReq.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1180 tdlsSetupReq.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1181 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301182
Kiran V1ccee932012-12-12 14:49:46 -08001183 /*
1184 * we will always try to init TDLS link with 11n capabilities
1185 * let TDLS setup response to come, and we will set our caps based
1186 * of peer caps
1187 */
1188
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001189 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1190
Kiet Lam770920c2013-10-21 12:49:30 +05301191 /* Populate HT/VHT Capabilities */
1192 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupReq.HTCaps,
1193 &tdlsSetupReq.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001194
Kiet Lam770920c2013-10-21 12:49:30 +05301195 /* Populate AID */
1196 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1197 &tdlsSetupReq.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001198
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301199 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1200 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1201 &tdlsSetupReq.SuppChannels,
1202 &tdlsSetupReq.SuppOperatingClasses);
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301203
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05301204 if (TRUE == pMac->lim.EnableTdls2040BSSCoexIE)
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301205 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05301206 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
1207 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24))
1208 {
1209 tdlsSetupReq.HT2040BSSCoexistence.present = 1;
1210 tdlsSetupReq.HT2040BSSCoexistence.infoRequest = 1;
1211 }
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301212 }
1213
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301214 /*
Kiran V1ccee932012-12-12 14:49:46 -08001215 * now we pack it. First, how much space are we going to need?
1216 */
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301217 status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq,
Kiran V1ccee932012-12-12 14:49:46 -08001218 &nPayload);
1219 if ( DOT11F_FAILED( status ) )
1220 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301221 limLog(pMac, LOGE,
1222 FL("Failed to calculate the packed size for a Setup Request (0x%08x)."),
1223 status);
Kiran V1ccee932012-12-12 14:49:46 -08001224 /* We'll fall back on the worst case scenario: */
1225 nPayload = sizeof( tDot11fProbeRequest );
1226 }
1227 else if ( DOT11F_WARNED( status ) )
1228 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301229 limLog(pMac, LOGW,
1230 FL("There were warnings while calculating the packed size for a Setup Request (0x%08x)."),
1231 status);
Kiran V1ccee932012-12-12 14:49:46 -08001232 }
1233
1234
1235 /*
1236 * This frame is going out from PE as data frames with special ethertype
1237 * 89-0d.
1238 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301239 */
Kiran V1ccee932012-12-12 14:49:46 -08001240
1241
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301242 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1243 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1244 + sizeof( eth_890d_header )
1245 + PAYLOAD_TYPE_TDLS_SIZE
1246 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001247
1248 /* Ok-- try to allocate memory from MGMT PKT pool */
1249
1250 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301251 ( tANI_U16 )nBytes, ( void** ) &pFrame,
Kiran V1ccee932012-12-12 14:49:46 -08001252 ( void** ) &pPacket );
1253 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1254 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301255 limLog(pMac, LOGE,
1256 FL("Failed to allocate %d bytes for a TDLS Setup Request."),
1257 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001258 return eSIR_MEM_ALLOC_FAILED;
1259 }
1260
1261 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301262 vos_mem_set( pFrame, nBytes, 0);
Kiran V1ccee932012-12-12 14:49:46 -08001263
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301264 /*
Kiran V1ccee932012-12-12 14:49:46 -08001265 * IE formation, memory allocation is completed, Now form TDLS discovery
1266 * request frame
1267 */
1268
1269 /* fill out the buffer descriptor */
1270
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301271 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
Pradeep Reddy POTTETI6f2c9bb2015-07-16 14:57:36 +05301272 LINK_IDEN_ADDR_OFFSET(tdlsSetupReq),
1273 TDLS_LINK_AP, TDLS_INITIATOR,
1274 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001275
1276#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1277 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
1278 {
1279 tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301280 tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad;
1281 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001282 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Req"),
1283 MAC_ADDR_ARRAY(tdlsSetupReq.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001284 }
1285#endif
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301286 limLog( pMac, LOGW, FL("SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1287 tdlsSetupReq.VHTCaps.supportedChannelWidthSet,
1288 tdlsSetupReq.VHTCaps.rxMCSMap,
1289 tdlsSetupReq.VHTCaps.txMCSMap,
1290 tdlsSetupReq.VHTCaps.txSupDataRate);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07001291
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301292 status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001293 + header_offset, nPayload, &nPayload );
1294
1295 if ( DOT11F_FAILED( status ) )
1296 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301297 limLog(pMac, LOGE,
1298 FL("Failed to pack a TDLS Setup Request (0x%08x)."),
1299 status);
Kiran V1ccee932012-12-12 14:49:46 -08001300 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1301 ( void* ) pFrame, ( void* ) pPacket );
1302 return eSIR_FAILURE;
1303 }
1304 else if ( DOT11F_WARNED( status ) )
1305 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301306 limLog(pMac, LOGW,
1307 FL("There were warnings while packing TDLS Setup Request (0x%08x)."),
1308 status);
Kiran V1ccee932012-12-12 14:49:46 -08001309 }
1310
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301311 //Copy the additional IE.
Kiran V1ccee932012-12-12 14:49:46 -08001312 //TODO : addIe is added at the end of the frame. This means it doesnt
1313 //follow the order. This should be ok, but we should consider changing this
1314 //if there is any IOT issue.
1315 if( addIeLen != 0 )
1316 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301317 limLog(pMac, LOG1, FL("Copy Additional Ie Len = %d"),
1318 addIeLen);
1319 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001320 }
1321
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301322 limLog(pMac, LOG1, FL("[TDLS] action %d (%s) -AP-> OTA peer="MAC_ADDRESS_STR),
1323 SIR_MAC_TDLS_SETUP_REQ,
1324 limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ),
1325 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08001326
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001327 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001328 HAL_TXRX_FRM_802_11_DATA,
1329 ANI_TXDIR_TODS,
Pradeep Reddy POTTETI01710062015-06-29 13:35:53 +05301330 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001331 limTxComplete, pFrame,
1332 limMgmtTXComplete,
Masti, Narayanraddia12cce82016-02-02 14:10:01 +05301333 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME |
1334 HAL_USE_PEER_STA_REQUESTED_MASK,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301335 pMac->lim.txBdToken++);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001336
Kiran V1ccee932012-12-12 14:49:46 -08001337 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1338 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001339 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301340 limLog(pMac, LOGE, FL("could not send TDLS Setup Request frame!"));
Kiran V1ccee932012-12-12 14:49:46 -08001341 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001342 }
Ganesh Kondabattiniff987022015-08-11 19:43:44 +05301343 pMac->lim.mgmtFrameSessionId = psessionEntry->smeSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001344
1345 return eSIR_SUCCESS;
1346
1347}
1348/*
1349 * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
1350 */
1351
1352tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08001353 tSirMacAddr peerMac, tANI_U16 reason, tANI_U8 responder, tpPESession psessionEntry,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301354 tANI_U8 *addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001355{
1356 tDot11fTDLSTeardown teardown ;
1357 tANI_U32 status = 0 ;
1358 tANI_U32 nPayload = 0 ;
1359 tANI_U32 nBytes = 0 ;
1360 tANI_U32 header_offset = 0 ;
1361 tANI_U8 *pFrame;
1362 void *pPacket;
1363 eHalStatus halstatus;
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001364#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1365 tANI_U32 padLen = 0;
1366#endif
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +05301367 tpDphHashNode pStaDs = NULL;
1368 tANI_U16 aid = 0;
1369 tANI_U8 qosMode = 0;
1370 tANI_U8 tdlsLinkType = 0;
1371
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301372 /*
Kiran V1ccee932012-12-12 14:49:46 -08001373 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1374 * and then hand it off to 'dot11fPackProbeRequest' (for
1375 * serialization). We start by zero-initializing the structure:
1376 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301377 vos_mem_set( ( tANI_U8* )&teardown, sizeof( tDot11fTDLSTeardown ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001378 teardown.Category.category = SIR_MAC_ACTION_TDLS ;
1379 teardown.Action.action = SIR_MAC_TDLS_TEARDOWN ;
1380 teardown.Reason.code = reason ;
1381
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301382 PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier,
Hoonki Leea34dd892013-02-05 22:56:02 -08001383 peerMac, (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301384 /*
Kiran V1ccee932012-12-12 14:49:46 -08001385 * now we pack it. First, how much space are we going to need?
1386 */
1387 status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
1388 if ( DOT11F_FAILED( status ) )
1389 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301390 limLog(pMac, LOGE,
1391 FL("Failed to calculate the packed size for Teardown frame (0x%08x)."),
1392 status);
Kiran V1ccee932012-12-12 14:49:46 -08001393 /* We'll fall back on the worst case scenario: */
1394 nPayload = sizeof( tDot11fProbeRequest );
1395 }
1396 else if ( DOT11F_WARNED( status ) )
1397 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301398 limLog(pMac, LOGW,
1399 FL("There were warnings while calculating the packed size for Teardown frame (0x%08x)."),
1400 status);
Kiran V1ccee932012-12-12 14:49:46 -08001401 }
Kiran V1ccee932012-12-12 14:49:46 -08001402 /*
1403 * This frame is going out from PE as data frames with special ethertype
1404 * 89-0d.
1405 * 8 bytes of RFC 1042 header
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301406 */
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +05301407 pStaDs = dphLookupHashEntry(pMac, peerMac, &aid,
1408 &psessionEntry->dph.dphHashTable);
1409 if (pStaDs)
1410 {
1411 qosMode = pStaDs->qosMode;
1412 }
1413 tdlsLinkType = (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
1414 ? TDLS_LINK_AP : TDLS_LINK_DIRECT;
1415 nBytes = nPayload + (((IS_QOS_ENABLED(psessionEntry) &&
1416 (tdlsLinkType == TDLS_LINK_AP)) ||
1417 ((tdlsLinkType == TDLS_LINK_DIRECT) && qosMode))
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301418 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1419 + sizeof( eth_890d_header )
1420 + PAYLOAD_TYPE_TDLS_SIZE
1421 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001422
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001423#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1424 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1425 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1426 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1427 */
1428 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1429 {
1430 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1431
1432 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1433 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1434 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1435
1436 nBytes += padLen;
1437 }
1438#endif
1439
Kiran V1ccee932012-12-12 14:49:46 -08001440 /* Ok-- try to allocate memory from MGMT PKT pool */
1441
1442 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1443 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1444 ( void** ) &pPacket );
1445 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1446 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301447 limLog(pMac, LOGE,
1448 FL("Failed to allocate %d bytes for a TDLS Teardown Frame."),
1449 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001450 return eSIR_MEM_ALLOC_FAILED;
1451 }
1452
1453 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301454 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001455
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301456 /*
Kiran V1ccee932012-12-12 14:49:46 -08001457 * IE formation, memory allocation is completed, Now form TDLS discovery
1458 * request frame
1459 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301460 limLog(pMac, LOGE, FL("Reason of TDLS Teardown: %d"), reason);
Kiran V1ccee932012-12-12 14:49:46 -08001461 /* fill out the buffer descriptor */
1462
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301463 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1464 LINK_IDEN_ADDR_OFFSET(teardown),
1465 (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE)
Gopichand Nakkala269032c2013-02-07 17:18:15 -08001466 ? TDLS_LINK_AP : TDLS_LINK_DIRECT,
1467 (responder == TRUE) ? TDLS_RESPONDER : TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301468 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001469
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301470 status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame
Kiran V1ccee932012-12-12 14:49:46 -08001471 + header_offset, nPayload, &nPayload );
1472
1473 if ( DOT11F_FAILED( status ) )
1474 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001475 limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req (0x%08x)."),
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301476 status);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301477 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
Kiran V1ccee932012-12-12 14:49:46 -08001478 ( void* ) pFrame, ( void* ) pPacket );
1479 return eSIR_FAILURE;
1480 }
1481 else if ( DOT11F_WARNED( status ) )
1482 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301483 limLog(pMac, LOGW, FL("There were warnings while packing TDLS Teardown frame (0x%08x)."),
1484 status);
Kiran V1ccee932012-12-12 14:49:46 -08001485 }
1486#if 0
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301487 if(pMac->hal.pCBackFnTxComp == NULL)
Kiran V1ccee932012-12-12 14:49:46 -08001488 {
1489 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301490 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
Kiran V1ccee932012-12-12 14:49:46 -08001491 {
1492 status = eHAL_STATUS_FAILURE;
1493 return status;
1494
1495 }
1496 }
1497 else
1498 {
1499 VOS_ASSERT(0) ;
1500 return status ;
1501 }
1502#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301503
Kiran V1ccee932012-12-12 14:49:46 -08001504 if( addIeLen != 0 )
1505 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301506 limLog(pMac, LOG1, FL("Copy Additional Ie Len = %d"), addIeLen);
1507 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001508 }
1509
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001510#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1511 if (padLen != 0)
1512 {
1513 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
1514 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
1515 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
1516 padVendorSpecific[0] = 221;
1517 padVendorSpecific[1] = padLen - 2;
1518 padVendorSpecific[2] = 0x00;
1519 padVendorSpecific[3] = 0xA0;
1520 padVendorSpecific[4] = 0xC6;
1521
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301522 limLog(pMac, LOG1, FL("Padding Vendor Specific Ie Len = %d"), padLen);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001523
1524 /* padding zero if more than 5 bytes are required */
1525 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301526 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
1527 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee6c6822a2013-02-06 14:10:46 -08001528 }
1529#endif
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301530 limLog(pMac, LOG1, FL("[TDLS] action %d (%s) -%s-> OTA peer="MAC_ADDRESS_STR),
1531 SIR_MAC_TDLS_TEARDOWN,
1532 limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN),
1533 ((reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) ?
1534 "AP": "DIRECT"),
1535 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08001536
1537 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1538 HAL_TXRX_FRM_802_11_DATA,
1539 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301540 TID_AC_VI,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301541 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001542 limMgmtTXComplete,
Masti, Narayanraddia12cce82016-02-02 14:10:01 +05301543 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME |
1544 HAL_USE_PEER_STA_REQUESTED_MASK,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301545 pMac->lim.txBdToken++);
Kiran V1ccee932012-12-12 14:49:46 -08001546 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1547 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001548 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301549 limLog(pMac, LOGE, FL("could not send TDLS Teardown frame"));
Kiran V1ccee932012-12-12 14:49:46 -08001550 return eSIR_FAILURE;
1551
1552 }
Ganesh Kondabattiniff987022015-08-11 19:43:44 +05301553 pMac->lim.mgmtFrameSessionId = psessionEntry->smeSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001554 return eSIR_SUCCESS;
1555
1556}
1557
1558/*
1559 * Send Setup RSP frame on AP link.
1560 */
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301561static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac,
1562 tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08001563 etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
1564{
1565 tDot11fTDLSSetupRsp tdlsSetupRsp ;
1566 tANI_U32 status = 0 ;
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301567 tANI_U16 caps = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08001568 tANI_U32 nPayload = 0 ;
1569 tANI_U32 header_offset = 0 ;
1570 tANI_U32 nBytes = 0 ;
1571 tANI_U8 *pFrame;
1572 void *pPacket;
1573 eHalStatus halstatus;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001574 uint32 selfDot11Mode;
Agarwal Ashish16020c42014-12-29 22:01:11 +05301575 tpSirMacCapabilityInfo pCapInfo;
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001576// Placeholder to support different channel bonding mode of TDLS than AP.
1577// Today, WNI_CFG_CHANNEL_BONDING_MODE will be overwritten when connecting to AP
1578// To support this feature, we need to introduce WNI_CFG_TDLS_CHANNEL_BONDING_MODE
1579// As of now, we hardcoded to max channel bonding of dot11Mode (i.e HT80 for 11ac/HT40 for 11n)
1580// uint32 tdlsChannelBondingMode;
Kiran V1ccee932012-12-12 14:49:46 -08001581
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301582 /*
Kiran V1ccee932012-12-12 14:49:46 -08001583 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1584 * and then hand it off to 'dot11fPackProbeRequest' (for
1585 * serialization). We start by zero-initializing the structure:
1586 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301587 vos_mem_set( ( tANI_U8* )&tdlsSetupRsp, sizeof( tDot11fTDLSSetupRsp ),0 );
Kiran V1ccee932012-12-12 14:49:46 -08001588
1589 /*
1590 * setup Fixed fields,
1591 */
1592 tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
1593 tdlsSetupRsp.Action.action = SIR_MAC_TDLS_SETUP_RSP ;
1594 tdlsSetupRsp.DialogToken.token = dialog;
1595
1596 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
1597 peerMac, TDLS_RESPONDER) ;
1598
1599 if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
1600 {
1601 /*
1602 * Could not get Capabilities value
1603 * from CFG. Log error.
1604 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301605 limLog(pMac, LOGE, FL("could not retrieve Capabilities value"));
Kiran V1ccee932012-12-12 14:49:46 -08001606 }
Agarwal Ashish16020c42014-12-29 22:01:11 +05301607
1608 pCapInfo = (tpSirMacCapabilityInfo) &caps;
1609 /* Export QoS capability */
1610 pCapInfo->qos = 1;
1611
Kiran V1ccee932012-12-12 14:49:46 -08001612 swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
1613
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301614 /* populate supported rate and ext supported rate IE */
1615 PopulateDot11fRatesTdls(pMac, &tdlsSetupRsp.SuppRates,
Masti, Narayanraddicc203f62015-12-24 14:41:29 +05301616 &tdlsSetupRsp.ExtSuppRates,
1617 psessionEntry->currentOperChannel);
Kiran V1ccee932012-12-12 14:49:46 -08001618
Masti, Narayanraddi4b359dd2015-02-03 15:49:29 +05301619 /* Populate extended capability IE */
Kiran V1ccee932012-12-12 14:49:46 -08001620 PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
1621
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301622 if ( 1 == pMac->lim.gLimTDLSWmmMode )
1623 {
Pradeep Reddy POTTETIf0f5fca2015-02-28 13:22:35 +05301624 tANI_U32 val = 0;
1625
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301626 /* include WMM IE */
Pradeep Reddy POTTETIf0f5fca2015-02-28 13:22:35 +05301627 tdlsSetupRsp.WMMInfoStation.version = SIR_MAC_OUI_VERSION_1;
1628 tdlsSetupRsp.WMMInfoStation.acvo_uapsd =
1629 (pMac->lim.gLimTDLSUapsdMask & 0x01);
1630 tdlsSetupRsp.WMMInfoStation.acvi_uapsd =
1631 ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1632 tdlsSetupRsp.WMMInfoStation.acbk_uapsd =
1633 ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1634 tdlsSetupRsp.WMMInfoStation.acbe_uapsd =
1635 ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1636
1637 if(wlan_cfgGetInt(pMac, WNI_CFG_MAX_SP_LENGTH, &val) != eSIR_SUCCESS)
Sushant Kaushik87787972015-09-11 16:05:00 +05301638 limLog(pMac, LOGE, FL("could not retrieve Max SP Length"));
Pradeep Reddy POTTETIf0f5fca2015-02-28 13:22:35 +05301639
1640 tdlsSetupRsp.WMMInfoStation.max_sp_length = (tANI_U8)val;
1641 tdlsSetupRsp.WMMInfoStation.present = 1;
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301642 }
1643 else
1644 {
1645 /*
1646 * TODO: we need to see if we have to support conditions where we have
1647 * EDCA parameter info element is needed a) if we need different QOS
1648 * parameters for off channel operations or QOS is not supported on
1649 * AP link and we wanted to QOS on direct link.
1650 */
1651 /* Populate QOS info, needed for Peer U-APSD session */
1652 /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
1653 TDLS doesn't want to depend on AP's capability */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301654 limLog(pMac, LOG1, FL("populate QOS IE in Setup Response frame"));
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301655 tdlsSetupRsp.QOSCapsStation.present = 1;
1656 tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
1657 tdlsSetupRsp.QOSCapsStation.qack = 0;
1658 tdlsSetupRsp.QOSCapsStation.acbe_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x08) >> 3);
1659 tdlsSetupRsp.QOSCapsStation.acbk_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x04) >> 2);
1660 tdlsSetupRsp.QOSCapsStation.acvi_uapsd = ((pMac->lim.gLimTDLSUapsdMask & 0x02) >> 1);
1661 tdlsSetupRsp.QOSCapsStation.acvo_uapsd = (pMac->lim.gLimTDLSUapsdMask & 0x01);
1662 }
Kiran V1ccee932012-12-12 14:49:46 -08001663
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001664 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfDot11Mode);
1665
Kiet Lam770920c2013-10-21 12:49:30 +05301666 /* Populate HT/VHT Capabilities */
1667 PopulateDot11fTdlsHtVhtCap( pMac, selfDot11Mode, &tdlsSetupRsp.HTCaps,
1668 &tdlsSetupRsp.VHTCaps, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001669
Kiet Lam770920c2013-10-21 12:49:30 +05301670 /* Populate AID */
1671 PopulateDotfTdlsVhtAID( pMac, selfDot11Mode, peerMac,
1672 &tdlsSetupRsp.AID, psessionEntry );
Hoonki Lee4ef946b2013-04-25 18:40:20 -07001673
Naresh Jayarambc62ba42014-02-12 21:39:14 +05301674 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled )
1675 PopulateDot11fTdlsOffchannelParams( pMac, psessionEntry,
1676 &tdlsSetupRsp.SuppChannels,
1677 &tdlsSetupRsp.SuppOperatingClasses);
1678
Kiran V1ccee932012-12-12 14:49:46 -08001679 tdlsSetupRsp.Status.status = setupStatus ;
1680
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05301681 if (TRUE == pMac->lim.EnableTdls2040BSSCoexIE)
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301682 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05301683 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
1684 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24))
1685 {
1686 tdlsSetupRsp.HT2040BSSCoexistence.present = 1;
1687 tdlsSetupRsp.HT2040BSSCoexistence.infoRequest = 1;
1688 }
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301689 }
Kiran V1ccee932012-12-12 14:49:46 -08001690 /*
1691 * now we pack it. First, how much space are we going to need?
1692 */
1693 status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp,
1694 &nPayload);
1695 if ( DOT11F_FAILED( status ) )
1696 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301697 limLog(pMac, LOGE,
1698 FL("Failed to calculate the packed size for a Setup Response (0x%08x)."),
1699 status);
Kiran V1ccee932012-12-12 14:49:46 -08001700 /* We'll fall back on the worst case scenario: */
1701 nPayload = sizeof( tDot11fProbeRequest );
1702 }
1703 else if ( DOT11F_WARNED( status ) )
1704 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301705 limLog(pMac, LOGW,
1706 FL("There were warnings while calculating the packed size for Setup Response (0x%08x)."),
1707 status);
Kiran V1ccee932012-12-12 14:49:46 -08001708 }
1709
1710 /*
1711 * This frame is going out from PE as data frames with special ethertype
1712 * 89-0d.
1713 * 8 bytes of RFC 1042 header
1714 */
1715
1716
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301717 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1718 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1719 + sizeof( eth_890d_header )
1720 + PAYLOAD_TYPE_TDLS_SIZE
1721 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001722
1723 /* Ok-- try to allocate memory from MGMT PKT pool */
1724
1725 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1726 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1727 ( void** ) &pPacket );
1728 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1729 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301730 limLog(pMac, LOGE,
1731 FL("Failed to allocate %d bytes for a TDLS Setup Response."),
1732 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001733 return eSIR_MEM_ALLOC_FAILED;
1734 }
1735
1736 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301737 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001738
1739 /*
1740 * IE formation, memory allocation is completed, Now form TDLS discovery
1741 * request frame
1742 */
1743
1744 /* fill out the buffer descriptor */
1745
1746 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1747 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp),
1748 TDLS_LINK_AP, TDLS_RESPONDER,
Pradeep Reddy POTTETI6f2c9bb2015-07-16 14:57:36 +05301749 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001750
1751#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1752 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
1753 {
1754 tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
1755 tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad;
1756 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001757 ("TDLS negative running: wrong BSSID " MAC_ADDRESS_STR " in TDLS Setup Rsp"),
1758 MAC_ADDR_ARRAY(tdlsSetupRsp.LinkIdentifier.bssid));
Kiran V1ccee932012-12-12 14:49:46 -08001759 }
1760#endif
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301761 limLog(pMac, LOG1,
1762 FL("SupportedChnlWidth %x rxMCSMap %x rxMCSMap %x txSupDataRate %x"),
1763 tdlsSetupRsp.VHTCaps.supportedChannelWidthSet,
1764 tdlsSetupRsp.VHTCaps.rxMCSMap,
1765 tdlsSetupRsp.VHTCaps.txMCSMap,
1766 tdlsSetupRsp.VHTCaps.txSupDataRate);
Kiran V1ccee932012-12-12 14:49:46 -08001767 status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame
1768 + header_offset, nPayload, &nPayload );
1769
1770 if ( DOT11F_FAILED( status ) )
1771 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301772 limLog(pMac, LOGE, FL("Failed to pack a TDLS Setup Response (0x%08x)."),
1773 status);
Kiran V1ccee932012-12-12 14:49:46 -08001774 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1775 ( void* ) pFrame, ( void* ) pPacket );
1776 return eSIR_FAILURE;
1777 }
1778 else if ( DOT11F_WARNED( status ) )
1779 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301780 limLog(pMac, LOGW,
1781 FL("There were warnings while packing TDLS Setup Response (0x%08x)."),
1782 status);
Kiran V1ccee932012-12-12 14:49:46 -08001783 }
1784
1785 //Copy the additional IE.
1786 //TODO : addIe is added at the end of the frame. This means it doesnt
1787 //follow the order. This should be ok, but we should consider changing this
1788 //if there is any IOT issue.
1789 if( addIeLen != 0 )
1790 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301791 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08001792 }
1793
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301794 limLog(pMac, LOG1,
1795 FL("[TDLS] action %d (%s) -AP-> OTA peer="MAC_ADDRESS_STR),
1796 SIR_MAC_TDLS_SETUP_RSP,
1797 limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP),
1798 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08001799
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001800 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
Kiran V1ccee932012-12-12 14:49:46 -08001801 HAL_TXRX_FRM_802_11_DATA,
1802 ANI_TXDIR_TODS,
1803 //ANI_TXDIR_IBSS,
Pradeep Reddy POTTETI01710062015-06-29 13:35:53 +05301804 TID_AC_VI,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001805 limTxComplete, pFrame,
1806 limMgmtTXComplete,
Masti, Narayanraddia12cce82016-02-02 14:10:01 +05301807 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME |
1808 HAL_USE_PEER_STA_REQUESTED_MASK,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05301809 pMac->lim.txBdToken++);
Kiran V1ccee932012-12-12 14:49:46 -08001810 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1811 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001812 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301813 limLog(pMac, LOGE, FL("could not send TDLS Setup Response"));
Kiran V1ccee932012-12-12 14:49:46 -08001814 return eSIR_FAILURE;
Kiran V1ccee932012-12-12 14:49:46 -08001815 }
Ganesh Kondabattiniff987022015-08-11 19:43:44 +05301816 pMac->lim.mgmtFrameSessionId = psessionEntry->smeSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08001817
1818 return eSIR_SUCCESS;
1819
1820}
1821
1822/*
1823 * Send TDLS setup CNF frame on AP link
1824 */
1825
1826tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301827 tANI_U8 dialog, tANI_U32 peerCapability, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)
Kiran V1ccee932012-12-12 14:49:46 -08001828{
1829 tDot11fTDLSSetupCnf tdlsSetupCnf ;
1830 tANI_U32 status = 0 ;
1831 tANI_U32 nPayload = 0 ;
1832 tANI_U32 nBytes = 0 ;
1833 tANI_U32 header_offset = 0 ;
1834 tANI_U8 *pFrame;
1835 void *pPacket;
1836 eHalStatus halstatus;
Hoonki Lee426f0302013-02-08 17:35:38 -08001837#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1838 tANI_U32 padLen = 0;
1839#endif
Kiran V1ccee932012-12-12 14:49:46 -08001840
1841 /*
1842 * The scheme here is to fill out a 'tDot11fProbeRequest' structure
1843 * and then hand it off to 'dot11fPackProbeRequest' (for
1844 * serialization). We start by zero-initializing the structure:
1845 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301846 vos_mem_set( ( tANI_U8* )&tdlsSetupCnf, sizeof( tDot11fTDLSSetupCnf ), 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001847
1848 /*
1849 * setup Fixed fields,
1850 */
1851 tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
1852 tdlsSetupCnf.Action.action = SIR_MAC_TDLS_SETUP_CNF ;
1853 tdlsSetupCnf.DialogToken.token = dialog ;
1854
Kiran V1ccee932012-12-12 14:49:46 -08001855 PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
1856 peerMac, TDLS_INITIATOR) ;
Kiran V1ccee932012-12-12 14:49:46 -08001857
1858 /*
1859 * TODO: we need to see if we have to support conditions where we have
1860 * EDCA parameter info element is needed a) if we need different QOS
1861 * parameters for off channel operations or QOS is not supported on
1862 * AP link and we wanted to QOS on direct link.
1863 */
1864
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301865 /* Check self and peer WMM capable */
1866 if ((1 == pMac->lim.gLimTDLSWmmMode) && (CHECK_BIT(peerCapability, TDLS_PEER_WMM_CAP)))
1867 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301868 limLog(pMac, LOG1, FL("populate WMM praram in Setup Confirm"));
Pradeep Reddy POTTETIa9c80d52014-05-09 18:05:29 +05301869 PopulateDot11fWMMParams(pMac, &tdlsSetupCnf.WMMParams, psessionEntry);
1870 }
1871
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301872 /* Check peer is VHT capable*/
1873 if (CHECK_BIT(peerCapability, TDLS_PEER_VHT_CAP))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001874 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301875 PopulateDot11fVHTOperation( pMac, &tdlsSetupCnf.VHTOperation,
1876 psessionEntry->currentOperChannel);
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301877 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001878 }
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301879 else if (CHECK_BIT(peerCapability, TDLS_PEER_HT_CAP)) /* Check peer is HT capable */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001880 {
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05301881 PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001882 }
Kiran V1ccee932012-12-12 14:49:46 -08001883
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05301884 if (TRUE == pMac->lim.EnableTdls2040BSSCoexIE)
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301885 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05301886 if ( 1 == pMac->lim.gLimTDLSOffChannelEnabled &&
1887 ( pMac->roam.configParam.bandCapability != eCSR_BAND_24))
1888 {
1889 tdlsSetupCnf.HT2040BSSCoexistence.present = 1;
1890 tdlsSetupCnf.HT2040BSSCoexistence.infoRequest = 1;
1891 }
Agarwal Ashishb4891ef2014-11-10 20:08:36 +05301892 }
1893
Kiran V1ccee932012-12-12 14:49:46 -08001894 /*
1895 * now we pack it. First, how much space are we going to need?
1896 */
1897 status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf,
1898 &nPayload);
1899 if ( DOT11F_FAILED( status ) )
1900 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301901 limLog(pMac, LOGE,
1902 FL("Failed to calculate the packed size for Setup Confirm (0x%08x)."),
1903 status);
Kiran V1ccee932012-12-12 14:49:46 -08001904 /* We'll fall back on the worst case scenario: */
1905 nPayload = sizeof( tDot11fProbeRequest );
1906 }
1907 else if ( DOT11F_WARNED( status ) )
1908 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301909 limLog(pMac, LOGW,
1910 FL("There were warnings while calculating the packed size for Setup Confirm (0x%08x)."),
1911 status);
Kiran V1ccee932012-12-12 14:49:46 -08001912 }
1913
1914 /*
1915 * This frame is going out from PE as data frames with special ethertype
1916 * 89-0d.
1917 * 8 bytes of RFC 1042 header
1918 */
1919
1920
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301921 nBytes = nPayload + ((IS_QOS_ENABLED(psessionEntry))
1922 ? sizeof(tSirMacDataHdr3a) : sizeof(tSirMacMgmtHdr))
1923 + sizeof( eth_890d_header )
1924 + PAYLOAD_TYPE_TDLS_SIZE
1925 + addIeLen;
Kiran V1ccee932012-12-12 14:49:46 -08001926
Hoonki Lee426f0302013-02-08 17:35:38 -08001927#ifndef NO_PAD_TDLS_MIN_8023_SIZE
1928 /* IOT issue with some AP : some AP doesn't like the data packet size < minimum 802.3 frame length (64)
1929 Hence AP itself padding some bytes, which caused teardown packet is dropped at
1930 receiver side. To avoid such IOT issue, we added some extra bytes to meet data frame size >= 64
1931 */
1932 if (nPayload + PAYLOAD_TYPE_TDLS_SIZE < MIN_IEEE_8023_SIZE)
1933 {
1934 padLen = MIN_IEEE_8023_SIZE - (nPayload + PAYLOAD_TYPE_TDLS_SIZE ) ;
1935
1936 /* if padLen is less than minimum vendorSpecific (5), pad up to 5 */
1937 if (padLen < MIN_VENDOR_SPECIFIC_IE_SIZE)
1938 padLen = MIN_VENDOR_SPECIFIC_IE_SIZE;
1939
1940 nBytes += padLen;
1941 }
1942#endif
1943
1944
Kiran V1ccee932012-12-12 14:49:46 -08001945 /* Ok-- try to allocate memory from MGMT PKT pool */
1946
1947 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1948 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1949 ( void** ) &pPacket );
1950 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1951 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301952 limLog(pMac, LOGE,
1953 FL("Failed to allocate %d bytes for a TDLS Setup Confirm."),
1954 nBytes);
Kiran V1ccee932012-12-12 14:49:46 -08001955 return eSIR_MEM_ALLOC_FAILED;
1956 }
1957
1958 /* zero out the memory */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301959 vos_mem_set( pFrame, nBytes, 0 );
Kiran V1ccee932012-12-12 14:49:46 -08001960
1961 /*
1962 * IE formation, memory allocation is completed, Now form TDLS discovery
1963 * request frame
1964 */
1965
1966 /* fill out the buffer descriptor */
1967
1968 header_offset = limPrepareTdlsFrameHeader(pMac, pFrame,
1969 LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05301970 TID_AC_VI, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08001971
1972#ifdef FEATURE_WLAN_TDLS_NEGATIVE
1973 if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
1974 tdlsSetupCnf.StatusCode.statusCode = 37;
1975 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001976 ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf"));
Kiran V1ccee932012-12-12 14:49:46 -08001977 }
1978#endif
1979 status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame
1980 + header_offset, nPayload, &nPayload );
1981
1982 if ( DOT11F_FAILED( status ) )
1983 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301984 limLog(pMac, LOGE,
1985 FL("Failed to pack a TDLS Setup Confirm (0x%08x)."),
1986 status);
Kiran V1ccee932012-12-12 14:49:46 -08001987 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1988 ( void* ) pFrame, ( void* ) pPacket );
1989 return eSIR_FAILURE;
1990 }
1991 else if ( DOT11F_WARNED( status ) )
1992 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05301993 limLog(pMac, LOGW,
1994 FL("There were warnings while packing TDLS Setup Confirm (0x%08x)."),
1995 status);
Kiran V1ccee932012-12-12 14:49:46 -08001996 }
1997#if 0
1998 if(pMac->hal.pCBackFnTxComp == NULL)
1999 {
2000 pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
2001 if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer))
2002 {
2003 status = eHAL_STATUS_FAILURE;
2004 return status;
2005
2006 }
2007 }
2008 else
2009 {
2010 VOS_ASSERT(0) ;
2011 return status ;
2012 }
2013#endif
2014 //Copy the additional IE.
2015 //TODO : addIe is added at the end of the frame. This means it doesnt
2016 //follow the order. This should be ok, but we should consider changing this
2017 //if there is any IOT issue.
2018 if( addIeLen != 0 )
2019 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302020 vos_mem_copy( pFrame + header_offset + nPayload, addIe, addIeLen );
Kiran V1ccee932012-12-12 14:49:46 -08002021 }
2022
Hoonki Lee426f0302013-02-08 17:35:38 -08002023#ifndef NO_PAD_TDLS_MIN_8023_SIZE
2024 if (padLen != 0)
2025 {
2026 /* QCOM VENDOR OUI = { 0x00, 0xA0, 0xC6, type = 0x0000 }; */
2027 tANI_U8 *padVendorSpecific = pFrame + header_offset + nPayload + addIeLen;
2028 /* make QCOM_VENDOR_OUI, and type = 0x0000, and all the payload to be zero */
2029 padVendorSpecific[0] = 221;
2030 padVendorSpecific[1] = padLen - 2;
2031 padVendorSpecific[2] = 0x00;
2032 padVendorSpecific[3] = 0xA0;
2033 padVendorSpecific[4] = 0xC6;
2034
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302035 limLog(pMac, LOG1, FL("Padding Vendor Specific Ie Len = %d"), padLen);
Hoonki Lee426f0302013-02-08 17:35:38 -08002036
2037 /* padding zero if more than 5 bytes are required */
2038 if (padLen > MIN_VENDOR_SPECIFIC_IE_SIZE)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302039 vos_mem_set( pFrame + header_offset + nPayload + addIeLen + MIN_VENDOR_SPECIFIC_IE_SIZE,
2040 padLen - MIN_VENDOR_SPECIFIC_IE_SIZE, 0);
Hoonki Lee426f0302013-02-08 17:35:38 -08002041 }
2042#endif
2043
2044
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302045 limLog(pMac, LOG1,
2046 FL("[TDLS] action %d (%s) -AP-> OTA peer="MAC_ADDRESS_STR),
2047 SIR_MAC_TDLS_SETUP_CNF,
2048 limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF),
2049 MAC_ADDR_ARRAY(peerMac));
Kiran V1ccee932012-12-12 14:49:46 -08002050
2051 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
2052 HAL_TXRX_FRM_802_11_DATA,
2053 ANI_TXDIR_TODS,
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05302054 TID_AC_VI,
Kiran V1ccee932012-12-12 14:49:46 -08002055 limTxComplete, pFrame,
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002056 limMgmtTXComplete,
Masti, Narayanraddia12cce82016-02-02 14:10:01 +05302057 HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME |
2058 HAL_USE_PEER_STA_REQUESTED_MASK,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05302059 pMac->lim.txBdToken++);
Kiran V1ccee932012-12-12 14:49:46 -08002060
2061
2062 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2063 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002064 pMac->lim.mgmtFrameSessionId = 0xff;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302065 limLog(pMac, LOGE, FL("could not send TDLS Setup Confirm frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002066 return eSIR_FAILURE;
2067
2068 }
Ganesh Kondabattiniff987022015-08-11 19:43:44 +05302069 pMac->lim.mgmtFrameSessionId = psessionEntry->smeSessionId;
Kiran V1ccee932012-12-12 14:49:46 -08002070
2071 return eSIR_SUCCESS;
2072}
2073
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302074/* This Function is similar to PopulateDot11fHTCaps, except that the HT Capabilities
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002075 * are considered from the AddStaReq rather from the cfg.dat as in PopulateDot11fHTCaps
2076 */
2077static tSirRetStatus limTdlsPopulateDot11fHTCaps(tpAniSirGlobal pMac, tpPESession psessionEntry,
2078 tSirTdlsAddStaReq *pTdlsAddStaReq, tDot11fIEHTCaps *pDot11f)
2079{
2080 tANI_U32 nCfgValue;
2081 tANI_U8 nCfgValue8;
2082 tSirMacHTParametersInfo *pHTParametersInfo;
2083 union {
2084 tANI_U16 nCfgValue16;
2085 tSirMacHTCapabilityInfo htCapInfo;
2086 tSirMacExtendedHTCapabilityInfo extHtCapInfo;
2087 } uHTCapabilityInfo;
2088
2089 tSirMacTxBFCapabilityInfo *pTxBFCapabilityInfo;
2090 tSirMacASCapabilityInfo *pASCapabilityInfo;
2091
2092 nCfgValue = pTdlsAddStaReq->htCap.capInfo;
2093
2094 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2095
2096 pDot11f->advCodingCap = uHTCapabilityInfo.htCapInfo.advCodingCap;
2097 pDot11f->mimoPowerSave = uHTCapabilityInfo.htCapInfo.mimoPowerSave;
2098 pDot11f->greenField = uHTCapabilityInfo.htCapInfo.greenField;
2099 pDot11f->shortGI20MHz = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
2100 pDot11f->shortGI40MHz = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
2101 pDot11f->txSTBC = uHTCapabilityInfo.htCapInfo.txSTBC;
2102 pDot11f->rxSTBC = uHTCapabilityInfo.htCapInfo.rxSTBC;
2103 pDot11f->delayedBA = uHTCapabilityInfo.htCapInfo.delayedBA;
2104 pDot11f->maximalAMSDUsize = uHTCapabilityInfo.htCapInfo.maximalAMSDUsize;
2105 pDot11f->dsssCckMode40MHz = uHTCapabilityInfo.htCapInfo.dsssCckMode40MHz;
2106 pDot11f->psmp = uHTCapabilityInfo.htCapInfo.psmp;
2107 pDot11f->stbcControlFrame = uHTCapabilityInfo.htCapInfo.stbcControlFrame;
2108 pDot11f->lsigTXOPProtection = uHTCapabilityInfo.htCapInfo.lsigTXOPProtection;
2109
2110 // All sessionized entries will need the check below
2111 if (psessionEntry == NULL) // Only in case of NO session
2112 {
2113 pDot11f->supportedChannelWidthSet = uHTCapabilityInfo.htCapInfo.supportedChannelWidthSet;
2114 }
2115 else
2116 {
2117 pDot11f->supportedChannelWidthSet = psessionEntry->htSupportedChannelWidthSet;
2118 }
2119
2120 /* Ensure that shortGI40MHz is Disabled if supportedChannelWidthSet is
2121 eHT_CHANNEL_WIDTH_20MHZ */
2122 if(pDot11f->supportedChannelWidthSet == eHT_CHANNEL_WIDTH_20MHZ)
2123 {
2124 pDot11f->shortGI40MHz = 0;
2125 }
2126
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302127 limLog(pMac, LOG1,
2128 FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, shortGI20:%d, shortGI40: %d, dsssCck: %d"),
2129 pDot11f->supportedChannelWidthSet,
2130 pDot11f->mimoPowerSave,
2131 pDot11f->greenField,
2132 pDot11f->shortGI20MHz,
2133 pDot11f->shortGI40MHz,
2134 pDot11f->dsssCckMode40MHz);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002135
2136 nCfgValue = pTdlsAddStaReq->htCap.ampduParamsInfo;
2137
2138 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2139 pHTParametersInfo = ( tSirMacHTParametersInfo* ) &nCfgValue8;
2140
2141 pDot11f->maxRxAMPDUFactor = pHTParametersInfo->maxRxAMPDUFactor;
2142 pDot11f->mpduDensity = pHTParametersInfo->mpduDensity;
2143 pDot11f->reserved1 = pHTParametersInfo->reserved;
2144
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302145 limLog(pMac, LOG1, FL("AMPDU Param: %x"), nCfgValue);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002146
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302147 vos_mem_copy( pDot11f->supportedMCSSet, pTdlsAddStaReq->htCap.suppMcsSet,
2148 SIZE_OF_SUPPORTED_MCS_SET);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002149
2150 nCfgValue = pTdlsAddStaReq->htCap.extendedHtCapInfo;
2151
2152 uHTCapabilityInfo.nCfgValue16 = nCfgValue & 0xFFFF;
2153
2154 pDot11f->pco = uHTCapabilityInfo.extHtCapInfo.pco;
2155 pDot11f->transitionTime = uHTCapabilityInfo.extHtCapInfo.transitionTime;
2156 pDot11f->mcsFeedback = uHTCapabilityInfo.extHtCapInfo.mcsFeedback;
2157
2158 nCfgValue = pTdlsAddStaReq->htCap.txBFCapInfo;
2159
2160 pTxBFCapabilityInfo = ( tSirMacTxBFCapabilityInfo* ) &nCfgValue;
2161 pDot11f->txBF = pTxBFCapabilityInfo->txBF;
2162 pDot11f->rxStaggeredSounding = pTxBFCapabilityInfo->rxStaggeredSounding;
2163 pDot11f->txStaggeredSounding = pTxBFCapabilityInfo->txStaggeredSounding;
2164 pDot11f->rxZLF = pTxBFCapabilityInfo->rxZLF;
2165 pDot11f->txZLF = pTxBFCapabilityInfo->txZLF;
2166 pDot11f->implicitTxBF = pTxBFCapabilityInfo->implicitTxBF;
2167 pDot11f->calibration = pTxBFCapabilityInfo->calibration;
2168 pDot11f->explicitCSITxBF = pTxBFCapabilityInfo->explicitCSITxBF;
2169 pDot11f->explicitUncompressedSteeringMatrix = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrix;
2170 pDot11f->explicitBFCSIFeedback = pTxBFCapabilityInfo->explicitBFCSIFeedback;
2171 pDot11f->explicitUncompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitUncompressedSteeringMatrixFeedback;
2172 pDot11f->explicitCompressedSteeringMatrixFeedback = pTxBFCapabilityInfo->explicitCompressedSteeringMatrixFeedback;
2173 pDot11f->csiNumBFAntennae = pTxBFCapabilityInfo->csiNumBFAntennae;
2174 pDot11f->uncompressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->uncompressedSteeringMatrixBFAntennae;
2175 pDot11f->compressedSteeringMatrixBFAntennae = pTxBFCapabilityInfo->compressedSteeringMatrixBFAntennae;
2176
2177 nCfgValue = pTdlsAddStaReq->htCap.antennaSelectionInfo;
2178
2179 nCfgValue8 = ( tANI_U8 ) nCfgValue;
2180
2181 pASCapabilityInfo = ( tSirMacASCapabilityInfo* ) &nCfgValue8;
2182 pDot11f->antennaSelection = pASCapabilityInfo->antennaSelection;
2183 pDot11f->explicitCSIFeedbackTx = pASCapabilityInfo->explicitCSIFeedbackTx;
2184 pDot11f->antennaIndicesFeedbackTx = pASCapabilityInfo->antennaIndicesFeedbackTx;
2185 pDot11f->explicitCSIFeedback = pASCapabilityInfo->explicitCSIFeedback;
2186 pDot11f->antennaIndicesFeedback = pASCapabilityInfo->antennaIndicesFeedback;
2187 pDot11f->rxAS = pASCapabilityInfo->rxAS;
2188 pDot11f->txSoundingPPDUs = pASCapabilityInfo->txSoundingPPDUs;
2189
Hoonki Lee66b75f32013-04-16 18:30:07 -07002190 pDot11f->present = pTdlsAddStaReq->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002191
2192 return eSIR_SUCCESS;
2193
2194}
2195
2196tSirRetStatus
2197limTdlsPopulateDot11fVHTCaps(tpAniSirGlobal pMac,
2198 tSirTdlsAddStaReq *pTdlsAddStaReq,
2199 tDot11fIEVHTCaps *pDot11f)
2200{
2201 tANI_U32 nCfgValue=0;
2202 union {
2203 tANI_U32 nCfgValue32;
2204 tSirMacVHTCapabilityInfo vhtCapInfo;
2205 } uVHTCapabilityInfo;
2206 union {
2207 tANI_U16 nCfgValue16;
2208 tSirMacVHTTxSupDataRateInfo vhtTxSupDataRateInfo;
2209 tSirMacVHTRxSupDataRateInfo vhtRxsupDataRateInfo;
2210 } uVHTSupDataRateInfo;
2211
Hoonki Lee66b75f32013-04-16 18:30:07 -07002212 pDot11f->present = pTdlsAddStaReq->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002213
2214 nCfgValue = pTdlsAddStaReq->vhtCap.vhtCapInfo;
2215 uVHTCapabilityInfo.nCfgValue32 = nCfgValue;
2216
2217 pDot11f->maxMPDULen = uVHTCapabilityInfo.vhtCapInfo.maxMPDULen;
2218 pDot11f->supportedChannelWidthSet = uVHTCapabilityInfo.vhtCapInfo.supportedChannelWidthSet;
2219 pDot11f->ldpcCodingCap = uVHTCapabilityInfo.vhtCapInfo.ldpcCodingCap;
2220 pDot11f->shortGI80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI80MHz;
2221 pDot11f->shortGI160and80plus80MHz = uVHTCapabilityInfo.vhtCapInfo.shortGI160and80plus80MHz;
2222 pDot11f->txSTBC = uVHTCapabilityInfo.vhtCapInfo.txSTBC;
2223 pDot11f->rxSTBC = uVHTCapabilityInfo.vhtCapInfo.rxSTBC;
2224 pDot11f->suBeamFormerCap = uVHTCapabilityInfo.vhtCapInfo.suBeamFormerCap;
2225 pDot11f->suBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.suBeamformeeCap;
2226 pDot11f->csnofBeamformerAntSup = uVHTCapabilityInfo.vhtCapInfo.csnofBeamformerAntSup;
2227 pDot11f->numSoundingDim = uVHTCapabilityInfo.vhtCapInfo.numSoundingDim;
2228 pDot11f->muBeamformerCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformerCap;
2229 pDot11f->muBeamformeeCap = uVHTCapabilityInfo.vhtCapInfo.muBeamformeeCap;
2230 pDot11f->vhtTXOPPS = uVHTCapabilityInfo.vhtCapInfo.vhtTXOPPS;
2231 pDot11f->htcVHTCap = uVHTCapabilityInfo.vhtCapInfo.htcVHTCap;
2232 pDot11f->maxAMPDULenExp = uVHTCapabilityInfo.vhtCapInfo.maxAMPDULenExp;
2233 pDot11f->vhtLinkAdaptCap = uVHTCapabilityInfo.vhtCapInfo.vhtLinkAdaptCap;
2234 pDot11f->rxAntPattern = uVHTCapabilityInfo.vhtCapInfo.rxAntPattern;
2235 pDot11f->txAntPattern = uVHTCapabilityInfo.vhtCapInfo.txAntPattern;
2236 pDot11f->reserved1= uVHTCapabilityInfo.vhtCapInfo.reserved1;
2237
2238 pDot11f->rxMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.rxMcsMap;
2239
2240 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.rxHighest;
2241 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2242 pDot11f->rxHighSupDataRate = uVHTSupDataRateInfo.vhtRxsupDataRateInfo.rxSupDataRate;
2243
2244 pDot11f->txMCSMap = pTdlsAddStaReq->vhtCap.suppMcs.txMcsMap;
2245
2246 nCfgValue = pTdlsAddStaReq->vhtCap.suppMcs.txHighest;
2247 uVHTSupDataRateInfo.nCfgValue16 = nCfgValue & 0xffff;
2248 pDot11f->txSupDataRate = uVHTSupDataRateInfo.vhtTxSupDataRateInfo.txSupDataRate;
2249
2250 pDot11f->reserved3= uVHTSupDataRateInfo.vhtTxSupDataRateInfo.reserved;
2251
2252 limLogVHTCap(pMac, pDot11f);
2253
2254 return eSIR_SUCCESS;
2255
2256}
2257
2258static tSirRetStatus
2259limTdlsPopulateMatchingRateSet(tpAniSirGlobal pMac,
2260 tpDphHashNode pStaDs,
2261 tANI_U8 *pSupportedRateSet,
2262 tANI_U8 supporteRatesLength,
2263 tANI_U8* pSupportedMCSSet,
2264 tSirMacPropRateSet *pAniLegRateSet,
2265 tpPESession psessionEntry,
2266 tDot11fIEVHTCaps *pVHTCaps)
2267
2268{
2269 tSirMacRateSet tempRateSet;
2270 tANI_U32 i,j,val,min,isArate;
2271 tSirMacRateSet tempRateSet2;
2272 tANI_U32 phyMode;
2273 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2274 isArate=0;
Leela Venkata Kiran Kumar Reddy Chiralac7a12152014-02-03 11:20:14 -08002275 tempRateSet2.numRates = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002276
2277 // limGetPhyMode(pMac, &phyMode);
2278 limGetPhyMode(pMac, &phyMode, NULL);
2279
2280 // get own rate set
2281 val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2282 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302283 (tANI_U8 *) &tempRateSet.rate,
2284 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002285 {
2286 /// Could not get rateset from CFG. Log error.
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302287 limLog(pMac, LOGE, FL("could not retrieve rateset"));
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07002288 val = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002289 }
2290 tempRateSet.numRates = val;
2291
2292 if (phyMode == WNI_CFG_PHY_MODE_11G)
2293 {
2294
2295 // get own extended rate set
2296 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2297 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302298 (tANI_U8 *) &tempRateSet2.rate,
2299 &val) != eSIR_SUCCESS)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002300 tempRateSet2.numRates = val;
2301 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002302
2303 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2304 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302305 limLog(pMac, LOGE, FL("more than 12 rates in CFG"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002306 goto error;
2307 }
2308
2309 /**
2310 * Handling of the rate set IEs is the following:
2311 * - keep only rates that we support and that the station supports
2312 * - sort and the rates into the pSta->rate array
2313 */
2314
2315 // Copy all rates in tempRateSet, there are 12 rates max
2316 for (i = 0; i < tempRateSet2.numRates; i++)
2317 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
2318
2319 tempRateSet.numRates += tempRateSet2.numRates;
2320
2321 /**
2322 * Sort rates in tempRateSet (they are likely to be already sorted)
2323 * put the result in tempRateSet2
2324 */
2325 tempRateSet2.numRates = 0;
2326
2327 for (i = 0;i < tempRateSet.numRates; i++)
2328 {
2329 min = 0;
2330 val = 0xff;
2331
2332 for(j = 0;j < tempRateSet.numRates; j++)
2333 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2334 {
2335 val = tempRateSet.rate[j] & 0x7f;
2336 min = j;
2337 }
2338
2339 tempRateSet2.rate[tempRateSet2.numRates++] = tempRateSet.rate[min];
2340 tempRateSet.rate[min] = 0xff;
2341 }
2342
2343 /**
2344 * Copy received rates in tempRateSet, the parser has ensured
2345 * unicity of the rates so there cannot be more than 12 . Need to Check this
2346 * TODO Sunil.
2347 */
Kaushik, Sushant92e6f872014-05-03 16:35:57 +05302348 if (supporteRatesLength > SIR_MAC_RATESET_EID_MAX)
2349 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302350 limLog(pMac, LOGW,
2351 FL("Supported rates length %d more than the Max limit, reset to Max"),
2352 supporteRatesLength);
Kaushik, Sushant92e6f872014-05-03 16:35:57 +05302353 supporteRatesLength = SIR_MAC_RATESET_EID_MAX;
2354 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002355 for (i = 0; i < supporteRatesLength; i++)
2356 {
2357 tempRateSet.rate[i] = pSupportedRateSet[i];
2358 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002359 tempRateSet.numRates = supporteRatesLength;
2360
2361 {
2362 tpSirSupportedRates rates = &pStaDs->supportedRates;
2363 tANI_U8 aRateIndex = 0;
2364 tANI_U8 bRateIndex = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302365 vos_mem_set( (tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002366
2367 for (i = 0;i < tempRateSet2.numRates; i++)
2368 {
2369 for (j = 0;j < tempRateSet.numRates; j++)
2370 {
2371 if ((tempRateSet2.rate[i] & 0x7F) ==
Deepthi Gowri30163712015-06-01 15:44:24 +05302372 (tempRateSet.rate[j] & 0x7F))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002373 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002374 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2375 {
2376 isArate=1;
Deepthi Gowri30163712015-06-01 15:44:24 +05302377 if (aRateIndex < SIR_NUM_11A_RATES)
2378 rates->llaRates[aRateIndex++] =
2379 tempRateSet2.rate[i];
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002380 }
2381 else
Deepthi Gowri30163712015-06-01 15:44:24 +05302382 {
2383 if (bRateIndex < SIR_NUM_11B_RATES)
2384 rates->llbRates[bRateIndex++] =
2385 tempRateSet2.rate[i];
2386 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002387 break;
2388 }
2389 }
2390 }
2391 }
2392
2393
2394 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
2395#ifdef FEATURE_WLAN_TDLS
2396 if (pStaDs->mlmStaContext.htCapability)
2397#else
2398 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2399 (pStaDs->mlmStaContext.htCapability))
2400#endif
2401 {
2402 val = SIZE_OF_SUPPORTED_MCS_SET;
2403 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2404 mcsSet,
2405 &val) != eSIR_SUCCESS)
2406 {
2407 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002408 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002409 goto error;
2410 }
2411
2412 for (i=0; i<val; i++)
2413 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2414
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302415 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap from CFG and DPH:"));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002416 for (i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2417 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302418 limLog(pMac, LOG1, FL("%x %x"),
2419 mcsSet[i],
2420 pStaDs->supportedRates.supportedMCSSet[i]);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002421 }
2422 }
2423
2424#ifdef WLAN_FEATURE_11AC
2425 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2426#endif
2427 /**
2428 * Set the erpEnabled bit iff the phy is in G mode and at least
2429 * one A rate is supported
2430 */
2431 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2432 pStaDs->erpEnabled = eHAL_SET;
2433
2434
2435
2436 return eSIR_SUCCESS;
2437
2438 error:
2439
2440 return eSIR_FAILURE;
2441}
2442
2443static int limTdlsSelectCBMode(tDphHashNode *pStaDs, tpPESession psessionEntry)
2444{
2445 tANI_U8 channel = psessionEntry->currentOperChannel;
2446
2447 if ( pStaDs->mlmStaContext.vhtCapability )
2448 {
2449 if ( channel== 36 || channel == 52 || channel == 100 ||
2450 channel == 116 || channel == 149 )
2451 {
2452 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
2453 }
2454 else if ( channel == 40 || channel == 56 || channel == 104 ||
2455 channel == 120 || channel == 153 )
2456 {
2457 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
2458 }
2459 else if ( channel == 44 || channel == 60 || channel == 108 ||
2460 channel == 124 || channel == 157 )
2461 {
2462 return PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
2463 }
2464 else if ( channel == 48 || channel == 64 || channel == 112 ||
2465 channel == 128 || channel == 161 )
2466 {
2467 return PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
2468 }
2469 else if ( channel == 165 )
2470 {
2471 return 0;
2472 }
2473 }
2474 else if ( pStaDs->mlmStaContext.htCapability )
2475 {
2476 if ( channel== 40 || channel == 48 || channel == 56 ||
2477 channel == 64 || channel == 104 || channel == 112 ||
2478 channel == 120 || channel == 128 || channel == 136 ||
2479 channel == 144 || channel == 153 || channel == 161 )
2480 {
2481 return 1;
2482 }
2483 else if ( channel== 36 || channel == 44 || channel == 52 ||
2484 channel == 60 || channel == 100 || channel == 108 ||
2485 channel == 116 || channel == 124 || channel == 132 ||
2486 channel == 140 || channel == 149 || channel == 157 )
2487 {
2488 return 2;
2489 }
2490 else if ( channel == 165 )
2491 {
2492 return 0;
2493 }
2494 }
2495 return 0;
2496}
2497
Kiran V1ccee932012-12-12 14:49:46 -08002498/*
2499 * update HASH node entry info
2500 */
2501static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002502 tSirTdlsAddStaReq *pTdlsAddStaReq, tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002503{
2504 //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
2505 tDot11fIEHTCaps htCap, *htCaps;
Kiet Lam770920c2013-10-21 12:49:30 +05302506 tDot11fIEVHTCaps *pVhtCaps = NULL;
Hoonki Lee99e53782013-02-12 18:07:03 -08002507#ifdef WLAN_FEATURE_11AC
Kiet Lam770920c2013-10-21 12:49:30 +05302508 tDot11fIEVHTCaps vhtCap;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002509 tANI_U8 cbMode;
Hoonki Lee99e53782013-02-12 18:07:03 -08002510#endif
Kiran V1ccee932012-12-12 14:49:46 -08002511 tpDphHashNode pSessStaDs = NULL;
2512 tANI_U16 aid;
2513
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002514 if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_ADD)
2515 {
2516 PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
2517 }
2518 else if (pTdlsAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE)
2519 {
2520 limTdlsPopulateDot11fHTCaps(pMac, NULL, pTdlsAddStaReq, &htCap);
2521 }
Kiran V1ccee932012-12-12 14:49:46 -08002522 htCaps = &htCap;
Hoonki Lee99e53782013-02-12 18:07:03 -08002523 if (htCaps->present)
Kiran V1ccee932012-12-12 14:49:46 -08002524 {
2525 pStaDs->mlmStaContext.htCapability = 1 ;
2526 pStaDs->htGreenfield = htCaps->greenField ;
Ganesh Kondabattinidaebdff2015-02-25 17:45:06 +05302527 /* pStaDs->htSupportedChannelWidthSet should have the base channel
2528 * capability. The htSupportedChannelWidthSet of the TDLS link on
2529 * base channel should be less than or equal to channel width of
2530 * STA-AP link. So take this setting from the psessionEntry.
2531 */
2532 pStaDs->htSupportedChannelWidthSet = psessionEntry->htSupportedChannelWidthSet ;
Kiran V1ccee932012-12-12 14:49:46 -08002533 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
2534 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
2535 pStaDs->htAMpduDensity = htCaps->mpduDensity;
2536 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
2537 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
2538 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
2539 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
2540 limFillRxHighestSupportedRate(pMac,
2541 &pStaDs->supportedRates.rxHighestDataRate,
2542 htCaps->supportedMCSSet);
2543 pStaDs->baPolicyFlag = 0xFF;
Kiran V1ccee932012-12-12 14:49:46 -08002544 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
2545 }
2546 else
2547 {
2548 pStaDs->mlmStaContext.htCapability = 0 ;
2549 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
2550 }
Hoonki Lee99e53782013-02-12 18:07:03 -08002551#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002552 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002553 pVhtCaps = &vhtCap;
2554 if (pVhtCaps->present)
2555 {
2556 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302557
Masti, Narayanraddi6b70f2c2015-12-24 14:55:44 +05302558 pStaDs->vhtSupportedChannelWidthSet =
2559 psessionEntry->vhtTxChannelWidthSet;
2560
2561 limLog(pMac, LOG1, FL("Vht supported channel width is set to = %d"),
2562 pStaDs->vhtSupportedChannelWidthSet);
Kiet Lam770920c2013-10-21 12:49:30 +05302563
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002564 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2565 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2566 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002567 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2568 }
2569 else
2570 {
2571 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002572 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002573 }
2574#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002575 /*Calculate the Secondary Coannel Offset */
2576 cbMode = limTdlsSelectCBMode(pStaDs, psessionEntry);
2577
2578 pStaDs->htSecondaryChannelOffset = cbMode;
2579
2580#ifdef WLAN_FEATURE_11AC
2581 if ( pStaDs->mlmStaContext.vhtCapability )
2582 {
2583 pStaDs->htSecondaryChannelOffset = limGetHTCBState(cbMode);
2584 }
2585#endif
Deepthi Gowri22f61da2015-05-25 17:14:45 +05302586
Kiran V1ccee932012-12-12 14:49:46 -08002587 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
2588 &psessionEntry->dph.dphHashTable) ;
2589
2590 /* Lets enable QOS parameter */
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +05302591 pStaDs->qosMode = (pTdlsAddStaReq->capability & CAPABILITIES_QOS_OFFSET) ||
2592 pTdlsAddStaReq->htcap_present;
Kiran V1ccee932012-12-12 14:49:46 -08002593 pStaDs->wmeEnabled = 1;
2594 pStaDs->lleEnabled = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002595 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2596 */
2597 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002598
2599 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002600
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002601 /* TDLS Dummy AddSTA does not have HTCap,VHTCap,Rates info , is it OK ??
2602 */
2603 limTdlsPopulateMatchingRateSet(pMac, pStaDs, pTdlsAddStaReq->supported_rates,
2604 pTdlsAddStaReq->supported_rates_length,
2605 (tANI_U8 *)pTdlsAddStaReq->htCap.suppMcsSet,
2606 &pStaDs->mlmStaContext.propRateSet,
Kiet Lam770920c2013-10-21 12:49:30 +05302607 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002608
2609 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2610 */
2611 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002612
2613 return ;
2614}
2615
Kiran V1ccee932012-12-12 14:49:46 -08002616/*
Deepthi Gowri22f61da2015-05-25 17:14:45 +05302617 * Add STA for TDLS setup procedure
Kiran V1ccee932012-12-12 14:49:46 -08002618 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002619static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
2620 tSirTdlsAddStaReq *pAddStaReq,
2621 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002622{
2623 tpDphHashNode pStaDs = NULL ;
2624 tSirRetStatus status = eSIR_SUCCESS ;
2625 tANI_U16 aid = 0 ;
2626
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002627 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002628 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08002629 if(NULL == pStaDs)
2630 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002631 aid = limAssignPeerIdx(pMac, psessionEntry) ;
2632
2633 if( !aid )
2634 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302635 limLog(pMac, LOGE, FL("No more free AID for peer " MAC_ADDRESS_STR),
2636 MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002637 return eSIR_FAILURE;
2638 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002639
2640 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
2641 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
2642
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302643 limLog(pMac, LOG1, FL("Aid = %d, for peer =" MAC_ADDRESS_STR),
2644 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002645 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
2646
2647 if (pStaDs)
2648 {
2649 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
2650 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
2651 }
2652
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002653 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002654 &psessionEntry->dph.dphHashTable) ;
2655
2656 if(NULL == pStaDs)
2657 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302658 limLog(pMac, LOGE, FL("add hash entry failed"));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002659 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07002660 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002661 }
Kiran V1ccee932012-12-12 14:49:46 -08002662 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002663
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002664 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08002665
2666 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
2667
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002668 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08002669
2670 if(eSIR_SUCCESS != status)
2671 {
2672 /* should not fail */
2673 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002674 }
Kiran V1ccee932012-12-12 14:49:46 -08002675 return status ;
2676}
2677
2678/*
2679 * Del STA, after Link is teardown or discovery response sent on direct link
2680 */
2681static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2682 tpPESession psessionEntry)
2683{
2684 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002685 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08002686 tpDphHashNode pStaDs = NULL ;
2687
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002688 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08002689 &psessionEntry->dph.dphHashTable) ;
2690
2691 if(pStaDs)
2692 {
2693
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302694 limLog(pMac, LOG1, FL("DEL STA peer MAC: "MAC_ADDRESS_STR),
2695 MAC_ADDR_ARRAY(pStaDs->staAddr));
2696 limLog(pMac, LOG1, FL("STA type = %x, sta idx = %x"),
2697 pStaDs->staType,
2698 pStaDs->staIndex);
Edhar, Mahesh Kumarc9e9f622014-12-11 15:40:29 +05302699 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
Ganesh Kondabattini6efefb22015-01-20 12:17:42 +05302700 eSIR_MAC_PEER_TIMEDOUT_REASON);
Kiran V1ccee932012-12-12 14:49:46 -08002701 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08002702 }
2703
2704 return pStaDs ;
2705}
2706
Kiran V1ccee932012-12-12 14:49:46 -08002707/*
2708 * Once Link is setup with PEER, send Add STA ind to SME
2709 */
2710static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002711 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
2712 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08002713{
2714 tSirMsgQ mmhMsg = {0} ;
2715 tSirTdlsAddStaRsp *addStaRsp = NULL ;
2716 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302717
2718 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
2719 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08002720 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302721 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Kiran V1ccee932012-12-12 14:49:46 -08002722 return eSIR_FAILURE;
2723 }
2724
2725 addStaRsp->sessionId = sessionId;
2726 addStaRsp->statusCode = status;
2727 if( pStaDs )
2728 {
2729 addStaRsp->staId = pStaDs->staIndex ;
2730 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
2731 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
2732 }
2733 if( peerMac )
2734 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302735 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002736 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
2737 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002738 if (updateSta)
2739 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
2740 else
2741 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
2742
Kiran V1ccee932012-12-12 14:49:46 -08002743 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
2744 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
2745
2746 mmhMsg.bodyptr = addStaRsp;
2747 mmhMsg.bodyval = 0;
2748 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2749
2750 return eSIR_SUCCESS ;
2751
2752}
2753/*
2754 * STA RSP received from HAL
2755 */
2756eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
2757 tpPESession psessionEntry)
2758{
2759 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
2760 tANI_U8 status = eSIR_SUCCESS ;
2761 tDphHashNode *pStaDs = NULL ;
2762 tANI_U16 aid = 0 ;
2763
2764 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302765 limLog(pMac, LOG1, FL("staIdx=%d, staMac="MAC_ADDRESS_STR),
2766 pAddStaParams->staIdx,
2767 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08002768
2769 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
2770 {
2771 VOS_ASSERT(0) ;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302772 limLog(pMac, LOGE, FL("Add sta failed "));
Kiran V1ccee932012-12-12 14:49:46 -08002773 status = eSIR_FAILURE;
2774 goto add_sta_error;
2775 }
2776
2777 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
2778 &psessionEntry->dph.dphHashTable);
2779 if(NULL == pStaDs)
2780 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302781 limLog(pMac, LOGE, FL("pStaDs is NULL "));
Kiran V1ccee932012-12-12 14:49:46 -08002782 status = eSIR_FAILURE;
2783 goto add_sta_error;
2784 }
2785
2786 pStaDs->bssId = pAddStaParams->bssIdx;
2787 pStaDs->staIndex = pAddStaParams->staIdx;
2788 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
2789 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
2790 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
2791 pStaDs->valid = 1 ;
Kiran V1ccee932012-12-12 14:49:46 -08002792add_sta_error:
2793 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002794 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302795 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08002796 return status ;
2797}
2798
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302799void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
2800 tpPESession psessionEntry,
2801 tDot11fIESuppChannels *suppChannels,
2802 tDot11fIESuppOperatingClasses *suppOperClasses)
2803{
2804 tANI_U32 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2805 tANI_U8 validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302806 tANI_U8 i, j;
Atul Mittalb849d5a2014-07-29 12:08:39 +05302807 tANI_U8 op_class;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302808 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
2809 validChan, &numChans) != eSIR_SUCCESS)
2810 {
2811 /**
2812 * Could not get Valid channel list from CFG.
2813 * Log error.
2814 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302815 limLog(pMac, LOGE, FL("could not retrieve valid channel list"));
Sushant Kaushik5b4c8212015-02-20 14:54:25 +05302816 return;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302817 }
2818 suppChannels->num_bands = (tANI_U8) numChans;
2819
Masti, Narayanraddi2f5dd652015-03-03 22:00:44 +05302820 for ( i = 0U, j = 0U; i < suppChannels->num_bands &&
2821 j < LIM_MAX_BANDS; i++)
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302822 {
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302823 /* don't populate dfs channels in supported channels ie */
Pradeep Reddy POTTETIf066fe32015-04-23 11:59:33 +05302824 if (!(NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(validChan[i]))) {
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302825 suppChannels->bands[j][0] = validChan[i];
2826 suppChannels->bands[j][1] = 1;
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05302827 /* store tdls self supported channels */
2828 tdlsSelfSupportedChannels[j] = validChan[i];
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302829 j++;
2830 }
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302831 }
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302832 /* update the channel list with new length */
2833 suppChannels->num_bands = j;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302834 suppChannels->present = 1 ;
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05302835 /* store tdls self supported channels new length */
2836 tdlsSelfNumChans = j;
2837
Atul Mittalb849d5a2014-07-29 12:08:39 +05302838 /*Get present operating class based on current operating channel*/
2839 op_class = limGetOPClassFromChannel(
2840 pMac->scan.countryCodeCurrent,
2841 psessionEntry->currentOperChannel,
2842 psessionEntry->htSecondaryChannelOffset);
2843 if (op_class == 0)
2844 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302845 limLog(pMac, LOGE,
2846 FL("Present Operating class is wrong, countryCodeCurrent: %s, currentOperChannel: %d, htSecondaryChannelOffset: %d"),
2847 pMac->scan.countryCodeCurrent,
2848 psessionEntry->currentOperChannel,
2849 psessionEntry->htSecondaryChannelOffset);
Atul Mittalb849d5a2014-07-29 12:08:39 +05302850 }
2851 else
2852 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302853 limLog(pMac, LOG1,
2854 FL("Present Operating channel=%d offset=%d class=%d"),
2855 psessionEntry->currentOperChannel,
2856 psessionEntry->htSecondaryChannelOffset,
2857 op_class);
Atul Mittalb849d5a2014-07-29 12:08:39 +05302858 }
2859 suppOperClasses->present = 1;
2860 suppOperClasses->classes[0] = op_class;
2861 /*Fill operating classes from static array*/
2862 suppOperClasses->num_classes = op_classes.num_classes;
2863 for ( i = 0U; i < suppOperClasses->num_classes; i++)
2864 {
2865 suppOperClasses->classes[i+1] = op_classes.classes[i];
2866
2867 }
2868 /*increment for present operating class*/
2869 suppOperClasses->num_classes++;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302870 return ;
2871}
2872
2873
Kiran V1ccee932012-12-12 14:49:46 -08002874/*
2875 * FUNCTION: Populate Link Identifier element IE
2876 *
2877 */
2878
Atul Mittalb849d5a2014-07-29 12:08:39 +05302879
Kiran V1ccee932012-12-12 14:49:46 -08002880void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
2881 tDot11fIELinkIdentifier *linkIden,
2882 tSirMacAddr peerMac, tANI_U8 reqType)
2883{
2884 //tANI_U32 size = sizeof(tSirMacAddr) ;
2885 tANI_U8 *initStaAddr = NULL ;
2886 tANI_U8 *respStaAddr = NULL ;
2887
2888 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
2889 (respStaAddr = linkIden->RespStaAddr))
2890 : ((respStaAddr = linkIden->InitStaAddr ),
2891 (initStaAddr = linkIden->RespStaAddr)) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302892 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08002893 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
2894
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302895 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08002896 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
2897
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302898 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002899 sizeof( tSirMacAddr ));
2900
2901 linkIden->present = 1 ;
2902 return ;
2903
2904}
2905
2906void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
2907 tDot11fIEExtCap *extCapability)
2908{
2909 extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302910 extCapability->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302911 extCapability->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
Kiran V1ccee932012-12-12 14:49:46 -08002912 extCapability->TDLSSupport = TDLS_SUPPORT ;
2913 extCapability->TDLSProhibited = TDLS_PROHIBITED ;
2914 extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
2915 extCapability->present = 1 ;
2916 return ;
2917}
Kiran V1ccee932012-12-12 14:49:46 -08002918
2919/*
2920 * Process Send Mgmt Request from SME and transmit to AP.
2921 */
2922tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
2923 tANI_U32 *pMsgBuf)
2924{
2925 /* get all discovery request parameters */
2926 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
2927 tpPESession psessionEntry;
2928 tANI_U8 sessionId;
2929 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
2930
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302931 limLog(pMac, LOG1, FL("Send Mgmt Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08002932
2933 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
2934 == NULL)
2935 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302936 limLog(pMac, LOGE,
2937 FL("PE Session does not exist for given sme sessionId %d"),
2938 pSendMgmtReq->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08002939 goto lim_tdls_send_mgmt_error;
2940 }
2941
2942 /* check if we are in proper state to work as TDLS client */
2943 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2944 {
2945 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002946 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08002947 psessionEntry->limSystemRole);
2948 goto lim_tdls_send_mgmt_error;
2949 }
2950
2951 /*
2952 * if we are still good, go ahead and check if we are in proper state to
2953 * do TDLS discovery req/rsp/....frames.
2954 */
2955 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
2956 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
2957 {
2958
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302959 limLog(pMac, LOGE, FL("send mgmt received in invalid LIMsme state (%d)"),
2960 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08002961 goto lim_tdls_send_mgmt_error;
2962 }
Abhishek Singh888420b2016-01-06 12:28:03 +05302963 vos_tdls_tx_rx_mgmt_event(SIR_MAC_ACTION_TDLS,
2964 SIR_MAC_ACTION_TX, SIR_MAC_MGMT_ACTION,
2965 pSendMgmtReq->reqType, pSendMgmtReq->peerMac);
Kiran V1ccee932012-12-12 14:49:46 -08002966
2967 switch( pSendMgmtReq->reqType )
2968 {
2969 case SIR_MAC_TDLS_DIS_REQ:
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302970 limLog(pMac, LOG1, FL("Transmit Discovery Request Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002971 /* format TDLS discovery request frame and transmit it */
2972 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
2973 psessionEntry) ;
2974 resultCode = eSIR_SME_SUCCESS;
2975 break;
2976 case SIR_MAC_TDLS_DIS_RSP:
2977 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302978 limLog(pMac, LOG1, FL("Transmit Discovery Response Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002979 //Send a response mgmt action frame
2980 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05302981 pSendMgmtReq->dialog, psessionEntry,
2982 &pSendMgmtReq->addIe[0],
2983 (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
Kiran V1ccee932012-12-12 14:49:46 -08002984 resultCode = eSIR_SME_SUCCESS;
2985 }
2986 break;
2987 case SIR_MAC_TDLS_SETUP_REQ:
2988 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302989 limLog(pMac, LOG1, FL("Transmit Setup Request Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002990 limSendTdlsLinkSetupReqFrame(pMac,
2991 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
2992 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
2993 resultCode = eSIR_SME_SUCCESS;
2994 }
2995 break;
2996 case SIR_MAC_TDLS_SETUP_RSP:
2997 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302998 limLog(pMac, LOG1, FL("Transmit Setup Response Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002999 limSendTdlsSetupRspFrame(pMac,
3000 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
3001 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3002 resultCode = eSIR_SME_SUCCESS;
3003 }
3004 break;
3005 case SIR_MAC_TDLS_SETUP_CNF:
3006 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303007 limLog(pMac, LOG1, FL("Transmit Setup Confirm Frame"));
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05303008 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, pSendMgmtReq->peerCapability,
Kiran V1ccee932012-12-12 14:49:46 -08003009 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3010 resultCode = eSIR_SME_SUCCESS;
3011 }
3012 break;
3013 case SIR_MAC_TDLS_TEARDOWN:
3014 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303015 limLog(pMac, LOG1, FL("Transmit Teardown Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08003016 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08003017 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003018 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3019 resultCode = eSIR_SME_SUCCESS;
3020 }
3021 break;
3022 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
3023 {
3024 }
3025 break;
3026 case SIR_MAC_TDLS_CH_SWITCH_REQ:
3027 {
3028 }
3029 break;
3030 case SIR_MAC_TDLS_CH_SWITCH_RSP:
3031 {
3032 }
3033 break;
3034 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
3035 {
3036 }
3037 break;
3038 default:
3039 break;
3040 }
3041
3042lim_tdls_send_mgmt_error:
3043
3044 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
3045 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
3046
3047 return eSIR_SUCCESS;
3048}
3049
3050/*
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303051 * Send Response to Link Establish Request to SME
3052 */
3053void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
3054 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
3055 tANI_U8 status)
3056{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303057 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303058
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303059 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303060
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303061 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
3062 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303063 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303064 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303065 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303066 }
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303067
3068 vos_mem_zero(pTdlsLinkEstablishReqRsp, sizeof(tSirTdlsLinkEstablishReqRsp));
3069
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303070 pTdlsLinkEstablishReqRsp->statusCode = status ;
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303071 if (pStaDs && peerMac)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303072 {
3073 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303074 pTdlsLinkEstablishReqRsp->sta_idx = pStaDs->staIndex;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303075 }
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303076
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303077 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303078
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303079 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303080 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303081 mmhMsg.bodyval = 0;
3082 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3083 return ;
3084
3085
3086}
3087
3088/*
Atul Mittal60bd4292014-08-14 12:19:27 +05303089 * Send Response to Chan Switch Request to SME
3090 */
3091void limSendSmeTdlsChanSwitchReqRsp(tpAniSirGlobal pMac,
3092 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
3093 tANI_U8 status)
3094{
3095 tSirMsgQ mmhMsg = {0} ;
3096
3097 tSirTdlsChanSwitchReqRsp *pTdlsChanSwitchReqRsp = NULL ;
3098
3099 pTdlsChanSwitchReqRsp = vos_mem_malloc(sizeof(tSirTdlsChanSwitchReqRsp));
3100 if ( NULL == pTdlsChanSwitchReqRsp )
3101 {
3102 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
3103 return ;
3104 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303105
3106 vos_mem_zero(pTdlsChanSwitchReqRsp, sizeof(tSirTdlsChanSwitchReqRsp));
3107
Atul Mittal60bd4292014-08-14 12:19:27 +05303108 pTdlsChanSwitchReqRsp->statusCode = status ;
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303109 if (pStaDs && peerMac )
Atul Mittal60bd4292014-08-14 12:19:27 +05303110 {
3111 vos_mem_copy(pTdlsChanSwitchReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303112 pTdlsChanSwitchReqRsp->sta_idx = pStaDs->staIndex;;
Atul Mittal60bd4292014-08-14 12:19:27 +05303113 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303114
Atul Mittal60bd4292014-08-14 12:19:27 +05303115 pTdlsChanSwitchReqRsp->sessionId = sessionId;
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303116
Atul Mittal60bd4292014-08-14 12:19:27 +05303117 mmhMsg.type = eWNI_SME_TDLS_CHANNEL_SWITCH_RSP ;
3118 mmhMsg.bodyptr = pTdlsChanSwitchReqRsp;
3119 mmhMsg.bodyval = 0;
3120 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3121 return ;
3122
3123
3124}
3125/*
Kiran V1ccee932012-12-12 14:49:46 -08003126 * Once link is teardown, send Del Peer Ind to SME
3127 */
3128static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
3129 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
3130 tANI_U8 status)
3131{
3132 tSirMsgQ mmhMsg = {0} ;
3133 tSirTdlsDelStaRsp *pDelSta = NULL ;
3134 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303135
3136 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
3137 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08003138 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303139 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Kiran V1ccee932012-12-12 14:49:46 -08003140 return eSIR_FAILURE;
3141 }
3142
3143 pDelSta->sessionId = sessionId;
3144 pDelSta->statusCode = status ;
3145 if( pStaDs )
3146 {
3147 pDelSta->staId = pStaDs->staIndex ;
3148 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003149 else
3150 pDelSta->staId = HAL_STA_INVALID_IDX;
3151
Kiran V1ccee932012-12-12 14:49:46 -08003152 if( peerMac )
3153 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303154 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003155 }
3156
3157 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
3158 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
3159
3160 mmhMsg.bodyptr = pDelSta;
3161
3162 mmhMsg.bodyval = 0;
3163 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3164 return eSIR_SUCCESS ;
3165
3166}
3167
3168/*
3169 * Process Send Mgmt Request from SME and transmit to AP.
3170 */
3171tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
3172 tANI_U32 *pMsgBuf)
3173{
3174 /* get all discovery request parameters */
3175 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
3176 tpPESession psessionEntry;
3177 tANI_U8 sessionId;
Kiran V1ccee932012-12-12 14:49:46 -08003178
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303179 limLog(pMac, LOG1, FL("TDLS Add STA Request Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08003180
3181 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
3182 == NULL)
3183 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303184 limLog(pMac, LOGE,
3185 FL("PE Session does not exist for given sme sessionId %d"),
3186 pAddStaReq->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08003187 goto lim_tdls_add_sta_error;
3188 }
3189
3190 /* check if we are in proper state to work as TDLS client */
3191 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3192 {
3193 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003194 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08003195 psessionEntry->limSystemRole);
3196 goto lim_tdls_add_sta_error;
3197 }
3198
3199 /*
3200 * if we are still good, go ahead and check if we are in proper state to
3201 * do TDLS discovery req/rsp/....frames.
3202 */
3203 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3204 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3205 {
3206
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303207 limLog(pMac, LOGE,
3208 FL("Add STA received in invalid LIMsme state (%d)"),
3209 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08003210 goto lim_tdls_add_sta_error;
3211 }
3212
3213 pMac->lim.gLimAddStaTdls = true ;
3214
3215 /* To start with, send add STA request to HAL */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003216 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08003217 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303218 limLog(pMac, LOGE, FL("Add TDLS Station request failed"));
Kiran V1ccee932012-12-12 14:49:46 -08003219 goto lim_tdls_add_sta_error;
3220 }
3221 return eSIR_SUCCESS;
3222lim_tdls_add_sta_error:
3223 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003224 pAddStaReq->sessionId, pAddStaReq->peerMac,
3225 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08003226
3227 return eSIR_SUCCESS;
3228}
3229/*
3230 * Process Del Sta Request from SME .
3231 */
3232tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
3233 tANI_U32 *pMsgBuf)
3234{
3235 /* get all discovery request parameters */
3236 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
3237 tpPESession psessionEntry;
3238 tANI_U8 sessionId;
3239 tpDphHashNode pStaDs = NULL ;
3240
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303241 limLog(pMac, LOG1, FL("TDLS Delete STA Request Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08003242
3243 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
3244 == NULL)
3245 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303246 limLog(pMac, LOGE,
3247 FL("PE Session does not exist for given sme sessionId %d"),
3248 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08003249 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003250 NULL, eSIR_FAILURE) ;
3251 return eSIR_FAILURE;
3252 }
3253
3254 /* check if we are in proper state to work as TDLS client */
3255 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3256 {
3257 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003258 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08003259 psessionEntry->limSystemRole);
3260 goto lim_tdls_del_sta_error;
3261 }
3262
3263 /*
3264 * if we are still good, go ahead and check if we are in proper state to
3265 * do TDLS discovery req/rsp/....frames.
3266 */
3267 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3268 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3269 {
3270
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303271 limLog(pMac, LOGE, FL("Del Sta received in invalid LIMsme state (%d)"),
3272 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08003273 goto lim_tdls_del_sta_error;
3274 }
3275
3276 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
3277
3278 /* now send indication to SME-->HDD->TL to remove STA from TL */
3279
3280 if(pStaDs)
3281 {
3282 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
3283 pStaDs, eSIR_SUCCESS) ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003284 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08003285
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003286 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
3287 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08003288 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3289
Kiran V1ccee932012-12-12 14:49:46 -08003290 return eSIR_SUCCESS;
3291
3292 }
3293
3294lim_tdls_del_sta_error:
3295 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
3296 NULL, eSIR_FAILURE) ;
3297
3298 return eSIR_SUCCESS;
3299}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003300
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303301/* Intersects the two input arrays and outputs an array */
3302/* For now the array length of tANI_U8 suffices */
3303static void limTdlsGetIntersection(tANI_U8 *input_array1,tANI_U8 input1_length,
3304 tANI_U8 *input_array2,tANI_U8 input2_length,
3305 tANI_U8 *output_array,tANI_U8 *output_length)
3306{
3307 tANI_U8 i,j,k=0,flag=0;
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05303308
3309 if (input1_length > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3310 {
3311 input1_length = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3312 }
3313
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303314 for(i=0;i<input1_length;i++)
3315 {
3316 flag=0;
3317 for(j=0;j<input2_length;j++)
3318 {
3319 if(input_array1[i]==input_array2[j])
3320 {
3321 flag=1;
3322 break;
3323 }
3324 }
3325 if(flag==1)
3326 {
3327 output_array[k]=input_array1[i];
3328 k++;
3329 }
3330 }
3331 *output_length = k;
3332}
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303333/*
3334 * Process Link Establishment Request from SME .
3335 */
3336tSirRetStatus limProcesSmeTdlsLinkEstablishReq(tpAniSirGlobal pMac,
3337 tANI_U32 *pMsgBuf)
3338{
3339 /* get all discovery request parameters */
3340 tSirTdlsLinkEstablishReq *pTdlsLinkEstablishReq = (tSirTdlsLinkEstablishReq*) pMsgBuf ;
3341 tpPESession psessionEntry;
3342 tANI_U8 sessionId;
3343 tpTdlsLinkEstablishParams pMsgTdlsLinkEstablishReq;
3344 tSirMsgQ msg;
3345 tANI_U16 peerIdx = 0 ;
3346 tpDphHashNode pStaDs = NULL ;
3347
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303348 limLog(pMac, LOG1, FL("Link Establish Request Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303349
3350 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
3351 == NULL)
3352 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303353 limLog(pMac, LOGE,
3354 FL("PE Session does not exist for given sme sessionId %d"),
3355 pTdlsLinkEstablishReq->sessionId);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303356 limSendSmeTdlsLinkEstablishReqRsp(pMac, pTdlsLinkEstablishReq->sessionId, pTdlsLinkEstablishReq->peerMac,
3357 NULL, eSIR_FAILURE) ;
3358 return eSIR_FAILURE;
3359 }
3360
3361 /* check if we are in proper state to work as TDLS client */
3362 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3363 {
3364 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003365 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303366 psessionEntry->limSystemRole);
3367 goto lim_tdls_link_establish_error;
3368 }
3369
3370 /*
3371 * if we are still good, go ahead and check if we are in proper state to
3372 * do TDLS discovery req/rsp/....frames.
3373 */
3374 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3375 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3376 {
3377
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303378 limLog(pMac, LOGE,
3379 FL("TDLS Link Establish Request received in invalid LIMsme state (%d)"),
3380 psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303381 goto lim_tdls_link_establish_error;
3382 }
3383 /*TODO Sunil , TDLSPeer Entry has the STA ID , Use it */
3384 pStaDs = dphLookupHashEntry(pMac, pTdlsLinkEstablishReq->peerMac, &peerIdx,
3385 &psessionEntry->dph.dphHashTable) ;
3386 if ( NULL == pStaDs )
3387 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303388 limLog(pMac, LOGE, FL( "pStaDs is NULL"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303389 goto lim_tdls_link_establish_error;
3390
3391 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303392 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
3393 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303394 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303395 limLog(pMac, LOGE,
3396 FL("Unable to allocate memory TDLS Link Establish Request"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303397 return eSIR_MEM_ALLOC_FAILED;
3398 }
3399
Girish Gowlicf762742014-07-02 13:54:09 +05303400 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303401
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05303402 pMsgTdlsLinkEstablishReq->staIdx = pStaDs->staIndex;
3403 pMsgTdlsLinkEstablishReq->isResponder = pTdlsLinkEstablishReq->isResponder;
3404 pMsgTdlsLinkEstablishReq->uapsdQueues = pTdlsLinkEstablishReq->uapsdQueues;
3405 pMsgTdlsLinkEstablishReq->maxSp = pTdlsLinkEstablishReq->maxSp;
3406 pMsgTdlsLinkEstablishReq->isBufsta = pTdlsLinkEstablishReq->isBufSta;
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303407
Atul Mittalbceb4a12014-11-27 18:50:19 +05303408 if (psessionEntry->tdlsChanSwitProhibited)
3409 {
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303410 /* If channel switch is prohibited by AP then dut can either
3411 * send a switch channel request with failure status or it can
3412 * ignore the request without sending the response.
3413 * isOffChannelSupported = 0 disables the TDLS off-channel and
3414 * if off-channel support is disabled then FW ignores switch
3415 * channel request sent by TDLS peer */
3416 pMsgTdlsLinkEstablishReq->isOffChannelSupported = 0;
Atul Mittalbceb4a12014-11-27 18:50:19 +05303417 limLog(pMac, LOG1, FL("Channel Switch Prohibited by AP"));
3418 }
3419 else
3420 {
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303421 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
3422 pTdlsLinkEstablishReq->isOffChannelSupported;
Atul Mittalbceb4a12014-11-27 18:50:19 +05303423 }
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303424
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05303425 if ((pTdlsLinkEstablishReq->supportedChannelsLen > 0) &&
3426 (pTdlsLinkEstablishReq->supportedChannelsLen <= SIR_MAC_MAX_SUPP_CHANNELS))
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303427 {
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05303428 /* check self supported channels and pass them to FW */
3429 if ((tdlsSelfNumChans > 0) &&
3430 (tdlsSelfNumChans < LIM_TDLS_MAX_NON_DFS_CHANNELS))
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303431 {
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05303432 limTdlsGetIntersection(tdlsSelfSupportedChannels, tdlsSelfNumChans,
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303433 pTdlsLinkEstablishReq->supportedChannels,
3434 pTdlsLinkEstablishReq->supportedChannelsLen,
3435 pMsgTdlsLinkEstablishReq->validChannels,
3436 &pMsgTdlsLinkEstablishReq->validChannelsLen);
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05303437 }
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303438 }
3439 vos_mem_copy(pMsgTdlsLinkEstablishReq->validOperClasses,
3440 pTdlsLinkEstablishReq->supportedOperClasses, pTdlsLinkEstablishReq->supportedOperClassesLen);
3441 pMsgTdlsLinkEstablishReq->validOperClassesLen =
3442 pTdlsLinkEstablishReq->supportedOperClassesLen;
3443
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303444 msg.type = WDA_SET_TDLS_LINK_ESTABLISH_REQ;
3445 msg.reserved = 0;
3446 msg.bodyptr = pMsgTdlsLinkEstablishReq;
3447 msg.bodyval = 0;
3448 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
3449 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003450 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303451 goto lim_tdls_link_establish_error;
3452 }
3453 return eSIR_SUCCESS;
3454lim_tdls_link_establish_error:
3455 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
3456 NULL, eSIR_FAILURE) ;
3457
3458 return eSIR_SUCCESS;
3459}
3460
3461
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003462/* Delete all the TDLS peer connected before leaving the BSS */
3463tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
3464{
3465 tpDphHashNode pStaDs = NULL ;
3466 int i, aid;
3467
3468 if (NULL == psessionEntry)
3469 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303470 limLog(pMac, LOGE, FL("NULL psessionEntry"));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003471 return eSIR_FAILURE;
3472 }
3473
3474 /* Check all the set bit in peerAIDBitmap and delete the peer (with that aid) entry
3475 from the hash table and add the aid in free pool */
3476 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
3477 {
3478 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
3479 {
3480 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
3481 {
3482 pStaDs = dphGetHashEntry(pMac, (aid + i*(sizeof(tANI_U32) << 3)), &psessionEntry->dph.dphHashTable);
3483
3484 if (NULL != pStaDs)
3485 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303486 limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
3487 MAC_ADDR_ARRAY(pStaDs->staAddr));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003488
3489 limSendDeauthMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3490 pStaDs->staAddr, psessionEntry, FALSE);
3491 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, &psessionEntry->dph.dphHashTable);
3492 }
3493 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)), psessionEntry) ;
3494 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
3495 }
3496 }
3497 }
3498 limSendSmeTDLSDeleteAllPeerInd(pMac, psessionEntry);
3499
3500 return eSIR_SUCCESS;
3501}
Atul Mittalb849d5a2014-07-29 12:08:39 +05303502
3503
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303504tANI_U8 limGetOffChMaxBwOffsetFromChannel(tANI_U8 *country,
3505 tANI_U8 channel,
3506 tANI_U8 peerVHTCapability)
3507{
3508 op_class_map_t *class = NULL;
3509 tANI_U16 i = 0;
3510 offset_t offset = BW20, max_allowed = BW80;
3511
3512 if ((TRUE == peerVHTCapability) &&
3513 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC) &&
3514 IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC))
3515 max_allowed = BW80;
3516 else
3517 max_allowed = BW40MINUS;
3518
3519 if (VOS_TRUE == vos_mem_compare(country,"US", 2)) {
3520
3521 class = us_op_class;
3522
3523 } else if (VOS_TRUE == vos_mem_compare(country,"EU", 2)) {
3524
3525 class = euro_op_class;
3526
3527 } else if (VOS_TRUE == vos_mem_compare(country,"JP", 2)) {
3528
3529 class = japan_op_class;
3530
3531 } else {
3532
3533 class = global_op_class;
3534
3535 }
3536
3537 while (class->op_class)
3538 {
3539 for (i=0; (i < 25 && class->channels[i]); i++)
3540 {
3541 if (channel == class->channels[i] && class->offset <= max_allowed)
3542 offset = class->offset;
3543 }
3544 class++;
3545 }
3546
3547 return offset;
3548}
3549
3550
Atul Mittalb849d5a2014-07-29 12:08:39 +05303551tANI_U8 limGetOPClassFromChannel(tANI_U8 *country,
3552 tANI_U8 channel,
3553 tANI_U8 offset)
3554{
3555 op_class_map_t *class = NULL;
3556 tANI_U16 i = 0;
3557
3558 if (VOS_TRUE == vos_mem_compare(country,"US", 2)) {
3559
3560 class = us_op_class;
3561
3562 } else if (VOS_TRUE == vos_mem_compare(country,"EU", 2)) {
3563
3564 class = euro_op_class;
3565
3566 } else if (VOS_TRUE == vos_mem_compare(country,"JP", 2)) {
3567
3568 class = japan_op_class;
3569
3570 } else {
3571
3572 class = global_op_class;
3573
3574 }
3575
3576 while (class->op_class)
3577 {
3578 if ((offset == class->offset) || (offset == BWALL))
3579 {
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303580 for (i=0; (i < 25 && class->channels[i]); i++)
Atul Mittalb849d5a2014-07-29 12:08:39 +05303581 {
3582 if (channel == class->channels[i])
3583 return class->op_class;
3584 }
3585 }
3586 class++;
3587 }
3588 return 0;
3589}
3590
3591tANI_BOOLEAN CheckAndAddOP(tANI_U8 class)
3592{
3593 tANI_U8 i;
3594
3595 for (i=0; i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1); i++)
3596 {
3597 /*0 is an invalid class. If class is already present ignore*/
3598 if (class == op_classes.classes[i])
3599 return FALSE;
3600 if(op_classes.classes[i] == 0)
3601 {
3602 return TRUE;
3603 }
3604 }
3605 //limLog(pMac, LOGE, FL("No space left for class = %d"), class);
3606 return FALSE;
3607}
3608
3609void limInitOperatingClasses( tHalHandle hHal )
3610{
3611
3612 tANI_U8 Index = 0;
3613 tANI_U8 class = 0;
3614 tANI_U8 i = 0;
3615 tANI_U8 j = 0;
3616 tANI_U8 swap = 0;
3617 tANI_U8 numChannels = 0;
3618 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3619 limLog(pMac, LOG1, FL("Current Country = %c%c"),
3620 pMac->scan.countryCodeCurrent[0],
3621 pMac->scan.countryCodeCurrent[1]);
3622
3623 vos_mem_set(op_classes.classes, sizeof(op_classes.classes), 0);
3624 numChannels = pMac->scan.baseChannels.numChannels;
3625 limLog(pMac, LOG1, "Num of base ch =%d", numChannels);
3626 for ( Index = 0;
3627 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
3628 Index++)
3629 {
3630 class = limGetOPClassFromChannel(
3631 pMac->scan.countryCodeCurrent,
3632 pMac->scan.baseChannels.channelList[ Index ],
3633 BWALL);
3634 limLog(pMac, LOG4, "ch=%d <=> %d=class",
3635 pMac->scan.baseChannels.channelList[ Index ],
3636 class);
3637 if (CheckAndAddOP(class))
3638 {
3639 op_classes.classes[i]= class;
3640 i++;
3641 }
3642 }
3643
3644 numChannels = pMac->scan.base20MHzChannels.numChannels;
3645 limLog(pMac, LOG1, "Num of 20MHz ch =%d", numChannels);
3646 for ( Index = 0;
3647 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
3648 Index++)
3649 {
3650 class = limGetOPClassFromChannel(
3651 pMac->scan.countryCodeCurrent,
3652 pMac->scan.base20MHzChannels.channelList[ Index ],
3653 BWALL);
3654 limLog(pMac, LOG4, "ch=%d <=> %d=class",
3655 pMac->scan.base20MHzChannels.channelList[ Index ],
3656 class);
3657 if (CheckAndAddOP(class))
3658 {
3659 op_classes.classes[i]= class;
3660 i++;
3661 }
3662 }
3663
3664 numChannels = pMac->scan.base40MHzChannels.numChannels;
3665 limLog(pMac, LOG1, "Num of 40MHz ch =%d", numChannels);
3666 for ( Index = 0;
3667 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
3668 Index++)
3669 {
3670 class = limGetOPClassFromChannel(
3671 pMac->scan.countryCodeCurrent,
3672 pMac->scan.base40MHzChannels.channelList[ Index ],
3673 BWALL);
3674 limLog(pMac, LOG4, "ch=%d <=> %d=class",
3675 pMac->scan.base40MHzChannels.channelList[ Index ],
3676 class);
3677 if (CheckAndAddOP(class))
3678 {
3679 op_classes.classes[i]= class;
3680 i++;
3681 }
3682 }
3683
3684 op_classes.num_classes = i;
3685 limLog(pMac, LOG1, "Total number of Unique supported classes =%d",
3686 op_classes.num_classes);
3687 /*as per spec the operating classes should be in ascending order*/
3688 /*Bubble sort is fine as we don't have many classes*/
3689 for (i = 0 ; i < ( op_classes.num_classes - 1 ); i++)
3690 {
3691 for (j = 0 ; j < op_classes.num_classes - i - 1; j++)
3692 {
3693 /* For decreasing order use < */
3694 if (op_classes.classes[j] > op_classes.classes[j+1])
3695 {
3696 swap = op_classes.classes[j];
3697 op_classes.classes[j] = op_classes.classes[j+1];
3698 op_classes.classes[j+1] = swap;
3699 }
3700 }
3701 }
3702 for (i=0; i < op_classes.num_classes; i++)
3703 {
3704
3705 limLog(pMac, LOG1, "supported op_class[%d]=%d", i,
3706 op_classes.classes[i]);
3707
3708 }
3709}
3710
Kiran V1ccee932012-12-12 14:49:46 -08003711#endif
Atul Mittalc0f739f2014-07-31 13:47:47 +05303712// tdlsoffchan
3713/*
3714 * Process Channel Switch from SME.
3715 */
3716tSirRetStatus limProcesSmeTdlsChanSwitchReq(tpAniSirGlobal pMac,
3717 tANI_U32 *pMsgBuf)
3718{
3719 /* get all discovery request parameters */
3720 tSirTdlsChanSwitch *pTdlsChanSwitch = (tSirTdlsChanSwitch*) pMsgBuf ;
3721 tpPESession psessionEntry;
3722 tANI_U8 sessionId;
3723 tpTdlsChanSwitchParams pMsgTdlsChanSwitch;
3724 tSirMsgQ msg;
3725 tANI_U16 peerIdx = 0;
3726 tpDphHashNode pStaDs = NULL;
3727
3728 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3729 ("TDLS Channel Switch Recieved on peer:" MAC_ADDRESS_STR),
3730 MAC_ADDR_ARRAY(pTdlsChanSwitch->peerMac));
3731
3732 psessionEntry = peFindSessionByBssid(pMac,
3733 pTdlsChanSwitch->bssid,
3734 &sessionId);
3735 if (psessionEntry == NULL)
3736 {
3737 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3738 "PE Session does not exist for given sme sessionId %d",
3739 pTdlsChanSwitch->sessionId);
Atul Mittal60bd4292014-08-14 12:19:27 +05303740 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
3741 pTdlsChanSwitch->peerMac,
3742 NULL, eSIR_FAILURE) ;
Atul Mittalc0f739f2014-07-31 13:47:47 +05303743 return eSIR_FAILURE;
3744 }
3745
3746 /* check if we are in proper state to work as TDLS client */
3747 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3748 {
3749 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3750 "TDLS Channel Switch received in wrong system Role %d",
3751 psessionEntry->limSystemRole);
3752 goto lim_tdls_chan_switch_error;
3753 }
3754
3755 /*
3756 * if we are still good, go ahead and check if we are in proper state to
3757 * do TDLS discovery req/rsp/....frames.
3758 */
3759 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3760 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3761 {
3762
3763 limLog(pMac, LOGE, "TDLS Channel Switch received in invalid LIMsme state (%d)",
3764 psessionEntry->limSmeState);
3765 goto lim_tdls_chan_switch_error;
3766 }
3767
3768 pStaDs = dphLookupHashEntry(pMac, pTdlsChanSwitch->peerMac, &peerIdx,
3769 &psessionEntry->dph.dphHashTable) ;
3770 if ( NULL == pStaDs )
3771 {
3772 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
3773 goto lim_tdls_chan_switch_error;
3774
3775 }
3776 pMsgTdlsChanSwitch = vos_mem_malloc(sizeof( tTdlsChanSwitchParams ));
3777 if ( NULL == pMsgTdlsChanSwitch )
3778 {
3779 limLog( pMac, LOGE,
3780 FL( "Unable to allocate memory TDLS Channel Switch" ));
3781 return eSIR_MEM_ALLOC_FAILED;
3782 }
3783
3784 vos_mem_set( (tANI_U8 *)pMsgTdlsChanSwitch, sizeof(tpTdlsChanSwitchParams), 0);
3785
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303786 /* if channel bw offset is not set,
3787 send maximum supported offset in the band */
3788 if (pTdlsChanSwitch->tdlsOffChBwOffset == 0)
3789 {
3790 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3791 ("Set TDLS channel Bw Offset"));
3792
3793 if ((pTdlsChanSwitch->tdlsOffCh >= 1) &&
3794 (pTdlsChanSwitch->tdlsOffCh <= 14))
3795 {
3796 pTdlsChanSwitch->tdlsOffChBwOffset = BW20;
3797 }
3798 else if ((pTdlsChanSwitch->tdlsOffCh >= 36) &&
3799 (pTdlsChanSwitch->tdlsOffCh <= 169))
3800 {
3801 pTdlsChanSwitch->tdlsOffChBwOffset =
3802 limGetOffChMaxBwOffsetFromChannel(
3803 pMac->scan.countryCodeCurrent,
3804 pTdlsChanSwitch->tdlsOffCh,
3805 pStaDs->mlmStaContext.vhtCapability);
3806 }
3807 }
3808 else
3809 {
3810 /* Channel Bandwidth Offset is set through iwpriv ioctl */
3811 (pTdlsChanSwitch->tdlsOffChBwOffset)--;
3812 }
3813
Atul Mittalc0f739f2014-07-31 13:47:47 +05303814 pMsgTdlsChanSwitch->staIdx = pStaDs->staIndex;
3815 pMsgTdlsChanSwitch->tdlsOffCh = pTdlsChanSwitch->tdlsOffCh;
3816 pMsgTdlsChanSwitch->tdlsOffChBwOffset = pTdlsChanSwitch->tdlsOffChBwOffset;
3817 pMsgTdlsChanSwitch->tdlsSwMode = pTdlsChanSwitch->tdlsSwMode;
3818 pMsgTdlsChanSwitch->operClass = limGetOPClassFromChannel(
3819 pMac->scan.countryCodeCurrent,
3820 pTdlsChanSwitch->tdlsOffCh,
3821 pTdlsChanSwitch->tdlsOffChBwOffset);
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303822
Atul Mittalc0f739f2014-07-31 13:47:47 +05303823 if(pMsgTdlsChanSwitch->operClass == 0)
3824 {
3825
3826 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3827 "Invalid Operating class 0 !!!");
Kaushik, Sushant651a5342014-10-31 18:31:45 +05303828 vos_mem_free(pMsgTdlsChanSwitch);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303829 goto lim_tdls_chan_switch_error;
3830 }
3831 else
3832 {
3833
3834 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05303835 "%s: TDLS Channel Switch params: staIdx %d class %d ch %d bw %d"
3836 " mode %d country code %c%c",
Atul Mittalc0f739f2014-07-31 13:47:47 +05303837 __func__,
3838 pMsgTdlsChanSwitch->staIdx,
3839 pMsgTdlsChanSwitch->operClass,
3840 pMsgTdlsChanSwitch->tdlsOffCh,
3841 pMsgTdlsChanSwitch->tdlsOffChBwOffset,
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05303842 pMsgTdlsChanSwitch->tdlsSwMode,
3843 pMac->scan.countryCodeCurrent[0],
3844 pMac->scan.countryCodeCurrent[1]);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303845 }
3846
3847 msg.type = WDA_SET_TDLS_CHAN_SWITCH_REQ;
3848 msg.reserved = 0;
3849 msg.bodyptr = pMsgTdlsChanSwitch;
3850 msg.bodyval = 0;
3851 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
3852 {
3853 limLog(pMac, LOGE, FL("halPostMsgApi failed\n"));
Kaushik, Sushant651a5342014-10-31 18:31:45 +05303854 vos_mem_free(pMsgTdlsChanSwitch);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303855 goto lim_tdls_chan_switch_error;
3856 }
3857
3858 return eSIR_SUCCESS;
3859
3860lim_tdls_chan_switch_error:
Atul Mittal60bd4292014-08-14 12:19:27 +05303861 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
3862 pTdlsChanSwitch->peerMac,
3863 NULL, eSIR_FAILURE);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303864 return eSIR_FAILURE;
3865}
3866
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05303867/*
3868 * Set 20_40 BSS Coex IE in TDLS frames.
3869 */
3870tSirRetStatus limProcessSmeSetTdls2040BSSCoexReq(tpAniSirGlobal pMac,
3871 tANI_U32 *pMsgBuf)
3872{
3873 tAniSetTdls2040BSSCoex *pmsg = NULL;
3874 pmsg = (tAniSetTdls2040BSSCoex*) pMsgBuf ;
3875
3876 if (NULL != pmsg) {
3877 pMac->lim.EnableTdls2040BSSCoexIE = pmsg->SetTdls2040BSSCoex;
3878 }
3879 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3880 "%s: 20_40 BSS Coex IE in TDLS frames "
3881 "pMac->lim.EnableTdls2040BSSCoexIE %d ", __func__,
3882 pMac->lim.EnableTdls2040BSSCoexIE);
3883
3884 return eSIR_SUCCESS;
3885}
3886
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303887tSirRetStatus limProcessSmeDelAllTdlsPeers(tpAniSirGlobal pMac,
3888 tANI_U32 *pMsgBuf)
3889{
3890 tSirDelAllTdlsPeers *pMsg = NULL;
3891 tpDphHashNode pStaDs = NULL ;
3892 tpPESession psessionEntry = NULL;
3893 uint8_t sessionId;
3894 int i, aid;
3895 pMsg = (tSirDelAllTdlsPeers*) pMsgBuf ;
3896
3897 if (pMsg == NULL) {
3898 limLog(pMac, LOGE, FL("NULL pMsg"));
3899 return eSIR_FAILURE;
3900 }
3901
3902 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
3903 if (NULL == psessionEntry)
3904 {
3905 limLog(pMac, LOGE, FL("NULL psessionEntry"));
3906 return eSIR_FAILURE;
3907 }
3908
3909 /* Check all the set bit in peerAIDBitmap and delete the
3910 * peer (with that aid) entry from the hash table and add
3911 * the aid in free pool
3912 */
3913 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
3914 {
3915 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
3916 {
3917 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
3918 {
3919 pStaDs = dphGetHashEntry(pMac,
3920 (aid + i*(sizeof(tANI_U32) << 3)),
3921 &psessionEntry->dph.dphHashTable);
3922 if (NULL != pStaDs)
3923 {
3924 limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
3925 MAC_ADDR_ARRAY(pStaDs->staAddr));
3926
3927 limSendDeauthMgmtFrame(pMac,
3928 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3929 pStaDs->staAddr, psessionEntry,
3930 FALSE);
Masti, Narayanraddi471e9382015-07-23 18:51:29 +05303931
3932 limTdlsDelSta(pMac, pStaDs->staAddr, psessionEntry);
3933
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303934 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,
3935 &psessionEntry->dph.dphHashTable);
3936 }
3937 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)),
3938 psessionEntry) ;
3939 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
3940 }
3941 }
3942 }
3943
3944 return eSIR_SUCCESS;
3945}