blob: 684627da71d4a8d2d2fedc1a1c7965f84de1aca0 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Gopichand Nakkala0c1331e2013-01-07 22:49:07 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080021/*
22 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
23 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Kiran V1ccee932012-12-12 14:49:46 -080041
42/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
44
45
46 \file csrTdlsProcess.c
47
48 Implementation for the TDLS interface to PE.
49
Gopichand Nakkalabd9fa2d2013-01-08 13:16:22 -080050 Copyright (C) 2010 Qualcomm, Incorporated
Kiran V1ccee932012-12-12 14:49:46 -080051
52
53 ========================================================================== */
54
55#ifdef FEATURE_WLAN_TDLS
56
57#include "aniGlobal.h" //for tpAniSirGlobal
58#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smeInside.h"
61#include "smsDebug.h"
62
63#include "csrSupport.h"
64#include "wlan_qct_tl.h"
65
66#include "vos_diag_core_log.h"
67#include "vos_diag_core_event.h"
68#include "csrInternal.h"
69
70
71
72#ifdef FEATURE_WLAN_TDLS_INTERNAL
73/*
74 * initialize Discovery list
75 */
76eHalStatus csrTdlsInitPeerList(tpAniSirGlobal pMac )
77{
78 tCsrTdlsCtxStruct *tdlsDisInfo = &pMac->tdlsCtx ;
79 csrLLOpen(pMac->hHdd, &tdlsDisInfo->tdlsPotentialPeerList) ;
80
81 return eHAL_STATUS_SUCCESS ;
82}
83#endif
84
Kiran V1ccee932012-12-12 14:49:46 -080085/*
86 * common routine to remove TDLS cmd from SME command list..
87 * commands are removed after getting reponse from PE.
88 */
89eHalStatus csrTdlsRemoveSmeCmd(tpAniSirGlobal pMac, eSmeCommandType cmdType)
90{
91 eHalStatus status = eHAL_STATUS_FAILURE;
92 tListElem *pEntry;
93 tSmeCmd *pCommand;
94
95 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
96 if( pEntry )
97 {
98 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
99 if( cmdType == pCommand->command )
100 {
101 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
102 pEntry, LL_ACCESS_LOCK ) )
103 {
104 vos_mem_zero( &pCommand->u.tdlsCmd, sizeof( tTdlsCmd ) );
105 csrReleaseCommand( pMac, pCommand );
106 smeProcessPendingQueue( pMac );
107 status = eHAL_STATUS_SUCCESS ;
108 }
109 }
110 }
111 return status ;
112}
113
114/*
115 * TDLS request API, called from HDD to send a TDLS frame
116 * in SME/CSR and send message to PE to trigger TDLS discovery procedure.
117 */
118eHalStatus csrTdlsSendMgmtReq(tHalHandle hHal, tANI_U8 sessionId, tCsrTdlsSendMgmt *tdlsSendMgmt)
119{
120 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
121 tSmeCmd *tdlsSendMgmtCmd ;
122 eHalStatus status = eHAL_STATUS_FAILURE ;
123
124 //If connected and in Infra. Only then allow this
125 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
126 csrIsConnStateConnectedInfra( pMac, sessionId ) &&
127 (NULL != tdlsSendMgmt) )
128 {
129 tdlsSendMgmtCmd = csrGetCommandBuffer(pMac) ;
130
131 if(tdlsSendMgmtCmd)
132 {
133 tTdlsSendMgmtCmdInfo *tdlsSendMgmtCmdInfo =
134 &tdlsSendMgmtCmd->u.tdlsCmd.u.tdlsSendMgmtCmdInfo ;
135
136 tdlsSendMgmtCmd->sessionId = sessionId;
137
138 tdlsSendMgmtCmdInfo->frameType = tdlsSendMgmt->frameType ;
139 tdlsSendMgmtCmdInfo->dialog = tdlsSendMgmt->dialog ;
Hoonki Leea34dd892013-02-05 22:56:02 -0800140 tdlsSendMgmtCmdInfo->statusCode = tdlsSendMgmt->statusCode ;
141 tdlsSendMgmtCmdInfo->responder = tdlsSendMgmt->responder;
Kiran V1ccee932012-12-12 14:49:46 -0800142 palCopyMemory(pMac->hHdd, tdlsSendMgmtCmdInfo->peerMac,
143 tdlsSendMgmt->peerMac, sizeof(tSirMacAddr)) ;
144
145 if( (0 != tdlsSendMgmt->len) && (NULL != tdlsSendMgmt->buf) )
146 {
147 status = palAllocateMemory( pMac->hHdd, (void **)&tdlsSendMgmtCmdInfo->buf,
148 tdlsSendMgmt->len );
149 if(!HAL_STATUS_SUCCESS( status ) )
150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800151 smsLog( pMac, LOGE, FL("Alloc Failed") );
Kiran V1ccee932012-12-12 14:49:46 -0800152 VOS_ASSERT(0) ;
153 return status ;
154 }
155 palCopyMemory(pMac->hHdd, tdlsSendMgmtCmdInfo->buf,
156 tdlsSendMgmt->buf, tdlsSendMgmt->len );
157 tdlsSendMgmtCmdInfo->len = tdlsSendMgmt->len;
158 }
159 else
160 {
161 tdlsSendMgmtCmdInfo->buf = NULL;
162 tdlsSendMgmtCmdInfo->len = 0;
163 }
164
165 tdlsSendMgmtCmd->command = eSmeCommandTdlsSendMgmt ;
166 tdlsSendMgmtCmd->u.tdlsCmd.size = sizeof(tTdlsSendMgmtCmdInfo) ;
167 smePushCommand(pMac, tdlsSendMgmtCmd, FALSE) ;
168 status = eHAL_STATUS_SUCCESS ;
169 }
170 }
171
172 return status ;
173}
174
175/*
176 * TDLS request API, called from HDD to add a TDLS peer
177 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800178eHalStatus csrTdlsChangePeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
179 tCsrStaParams *pstaParams)
180{
181 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
182 tSmeCmd *tdlsAddStaCmd ;
183 eHalStatus status = eHAL_STATUS_FAILURE ;
184
185 //If connected and in Infra. Only then allow this
186 if (CSR_IS_SESSION_VALID( pMac, sessionId ) &&
187 csrIsConnStateConnectedInfra( pMac, sessionId ) &&
188 (NULL != peerMac)){
189
190 tdlsAddStaCmd = csrGetCommandBuffer(pMac) ;
191
192 if (tdlsAddStaCmd)
193 {
194 tTdlsAddStaCmdInfo *tdlsAddStaCmdInfo =
195 &tdlsAddStaCmd->u.tdlsCmd.u.tdlsAddStaCmdInfo ;
196
197 tdlsAddStaCmdInfo->tdlsAddOper = TDLS_OPER_UPDATE;
198
199 tdlsAddStaCmd->sessionId = sessionId;
200
201 palCopyMemory(pMac->hHdd, tdlsAddStaCmdInfo->peerMac,
202 peerMac, sizeof(tSirMacAddr)) ;
203 tdlsAddStaCmdInfo->capability = pstaParams->capability;
204 tdlsAddStaCmdInfo->uapsdQueues = pstaParams->uapsd_queues;
205 tdlsAddStaCmdInfo->maxSp = pstaParams->max_sp;
206 palCopyMemory(pMac->hHdd, tdlsAddStaCmdInfo->extnCapability,
207 pstaParams->extn_capability,
208 sizeof(pstaParams->extn_capability));
209
Hoonki Lee66b75f32013-04-16 18:30:07 -0700210 tdlsAddStaCmdInfo->htcap_present = pstaParams->htcap_present;
211 if(pstaParams->htcap_present)
212 palCopyMemory(pMac->hHdd, &tdlsAddStaCmdInfo->HTCap,
213 &pstaParams->HTCap, sizeof(pstaParams->HTCap));
214 else
215 palZeroMemory(pMac->hHdd, &tdlsAddStaCmdInfo->HTCap, sizeof(pstaParams->HTCap));
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800216
Hoonki Lee66b75f32013-04-16 18:30:07 -0700217 tdlsAddStaCmdInfo->vhtcap_present = pstaParams->vhtcap_present;
218 if(pstaParams->vhtcap_present)
219 palCopyMemory(pMac->hHdd, &tdlsAddStaCmdInfo->VHTCap,
220 &pstaParams->VHTCap, sizeof(pstaParams->VHTCap));
221 else
222 palZeroMemory(pMac->hHdd, &tdlsAddStaCmdInfo->VHTCap, sizeof(pstaParams->VHTCap));
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800223
224 tdlsAddStaCmdInfo->supportedRatesLen = pstaParams->supported_rates_len;
225
226 if (0 != pstaParams->supported_rates_len)
227 palCopyMemory(pMac->hHdd, &tdlsAddStaCmdInfo->supportedRates,
228 pstaParams->supported_rates,
229 pstaParams->supported_rates_len);
230
231 tdlsAddStaCmd->command = eSmeCommandTdlsAddPeer;
232 tdlsAddStaCmd->u.tdlsCmd.size = sizeof(tTdlsAddStaCmdInfo) ;
233 smePushCommand(pMac, tdlsAddStaCmd, FALSE) ;
234 status = eHAL_STATUS_SUCCESS ;
235 }
236 }
237
238 return status ;
239}
240
241/*
242 * TDLS request API, called from HDD to add a TDLS peer
243 */
Kiran V1ccee932012-12-12 14:49:46 -0800244eHalStatus csrTdlsAddPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
245{
246 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
247 tSmeCmd *tdlsAddStaCmd ;
248 eHalStatus status = eHAL_STATUS_FAILURE ;
249
250 //If connected and in Infra. Only then allow this
251 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
252 csrIsConnStateConnectedInfra( pMac, sessionId ) &&
253 (NULL != peerMac) )
254 {
255 tdlsAddStaCmd = csrGetCommandBuffer(pMac) ;
256
257 if(tdlsAddStaCmd)
258 {
259 tTdlsAddStaCmdInfo *tdlsAddStaCmdInfo =
260 &tdlsAddStaCmd->u.tdlsCmd.u.tdlsAddStaCmdInfo ;
261
262 tdlsAddStaCmd->sessionId = sessionId;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800263 tdlsAddStaCmdInfo->tdlsAddOper = TDLS_OPER_ADD;
Kiran V1ccee932012-12-12 14:49:46 -0800264
265 palCopyMemory(pMac->hHdd, tdlsAddStaCmdInfo->peerMac,
266 peerMac, sizeof(tSirMacAddr)) ;
267
268 tdlsAddStaCmd->command = eSmeCommandTdlsAddPeer ;
269 tdlsAddStaCmd->u.tdlsCmd.size = sizeof(tTdlsAddStaCmdInfo) ;
270 smePushCommand(pMac, tdlsAddStaCmd, FALSE) ;
271 status = eHAL_STATUS_SUCCESS ;
272 }
273 }
274
275 return status ;
276}
277
278/*
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800279 * TDLS request API, called from HDD to delete a TDLS peer
Kiran V1ccee932012-12-12 14:49:46 -0800280 */
281eHalStatus csrTdlsDelPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
282{
283 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
284 tSmeCmd *tdlsDelStaCmd ;
285 eHalStatus status = eHAL_STATUS_FAILURE ;
286
287 //If connected and in Infra. Only then allow this
288 if( CSR_IS_SESSION_VALID( pMac, sessionId ) &&
289 csrIsConnStateConnectedInfra( pMac, sessionId ) &&
290 (NULL != peerMac) )
291 {
292 tdlsDelStaCmd = csrGetCommandBuffer(pMac) ;
293
294 if(tdlsDelStaCmd)
295 {
296 tTdlsDelStaCmdInfo *tdlsDelStaCmdInfo =
297 &tdlsDelStaCmd->u.tdlsCmd.u.tdlsDelStaCmdInfo ;
298
299 tdlsDelStaCmd->sessionId = sessionId;
300
301 palCopyMemory(pMac->hHdd, tdlsDelStaCmdInfo->peerMac,
302 peerMac, sizeof(tSirMacAddr)) ;
303
304 tdlsDelStaCmd->command = eSmeCommandTdlsDelPeer ;
305 tdlsDelStaCmd->u.tdlsCmd.size = sizeof(tTdlsDelStaCmdInfo) ;
306 smePushCommand(pMac, tdlsDelStaCmd, FALSE) ;
307 status = eHAL_STATUS_SUCCESS ;
308 }
309 }
310
311 return status ;
312}
313#ifdef FEATURE_WLAN_TDLS_INTERNAL
314/*
315 * TDLS request API, called from HDD to enable TDLS discovery request
316 * in SME/CSR and send message to PE to trigger TDLS discovery procedure.
317 */
318eHalStatus csrTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tCsrTdlsDisRequest *tdlsDisReq)
319{
320 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
321 tSmeCmd *tdlsDisReqCmd ;
322 eHalStatus status = eHAL_STATUS_FAILURE ;
323
324 if(tdlsDisReq)
325 {
326 tdlsDisReqCmd = csrGetCommandBuffer(pMac) ;
327
328 if(tdlsDisReqCmd)
329 {
330 tTdlsDisReqCmdinfo *disReqCmdInfo =
331 &tdlsDisReqCmd->u.tdlsCmd.u.tdlsDisReqCmdInfo ;
332
333 tdlsDisReqCmd->sessionId = sessionId;
334
335 disReqCmdInfo->tdlsDisType = tdlsDisReq->disType ;
336 palCopyMemory(pMac->hHdd, disReqCmdInfo->peerMac,
337 tdlsDisReq->peerMac, sizeof(tSirMacAddr)) ;
338 tdlsDisReqCmd->command = eSmeCommandTdlsDiscovery ;
339 tdlsDisReqCmd->u.tdlsCmd.size = sizeof(tTdlsDisReqCmdinfo) ;
340 smePushCommand(pMac, tdlsDisReqCmd, FALSE) ;
341 status = eHAL_STATUS_SUCCESS ;
342 }
343 }
344
345 return status ;
346}
347
348/*
349 * TDLS request API, called from HDD to enable TDLS link setup request
350 * in SME/CSR and send message to PE to trigger TDLS link setup procedure.
351 */
352eHalStatus csrTdlsSetupReq(tHalHandle hHal, tANI_U8 sessionId, tCsrTdlsSetupRequest *tdlsSetupReq)
353{
354 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
355 tSmeCmd *tdlsSetupReqCmd ;
356 eHalStatus status = eHAL_STATUS_FAILURE ;
357
358 if(tdlsSetupReq)
359 {
360 tdlsSetupReqCmd = csrGetCommandBuffer(pMac) ;
361
362 if(tdlsSetupReqCmd)
363 {
364 tTdlsLinkSetupReqCmdinfo *setupCmdInfo =
365 &tdlsSetupReqCmd->u.tdlsCmd.u.tdlsLinkSetupReqCmdInfo ;
366
367 tdlsSetupReqCmd->sessionId = sessionId;
368
369 palCopyMemory(pMac->hHdd, setupCmdInfo->peerMac,
370 tdlsSetupReq->peerMac, sizeof(tSirMacAddr)) ;
371 tdlsSetupReqCmd->command = eSmeCommandTdlsLinkSetup ;
372 tdlsSetupReqCmd->u.tdlsCmd.size = sizeof(tTdlsLinkSetupReqCmdinfo) ;
373 smePushCommand(pMac, tdlsSetupReqCmd, FALSE) ;
374 status = eHAL_STATUS_SUCCESS ;
375 }
376 }
377
378 return status ;
379}
380/*
381 * TDLS request API, called from HDD to enable TDLS link teardown request
382 * in SME/CSR and send message to PE to trigger TDLS link teardown procedure.
383 */
384eHalStatus csrTdlsTeardownReq(tHalHandle hHal, tANI_U8 sessionId,
385 tCsrTdlsTeardownRequest *tdlsTeardownReq)
386{
387 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
388 tSmeCmd *tdlsTeardownReqCmd ;
389 eHalStatus status = eHAL_STATUS_FAILURE ;
390
391 if(tdlsTeardownReq)
392 {
393 tdlsTeardownReqCmd = csrGetCommandBuffer(pMac) ;
394
395 if(tdlsTeardownReqCmd)
396 {
397 tTdlsLinkTeardownCmdinfo *teardownCmdInfo =
398 &tdlsTeardownReqCmd->u.tdlsCmd.u.tdlsLinkTeardownCmdInfo ;
399
400 tdlsTeardownReqCmd->sessionId = sessionId;
401
402 palCopyMemory(pMac->hHdd, teardownCmdInfo->peerMac,
403 tdlsTeardownReq->peerMac, sizeof(tSirMacAddr)) ;
404 tdlsTeardownReqCmd->command = eSmeCommandTdlsLinkTear ;
405 tdlsTeardownReqCmd->u.tdlsCmd.size =
406 sizeof(tTdlsLinkTeardownCmdinfo) ;
407 smePushCommand(pMac, tdlsTeardownReqCmd, FALSE) ;
408 status = eHAL_STATUS_SUCCESS ;
409 }
410 }
411
412 return status ;
413}
414
415#endif
416
417/*
418 * TDLS messages sent to PE .
419 */
420eHalStatus tdlsSendMessage(tpAniSirGlobal pMac, tANI_U16 msg_type,
421 void *msg_data, tANI_U32 msg_size)
422{
423
424 tSirMbMsg *pMsg = (tSirMbMsg *)msg_data ;
425 pMsg->type = msg_type ;
426 pMsg->msgLen = (tANI_U16) (msg_size) ;
427
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800428 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800429 ("sending msg = %d"), pMsg->type) ;
Kiran V1ccee932012-12-12 14:49:46 -0800430 /* Send message. */
431 if (palSendMBMessage(pMac->hHdd, pMsg) != eHAL_STATUS_SUCCESS)
432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800433 smsLog(pMac, LOGE, FL("Cannot send message"));
Kiran V1ccee932012-12-12 14:49:46 -0800434 return eHAL_STATUS_FAILURE;
435 }
436
437 return eHAL_STATUS_SUCCESS;
438}
439
440eHalStatus csrTdlsProcessSendMgmt( tpAniSirGlobal pMac, tSmeCmd *cmd )
441{
442 tTdlsSendMgmtCmdInfo *tdlsSendMgmtCmdInfo = &cmd->u.tdlsCmd.u.tdlsSendMgmtCmdInfo ;
443 tSirTdlsSendMgmtReq *tdlsSendMgmtReq = NULL ;
444 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
445 eHalStatus status = eHAL_STATUS_FAILURE;
446
Jeff Johnson18a89562013-04-04 16:52:06 -0700447 if (NULL == pSession->pConnectBssDesc)
448 {
449 smsLog( pMac, LOGE, FL("BSS Description is not present") );
450 return eHAL_STATUS_FAILURE;
451 }
452
Kiran V1ccee932012-12-12 14:49:46 -0800453 status = palAllocateMemory( pMac->hHdd, (void **)&tdlsSendMgmtReq,
454 (sizeof(tSirTdlsSendMgmtReq) + tdlsSendMgmtCmdInfo->len ) );
455
Jeff Johnson18a89562013-04-04 16:52:06 -0700456 if (!HAL_STATUS_SUCCESS( status ) )
Kiran V1ccee932012-12-12 14:49:46 -0800457 {
Jeff Johnson18a89562013-04-04 16:52:06 -0700458 smsLog( pMac, LOGE, FL("alloc failed") );
Kiran V1ccee932012-12-12 14:49:46 -0800459 VOS_ASSERT(0) ;
460 return status ;
461 }
462 tdlsSendMgmtReq->sessionId = cmd->sessionId;
463 //Using dialog as transactionId. This can be used to match response with request
464 tdlsSendMgmtReq->transactionId = tdlsSendMgmtCmdInfo->dialog;
465 tdlsSendMgmtReq->reqType = tdlsSendMgmtCmdInfo->frameType ;
466 tdlsSendMgmtReq->dialog = tdlsSendMgmtCmdInfo->dialog ;
467 tdlsSendMgmtReq->statusCode = tdlsSendMgmtCmdInfo->statusCode ;
Hoonki Leea34dd892013-02-05 22:56:02 -0800468 tdlsSendMgmtReq->responder = tdlsSendMgmtCmdInfo->responder;
Jeff Johnson18a89562013-04-04 16:52:06 -0700469
470 palCopyMemory(pMac->hHdd, tdlsSendMgmtReq->bssid,
471 pSession->pConnectBssDesc->bssId, sizeof (tSirMacAddr));
472
Kiran V1ccee932012-12-12 14:49:46 -0800473 palCopyMemory(pMac->hHdd, tdlsSendMgmtReq->peerMac,
474 tdlsSendMgmtCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
475
476 if(tdlsSendMgmtCmdInfo->len && tdlsSendMgmtCmdInfo->buf)
477 {
478 palCopyMemory(pMac->hHdd, tdlsSendMgmtReq->addIe, tdlsSendMgmtCmdInfo->buf,
479 tdlsSendMgmtCmdInfo->len);
480
481 }
482 // Send the request to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800483 smsLog( pMac, LOG1, "sending TDLS Mgmt Frame req to PE " );
Kiran V1ccee932012-12-12 14:49:46 -0800484 status = tdlsSendMessage(pMac, eWNI_SME_TDLS_SEND_MGMT_REQ,
485 (void *)tdlsSendMgmtReq , sizeof(tSirTdlsSendMgmtReq)+tdlsSendMgmtCmdInfo->len) ;
486 if(!HAL_STATUS_SUCCESS( status ) )
487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800488 smsLog( pMac, LOGE, FL("Failed to send request to MAC"));
Kiran V1ccee932012-12-12 14:49:46 -0800489 }
490 if(tdlsSendMgmtCmdInfo->len && tdlsSendMgmtCmdInfo->buf)
491 {
492 //Done with the buf. Free it.
493 palFreeMemory( pMac->hHdd, tdlsSendMgmtCmdInfo->buf );
494 tdlsSendMgmtCmdInfo->len = 0;
495 }
496
497 return status;
498}
499
500eHalStatus csrTdlsProcessAddSta( tpAniSirGlobal pMac, tSmeCmd *cmd )
501{
502 tTdlsAddStaCmdInfo *tdlsAddStaCmdInfo = &cmd->u.tdlsCmd.u.tdlsAddStaCmdInfo ;
503 tSirTdlsAddStaReq *tdlsAddStaReq = NULL ;
504 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
505 eHalStatus status = eHAL_STATUS_FAILURE;
506
Jeff Johnson18a89562013-04-04 16:52:06 -0700507 if (NULL == pSession->pConnectBssDesc)
508 {
509 smsLog( pMac, LOGE, FL("BSS description is not present") );
510 return eHAL_STATUS_FAILURE;
511 }
512
Kiran V1ccee932012-12-12 14:49:46 -0800513 status = palAllocateMemory( pMac->hHdd, (void **)&tdlsAddStaReq,
514 (sizeof(tSirTdlsAddStaReq) ) );
515
Jeff Johnson18a89562013-04-04 16:52:06 -0700516 if (!HAL_STATUS_SUCCESS( status ) )
Kiran V1ccee932012-12-12 14:49:46 -0800517 {
Jeff Johnson18a89562013-04-04 16:52:06 -0700518 smsLog( pMac, LOGE, FL("alloc failed") );
Kiran V1ccee932012-12-12 14:49:46 -0800519 VOS_ASSERT(0) ;
520 return status ;
521 }
522 tdlsAddStaReq->sessionId = cmd->sessionId;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800523 tdlsAddStaReq->tdlsAddOper = tdlsAddStaCmdInfo->tdlsAddOper;
Kiran V1ccee932012-12-12 14:49:46 -0800524 //Using dialog as transactionId. This can be used to match response with request
525 tdlsAddStaReq->transactionId = 0;
Gopichand Nakkala5907c3e2013-03-07 16:54:48 -0800526
Jeff Johnson18a89562013-04-04 16:52:06 -0700527 palCopyMemory(pMac->hHdd, tdlsAddStaReq->bssid,
528 pSession->pConnectBssDesc->bssId, sizeof (tSirMacAddr));
Gopichand Nakkala5907c3e2013-03-07 16:54:48 -0800529
Kiran V1ccee932012-12-12 14:49:46 -0800530 palCopyMemory(pMac->hHdd, tdlsAddStaReq->peerMac,
531 tdlsAddStaCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
532
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800533 tdlsAddStaReq->capability = tdlsAddStaCmdInfo->capability;
534 tdlsAddStaReq->uapsd_queues = tdlsAddStaCmdInfo->uapsdQueues;
535 tdlsAddStaReq->max_sp = tdlsAddStaCmdInfo->maxSp;
536
537 palCopyMemory(pMac->hHdd, tdlsAddStaReq->extn_capability,
538 tdlsAddStaCmdInfo->extnCapability,
539 SIR_MAC_MAX_EXTN_CAP);
Hoonki Lee66b75f32013-04-16 18:30:07 -0700540 tdlsAddStaReq->htcap_present = tdlsAddStaCmdInfo->htcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800541 palCopyMemory(pMac->hHdd, &tdlsAddStaReq->htCap,
542 &tdlsAddStaCmdInfo->HTCap, sizeof(tdlsAddStaCmdInfo->HTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -0700543 tdlsAddStaReq->vhtcap_present = tdlsAddStaCmdInfo->vhtcap_present;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800544 palCopyMemory(pMac->hHdd, &tdlsAddStaReq->vhtCap,
545 &tdlsAddStaCmdInfo->VHTCap, sizeof(tdlsAddStaCmdInfo->VHTCap));
546 tdlsAddStaReq->supported_rates_length = tdlsAddStaCmdInfo->supportedRatesLen;
547 palCopyMemory(pMac->hHdd, &tdlsAddStaReq->supported_rates,
548 tdlsAddStaCmdInfo->supportedRates, tdlsAddStaCmdInfo->supportedRatesLen);
549
Kiran V1ccee932012-12-12 14:49:46 -0800550 // Send the request to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800551 smsLog( pMac, LOGE, "sending TDLS Add Sta req to PE " );
Kiran V1ccee932012-12-12 14:49:46 -0800552 status = tdlsSendMessage(pMac, eWNI_SME_TDLS_ADD_STA_REQ,
553 (void *)tdlsAddStaReq , sizeof(tSirTdlsAddStaReq)) ;
554 if(!HAL_STATUS_SUCCESS( status ) )
555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800556 smsLog( pMac, LOGE, FL("Failed to send request to MAC"));
Kiran V1ccee932012-12-12 14:49:46 -0800557 }
558 return status;
559}
560
561eHalStatus csrTdlsProcessDelSta( tpAniSirGlobal pMac, tSmeCmd *cmd )
562{
563 tTdlsDelStaCmdInfo *tdlsDelStaCmdInfo = &cmd->u.tdlsCmd.u.tdlsDelStaCmdInfo ;
564 tSirTdlsDelStaReq *tdlsDelStaReq = NULL ;
565 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
566 eHalStatus status = eHAL_STATUS_FAILURE;
567
Jeff Johnson18a89562013-04-04 16:52:06 -0700568 if (NULL == pSession->pConnectBssDesc)
569 {
570 smsLog( pMac, LOGE, FL("BSS description is not present") );
571 return eHAL_STATUS_FAILURE;
572 }
573
Kiran V1ccee932012-12-12 14:49:46 -0800574 status = palAllocateMemory( pMac->hHdd, (void **)&tdlsDelStaReq,
575 (sizeof(tSirTdlsDelStaReq) ) );
576
Jeff Johnson18a89562013-04-04 16:52:06 -0700577 if (!HAL_STATUS_SUCCESS( status ) )
Kiran V1ccee932012-12-12 14:49:46 -0800578 {
Jeff Johnson18a89562013-04-04 16:52:06 -0700579 smsLog( pMac, LOGE, FL("alloc failed") );
Kiran V1ccee932012-12-12 14:49:46 -0800580 VOS_ASSERT(0) ;
581 return status ;
582 }
583 tdlsDelStaReq->sessionId = cmd->sessionId;
584 //Using dialog as transactionId. This can be used to match response with request
585 tdlsDelStaReq->transactionId = 0;
Jeff Johnson18a89562013-04-04 16:52:06 -0700586
587 palCopyMemory(pMac->hHdd, tdlsDelStaReq->bssid,
588 pSession->pConnectBssDesc->bssId, sizeof (tSirMacAddr));
589
Kiran V1ccee932012-12-12 14:49:46 -0800590 palCopyMemory(pMac->hHdd, tdlsDelStaReq->peerMac,
591 tdlsDelStaCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
592
593 // Send the request to PE.
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800594#ifdef WLAN_FEATURE_TDLS_DEBUG
595 smsLog( pMac, LOGE,
596#else
597 smsLog( pMac, LOG1,
598#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800599 "sending TDLS Del Sta %02x:%02x:%02x:%02x:%02x:%02x req to PE",
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800600 tdlsDelStaCmdInfo->peerMac[0], tdlsDelStaCmdInfo->peerMac[1], tdlsDelStaCmdInfo->peerMac[2],
601 tdlsDelStaCmdInfo->peerMac[3], tdlsDelStaCmdInfo->peerMac[4], tdlsDelStaCmdInfo->peerMac[5]);
Kiran V1ccee932012-12-12 14:49:46 -0800602 status = tdlsSendMessage(pMac, eWNI_SME_TDLS_DEL_STA_REQ,
603 (void *)tdlsDelStaReq , sizeof(tSirTdlsDelStaReq)) ;
604 if(!HAL_STATUS_SUCCESS( status ) )
605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800606 smsLog( pMac, LOGE, FL("Failed to send request to MAC"));
Kiran V1ccee932012-12-12 14:49:46 -0800607 }
608 return status;
609}
610/*
611 * commands received from CSR
612 */
613eHalStatus csrTdlsProcessCmd(tpAniSirGlobal pMac, tSmeCmd *cmd)
614{
615 eSmeCommandType cmdType = cmd->command ;
616#ifdef FEATURE_WLAN_TDLS_INTERNAL
617 tTdlsCmd tdlsCmd = cmd->u.tdlsCmd ;
618#endif
619 tANI_BOOLEAN status = eANI_BOOLEAN_TRUE;
620 switch(cmdType)
621 {
622 case eSmeCommandTdlsSendMgmt:
623 {
624 status = csrTdlsProcessSendMgmt( pMac, cmd );
625 if(HAL_STATUS_SUCCESS( status ) )
626 {
627 status = eANI_BOOLEAN_FALSE ;
628 }
629 }
630 break ;
631 case eSmeCommandTdlsAddPeer:
632 {
633 status = csrTdlsProcessAddSta( pMac, cmd );
634 if(HAL_STATUS_SUCCESS( status ) )
635 {
636 status = eANI_BOOLEAN_FALSE ;
637 }
638 }
639 break;
640 case eSmeCommandTdlsDelPeer:
641 {
642 status = csrTdlsProcessDelSta( pMac, cmd );
643 if(HAL_STATUS_SUCCESS( status ) )
644 {
645 status = eANI_BOOLEAN_FALSE ;
646 }
647 }
648 break;
649#ifdef FEATURE_WLAN_TDLS_INTERNAL
650 case eSmeCommandTdlsDiscovery:
651 {
652 tTdlsDisReqCmdinfo *disReqCmdInfo = &tdlsCmd.u.tdlsDisReqCmdInfo ;
653 tSirTdlsDisReq *disReq = NULL ;
654 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
655
656 status = palAllocateMemory( pMac->hHdd, (void **)&disReq,
657 sizeof(tSirTdlsDisReq));
658
659 if(!HAL_STATUS_SUCCESS( status ) )
660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800661 smsLog( pMac, LOGE, "dis Req alloc failed " );
Kiran V1ccee932012-12-12 14:49:46 -0800662 VOS_ASSERT(0) ;
663 break ;
664 }
665 disReq->sessionId = cmd->sessionId;
666 disReq->transactionId = 0; /* TODO ? */
667 disReq->reqType = disReqCmdInfo->tdlsDisType ;
668 palCopyMemory(pMac->hHdd, disReq->bssid, pSession->pConnectBssDesc->bssId,
669 sizeof (tSirMacAddr));
670 palCopyMemory(pMac->hHdd, disReq->peerMac,
671 disReqCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800672 smsLog( pMac, LOGE, "sending TDLS discovery to PE " );
Kiran V1ccee932012-12-12 14:49:46 -0800673 status = tdlsSendMessage(pMac, eWNI_SME_TDLS_DISCOVERY_START_REQ,
674 (void *)disReq , sizeof(tSirTdlsDisReq)) ;
675 if(HAL_STATUS_SUCCESS( status ) )
676 {
677 status = eANI_BOOLEAN_FALSE ;
678 }
679 /* TODO: Add error handling */
680
681 break ;
682 }
683 case eSmeCommandTdlsLinkSetup:
684 {
685 tTdlsLinkSetupReqCmdinfo *linkSetupReqCmdInfo =
686 &tdlsCmd.u.tdlsLinkSetupReqCmdInfo ;
687 tSirTdlsSetupReq *setupReq = NULL ;
688 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
689
690 status = palAllocateMemory( pMac->hHdd, (void **)&setupReq,
691 sizeof(tSirTdlsSetupReq));
692
693 if(!HAL_STATUS_SUCCESS( status ) )
694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800695 smsLog( pMac, LOGE, "dis Req alloc failed " );
Kiran V1ccee932012-12-12 14:49:46 -0800696 VOS_ASSERT(0) ;
697 break ;
698 }
699 setupReq->sessionId = cmd->sessionId;
700 setupReq->transactionId = 0; /* TODO ? */
701
702 palCopyMemory(pMac->hHdd, setupReq->bssid, pSession->pConnectBssDesc->bssId,
703 sizeof (tSirMacAddr));
704 palCopyMemory(pMac->hHdd, setupReq->peerMac,
705 linkSetupReqCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
706
707 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800708 ("sending TDLS link setup to PE "));
Kiran V1ccee932012-12-12 14:49:46 -0800709 status = tdlsSendMessage(pMac, eWNI_SME_TDLS_LINK_START_REQ,
710 (void *)setupReq , sizeof(tSirTdlsSetupReq) ) ;
711
712 if(HAL_STATUS_SUCCESS( status ) )
713 {
714 status = eANI_BOOLEAN_FALSE ;
715 }
716 /* TODO: Add error handling */
717 break ;
718 }
719 case eSmeCommandTdlsLinkTear:
720 {
721 tTdlsLinkTeardownCmdinfo *linkTeardownCmdInfo =
722 &tdlsCmd.u.tdlsLinkTeardownCmdInfo ;
723 tSirTdlsTeardownReq *teardownReq = NULL ;
724 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
725
726 status = palAllocateMemory( pMac->hHdd, (void **)&teardownReq,
727 sizeof(tSirTdlsTeardownReq));
728 if(!HAL_STATUS_SUCCESS( status ) )
729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800730 smsLog( pMac, LOGE, "teardown Req alloc failed " );
Kiran V1ccee932012-12-12 14:49:46 -0800731 VOS_ASSERT(0) ;
732 break ;
733 }
734 teardownReq->sessionId = cmd->sessionId;
735 teardownReq->transactionId = 0; /* TODO ? */
736
737 palCopyMemory(pMac->hHdd, teardownReq->bssid, pSession->pConnectBssDesc->bssId,
738 sizeof (tSirMacAddr));
739 palCopyMemory(pMac->hHdd, &teardownReq->peerMac,
740 linkTeardownCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
741 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800742 ("teardown request..")) ;
Kiran V1ccee932012-12-12 14:49:46 -0800743 status = tdlsSendMessage(pMac, eWNI_SME_TDLS_TEARDOWN_REQ,
744 (void *)teardownReq , sizeof(tSirTdlsTeardownReq)) ;
745
746 if(HAL_STATUS_SUCCESS( status ) )
747 {
748 status = eANI_BOOLEAN_FALSE ;
749 }
750 /* TODO: Add error handling */
751 break ;
752 }
753#endif
754 default:
755 {
756 /* TODO: Add defualt handling */
757 break ;
758 }
759
760 }
761 return status ;
762}
763
764#ifdef FEATURE_WLAN_TDLS_INTERNAL
765/*
766 * Find specific TDLS peer (based on peer MAC address).
767 */
768tCsrTdlsPeerLinkinfo *findTdlsPeer(tpAniSirGlobal pMac,
769 tDblLinkList *peerList, tSirMacAddr peerMac)
770{
771 tListElem *pEntry = NULL ;
772 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
773 tSirTdlsPeerInfo *peerInfo = NULL ;
774
775 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
776 while(pEntry)
777 {
778 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
779 tdlsPeerStaLink) ;
780 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
781
782 if(palEqualMemory( pMac->hHdd,(tANI_U8 *)peerInfo->peerMac,
783 (tANI_U8 *) peerMac, sizeof(tSirMacAddr)) )
784 {
785 break ;
786 }
787
788 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
789 }
790
791 return ((pEntry) ? peerLinkInfo: NULL) ;
792}
793/*
794 * Delete TDLD peer info, called from TDLS teardown request.
795 */
796static eHalStatus tdlsDeleteTdlsPeerInfo(tpAniSirGlobal pMac,
797 tSirMacAddr peerMac)
798{
799 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
800 tCsrTdlsPeerLinkinfo *peerInfo =
801 findTdlsPeer(pMac, &disInfo->tdlsPotentialPeerList, peerMac) ;
802 eHalStatus status = eHAL_STATUS_FAILURE ;
803
804 if((csrLLRemoveEntry(&disInfo->tdlsPotentialPeerList,
805 &peerInfo->tdlsPeerStaLink, LL_ACCESS_NOLOCK)))
806 {
807 status = palFreeMemory(pMac->hHdd, (void *)peerInfo) ;
808
809 }
810
811 return status ;
812}
813
814/*
815 * UPDATE TDLS peer state to TDLS LINK STATE, this will be called after
816 * link is successfully setup with TDLS Peer.
817 */
818static eHalStatus tdlsUpdateTdlsPeerState(tpAniSirGlobal pMac,
819 tSirMacAddr peerMac,tANI_U8 state )
820{
821 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
822 tCsrTdlsPeerLinkinfo *peerLinkInfo =
823 findTdlsPeer(pMac, &disInfo->tdlsPotentialPeerList, peerMac) ;
824 eHalStatus status = eHAL_STATUS_FAILURE ;
825
826 if(peerLinkInfo)
827 {
828 tSirTdlsPeerInfo *peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
829 peerInfo->tdlsPeerState = state ;
830 status = eHAL_STATUS_SUCCESS ;
831 }
832 else
833 {
834 /* TODO: update this peer found in link setup in peer list */
835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800836 ("This TDLS client is not in discovery list ") );
Kiran V1ccee932012-12-12 14:49:46 -0800837 status = eHAL_STATUS_SUCCESS ;
838 }
839
840 return status ;
841}
842
843/*
844 * save TDLS peer info, this will be called after successfull completion
845 * of TDLS discovery procedure.
846 */
847static eHalStatus tdlsSaveTdlsPeerInfo(tpAniSirGlobal pMac,
848 tSirTdlsPeerInfo *disPeerInfo)
849{
850 tCsrTdlsPeerLinkinfo *peerInfo = NULL ;
851 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
852 eHalStatus status = eHAL_STATUS_FAILURE ;
853 /*
854 * Ok, allocate memory for peer info here
855 * we allocate memory for each peer here and free his memory
856 * at the time the peer node is getting deleted, possible case is
857 * teardown
858 */
859 status = palAllocateMemory( pMac->hHdd, (void **)&peerInfo,
860 sizeof(tCsrTdlsPeerLinkinfo));
861
862 /*
863 * go ahead and copy peerInfo and insert this node info discovery rsp
864 * database.
865 */
866 if (HAL_STATUS_SUCCESS(status))
867 {
868 palZeroMemory(pMac->hHdd, &peerInfo->tdlsDisPeerInfo,
869 sizeof(tSirTdlsPeerInfo));
870 palCopyMemory(pMac->hHdd, &peerInfo->tdlsDisPeerInfo, disPeerInfo,
871 sizeof(tSirTdlsPeerInfo));
872
873 /*
874 * update TDLS client count to indicate there is tdls client
875 * in tdls potential peer list.
876 */
877 disInfo->tdlsPeerCount++ ;
878
879 /*
880 * finally insert this tdls peer info into tdls potential peer list
881 */
882 csrLLInsertTail( &disInfo->tdlsPotentialPeerList,
883 &peerInfo->tdlsPeerStaLink, LL_ACCESS_LOCK );
884 }
885
886 return status ;
887
888}
889
890#endif
891/*
892 * TDLS Message processor, will be called after TDLS message recieved from
893 * PE
894 */
895eHalStatus tdlsMsgProcessor(tpAniSirGlobal pMac, v_U16_t msgType,
896 void *pMsgBuf)
897{
898 switch(msgType)
899 {
900 case eWNI_SME_TDLS_SEND_MGMT_RSP:
901 {
902 /* remove pending eSmeCommandTdlsDiscovery command */
903 csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsSendMgmt) ;
904 }
905 break;
906 case eWNI_SME_TDLS_ADD_STA_RSP:
907 {
908 tSirTdlsAddStaRsp *addStaRsp = (tSirTdlsAddStaRsp *) pMsgBuf ;
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800909 eCsrRoamResult roamResult ;
Kiran V1ccee932012-12-12 14:49:46 -0800910 tCsrRoamInfo roamInfo = {0} ;
911 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, addStaRsp->peerMac,
912 sizeof(tSirMacAddr)) ;
913 roamInfo.staId = addStaRsp->staId ;
914 roamInfo.ucastSig = addStaRsp->ucastSig ;
915 roamInfo.bcastSig = addStaRsp->bcastSig ;
Lee Hoonkif987a0b2013-01-29 02:07:07 -0800916 roamInfo.statusCode = addStaRsp->statusCode ;
Kiran V1ccee932012-12-12 14:49:46 -0800917 /*
918 * register peer with TL, we have to go through HDD as this is
919 * the only way to register any STA with TL.
920 */
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800921 if (addStaRsp->tdlsAddOper == TDLS_OPER_ADD)
922 roamResult = eCSR_ROAM_RESULT_ADD_TDLS_PEER;
Jeff Johnson18a89562013-04-04 16:52:06 -0700923 else /* addStaRsp->tdlsAddOper must be TDLS_OPER_UPDATE */
Gopichand Nakkala681989c2013-03-06 22:27:48 -0800924 roamResult = eCSR_ROAM_RESULT_UPDATE_TDLS_PEER;
Kiran V1ccee932012-12-12 14:49:46 -0800925 csrRoamCallCallback(pMac, addStaRsp->sessionId, &roamInfo, 0,
Jeff Johnson18a89562013-04-04 16:52:06 -0700926 eCSR_ROAM_TDLS_STATUS_UPDATE,
927 roamResult);
928
Kiran V1ccee932012-12-12 14:49:46 -0800929 /* remove pending eSmeCommandTdlsDiscovery command */
930 csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsAddPeer) ;
931 }
932 break;
933 case eWNI_SME_TDLS_DEL_STA_RSP:
934 {
935 tSirTdlsDelStaRsp *delStaRsp = (tSirTdlsDelStaRsp *) pMsgBuf ;
936 tCsrRoamInfo roamInfo = {0} ;
937
938 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, delStaRsp->peerMac,
939 sizeof(tSirMacAddr)) ;
940 roamInfo.staId = delStaRsp->staId ;
941 roamInfo.statusCode = delStaRsp->statusCode ;
942 /*
943 * register peer with TL, we have to go through HDD as this is
944 * the only way to register any STA with TL.
945 */
946 csrRoamCallCallback(pMac, delStaRsp->sessionId, &roamInfo, 0,
947 eCSR_ROAM_TDLS_STATUS_UPDATE,
948 eCSR_ROAM_RESULT_DELETE_TDLS_PEER);
949
Kiran V1ccee932012-12-12 14:49:46 -0800950 csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsDelPeer) ;
951 }
952 break;
Hoonki Leee6bfe942013-02-05 15:01:19 -0800953 case eWNI_SME_TDLS_DEL_STA_IND:
954 {
955 tpSirTdlsDelStaInd pSirTdlsDelStaInd = (tpSirTdlsDelStaInd) pMsgBuf ;
956 tCsrRoamInfo roamInfo = {0} ;
957 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSirTdlsDelStaInd->peerMac,
958 sizeof(tSirMacAddr)) ;
959 roamInfo.staId = pSirTdlsDelStaInd->staId ;
960 roamInfo.reasonCode = pSirTdlsDelStaInd->reasonCode ;
961
962 /* Sending the TEARDOWN indication to HDD. */
963 csrRoamCallCallback(pMac, pSirTdlsDelStaInd->sessionId, &roamInfo, 0,
964 eCSR_ROAM_TDLS_STATUS_UPDATE,
965 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND);
966 break ;
967 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +0530968#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
969 case eWNI_SME_TDLS_AP_DISAPPEAR_IND:
970 {
971 tpSirTdlsDisappearAPInd pSirTdlsDisappearAPInd = (tpSirTdlsDisappearAPInd) pMsgBuf;
972 tCsrRoamInfo roamInfo = {0} ;
973 roamInfo.staId = pSirTdlsDisappearAPInd->staId ;
974 /* Sending the TEARDOWN indication to HDD. */
975 csrRoamCallCallback(pMac, pSirTdlsDisappearAPInd->sessionId, &roamInfo, 0,
976 eCSR_ROAM_TDLS_STATUS_UPDATE,
977 eCSR_ROAM_RESULT_TDLS_DISAPPEAR_AP_IND);
978 break ;
979 }
980#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800981 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
982 {
983 tpSirTdlsDelAllPeerInd pSirTdlsDelAllPeerInd = (tpSirTdlsDelAllPeerInd) pMsgBuf ;
984 tCsrRoamInfo roamInfo = {0} ;
985
986 /* Sending the TEARDOWN indication to HDD. */
987 csrRoamCallCallback(pMac, pSirTdlsDelAllPeerInd->sessionId, &roamInfo, 0,
988 eCSR_ROAM_TDLS_STATUS_UPDATE,
989 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800990 break ;
991 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800992 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
993 {
994 tpSirMgmtTxCompletionInd pSirTdlsDelAllPeerInd = (tpSirMgmtTxCompletionInd) pMsgBuf ;
995 tCsrRoamInfo roamInfo = {0} ;
996 roamInfo.reasonCode = pSirTdlsDelAllPeerInd->txCompleteStatus;
997
998 csrRoamCallCallback(pMac, pSirTdlsDelAllPeerInd->sessionId, &roamInfo,
999 0, eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND, 0);
1000 }
Kiran V1ccee932012-12-12 14:49:46 -08001001#ifdef FEATURE_WLAN_TDLS_INTERNAL
1002 case eWNI_SME_TDLS_DISCOVERY_START_RSP:
1003 {
1004 /* remove pending eSmeCommandTdlsDiscovery command */
1005 csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsDiscovery) ;
1006 }
1007 /* fall through .. */
1008 case eWNI_SME_TDLS_DISCOVERY_START_IND:
1009 {
1010 tSirTdlsDisRsp *disRsp = (tSirTdlsDisRsp *)pMsgBuf ;
1011
1012 if(eSIR_SME_SUCCESS == disRsp->statusCode)
1013 {
1014 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
1015 tANI_U16 disStaCount = disRsp->numDisSta ;
1016 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
1017 tANI_U8 i = 0 ;
1018
1019 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001020 ("DIS START RSP/IND recieved sta count = %d"), disStaCount) ;
Kiran V1ccee932012-12-12 14:49:46 -08001021 for( ; i < disStaCount ; i++)
1022 {
1023 tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[i] ;
1024 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001025 ("SME, peer MAC:")) ;
Kiran V1ccee932012-12-12 14:49:46 -08001026 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1027 (" %02x,%02x,%02x,%02x,%02x,%02x"),
1028 peerInfo->peerMac[0],
1029 peerInfo->peerMac[1],
1030 peerInfo->peerMac[2],
1031 peerInfo->peerMac[3],
1032 peerInfo->peerMac[4],
1033 peerInfo->peerMac[5]) ;
1034
1035 peerLinkInfo = findTdlsPeer(pMac,
1036 &disInfo->tdlsPotentialPeerList,
1037 peerInfo->peerMac) ;
1038
1039 if(NULL == peerLinkInfo)
1040 {
1041 /* update discovery data base, if this is new entry */
1042 tdlsSaveTdlsPeerInfo(pMac, peerInfo) ;
1043 }
1044 else
1045 {
1046 /* update RSSI of existing peer */
1047 tSirTdlsPeerInfo *newPeerInfo =
1048 &peerLinkInfo->tdlsDisPeerInfo ;
1049 newPeerInfo->tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
1050 }
1051 }
1052 if(0 == i)
1053 {
1054 smsLog( pMac, LOGW, "there is no tdls client \
1055 discovered .." ) ;
1056 }
1057 }
1058 else
1059 {
1060 smsLog( pMac, LOGW, "there is no tdls client discovered .." );
1061 }
1062 /* Now free the memory for this message */
1063 break ;
Ng Chilamfc416462012-12-27 17:26:52 -08001064 }
Kiran V1ccee932012-12-12 14:49:46 -08001065 case eWNI_SME_TDLS_LINK_START_RSP:
1066 {
1067 /* remove pending eSmeCommandTdlsLinkSetup command */
1068 csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsLinkSetup) ;
1069 }
1070 /* fall through .. */
1071 case eWNI_SME_TDLS_LINK_START_IND:
1072 {
1073 tSirTdlsLinksetupRsp *linkSetupRsp =
1074 (tSirTdlsLinksetupRsp *) pMsgBuf ;
1075
1076 if(eSIR_SME_SUCCESS == linkSetupRsp->statusCode)
1077 {
1078 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001079 ("Link setup for Peer %02x,%02x,%02x,%02x,%02x,%02x"),
Kiran V1ccee932012-12-12 14:49:46 -08001080 linkSetupRsp->peerMac[0],
1081 linkSetupRsp->peerMac[1],
1082 linkSetupRsp->peerMac[2],
1083 linkSetupRsp->peerMac[3],
1084 linkSetupRsp->peerMac[4],
1085 linkSetupRsp->peerMac[5]) ;
1086
1087 tdlsUpdateTdlsPeerState(pMac, linkSetupRsp->peerMac,
1088 TDLS_LINK_SETUP_STATE) ;
1089 }
1090 else
1091 {
1092 smsLog( pMac, LOGW, "failure receieved in link setup .." );
1093 }
1094 break ;
1095 }
1096
1097 case eWNI_SME_TDLS_TEARDOWN_RSP:
1098 {
1099 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001100 ("TEARDOWN RSP from PE ")) ;
Kiran V1ccee932012-12-12 14:49:46 -08001101 /* remove pending eSmeCommandTdlsLinkTear command */
1102 csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsLinkTear) ;
1103 }
1104 /* fall through .. */
1105 case eWNI_SME_TDLS_TEARDOWN_IND:
1106 {
1107 tSirTdlsTeardownRsp *linkTearRsp =
1108 (tSirTdlsTeardownRsp *) pMsgBuf ;
1109 if(eSIR_SME_SUCCESS == linkTearRsp->statusCode)
1110 {
1111
1112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001113 ("Teardown peer MAC = %02x,%02x,%02x,%02x,%02x,%02x"),
Kiran V1ccee932012-12-12 14:49:46 -08001114 linkTearRsp->peerMac[0],
1115 linkTearRsp->peerMac[1],
1116 linkTearRsp->peerMac[2],
1117 linkTearRsp->peerMac[3],
1118 linkTearRsp->peerMac[4],
1119 linkTearRsp->peerMac[5]) ;
1120 tdlsDeleteTdlsPeerInfo(pMac, linkTearRsp->peerMac) ;
1121 }
1122 else
1123 {
1124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1125 ("failure receieved in Teardown .." ));
1126 }
1127 break ;
1128 }
1129 case eWNI_SME_ADD_TDLS_PEER_IND:
1130 {
1131 tSirTdlsPeerInd *peerInd = (tSirTdlsPeerInd *) pMsgBuf ;
1132 tCsrRoamInfo roamInfo = {0} ;
1133 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, peerInd->peerMac,
1134 sizeof(tSirMacAddr)) ;
1135 roamInfo.staId = peerInd->staId ;
1136 roamInfo.ucastSig = peerInd->ucastSig ;
1137 roamInfo.bcastSig = peerInd->bcastSig ;
1138 /*
1139 * register peer with TL, we have to go through HDD as this is
1140 * the only way to register any STA with TL.
1141 */
1142 csrRoamCallCallback(pMac, peerInd->sessionId, &roamInfo, 0,
1143 eCSR_ROAM_TDLS_STATUS_UPDATE,
1144 eCSR_ROAM_RESULT_ADD_TDLS_PEER);
1145 break ;
1146
1147 }
1148 case eWNI_SME_DELETE_TDLS_PEER_IND:
1149 {
1150 tSirTdlsPeerInd *peerInd = (tSirTdlsPeerInd *) pMsgBuf ;
1151 tCsrRoamInfo roamInfo = {0} ;
1152 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, peerInd->peerMac,
1153 sizeof(tSirMacAddr)) ;
1154 roamInfo.staId = peerInd->staId ;
1155 /*
1156 * register peer with TL, we have to go through HDD as this is
1157 * the only way to register any STA with TL.
1158 */
1159 csrRoamCallCallback(pMac, peerInd->sessionId, &roamInfo, 0,
1160 eCSR_ROAM_TDLS_STATUS_UPDATE,
1161 eCSR_ROAM_RESULT_DELETE_TDLS_PEER);
1162 break ;
1163
1164 }
1165#endif
1166 default:
1167 {
1168 break ;
1169 }
1170 }
1171
1172 return eHAL_STATUS_SUCCESS ;
1173}
1174#endif