blob: 71a693956f598c74c14cd45c29f825d81022296e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/*===========================================================================
7
8 b t a m p F s m . C
9
10 OVERVIEW:
11
12 This software unit holds the implementation of the Finite State Machine that
13 controls the operation of each individual AMP Physical link.
14 (Currently, this is limited to ONE link.)
15
16 The btampFsm() routine provided by this module is called by the rest of
17 the BT-AMP PAL module whenever a control plane operation occurs that requires a
18 major state transition.
19
20 DEPENDENCIES:
21
22 Are listed for each API below.
23
24
25 Copyright (c) 2008 QUALCOMM Incorporated.
26 All Rights Reserved.
27 Qualcomm Confidential and Proprietary
28===========================================================================*/
29
30/*===========================================================================
31
32 EDIT HISTORY FOR FILE
33
34
35 This section contains comments describing changes made to the module.
36 Notice that changes are listed in reverse chronological order.
37
38
39 $Header: /prj/qct/asw/engbuilds/scl/users02/jzmuda/gb-bluez/vendor/qcom/proprietary/wlan/libra/CORE/BAP/src/btampFsm.c,v 1.11 2011/03/30 21:52:10 jzmuda Exp jzmuda $
40
41
42 when who what, where, why
43---------- --- --------------------------------------------------------
442008-10-16 jez Created module
45
46===========================================================================*/
47
48/* This file is generated from btampFsm.cdd - do not edit manually*/
49/* Generated on: Thu Oct 16 15:40:39 PDT 2008 / version 1.2 Beta 1 */
50
51/*----------------------------------------------------------------------------
52 * Include Files
53 * -------------------------------------------------------------------------*/
54
55
56#include "fsmDefs.h"
57//#include "btampFsm.h"
58#include "bapInternal.h"
59#include "btampFsm_ext.h"
60
61// Pick up the BTAMP Timer API definitions
62#include "bapApiTimer.h"
63
64// Pick up the BTAMP RSN definitions
65#include "bapRsn8021xFsm.h"
66
67#include "bapRsn8021xAuthFsm.h"
68// Pick up the SME API definitions
69#include "sme_Api.h"
70
71// Pick up the PMC API definitions
72#include "pmcApi.h"
73
74// Pick up the BTAMP API defintions for interfacing to External subsystems
75#include "bapApiExt.h"
76
77#include "wlan_nlink_common.h"
78#include "wlan_btc_svc.h"
79
80// Pick up the DOT11 Frames compiler
81// I just need these one "opaque" type definition in order to use the "frames" code
82typedef struct sAniSirGlobal *tpAniSirGlobal;
83#include "dot11f.h"
84
85#if 0
86/*
87 * Event-related Defines.
88 * - Ultimately, these events will be values
89 * - from an enumeration. That are set by some
90 * - of the following events.
91 */
92#define eWLAN_BAP_MAC_START_BSS_SUCCESS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STARTED */
93#define eWLAN_BAP_MAC_START_FAILS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
94#define eWLAN_BAP_MAC_SCAN_COMPLETE /* bapScanCompleteCallback */
95#define eWLAN_BAP_CHANNEL_NOT_SELECTED /* No existing Infra assoc - e.g., use HAL to access the STA LIST and find nothing */
96#define eWLAN_BAP_MAC_CONNECT_COMPLETED /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATED */
97#define eWLAN_BAP_MAC_CONNECT_FAILED /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_FAILURE or eCSR_ROAM_RESULT_NOT_ASSOCIATED */
98#define eWLAN_BAP_MAC_CONNECT_INDICATION /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND */
99#define eWLAN_BAP_RSN_SUCCESS /* setKey IOCTL from the Auth/Supp App */
100#define eWLAN_BAP_RSN_FAILURE /* deAuth IOCTL from the Auth/Supp App */
101#define eWLAN_BAP_MAC_KEY_SET_SUCCESS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_KEY_SET */
102#define eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_DISASSOC_IND */
103#define eWLAN_BAP_MAC_READY_FOR_CONNECTIONS /* bapRoamCompleteCallback with eCSR_ROAM_RESULT_WDS_STOPPED */
104#define eWLAN_BAP_CHANNEL_SELECTION_FAILED /* ??? */
105
106#endif /* 0 */
107
108/*Min and max channel values in 2.4GHz band for operational channel validation
109 on connect*/
110#define WLAN_BAP_MIN_24G_CH 1
111#define WLAN_BAP_MAX_24G_CH 14
112
113
114/* The HCI Disconnect Logical Link Complete Event signalling routine*/
115VOS_STATUS
116signalHCIDiscLogLinkCompEvent
117(
118 ptBtampContext btampContext, /* btampContext value */
119 v_U8_t status, /* the BT-AMP status */
120 v_U16_t log_link_handle, /* The Logical Link that disconnected*/
121 v_U8_t reason /* the BT-AMP reason code */
122);
123
124
125/* Stubs - TODO : Remove once the functions are available */
126int
127bapSuppDisconnect(tBtampContext *ctx)
128{
129 // Disconnect function is called internally
130 // TODO : Need to find, if it disconnect will be issued from bap for supplicant
131 return ANI_OK;
132}
133
134int
135bapAuthDisconnect(tBtampContext *ctx)
136{
137 // Disconnect function is called internally
138 // TODO : Need to find, if it disconnect will be issued from bap for supplicant
139 return ANI_OK;
140}
141
142VOS_STATUS
143bapSetKey( v_PVOID_t pvosGCtx, tCsrRoamSetKey *pSetKeyInfo )
144{
145 tWLAN_BAPEvent bapEvent; /* State machine event */
146 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
147 ptBtampContext btampContext; /* use btampContext value */
148 v_U8_t status; /* return the BT-AMP status here */
149 eHalStatus halStatus;
150 v_U32_t roamId = 0xFF;
151 tHalHandle hHal = NULL;
152 v_U8_t groupMac[ANI_MAC_ADDR_SIZE] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
153
154 /* Validate params */
155 if ((pvosGCtx == NULL) || (pSetKeyInfo == NULL))
156 {
157 return VOS_STATUS_E_FAULT;
158 }
159
160 btampContext = VOS_GET_BAP_CB(pvosGCtx);
161 /* Validate params */
162 if ( btampContext == NULL)
163 {
164 return VOS_STATUS_E_FAULT;
165 }
166 hHal = VOS_GET_HAL_CB(btampContext->pvosGCtx);
167 if (NULL == hHal)
168 {
169 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700170 "hHal is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700171
172 return VOS_STATUS_E_FAULT;
173 }
174
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530175 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %p", __func__, btampContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700176
177 /* Fill in the event structure */
178 bapEvent.event = eWLAN_BAP_RSN_SUCCESS;
179 bapEvent.params = NULL;
180
181 /* Signal the successful RSN auth and key exchange event */
182 /* (You have to signal BEFORE calling sme_RoamSetKey) */
183 vosStatus = btampFsm(btampContext, &bapEvent, &status);
184
185 /* Set the Pairwise Key */
186 halStatus = sme_RoamSetKey(
187 hHal,
188 btampContext->sessionId,
189 pSetKeyInfo,
190 &roamId );
191 if ( halStatus != eHAL_STATUS_SUCCESS )
192 {
193 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
194 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
195 return VOS_STATUS_E_FAULT;
196 }
197
198 /* Set the Group Key */
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -0700199 vos_mem_copy( pSetKeyInfo->peerMac, groupMac, sizeof( tAniMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700200 halStatus = sme_RoamSetKey(
201 hHal,
202 btampContext->sessionId,
203 pSetKeyInfo,
204 &roamId );
205 if ( halStatus != eHAL_STATUS_SUCCESS )
206 {
207 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
208 "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus );
209 return VOS_STATUS_E_FAULT;
210 }
211
212 return vosStatus;
213}
214
215/*
216 * Debug-related Defines.
217 * - Ultimately, these events will be values
218 * - from an enumeration. That are set by some
219 * - of the following events.
220 */
221#define DUMPLOG_ON
222#if defined DUMPLOG_ON
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800223#define DUMPLOG(n, name1, name2, aStr, size) do { \
224 int i; \
225 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%d. %s: %s = \n", n, name1, name2); \
226 for (i = 0; i < size; i++) \
227 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%2.2x%s", ((unsigned char *)aStr)[i], i % 16 == 15 ? "\n" : " "); \
228 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "\n"); \
229 } while (0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700230#else
231#define DUMPLOG(n, name1, name2, aStr, size)
232#endif
233
234/*
235 * State transition procedures
236 */
237
238VOS_STATUS
239gotoS1
240(
241 ptBtampContext btampContext, /* btampContext value */
242 ptWLAN_BAPEvent bapEvent, /* State machine event */
243 tWLAN_BAPRole BAPDeviceRole,
244 v_U8_t *status /* return the BT-AMP status here */
245)
246{
247 tBtampTLVHCI_Create_Physical_Link_Cmd *pBapHCIPhysLinkCreate
248 = (tBtampTLVHCI_Create_Physical_Link_Cmd *) bapEvent->params;
249 tBtampTLVHCI_Accept_Physical_Link_Cmd *pBapHCIPhysLinkAccept
250 = (tBtampTLVHCI_Accept_Physical_Link_Cmd *) bapEvent->params;
251 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
252 v_U32_t conAcceptTOInterval;
253 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
254
255 /* Remember role */
256 btampContext->BAPDeviceRole = BAPDeviceRole;
257
258 switch(BAPDeviceRole)
259 {
260 case BT_INITIATOR:
261 /* Copy down the phy_link_handle value */
262 btampContext->phy_link_handle = pBapHCIPhysLinkCreate->phy_link_handle;
263 /* Copy out the key material from the HCI command */
264 btampContext->key_type = pBapHCIPhysLinkCreate->key_type;
265 btampContext->key_length = pBapHCIPhysLinkCreate->key_length;
266 vos_mem_copy(
267 btampContext->key_material,
268 pBapHCIPhysLinkCreate->key_material,
269 32); /* Need a key size define */
270 break;
271 case BT_RESPONDER:
272 /* Copy down the phy_link_handle value */
273 btampContext->phy_link_handle = pBapHCIPhysLinkAccept->phy_link_handle;
274 /* Copy out the key material from the HCI command */
275 btampContext->key_type = pBapHCIPhysLinkAccept->key_type;
276 btampContext->key_length = pBapHCIPhysLinkAccept->key_length;
277 vos_mem_copy(
278 btampContext->key_material,
279 pBapHCIPhysLinkAccept->key_material,
280 32); /* Need a key size define */
281 break;
282 default:
283 *status = WLANBAP_ERROR_HOST_REJ_RESOURCES; /* return the BT-AMP status here */
284 return VOS_STATUS_E_RESOURCES;
285 }
286
287 conAcceptTOInterval = (btampContext->bapConnectionAcceptTimerInterval * 5)/ 8;
288 /* Start the Connection Accept Timer */
289 vosStatus = WLANBAP_StartConnectionAcceptTimer (
290 btampContext,
291 conAcceptTOInterval);
292
293 *status = WLANBAP_STATUS_SUCCESS; /* return the BT-AMP status here */
294
295 return VOS_STATUS_SUCCESS;
296} //gotoS1
297
298VOS_STATUS
299gotoScanning
300(
301 ptBtampContext btampContext, /* btampContext value */
302 tWLAN_BAPRole BAPDeviceRole,
303 v_U8_t *status /* return the BT-AMP status here */
304)
305{
306 /* Initiate a SCAN request */
307 //csrScanRequest();
308 *status = WLANBAP_STATUS_SUCCESS; /* return the BT-AMP status here */
309
310 return VOS_STATUS_SUCCESS;
311}
312
313
314#if 0
315/*==========================================================================
316
317 FUNCTION: convertRoleToBssType
318
319 DESCRIPTION: Return one of the following values:
320
321 eCSR_BSS_TYPE_INFRASTRUCTURE,
322 eCSR_BSS_TYPE_IBSS, // an IBSS network we will NOT start
323 eCSR_BSS_TYPE_START_IBSS, // an IBSS network we will start if no partners detected.
324 eCSR_BSS_TYPE_WDS_AP, // BT-AMP AP
325 eCSR_BSS_TYPE_WDS_STA, // BT-AMP station
326 eCSR_BSS_TYPE_ANY,
327============================================================================*/
328#endif
329eCsrRoamBssType
330convertRoleToBssType
331(
332 tWLAN_BAPRole bapRole /* BT-AMP role */
333)
334{
335 switch (bapRole)
336 {
337 case BT_RESPONDER:
338 // an WDS network we will join
339 return eCSR_BSS_TYPE_WDS_STA;
340 //return eCSR_BSS_TYPE_INFRASTRUCTURE;
341 //return eCSR_BSS_TYPE_IBSS; // Initial testing with IBSS on both ends makes more sense
342 case BT_INITIATOR:
343 // an WDS network we will start if no partners detected.
344 return eCSR_BSS_TYPE_WDS_AP;
345 //return eCSR_BSS_TYPE_START_IBSS; // I really should try IBSS on both ends
346 default:
347 return eCSR_BSS_TYPE_INFRASTRUCTURE;
348 }
349} // convertRoleToBssType
350
351
352char hexValue[] = {'0', '1', '2', '3', '4', '5', '6', '7',
353 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
354 };
355
356#define BAP_MIN(x, y) ((x) < (y) ? (x) : (y))
357#define MAX_BYTES 8
358// Each byte will be converted to hex digits followed by a
359// punctuation (which is specified in the "delimiter" param.) Thus
360// allocate three times the storage.
361v_U8_t *
362bapBin2Hex(const v_U8_t *bytes, v_U32_t len, char delimiter)
363{
364 static v_U8_t buf[MAX_BYTES*(2+1)];
365 v_U32_t i;
366 v_U8_t *ptr;
367
368 len = BAP_MIN(len, MAX_BYTES);
369 for (i = 0, ptr = buf; i < len; i++)
370 {
371 *ptr++ = hexValue[ (bytes[i] >> 4) & 0x0f];
372 *ptr++ = hexValue[ bytes[i] & 0x0f];
373 *ptr++ = delimiter;
374 //sprintf(ptr, "%.2x%c", bytes[i], delimiter);
375 //ptr += 3;
376 }
377
378 // Delete the extra punctuation and null terminate the string
379 if (len > 0)
380 ptr--;
381 *ptr = '\0';
382
383 return buf;
384}// bapBin2Hex
385
386char bapSsidPrefixValue[] = {'A', 'M', 'P', '-'};
387
388v_U8_t *
389convertBSSIDToSSID
390(
391 v_U8_t *bssid /* BSSID value */
392)
393{
394 static v_U8_t ssId[32];
395
396 vos_mem_copy(
397 ssId,
398 bapSsidPrefixValue,
399 4);
400
401 vos_mem_copy(
402 &ssId[4],
403 bapBin2Hex(bssid, 6, '-'),
404 17);
405
406 return ssId;
407} // convertBSSIDToSSID
408
409VOS_STATUS
410convertToCsrProfile
411(
412 ptBtampContext btampContext, /* btampContext value */
413 eCsrRoamBssType bssType,
414 tCsrRoamProfile *pProfile /* return the profile info here */
415)
416{
417 static v_U8_t btampRSNIE[] = {0x30, 0x14, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00,
418 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x00, 0x00
419 };
420 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
421 v_S7_t sessionid = -1;
422 tHalHandle hHal = NULL;
423 v_U32_t triplet;
424 v_U8_t regulatoryClass;
425 v_U8_t firstChannel;
426 v_U8_t numChannels;
427 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
428 if (NULL == btampContext)
429 {
430 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700431 "btampContext is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700432
433 return VOS_STATUS_E_FAULT;
434 }
435
436 hHal = VOS_GET_HAL_CB(btampContext->pvosGCtx);
437 if (NULL == hHal)
438 {
439 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700440 "hHal is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700441
442 return VOS_STATUS_E_FAULT;
443 }
444
445 //Zero out entire roamProfile structure to avoid problems in uninitialized pointers as the structure expands */
446 //vos_mem_zero(pProfile,sizeof(tCsrRoamProfile));
447
448 //Set the BSS Type
449 //pProfile->BSSType = convertRoleToBssType(btampContext->BAPDeviceRole );
450 pProfile->BSSType = bssType;
451 //pProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
452
453 //Set the SSID
454
455 if ( bssType == eCSR_BSS_TYPE_WDS_STA)
456 {
457 pProfile->SSIDs.numOfSSIDs = 2;
458
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700459 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: bssType = %s, SSID specified = %s\n", __func__, "eCSR_BSS_TYPE_WDS_STA", convertBSSIDToSSID(btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700460
461 vos_mem_zero(pProfile->SSIDs.SSIDList[0].SSID.ssId,
462 sizeof(pProfile->SSIDs.SSIDList[0].SSID.ssId));
463 vos_mem_copy(pProfile->SSIDs.SSIDList[0].SSID.ssId,
464 convertBSSIDToSSID(btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr),
465 21); // Length of BTAMP SSID is 21 bytes
466 pProfile->SSIDs.SSIDList[0].SSID.length = 21;
467
468 vos_mem_zero(pProfile->SSIDs.SSIDList[1].SSID.ssId,
469 sizeof(pProfile->SSIDs.SSIDList[1].SSID.ssId));
470 vos_mem_copy(pProfile->SSIDs.SSIDList[1].SSID.ssId,
471 convertBSSIDToSSID(btampContext->self_mac_addr),
472 21); // Length of BTAMP SSID is 21 bytes
473 pProfile->SSIDs.SSIDList[1].SSID.length = 21;
474
475 //Set the BSSID to the Remote AP
476 pProfile->BSSIDs.numOfBSSIDs = 1;
477 vos_mem_copy(pProfile->BSSIDs.bssid,
478 btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr,
479 sizeof( tCsrBssid ) );
480
481 }
482 else if ( bssType == eCSR_BSS_TYPE_WDS_AP)
483 {
484 pProfile->SSIDs.numOfSSIDs = 1;
485
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700486 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: bssType = %s, SSID specified = %s\n", __func__, "eCSR_BSS_TYPE_WDS_AP", convertBSSIDToSSID(btampContext->self_mac_addr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700487
488 vos_mem_zero(pProfile->SSIDs.SSIDList[0].SSID.ssId,
489 sizeof(pProfile->SSIDs.SSIDList[0].SSID.ssId));
490 vos_mem_copy(pProfile->SSIDs.SSIDList[0].SSID.ssId,
491 convertBSSIDToSSID(btampContext->self_mac_addr),
492 21); // Length of BTAMP SSID is 21 bytes
493 pProfile->SSIDs.SSIDList[0].SSID.length = 21;
494
495#if 0
496 //In case you are an AP, don't set the BSSID
497 pProfile->BSSIDs.numOfBSSIDs = 0;
498#endif //0
499
500 //Set the BSSID to your "self MAC Addr"
501 pProfile->BSSIDs.numOfBSSIDs = 1;
502 vos_mem_copy(pProfile->BSSIDs.bssid,
503 btampContext->self_mac_addr,
504 sizeof( tCsrBssid ) );
505
506 }
507 else
508 // Handle everything else as bssType eCSR_BSS_TYPE_INFRASTRUCTURE
509 {
510 pProfile->SSIDs.numOfSSIDs = 1;
511
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700512 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: bssType = %s, SSID specified = %s\n", __func__, "eCSR_BSS_TYPE_WDS_STA", convertBSSIDToSSID(btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
514 vos_mem_zero(pProfile->SSIDs.SSIDList[0].SSID.ssId,
515 sizeof(pProfile->SSIDs.SSIDList[0].SSID.ssId));
516 vos_mem_copy(pProfile->SSIDs.SSIDList[0].SSID.ssId,
517 convertBSSIDToSSID(btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr),
518 21); // Length of BTAMP SSID is 21 bytes
519 pProfile->SSIDs.SSIDList[0].SSID.length = 21;
520
521 //Set the BSSID to the Remote AP
522 pProfile->BSSIDs.numOfBSSIDs = 1;
523 vos_mem_copy(pProfile->BSSIDs.bssid,
524 btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr,
525 sizeof( tCsrBssid ) );
526
527 }
528
529 //Always set the Auth Type
530 //pProfile->negotiatedAuthType = eCSR_AUTH_TYPE_RSN_PSK;
531 //pProfile->negotiatedAuthType = eCSR_AUTH_TYPE_NONE;
532 //pProfile->negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
533 pProfile->AuthType.numEntries = 1;
534 //pProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
535 pProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
536
537 //Always set the Encryption Type
538 //pProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_AES;
539 //pProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
540 pProfile->EncryptionType.numEntries = 1;
541 //pProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
542 pProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
543
544 pProfile->mcEncryptionType.numEntries = 1;
545 //pProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
546 pProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
547
548 //set the RSN IE
549 //This is weird, but it works
550 pProfile->pRSNReqIE = &btampRSNIE[0];
551 pProfile->nRSNReqIELength = 0x16; //TODO
552 //pProfile->pRSNReqIE = NULL;
553
554 /** We don't use the WPAIE.But NULL it to avoid being used **/
555 pProfile->pWPAReqIE = NULL;
556 pProfile->nWPAReqIELength = 0;
557
558 // Identify the operation channel
559
560 /* Choose the operation channel from the preferred channel list */
561 pProfile->operationChannel = 0;
562 regulatoryClass = 0;
563 for (triplet = 0; triplet < btampContext->btamp_Remote_AMP_Assoc.HC_pref_num_triplets; triplet++)
564 {
565 firstChannel = 0;
566 numChannels = 0;
567
568 /* is this a regulatory class triplet? */
569 if (btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets[triplet][0] == 201)
570 {
571 /* identify supported 2.4GHz regulatory classes */
572 switch (btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets[triplet][1])
573 {
574 case 254:
575 {
576 /* class 254 is special regulatory class defined by BT HS+3.0 spec that
577 is valid only for unknown/'mobile' country */
578 if ((btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[0] == 'X') &&
579 (btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[1] == 'X'))
580 {
581 regulatoryClass = 254;
582 firstChannel = 1;
583 numChannels = 11;
584 }
585 break;
586 }
587 case 12:
588 {
589 /* class 12 in the US regulatory domain is 2.4GHz channels 1-11 */
590 if ((btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[0] == 'U') &&
591 (btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[1] == 'S'))
592 {
593 regulatoryClass = 12;
594 firstChannel = 1;
595 numChannels = 11;
596 }
597 break;
598 }
599 case 4:
600 {
601 /* class 4 in the Europe regulatory domain is 2.4GHz channels 1-13 */
602 if ((btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[0] == 'G') &&
603 (btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[1] == 'B'))
604 {
605 regulatoryClass = 4;
606 firstChannel = 1;
607 numChannels = 13;
608 }
609 break;
610 }
611 case 30:
612 {
613 /* class 30 in the Japan regulatory domain is 2.4GHz channels 1-13 */
614 if ((btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[0] == 'J') &&
615 (btampContext->btamp_Remote_AMP_Assoc.HC_pref_country[1] == 'P'))
616 {
617 regulatoryClass = 30;
618 firstChannel = 1;
619 numChannels = 13;
620 }
621 break;
622 }
623 default:
624 {
625 break;
626 }
627 }
628 /* if the next triplet is not another regulatory class triplet then it must be a sub-band
629 triplet. Skip processing the default channels for this regulatory class triplet and let
630 the sub-band triplet restrict the available channels */
631 if (((triplet+1) < btampContext->btamp_Remote_AMP_Assoc.HC_pref_num_triplets) &&
632 (btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets[triplet+1][0] != 201))
633 {
634 continue;
635 }
636 }
637 else
638 {
639 /* if the regulatory class is valid then this is a sub-band triplet */
640 if (regulatoryClass)
641 {
642 firstChannel = btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets[triplet][0];
643 numChannels = btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets[triplet][1];
644 }
645 }
646
647 if (firstChannel && numChannels)
648 {
649 if (!btampContext->btamp_AMP_Assoc.HC_pref_num_triplets)
650 {
651 pProfile->operationChannel = firstChannel;
652 break;
653 }
654 else if (((btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][0] + btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][1]) <= firstChannel) ||
655 ((firstChannel + numChannels ) <= btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][0]))
656 {
657 continue;
658 }
659 else if ((btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][0] + btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][1]) > firstChannel)
660 {
661 pProfile->operationChannel = firstChannel;
662 break;
663 }
664 else if ((firstChannel + numChannels) > btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][0])
665 {
666 pProfile->operationChannel = btampContext->btamp_AMP_Assoc.HC_pref_triplets[1][0];
667 break;
668 }
669 }
670 }
671
672 if (!pProfile->operationChannel)
673 {
674 return VOS_STATUS_E_INVAL;
675 }
676
677 /*Set the selected channel */
678 sessionid = sme_GetInfraSessionId(hHal);
679 /*if there is infra session up already, use that channel only for BT AMP
680 connection, else we can use the user preferred one*/
681 if(-1 != sessionid)
682 {
683 pProfile->operationChannel =
684 sme_GetInfraOperationChannel(hHal,
685 sessionid);
686 }
687
688 if(sme_IsChannelValid(hHal, pProfile->operationChannel))
689 {
690 btampContext->channel = pProfile->operationChannel;
691 }
692 else
693 {
694 //no valid channel, not proceeding with connection
695 return VOS_STATUS_E_INVAL;
696 }
697
698 if ( BT_INITIATOR == btampContext->BAPDeviceRole )
699 {
700 pProfile->ChannelInfo.numOfChannels = 1;
701 pProfile->ChannelInfo.ChannelList = &pProfile->operationChannel;
702 }
703 else
704 {
705 pProfile->ChannelInfo.numOfChannels = 1;
706 pProfile->ChannelInfo.ChannelList = &pProfile->operationChannel;
707 }
708
709
710 // Turn off CB mode
711 pProfile->CBMode = eCSR_CB_OFF;
712
713 //set the phyMode to accept anything
714 //Taurus means everything because it covers all the things we support
715 pProfile->phyMode = eCSR_DOT11_MODE_11n; //eCSR_DOT11_MODE_TAURUS; //eCSR_DOT11_MODE_AUTO; /*eCSR_DOT11_MODE_BEST;*/
716
717 //set the mode in CFG as well
718 sme_CfgSetInt(hHal, WNI_CFG_DOT11_MODE, WNI_CFG_DOT11_MODE_11N, NULL, eANI_BOOLEAN_FALSE);
719
720 pProfile->bWPSAssociation = eANI_BOOLEAN_FALSE;
721
722 //Make sure we DON'T request UAPSD
723 pProfile->uapsd_mask = 0;
724
725 //return the vosStatus
726 return vosStatus;
727} //convertToCsrProfile
728
729VOS_STATUS
730gotoStarting
731(
732 ptBtampContext btampContext, /* btampContext value */
733 ptWLAN_BAPEvent bapEvent, /* State machine event */
734 eCsrRoamBssType bssType,
735 v_U8_t *status /* return the BT-AMP status here */
736)
737{
738 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
739 eHalStatus halStatus;
740 v_U32_t parseStatus;
741 /* tHalHandle */
742 tHalHandle hHal;
743 tBtampTLVHCI_Write_Remote_AMP_ASSOC_Cmd *pBapHCIWriteRemoteAMPAssoc
744 = (tBtampTLVHCI_Write_Remote_AMP_ASSOC_Cmd *) bapEvent->params;
745 tBtampAMP_ASSOC btamp_ASSOC;
746
747 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
748 if (NULL == btampContext)
749 {
750 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700751 "btampContext is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700752
753 return VOS_STATUS_E_FAULT;
754 }
755
756 hHal = VOS_GET_HAL_CB(btampContext->pvosGCtx);
757 if (NULL == hHal)
758 {
759 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700760 "hHal is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
762 return VOS_STATUS_E_FAULT;
763 }
764
765 //If we are a BT-Responder, we are assuming we are a BT "slave" and we HAVE
766 //to "squelch" the slaves frequent (every 1.25ms) polls.
767
768 if (eCSR_BSS_TYPE_WDS_STA == bssType)
769 {
770 /* Sleep for 300(200) milliseconds - to allow BT through */
771 vos_sleep( 200 );
772 /* Signal BT Coexistence code in firmware to prefer WLAN */
773 WLANBAP_NeedBTCoexPriority ( btampContext, 1);
774 }
775
776
777 //Tell PMC to exit BMPS;
778 halStatus = pmcRequestFullPower(
779 hHal,
780 WLANBAP_pmcFullPwrReqCB,
781 btampContext,
782 eSME_REASON_OTHER);
783 // JEZ081210: This has to wait until we sync down from
784 // /main/latest as of 12/4. We are currently at 12/3.
785 //eSME_FULL_PWR_NEEDED_BY_BAP);
786 //Need to check the result...because Host may have been told by
787 //OS to go to standby (D2) device state. In that case, I have to
788 //fail the HCI Create Physical Link
789
790 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700791 "In %s, amp_assoc_remaining_length = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 pBapHCIWriteRemoteAMPAssoc->amp_assoc_remaining_length);
793#if 0
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700794 DUMPLOG(1, __func__, "amp_assoc_fragment",
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 pBapHCIWriteRemoteAMPAssoc->amp_assoc_fragment,
796 64);
797#endif //0
798
799 //What about parsing the AMP Assoc structure?
800 parseStatus = btampUnpackAMP_ASSOC(
801 hHal,
802 pBapHCIWriteRemoteAMPAssoc->amp_assoc_fragment,
803 pBapHCIWriteRemoteAMPAssoc->amp_assoc_remaining_length,
804 &btamp_ASSOC);
805
806 /* Unknown or Reserved TLVs are allowed in the write AMP assoc fragment */
807 if ((BTAMP_PARSE_SUCCESS != parseStatus ) && (BTAMP_UNKNOWN_TLVS != parseStatus))
808 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700809 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, parseStatus = %d", __func__, parseStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 *status = WLANBAP_ERROR_INVALID_HCI_CMND_PARAM;
811 return VOS_STATUS_E_BADMSG;
812 }
813
814 //What about writing the peer MAC address, and other info to the BTAMP
815 //context for this physical link?
816 if (btamp_ASSOC.AMP_Assoc_MAC_Addr.present == 1)
817 {
818 /* Save the peer MAC address */
819 vos_mem_copy(
820 btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr,
821 btamp_ASSOC.AMP_Assoc_MAC_Addr.mac_addr,
822 sizeof(btampContext->btamp_Remote_AMP_Assoc.HC_mac_addr));
823 /* Save it in the peer MAC address field */
824 vos_mem_copy(
825 btampContext->peer_mac_addr,
826 btamp_ASSOC.AMP_Assoc_MAC_Addr.mac_addr,
827 sizeof(btampContext->peer_mac_addr));
828 }
829
830 if (btamp_ASSOC.AMP_Assoc_Preferred_Channel_List.present == 1)
831 {
832 /* Save the peer Preferred Channel List */
833 vos_mem_copy(
834 btampContext->btamp_Remote_AMP_Assoc.HC_pref_country,
835 btamp_ASSOC.AMP_Assoc_Preferred_Channel_List.country,
836 sizeof(btampContext->btamp_Remote_AMP_Assoc.HC_pref_country));
837 /* Save the peer Preferred Channel List */
838 btampContext->btamp_Remote_AMP_Assoc.HC_pref_num_triplets =
839 btamp_ASSOC.AMP_Assoc_Preferred_Channel_List.num_triplets;
840 if(WLANBAP_MAX_NUM_TRIPLETS <
841 btampContext->btamp_Remote_AMP_Assoc.HC_pref_num_triplets)
842 {
843 btampContext->btamp_Remote_AMP_Assoc.HC_pref_num_triplets =
844 WLANBAP_MAX_NUM_TRIPLETS;
845 }
846 vos_mem_copy(
847 btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets,
848 btamp_ASSOC.AMP_Assoc_Preferred_Channel_List.triplets,
849 sizeof(btampContext->btamp_Remote_AMP_Assoc.HC_pref_triplets[0]) *
850 btampContext->btamp_Remote_AMP_Assoc.HC_pref_num_triplets
851 );
852 }
853
854 if (btamp_ASSOC.AMP_Assoc_Connected_Channel.present == 1)
855 {
856 /* Save the peer Connected Channel */
857 vos_mem_copy(
858 btampContext->btamp_Remote_AMP_Assoc.HC_cnct_country,
859 btamp_ASSOC.AMP_Assoc_Connected_Channel.country,
860 sizeof(btampContext->btamp_Remote_AMP_Assoc.HC_cnct_country));
861 /* Save the peer Connected Channel */
862 btampContext->btamp_Remote_AMP_Assoc.HC_cnct_num_triplets =
863 btamp_ASSOC.AMP_Assoc_Connected_Channel.num_triplets;
864 if(WLANBAP_MAX_NUM_TRIPLETS <
865 btampContext->btamp_Remote_AMP_Assoc.HC_cnct_num_triplets)
866 {
867 btampContext->btamp_Remote_AMP_Assoc.HC_cnct_num_triplets =
868 WLANBAP_MAX_NUM_TRIPLETS;
869 }
870 vos_mem_copy(
871 btampContext->btamp_Remote_AMP_Assoc.HC_cnct_triplets,
872 btamp_ASSOC.AMP_Assoc_Connected_Channel.triplets,
873 sizeof(btampContext->btamp_Remote_AMP_Assoc.HC_cnct_triplets[0]) *
874 btampContext->btamp_Remote_AMP_Assoc.HC_cnct_num_triplets
875 );
876 }
877
878 if (btamp_ASSOC.AMP_Assoc_PAL_Capabilities.present == 1)
879 {
880 /* Save the peer PAL Capabilities */
881 btampContext->btamp_Remote_AMP_Assoc.HC_pal_capabilities
882 = btamp_ASSOC.AMP_Assoc_PAL_Capabilities.pal_capabilities;
883 }
884
885 if (btamp_ASSOC.AMP_Assoc_PAL_Version.present == 1)
886 {
887 /* Save the peer PAL Version */
888 btampContext->btamp_Remote_AMP_Assoc.HC_pal_version
889 = btamp_ASSOC.AMP_Assoc_PAL_Version.pal_version;
890
891 btampContext->btamp_Remote_AMP_Assoc.HC_pal_CompanyID
892 = btamp_ASSOC.AMP_Assoc_PAL_Version.pal_CompanyID;
893
894 btampContext->btamp_Remote_AMP_Assoc.HC_pal_subversion
895 = btamp_ASSOC.AMP_Assoc_PAL_Version.pal_subversion;
896 }
897
898 //Set Connection Accept Timeout;
899 /* Already done in gotoS1() */
900 //Set gNeedPhysLinkCompEvent;
901 //JEZ081114: This needs to happen earlier. In gotoS1. Right at HCI Create Physical Link
902 btampContext->gNeedPhysLinkCompEvent = VOS_TRUE;
903 //Clear gDiscRequested;
904 btampContext->gDiscRequested = VOS_FALSE;
905 //Set gPhysLinkStatus to 0 (no error);
906 btampContext->gPhysLinkStatus = WLANBAP_STATUS_SUCCESS;
907 //Set gDiscReason to 0 (no reason);
908 btampContext->gDiscReason = WLANBAP_STATUS_SUCCESS;
909 /* Initiate the link as either START or JOIN */
910 //halStatus = csrRoamOpenSession(&newSession);
911 /*Added by Luiza:*/
912
913 if (btampContext->isBapSessionOpen == FALSE)
914 {
915
916 halStatus = sme_OpenSession(hHal,
917 WLANBAP_RoamCallback,
918 btampContext,
919 // <=== JEZ081210: FIXME
920 //(tANI_U8 *) btampContext->self_mac_addr,
921 btampContext->self_mac_addr,
922 &btampContext->sessionId);
923 if(eHAL_STATUS_SUCCESS == halStatus)
924 {
925 btampContext->isBapSessionOpen = TRUE;
926 }
927 else
928 {
929 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700930 "sme_OpenSession failed in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 *status = WLANBAP_ERROR_NO_CNCT;
932 return VOS_STATUS_E_FAILURE;
933 }
934 }
935 /* Update the SME Session info for this Phys Link (i.e., for this Phys State Machine instance) */
936 //bapUpdateSMESessionForThisPhysLink(newSession, PhysLinkHandle);
937 // Taken care of, above
938 //halStatus = csrRoamConnect(newSession, bssType);
939 // Final
940 vosStatus = convertToCsrProfile (
941 btampContext, /* btampContext value */
942 bssType,
943 &btampContext->csrRoamProfile); /* return the profile info here */
944 if(VOS_STATUS_E_INVAL == vosStatus)
945 {
946 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700947 "Incorrect channel to create AMP link %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 *status = WLANBAP_ERROR_NO_SUITABLE_CHANNEL;
949 return VOS_STATUS_E_INVAL;
950 }
951#if 0
952 halStatus = sme_RoamConnect(VOS_GET_HAL_CB(btampContext->pvosGCtx),
953 &btampContext->csrRoamProfile,
954 NULL, /* tScanResultHandle hBssListIn, */
955 &btampContext->csrRoamId);
956#endif //0
957//#if 0
958 halStatus = sme_RoamConnect(hHal,
959 btampContext->sessionId,
960 &btampContext->csrRoamProfile,
961 &btampContext->csrRoamId);
962//#endif //0
963
964 //Map the halStatus into a vosStatus
965 return vosStatus;
966} //gotoStarting
967
968VOS_STATUS
969gotoConnecting(
970 ptBtampContext btampContext /* btampContext value */
971)
972{
973 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
974
975 /* No longer needed. This call has been made in gotoStarting(). */
976 /* Signal BT Coexistence code in firmware to prefer WLAN */
977 WLANBAP_NeedBTCoexPriority ( btampContext, 1);
978
979 return vosStatus;
980} //gotoConnecting
981
982VOS_STATUS
983gotoAuthenticating(
984 ptBtampContext btampContext /* btampContext value */
985)
986{
987 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
988
989 /* Signal BT Coexistence code in firmware to prefer WLAN */
990 WLANBAP_NeedBTCoexPriority ( btampContext, 1);
991
992 return vosStatus;
993} //gotoAuthenticating
994
995#if 0
996VOID initRsnSupplicant()
997{
998/* This is a NO-OP. The Supplicant waits for MSG 1 */
999}
1000#endif /* 0 */
1001VOS_STATUS
1002initRsnSupplicant
1003(
1004 ptBtampContext btampContext, /* btampContext value */
1005 tWLAN_BAPRole BAPDeviceRole
1006)
1007{
1008 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1009
1010 /* This is a NO-OP. The Supplicant waits for MSG 1 */
1011 /* Init RSN FSM */
1012 if (!(suppRsnFsmCreate(btampContext)))
1013 {
1014 /* Send Start Event */
1015 /* RSN_FSM_AUTH_START */
1016 }
1017 else
1018 {
1019 /* RSN Init Failed */
1020 vosStatus = VOS_STATUS_E_FAILURE;
1021 }
1022 /* This is a NO-OP. The Supplicant waits for MSG 1 */
1023 return vosStatus;
1024}
1025
1026#if 0
1027VOID initRsnAuthenticator()
1028{
1029/* Signal the Authenticator/Supplicant App that we are associated. */
1030/* Use an IOCTL? That the app is hanging a read on? Or use a "special" data packet. Again, that the app is waiting on a receive for. */
1031}
1032#endif /* 0 */
1033VOS_STATUS
1034initRsnAuthenticator
1035(
1036 ptBtampContext btampContext, /* btampContext value */
1037 tWLAN_BAPRole BAPDeviceRole
1038)
1039{
1040 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1041 /* Init RSN FSM */
1042 if (!(authRsnFsmCreate(btampContext)))
1043 {
1044 /* Send Start Event */
1045 }
1046 else
1047 {
1048 /* RSN Init Failed */
1049 vosStatus = VOS_STATUS_E_FAILURE;
1050 }
1051 return vosStatus;
1052/* Signal the Authenticator/Supplicant App that we are associated. */
1053/* Use an IOCTL? That the app is hanging a read on? Or use a "special" data packet. Again, that the app is waiting on a receive for. */
1054}
1055
1056/* We have to register our STA with TL */
1057VOS_STATUS
1058regStaWithTl
1059(
1060 ptBtampContext btampContext, /* btampContext value */
1061 tWLAN_BAPRole BAPDeviceRole,
1062 tCsrRoamInfo *pCsrRoamInfo
1063)
1064{
1065 VOS_STATUS vosStatus;
1066 WLAN_STADescType staDesc;
1067 tANI_S8 rssi = 0;
1068
1069 vos_mem_zero(&staDesc, sizeof(WLAN_STADescType));
1070 /* Fill in everything I know about the STA */
1071 btampContext->ucSTAId = staDesc.ucSTAId = pCsrRoamInfo->staId;
1072
1073 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BAP register TL ucSTAId=%d\n",
1074 staDesc.ucSTAId );
1075
1076 /* Fill in the peer MAC address */
1077 vos_mem_copy(
1078 staDesc.vSTAMACAddress.bytes,
1079 btampContext->peer_mac_addr,
1080 sizeof(btampContext->peer_mac_addr));
1081
1082 /* Fill in the self MAC address */
1083 vos_mem_copy(
1084 staDesc.vSelfMACAddress.bytes,
1085 btampContext->self_mac_addr,
1086 sizeof(btampContext->peer_mac_addr));
1087
1088 /* Set the STA Type */
1089 staDesc.wSTAType = WLAN_STA_BT_AMP;
1090
1091 // Set the QoS field appropriately, if the info available
1092 if( pCsrRoamInfo->u.pConnectedProfile)
1093 {
1094 btampContext->bapQosCfg.bWmmIsEnabled = //1;
1095 pCsrRoamInfo->u.pConnectedProfile->qosConnection;
1096 }
1097 else
1098 {
1099 btampContext->bapQosCfg.bWmmIsEnabled = 0;
1100 }
1101
1102 // set the QoS field appropriately
1103 if( btampContext->bapQosCfg.bWmmIsEnabled )
1104 {
1105 staDesc.ucQosEnabled = 1;
1106 }
1107 else
1108 {
1109 staDesc.ucQosEnabled = 0;
1110 }
1111
1112 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BAP register TL QoS_enabled=%d\n",
1113 staDesc.ucQosEnabled );
1114
1115 // UMA is ready we inform TL not to do frame
1116 // translation for WinMob 6.1
1117 //*** Not to enabled UMA.
1118 /* Enable UMA for TX translation only when there is no concurrent session active */
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 staDesc.ucSwFrameRXXlation = 1;
1121 staDesc.ucAddRmvLLC = 0;
1122
1123 if ( btampContext->ucSecEnabled )
1124 {
1125 staDesc.ucProtectedFrame = 1;
1126 }
1127 else
1128 {
1129 staDesc.ucProtectedFrame = 0;
1130 }
1131
1132 staDesc.ucUcastSig = pCsrRoamInfo->ucastSig;
1133 staDesc.ucBcastSig = pCsrRoamInfo->bcastSig;
1134 staDesc.ucInitState = ( btampContext->ucSecEnabled)?
1135 WLANTL_STA_CONNECTED:WLANTL_STA_AUTHENTICATED;
1136 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1137 if(NULL != pCsrRoamInfo->pBssDesc)
1138 {
1139 rssi = pCsrRoamInfo->pBssDesc->rssi;
1140 }
1141 /* register our STA with TL */
1142 vosStatus = WLANTL_RegisterSTAClient
1143 (
1144 btampContext->pvosGCtx,
1145 WLANBAP_STARxCB,
1146 WLANBAP_TxCompCB,
1147 (WLANTL_STAFetchPktCBType)WLANBAP_STAFetchPktCB,
1148 &staDesc ,
1149 rssi);
1150 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1151 {
1152 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsoncbf37562013-10-30 12:08:36 -07001153 "%s: WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001154 __func__, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 }
1156
1157 if ( ! btampContext->ucSecEnabled )
1158 {
1159 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_MED,
1160 "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", btampContext->ucSTAId);
1161
1162 // Connections that do not need Upper layer auth, transition TL directly
1163 // to 'Authenticated' state.
1164 vosStatus = WLANTL_ChangeSTAState( btampContext->pvosGCtx, staDesc.ucSTAId,
1165 WLANTL_STA_AUTHENTICATED );
1166 }
1167 else
1168 {
1169
1170 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_MED,
1171 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", btampContext->ucSTAId );
1172
1173 vosStatus = WLANTL_ChangeSTAState( btampContext->pvosGCtx, staDesc.ucSTAId,
1174 WLANTL_STA_CONNECTED );
1175 }
1176
1177 return VOS_STATUS_SUCCESS;
1178} /* regStaWithTl */
1179
1180#if 0
1181/*==========================================================================
1182
1183 FUNCTION: determineChan
1184
1185 DESCRIPTION: Return the current channel we are to operate on
1186
1187============================================================================*/
1188#endif
1189
1190VOS_STATUS
1191determineChan
1192(
1193 ptBtampContext btampContext, /* btampContext value */
1194 tWLAN_BAPRole BAPDeviceRole,
1195 v_U32_t *channel, /* Current channel */
1196 v_U8_t *status /* return the BT-AMP status here */
1197)
1198{
1199 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1200 v_U32_t activeFlag; /* Channel active flag */
1201 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1202
1203 switch(BAPDeviceRole)
1204 {
1205 case BT_INITIATOR:
1206 /* if an Infra assoc already exists, return that channel. */
1207 /* or use the results from the Scan to determine the least busy channel. How? */
1208 /* For now, just do this. */
1209 vosStatus = WLANBAP_GetCurrentChannel (btampContext, channel, &activeFlag);
1210 break;
1211 case BT_RESPONDER:
1212 /* return the value obtained from the Preferred Channels field of the AMP Assoc structure from the BT-AMP peer (device A) */
1213 /* No! I don't have that yet. */
1214 /* For now, just do this. */
1215 vosStatus = WLANBAP_GetCurrentChannel (btampContext, channel, &activeFlag);
1216 break;
1217 default:
1218 *status = WLANBAP_ERROR_HOST_REJ_RESOURCES; /* return the BT-AMP status here */
1219 return VOS_STATUS_E_RESOURCES;
1220 }
1221 *status = WLANBAP_STATUS_SUCCESS; /* return the BT-AMP status here */
1222
1223 return vosStatus;
1224} // determineChan
1225
1226VOS_STATUS
1227gotoDisconnected
1228(
1229 ptBtampContext btampContext /* btampContext value */
1230)
1231{
1232 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1233 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1234
1235 //Is it legitimate to always make this call?
1236 //What if pmcRequestFullPower wasn't called?
1237 //Tell PMC to resume BMPS; /* Whatever the previous BMPS "state" was */
1238 //Comment this out until such time as we have PMC support
1239 //halStatus = pmcResumePower ( hHal);
1240
1241 /* Signal BT Coexistence code in firmware to no longer prefer WLAN */
1242 WLANBAP_NeedBTCoexPriority ( btampContext, 0);
1243
1244 //Map the halStatus into a vosStatus
1245 return vosStatus;
1246} // gotoDisconnected
1247
1248VOS_STATUS
1249gotoDisconnecting
1250(
1251 ptBtampContext btampContext, /* btampContext value */
1252 v_U8_t needPhysLinkCompEvent,
1253 v_U8_t physLinkStatus, /* BT-AMP disconnecting status */
1254// v_U8_t statusPresent, /* BT-AMP disconnecting status present */
1255 v_U8_t discRequested,
1256 v_U8_t discReason /* BT-AMP disconnecting reason */
1257)
1258{
1259
1260 // gNeedPhysLinkCompEvent
1261 btampContext->gNeedPhysLinkCompEvent = needPhysLinkCompEvent;
1262 // gPhysLinkStatus
1263 btampContext->gPhysLinkStatus = physLinkStatus; /* BT-AMP disconnecting status */
1264 // gDiscRequested
1265 btampContext->gDiscRequested = discRequested;
1266 // gDiscReason
1267 btampContext->gDiscReason = discReason; /* BT-AMP disconnecting reason */
1268
1269 //WLANBAP_DeInitLinkSupervision( btampHandle);
1270 //WLANBAP_StopLinkSupervisionTimer(btampContext);
1271
1272 /* Inform user space that no AMP channel is in use, for AFH purposes */
1273 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW,
1274 "Calling send_btc_nlink_msg() with AMP channel = 0");
1275 send_btc_nlink_msg(WLAN_AMP_ASSOC_DONE_IND, 0);
1276
1277 return VOS_STATUS_SUCCESS;
1278} //gotoDisconnecting
1279
1280VOS_STATUS
1281gotoConnected
1282(
1283 ptBtampContext btampContext /* btampContext value */
1284)
1285{
1286 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1287 ptBtampHandle btampHandle = ( ptBtampHandle)btampContext;
1288//#if 0
1289 /* Stop the Connection Accept Timer */
1290 vosStatus = WLANBAP_StopConnectionAcceptTimer (btampContext);
1291//#endif
1292 ///*De-initialize the timer */
1293 //vosStatus = WLANBAP_DeinitConnectionAcceptTimer(btampContext);
1294
1295 /* Signal BT Coex in firmware to now honor only priority BT requests */
1296 WLANBAP_NeedBTCoexPriority ( btampContext, 2);
1297
1298 // If required after successful Upper layer auth, transition TL
1299 // to 'Authenticated' state.
1300 if ( btampContext->ucSecEnabled )
1301 {
1302 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_MED,
1303 "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", btampContext->ucSTAId);
1304
1305 vosStatus = WLANTL_ChangeSTAState(
1306 btampContext->pvosGCtx,
1307 btampContext->ucSTAId,
1308 WLANTL_STA_AUTHENTICATED );
1309 }
1310
1311 btampContext->dataPktPending = VOS_FALSE;
1312 vosStatus = WLANBAP_InitLinkSupervision( btampHandle);
1313
1314 /* Inform user space of the AMP channel selected, for AFH purposes */
1315 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW,
1316 "Calling send_btc_nlink_msg() with AMP channel %d", btampContext->channel);
1317 send_btc_nlink_msg(WLAN_AMP_ASSOC_DONE_IND, btampContext->channel);
1318
1319 return vosStatus;
1320} //gotoConnected
1321
1322
1323/* the HCI Event signalling routine*/
1324VOS_STATUS
1325signalHCIPhysLinkCompEvent
1326(
1327 ptBtampContext btampContext, /* btampContext value */
1328 v_U8_t status /* the BT-AMP status */
1329)
1330{
1331 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1332 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1333 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1334
1335 /* Format the Physical Link Complete event to return... */
1336 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_PHYSICAL_LINK_COMPLETE_EVENT;
1337 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.present = 1;
1338 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.status = status;
1339 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.phy_link_handle
1340 = btampContext->phy_link_handle;
1341 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.ch_number
1342 = btampContext->channel;
1343
1344 if(WLANBAP_STATUS_SUCCESS == status)
1345 {
1346 /* Start the Tx packet monitoring timer */
1347 WLANBAP_StartTxPacketMonitorTimer(btampContext);
1348 }
1349 else
1350 { //reset the PL handle
1351 btampContext->phy_link_handle = 0;
1352 }
1353
1354 vosStatus = (*btampContext->pBapHCIEventCB)
1355 (
1356 btampContext->pHddHdl, /* this refers the BSL per application context */
1357 &bapHCIEvent, /* This now encodes ALL event types */
1358 VOS_TRUE /* Flag to indicate assoc-specific event */
1359 );
1360
1361 return vosStatus;
1362} /* signalHCIPhysLinkCompEvent */
1363
1364/* the HCI Disconnect Complete Event signalling routine*/
1365VOS_STATUS
1366signalHCIPhysLinkDiscEvent
1367(
1368 ptBtampContext btampContext, /* btampContext value */
1369 v_U8_t status, /* the BT-AMP status */
1370 v_U8_t reason /* the BT-AMP reason code */
1371)
1372{
1373 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1374 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1375 v_U8_t i;
1376 tpBtampLogLinkCtx pLogLinkContext = NULL;
1377 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1378
1379#ifdef BAP_DEBUG
1380 /* Trace the tBtampCtx being passed in. */
1381 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301382 "WLAN BAP Context Monitor: btampContext value = %p in %s:%d", btampContext, __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001383#endif //BAP_DEBUG
1384
1385 /* Loop disconnecting all Logical Links on this Physical Link */
1386 for (i = 0 ; i < WLANBAP_MAX_LOG_LINKS; i++)
1387 {
1388 pLogLinkContext = &(btampContext->btampLogLinkCtx[i]);
1389
1390 if (pLogLinkContext->present == VOS_TRUE)
1391 {
1392 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1393 "WLAN BAP: Deleting logical link entry %d in %s", i,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001394 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395
1396 /* Mark this Logical Link index value as free */
1397 pLogLinkContext->present = VOS_FALSE;
1398
1399 // signalHCIDiscLogLink(status = SUCCESS, reason = CONNECTION_TERM_BY_REMOTE_HOST);
1400 signalHCIDiscLogLinkCompEvent
1401 ( btampContext,
1402 WLANBAP_STATUS_SUCCESS,
1403 i, // logical link
1404 // I don't know how to signal CONNECTION_TERM_BY_REMOTE_HOST
1405 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
1406 }
1407 }
1408
1409 /*Reset current_log_link_index and total_log_link_index values*/
1410 btampContext->current_log_link_index = 0;
1411 btampContext->total_log_link_index = 0;
1412
1413 /* Format the Physical Link Disconnect Complete event to return... */
1414 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_COMPLETE_EVENT;
1415 bapHCIEvent.u.btampDisconnectPhysicalLinkCompleteEvent.present = 1;
1416 bapHCIEvent.u.btampDisconnectPhysicalLinkCompleteEvent.status = status;
1417 bapHCIEvent.u.btampDisconnectPhysicalLinkCompleteEvent.reason = reason;//uncommented to debug
1418 bapHCIEvent.u.btampDisconnectPhysicalLinkCompleteEvent.phy_link_handle
1419 = btampContext->phy_link_handle;
1420
1421 /* Stop the Tx packet monitoring timer */
1422 WLANBAP_StopTxPacketMonitorTimer(btampContext);
1423
1424 /*Need to clean up the phy link handle as we are disconnected at this
1425 point
1426 ?? - do we need to do any more cleanup on this*/
1427 btampContext->phy_link_handle = 0;
1428 vosStatus = (*btampContext->pBapHCIEventCB)
1429 (
1430 btampContext->pHddHdl, /* this refers the BSL per application context */
1431 &bapHCIEvent, /* This now encodes ALL event types */
1432 VOS_TRUE /* Flag to indicate assoc-specific event */
1433 );
1434
1435 return vosStatus;
1436} /* signalHCIPhysLinkDiscEvent */
1437
1438/* the HCI Channel Select Event signalling routine*/
1439VOS_STATUS
1440signalHCIChanSelEvent
1441(
1442 ptBtampContext btampContext /* btampContext value */
1443)
1444{
1445 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1446 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1447 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1448
1449 /* Format the Physical Link Disconnect Complete event to return... */
1450 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_CHANNEL_SELECTED_EVENT;
1451 bapHCIEvent.u.btampChannelSelectedEvent.present = 1;
1452 bapHCIEvent.u.btampChannelSelectedEvent.phy_link_handle
1453 = btampContext->phy_link_handle;
1454
1455 vosStatus = (*btampContext->pBapHCIEventCB)
1456 (
1457 btampContext->pHddHdl, /* this refers the BSL per application context */
1458 &bapHCIEvent, /* This now encodes ALL event types */
1459 VOS_TRUE /* Flag to indicate assoc-specific event */
1460 );
1461
1462 return vosStatus;
1463} /* signalHCIChanSelEvent */
1464
1465
1466/* the HCI Disconnect Logical Link Complete Event signalling routine*/
1467VOS_STATUS
1468signalHCIDiscLogLinkCompEvent
1469(
1470 ptBtampContext btampContext, /* btampContext value */
1471 v_U8_t status, /* the BT-AMP status */
1472 v_U16_t log_link_handle, /* The Logical Link that disconnected*/
1473 v_U8_t reason /* the BT-AMP reason code */
1474)
1475{
1476 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1477 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
1478 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1479
1480 /* Format the Logical Link Disconnect Complete event to return... */
1481 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_COMPLETE_EVENT;
1482 bapHCIEvent.u.btampDisconnectLogicalLinkCompleteEvent.present = 1;
1483 bapHCIEvent.u.btampDisconnectLogicalLinkCompleteEvent.status = status;
1484 bapHCIEvent.u.btampDisconnectLogicalLinkCompleteEvent.reason = reason;
1485 bapHCIEvent.u.btampDisconnectLogicalLinkCompleteEvent.log_link_handle
1486 = (log_link_handle << 8) + btampContext->phy_link_handle;
1487
1488 vosStatus = (*btampContext->pBapHCIEventCB)
1489 (
1490 btampContext->pHddHdl, /* this refers the BSL per application context */
1491 &bapHCIEvent, /* This now encodes ALL event types */
1492 VOS_TRUE /* Flag to indicate assoc-specific event */
1493 );
1494
1495 return vosStatus;
1496} /* signalHCIDiscLogLinkCompEvent */
1497
1498
1499// These are needed to recognize RSN suite types
1500#define WLANBAP_RSN_OUI_SIZE 4
1501tANI_U8 pRSNOui00[ WLANBAP_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
1502tANI_U8 pRSNOui01[ WLANBAP_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
1503tANI_U8 pRSNOui02[ WLANBAP_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
1504tANI_U8 pRSNOui03[ WLANBAP_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
1505tANI_U8 pRSNOui04[ WLANBAP_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
1506tANI_U8 pRSNOui05[ WLANBAP_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
1507
1508#define GET_IE_LEN_IN_BSS(lenInBss) ( lenInBss + sizeof(lenInBss) - ((int) OFFSET_OF( tSirBssDescription, ieFields)))
1509/* Incoming Association indication validation predicate */
1510v_U32_t
1511validAssocInd
1512(
1513 ptBtampContext btampContext, /* btampContext value */
1514 tCsrRoamInfo *pRoamInfo
1515)
1516{
1517 /* tHalHandle */
1518 tHalHandle hHal = VOS_GET_HAL_CB(btampContext->pvosGCtx);
1519 v_U32_t ieLen;
1520
1521 /* For now, always return true */
1522 return VOS_TRUE;
1523
1524 /* Check for a valid peer MAC address */
1525 /* For an incoming Assoc Indication, the peer MAC address
1526 * should match the value that the BlueTooth AMP
1527 * configured us with.
1528 */
1529 if ( !vos_mem_compare( btampContext->peer_mac_addr,
1530 pRoamInfo->peerMac,
1531 sizeof(btampContext->peer_mac_addr) ))
1532 {
1533 /* Return not valid */
1534 return VOS_FALSE;
1535 }
1536
1537 /* JEZ081115: For now, ignore the RSN IE */
1538 /* Otherwise, it is valid */
1539 return VOS_TRUE;
1540
1541 /* Check for a trivial case: IEs missing */
1542 if( pRoamInfo->prsnIE == NULL )
1543 {
1544 //btampContext->ieFields = NULL;
1545 //btampContext->ieLen = 0;
1546 /* Return not valid */
1547 return VOS_FALSE;
1548 }
1549
1550 //btampContext->ieLen = GET_IE_LEN_IN_BSS( pBssDesc->length );
1551 //ieLen = GET_IE_LEN_IN_BSS( pBssDesc->length );
1552 ieLen = pRoamInfo->rsnIELen;
1553
1554 /* Check for a trivial case: IEs zero length */
1555 //if( btampContext->ieLen == 0 )
1556 if( ieLen == 0 )
1557 {
1558 //btampContext->ieFields = NULL;
1559 //btampContext->ieLen = 0;
1560 /* Return not valid */
1561 return VOS_FALSE;
1562 }
1563
1564 {
1565 // --- Start of block ---
1566 tDot11fBeaconIEs dot11BeaconIEs;
1567 tDot11fIESSID *pDot11SSID;
1568 tDot11fIERSN *pDot11RSN;
1569
1570 // JEZ081215: This really needs to be updated to just validate the RSN IE.
1571 // Validating the SSID can be done directly from...
1572
1573 // "Unpack" really wants tpAniSirGlobal (pMac) as its first param.
1574 // But since it isn't used, I just pass in some arbitrary "context" pointer.
1575 // So hHalHandle will make it happy.
1576 dot11fUnpackBeaconIEs((tpAniSirGlobal) hHal,
1577 (tANI_U8 *) pRoamInfo->prsnIE,
1578 ieLen,
1579 &dot11BeaconIEs);
1580
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001581 //DUMPLOG(9, __func__, "dot11BeaconIEs", &dot11BeaconIEs, 64);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
1583 pDot11SSID = &dot11BeaconIEs.SSID;
1584
1585 // Assume there wasn't an SSID in the Assoc Request
1586 btampContext->assocSsidLen = 0;
1587
1588 if (pDot11SSID->present )
1589 {
1590
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001591 //DUMPLOG(10, __func__, "pDot11SSID present", pDot11SSID, 64);
Jeff Johnson295189b2012-06-20 16:38:30 -07001592
1593 btampContext->assocSsidLen = pDot11SSID->num_ssid;
1594 vos_mem_copy(btampContext->assocSsid,
1595 pDot11SSID->ssid,
1596 btampContext->assocSsidLen );
1597 }
1598 else
1599 return VOS_FALSE;
1600
1601 // Check the validity of the SSID against our SSID value
1602 if ( !vos_mem_compare( btampContext->ownSsid,
1603 pDot11SSID->ssid,
1604 btampContext->ownSsidLen ))
1605 {
1606 /* Return not valid */
1607 return VOS_FALSE;
1608 }
1609
1610 pDot11RSN = &dot11BeaconIEs.RSN;
1611
1612 // Assume there wasn't an RSN IE in the Assoc Request
1613 //btampContext->assocRsnIeLen = 0;
1614
1615 if (pDot11RSN->present )
1616 {
1617
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001618 //DUMPLOG(10, __func__, "pDot11RSN present", pDot11RSN, 64);
Jeff Johnson295189b2012-06-20 16:38:30 -07001619
1620 //The 802.11 BT-AMP PAL only supports WPA2-PSK
1621 if (!vos_mem_compare(pRSNOui02, // RSN-PSK
1622 pDot11RSN->akm_suites[0],
1623 WLANBAP_RSN_OUI_SIZE))
1624 return VOS_FALSE;
1625
1626 //The 802.11 BT-AMP PAL only supports AES-CCMP Unicast
1627 if (!vos_mem_compare(pRSNOui04, // AES-CCMP
1628 pDot11RSN->pwise_cipher_suites[0],
1629 WLANBAP_RSN_OUI_SIZE))
1630 return VOS_FALSE;
1631 }
1632 else
1633 return VOS_FALSE;
1634
1635
1636 } // --- End of block ---
1637
1638 /* Otherwise, it is valid */
1639 return VOS_TRUE;
1640} /* validAssocInd */
1641
1642/* the change state function*/
1643void
1644btampfsmChangeToState
1645(
1646 BTAMPFSM_INSTANCEDATA_T *instance,
1647 BTAMPFSM_STATES_T state
1648)
1649{
1650 instance->stateVar = state;
1651 //BTAMPFSM_ENTRY_FLAG_T disconnectedEntry;
1652
1653}
1654
1655/* Physical Link state machine function */
1656//int
1657VOS_STATUS
1658btampFsm
1659(
1660 //BTAMPFSM_INSTANCEDATA_T *instanceVar
1661 ptBtampContext btampContext, /* btampContext value */
1662// tBtampSessCtx *tpBtampSessCtx, /* btampContext value */
1663 ptWLAN_BAPEvent bapEvent, /* State machine event */
1664 v_U8_t *status /* return the BT-AMP status here */
1665)
1666{
1667 /* Retrieve the phy link state machine structure
1668 * from the btampContext value
1669 */
1670 BTAMPFSM_INSTANCEDATA_T *instanceVar;
1671 v_U32_t msg = bapEvent->event; /* State machine input event message */
1672 v_U32_t channel; /* Current channel */
1673 v_U32_t activeFlag; /* Channel active flag */
1674 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1675 ptBtampHandle btampHandle = ( ptBtampHandle)btampContext;
1676 v_U8_t ucSTAId; /* The StaId (used by TL, PE, and HAL) */
1677 v_PVOID_t pHddHdl; /* Handle to return BSL context in */
1678 tHalHandle hHal = NULL;
1679 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1680 /* Validate params */
1681 if (btampHandle == NULL)
1682 {
1683 return VOS_STATUS_E_FAULT;
1684 }
1685 instanceVar = &(btampContext->bapPhysLinkMachine);
1686
1687 hHal = VOS_GET_HAL_CB(btampContext->pvosGCtx);
1688 if (NULL == hHal)
1689 {
1690 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001691 "hHal is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
1693 return VOS_STATUS_E_FAULT;
1694 }
1695
1696
1697
1698#define CHANNEL_NOT_SELECTED (WLANBAP_GetCurrentChannel (btampContext, &channel, &activeFlag) != VOS_STATUS_SUCCESS)
1699
1700 /*Initialize BTAMP PAL status code being returned to the btampFsm caller */
1701 *status = WLANBAP_STATUS_SUCCESS;
1702
1703 switch(instanceVar->stateVar)
1704 {
1705
1706 case DISCONNECTED:
1707 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_CREATE))
1708 {
1709 /*Transition from DISCONNECTED to S1 (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001710 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "DISCONNECTED", "S1");
Jeff Johnson295189b2012-06-20 16:38:30 -07001711
1712#if 0
1713 /* This will have issues in multisession. Need not close the session */
1714 /* TODO : Need to have better handling */
1715 if(btampContext->isBapSessionOpen == TRUE)//We want to close only BT-AMP Session
1716 {
1717 sme_CloseSession(VOS_GET_HAL_CB(btampContext->pvosGCtx),
1718 btampContext->sessionId);
1719 /*Added by Luiza:*/
1720 btampContext->isBapSessionOpen = FALSE;
1721 }
1722#endif
1723
1724 /* Set BAP device role */
1725 vosStatus = gotoS1( btampContext, bapEvent, BT_INITIATOR, status);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001726 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, cmd status is %d", __func__, *status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 /*Advance outer statevar */
1728 btampfsmChangeToState(instanceVar,S1);
1729 }
1730 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_ACCEPT))
1731 {
1732 /*Transition from DISCONNECTED to S1 (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001733 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "DISCONNECTED", "S1");
Jeff Johnson295189b2012-06-20 16:38:30 -07001734
1735#if 0
1736 if(btampContext->isBapSessionOpen == TRUE)
1737 {
1738 sme_CloseSession(VOS_GET_HAL_CB(btampContext->pvosGCtx),
1739 btampContext->sessionId);
1740 /*Added by Luiza:*/
1741 btampContext->isBapSessionOpen = FALSE;
1742 }
1743 /*Action code for transition */
1744#endif
1745
1746 /* Set BAP device role */
1747 vosStatus = gotoS1(btampContext, bapEvent, BT_RESPONDER, status);
1748 /*Advance outer statevar */
1749 btampfsmChangeToState(instanceVar,S1);
1750 }
1751 else
1752 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001753 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "DISCONNECTED", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 /* Intentionally left blank */
1755 }
1756 break;
1757
1758 case S1:
1759 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_WRITE_REMOTE_AMP_ASSOC
1760 ) && (btampContext->BAPDeviceRole == BT_INITIATOR && !(CHANNEL_NOT_SELECTED)))
1761 {
1762 /*Transition from S1 to STARTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001763 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "S1", "STARTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 /*Action code for transition */
1766 vosStatus = determineChan(btampContext, BT_INITIATOR, &channel, status);
1767 /*Advance outer statevar */
1768 btampfsmChangeToState(instanceVar,STARTING);
1769 // This has to be commented out until I get the BT-AMP SME/CSR changes
1770 vosStatus = gotoStarting( btampContext, bapEvent, eCSR_BSS_TYPE_WDS_AP, status);
1771 if (VOS_STATUS_SUCCESS != vosStatus)
1772 {
1773 btampfsmChangeToState(instanceVar, S1);
1774 }
1775 }
1776 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
1777 {
1778 /*Transition from S1 to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001779 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "S1", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07001780
1781 /*Action code for transition */
1782 /* Set everything back as dis-connected */
1783 gotoDisconnected( btampContext);
1784 /*Advance outer statevar */
1785 btampfsmChangeToState(instanceVar,DISCONNECTED);
1786 /*Signal the disconnect */
1787 signalHCIPhysLinkCompEvent( btampContext, WLANBAP_ERROR_HOST_TIMEOUT);
1788 }
1789 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
1790 {
1791 /*Transition from S1 to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001792 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "S1", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07001793
1794 /*Action code for transition */
1795 gotoDisconnected(btampContext);
1796 /*Advance outer statevar */
1797 btampfsmChangeToState(instanceVar,DISCONNECTED);
1798 /*Signal the successful physical link disconnect */
1799 signalHCIPhysLinkDiscEvent
1800 ( btampContext,
1801 WLANBAP_STATUS_SUCCESS,
1802 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
1803 /*Signal the unsuccessful physical link creation */
1804 signalHCIPhysLinkCompEvent( btampContext, WLANBAP_ERROR_NO_CNCT );
1805 }
1806 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_WRITE_REMOTE_AMP_ASSOC
1807 ) && (btampContext->BAPDeviceRole == BT_RESPONDER))
1808 {
1809 /*Transition from S1 to STARTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001810 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "S1", "STARTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001811
1812 /*Action code for transition */
1813 //determineChan(BT_RESPONDER);
1814 vosStatus = determineChan(btampContext, BT_RESPONDER, &channel, status);
1815 btampfsmChangeToState(instanceVar,STARTING);//Moved to here to debug
1816 // This has to be commented out until I get the BT-AMP SME/CSR changes
1817 /*Advance outer statevar */
1818 // btampfsmChangeToState(instanceVar,STARTING);
1819 vosStatus = gotoStarting( btampContext, bapEvent, eCSR_BSS_TYPE_WDS_STA, status);
1820 if (VOS_STATUS_SUCCESS != vosStatus)
1821 {
1822 btampfsmChangeToState(instanceVar, S1);
1823 }
1824 }
1825 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_WRITE_REMOTE_AMP_ASSOC
1826 ) && (btampContext->BAPDeviceRole == BT_INITIATOR && CHANNEL_NOT_SELECTED))
1827 {
1828 /*Transition from S1 to SCANNING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001829 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "S1", "SCANNING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001830
1831 /*Action code for transition */
1832 gotoScanning(btampContext, BT_RESPONDER, status);
1833 /*Advance outer statevar */
1834 btampfsmChangeToState(instanceVar,SCANNING);
1835 }
1836 else
1837 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001838 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "S1", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 /* Intentionally left blank */
1840 }
1841 break;
1842
1843 case STARTING:
1844 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_START_BSS_SUCCESS
1845 ) && (btampContext->BAPDeviceRole == BT_INITIATOR))
1846 {
1847 /*Transition from STARTING to CONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001848 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "STARTING", "CONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001849
1850 btampfsmChangeToState(instanceVar,CONNECTING);//Moved to debug
1851
1852 /*Set the selected channel */
1853 /*should have been already set */
1854 btampContext->channel = ( 0 == btampContext->channel )?1:btampContext->channel;
1855
1856 /*Action code for transition */
1857 signalHCIChanSelEvent(btampContext);
1858
1859 }
1860 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
1861 {
1862 /*Transition from STARTING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001863 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "STARTING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001864
1865 /*Action code for transition */
1866 //csrRoamDisconnect();
1867 sme_RoamDisconnect(hHal,
1868 //JEZ081115: Fixme
1869 btampContext->sessionId,
1870 // Danlin, where are the richer reason codes?
1871 // I want to be able to convey everything 802.11 supports...
1872 eCSR_DISCONNECT_REASON_UNSPECIFIED);
1873
1874 gotoDisconnecting(
1875 btampContext,
1876 VOS_TRUE,
1877 WLANBAP_ERROR_NO_CNCT,
1878 //VOS_TRUE, // Should be VOS_FALSE !!!
1879 VOS_FALSE,
1880 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
1881 /*Advance outer statevar */
1882 btampfsmChangeToState(instanceVar,DISCONNECTING);
1883 // It is NOT clear that we need to send the Phy Link Disconnect
1884 // Complete Event here.
1885 signalHCIPhysLinkDiscEvent
1886 ( btampContext,
1887 WLANBAP_STATUS_SUCCESS,
1888 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
1889 }
1890 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_CHANNEL_SELECTION_FAILED))
1891 {
1892 /*Transition from STARTING to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001893 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "STARTING", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07001894
1895 gotoDisconnected(btampContext);
1896 /*Advance outer statevar */
1897 btampfsmChangeToState(instanceVar,DISCONNECTED);
1898 /*Action code for transition */
1899 signalHCIPhysLinkCompEvent( btampContext, WLANBAP_ERROR_HOST_REJ_RESOURCES );
1900 }
1901 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_START_BSS_SUCCESS
1902 ) && (btampContext->BAPDeviceRole == BT_RESPONDER))
1903 {
1904 /*Transition from STARTING to CONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001905 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "STARTING", "CONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001906
1907 /* Set the selected channel */
1908 /*should have been already set */
1909 btampContext->channel = ( 0 == btampContext->channel )?1:btampContext->channel;
1910
1911 /*Advance outer statevar */
1912 btampfsmChangeToState(instanceVar,CONNECTING);
1913 /*Action code for transition */
1914 gotoConnecting(btampContext);
1915
1916 }
1917 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
1918 {
1919 /*Transition from STARTING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001920 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "STARTING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001921
1922 /*Action code for transition */
1923 //csrRoamDisconnect();
1924 sme_RoamDisconnect(hHal,
1925 //JEZ081115: Fixme
1926 btampContext->sessionId,
1927 eCSR_DISCONNECT_REASON_UNSPECIFIED);
1928 gotoDisconnecting(
1929 btampContext,
1930 VOS_TRUE,
1931 WLANBAP_ERROR_HOST_TIMEOUT,
1932 VOS_FALSE,
1933 0);
1934 /*Advance outer statevar */
1935 btampfsmChangeToState(instanceVar,DISCONNECTING);
1936 }
1937 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_START_FAILS))
1938 {
1939 /*Transition from STARTING to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001940 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "STARTING", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07001941
1942 /*Action code for transition */
1943 gotoDisconnected(btampContext);
1944 /*Advance outer statevar */
1945 btampfsmChangeToState(instanceVar,DISCONNECTED);
1946 signalHCIPhysLinkCompEvent( btampContext, WLANBAP_ERROR_MAX_NUM_CNCTS );
1947 }
1948 else
1949 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001950 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "STARTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 /* Intentionally left blank */
1952 }
1953 break;
1954
1955 case CONNECTING:
1956 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_CONNECT_COMPLETED
1957 ) && (btampContext->BAPDeviceRole == BT_RESPONDER))
1958 {
1959 /*Transition from CONNECTING to AUTHENTICATING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001960 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "AUTHENTICATING");
1961 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "CONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07001962
1963 gotoAuthenticating(btampContext);
1964 /*Action code for transition */
1965 initRsnSupplicant(btampContext, BT_RESPONDER);
1966#if 1
1967 /*Advance outer statevar */
1968 btampfsmChangeToState(instanceVar,AUTHENTICATING);
1969#else
1970 /*Action code for transition */
1971 signalHCIPhysLinkCompEvent(btampContext, WLANBAP_STATUS_SUCCESS);
1972 gotoConnected(btampContext);
1973 /*Advance outer statevar */
1974 btampfsmChangeToState(instanceVar,CONNECTED);
1975#endif
1976 /* register our STA with TL */
1977 regStaWithTl (
1978 btampContext, /* btampContext value */
1979 BT_RESPONDER,
1980 (tCsrRoamInfo *)bapEvent->params);
1981
1982 }
1983 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
1984 {
1985 /*Transition from CONNECTING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001986 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07001987
1988 /*Action code for transition */
1989 //csrRoamDisconnect();
1990 sme_RoamDisconnect(hHal,
1991 //JEZ081115: Fixme
1992 btampContext->sessionId,
1993 eCSR_DISCONNECT_REASON_UNSPECIFIED);
1994 gotoDisconnecting(
1995 btampContext,
1996 VOS_TRUE,
1997 WLANBAP_ERROR_NO_CNCT,
1998 //VOS_TRUE, // Should be VOS_FALSE !!!
1999 VOS_FALSE,
2000 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2001 /*Advance outer statevar */
2002 btampfsmChangeToState(instanceVar,DISCONNECTING);
2003 // It is NOT clear that we need to send the Phy Link Disconnect
2004 // Complete Event here.
2005 signalHCIPhysLinkDiscEvent
2006 ( btampContext,
2007 WLANBAP_STATUS_SUCCESS,
2008 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2009 }
2010 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_CONNECT_INDICATION
2011 //) && (bssDesc indicates an invalid peer MAC Addr or SecParam)){
2012 ) && !validAssocInd(btampContext, (tCsrRoamInfo *)bapEvent->params))
2013 {
2014 /*Transition from CONNECTING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002015 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 /*Action code for transition */
2017 //csrRoamDisconnect(DEAUTH);
2018 //JEZ081120: Danlin points out that I could just ignore this
2019 sme_RoamDisconnect(hHal,
2020 //JEZ081115: Fixme
2021 btampContext->sessionId,
2022 eCSR_DISCONNECT_REASON_DEAUTH);
2023 //eCSR_DISCONNECT_REASON_UNSPECIFIED);
2024 gotoDisconnecting(
2025 btampContext,
2026 VOS_TRUE,
2027 WLANBAP_ERROR_AUTHENT_FAILURE,
2028 VOS_FALSE,
2029 0);
2030
2031 /*Set the status code being returned to the btampFsm caller */
2032 *status = WLANBAP_ERROR_AUTHENT_FAILURE;
2033
2034 /*Advance outer statevar */
2035 btampfsmChangeToState(instanceVar,DISCONNECTING);
2036 }
2037 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_CONNECT_INDICATION
2038 //) && (bssDesc indicates a valid MAC Addr and SecParam)){
2039 ) && validAssocInd(btampContext, (tCsrRoamInfo *)bapEvent->params))
2040 {
2041 /*Transition from CONNECTING to VALIDATED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002042 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "VALIDATED");
2043 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "AUTHENTICATING");
2044 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "CONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
2046 /*Action code for transition */
2047 // JEZ081027: This one is a pain. Since we are responding in the
2048 // callback itself. This messes up my state machine.
2049 //csrRoamAccept();
2050
2051 // No! This is fine.
2052 /*Set the status code being returned to the btampFsm caller */
2053 *status = WLANBAP_STATUS_SUCCESS;
2054
2055 /* JEZ081215: N.B.: Currently, I don't get the
2056 * eCSR_ROAM_RESULT_WDS_ASSOCIATED as an AP.
2057 * So, I have to register with TL, here. This
2058 * seems weird.
2059 */
2060
2061 /* register our STA with TL */
2062 regStaWithTl (
2063 btampContext, /* btampContext value */
2064 BT_INITIATOR,
2065 (tCsrRoamInfo *)bapEvent->params );
2066
2067 gotoAuthenticating(btampContext);
2068 /*Action code for transition */
2069 initRsnAuthenticator(btampContext, BT_INITIATOR);
2070
2071#if 1
2072 /*Advance outer statevar */
2073 //btampfsmChangeToState(instanceVar,VALIDATED);
2074 btampfsmChangeToState(instanceVar,AUTHENTICATING);
2075#else
2076 /*Action code for transition */
2077 signalHCIPhysLinkCompEvent(btampContext, WLANBAP_STATUS_SUCCESS);
2078 gotoConnected(btampContext);
2079 /*Advance outer statevar */
2080 btampfsmChangeToState(instanceVar,CONNECTED);
2081#endif
2082 }
2083 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_CONNECT_FAILED))
2084 {
2085 /*Transition from CONNECTING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002086 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002087
2088 /*Action code for transition */
2089 sme_RoamDisconnect(hHal,
2090 btampContext->sessionId,
2091 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2092 /* Section 3.1.8 and section 3.1.9 have contradictory semantics for 0x16.
2093 * 3.1.8 is "connection terminated by local host". 3.1.9 is "failed connection".
2094 */
2095 //gotoDisconnecting(FAILED_CONNECTION);
2096 gotoDisconnecting(
2097 btampContext,
2098 VOS_TRUE,
2099 WLANBAP_ERROR_TERM_BY_LOCAL_HOST, //FAILED_CONNECTION
2100 VOS_FALSE,
2101 0);
2102 /*Advance outer statevar */
2103 btampfsmChangeToState(instanceVar,DISCONNECTING);
2104 }
2105 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
2106 {
2107 /*Transition from CONNECTING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002108 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002109
2110 /*Action code for transition */
2111 //csrRoamDisconnect();
2112 sme_RoamDisconnect(hHal,
2113 //JEZ081115: Fixme
2114 btampContext->sessionId,
2115 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2116 gotoDisconnecting(
2117 btampContext,
2118 VOS_TRUE,
2119 WLANBAP_ERROR_HOST_TIMEOUT,
2120 VOS_FALSE,
2121 0);
2122 /*Advance outer statevar */
2123 btampfsmChangeToState(instanceVar,DISCONNECTING);
2124 }
2125 else
2126 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002127 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "CONNECTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 /* Intentionally left blank */
2129 }
2130 break;
2131
2132 case AUTHENTICATING:
2133 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_RSN_SUCCESS
2134 ) && (btampContext->BAPDeviceRole == BT_RESPONDER))
2135 {
2136 /*Transition from AUTHENTICATING to KEYING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002137 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "AUTHENTICATING", "KEYING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002138
2139 /*Action code for transition */
2140 //sme_RoamSetContext();
2141#if 0
2142 sme_RoamSetKey(
2143 VOS_GET_HAL_CB(btampContext->pvosGCtx),
2144 btampContext->sessionId,
2145 tSirMacAddr peerBssId,
2146 eCsrEncryptionType encryptType,
2147 tANI_U16 keyLength,
2148 tANI_U8 *pKey,
2149 VOS_TRUE, // TRUE
2150 tANI_U8 paeRole);
2151#endif //0
2152 /*Advance outer statevar */
2153 btampfsmChangeToState(instanceVar,KEYING);
2154 }
2155 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_RSN_SUCCESS
2156 ) && (btampContext->BAPDeviceRole == BT_INITIATOR))
2157 {
2158 /*Transition from AUTHENTICATING to KEYING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002159 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "AUTHENTICATING", "KEYING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161 /*Action code for transition */
2162 //sme_RoamSetContext();
2163#if 0
2164 sme_RoamSetKey(
2165 VOS_GET_HAL_CB(btampContext->pvosGCtx),
2166 btampContext->sessionId,
2167 tSirMacAddr peerBssId,
2168 eCsrEncryptionType encryptType,
2169 tANI_U16 keyLength,
2170 tANI_U8 *pKey,
2171 VOS_TRUE, // TRUE
2172 tANI_U8 paeRole);
2173#endif //0
2174 /*Advance outer statevar */
2175 btampfsmChangeToState(instanceVar,KEYING);
2176 }
2177 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
2178 {
2179 /*Transition from AUTHENTICATING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002180 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s ConnectAcceptTimeout", __func__, "AUTHENTICATING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 gotoDisconnecting(
2183 btampContext,
2184 VOS_TRUE,
2185 WLANBAP_ERROR_HOST_TIMEOUT,
2186 VOS_FALSE,
2187 0);
2188 /*Advance outer statevar */
2189 btampfsmChangeToState(instanceVar,DISCONNECTING);
2190 /*Action code for transition */
2191 sme_RoamDisconnect(hHal,
2192 //JEZ081115: Fixme
2193 btampContext->sessionId,
2194 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2195
2196 }
2197 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
2198 {
2199 /*Transition from AUTHENTICATING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002200 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s Physicallink Disconnect", __func__, "AUTHENTICATING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002201
2202 /*Action code for transition */
2203 //csrRoamDisconnect();
2204 sme_RoamDisconnect(hHal,
2205 //JEZ081115: Fixme
2206 btampContext->sessionId,
2207 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2208 gotoDisconnecting(
2209 btampContext,
2210 VOS_TRUE,
2211 WLANBAP_ERROR_NO_CNCT,
2212 //VOS_TRUE, // Should be VOS_FALSE !!!
2213 VOS_FALSE,
2214 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2215 /*Advance outer statevar */
2216 btampfsmChangeToState(instanceVar,DISCONNECTING);
2217 // It is NOT clear that we need to send the Phy Link Disconnect
2218 // Complete Event here.
2219 signalHCIPhysLinkDiscEvent
2220 ( btampContext,
2221 WLANBAP_STATUS_SUCCESS,
2222 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2223 }
2224 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_RSN_FAILURE))
2225 {
2226 /*Transition from AUTHENTICATING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002227 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s RSN Failure", __func__, "AUTHENTICATING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002228
2229 /*Action code for transition */
2230 //csrRoamDisconnect(DEAUTH);
2231 sme_RoamDisconnect(hHal,
2232 //JEZ081115: Fixme
2233 btampContext->sessionId,
2234 eCSR_DISCONNECT_REASON_DEAUTH);
2235 //eCSR_DISCONNECT_REASON_UNSPECIFIED);
2236 gotoDisconnecting(
2237 btampContext,
2238 VOS_TRUE,
2239 WLANBAP_ERROR_AUTHENT_FAILURE,
2240 VOS_FALSE,
2241 0);
2242 /*Advance outer statevar */
2243 btampfsmChangeToState(instanceVar,DISCONNECTING);
2244 }
2245 else
2246 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002247 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "AUTHENTICATING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 /* Intentionally left blank */
2249 }
2250 break;
2251
2252 case CONNECTED:
2253 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
2254 {
2255 /*Transition from CONNECTED to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002256 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTED", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
2258 gotoDisconnecting(
2259 btampContext,
2260 VOS_FALSE,
2261 0,
2262 VOS_TRUE,
2263 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2264 /*Advance outer statevar */
2265 btampfsmChangeToState(instanceVar,DISCONNECTING);
2266
2267 WLANBAP_DeInitLinkSupervision(( ptBtampHandle)btampContext);
2268 /*Action code for transition */
2269 //csrRoamDisconnect();
2270 sme_RoamDisconnect(hHal,
2271 //JEZ081115: Fixme
2272 btampContext->sessionId,
2273 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2274 }
2275 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION))
2276 {
2277
2278 /*Transition from CONNECTED to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002279 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "CONNECTED", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 WLANBAP_DeInitLinkSupervision(( ptBtampHandle)btampContext);
2281
2282 gotoDisconnecting(
2283 btampContext,
2284 VOS_FALSE,
2285 0,
2286 VOS_TRUE,
2287 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2288 /*Action code for transition */
2289 sme_RoamDisconnect(hHal,
2290 btampContext->sessionId,
2291 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2292 /*Advance outer statevar */
2293 btampfsmChangeToState(instanceVar,DISCONNECTING);
2294 }
2295 else
2296 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002297 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "CONNECTED", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 /* Intentionally left blank */
2299 }
2300 break;
2301
2302/* JEZ081107: This will only work if I have already signalled the disconnect complete
2303 * event in every case where a physical link complete event is required. And a
2304 * disconnect was requested.
2305 * - - -
2306 * And only if I check for gNeedPhysLinkCompEvent BEFORE I check gDiscRequested.
2307 * Naw! Not necessary.
2308 */
2309 case DISCONNECTING:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002310 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Entered DISCONNECTING:", __func__);//Debug statement
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_READY_FOR_CONNECTIONS
2312 ) && (btampContext->gDiscRequested == VOS_TRUE))
2313 {
2314 /*Transition from DISCONNECTING to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002315 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "DISCONNECTING", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07002316
2317 //Clear gDiscRequested;
2318 btampContext->gDiscRequested = VOS_FALSE;
2319
2320 if(btampContext->BAPDeviceRole == BT_INITIATOR)
2321 {
2322 if(!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&btampContext->bapLock)))
2323 {
2324 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"btampFsm, Get LOCK Fail");
2325 }
2326 authRsnFsmFree(btampContext);
2327 if(!VOS_IS_STATUS_SUCCESS(vos_lock_release(&btampContext->bapLock)))
2328 {
2329 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"btampFsm, Release LOCK Fail");
2330 }
2331 }
2332 else if(btampContext->BAPDeviceRole == BT_RESPONDER)
2333 {
2334 suppRsnFsmFree(btampContext);
2335 }
2336
2337 /* Lookup the StaId using the phy_link_handle and the BAP context */
2338 vosStatus = WLANBAP_GetStaIdFromLinkCtx (
2339 btampHandle, /* btampHandle value in */
2340 btampContext->phy_link_handle, /* phy_link_handle value in */
2341 &ucSTAId, /* The StaId (used by TL, PE, and HAL) */
2342 &pHddHdl); /* Handle to return BSL context */
2343 if ( VOS_STATUS_SUCCESS != vosStatus )
2344 {
2345 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002346 "Unable to retrieve STA Id from BAP context and phy_link_handle in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 return VOS_STATUS_E_FAULT;
2348 }
2349 WLANTL_ClearSTAClient(btampContext->pvosGCtx, ucSTAId);
2350
2351 // gotoDisconnected(btampContext);
2352
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002353 // VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s:In DISCONNECTING-changing outer state var to DISCONNECTED", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 /*Advance outer statevar */
2355 // btampfsmChangeToState(instanceVar,DISCONNECTED);
2356
2357 signalHCIPhysLinkDiscEvent
2358 ( btampContext,
2359 WLANBAP_STATUS_SUCCESS,
2360 btampContext->gDiscReason);
2361 /*sme_CloseSession(VOS_GET_HAL_CB(btampContext->pvosGCtx),
2362 btampContext->sessionId);*/
2363 /*Action code for transition */
2364 gotoDisconnected(btampContext);
2365
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002366 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s:In DISCONNECTING-changing outer state var to DISCONNECTED", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 /*Advance outer statevar */
2368 btampfsmChangeToState(instanceVar,DISCONNECTED);
2369 }
2370 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_READY_FOR_CONNECTIONS
2371 ) && (btampContext->gNeedPhysLinkCompEvent == VOS_TRUE))
2372 {
2373 /*Transition from DISCONNECTING to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002374 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s gNeedPhysLinkComp TRUE", __func__, "DISCONNECTING", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 if(btampContext->BAPDeviceRole == BT_INITIATOR)
2376 {
2377 if(!VOS_IS_STATUS_SUCCESS(vos_lock_acquire(&btampContext->bapLock)))
2378 {
2379 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"btampFsm, Get LOCK Fail");
2380 }
2381 authRsnFsmFree(btampContext);
2382 if(!VOS_IS_STATUS_SUCCESS(vos_lock_release(&btampContext->bapLock)))
2383 {
2384 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"btampFsm, Release LOCK Fail");
2385 }
2386
2387 }
2388 else if(btampContext->BAPDeviceRole == BT_RESPONDER)
2389 {
2390 suppRsnFsmFree(btampContext);
2391 }
2392 /* Lookup the StaId using the phy_link_handle and the BAP context */
2393 vosStatus = WLANBAP_GetStaIdFromLinkCtx (
2394 btampHandle, /* btampHandle value in */
2395 btampContext->phy_link_handle, /* phy_link_handle value in */
2396 &ucSTAId, /* The StaId (used by TL, PE, and HAL) */
2397 &pHddHdl); /* Handle to return BSL context */
2398 if ( VOS_STATUS_SUCCESS != vosStatus )
2399 {
2400 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002401 "Unable to retrieve STA Id from BAP context and phy_link_handle in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 return VOS_STATUS_E_FAULT;
2403 }
2404 WLANTL_ClearSTAClient(btampContext->pvosGCtx, ucSTAId);
2405
2406
2407 /*Action code for transition */
2408 // signalHCIPhysLinkCompEvent(btampContext, WLANBAP_ERROR_NO_CNCT/*btampContext->gPhysLinkStatus*/);
2409 signalHCIPhysLinkCompEvent(btampContext, btampContext->gPhysLinkStatus);
2410 gotoDisconnected(btampContext);
2411 /*sme_CloseSession(VOS_GET_HAL_CB(btampContext->pvosGCtx),
2412 btampContext->sessionId);*/
2413 /*Advance outer statevar */
2414 btampfsmChangeToState(instanceVar,DISCONNECTED);
2415 // signalHCIPhysLinkCompEvent(btampContext, btampContext->gPhysLinkStatus);
2416 }
2417 else
2418 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002419 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "DISCONNECTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 /* Intentionally left blank */
2421 }
2422 break;
2423
2424 case KEYING:
2425 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
2426 {
2427 /*Transition from KEYING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002428 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "KEYING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002429
2430 /*Action code for transition */
2431 //csrRoamDisconnect();
2432 sme_RoamDisconnect(hHal,
2433 //JEZ081115: Fixme
2434 btampContext->sessionId,
2435 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2436 gotoDisconnecting(
2437 btampContext,
2438 VOS_TRUE,
2439 WLANBAP_ERROR_HOST_TIMEOUT,
2440 VOS_FALSE,
2441 0);
2442 /*Advance outer statevar */
2443 btampfsmChangeToState(instanceVar,DISCONNECTING);
2444 }
2445 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
2446 {
2447 /*Transition from KEYING to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002448 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "KEYING", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002449
2450 /*Action code for transition */
2451 //csrRoamDisconnect();
2452 sme_RoamDisconnect(hHal,
2453 //JEZ081115: Fixme
2454 btampContext->sessionId,
2455 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2456
2457 gotoDisconnecting(
2458 btampContext,
2459 VOS_TRUE,
2460 WLANBAP_ERROR_NO_CNCT,
2461 //VOS_TRUE, // Should be VOS_FALSE !!!
2462 VOS_FALSE,
2463 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2464 /*Advance outer statevar */
2465 btampfsmChangeToState(instanceVar,DISCONNECTING);
2466
2467 // It is NOT clear that we need to send the Phy Link Disconnect
2468 // Complete Event here.
2469 signalHCIPhysLinkDiscEvent
2470 ( btampContext,
2471 WLANBAP_STATUS_SUCCESS,
2472 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2473 }
2474 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_KEY_SET_SUCCESS))
2475 {
2476 /*Transition from KEYING to CONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002477 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "KEYING", "CONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07002478
2479 /*Action code for transition */
2480 gotoConnected(btampContext);
2481 /*Advance outer statevar */
2482 btampfsmChangeToState(instanceVar,CONNECTED);
2483 signalHCIPhysLinkCompEvent(btampContext, WLANBAP_STATUS_SUCCESS);
2484 }
2485 else
2486 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002487 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "KEYING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 /* Intentionally left blank */
2489 }
2490 break;
2491
2492 case SCANNING:
2493 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_SCAN_COMPLETE))
2494 {
2495 /*Transition from SCANNING to STARTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002496 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "SCANNING", "STARTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002497
2498 /*Action code for transition */
2499 vosStatus = determineChan(btampContext, BT_INITIATOR, &channel, status);
2500 // This has to be commented out until I get the BT-AMP SME/CSR changes
2501 /*Advance outer statevar */
2502 btampfsmChangeToState(instanceVar,STARTING);
2503 vosStatus = gotoStarting( btampContext, bapEvent, eCSR_BSS_TYPE_WDS_AP, status);
2504 if (VOS_STATUS_SUCCESS != vosStatus)
2505 {
2506 btampfsmChangeToState(instanceVar, SCANNING);
2507 }
2508 }
2509 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
2510 {
2511 /*Transition from SCANNING to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002512 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "SCANNING", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07002513
2514 /*Action code for transition */
2515 gotoDisconnected(btampContext);
2516 /*Advance outer statevar */
2517 btampfsmChangeToState(instanceVar,DISCONNECTED);
2518
2519 signalHCIPhysLinkCompEvent( btampContext, WLANBAP_ERROR_HOST_TIMEOUT);
2520 }
2521 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
2522 {
2523 /*Transition from SCANNING to DISCONNECTED (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002524 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "SCANNING", "DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -07002525
2526 /*Action code for transition */
2527 gotoDisconnected(btampContext);
2528 /*Advance outer statevar */
2529 btampfsmChangeToState(instanceVar,DISCONNECTED);
2530 signalHCIPhysLinkDiscEvent
2531 ( btampContext,
2532 WLANBAP_STATUS_SUCCESS,
2533 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2534 signalHCIPhysLinkCompEvent( btampContext, WLANBAP_ERROR_NO_CNCT);
2535 }
2536 else
2537 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002538 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "SCANNING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 /* Intentionally left blank */
2540 }
2541 break;
2542
2543 case VALIDATED:
2544 if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_MAC_CONNECT_COMPLETED
2545 ) && (btampContext->BAPDeviceRole == BT_INITIATOR))
2546 {
2547 /*Transition from VALIDATED to AUTHENTICATING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002548 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "VALIDATED", "AUTHENTICATING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002549
2550 gotoAuthenticating(btampContext);
2551 /*Action code for transition */
2552 initRsnAuthenticator(btampContext, BT_INITIATOR);
2553 /*Advance outer statevar */
2554 btampfsmChangeToState(instanceVar,AUTHENTICATING);
2555 }
2556 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT))
2557 {
2558 /*Transition from VALIDATED to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002559 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "VALIDATED", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002560
2561 /*Action code for transition */
2562 //csrRoamDisconnect();
2563 sme_RoamDisconnect(hHal,
2564 //JEZ081115: Fixme
2565 btampContext->sessionId,
2566 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2567 gotoDisconnecting(
2568 btampContext,
2569 VOS_TRUE,
2570 WLANBAP_ERROR_HOST_TIMEOUT,
2571 VOS_FALSE,
2572 0);
2573 /*Advance outer statevar */
2574 btampfsmChangeToState(instanceVar,DISCONNECTING);
2575 }
2576 else if((msg==(BTAMPFSM_EVENT_T)eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT))
2577 {
2578 /*Transition from VALIDATED to DISCONNECTING (both without substates)*/
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002579 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s", __func__, "VALIDATED", "DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -07002580
2581 /*Action code for transition */
2582 //csrRoamDisconnect();
2583 sme_RoamDisconnect(hHal,
2584 //JEZ081115: Fixme
2585 btampContext->sessionId,
2586 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2587
2588 gotoDisconnecting(
2589 btampContext,
2590 VOS_TRUE,
2591 WLANBAP_ERROR_NO_CNCT,
2592 //VOS_TRUE, // Should be VOS_FALSE !!!
2593 VOS_FALSE,
2594 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2595 /*Advance outer statevar */
2596 btampfsmChangeToState(instanceVar,DISCONNECTING);
2597
2598 // It is NOT clear that we need to send the Phy Link Disconnect
2599 // Complete Event here.
2600 signalHCIPhysLinkDiscEvent
2601 ( btampContext,
2602 WLANBAP_STATUS_SUCCESS,
2603 WLANBAP_ERROR_TERM_BY_LOCAL_HOST);
2604 }
2605 else
2606 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002607 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, in state %s, invalid event msg %d", __func__, "VALIDATED", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 /* Intentionally left blank */
2609 }
2610 break;
2611
2612 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002613 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, invalid state %d", __func__, instanceVar->stateVar);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 /*Intentionally left blank*/
2615 break;
2616 }
2617
2618 return vosStatus;
2619}
2620
2621VOS_STATUS btampEstablishLogLink(ptBtampContext btampContext)
2622{
2623 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2624 vos_msg_t msg;
2625
2626 tAniBtAmpLogLinkReq *pMsg;
2627
2628 pMsg = vos_mem_malloc(sizeof(tAniBtAmpLogLinkReq));
2629 if ( NULL == pMsg )
2630 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002631 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "In %s, failed to allocate mem for req", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 return VOS_STATUS_E_NOMEM;
2633 }
2634
2635 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_BTAMP_LOG_LINK_IND);
2636 pMsg->msgLen = (tANI_U16)sizeof(tAniBtAmpLogLinkReq);
2637 pMsg->sessionId = btampContext->sessionId;
2638 pMsg->btampHandle = btampContext;
2639
2640 msg.type = eWNI_SME_BTAMP_LOG_LINK_IND;
2641 msg.bodyptr = pMsg;
2642 msg.reserved = 0;
2643
2644 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
2645 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002646 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "In %s, failed to post msg to self", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 vos_mem_free(pMsg);
2648 vosStatus = VOS_STATUS_E_FAILURE;
2649 }
2650 return vosStatus;
2651}
2652
2653void btampEstablishLogLinkHdlr(void* pMsg)
2654{
2655 tAniBtAmpLogLinkReq *pBtAmpLogLinkReq = (tAniBtAmpLogLinkReq*)pMsg;
2656 ptBtampContext btampContext;
2657
2658 if(pBtAmpLogLinkReq)
2659 {
2660 btampContext = (ptBtampContext)pBtAmpLogLinkReq->btampHandle;
2661 if(NULL != btampContext)
2662 {
2663 vos_sleep( 200 );
2664 WLAN_BAPEstablishLogicalLink(btampContext);
2665 }
2666 else
2667 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002668 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "In %s, btampContext is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 return;
2670 }
2671
2672 }
2673 else
2674 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002675 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "In %s, pBtAmpLogLinkReq is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 }
2677 return;
2678}
2679