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