blob: 9bed29053553298c5f6cbea437f4e7b1782d74c3 [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 */
Masti, Narayanraddi7e7fae62016-03-30 11:47:24 +05302532 limLog(pMac, LOG1,
2533 FL("supportedChannelWidthSet %x htSupportedChannelWidthSet %x"),
2534 htCaps->supportedChannelWidthSet,
2535 psessionEntry->htSupportedChannelWidthSet);
2536
2537 pStaDs->htSupportedChannelWidthSet =
2538 (htCaps->supportedChannelWidthSet <
2539 psessionEntry->htSupportedChannelWidthSet) ?
2540 htCaps->supportedChannelWidthSet :
2541 psessionEntry->htSupportedChannelWidthSet;
2542
2543 limLog(pMac, LOG1, FL("pStaDs->htSupportedChannelWidthSet %x"),
2544 pStaDs->htSupportedChannelWidthSet);
2545
Kiran V1ccee932012-12-12 14:49:46 -08002546 pStaDs->htMIMOPSState = htCaps->mimoPowerSave ;
2547 pStaDs->htMaxAmsduLength = htCaps->maximalAMSDUsize;
2548 pStaDs->htAMpduDensity = htCaps->mpduDensity;
2549 pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
2550 pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
2551 pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
2552 pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
2553 limFillRxHighestSupportedRate(pMac,
2554 &pStaDs->supportedRates.rxHighestDataRate,
2555 htCaps->supportedMCSSet);
2556 pStaDs->baPolicyFlag = 0xFF;
Kiran V1ccee932012-12-12 14:49:46 -08002557 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
2558 }
2559 else
2560 {
2561 pStaDs->mlmStaContext.htCapability = 0 ;
2562 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
2563 }
Hoonki Lee99e53782013-02-12 18:07:03 -08002564#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002565 limTdlsPopulateDot11fVHTCaps(pMac, pTdlsAddStaReq, &vhtCap);
Hoonki Lee99e53782013-02-12 18:07:03 -08002566 pVhtCaps = &vhtCap;
2567 if (pVhtCaps->present)
2568 {
2569 pStaDs->mlmStaContext.vhtCapability = 1 ;
Kiet Lam770920c2013-10-21 12:49:30 +05302570
Masti, Narayanraddi6b70f2c2015-12-24 14:55:44 +05302571 pStaDs->vhtSupportedChannelWidthSet =
2572 psessionEntry->vhtTxChannelWidthSet;
2573
2574 limLog(pMac, LOG1, FL("Vht supported channel width is set to = %d"),
2575 pStaDs->vhtSupportedChannelWidthSet);
Kiet Lam770920c2013-10-21 12:49:30 +05302576
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002577 pStaDs->vhtLdpcCapable = pVhtCaps->ldpcCodingCap;
2578 pStaDs->vhtBeamFormerCapable= pVhtCaps->suBeamFormerCap;
2579 // TODO , is it necessary , Sunil???
Hoonki Lee99e53782013-02-12 18:07:03 -08002580 pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_AC;
2581 }
2582 else
2583 {
2584 pStaDs->mlmStaContext.vhtCapability = 0 ;
Hoonki Lee66b75f32013-04-16 18:30:07 -07002585 pStaDs->vhtSupportedChannelWidthSet = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002586 }
2587#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002588 /*Calculate the Secondary Coannel Offset */
2589 cbMode = limTdlsSelectCBMode(pStaDs, psessionEntry);
2590
2591 pStaDs->htSecondaryChannelOffset = cbMode;
2592
2593#ifdef WLAN_FEATURE_11AC
2594 if ( pStaDs->mlmStaContext.vhtCapability )
2595 {
2596 pStaDs->htSecondaryChannelOffset = limGetHTCBState(cbMode);
2597 }
2598#endif
Deepthi Gowri22f61da2015-05-25 17:14:45 +05302599
Kiran V1ccee932012-12-12 14:49:46 -08002600 pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid,
2601 &psessionEntry->dph.dphHashTable) ;
2602
2603 /* Lets enable QOS parameter */
Pradeep Reddy POTTETI74084312015-08-04 18:26:30 +05302604 pStaDs->qosMode = (pTdlsAddStaReq->capability & CAPABILITIES_QOS_OFFSET) ||
2605 pTdlsAddStaReq->htcap_present;
Kiran V1ccee932012-12-12 14:49:46 -08002606 pStaDs->wmeEnabled = 1;
2607 pStaDs->lleEnabled = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002608 /* TDLS Dummy AddSTA does not have qosInfo , is it OK ??
2609 */
2610 pStaDs->qos.capability.qosInfo = (*(tSirMacQosInfoStation *) &pTdlsAddStaReq->uapsd_queues);
Kiran V1ccee932012-12-12 14:49:46 -08002611
2612 /* populate matching rate set */
Kiran V1ccee932012-12-12 14:49:46 -08002613
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002614 /* TDLS Dummy AddSTA does not have HTCap,VHTCap,Rates info , is it OK ??
2615 */
2616 limTdlsPopulateMatchingRateSet(pMac, pStaDs, pTdlsAddStaReq->supported_rates,
2617 pTdlsAddStaReq->supported_rates_length,
2618 (tANI_U8 *)pTdlsAddStaReq->htCap.suppMcsSet,
2619 &pStaDs->mlmStaContext.propRateSet,
Kiet Lam770920c2013-10-21 12:49:30 +05302620 psessionEntry, pVhtCaps);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002621
2622 /* TDLS Dummy AddSTA does not have right capability , is it OK ??
2623 */
2624 pStaDs->mlmStaContext.capabilityInfo = ( *(tSirMacCapabilityInfo *) &pTdlsAddStaReq->capability);
Kiran V1ccee932012-12-12 14:49:46 -08002625
2626 return ;
2627}
2628
Kiran V1ccee932012-12-12 14:49:46 -08002629/*
Deepthi Gowri22f61da2015-05-25 17:14:45 +05302630 * Add STA for TDLS setup procedure
Kiran V1ccee932012-12-12 14:49:46 -08002631 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002632static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac,
2633 tSirTdlsAddStaReq *pAddStaReq,
2634 tpPESession psessionEntry)
Kiran V1ccee932012-12-12 14:49:46 -08002635{
2636 tpDphHashNode pStaDs = NULL ;
2637 tSirRetStatus status = eSIR_SUCCESS ;
2638 tANI_U16 aid = 0 ;
2639
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002640 pStaDs = dphLookupHashEntry(pMac, pAddStaReq->peerMac, &aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002641 &psessionEntry->dph.dphHashTable);
Kiran V1ccee932012-12-12 14:49:46 -08002642 if(NULL == pStaDs)
2643 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002644 aid = limAssignPeerIdx(pMac, psessionEntry) ;
2645
2646 if( !aid )
2647 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302648 limLog(pMac, LOGE, FL("No more free AID for peer " MAC_ADDRESS_STR),
2649 MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002650 return eSIR_FAILURE;
2651 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002652
2653 /* Set the aid in peerAIDBitmap as it has been assigned to TDLS peer */
2654 SET_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, aid);
2655
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302656 limLog(pMac, LOG1, FL("Aid = %d, for peer =" MAC_ADDRESS_STR),
2657 aid, MAC_ADDR_ARRAY(pAddStaReq->peerMac));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002658 pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
2659
2660 if (pStaDs)
2661 {
2662 (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
2663 limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
2664 }
2665
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002666 pStaDs = dphAddHashEntry(pMac, pAddStaReq->peerMac, aid,
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002667 &psessionEntry->dph.dphHashTable) ;
2668
2669 if(NULL == pStaDs)
2670 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302671 limLog(pMac, LOGE, FL("add hash entry failed"));
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002672 VOS_ASSERT(0) ;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07002673 return eSIR_FAILURE;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002674 }
Kiran V1ccee932012-12-12 14:49:46 -08002675 }
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002676
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002677 limTdlsUpdateHashNodeInfo(pMac, pStaDs, pAddStaReq, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08002678
2679 pStaDs->staType = STA_ENTRY_TDLS_PEER ;
2680
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002681 status = limAddSta(pMac, pStaDs, (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE) ? true: false, psessionEntry);
Kiran V1ccee932012-12-12 14:49:46 -08002682
2683 if(eSIR_SUCCESS != status)
2684 {
2685 /* should not fail */
2686 VOS_ASSERT(0) ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002687 }
Kiran V1ccee932012-12-12 14:49:46 -08002688 return status ;
2689}
2690
2691/*
2692 * Del STA, after Link is teardown or discovery response sent on direct link
2693 */
2694static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
2695 tpPESession psessionEntry)
2696{
2697 tSirRetStatus status = eSIR_SUCCESS ;
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002698 tANI_U16 peerIdx = 0 ;
Kiran V1ccee932012-12-12 14:49:46 -08002699 tpDphHashNode pStaDs = NULL ;
2700
Gopichand Nakkala777e6032012-12-31 16:39:21 -08002701 pStaDs = dphLookupHashEntry(pMac, peerMac, &peerIdx,
Kiran V1ccee932012-12-12 14:49:46 -08002702 &psessionEntry->dph.dphHashTable) ;
2703
2704 if(pStaDs)
2705 {
2706
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302707 limLog(pMac, LOG1, FL("DEL STA peer MAC: "MAC_ADDRESS_STR),
2708 MAC_ADDR_ARRAY(pStaDs->staAddr));
2709 limLog(pMac, LOG1, FL("STA type = %x, sta idx = %x"),
2710 pStaDs->staType,
2711 pStaDs->staIndex);
Edhar, Mahesh Kumarc9e9f622014-12-11 15:40:29 +05302712 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
Ganesh Kondabattini6efefb22015-01-20 12:17:42 +05302713 eSIR_MAC_PEER_TIMEDOUT_REASON);
Kiran V1ccee932012-12-12 14:49:46 -08002714 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
Kiran V1ccee932012-12-12 14:49:46 -08002715 }
2716
2717 return pStaDs ;
2718}
2719
Kiran V1ccee932012-12-12 14:49:46 -08002720/*
2721 * Once Link is setup with PEER, send Add STA ind to SME
2722 */
2723static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002724 tANI_U8 sessionId, tSirMacAddr peerMac, tANI_U8 updateSta,
2725 tDphHashNode *pStaDs, tANI_U8 status)
Kiran V1ccee932012-12-12 14:49:46 -08002726{
2727 tSirMsgQ mmhMsg = {0} ;
2728 tSirTdlsAddStaRsp *addStaRsp = NULL ;
2729 mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302730
2731 addStaRsp = vos_mem_malloc(sizeof(tSirTdlsAddStaRsp));
2732 if ( NULL == addStaRsp )
Kiran V1ccee932012-12-12 14:49:46 -08002733 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302734 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Kiran V1ccee932012-12-12 14:49:46 -08002735 return eSIR_FAILURE;
2736 }
2737
2738 addStaRsp->sessionId = sessionId;
2739 addStaRsp->statusCode = status;
2740 if( pStaDs )
2741 {
2742 addStaRsp->staId = pStaDs->staIndex ;
2743 addStaRsp->ucastSig = pStaDs->ucUcastSig ;
2744 addStaRsp->bcastSig = pStaDs->ucBcastSig ;
2745 }
2746 if( peerMac )
2747 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302748 vos_mem_copy( addStaRsp->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002749 (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
2750 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002751 if (updateSta)
2752 addStaRsp->tdlsAddOper = TDLS_OPER_UPDATE;
2753 else
2754 addStaRsp->tdlsAddOper = TDLS_OPER_ADD;
2755
Kiran V1ccee932012-12-12 14:49:46 -08002756 addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
2757 addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
2758
2759 mmhMsg.bodyptr = addStaRsp;
2760 mmhMsg.bodyval = 0;
2761 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
2762
2763 return eSIR_SUCCESS ;
2764
2765}
2766/*
2767 * STA RSP received from HAL
2768 */
2769eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg,
2770 tpPESession psessionEntry)
2771{
2772 tAddStaParams *pAddStaParams = (tAddStaParams *) msg ;
2773 tANI_U8 status = eSIR_SUCCESS ;
2774 tDphHashNode *pStaDs = NULL ;
2775 tANI_U16 aid = 0 ;
2776
2777 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302778 limLog(pMac, LOG1, FL("staIdx=%d, staMac="MAC_ADDRESS_STR),
2779 pAddStaParams->staIdx,
2780 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Kiran V1ccee932012-12-12 14:49:46 -08002781
2782 if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
2783 {
2784 VOS_ASSERT(0) ;
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302785 limLog(pMac, LOGE, FL("Add sta failed "));
Kiran V1ccee932012-12-12 14:49:46 -08002786 status = eSIR_FAILURE;
2787 goto add_sta_error;
2788 }
2789
2790 pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid,
2791 &psessionEntry->dph.dphHashTable);
2792 if(NULL == pStaDs)
2793 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302794 limLog(pMac, LOGE, FL("pStaDs is NULL "));
Kiran V1ccee932012-12-12 14:49:46 -08002795 status = eSIR_FAILURE;
2796 goto add_sta_error;
2797 }
2798
2799 pStaDs->bssId = pAddStaParams->bssIdx;
2800 pStaDs->staIndex = pAddStaParams->staIdx;
2801 pStaDs->ucUcastSig = pAddStaParams->ucUcastSig;
2802 pStaDs->ucBcastSig = pAddStaParams->ucBcastSig;
2803 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
2804 pStaDs->valid = 1 ;
Kiran V1ccee932012-12-12 14:49:46 -08002805add_sta_error:
2806 status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002807 pAddStaParams->staMac, pAddStaParams->updateSta, pStaDs, status) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302808 vos_mem_free( pAddStaParams );
Kiran V1ccee932012-12-12 14:49:46 -08002809 return status ;
2810}
2811
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302812void PopulateDot11fTdlsOffchannelParams(tpAniSirGlobal pMac,
2813 tpPESession psessionEntry,
2814 tDot11fIESuppChannels *suppChannels,
2815 tDot11fIESuppOperatingClasses *suppOperClasses)
2816{
2817 tANI_U32 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2818 tANI_U8 validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302819 tANI_U8 i, j;
Atul Mittalb849d5a2014-07-29 12:08:39 +05302820 tANI_U8 op_class;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302821 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
2822 validChan, &numChans) != eSIR_SUCCESS)
2823 {
2824 /**
2825 * Could not get Valid channel list from CFG.
2826 * Log error.
2827 */
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302828 limLog(pMac, LOGE, FL("could not retrieve valid channel list"));
Sushant Kaushik5b4c8212015-02-20 14:54:25 +05302829 return;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302830 }
2831 suppChannels->num_bands = (tANI_U8) numChans;
2832
Masti, Narayanraddi2f5dd652015-03-03 22:00:44 +05302833 for ( i = 0U, j = 0U; i < suppChannels->num_bands &&
2834 j < LIM_MAX_BANDS; i++)
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302835 {
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302836 /* don't populate dfs channels in supported channels ie */
Pradeep Reddy POTTETIf066fe32015-04-23 11:59:33 +05302837 if (!(NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(validChan[i]))) {
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302838 suppChannels->bands[j][0] = validChan[i];
2839 suppChannels->bands[j][1] = 1;
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05302840 /* store tdls self supported channels */
2841 tdlsSelfSupportedChannels[j] = validChan[i];
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302842 j++;
2843 }
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302844 }
Pradeep Reddy POTTETI1571b4f2015-02-18 15:34:26 +05302845 /* update the channel list with new length */
2846 suppChannels->num_bands = j;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302847 suppChannels->present = 1 ;
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05302848 /* store tdls self supported channels new length */
2849 tdlsSelfNumChans = j;
2850
Atul Mittalb849d5a2014-07-29 12:08:39 +05302851 /*Get present operating class based on current operating channel*/
2852 op_class = limGetOPClassFromChannel(
2853 pMac->scan.countryCodeCurrent,
2854 psessionEntry->currentOperChannel,
2855 psessionEntry->htSecondaryChannelOffset);
2856 if (op_class == 0)
2857 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302858 limLog(pMac, LOGE,
2859 FL("Present Operating class is wrong, countryCodeCurrent: %s, currentOperChannel: %d, htSecondaryChannelOffset: %d"),
2860 pMac->scan.countryCodeCurrent,
2861 psessionEntry->currentOperChannel,
2862 psessionEntry->htSecondaryChannelOffset);
Atul Mittalb849d5a2014-07-29 12:08:39 +05302863 }
2864 else
2865 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302866 limLog(pMac, LOG1,
2867 FL("Present Operating channel=%d offset=%d class=%d"),
2868 psessionEntry->currentOperChannel,
2869 psessionEntry->htSecondaryChannelOffset,
2870 op_class);
Atul Mittalb849d5a2014-07-29 12:08:39 +05302871 }
2872 suppOperClasses->present = 1;
2873 suppOperClasses->classes[0] = op_class;
2874 /*Fill operating classes from static array*/
2875 suppOperClasses->num_classes = op_classes.num_classes;
2876 for ( i = 0U; i < suppOperClasses->num_classes; i++)
2877 {
2878 suppOperClasses->classes[i+1] = op_classes.classes[i];
2879
2880 }
2881 /*increment for present operating class*/
2882 suppOperClasses->num_classes++;
Naresh Jayarambc62ba42014-02-12 21:39:14 +05302883 return ;
2884}
2885
2886
Kiran V1ccee932012-12-12 14:49:46 -08002887/*
2888 * FUNCTION: Populate Link Identifier element IE
2889 *
2890 */
2891
Atul Mittalb849d5a2014-07-29 12:08:39 +05302892
Kiran V1ccee932012-12-12 14:49:46 -08002893void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
2894 tDot11fIELinkIdentifier *linkIden,
2895 tSirMacAddr peerMac, tANI_U8 reqType)
2896{
2897 //tANI_U32 size = sizeof(tSirMacAddr) ;
2898 tANI_U8 *initStaAddr = NULL ;
2899 tANI_U8 *respStaAddr = NULL ;
2900
2901 (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
2902 (respStaAddr = linkIden->RespStaAddr))
2903 : ((respStaAddr = linkIden->InitStaAddr ),
2904 (initStaAddr = linkIden->RespStaAddr)) ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302905 vos_mem_copy( (tANI_U8 *)linkIden->bssid,
Kiran V1ccee932012-12-12 14:49:46 -08002906 (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ;
2907
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302908 vos_mem_copy( (tANI_U8 *)initStaAddr,
Kiran V1ccee932012-12-12 14:49:46 -08002909 psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
2910
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302911 vos_mem_copy( (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08002912 sizeof( tSirMacAddr ));
2913
2914 linkIden->present = 1 ;
2915 return ;
2916
2917}
2918
2919void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac,
2920 tDot11fIEExtCap *extCapability)
2921{
Hu Wangc12631c2016-08-11 09:57:03 +08002922 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)extCapability->bytes;
2923
2924 p_ext_cap->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
2925 p_ext_cap->TDLSPeerUAPSDBufferSTA = pMac->lim.gLimTDLSBufStaEnabled;
2926 p_ext_cap->TDLSChannelSwitching = pMac->lim.gLimTDLSOffChannelEnabled ;
2927 p_ext_cap->TDLSSupport = TDLS_SUPPORT ;
2928 p_ext_cap->TDLSProhibited = TDLS_PROHIBITED ;
2929 p_ext_cap->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
2930
2931 extCapability->present = 1;
2932 extCapability->num_bytes = lim_compute_ext_cap_ie_length(extCapability);
2933
Kiran V1ccee932012-12-12 14:49:46 -08002934 return ;
2935}
Kiran V1ccee932012-12-12 14:49:46 -08002936
2937/*
2938 * Process Send Mgmt Request from SME and transmit to AP.
2939 */
2940tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac,
2941 tANI_U32 *pMsgBuf)
2942{
2943 /* get all discovery request parameters */
2944 tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
2945 tpPESession psessionEntry;
2946 tANI_U8 sessionId;
2947 tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
2948
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302949 limLog(pMac, LOG1, FL("Send Mgmt Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08002950
2951 if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId))
2952 == NULL)
2953 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302954 limLog(pMac, LOGE,
2955 FL("PE Session does not exist for given sme sessionId %d"),
2956 pSendMgmtReq->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08002957 goto lim_tdls_send_mgmt_error;
2958 }
2959
2960 /* check if we are in proper state to work as TDLS client */
2961 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2962 {
2963 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002964 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08002965 psessionEntry->limSystemRole);
2966 goto lim_tdls_send_mgmt_error;
2967 }
2968
2969 /*
2970 * if we are still good, go ahead and check if we are in proper state to
2971 * do TDLS discovery req/rsp/....frames.
2972 */
2973 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
2974 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
2975 {
2976
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302977 limLog(pMac, LOGE, FL("send mgmt received in invalid LIMsme state (%d)"),
2978 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08002979 goto lim_tdls_send_mgmt_error;
2980 }
Abhishek Singh888420b2016-01-06 12:28:03 +05302981 vos_tdls_tx_rx_mgmt_event(SIR_MAC_ACTION_TDLS,
2982 SIR_MAC_ACTION_TX, SIR_MAC_MGMT_ACTION,
2983 pSendMgmtReq->reqType, pSendMgmtReq->peerMac);
Kiran V1ccee932012-12-12 14:49:46 -08002984
2985 switch( pSendMgmtReq->reqType )
2986 {
2987 case SIR_MAC_TDLS_DIS_REQ:
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302988 limLog(pMac, LOG1, FL("Transmit Discovery Request Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002989 /* format TDLS discovery request frame and transmit it */
2990 limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog,
2991 psessionEntry) ;
2992 resultCode = eSIR_SME_SUCCESS;
2993 break;
2994 case SIR_MAC_TDLS_DIS_RSP:
2995 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05302996 limLog(pMac, LOG1, FL("Transmit Discovery Response Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08002997 //Send a response mgmt action frame
2998 limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
Mahesh A Saptasagar9be00d72014-08-28 16:04:43 +05302999 pSendMgmtReq->dialog, psessionEntry,
3000 &pSendMgmtReq->addIe[0],
3001 (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
Kiran V1ccee932012-12-12 14:49:46 -08003002 resultCode = eSIR_SME_SUCCESS;
3003 }
3004 break;
3005 case SIR_MAC_TDLS_SETUP_REQ:
3006 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303007 limLog(pMac, LOG1, FL("Transmit Setup Request Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08003008 limSendTdlsLinkSetupReqFrame(pMac,
3009 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
3010 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3011 resultCode = eSIR_SME_SUCCESS;
3012 }
3013 break;
3014 case SIR_MAC_TDLS_SETUP_RSP:
3015 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303016 limLog(pMac, LOG1, FL("Transmit Setup Response Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08003017 limSendTdlsSetupRspFrame(pMac,
3018 pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
3019 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3020 resultCode = eSIR_SME_SUCCESS;
3021 }
3022 break;
3023 case SIR_MAC_TDLS_SETUP_CNF:
3024 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303025 limLog(pMac, LOG1, FL("Transmit Setup Confirm Frame"));
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +05303026 limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, pSendMgmtReq->peerCapability,
Kiran V1ccee932012-12-12 14:49:46 -08003027 psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3028 resultCode = eSIR_SME_SUCCESS;
3029 }
3030 break;
3031 case SIR_MAC_TDLS_TEARDOWN:
3032 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303033 limLog(pMac, LOG1, FL("Transmit Teardown Frame"));
Kiran V1ccee932012-12-12 14:49:46 -08003034 limSendTdlsTeardownFrame(pMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08003035 pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, pSendMgmtReq->responder, psessionEntry,
Kiran V1ccee932012-12-12 14:49:46 -08003036 &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
3037 resultCode = eSIR_SME_SUCCESS;
3038 }
3039 break;
3040 case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
3041 {
3042 }
3043 break;
3044 case SIR_MAC_TDLS_CH_SWITCH_REQ:
3045 {
3046 }
3047 break;
3048 case SIR_MAC_TDLS_CH_SWITCH_RSP:
3049 {
3050 }
3051 break;
3052 case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
3053 {
3054 }
3055 break;
3056 default:
3057 break;
3058 }
3059
3060lim_tdls_send_mgmt_error:
3061
3062 limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
3063 resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
3064
3065 return eSIR_SUCCESS;
3066}
3067
3068/*
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303069 * Send Response to Link Establish Request to SME
3070 */
3071void limSendSmeTdlsLinkEstablishReqRsp(tpAniSirGlobal pMac,
3072 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
3073 tANI_U8 status)
3074{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303075 tSirMsgQ mmhMsg = {0} ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303076
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303077 tSirTdlsLinkEstablishReqRsp *pTdlsLinkEstablishReqRsp = NULL ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303078
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303079 pTdlsLinkEstablishReqRsp = vos_mem_malloc(sizeof(tSirTdlsLinkEstablishReqRsp));
3080 if ( NULL == pTdlsLinkEstablishReqRsp )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303081 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303082 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303083 return ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303084 }
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303085
3086 vos_mem_zero(pTdlsLinkEstablishReqRsp, sizeof(tSirTdlsLinkEstablishReqRsp));
3087
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303088 pTdlsLinkEstablishReqRsp->statusCode = status ;
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303089 if (pStaDs && peerMac)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303090 {
3091 vos_mem_copy(pTdlsLinkEstablishReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303092 pTdlsLinkEstablishReqRsp->sta_idx = pStaDs->staIndex;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303093 }
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303094
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303095 pTdlsLinkEstablishReqRsp->sessionId = sessionId;
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303096
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303097 mmhMsg.type = eWNI_SME_TDLS_LINK_ESTABLISH_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303098 mmhMsg.bodyptr = pTdlsLinkEstablishReqRsp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303099 mmhMsg.bodyval = 0;
3100 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3101 return ;
3102
3103
3104}
3105
3106/*
Atul Mittal60bd4292014-08-14 12:19:27 +05303107 * Send Response to Chan Switch Request to SME
3108 */
3109void limSendSmeTdlsChanSwitchReqRsp(tpAniSirGlobal pMac,
3110 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
3111 tANI_U8 status)
3112{
3113 tSirMsgQ mmhMsg = {0} ;
3114
3115 tSirTdlsChanSwitchReqRsp *pTdlsChanSwitchReqRsp = NULL ;
3116
3117 pTdlsChanSwitchReqRsp = vos_mem_malloc(sizeof(tSirTdlsChanSwitchReqRsp));
3118 if ( NULL == pTdlsChanSwitchReqRsp )
3119 {
3120 PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
3121 return ;
3122 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303123
3124 vos_mem_zero(pTdlsChanSwitchReqRsp, sizeof(tSirTdlsChanSwitchReqRsp));
3125
Atul Mittal60bd4292014-08-14 12:19:27 +05303126 pTdlsChanSwitchReqRsp->statusCode = status ;
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303127 if (pStaDs && peerMac )
Atul Mittal60bd4292014-08-14 12:19:27 +05303128 {
3129 vos_mem_copy(pTdlsChanSwitchReqRsp->peerMac, peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303130 pTdlsChanSwitchReqRsp->sta_idx = pStaDs->staIndex;;
Atul Mittal60bd4292014-08-14 12:19:27 +05303131 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303132
Atul Mittal60bd4292014-08-14 12:19:27 +05303133 pTdlsChanSwitchReqRsp->sessionId = sessionId;
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303134
Atul Mittal60bd4292014-08-14 12:19:27 +05303135 mmhMsg.type = eWNI_SME_TDLS_CHANNEL_SWITCH_RSP ;
3136 mmhMsg.bodyptr = pTdlsChanSwitchReqRsp;
3137 mmhMsg.bodyval = 0;
3138 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3139 return ;
3140
3141
3142}
3143/*
Kiran V1ccee932012-12-12 14:49:46 -08003144 * Once link is teardown, send Del Peer Ind to SME
3145 */
3146static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac,
3147 tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode *pStaDs,
3148 tANI_U8 status)
3149{
3150 tSirMsgQ mmhMsg = {0} ;
3151 tSirTdlsDelStaRsp *pDelSta = NULL ;
3152 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303153
3154 pDelSta = vos_mem_malloc(sizeof(tSirTdlsDelStaRsp));
3155 if ( NULL == pDelSta )
Kiran V1ccee932012-12-12 14:49:46 -08003156 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303157 limLog(pMac, LOGE, FL("Failed to allocate memory"));
Kiran V1ccee932012-12-12 14:49:46 -08003158 return eSIR_FAILURE;
3159 }
3160
3161 pDelSta->sessionId = sessionId;
3162 pDelSta->statusCode = status ;
3163 if( pStaDs )
3164 {
3165 pDelSta->staId = pStaDs->staIndex ;
3166 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003167 else
3168 pDelSta->staId = HAL_STA_INVALID_IDX;
3169
Kiran V1ccee932012-12-12 14:49:46 -08003170 if( peerMac )
3171 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303172 vos_mem_copy(pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
Kiran V1ccee932012-12-12 14:49:46 -08003173 }
3174
3175 pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
3176 pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
3177
3178 mmhMsg.bodyptr = pDelSta;
3179
3180 mmhMsg.bodyval = 0;
3181 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3182 return eSIR_SUCCESS ;
3183
3184}
3185
3186/*
3187 * Process Send Mgmt Request from SME and transmit to AP.
3188 */
3189tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac,
3190 tANI_U32 *pMsgBuf)
3191{
3192 /* get all discovery request parameters */
3193 tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
3194 tpPESession psessionEntry;
3195 tANI_U8 sessionId;
Kiran V1ccee932012-12-12 14:49:46 -08003196
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303197 limLog(pMac, LOG1, FL("TDLS Add STA Request Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08003198
3199 if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId))
3200 == NULL)
3201 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303202 limLog(pMac, LOGE,
3203 FL("PE Session does not exist for given sme sessionId %d"),
3204 pAddStaReq->sessionId);
Kiran V1ccee932012-12-12 14:49:46 -08003205 goto lim_tdls_add_sta_error;
3206 }
3207
3208 /* check if we are in proper state to work as TDLS client */
3209 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3210 {
3211 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003212 "send mgmt received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08003213 psessionEntry->limSystemRole);
3214 goto lim_tdls_add_sta_error;
3215 }
3216
3217 /*
3218 * if we are still good, go ahead and check if we are in proper state to
3219 * do TDLS discovery req/rsp/....frames.
3220 */
3221 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3222 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3223 {
3224
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303225 limLog(pMac, LOGE,
3226 FL("Add STA received in invalid LIMsme state (%d)"),
3227 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08003228 goto lim_tdls_add_sta_error;
3229 }
3230
3231 pMac->lim.gLimAddStaTdls = true ;
3232
3233 /* To start with, send add STA request to HAL */
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003234 if (eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq, psessionEntry))
Kiran V1ccee932012-12-12 14:49:46 -08003235 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303236 limLog(pMac, LOGE, FL("Add TDLS Station request failed"));
Kiran V1ccee932012-12-12 14:49:46 -08003237 goto lim_tdls_add_sta_error;
3238 }
3239 return eSIR_SUCCESS;
3240lim_tdls_add_sta_error:
3241 limSendSmeTdlsAddStaRsp(pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003242 pAddStaReq->sessionId, pAddStaReq->peerMac,
3243 (pAddStaReq->tdlsAddOper == TDLS_OPER_UPDATE), NULL, eSIR_FAILURE );
Kiran V1ccee932012-12-12 14:49:46 -08003244
3245 return eSIR_SUCCESS;
3246}
3247/*
3248 * Process Del Sta Request from SME .
3249 */
3250tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac,
3251 tANI_U32 *pMsgBuf)
3252{
3253 /* get all discovery request parameters */
3254 tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
3255 tpPESession psessionEntry;
3256 tANI_U8 sessionId;
3257 tpDphHashNode pStaDs = NULL ;
3258
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303259 limLog(pMac, LOG1, FL("TDLS Delete STA Request Recieved"));
Kiran V1ccee932012-12-12 14:49:46 -08003260
3261 if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId))
3262 == NULL)
3263 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303264 limLog(pMac, LOGE,
3265 FL("PE Session does not exist for given sme sessionId %d"),
3266 pDelStaReq->sessionId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08003267 limSendSmeTdlsDelStaRsp(pMac, pDelStaReq->sessionId, pDelStaReq->peerMac,
Kiran V1ccee932012-12-12 14:49:46 -08003268 NULL, eSIR_FAILURE) ;
3269 return eSIR_FAILURE;
3270 }
3271
3272 /* check if we are in proper state to work as TDLS client */
3273 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3274 {
3275 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003276 "Del sta received in wrong system Role %d",
Kiran V1ccee932012-12-12 14:49:46 -08003277 psessionEntry->limSystemRole);
3278 goto lim_tdls_del_sta_error;
3279 }
3280
3281 /*
3282 * if we are still good, go ahead and check if we are in proper state to
3283 * do TDLS discovery req/rsp/....frames.
3284 */
3285 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3286 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3287 {
3288
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303289 limLog(pMac, LOGE, FL("Del Sta received in invalid LIMsme state (%d)"),
3290 psessionEntry->limSmeState);
Kiran V1ccee932012-12-12 14:49:46 -08003291 goto lim_tdls_del_sta_error;
3292 }
3293
3294 pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
3295
3296 /* now send indication to SME-->HDD->TL to remove STA from TL */
3297
3298 if(pStaDs)
3299 {
3300 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
3301 pStaDs, eSIR_SUCCESS) ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003302 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
Hoonki Leef63df0d2013-01-16 19:29:14 -08003303
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003304 /* Clear the aid in peerAIDBitmap as this aid is now in freepool */
3305 CLEAR_PEER_AID_BITMAP(psessionEntry->peerAIDBitmap, pStaDs->assocId);
Hoonki Leef63df0d2013-01-16 19:29:14 -08003306 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3307
Kiran V1ccee932012-12-12 14:49:46 -08003308 return eSIR_SUCCESS;
3309
3310 }
3311
3312lim_tdls_del_sta_error:
3313 limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
3314 NULL, eSIR_FAILURE) ;
3315
3316 return eSIR_SUCCESS;
3317}
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003318
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303319/* Intersects the two input arrays and outputs an array */
3320/* For now the array length of tANI_U8 suffices */
3321static void limTdlsGetIntersection(tANI_U8 *input_array1,tANI_U8 input1_length,
3322 tANI_U8 *input_array2,tANI_U8 input2_length,
3323 tANI_U8 *output_array,tANI_U8 *output_length)
3324{
3325 tANI_U8 i,j,k=0,flag=0;
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05303326
3327 if (input1_length > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3328 {
3329 input1_length = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3330 }
3331
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303332 for(i=0;i<input1_length;i++)
3333 {
3334 flag=0;
3335 for(j=0;j<input2_length;j++)
3336 {
3337 if(input_array1[i]==input_array2[j])
3338 {
3339 flag=1;
3340 break;
3341 }
3342 }
3343 if(flag==1)
3344 {
3345 output_array[k]=input_array1[i];
3346 k++;
3347 }
3348 }
3349 *output_length = k;
3350}
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303351/*
3352 * Process Link Establishment Request from SME .
3353 */
3354tSirRetStatus limProcesSmeTdlsLinkEstablishReq(tpAniSirGlobal pMac,
3355 tANI_U32 *pMsgBuf)
3356{
3357 /* get all discovery request parameters */
3358 tSirTdlsLinkEstablishReq *pTdlsLinkEstablishReq = (tSirTdlsLinkEstablishReq*) pMsgBuf ;
3359 tpPESession psessionEntry;
3360 tANI_U8 sessionId;
3361 tpTdlsLinkEstablishParams pMsgTdlsLinkEstablishReq;
3362 tSirMsgQ msg;
3363 tANI_U16 peerIdx = 0 ;
3364 tpDphHashNode pStaDs = NULL ;
3365
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303366 limLog(pMac, LOG1, FL("Link Establish Request Recieved")) ;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303367
3368 if((psessionEntry = peFindSessionByBssid(pMac, pTdlsLinkEstablishReq->bssid, &sessionId))
3369 == NULL)
3370 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303371 limLog(pMac, LOGE,
3372 FL("PE Session does not exist for given sme sessionId %d"),
3373 pTdlsLinkEstablishReq->sessionId);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303374 limSendSmeTdlsLinkEstablishReqRsp(pMac, pTdlsLinkEstablishReq->sessionId, pTdlsLinkEstablishReq->peerMac,
3375 NULL, eSIR_FAILURE) ;
3376 return eSIR_FAILURE;
3377 }
3378
3379 /* check if we are in proper state to work as TDLS client */
3380 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3381 {
3382 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003383 "TDLS Link Establish Request received in wrong system Role %d",
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303384 psessionEntry->limSystemRole);
3385 goto lim_tdls_link_establish_error;
3386 }
3387
3388 /*
3389 * if we are still good, go ahead and check if we are in proper state to
3390 * do TDLS discovery req/rsp/....frames.
3391 */
3392 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3393 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3394 {
3395
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303396 limLog(pMac, LOGE,
3397 FL("TDLS Link Establish Request received in invalid LIMsme state (%d)"),
3398 psessionEntry->limSmeState);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303399 goto lim_tdls_link_establish_error;
3400 }
3401 /*TODO Sunil , TDLSPeer Entry has the STA ID , Use it */
3402 pStaDs = dphLookupHashEntry(pMac, pTdlsLinkEstablishReq->peerMac, &peerIdx,
3403 &psessionEntry->dph.dphHashTable) ;
3404 if ( NULL == pStaDs )
3405 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303406 limLog(pMac, LOGE, FL( "pStaDs is NULL"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303407 goto lim_tdls_link_establish_error;
3408
3409 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303410 pMsgTdlsLinkEstablishReq = vos_mem_malloc(sizeof( tTdlsLinkEstablishParams ));
3411 if ( NULL == pMsgTdlsLinkEstablishReq )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303412 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303413 limLog(pMac, LOGE,
3414 FL("Unable to allocate memory TDLS Link Establish Request"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303415 return eSIR_MEM_ALLOC_FAILED;
3416 }
3417
Girish Gowlicf762742014-07-02 13:54:09 +05303418 vos_mem_set( (tANI_U8 *)pMsgTdlsLinkEstablishReq, sizeof(tTdlsLinkEstablishParams), 0);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303419
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05303420 pMsgTdlsLinkEstablishReq->staIdx = pStaDs->staIndex;
3421 pMsgTdlsLinkEstablishReq->isResponder = pTdlsLinkEstablishReq->isResponder;
3422 pMsgTdlsLinkEstablishReq->uapsdQueues = pTdlsLinkEstablishReq->uapsdQueues;
3423 pMsgTdlsLinkEstablishReq->maxSp = pTdlsLinkEstablishReq->maxSp;
3424 pMsgTdlsLinkEstablishReq->isBufsta = pTdlsLinkEstablishReq->isBufSta;
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303425
Atul Mittalbceb4a12014-11-27 18:50:19 +05303426 if (psessionEntry->tdlsChanSwitProhibited)
3427 {
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303428 /* If channel switch is prohibited by AP then dut can either
3429 * send a switch channel request with failure status or it can
3430 * ignore the request without sending the response.
3431 * isOffChannelSupported = 0 disables the TDLS off-channel and
3432 * if off-channel support is disabled then FW ignores switch
3433 * channel request sent by TDLS peer */
3434 pMsgTdlsLinkEstablishReq->isOffChannelSupported = 0;
Atul Mittalbceb4a12014-11-27 18:50:19 +05303435 limLog(pMac, LOG1, FL("Channel Switch Prohibited by AP"));
3436 }
3437 else
3438 {
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303439 pMsgTdlsLinkEstablishReq->isOffChannelSupported =
3440 pTdlsLinkEstablishReq->isOffChannelSupported;
Atul Mittalbceb4a12014-11-27 18:50:19 +05303441 }
Ganesh Kondabattiniebf56a12015-02-19 16:22:42 +05303442
Pradeep Reddy POTTETI7e6de8d2014-07-18 17:24:19 +05303443 if ((pTdlsLinkEstablishReq->supportedChannelsLen > 0) &&
3444 (pTdlsLinkEstablishReq->supportedChannelsLen <= SIR_MAC_MAX_SUPP_CHANNELS))
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303445 {
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05303446 /* check self supported channels and pass them to FW */
3447 if ((tdlsSelfNumChans > 0) &&
3448 (tdlsSelfNumChans < LIM_TDLS_MAX_NON_DFS_CHANNELS))
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303449 {
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05303450 limTdlsGetIntersection(tdlsSelfSupportedChannels, tdlsSelfNumChans,
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303451 pTdlsLinkEstablishReq->supportedChannels,
3452 pTdlsLinkEstablishReq->supportedChannelsLen,
3453 pMsgTdlsLinkEstablishReq->validChannels,
3454 &pMsgTdlsLinkEstablishReq->validChannelsLen);
Pradeep Reddy POTTETI8f736ad2015-04-23 15:20:16 +05303455 }
Naresh Jayarambc62ba42014-02-12 21:39:14 +05303456 }
3457 vos_mem_copy(pMsgTdlsLinkEstablishReq->validOperClasses,
3458 pTdlsLinkEstablishReq->supportedOperClasses, pTdlsLinkEstablishReq->supportedOperClassesLen);
3459 pMsgTdlsLinkEstablishReq->validOperClassesLen =
3460 pTdlsLinkEstablishReq->supportedOperClassesLen;
3461
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303462 msg.type = WDA_SET_TDLS_LINK_ESTABLISH_REQ;
3463 msg.reserved = 0;
3464 msg.bodyptr = pMsgTdlsLinkEstablishReq;
3465 msg.bodyval = 0;
3466 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
3467 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003468 limLog(pMac, LOGE, FL("halPostMsgApi failed"));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303469 goto lim_tdls_link_establish_error;
3470 }
3471 return eSIR_SUCCESS;
3472lim_tdls_link_establish_error:
3473 limSendSmeTdlsLinkEstablishReqRsp(pMac, psessionEntry->smeSessionId, pTdlsLinkEstablishReq->peerMac,
3474 NULL, eSIR_FAILURE) ;
3475
3476 return eSIR_SUCCESS;
3477}
3478
3479
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003480/* Delete all the TDLS peer connected before leaving the BSS */
3481tSirRetStatus limDeleteTDLSPeers(tpAniSirGlobal pMac, tpPESession psessionEntry)
3482{
3483 tpDphHashNode pStaDs = NULL ;
3484 int i, aid;
3485
3486 if (NULL == psessionEntry)
3487 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303488 limLog(pMac, LOGE, FL("NULL psessionEntry"));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003489 return eSIR_FAILURE;
3490 }
3491
3492 /* Check all the set bit in peerAIDBitmap and delete the peer (with that aid) entry
3493 from the hash table and add the aid in free pool */
3494 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
3495 {
3496 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
3497 {
3498 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
3499 {
3500 pStaDs = dphGetHashEntry(pMac, (aid + i*(sizeof(tANI_U32) << 3)), &psessionEntry->dph.dphHashTable);
3501
3502 if (NULL != pStaDs)
3503 {
Sachin Ahujab3a1a152014-11-11 22:14:10 +05303504 limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
3505 MAC_ADDR_ARRAY(pStaDs->staAddr));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003506
3507 limSendDeauthMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3508 pStaDs->staAddr, psessionEntry, FALSE);
3509 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, &psessionEntry->dph.dphHashTable);
3510 }
3511 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)), psessionEntry) ;
3512 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
3513 }
3514 }
3515 }
3516 limSendSmeTDLSDeleteAllPeerInd(pMac, psessionEntry);
3517
3518 return eSIR_SUCCESS;
3519}
Atul Mittalb849d5a2014-07-29 12:08:39 +05303520
3521
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303522tANI_U8 limGetOffChMaxBwOffsetFromChannel(tANI_U8 *country,
3523 tANI_U8 channel,
3524 tANI_U8 peerVHTCapability)
3525{
3526 op_class_map_t *class = NULL;
3527 tANI_U16 i = 0;
3528 offset_t offset = BW20, max_allowed = BW80;
3529
3530 if ((TRUE == peerVHTCapability) &&
3531 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC) &&
3532 IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC))
3533 max_allowed = BW80;
3534 else
3535 max_allowed = BW40MINUS;
3536
3537 if (VOS_TRUE == vos_mem_compare(country,"US", 2)) {
3538
3539 class = us_op_class;
3540
3541 } else if (VOS_TRUE == vos_mem_compare(country,"EU", 2)) {
3542
3543 class = euro_op_class;
3544
3545 } else if (VOS_TRUE == vos_mem_compare(country,"JP", 2)) {
3546
3547 class = japan_op_class;
3548
3549 } else {
3550
3551 class = global_op_class;
3552
3553 }
3554
3555 while (class->op_class)
3556 {
3557 for (i=0; (i < 25 && class->channels[i]); i++)
3558 {
3559 if (channel == class->channels[i] && class->offset <= max_allowed)
3560 offset = class->offset;
3561 }
3562 class++;
3563 }
3564
3565 return offset;
3566}
3567
Abhishek Singh0f09f382018-12-04 14:06:07 +05303568offset_t lim_get_channel_width_from_opclass(tANI_U8 *country, tANI_U8 channel,
3569 tANI_U8 peer_vht_capable,
3570 tANI_U8 op_class)
3571{
3572 op_class_map_t *class;
3573 tANI_U16 i = 0;
3574 offset_t offset, max_allowed;
3575
3576 if (peer_vht_capable &&
3577 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC) &&
3578 IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC))
3579 max_allowed = BW80;
3580 else
3581 max_allowed = BW40MINUS;
3582
3583 if (vos_mem_compare(country,"US", 2))
3584 class = us_op_class;
3585 else if (vos_mem_compare(country,"EU", 2))
3586 class = euro_op_class;
3587 else if (vos_mem_compare(country,"JP", 2))
3588 class = japan_op_class;
3589 else
3590 class = global_op_class;
3591
3592 while (class->op_class) {
3593 if (op_class == class->op_class) {
3594 for (i = 0; (i < 25 && class->channels[i]); i++) {
3595 if (channel == class->channels[i]) {
3596 offset = class->offset;
3597 return (offset <= max_allowed) ? offset: BW20;
3598 }
3599 }
3600 }
3601 class++;
3602 }
3603
3604 return BW20;
3605}
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303606
Atul Mittalb849d5a2014-07-29 12:08:39 +05303607tANI_U8 limGetOPClassFromChannel(tANI_U8 *country,
3608 tANI_U8 channel,
3609 tANI_U8 offset)
3610{
3611 op_class_map_t *class = NULL;
3612 tANI_U16 i = 0;
3613
3614 if (VOS_TRUE == vos_mem_compare(country,"US", 2)) {
3615
3616 class = us_op_class;
3617
3618 } else if (VOS_TRUE == vos_mem_compare(country,"EU", 2)) {
3619
3620 class = euro_op_class;
3621
3622 } else if (VOS_TRUE == vos_mem_compare(country,"JP", 2)) {
3623
3624 class = japan_op_class;
3625
3626 } else {
3627
3628 class = global_op_class;
3629
3630 }
3631
3632 while (class->op_class)
3633 {
3634 if ((offset == class->offset) || (offset == BWALL))
3635 {
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303636 for (i=0; (i < 25 && class->channels[i]); i++)
Atul Mittalb849d5a2014-07-29 12:08:39 +05303637 {
3638 if (channel == class->channels[i])
3639 return class->op_class;
3640 }
3641 }
3642 class++;
3643 }
3644 return 0;
3645}
3646
3647tANI_BOOLEAN CheckAndAddOP(tANI_U8 class)
3648{
3649 tANI_U8 i;
3650
3651 for (i=0; i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1); i++)
3652 {
3653 /*0 is an invalid class. If class is already present ignore*/
3654 if (class == op_classes.classes[i])
3655 return FALSE;
3656 if(op_classes.classes[i] == 0)
3657 {
3658 return TRUE;
3659 }
3660 }
3661 //limLog(pMac, LOGE, FL("No space left for class = %d"), class);
3662 return FALSE;
3663}
3664
3665void limInitOperatingClasses( tHalHandle hHal )
3666{
3667
3668 tANI_U8 Index = 0;
3669 tANI_U8 class = 0;
3670 tANI_U8 i = 0;
3671 tANI_U8 j = 0;
3672 tANI_U8 swap = 0;
3673 tANI_U8 numChannels = 0;
3674 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3675 limLog(pMac, LOG1, FL("Current Country = %c%c"),
3676 pMac->scan.countryCodeCurrent[0],
3677 pMac->scan.countryCodeCurrent[1]);
3678
3679 vos_mem_set(op_classes.classes, sizeof(op_classes.classes), 0);
3680 numChannels = pMac->scan.baseChannels.numChannels;
3681 limLog(pMac, LOG1, "Num of base ch =%d", numChannels);
3682 for ( Index = 0;
3683 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
3684 Index++)
3685 {
3686 class = limGetOPClassFromChannel(
3687 pMac->scan.countryCodeCurrent,
3688 pMac->scan.baseChannels.channelList[ Index ],
3689 BWALL);
3690 limLog(pMac, LOG4, "ch=%d <=> %d=class",
3691 pMac->scan.baseChannels.channelList[ Index ],
3692 class);
3693 if (CheckAndAddOP(class))
3694 {
3695 op_classes.classes[i]= class;
3696 i++;
3697 }
3698 }
3699
3700 numChannels = pMac->scan.base20MHzChannels.numChannels;
3701 limLog(pMac, LOG1, "Num of 20MHz ch =%d", numChannels);
3702 for ( Index = 0;
3703 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
3704 Index++)
3705 {
3706 class = limGetOPClassFromChannel(
3707 pMac->scan.countryCodeCurrent,
3708 pMac->scan.base20MHzChannels.channelList[ Index ],
3709 BWALL);
3710 limLog(pMac, LOG4, "ch=%d <=> %d=class",
3711 pMac->scan.base20MHzChannels.channelList[ Index ],
3712 class);
3713 if (CheckAndAddOP(class))
3714 {
3715 op_classes.classes[i]= class;
3716 i++;
3717 }
3718 }
3719
3720 numChannels = pMac->scan.base40MHzChannels.numChannels;
3721 limLog(pMac, LOG1, "Num of 40MHz ch =%d", numChannels);
3722 for ( Index = 0;
3723 Index < numChannels && i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1);
3724 Index++)
3725 {
3726 class = limGetOPClassFromChannel(
3727 pMac->scan.countryCodeCurrent,
3728 pMac->scan.base40MHzChannels.channelList[ Index ],
3729 BWALL);
3730 limLog(pMac, LOG4, "ch=%d <=> %d=class",
3731 pMac->scan.base40MHzChannels.channelList[ Index ],
3732 class);
3733 if (CheckAndAddOP(class))
3734 {
3735 op_classes.classes[i]= class;
3736 i++;
3737 }
3738 }
3739
3740 op_classes.num_classes = i;
3741 limLog(pMac, LOG1, "Total number of Unique supported classes =%d",
3742 op_classes.num_classes);
3743 /*as per spec the operating classes should be in ascending order*/
3744 /*Bubble sort is fine as we don't have many classes*/
3745 for (i = 0 ; i < ( op_classes.num_classes - 1 ); i++)
3746 {
3747 for (j = 0 ; j < op_classes.num_classes - i - 1; j++)
3748 {
3749 /* For decreasing order use < */
3750 if (op_classes.classes[j] > op_classes.classes[j+1])
3751 {
3752 swap = op_classes.classes[j];
3753 op_classes.classes[j] = op_classes.classes[j+1];
3754 op_classes.classes[j+1] = swap;
3755 }
3756 }
3757 }
3758 for (i=0; i < op_classes.num_classes; i++)
3759 {
3760
3761 limLog(pMac, LOG1, "supported op_class[%d]=%d", i,
3762 op_classes.classes[i]);
3763
3764 }
3765}
3766
Kiran V1ccee932012-12-12 14:49:46 -08003767#endif
Atul Mittalc0f739f2014-07-31 13:47:47 +05303768// tdlsoffchan
3769/*
3770 * Process Channel Switch from SME.
3771 */
3772tSirRetStatus limProcesSmeTdlsChanSwitchReq(tpAniSirGlobal pMac,
3773 tANI_U32 *pMsgBuf)
3774{
3775 /* get all discovery request parameters */
3776 tSirTdlsChanSwitch *pTdlsChanSwitch = (tSirTdlsChanSwitch*) pMsgBuf ;
3777 tpPESession psessionEntry;
3778 tANI_U8 sessionId;
3779 tpTdlsChanSwitchParams pMsgTdlsChanSwitch;
3780 tSirMsgQ msg;
3781 tANI_U16 peerIdx = 0;
3782 tpDphHashNode pStaDs = NULL;
3783
3784 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3785 ("TDLS Channel Switch Recieved on peer:" MAC_ADDRESS_STR),
3786 MAC_ADDR_ARRAY(pTdlsChanSwitch->peerMac));
3787
3788 psessionEntry = peFindSessionByBssid(pMac,
3789 pTdlsChanSwitch->bssid,
3790 &sessionId);
3791 if (psessionEntry == NULL)
3792 {
3793 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3794 "PE Session does not exist for given sme sessionId %d",
3795 pTdlsChanSwitch->sessionId);
Atul Mittal60bd4292014-08-14 12:19:27 +05303796 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
3797 pTdlsChanSwitch->peerMac,
3798 NULL, eSIR_FAILURE) ;
Atul Mittalc0f739f2014-07-31 13:47:47 +05303799 return eSIR_FAILURE;
3800 }
3801
3802 /* check if we are in proper state to work as TDLS client */
3803 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3804 {
3805 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3806 "TDLS Channel Switch received in wrong system Role %d",
3807 psessionEntry->limSystemRole);
3808 goto lim_tdls_chan_switch_error;
3809 }
3810
3811 /*
3812 * if we are still good, go ahead and check if we are in proper state to
3813 * do TDLS discovery req/rsp/....frames.
3814 */
3815 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3816 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3817 {
3818
3819 limLog(pMac, LOGE, "TDLS Channel Switch received in invalid LIMsme state (%d)",
3820 psessionEntry->limSmeState);
3821 goto lim_tdls_chan_switch_error;
3822 }
3823
3824 pStaDs = dphLookupHashEntry(pMac, pTdlsChanSwitch->peerMac, &peerIdx,
3825 &psessionEntry->dph.dphHashTable) ;
3826 if ( NULL == pStaDs )
3827 {
3828 limLog( pMac, LOGE, FL( "pStaDs is NULL" ));
3829 goto lim_tdls_chan_switch_error;
3830
3831 }
3832 pMsgTdlsChanSwitch = vos_mem_malloc(sizeof( tTdlsChanSwitchParams ));
3833 if ( NULL == pMsgTdlsChanSwitch )
3834 {
3835 limLog( pMac, LOGE,
3836 FL( "Unable to allocate memory TDLS Channel Switch" ));
3837 return eSIR_MEM_ALLOC_FAILED;
3838 }
3839
Sunkad, Anand Ningappabf1650a2016-02-08 12:08:13 +05303840 vos_mem_set( (tANI_U8 *)pMsgTdlsChanSwitch, sizeof(*pMsgTdlsChanSwitch), 0);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303841
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303842 /* if channel bw offset is not set,
3843 send maximum supported offset in the band */
3844 if (pTdlsChanSwitch->tdlsOffChBwOffset == 0)
3845 {
3846 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3847 ("Set TDLS channel Bw Offset"));
3848
3849 if ((pTdlsChanSwitch->tdlsOffCh >= 1) &&
3850 (pTdlsChanSwitch->tdlsOffCh <= 14))
3851 {
3852 pTdlsChanSwitch->tdlsOffChBwOffset = BW20;
3853 }
3854 else if ((pTdlsChanSwitch->tdlsOffCh >= 36) &&
3855 (pTdlsChanSwitch->tdlsOffCh <= 169))
3856 {
3857 pTdlsChanSwitch->tdlsOffChBwOffset =
3858 limGetOffChMaxBwOffsetFromChannel(
3859 pMac->scan.countryCodeCurrent,
3860 pTdlsChanSwitch->tdlsOffCh,
3861 pStaDs->mlmStaContext.vhtCapability);
3862 }
3863 }
3864 else
3865 {
3866 /* Channel Bandwidth Offset is set through iwpriv ioctl */
3867 (pTdlsChanSwitch->tdlsOffChBwOffset)--;
3868 }
3869
Atul Mittalc0f739f2014-07-31 13:47:47 +05303870 pMsgTdlsChanSwitch->staIdx = pStaDs->staIndex;
3871 pMsgTdlsChanSwitch->tdlsOffCh = pTdlsChanSwitch->tdlsOffCh;
3872 pMsgTdlsChanSwitch->tdlsOffChBwOffset = pTdlsChanSwitch->tdlsOffChBwOffset;
3873 pMsgTdlsChanSwitch->tdlsSwMode = pTdlsChanSwitch->tdlsSwMode;
3874 pMsgTdlsChanSwitch->operClass = limGetOPClassFromChannel(
3875 pMac->scan.countryCodeCurrent,
3876 pTdlsChanSwitch->tdlsOffCh,
3877 pTdlsChanSwitch->tdlsOffChBwOffset);
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05303878
Atul Mittalc0f739f2014-07-31 13:47:47 +05303879 if(pMsgTdlsChanSwitch->operClass == 0)
3880 {
3881
3882 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
3883 "Invalid Operating class 0 !!!");
Kaushik, Sushant651a5342014-10-31 18:31:45 +05303884 vos_mem_free(pMsgTdlsChanSwitch);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303885 goto lim_tdls_chan_switch_error;
3886 }
3887 else
3888 {
3889
3890 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05303891 "%s: TDLS Channel Switch params: staIdx %d class %d ch %d bw %d"
3892 " mode %d country code %c%c",
Atul Mittalc0f739f2014-07-31 13:47:47 +05303893 __func__,
3894 pMsgTdlsChanSwitch->staIdx,
3895 pMsgTdlsChanSwitch->operClass,
3896 pMsgTdlsChanSwitch->tdlsOffCh,
3897 pMsgTdlsChanSwitch->tdlsOffChBwOffset,
Ganesh Kondabattinib554d292015-02-11 14:37:25 +05303898 pMsgTdlsChanSwitch->tdlsSwMode,
3899 pMac->scan.countryCodeCurrent[0],
3900 pMac->scan.countryCodeCurrent[1]);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303901 }
3902
3903 msg.type = WDA_SET_TDLS_CHAN_SWITCH_REQ;
3904 msg.reserved = 0;
3905 msg.bodyptr = pMsgTdlsChanSwitch;
3906 msg.bodyval = 0;
3907 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
3908 {
3909 limLog(pMac, LOGE, FL("halPostMsgApi failed\n"));
Kaushik, Sushant651a5342014-10-31 18:31:45 +05303910 vos_mem_free(pMsgTdlsChanSwitch);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303911 goto lim_tdls_chan_switch_error;
3912 }
3913
3914 return eSIR_SUCCESS;
3915
3916lim_tdls_chan_switch_error:
Atul Mittal60bd4292014-08-14 12:19:27 +05303917 limSendSmeTdlsChanSwitchReqRsp(pMac, pTdlsChanSwitch->sessionId,
3918 pTdlsChanSwitch->peerMac,
3919 NULL, eSIR_FAILURE);
Atul Mittalc0f739f2014-07-31 13:47:47 +05303920 return eSIR_FAILURE;
3921}
3922
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05303923/*
3924 * Set 20_40 BSS Coex IE in TDLS frames.
3925 */
3926tSirRetStatus limProcessSmeSetTdls2040BSSCoexReq(tpAniSirGlobal pMac,
3927 tANI_U32 *pMsgBuf)
3928{
3929 tAniSetTdls2040BSSCoex *pmsg = NULL;
3930 pmsg = (tAniSetTdls2040BSSCoex*) pMsgBuf ;
3931
3932 if (NULL != pmsg) {
3933 pMac->lim.EnableTdls2040BSSCoexIE = pmsg->SetTdls2040BSSCoex;
3934 }
3935 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
3936 "%s: 20_40 BSS Coex IE in TDLS frames "
3937 "pMac->lim.EnableTdls2040BSSCoexIE %d ", __func__,
3938 pMac->lim.EnableTdls2040BSSCoexIE);
3939
3940 return eSIR_SUCCESS;
3941}
3942
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303943tSirRetStatus limProcessSmeDelAllTdlsPeers(tpAniSirGlobal pMac,
3944 tANI_U32 *pMsgBuf)
3945{
3946 tSirDelAllTdlsPeers *pMsg = NULL;
3947 tpDphHashNode pStaDs = NULL ;
3948 tpPESession psessionEntry = NULL;
3949 uint8_t sessionId;
3950 int i, aid;
3951 pMsg = (tSirDelAllTdlsPeers*) pMsgBuf ;
3952
3953 if (pMsg == NULL) {
3954 limLog(pMac, LOGE, FL("NULL pMsg"));
3955 return eSIR_FAILURE;
3956 }
3957
3958 psessionEntry = peFindSessionByBssid(pMac, pMsg->bssid, &sessionId);
3959 if (NULL == psessionEntry)
3960 {
3961 limLog(pMac, LOGE, FL("NULL psessionEntry"));
3962 return eSIR_FAILURE;
3963 }
3964
3965 /* Check all the set bit in peerAIDBitmap and delete the
3966 * peer (with that aid) entry from the hash table and add
3967 * the aid in free pool
3968 */
3969 for (i = 0; i < sizeof(psessionEntry->peerAIDBitmap)/sizeof(tANI_U32); i++)
3970 {
3971 for (aid = 0; aid < (sizeof(tANI_U32) << 3); aid++)
3972 {
3973 if (CHECK_BIT(psessionEntry->peerAIDBitmap[i], aid))
3974 {
3975 pStaDs = dphGetHashEntry(pMac,
3976 (aid + i*(sizeof(tANI_U32) << 3)),
3977 &psessionEntry->dph.dphHashTable);
3978 if (NULL != pStaDs)
3979 {
3980 limLog(pMac, LOGE, FL("Deleting "MAC_ADDRESS_STR),
3981 MAC_ADDR_ARRAY(pStaDs->staAddr));
3982
3983 limSendDeauthMgmtFrame(pMac,
3984 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3985 pStaDs->staAddr, psessionEntry,
3986 FALSE);
Masti, Narayanraddi471e9382015-07-23 18:51:29 +05303987
3988 limTdlsDelSta(pMac, pStaDs->staAddr, psessionEntry);
3989
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303990 dphDeleteHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,
3991 &psessionEntry->dph.dphHashTable);
3992 }
3993 limReleasePeerIdx(pMac, (aid + i*(sizeof(tANI_U32) << 3)),
3994 psessionEntry) ;
3995 CLEAR_BIT(psessionEntry->peerAIDBitmap[i], aid);
3996 }
3997 }
3998 }
3999
4000 return eSIR_SUCCESS;
4001}