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