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