blob: 1e78de64ff3742e3bb66ae18b6a3bd650c268ee3 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*===========================================================================
23
24 b a p M o d u l e . C
25
26 OVERVIEW:
27
28 This software unit holds the implementation of the WLAN BAP modules
29 Module support functions. It is also where the global BAP module
30 context, and per-instance (returned in BAP_Open device open) contexts.
31
32 The functions externalized by this module are to be called by the device
33 specific BAP Shim Layer (BSL) (in HDD) which implements a stream device on a
34 particular platform.
35
36 DEPENDENCIES:
37
38 Are listed for each API below.
39
40
41 Copyright (c) 2008 QUALCOMM Incorporated.
42 All Rights Reserved.
43 Qualcomm Confidential and Proprietary
44===========================================================================*/
45
46/*===========================================================================
47
48 EDIT HISTORY FOR FILE
49
50
51 This section contains comments describing changes made to the module.
52 Notice that changes are listed in reverse chronological order.
53
54
55 $Header: /home/labuser/ampBlueZ_2/CORE/BAP/src/bapModule.c,v 1.1 2010/07/12 19:05:35 labuser Exp labuser $$DateTime$$Author: labuser $
56
57
58 when who what, where, why
59---------- --- --------------------------------------------------------
602008-09-15 jez Created module
61
62===========================================================================*/
63
64/*----------------------------------------------------------------------------
65 * Include Files
66 * -------------------------------------------------------------------------*/
67// Pull in some message types used by BTC
68#include "sirParams.h"
69//#include "halFwApi.h"
70
71#include "wlan_qct_tl.h"
72#include "vos_trace.h"
73// Pick up the sme callback registration API
74#include "sme_Api.h"
75#include "ccmApi.h"
76
77/* BT-AMP PAL API header file */
78#include "bapApi.h"
79#include "bapInternal.h"
80
81// Pick up the BTAMP RSN definitions
82#include "bapRsnTxRx.h"
83//#include "assert.h"
84#include "bapApiTimer.h"
85
86#if defined(ANI_OS_TYPE_LINUX) || defined(ANI_OS_TYPE_ANDROID)
87#include "bap_hdd_main.h"
88#endif
89
90//#define BAP_DEBUG
91/*----------------------------------------------------------------------------
92 * Preprocessor Definitions and Constants
93 * -------------------------------------------------------------------------*/
94//#define VOS_GET_BAP_CB(ctx) vos_get_context( VOS_MODULE_ID_BAP, ctx)
95
96
97/*----------------------------------------------------------------------------
98 * Type Declarations
99 * -------------------------------------------------------------------------*/
100
101/*----------------------------------------------------------------------------
102 * Global Data Definitions
103 * -------------------------------------------------------------------------*/
104// include the phy link state machine structure here
105static tWLAN_BAPbapPhysLinkMachine bapPhysLinkMachineInitial
106 = BTAMPFSM_INSTANCEDATA_INIT;
107
108/*----------------------------------------------------------------------------
109 * External declarations for global context
110 * -------------------------------------------------------------------------*/
111// No! Get this from VOS.
112// The main per-Physical Link (per WLAN association) context.
113//tBtampContext btampCtx;
114ptBtampContext gpBtampCtx = NULL;
115
116// Include the Local AMP Info structure.
117tBtampHCI_AMP_Info btampHCI_AMP_Info;
118// Include the Local Data Block Size info structure.
119tBtampHCI_Data_Block_Size btampHCI_Data_Block_Size;
120// Include the Local Version info structure.
121tBtampHCI_Version_Info btampHCI_Version_Info;
122// Include the Local Supported Cmds info structure.
123tBtampHCI_Supported_Cmds btampHCI_Supported_Cmds;
124
125static unsigned char pBtStaOwnMacAddr[WNI_CFG_BSSID_LEN];
126
127 /*BT-AMP SSID; per spec should have this format: "AMP-00-0a-f5-04-05-08" */
128#define WLAN_BAP_SSID_MAX_LEN 21
129static char pBtStaOwnSsid[WLAN_BAP_SSID_MAX_LEN];
130
131/*----------------------------------------------------------------------------
132 * Static Variable Definitions
133 * -------------------------------------------------------------------------*/
134
135/*----------------------------------------------------------------------------
136 * Static Function Declarations and Definitions
137 * -------------------------------------------------------------------------*/
138
139/*----------------------------------------------------------------------------
140 * Externalized Function Definitions
141* -------------------------------------------------------------------------*/
142
143/*----------------------------------------------------------------------------
144 * Function Declarations and Documentation
145 * -------------------------------------------------------------------------*/
146
147/*==========================================================================
148
149 FUNCTION WLANBAP_Open
150
151 DESCRIPTION
152 Called at driver initialization (vos_open). BAP will initialize
153 all its internal resources and will wait for the call to start to
154 register with the other modules.
155
156 DEPENDENCIES
157
158 PARAMETERS
159
160 IN
161 pvosGCtx: pointer to the global vos context; a handle to BAP's
162 control block can be extracted from its context
163
164 RETURN VALUE
165 The result code associated with performing the operation
166
167 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
168 fault
169 VOS_STATUS_SUCCESS: Everything is good :)
170
171 SIDE EFFECTS
172
173============================================================================*/
174VOS_STATUS
175WLANBAP_Open
176(
177 v_PVOID_t pvosGCtx
178)
179{
180 ptBtampContext pBtampCtx = NULL;
181 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
182
183 /*------------------------------------------------------------------------
184 Allocate (and sanity check?!) BAP control block
185 ------------------------------------------------------------------------*/
186 vos_alloc_context(pvosGCtx, VOS_MODULE_ID_BAP, (v_VOID_t**)&pBtampCtx, sizeof(tBtampContext));
187
188 pBtampCtx = VOS_GET_BAP_CB(pvosGCtx);
189 if ( NULL == pBtampCtx )
190 {
191 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
192 "Invalid BAP pointer from pvosGCtx on WLANBAP_Open");
193 //"Failed to allocate BAP pointer from pvosGCtx on WLANBAP_Open");
194 return VOS_STATUS_E_FAULT;
195 }
196
197 /*------------------------------------------------------------------------
198 Clean up BAP control block, initialize all values
199 ------------------------------------------------------------------------*/
200 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Open");
201
202 WLANBAP_CleanCB(pBtampCtx, 0 /*do not empty*/);
203
204 // Setup the "link back" to the VOSS context
205 pBtampCtx->pvosGCtx = pvosGCtx;
206
207 // Store a pointer to the BAP context provided by VOSS
208 gpBtampCtx = pBtampCtx;
209
210 /*------------------------------------------------------------------------
211 Allocate internal resources
212 ------------------------------------------------------------------------*/
213
214 return VOS_STATUS_SUCCESS;
215}/* WLANBAP_Open */
216
217
218/*==========================================================================
219
220 FUNCTION WLANBAP_Start
221
222 DESCRIPTION
223 Called as part of the overall start procedure (vos_start). BAP will
224 use this call to register with TL as the BAP entity for
225 BT-AMP RSN frames.
226
227 DEPENDENCIES
228
229 PARAMETERS
230
231 IN
232 pvosGCtx: pointer to the global vos context; a handle to BAP's
233 control block can be extracted from its context
234
235 RETURN VALUE
236 The result code associated with performing the operation
237
238 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
239 fault
240 VOS_STATUS_SUCCESS: Everything is good :)
241
242 Other codes can be returned as a result of a BAL failure;
243
244 SIDE EFFECTS
245
246============================================================================*/
247VOS_STATUS
248WLANBAP_Start
249(
250 v_PVOID_t pvosGCtx
251)
252{
253 ptBtampContext pBtampCtx = NULL;
254 VOS_STATUS vosStatus;
255 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
256
257 /*------------------------------------------------------------------------
258 Sanity check
259 Extract BAP control block
260 ------------------------------------------------------------------------*/
261 pBtampCtx = VOS_GET_BAP_CB(pvosGCtx);
262 if ( NULL == pBtampCtx )
263 {
264 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
265 "Invalid BAP pointer from pvosGCtx on WLANBAP_Start");
266 return VOS_STATUS_E_FAULT;
267 }
268
269 /*------------------------------------------------------------------------
270 Register with TL as an BT-AMP RSN client
271 ------------------------------------------------------------------------*/
272 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Start TL register");
273
274 /*------------------------------------------------------------------------
275 Register with CSR for Roam (connection status) Events
276 ------------------------------------------------------------------------*/
277 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Start CSR Register");
278
279
280 /* Initialize the BAP Tx packet monitor timer */
281 WLANBAP_InitConnectionAcceptTimer (pBtampCtx );
282 WLANBAP_InitLinkSupervisionTimer(pBtampCtx);
283
284 vosStatus = vos_timer_init(
285 &pBtampCtx->bapTxPktMonitorTimer,
286 VOS_TIMER_TYPE_SW, /* use this type */
287 WLANBAP_TxPacketMonitorHandler,
288 pBtampCtx);
289
290 vosStatus = vos_lock_init(&pBtampCtx->bapLock);
291 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
292 {
293 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"Lock Init Fail");
294 }
295
296 return vosStatus;
297}/* WLANBAP_Start */
298
299/*==========================================================================
300
301 FUNCTION WLANBAP_Stop
302
303 DESCRIPTION
304 Called by vos_stop to stop operation in BAP, before close. BAP will suspend all
305 BT-AMP Protocol Adaption Layer operation and will wait for the close
306 request to clean up its resources.
307
308 DEPENDENCIES
309
310 PARAMETERS
311
312 IN
313 pvosGCtx: pointer to the global vos context; a handle to BAP's
314 control block can be extracted from its context
315
316 RETURN VALUE
317 The result code associated with performing the operation
318
319 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
320 fault
321 VOS_STATUS_SUCCESS: Everything is good :)
322
323 SIDE EFFECTS
324
325============================================================================*/
326VOS_STATUS
327WLANBAP_Stop
328(
329 v_PVOID_t pvosGCtx
330)
331{
332 ptBtampContext pBtampCtx = NULL;
333 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
334 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
335
336 /*------------------------------------------------------------------------
337 Sanity check
338 Extract BAP control block
339 ------------------------------------------------------------------------*/
340 pBtampCtx = VOS_GET_BAP_CB(pvosGCtx);
341 if ( NULL == pBtampCtx )
342 {
343 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
344 "Invalid BAP pointer from pvosGCtx on WLANBAP_Stop");
345 return VOS_STATUS_E_FAULT;
346 }
347
348 /*------------------------------------------------------------------------
349 Stop BAP (de-register RSN handler!?)
350 ------------------------------------------------------------------------*/
351 vosStatus = WLANBAP_DeinitConnectionAcceptTimer(pBtampCtx);
352 if ( VOS_STATUS_SUCCESS != vosStatus)
353 {
354 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
355 "Couldn't destroy bapConnectionAcceptTimer");
356 }
357
358 vosStatus = WLANBAP_DeinitLinkSupervisionTimer(pBtampCtx);
359 if ( VOS_STATUS_SUCCESS != vosStatus)
360 {
361 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
362 "Couldn't destroy bapLinkSupervisionTimer");
363 }
364
365 vosStatus = vos_timer_destroy (
366 &pBtampCtx->bapTxPktMonitorTimer );
367 if ( VOS_STATUS_SUCCESS != vosStatus)
368 {
369 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
370 "Couldn't destroy bapTxPktMonitorTimer");
371 }
372 vos_lock_destroy(&pBtampCtx->bapLock);
373 return VOS_STATUS_SUCCESS;
374}/* WLANBAP_Stop */
375
376/*==========================================================================
377
378 FUNCTION WLANBAP_Close
379
380 DESCRIPTION
381 Called by vos_close during general driver close procedure. BAP will clean up
382 all the internal resources.
383
384 DEPENDENCIES
385
386 PARAMETERS
387
388 IN
389 pvosGCtx: pointer to the global vos context; a handle to BAP's
390 control block can be extracted from its context
391
392 RETURN VALUE
393 The result code associated with performing the operation
394
395 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
396 fault
397 VOS_STATUS_SUCCESS: Everything is good :)
398
399 SIDE EFFECTS
400
401============================================================================*/
402VOS_STATUS
403WLANBAP_Close
404(
405 v_PVOID_t pvosGCtx
406)
407{
408 ptBtampContext pBtampCtx = NULL;
409 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
410
411 /*------------------------------------------------------------------------
412 Sanity check
413 Extract BAP control block
414 ------------------------------------------------------------------------*/
415 pBtampCtx = VOS_GET_BAP_CB(pvosGCtx);
416 if ( NULL == pBtampCtx )
417 {
418 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
419 "Invalid BAP pointer from pvosGCtx on WLANBAP_Close");
420 return VOS_STATUS_E_FAULT;
421 }
422
423 /*------------------------------------------------------------------------
424 Cleanup BAP control block.
425 ------------------------------------------------------------------------*/
426 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_Close");
427 WLANBAP_CleanCB(pBtampCtx, 1 /* empty queues/lists/pkts if any*/);
428#if (defined(ANI_OS_TYPE_LINUX) || defined(ANI_OS_TYPE_ANDROID))&& defined(WLAN_BTAMP_FEATURE)
429 BSL_Deinit(pvosGCtx);
430#endif
431 /*------------------------------------------------------------------------
432 Free BAP context from VOSS global
433 ------------------------------------------------------------------------*/
434 vos_free_context(pvosGCtx, VOS_MODULE_ID_BAP, pBtampCtx);
435 return VOS_STATUS_SUCCESS;
436}/* WLANBAP_Close */
437
438/*----------------------------------------------------------------------------
439 HDD interfaces - Per instance initialization
440 ---------------------------------------------------------------------------*/
441
442/*==========================================================================
443
444 FUNCTION WLANBAP_GetNewHndl
445
446 DESCRIPTION
447 Called by HDD at driver open (BSL_Open). BAP will initialize
448 allocate a per-instance "file handle" equivalent for this specific
449 open call.
450
451 There should only ever be one call to BSL_Open. Since
452 the open app user is the BT stack.
453
454
455 DEPENDENCIES
456
457 PARAMETERS
458
459 IN
460 hBtampHandle: Handle to return btampHandle value in.
461
462 RETURN VALUE
463 The result code associated with performing the operation
464
465 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
466 fault
467 VOS_STATUS_SUCCESS: Everything is good :)
468
469 SIDE EFFECTS
470
471============================================================================*/
472
473VOS_STATUS
474WLANBAP_GetNewHndl
475(
476 ptBtampHandle *hBtampHandle /* Handle to return btampHandle value in */
477)
478{
479 ptBtampContext btampContext = NULL;
480 /*------------------------------------------------------------------------
481 Sanity check params
482 ------------------------------------------------------------------------*/
483 if ( NULL == hBtampHandle)
484 {
485 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
486 "Invalid BAP handle pointer in WLANBAP_GetNewHndl");
487 return VOS_STATUS_E_FAULT;
488 }
489
490#ifndef BTAMP_MULTIPLE_PHY_LINKS
491 /*------------------------------------------------------------------------
492 Sanity check the BAP control block pointer
493 ------------------------------------------------------------------------*/
494 if ( NULL == gpBtampCtx )
495 {
496 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
497 "Invalid BAP pointer in WLANBAP_GetNewHndl");
498 return VOS_STATUS_E_FAULT;
499 }
500
501 //*hBtampHandle = (ptBtampHandle) &btampCtx;
502 /* return a pointer to the tBtampContext structure - allocated by VOS for us */
503 *hBtampHandle = (ptBtampHandle) gpBtampCtx;
504 btampContext = gpBtampCtx;
505
506 /* Update the MAC address and SSID if in case the Read Local AMP Assoc
507 * Request is made before Create Physical Link creation.
508 */
509 WLANBAP_ReadMacConfig (btampContext);
510 return VOS_STATUS_SUCCESS;
511#else // defined(BTAMP_MULTIPLE_PHY_LINKS)
512#endif //BTAMP_MULTIPLE_PHY_LINKS
513}/* WLANBAP_GetNewHndl */
514
515
516/*==========================================================================
517
518 FUNCTION WLANBAP_ReleaseHndl
519
520 DESCRIPTION
521 Called by HDD at driver open (BSL_Close). BAP will reclaim (invalidate)
522 the "file handle" passed into this call.
523
524
525 DEPENDENCIES
526
527 PARAMETERS
528
529 IN
530 btampHandle: btampHandle value to invalidate.
531
532 RETURN VALUE
533 The result code associated with performing the operation
534
535 VOS_STATUS_E_FAULT: btampHandle is NULL ; access would cause a
536 page fault
537 VOS_STATUS_SUCCESS: Everything is good :)
538
539 SIDE EFFECTS
540
541============================================================================*/
542VOS_STATUS
543WLANBAP_ReleaseHndl
544(
545 ptBtampHandle btampHandle /* btamp handle value to release */
546)
547{
548 /* obtain btamp Context */
549 ptBtampContext btampContext = (ptBtampContext) btampHandle;
550 tHalHandle halHandle;
551 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
552 /*------------------------------------------------------------------------
553 Sanity check params
554 ------------------------------------------------------------------------*/
555 if ( NULL == btampHandle)
556 {
557 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
558 "Invalid BAP handle value in WLANBAP_ReleaseHndl");
559 return VOS_STATUS_E_FAULT;
560 }
561
562 /* JEZ081001: TODO: Major: */
563 /* Check to see if any wireless associations are still active */
564 /* ...if so, I have to call
565 * sme_RoamDisconnect(VOS_GET_HAL_CB(btampHandle->pvosGCtx),
566 * btampHandle->sessionId,
567 * eCSR_DISCONNECT_REASON_UNSPECIFIED);
568 * on all of them */
569
570 halHandle = VOS_GET_HAL_CB(btampContext->pvosGCtx);
571 if(NULL == halHandle)
572 {
573 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
574 "halHandle is NULL in %s", __FUNCTION__);
575 return VOS_STATUS_E_FAULT;
576 }
577
578 if( btampContext->isBapSessionOpen == TRUE )
579 {
580 halStatus = sme_CloseSession(halHandle,
581 btampContext->sessionId, NULL, NULL);
582 if(eHAL_STATUS_SUCCESS == halStatus)
583 {
584 btampContext->isBapSessionOpen = FALSE;
585 }
586 }
587
588 /* release the btampHandle */
589
590 return VOS_STATUS_SUCCESS;
591}/* WLANBAP_ReleaseHndl */
592
593/*----------------------------------------------------------------------------
594 * Utility Function implementations
595 * -------------------------------------------------------------------------*/
596
597/*==========================================================================
598
599 FUNCTION WLANBAP_CleanCB
600
601 DESCRIPTION
602 Clear out all fields in the BAP context.
603
604 DEPENDENCIES
605
606 PARAMETERS
607
608 IN
609 pBtampCtx: pointer to the BAP control block
610 freeFlag: flag indicating whether to free any allocations.
611
612 RETURN VALUE
613 The result code associated with performing the operation
614
615 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
616 fault
617 VOS_STATUS_SUCCESS: Everything is good :)
618
619 SIDE EFFECTS
620
621============================================================================*/
622VOS_STATUS
623WLANBAP_CleanCB
624(
625 ptBtampContext pBtampCtx,
626 v_U32_t freeFlag // 0 /*do not empty*/);
627)
628{
629 v_U16_t i; /* Logical Link index */
630 tpBtampLogLinkCtx pLogLinkContext = NULL;
631
632 /*------------------------------------------------------------------------
633 Sanity check BAP control block
634 ------------------------------------------------------------------------*/
635
636 if ( NULL == pBtampCtx )
637 {
638 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
639 "Invalid BAP pointer in WLANBAP_CleanCB");
640 return VOS_STATUS_E_FAULT;
641 }
642
643 /*------------------------------------------------------------------------
644 Clean up BAP control block, initialize all values
645 ------------------------------------------------------------------------*/
646 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_CleanCB");
647
648 // First, clear out EVERYTHING in the BT-AMP context
649 vos_mem_set( pBtampCtx, sizeof( *pBtampCtx), 0);
650
651 pBtampCtx->pvosGCtx = NULL;
652
653 // Initialize physical link state machine to DISCONNECTED state
654 //pBtampCtx->bapPhysLinkMachine = BTAMPFSM_INSTANCEDATA_INIT;
655
656 // Initialize physical link state machine to DISCONNECTED state
657 vos_mem_copy(
658 &pBtampCtx->bapPhysLinkMachine,
659 &bapPhysLinkMachineInitial, /* BTAMPFSM_INSTANCEDATA_INIT; */
660 sizeof( pBtampCtx->bapPhysLinkMachine));
661
662 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Initializing State: %d", __FUNCTION__, bapPhysLinkMachineInitial.stateVar);
663 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Initialized State: %d", __FUNCTION__, pBtampCtx->bapPhysLinkMachine.stateVar);
664
665 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: btampContext value: %x", __FUNCTION__, pBtampCtx);
666#ifdef BAP_DEBUG
667 /* Trace the tBtampCtx being passed in. */
668 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
669 "WLAN BAP Context Monitor: pBtampCtx value = %x in %s:%d", pBtampCtx, __FUNCTION__, __LINE__ );
670#endif //BAP_DEBUG
671
672
673 pBtampCtx->sessionId = 0;
674 pBtampCtx->pAppHdl = NULL; // Per-app BSL context
675 pBtampCtx->pHddHdl = NULL; // Per-app BSL context
676 /* 8 bits of phy_link_handle identifies this association */
677 pBtampCtx->phy_link_handle = 0;
678 pBtampCtx->channel = 0;
679 pBtampCtx->BAPDeviceRole = BT_RESPONDER;
680 pBtampCtx->ucSTAId = 0;
681
682 // gNeedPhysLinkCompEvent
683 pBtampCtx->gNeedPhysLinkCompEvent = VOS_FALSE;
684 // gPhysLinkStatus
685 pBtampCtx->gPhysLinkStatus = WLANBAP_STATUS_SUCCESS;
686 // gDiscRequested
687 pBtampCtx->gDiscRequested = VOS_FALSE;
688 // gDiscReason
689 pBtampCtx->gDiscReason = WLANBAP_STATUS_SUCCESS;
690
691 /* Connection Accept Timer interval*/
692 pBtampCtx->bapConnectionAcceptTimerInterval = WLANBAP_CONNECTION_ACCEPT_TIMEOUT;
693 /* Link Supervision Timer interval*/
694 pBtampCtx->bapLinkSupervisionTimerInterval = WLANBAP_LINK_SUPERVISION_TIMEOUT;
695 /* Logical Link Accept Timer interval*/
696 pBtampCtx->bapLogicalLinkAcceptTimerInterval = WLANBAP_LOGICAL_LINK_ACCEPT_TIMEOUT;
697 /* Best Effort Flush timer interval*/
698 pBtampCtx->bapBEFlushTimerInterval = WLANBAP_BE_FLUSH_TIMEOUT;
699
700 // Include the associations MAC addresses
701 vos_mem_copy(
702 pBtampCtx->self_mac_addr,
703 pBtStaOwnMacAddr, /* Where do I get the current MAC address? */
704 sizeof(pBtampCtx->self_mac_addr));
705
706 vos_mem_set(
707 pBtampCtx->peer_mac_addr,
708 sizeof(pBtampCtx->peer_mac_addr),
709 0);
710
711 // The array of logical links
712 pBtampCtx->current_log_link_index = 0; /* assigned mod 16 */
713 pBtampCtx->total_log_link_index = 0; /* should never be >16 */
714
715 // Clear up the array of logical links
716 for (i = 0; i < WLANBAP_MAX_LOG_LINKS ; i++)
717 {
718 pLogLinkContext = &pBtampCtx->btampLogLinkCtx[i];
719 pLogLinkContext->present = 0;
720 pLogLinkContext->uTxPktCompleted = 0;
721 pLogLinkContext->log_link_handle = 0;
722 }
723
724
725 // Include the HDD BAP Shim Layer callbacks for Fetch, TxComp, and RxPkt
726 pBtampCtx->pfnBtampFetchPktCB = NULL;
727 pBtampCtx->pfnBtamp_STARxCB = NULL;
728 pBtampCtx->pfnBtampTxCompCB = NULL;
729 /* Implements the callback for ALL asynchronous events. */
730 pBtampCtx->pBapHCIEventCB = NULL;
731
732 /* Set the default for event mask */
733 vos_mem_set(
734 pBtampCtx->event_mask_page_2,
735 sizeof(pBtampCtx->event_mask_page_2),
736 0);
737
738 /* Set the default for location data. */
739 pBtampCtx->btamp_Location_Data_Info.loc_options = 0x58;
740 /* Set the default data transfer mode */
741 pBtampCtx->ucDataTrafficMode = WLANBAP_FLOW_CONTROL_MODE_BLOCK_BASED;
742
743 return VOS_STATUS_SUCCESS;
744}/* WLANBAP_CleanCB */
745
746/*==========================================================================
747
748 FUNCTION WLANBAP_GetCtxFromStaId
749
750 DESCRIPTION
751 Called inside the BT-AMP PAL (BAP) layer whenever we need either the
752 BSL context or the BTAMP context from the StaId.
753
754
755 DEPENDENCIES
756
757 PARAMETERS
758
759 IN
760 ucSTAId: The StaId (used by TL, PE, and HAL)
761
762 OUT
763 hBtampHandle: Handle (pointer to a pointer) to return the
764 btampHandle value in.
765 hHddHdl: Handle to return the BSL context pointer in.
766
767 RETURN VALUE
768 The result code associated with performing the operation
769
770 VOS_STATUS_E_FAULT: NULL pointer; access would cause a page fault
771 VOS_STATUS_SUCCESS: Everything is good :)
772
773 SIDE EFFECTS
774
775============================================================================*/
776VOS_STATUS
777WLANBAP_GetCtxFromStaId
778(
779 v_U8_t ucSTAId, /* The StaId (used by TL, PE, and HAL) */
780 ptBtampHandle *hBtampHandle, /* Handle to return per app btampHandle value in */
781 ptBtampContext *hBtampContext, /* Handle to return per assoc btampContext value in */
782 v_PVOID_t *hHddHdl /* Handle to return BSL context in */
783)
784{
785#ifndef BTAMP_MULTIPLE_PHY_LINKS
786
787 /* For now, we know there is only one application context */
788 /* ...and only one physical link context */
789 //*hBtampHandle = &((ptBtampContext) btampCtx);
790 //*hBtampHandle = &btampCtx;
791 *hBtampHandle = (v_VOID_t*)gpBtampCtx;
792
793 //*hBtampContext = &btampCtx;
794 *hBtampContext = gpBtampCtx;
795
796 /* Handle to return BSL context in */
797 //*hHddHdl = btampCtx.pHddHdl;
798 *hHddHdl = gpBtampCtx->pHddHdl;
799
800 return VOS_STATUS_SUCCESS;
801#else // defined(BTAMP_MULTIPLE_PHY_LINKS)
802
803#endif //BTAMP_MULTIPLE_PHY_LINKS
804}/* WLANBAP_GetCtxFromStaId */
805
806/*==========================================================================
807
808 FUNCTION WLANBAP_GetStaIdFromLinkCtx
809
810 DESCRIPTION
811 Called inside the BT-AMP PAL (BAP) layer whenever we need the
812 StaId (or hHddHdl) from the BTAMP context and phy_link_handle.
813
814
815 DEPENDENCIES
816
817 PARAMETERS
818
819 IN
820 hBtampHandle: Handle (pointer to a pointer) to return the
821 btampHandle value in.
822 phy_link_handle: physical link handle value. Unique per assoc.
823
824 OUT
825 pucSTAId: The StaId (used by TL, PE, and HAL)
826 hHddHdl: Handle to return the BSL context pointer in.
827
828 RETURN VALUE
829 The result code associated with performing the operation
830
831 VOS_STATUS_E_FAULT: NULL pointer; access would cause a page fault
832 VOS_STATUS_SUCCESS: Everything is good :)
833
834 SIDE EFFECTS
835
836============================================================================*/
837VOS_STATUS
838WLANBAP_GetStaIdFromLinkCtx
839(
840 ptBtampHandle btampHandle, /* btampHandle value in */
841 v_U8_t phy_link_handle, /* phy_link_handle value in */
842 v_U8_t *pucSTAId, /* The StaId (used by TL, PE, and HAL) */
843 v_PVOID_t *hHddHdl /* Handle to return BSL context */
844)
845{
846#ifndef BTAMP_MULTIPLE_PHY_LINKS
847 ptBtampContext pBtampCtx = (ptBtampContext) btampHandle;
848
849 /*------------------------------------------------------------------------
850 Sanity check params
851 ------------------------------------------------------------------------*/
852 if ( NULL == pBtampCtx)
853 {
854 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
855 "Invalid BAP handle value in %s", __FUNCTION__);
856 return VOS_STATUS_E_FAULT;
857 }
858
859 /* Since there is only one physical link...we have stored all
860 * the physical link specific context in the application context
861 */
862 /* The StaId (used by TL, PE, and HAL) */
863 *pucSTAId = pBtampCtx->ucSTAId;
864
865 /* Handle to return BSL context */
866 *hHddHdl = pBtampCtx->pHddHdl;
867
868 return VOS_STATUS_SUCCESS;
869#else // defined(BTAMP_MULTIPLE_PHY_LINKS)
870
871#endif //BTAMP_MULTIPLE_PHY_LINKS
872}/* WLANBAP_GetStaIdFromLinkCtx */
873
874/*==========================================================================
875
876 FUNCTION WLANBAP_CreateNewPhyLinkCtx
877
878 DESCRIPTION
879 Called in order to create (or update) a BAP Physical Link "context"
880
881
882 DEPENDENCIES
883
884 PARAMETERS
885
886 IN
887 btampHandle: BAP app context handle
888 phy_link_handle: phy_link_handle from the Command
889 pHddHdl: BSL passes in its specific context
890
891 OUT
892 hBtampContext: Handle (pointer to a pointer) to return the
893 per "Phy Link" ptBtampContext value in.
894
895 RETURN VALUE
896 The result code associated with performing the operation
897
898 VOS_STATUS_E_FAULT: NULL pointer; access would cause a page fault
899 VOS_STATUS_SUCCESS: Everything is good :)
900
901 SIDE EFFECTS
902
903============================================================================*/
904VOS_STATUS
905WLANBAP_CreateNewPhyLinkCtx
906(
907 ptBtampHandle btampHandle,
908 v_U8_t phy_link_handle, /* I get phy_link_handle from the Command */
909 v_PVOID_t pHddHdl, /* BSL passes in its specific context */
910 ptBtampContext *hBtampContext, /* Handle to return per assoc btampContext value in */
911 tWLAN_BAPRole BAPDeviceRole
912)
913{
914#ifndef BTAMP_MULTIPLE_PHY_LINKS
915 ptBtampContext pBtampCtx = gpBtampCtx;
916 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
917
918 /* Read and Set MAC address and SSID to BT-AMP context */
919 WLANBAP_ReadMacConfig (pBtampCtx);
920
921 /*------------------------------------------------------------------------
922 For now, presume security is not enabled.
923 ------------------------------------------------------------------------*/
924 pBtampCtx->ucSecEnabled = WLANBAP_SECURITY_ENABLED_STATE;
925
926 /*------------------------------------------------------------------------
927 Initial Short Range Mode for this physical link is 'disabled'
928 ------------------------------------------------------------------------*/
929 pBtampCtx->phy_link_srm = 0;
930
931 /*------------------------------------------------------------------------
932 Clear out the logical links.
933 ------------------------------------------------------------------------*/
934 pBtampCtx->current_log_link_index = 0;
935 pBtampCtx->total_log_link_index = 0;
936
937 /*------------------------------------------------------------------------
938 Now configure the roaming profile links. To SSID and bssid.
939 ------------------------------------------------------------------------*/
940 // We have room for two SSIDs.
941 pBtampCtx->csrRoamProfile.SSIDs.numOfSSIDs = 1; // This is true for now.
942 pBtampCtx->csrRoamProfile.SSIDs.SSIDList = pBtampCtx->SSIDList; //Array of two
943 pBtampCtx->csrRoamProfile.SSIDs.SSIDList[0].SSID.length = 0;
944 pBtampCtx->csrRoamProfile.SSIDs.SSIDList[0].handoffPermitted = VOS_FALSE;
945 pBtampCtx->csrRoamProfile.SSIDs.SSIDList[0].ssidHidden = VOS_FALSE;
946
947 pBtampCtx->csrRoamProfile.BSSIDs.numOfBSSIDs = 1; // This is true for now.
948 pBtampCtx->csrRoamProfile.BSSIDs.bssid = &pBtampCtx->bssid;
949
950 // Now configure the auth type in the roaming profile. To open.
951 //pBtampCtx->csrRoamProfile.AuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM; // open is the default
952 //pBtampCtx->csrRoamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM; // open is the default
953 pBtampCtx->csrRoamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_RSN_PSK;
954 pBtampCtx->csrRoamProfile.negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_AES;
955
956 pBtampCtx->phy_link_handle = phy_link_handle;
957 /* For now, we know there is only one physical link context */
958 //*hBtampContext = &btampCtx;
959
960 pBtampCtx->pHddHdl = pHddHdl;
961
962 *hBtampContext = pBtampCtx;
963 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
964 "Btamp Ctxt = %x", pBtampCtx);
965
966 return VOS_STATUS_SUCCESS;
967#else // defined(BTAMP_MULTIPLE_PHY_LINKS)
968
969#endif //BTAMP_MULTIPLE_PHY_LINKS
970}/* WLANBAP_CreateNewPhyLinkCtx */
971
972/*==========================================================================
973
974 FUNCTION WLANBAP_UpdatePhyLinkCtxStaId
975
976 DESCRIPTION
977 Called to update the STAId value associated with Physical Link "context"
978
979
980 DEPENDENCIES
981
982 PARAMETERS
983
984 IN
985 pBtampContext: ptBtampContext to update.
986 ucSTAId: The StaId (used by TL, PE, and HAL)
987
988
989 RETURN VALUE
990 The result code associated with performing the operation
991
992 VOS_STATUS_E_FAULT: NULL pointer; access would cause a page fault
993 VOS_STATUS_SUCCESS: Everything is good :)
994
995 SIDE EFFECTS
996
997============================================================================*/
998VOS_STATUS
999WLANBAP_UpdatePhyLinkCtxStaId
1000(
1001 ptBtampContext pBtampContext, /* btampContext value in */
1002 v_U8_t ucSTAId
1003)
1004{
1005#ifndef BTAMP_MULTIPLE_PHY_LINKS
1006
1007 /*------------------------------------------------------------------------
1008 Sanity check params
1009 ------------------------------------------------------------------------*/
1010 if ( NULL == pBtampContext)
1011 {
1012 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1013 "Invalid BAP handle value in %s", __FUNCTION__);
1014 return VOS_STATUS_E_FAULT;
1015 }
1016
1017 /* The StaId (used by TL, PE, and HAL) */
1018 pBtampContext->ucSTAId = ucSTAId;
1019
1020 return VOS_STATUS_SUCCESS;
1021#else // defined(BTAMP_MULTIPLE_PHY_LINKS)
1022
1023#endif //BTAMP_MULTIPLE_PHY_LINKS
1024}/* WLANBAP_UpdatePhyLinkCtxStaId */
1025
1026v_U8_t
1027bapAllocNextLogLinkIndex
1028(
1029 ptBtampContext pBtampContext, /* Pointer to the per assoc btampContext value */
1030 v_U8_t phy_link_handle /* I get phy_link_handle from the Command */
1031)
1032{
1033 return ++(pBtampContext->current_log_link_index) % WLANBAP_MAX_LOG_LINKS;
1034}/* bapAllocNextLogLinkIndex */
1035
1036/*==========================================================================
1037
1038 FUNCTION WLANBAP_CreateNewLogLinkCtx
1039
1040 DESCRIPTION
1041 Called in order to allocate a BAP Logical Link "context" and "index"
1042
1043
1044 DEPENDENCIES
1045
1046 PARAMETERS
1047
1048 IN
1049 pBtampContext: Pointer to the ptBtampContext value in.
1050 phy_link_handle: phy_link_handle involved
1051
1052 OUT
1053 pLog_link_handle: return the log_link_handle here
1054
1055 RETURN VALUE
1056 The result code associated with performing the operation
1057
1058 VOS_STATUS_E_FAULT: NULL pointer; access would cause a page fault
1059 VOS_STATUS_SUCCESS: Everything is good :)
1060
1061 SIDE EFFECTS
1062
1063============================================================================*/
1064VOS_STATUS
1065WLANBAP_CreateNewLogLinkCtx
1066(
1067 ptBtampContext pBtampContext, /* Pointer to the per assoc btampContext value */
1068 v_U8_t phy_link_handle, /* I get phy_link_handle from the Command */
1069 v_U8_t tx_flow_spec[18],
1070 v_U8_t rx_flow_spec[18],
1071 v_U16_t *pLog_link_handle /* Return the logical link index here */
1072)
1073{
1074#ifndef BTAMP_MULTIPLE_PHY_LINKS
1075 v_U16_t i; /* Logical Link index */
1076 tpBtampLogLinkCtx pLogLinkContext;
1077 v_U32_t retval;
1078 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1079
1080 /*------------------------------------------------------------------------
1081 For now, allocate the logical links serially.
1082 ------------------------------------------------------------------------*/
1083 i = pBtampContext->current_log_link_index
1084 = bapAllocNextLogLinkIndex(pBtampContext, phy_link_handle);
1085 pBtampContext->total_log_link_index++;
1086
1087 *pLog_link_handle = (i << 8) + ( v_U16_t ) phy_link_handle ; /* Return the logical link index here */
1088 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
1089 " %s:*pLog_link_handle=%x", __FUNCTION__,*pLog_link_handle);
1090
1091 /*------------------------------------------------------------------------
1092 Evaluate the Tx and Rx Flow specification for this logical link.
1093 ------------------------------------------------------------------------*/
1094 // Currently we only support flow specs with service types of BE (0x01)
1095
1096#ifdef BAP_DEBUG
1097 /* Trace the tBtampCtx being passed in. */
1098 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
1099 "WLAN BAP Context Monitor: pBtampContext value = %x in %s:%d", pBtampContext, __FUNCTION__, __LINE__ );
1100#endif //BAP_DEBUG
1101
1102 /*------------------------------------------------------------------------
1103 Now configure the Logical Link context.
1104 ------------------------------------------------------------------------*/
1105 pLogLinkContext = &(pBtampContext->btampLogLinkCtx[i]);
1106
1107 /* Extract Tx flow spec into the context structure */
1108 retval = btampUnpackTlvFlow_Spec((void *)pBtampContext, tx_flow_spec,
1109 WLAN_BAP_PAL_FLOW_SPEC_TLV_LEN,
1110 &pLogLinkContext->btampFlowSpec);
1111 if (retval != BTAMP_PARSE_SUCCESS)
1112 {
1113 /* Flow spec parsing failed, return failure */
1114 return VOS_STATUS_E_BADMSG;
1115 }
1116
1117 /* Save the Logical link handle in the logical link context
1118 As of now, only the index is saved as logical link handle since
1119 same is returned in the event.
1120 FIXME: Decide whether this index has to be combined with physical
1121 link handle to generate the Logical link handle.
1122 */
1123 pLogLinkContext->log_link_handle = *pLog_link_handle;
1124
1125 // Mark this entry as OCCUPIED
1126 pLogLinkContext->present = VOS_TRUE;
1127 // Now initialize the Logical Link context
1128 pLogLinkContext->btampAC = 1;
1129 // Now initialize the values in the Logical Link context
1130 pLogLinkContext->ucTID = 0; // Currently we only support BE TID (0x00)
1131 pLogLinkContext->ucUP = 0;
1132 pLogLinkContext->uTxPktCompleted = 0;
1133
1134 return VOS_STATUS_SUCCESS;
1135#else // defined(BTAMP_MULTIPLE_PHY_LINKS)
1136
1137#endif //BTAMP_MULTIPLE_PHY_LINKS
1138}/* WLANBAP_CreateNewLogLinkCtx */
1139
1140/*==========================================================================
1141
1142 FUNCTION WLANBAP_pmcFullPwrReqCB
1143
1144 DESCRIPTION
1145 Callback provide to PMC in the pmcRequestFullPower API.
1146
1147
1148 DEPENDENCIES
1149
1150 PARAMETERS
1151
1152 IN
1153 callbackContext: The user passed in a context to identify
1154 status: The halStatus
1155
1156
1157 RETURN VALUE
1158 None
1159
1160 SIDE EFFECTS
1161
1162============================================================================*/
1163void
1164WLANBAP_pmcFullPwrReqCB
1165(
1166 void *callbackContext,
1167 eHalStatus status
1168)
1169{
1170
1171}/* WLANBAP_pmcFullPwrReqCB */
1172
1173
1174/*==========================================================================
1175
1176 FUNCTION WLANBAP_ReadMacConfig
1177
1178 DESCRIPTION
1179 This function sets the MAC config (Address and SSID to BT-AMP context
1180
1181 DEPENDENCIES
1182
1183 PARAMETERS
1184
1185 pvosGCtx: pointer to the global vos context; a handle to BAP's
1186 control block can be extracted from its context
1187
1188 RETURN VALUE
1189 None
1190
1191 SIDE EFFECTS
1192
1193============================================================================*/
1194void
1195WLANBAP_ReadMacConfig
1196(
1197 ptBtampContext pBtampCtx
1198)
1199{
1200 tANI_U32 len = WNI_CFG_BSSID_LEN;
1201 tHalHandle pMac = NULL;
1202
1203 /*------------------------------------------------------------------------
1204 Temporary method to get the self MAC address
1205 ------------------------------------------------------------------------*/
1206 if (NULL == pBtampCtx)
1207 {
1208 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1209 "pBtampCtx is NULL in %s", __FUNCTION__);
1210
1211 return;
1212 }
1213
1214 pMac = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pBtampCtx->pvosGCtx);
1215 if (NULL == pMac)
1216 {
1217 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1218 "pMac is NULL in %s", __FUNCTION__);
1219
1220 return;
1221 }
1222
1223 ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pBtStaOwnMacAddr, &len );
1224
1225 VOS_ASSERT( WNI_CFG_BSSID_LEN == len );
1226
1227 /* Form the SSID from Mac address */
1228 VOS_SNPRINTF( pBtStaOwnSsid, WLAN_BAP_SSID_MAX_LEN,
1229 "AMP-%02x-%02x-%02x-%02x-%02x-%02x",
1230 pBtStaOwnMacAddr[0], pBtStaOwnMacAddr[1], pBtStaOwnMacAddr[2],
1231 pBtStaOwnMacAddr[3], pBtStaOwnMacAddr[4], pBtStaOwnMacAddr[5]);
1232
1233 /*------------------------------------------------------------------------
1234 Set the MAC address for this instance
1235 ------------------------------------------------------------------------*/
1236 vos_mem_copy(
1237 pBtampCtx->self_mac_addr,
1238 pBtStaOwnMacAddr,
1239 sizeof(pBtampCtx->self_mac_addr));
1240
1241 /*------------------------------------------------------------------------
1242 Set our SSID value
1243 ------------------------------------------------------------------------*/
1244 pBtampCtx->ownSsidLen = 21;
1245 vos_mem_copy(
1246 pBtampCtx->ownSsid,
1247 pBtStaOwnSsid,
1248 pBtampCtx->ownSsidLen);
1249}
1250
1251/*==========================================================================
1252
1253 FUNCTION WLANBAP_NeedBTCoexPriority
1254
1255 DESCRIPTION
1256 This function will cause a message to be sent to BTC firmware
1257 if a change in priority has occurred. (From AMP's point-of-view.)
1258
1259 DEPENDENCIES
1260
1261 PARAMETERS
1262
1263 pvosGCtx: pointer to the global vos context; a handle to HAL's
1264 control block can be extracted from its context
1265
1266 RETURN VALUE
1267 None
1268
1269 SIDE EFFECTS
1270
1271============================================================================*/
1272// Global
1273static int gBapCoexPriority = 0;
1274
1275void
1276WLANBAP_NeedBTCoexPriority
1277(
1278 ptBtampContext pBtampCtx,
1279 v_U32_t needCoexPriority
1280)
1281{
1282 tHalHandle pMac = NULL;
1283 tSmeBtAmpEvent btAmpEvent;
1284
1285
1286 /*------------------------------------------------------------------------
1287 Retrieve the pMac (HAL context)
1288 ------------------------------------------------------------------------*/
1289 pMac = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pBtampCtx->pvosGCtx);
1290
1291 // Is re-entrancy protection needed for this?
1292 if (needCoexPriority != gBapCoexPriority) {
1293 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
1294 "Calling %s with needCoexPriority=%d.", __FUNCTION__, needCoexPriority);
1295
1296 gBapCoexPriority = needCoexPriority;
1297 switch ( needCoexPriority)
1298 {
1299 case 0: /* Idle */
1300 btAmpEvent.btAmpEventType = BTAMP_EVENT_CONNECTION_TERMINATED;
1301 pBtampCtx->btamp_session_on = FALSE;
1302 sme_sendBTAmpEvent(pMac, btAmpEvent);
1303
1304 break;
1305
1306 case 1: /* Associating */
1307 btAmpEvent.btAmpEventType = BTAMP_EVENT_CONNECTION_START;
1308 pBtampCtx->btamp_session_on = TRUE;
1309 sme_sendBTAmpEvent(pMac, btAmpEvent);
1310
1311 break;
1312
1313 case 2: /* Post-assoc */
1314 btAmpEvent.btAmpEventType = BTAMP_EVENT_CONNECTION_STOP;
1315 sme_sendBTAmpEvent(pMac, btAmpEvent);
1316
1317 break;
1318
1319 default:
1320 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1321 "%s: Invalid Coexistence priority request: %d",
1322 __FUNCTION__, needCoexPriority);
1323 }
1324
1325 }
1326}
1327
1328
1329/*==========================================================================
1330
1331 FUNCTION WLANBAP_RxCallback
1332
1333 DESCRIPTION
1334 This function is called by TL call this function for all frames except for Data frames
1335
1336 DEPENDENCIES
1337
1338 PARAMETERS
1339
1340 pvosGCtx: pointer to the global vos context; a handle to BAP's
1341 control block can be extracted from its context
1342 pPacket Vos packet
1343 frameType Frame type
1344
1345 RETURN VALUE
1346 None
1347
1348 SIDE EFFECTS
1349
1350============================================================================*/
1351VOS_STATUS WLANBAP_RxCallback
1352(
1353 v_PVOID_t pvosGCtx,
1354 vos_pkt_t *pPacket,
1355 WLANTL_BAPFrameEnumType frameType
1356)
1357{
1358 ptBtampContext pBtampCtx = NULL;
1359
1360 pBtampCtx = VOS_GET_BAP_CB(pvosGCtx);
1361 if ( NULL == pBtampCtx )
1362 {
1363 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1364 "Invalid BAP pointer from pvosGCtx on WLANBAP_Start");
1365 return VOS_STATUS_E_FAULT;
1366 }
1367
1368 switch (frameType)
1369 {
1370 case WLANTL_BT_AMP_TYPE_LS_REQ: /* Fall through */
1371 case WLANTL_BT_AMP_TYPE_LS_REP:
1372 {
1373 /* Link supervision frame, process this frame */
1374 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
1375 "%s: link Supervision packet received over TL: %d, => BAP",
1376 __FUNCTION__, frameType);
1377 WLANBAP_RxProcLsPkt((ptBtampHandle)pBtampCtx,
1378 pBtampCtx->phy_link_handle,
1379 frameType,
1380 pPacket);
1381 break;
1382 }
1383
1384 case WLANTL_BT_AMP_TYPE_AR: /* Fall through */
1385 case WLANTL_BT_AMP_TYPE_SEC:
1386 {
1387 /* Call the RSN callback handler */
1388 bapRsnRxCallback (pvosGCtx, pPacket);
1389 break;
1390 }
1391
1392 default:
1393 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1394 "%s: Invalid frametype from TL: %d, => BAP",
1395 __FUNCTION__, frameType);
1396 }
1397
1398 return ( VOS_STATUS_SUCCESS );
1399}