blob: 48dbc1674502047c8a40d89a7eb82939492d87ab [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*===========================================================================
43
44 b a p A p i T i m e r . C
45
46 OVERVIEW:
47
48 This software unit holds the implementation of the timer routines
49 required by the WLAN BAP module.
50
51 The functions provide by this module are called by the rest of
52 the BT-AMP PAL module.
53
54 DEPENDENCIES:
55
56 Are listed for each API below.
57
58
59 Copyright (c) 2008 QUALCOMM Incorporated.
60 All Rights Reserved.
61 Qualcomm Confidential and Proprietary
62===========================================================================*/
63
64/*===========================================================================
65
66 EDIT HISTORY FOR FILE
67
68
69 This section contains comments describing changes made to the module.
70 Notice that changes are listed in reverse chronological order.
71
72
73 $Header: /home/labuser/btamp-label9/CORE/BAP/src/bapApiTimer.c,v 1.5 2010/09/04 00:14:37 labuser Exp labuser $$DateTime$$Author: labuser $
74
75
76 when who what, where, why
77---------- --- --------------------------------------------------------
782008-10-23 jez Created module
79
80===========================================================================*/
81
82/*----------------------------------------------------------------------------
83 * Include Files
84 * -------------------------------------------------------------------------*/
85// I think this pulls in everything
86#include "vos_types.h"
87#include "bapApiTimer.h"
88
89//#define BAP_DEBUG
90
91/*----------------------------------------------------------------------------
92 * Preprocessor Definitions and Constants
93 * -------------------------------------------------------------------------*/
94#define WLAN_BAP_TX_PKT_MONITOR_TIME 100
95
96/*----------------------------------------------------------------------------
97 * Type Declarations
98 * -------------------------------------------------------------------------*/
99
100/*----------------------------------------------------------------------------
101 * Global Data Definitions
102 * -------------------------------------------------------------------------*/
103
104/*----------------------------------------------------------------------------
105 * External declarations for global context
106 * -------------------------------------------------------------------------*/
107#if 1
108//*BT-AMP packet LLC OUI value*/
109static const v_U8_t WLANBAP_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
110
111#endif
112
113/*----------------------------------------------------------------------------
114 * Static Variable Definitions
115 * -------------------------------------------------------------------------*/
116
117/*----------------------------------------------------------------------------
118 * Static Function Declarations and Definitions
119 * -------------------------------------------------------------------------*/
120
121/*----------------------------------------------------------------------------
122 * Externalized Function Definitions
123* -------------------------------------------------------------------------*/
124
125/*----------------------------------------------------------------------------
126 * Function Declarations and Documentation
127 * -------------------------------------------------------------------------*/
128
129/*----------------------------------------------------------------------------
130 * Utility Function implementations
131 * -------------------------------------------------------------------------*/
132
133/*==========================================================================
134
135 FUNCTION WLANBAP_InitConnectionAcceptTimer
136
137 DESCRIPTION
138 Initialize the Connection Accept Timer.
139
140 DEPENDENCIES
141
142 PARAMETERS
143
144 IN
145 pBtampCtx: pointer to the BAP control block
146
147 RETURN VALUE
148 The result code associated with performing the operation
149
150 VOS_STATUS_E_FAULT: access would cause a page fault
151 VOS_STATUS_SUCCESS: Everything is good :)
152
153 SIDE EFFECTS
154
155============================================================================*/
156VOS_STATUS
157WLANBAP_InitConnectionAcceptTimer
158(
159 ptBtampContext pBtampCtx
160)
161{
162 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
163
164 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
165
166
167 /*------------------------------------------------------------------------
168 Sanity check BAP control block
169 ------------------------------------------------------------------------*/
170
171 if ( NULL == pBtampCtx )
172 {
173 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700174 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 return VOS_STATUS_E_FAULT;
176 }
177
178 /*Initialize the timer */
179 vosStatus = vos_timer_init(
180 &pBtampCtx->bapConnectionAcceptTimer,
181 VOS_TIMER_TYPE_SW, /* use this type */
182 WLANBAP_ConnectionAcceptTimerHandler,
183 pBtampCtx);
184
185 return VOS_STATUS_SUCCESS;
186}/* WLANBAP_InitConnectionAcceptTimer */
187
188/*==========================================================================
189
190 FUNCTION WLANBAP_DeinitConnectionAcceptTimer
191
192 DESCRIPTION
193 Destroy the Connection Accept Timer.
194
195 DEPENDENCIES
196
197 PARAMETERS
198
199 IN
200 pBtampCtx: pointer to the BAP control block
201
202 RETURN VALUE
203 The result code associated with performing the operation
204
205 VOS_STATUS_E_FAULT: access would cause a page fault
206 VOS_STATUS_SUCCESS: Everything is good :)
207
208 SIDE EFFECTS
209
210============================================================================*/
211VOS_STATUS
212WLANBAP_DeinitConnectionAcceptTimer
213(
214 ptBtampContext pBtampCtx
215)
216{
217 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
218
219 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
220
221
222 /*------------------------------------------------------------------------
223 Sanity check BAP control block
224 ------------------------------------------------------------------------*/
225
226 if ( NULL == pBtampCtx )
227 {
228 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700229 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 return VOS_STATUS_E_FAULT;
231 }
232
233 /*Initialize and then Start the timer */
234 vosStatus = vos_timer_destroy (
235 &pBtampCtx->bapConnectionAcceptTimer );
236
237 return VOS_STATUS_SUCCESS;
238}/* WLANBAP_DeinitConnectionAcceptTimer */
239
240/*==========================================================================
241
242 FUNCTION WLANBAP_StartConnectionAcceptTimer
243
244 DESCRIPTION
245 Start the Connection Accept Timer.
246
247 DEPENDENCIES
248
249 PARAMETERS
250
251 IN
252 pBtampCtx: pointer to the BAP control block
253 interval: time interval.
254
255 RETURN VALUE
256 The result code associated with performing the operation
257
258 VOS_STATUS_E_FAULT: access would cause a page fault
259 VOS_STATUS_SUCCESS: Everything is good :)
260
261 SIDE EFFECTS
262
263============================================================================*/
264VOS_STATUS
265WLANBAP_StartConnectionAcceptTimer
266(
267 ptBtampContext pBtampCtx,
268 v_U32_t interval
269)
270{
271 /*------------------------------------------------------------------------
272 Sanity check BAP control block
273 ------------------------------------------------------------------------*/
274
275 if ( NULL == pBtampCtx )
276 {
277 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700278 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 return VOS_STATUS_E_FAULT;
280 }
281
282 /*Start the connection accept timer*/
283 vos_timer_start(
284 &pBtampCtx->bapConnectionAcceptTimer,
285 interval);
286
287 return VOS_STATUS_SUCCESS;
288}/* WLANBAP_StartConnectionAcceptTimer */
289
290
291/*==========================================================================
292
293 FUNCTION WLANBAP_StopConnectionAcceptTimer
294
295 DESCRIPTION
296 Stop the Connection Accept Timer.
297
298 DEPENDENCIES
299
300 PARAMETERS
301
302 IN
303 pBtampCtx: pointer to the BAP control block
304
305 RETURN VALUE
306 The result code associated with performing the operation
307
308 VOS_STATUS_E_FAULT: access would cause a page fault
309 VOS_STATUS_SUCCESS: Everything is good :)
310
311 SIDE EFFECTS
312
313============================================================================*/
314VOS_STATUS
315WLANBAP_StopConnectionAcceptTimer
316(
317 ptBtampContext pBtampCtx
318)
319{
320 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
321 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
322
323
324 /*------------------------------------------------------------------------
325 Sanity check BAP control block
326 ------------------------------------------------------------------------*/
327
328 if ( NULL == pBtampCtx )
329 {
330 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700331 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332 return VOS_STATUS_E_FAULT;
333 }
334
335 /*Stop the timer */
336 vosStatus = vos_timer_stop(
337 &pBtampCtx->bapConnectionAcceptTimer);
338
339
340 return VOS_STATUS_SUCCESS;
341}/* WLANBAP_StopConnectionAcceptTimer */
342
343
344
345/*==========================================================================
346
347 FUNCTION WLANBAP_ConnectionAcceptTimerHandler
348
349 DESCRIPTION
350 Callback function registered with vos timer for the Connection
351 Accept timer
352
353 DEPENDENCIES
354
355 PARAMETERS
356
357 IN
358 userData: pointer can be used to retrive the BT-AMP context
359
360 RETURN VALUE
361 None
362
363 SIDE EFFECTS
364
365============================================================================*/
366v_VOID_t
367WLANBAP_ConnectionAcceptTimerHandler
368(
369 v_PVOID_t userData
370)
371{
372 ptBtampContext pBtampCtx = (ptBtampContext)userData;
373 tWLAN_BAPEvent bapEvent; /* State machine event */
374 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
375 v_U8_t status; /* return the BT-AMP status here */
376 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
377
378 /*-----------------------------------------------------------------------
379 Sanity check
380 -----------------------------------------------------------------------*/
381 if ( NULL == pBtampCtx )
382 {
383 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700384 "WLAN BAP: Fatal error in %s", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 VOS_ASSERT(0);
386 return;
387 }
388
389 /*---------------------------------------------------------------------
390 Feed this timeout to the BTAMP FSM
391 ---------------------------------------------------------------------*/
392 /* Fill in the event structure */
393 bapEvent.event = eWLAN_BAP_TIMER_CONNECT_ACCEPT_TIMEOUT;
394 bapEvent.params = NULL;
395
396 /* Handle event */
397 vosStatus = btampFsm(pBtampCtx, &bapEvent, &status);
398
399 /* Now transition to fully disconnected and notify phy link disconnect*/
400 bapEvent.event = eWLAN_BAP_MAC_READY_FOR_CONNECTIONS;
401 bapEvent.params = NULL;
402
403 /* Handle event */
404 vosStatus = btampFsm(pBtampCtx, &bapEvent, &status);
405
406
407}/*WLANBAP_ConnectionAcceptTimerHandler*/
408
409/*==========================================================================
410
411 FUNCTION WLANBAP_InitLinkSupervisionTimer
412
413 DESCRIPTION
414 Initialize the Link Supervision Timer.
415
416 DEPENDENCIES
417
418 PARAMETERS
419
420 IN
421 pBtampCtx: pointer to the BAP control block
422
423 RETURN VALUE
424 The result code associated with performing the operation
425
426 VOS_STATUS_E_FAULT: access would cause a page fault
427 VOS_STATUS_SUCCESS: Everything is good :)
428
429 SIDE EFFECTS
430
431============================================================================*/
432VOS_STATUS
433WLANBAP_InitLinkSupervisionTimer
434(
435 ptBtampContext pBtampCtx
436)
437{
438 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
439
440 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
441
442
443 /*------------------------------------------------------------------------
444 Sanity check BAP control block
445 ------------------------------------------------------------------------*/
446
447 if ( NULL == pBtampCtx )
448 {
449 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700450 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 return VOS_STATUS_E_FAULT;
452 }
453
454 /*Initialize the timer */
455 vosStatus = vos_timer_init(
456 &pBtampCtx->bapLinkSupervisionTimer,
457 VOS_TIMER_TYPE_SW, /* use this type */
458 WLANBAP_LinkSupervisionTimerHandler,
459 pBtampCtx);
460
461 return VOS_STATUS_SUCCESS;
462}/* WLANBAP_InitLinkSupervisionTimer */
463
464/*==========================================================================
465
466 FUNCTION WLANBAP_DeinitLinkSupervisionTimer
467
468 DESCRIPTION
469 Destroy the Link Supervision Timer.
470
471 DEPENDENCIES
472
473 PARAMETERS
474
475 IN
476 pBtampCtx: pointer to the BAP control block
477
478 RETURN VALUE
479 The result code associated with performing the operation
480
481 VOS_STATUS_E_FAULT: access would cause a page fault
482 VOS_STATUS_SUCCESS: Everything is good :)
483
484 SIDE EFFECTS
485
486============================================================================*/
487VOS_STATUS
488WLANBAP_DeinitLinkSupervisionTimer
489(
490 ptBtampContext pBtampCtx
491)
492{
493 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
494
495 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
496
497
498 /*------------------------------------------------------------------------
499 Sanity check BAP control block
500 ------------------------------------------------------------------------*/
501
502 if ( NULL == pBtampCtx )
503 {
504 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700505 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 return VOS_STATUS_E_FAULT;
507 }
508
509 /*Initialize and then Start the timer */
510 vosStatus = vos_timer_destroy (
511 &pBtampCtx->bapLinkSupervisionTimer );
512
513 return VOS_STATUS_SUCCESS;
514}/* WLANBAP_DeinitLinkSupervisionTimer */
515
516/*==========================================================================
517
518 FUNCTION WLANBAP_StartLinkSupervisionTimer
519
520 DESCRIPTION
521 Start the LinkSupervisionTimer Timer.
522
523 DEPENDENCIES
524
525 PARAMETERS
526
527 IN
528 pBtampCtx: pointer to the BAP control block
529 interval: time interval.
530
531 RETURN VALUE
532 The result code associated with performing the operation
533
534 VOS_STATUS_E_FAULT: access would cause a page fault
535 VOS_STATUS_SUCCESS: Everything is good :)
536
537 SIDE EFFECTS
538
539============================================================================*/
540VOS_STATUS
541WLANBAP_StartLinkSupervisionTimer
542(
543 ptBtampContext pBtampCtx,
544 v_U32_t interval
545)
546{
547 /*------------------------------------------------------------------------
548 Sanity check BAP control block
549 ------------------------------------------------------------------------*/
550
551 if ( NULL == pBtampCtx )
552 {
553 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700554 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 return VOS_STATUS_E_FAULT;
556 }
557
558 vos_timer_start(
559 &pBtampCtx->bapLinkSupervisionTimer,
560 interval);
561
562 return VOS_STATUS_SUCCESS;
563}/* WLANBAP_StartLinkSupervisionTimer */
564
565/*==========================================================================
566
567 FUNCTION WLANBAP_StopLinkSupervisionTimer
568
569 DESCRIPTION
570 Stop the LinkSupervision Timer.
571
572 DEPENDENCIES
573
574 PARAMETERS
575
576 IN
577 pBtampCtx: pointer to the BAP control block
578
579 RETURN VALUE
580 The result code associated with performing the operation
581
582 VOS_STATUS_E_FAULT: access would cause a page fault
583 VOS_STATUS_SUCCESS: Everything is good :)
584
585 SIDE EFFECTS
586
587============================================================================*/
588VOS_STATUS
589WLANBAP_StopLinkSupervisionTimer
590(
591 ptBtampContext pBtampCtx
592)
593{
594 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
595 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
596
597
598 /*------------------------------------------------------------------------
599 Sanity check BAP control block
600 ------------------------------------------------------------------------*/
601
602 if ( NULL == pBtampCtx )
603 {
604 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700605 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700606 return VOS_STATUS_E_FAULT;
607 }
608
609 /*Stop the timer */
610 vosStatus = vos_timer_stop(
611 &pBtampCtx->bapLinkSupervisionTimer);
612
613
614 return VOS_STATUS_SUCCESS;
615}/* WLANBAP_StopLinkSupervisionTimer */
616
617
618/*==========================================================================
619
620 FUNCTION WLANBAP_LinkSupervisionTimerHandler
621
622 DESCRIPTION
623 Callback function registered with vos timer for the LinkSupervision timer
624
625 DEPENDENCIES
626
627 PARAMETERS
628
629 IN
630 userData: pointer can be used to retrive the BT-AMP context
631
632 RETURN VALUE
633 None
634
635 SIDE EFFECTS
636
637============================================================================*/
638v_VOID_t
639WLANBAP_LinkSupervisionTimerHandler
640(
641 v_PVOID_t userData
642)
643{
644 ptBtampContext pBtampCtx = (ptBtampContext)userData;
645 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
646 ptBtampHandle btampHandle = (ptBtampHandle)userData;
647 tWLAN_BAPEvent bapEvent; /* State machine event */
648 v_U8_t phy_link_handle;
649
650 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
651
652 /*-----------------------------------------------------------------------
653 Sanity check
654 -----------------------------------------------------------------------*/
655 if ( NULL == pBtampCtx )
656 {
657 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700658 "WLAN BAP: Fatal error in %s", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 VOS_ASSERT(0);
660 return;
661 }
662
663 phy_link_handle = pBtampCtx->phy_link_handle;
664 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700665 "WLAN BAP:In LinkSupervision Timer handler %s", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700666
667 if(pBtampCtx->dataPktPending == VOS_TRUE)
668 {
669 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700670 "%s: Data seen. Do nothing", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700671
672 pBtampCtx->dataPktPending = VOS_FALSE;
673 pBtampCtx->lsReqPktPending = VOS_FALSE;
674 pBtampCtx->retries = 0;
675 vosStatus = WLANBAP_StopLinkSupervisionTimer(pBtampCtx);
676 vosStatus = WLANBAP_StartLinkSupervisionTimer (pBtampCtx,
677 pBtampCtx->bapLinkSupervisionTimerInterval * WLANBAP_BREDR_BASEBAND_SLOT_TIME);
678
679 //Data is seen. or our previous packet is not yet fetched by TL.Don't do any thing.Just return;
680 return;
681 }
682 else if((pBtampCtx->lsReqPktPending == VOS_TRUE )
683 && (pBtampCtx->retries == WLANBAP_LINK_SUPERVISION_RETRIES))
684 {
685 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700686 "#########WLAN BAP: LinkSupervision Timed OUT######## %s", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700687
688 /*---------------------------------------------------------------------
689 Feed this timeout to the BTAMP FSM
690 ---------------------------------------------------------------------*/
691 /* Fill in the event structure */
692 /* JEZ110307: Which should this be? */
693 //bapEvent.event =eWLAN_BAP_HCI_PHYSICAL_LINK_DISCONNECT;
694 bapEvent.event =eWLAN_BAP_MAC_INDICATES_MEDIA_DISCONNECTION;
695 bapEvent.params = NULL;
696
697 /* Handle event */
698 vosStatus = btampFsm(pBtampCtx, &bapEvent, (v_U8_t *)&vosStatus);
699 }
700 else
701 {
702 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700703 "%s: Resend the LS packet", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700704
705 /* If we have transmit pkt pending and the time out occurred,resend the ls packet */
706 WLANBAP_StopLinkSupervisionTimer(pBtampCtx);
707 pBtampCtx->pPacket = pBtampCtx->lsReqPacket;
708 vosStatus = WLANBAP_TxLinkSupervision( btampHandle,
709 phy_link_handle,
710 pBtampCtx->pPacket ,
711 WLANTL_BT_AMP_TYPE_LS_REQ);
712 }
713
714}/*WLANBAP_LinkSupervisionTimerHandler*/
715
716/*==========================================================================
717
718 FUNCTION WLANBAP_StartTxPacketMonitorTimer
719
720 DESCRIPTION
721 Start the Tx Packet Monitor Timer.
722
723 DEPENDENCIES
724
725 PARAMETERS
726
727 IN
728 pBtampCtx: pointer to the BAP control block
729 interval: time interval.
730
731 RETURN VALUE
732 The result code associated with performing the operation
733
734 VOS_STATUS_E_FAULT: access would cause a page fault
735 VOS_STATUS_SUCCESS: Everything is good :)
736
737 SIDE EFFECTS
738
739============================================================================*/
740VOS_STATUS
741WLANBAP_StartTxPacketMonitorTimer
742(
743 ptBtampContext pBtampCtx
744)
745{
746 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
747 v_U32_t uInterval = WLAN_BAP_TX_PKT_MONITOR_TIME;
748 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
749
750
751 /*------------------------------------------------------------------------
752 Sanity check BAP control block
753 ------------------------------------------------------------------------*/
754 if ( NULL == pBtampCtx )
755 {
756 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700757 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 return VOS_STATUS_E_FAULT;
759 }
760
761 /*Start the timer */
762 vosStatus = vos_timer_start( &pBtampCtx->bapTxPktMonitorTimer,
763 uInterval);
764
765 return vosStatus;
766}/* WLANBAP_StartTxPacketMonitorTimer */
767
768
769/*==========================================================================
770
771 FUNCTION WLANBAP_StopTxPacketMonitorTimer
772
773 DESCRIPTION
774 Stop the Tx Packet Monitor Timer.
775
776 DEPENDENCIES
777
778 PARAMETERS
779
780 IN
781 pBtampCtx: pointer to the BAP control block
782
783 RETURN VALUE
784 The result code associated with performing the operation
785
786 VOS_STATUS_E_FAULT: access would cause a page fault
787 VOS_STATUS_SUCCESS: Everything is good :)
788
789 SIDE EFFECTS
790
791============================================================================*/
792VOS_STATUS
793WLANBAP_StopTxPacketMonitorTimer
794(
795 ptBtampContext pBtampCtx
796)
797{
798 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
799 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
800
801
802 /*------------------------------------------------------------------------
803 Sanity check BAP control block
804 ------------------------------------------------------------------------*/
805 if ( NULL == pBtampCtx )
806 {
807 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700808 "Invalid BAP pointer in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 return VOS_STATUS_E_FAULT;
810 }
811
812 /*Stop the timer */
813 vosStatus = vos_timer_stop( &pBtampCtx->bapTxPktMonitorTimer);
814
815
816 return vosStatus;
817}/* WLANBAP_StopTxPacketMonitorTimer */
818
819
820/*==========================================================================
821
822 FUNCTION WLANBAP_SendCompletedPktsEvent
823
824 DESCRIPTION
825 Utility function for sending the NUM_OF_COMPLETED_PKTS_EVENT to HCI
826
827 DEPENDENCIES
828
829 PARAMETERS
830
831 IN
832 pBtampCtx: pointer to the BAP control block
833
834 RETURN VALUE
835 None
836
837 SIDE EFFECTS
838
839============================================================================*/
840v_VOID_t
841WLANBAP_SendCompletedPktsEvent
842(
843 ptBtampContext pBtampCtx
844)
845{
846 v_U8_t i, j;
847 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
848 v_U32_t uTxCompleted = 0;
849 tpBtampLogLinkCtx pLogLinkContext = NULL;
850 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
851 /* Format the Number of completed packets event */
852 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_NUM_OF_COMPLETED_PKTS_EVENT;
853 bapHCIEvent.u.btampNumOfCompletedPktsEvent.num_handles = 0;
854
855 /*---------------------------------------------------------------------
856 Check if LL still exists, if TRUE generate num_pkt_event and
857 restart the timer
858 ---------------------------------------------------------------------*/
859 for (i = 0, j = 0; i < WLANBAP_MAX_LOG_LINKS ; i++)
860 {
861 pLogLinkContext = &pBtampCtx->btampLogLinkCtx[i];
862 if ( pLogLinkContext->present )
863 {
864 uTxCompleted = pLogLinkContext->uTxPktCompleted;
865 bapHCIEvent.u.btampNumOfCompletedPktsEvent.conn_handles[j] =
866 pLogLinkContext->log_link_handle;
867 bapHCIEvent.u.btampNumOfCompletedPktsEvent.num_completed_pkts[j] =
868 uTxCompleted;
869
870 j++;
871
872 vos_atomic_decrement_U32_by_value((v_U32_t *) &pLogLinkContext->uTxPktCompleted,
873 (v_U32_t) uTxCompleted);
874
875 if (uTxCompleted) {
876 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700877 "wlan bap: %s Log Link handle - %d No Of Pkts - %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 pLogLinkContext->log_link_handle, uTxCompleted);
879 }
880 }
881 }
882
883 /* Indicate only if at least one logical link is present and number of
884 completed packets is non zero */
885 if (j && uTxCompleted)
886 {
887 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
888 "WLAN BAP: Indicating Num Completed packets Event");
889
890 /*issue num_pkt_event for uTxCompleted*/
891 bapHCIEvent.u.btampNumOfCompletedPktsEvent.num_handles = j;
892 (*pBtampCtx->pBapHCIEventCB)
893 (
894 pBtampCtx->pHddHdl, /* this refers the BSL per application context */
895 &bapHCIEvent, /* This now encodes ALL event types */
896 VOS_TRUE /* Flag to indicate assoc-specific event */
897 );
898 }
899
900}
901
902/*==========================================================================
903
904 FUNCTION WLANBAP_SendCompletedDataBlksEvent
905
906 DESCRIPTION
907 Utility function for sending the NUM_OF_COMPLETED_DATA_BLOCKS_EVENT to HCI
908
909 DEPENDENCIES
910
911 PARAMETERS
912
913 IN
914 pBtampCtx: pointer to the BAP control block
915
916 RETURN VALUE
917 None
918
919 SIDE EFFECTS
920
921============================================================================*/
922v_VOID_t
923WLANBAP_SendCompletedDataBlksEvent
924(
925 ptBtampContext pBtampCtx
926)
927{
928 v_U8_t i, j;
929 tBtampHCI_Event bapHCIEvent; /* This now encodes ALL event types */
930 v_U32_t uTxCompleted = 0;
931 tpBtampLogLinkCtx pLogLinkContext = NULL;
932 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
933 /* Format the Number of completed data blocks event */
934 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_NUM_OF_COMPLETED_DATA_BLOCKS_EVENT;
935 bapHCIEvent.u.btampNumOfCompletedDataBlocksEvent.num_handles = 0;
936
937 /*---------------------------------------------------------------------
938 Check if LL still exists, if TRUE generate num_data_blocks_event and
939 restart the timer
940 ---------------------------------------------------------------------*/
941 for (i = 0, j = 0; i < WLANBAP_MAX_LOG_LINKS ; i++)
942 {
943 pLogLinkContext = &pBtampCtx->btampLogLinkCtx[i];
944 if ( pLogLinkContext->present )
945 {
946 uTxCompleted = pLogLinkContext->uTxPktCompleted;
947 bapHCIEvent.u.btampNumOfCompletedDataBlocksEvent.conn_handles[j] =
948 pLogLinkContext->log_link_handle;
949 bapHCIEvent.u.btampNumOfCompletedDataBlocksEvent.num_completed_pkts[j] =
950 uTxCompleted;
951 bapHCIEvent.u.btampNumOfCompletedDataBlocksEvent.num_completed_blocks[j] =
952 uTxCompleted;
953 bapHCIEvent.u.btampNumOfCompletedDataBlocksEvent.total_num_data_blocks = 16;
954
955 j++;
956
957 vos_atomic_decrement_U32_by_value((v_U32_t *) &pLogLinkContext->uTxPktCompleted,
958 (v_U32_t) uTxCompleted);
959
960 if (uTxCompleted) {
961 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700962 "wlan bap: %s Log Link handle - %d No Of Pkts - %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 pLogLinkContext->log_link_handle, uTxCompleted);
964 }
965 }
966 }
967
968 /* Indicate only if at least one logical link is present and number of
969 completed data blocks is non zero */
970 if (j && uTxCompleted)
971 {
972 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
973 "WLAN BAP: Indicating Num Completed Data Blocks Event");
974
975 /*issue num_data_blocks_event for uTxCompleted*/
976 bapHCIEvent.u.btampNumOfCompletedDataBlocksEvent.num_handles = j;
977 (*pBtampCtx->pBapHCIEventCB)
978 (
979 pBtampCtx->pHddHdl, /* this refers the BSL per application context */
980 &bapHCIEvent, /* This now encodes ALL event types */
981 VOS_TRUE /* Flag to indicate assoc-specific event */
982 );
983 }
984
985}
986
987/*==========================================================================
988
989 FUNCTION WLANBAP_TxPacketMonitorHandler
990
991 DESCRIPTION
992 Callback function registered with vos timer for the Tx Packet Monitor
993 Timer.
994
995 DEPENDENCIES
996
997 PARAMETERS
998
999 IN
1000 userData: pointer can be used to retrive the BT-AMP context
1001
1002 RETURN VALUE
1003 None
1004
1005 SIDE EFFECTS
1006
1007============================================================================*/
1008v_VOID_t
1009WLANBAP_TxPacketMonitorHandler
1010(
1011 v_PVOID_t userData
1012)
1013{
1014 ptBtampContext pBtampCtx = (ptBtampContext)userData;
1015 BTAMPFSM_INSTANCEDATA_T *instanceVar = &pBtampCtx->bapPhysLinkMachine;
1016 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1017
1018 /*-----------------------------------------------------------------------
1019 Sanity check
1020 -----------------------------------------------------------------------*/
1021 if ( NULL == pBtampCtx )
1022 {
1023 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001024 "WLAN BAP: Fatal error in %s", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 VOS_ASSERT(0);
1026 return;
1027 }
1028
1029#if 0 //BAP_DEBUG
1030 /* Trace the tBtampCtx being passed in. */
1031 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001032 "WLAN BAP Context Monitor: pBtampCtx value = %x in %s:%d", pBtampCtx, __func__, __LINE__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07001033#endif //BAP_DEBUG
1034
1035 if(WLANBAP_FLOW_CONTROL_MODE_BLOCK_BASED == pBtampCtx->ucDataTrafficMode)
1036 {
1037 WLANBAP_SendCompletedDataBlksEvent(pBtampCtx);
1038 }
1039 else
1040 {
1041 WLANBAP_SendCompletedPktsEvent(pBtampCtx);
1042 }
1043
1044 /* Restart the Packet monitoring timer if still Physical link
1045 * is present.
1046 * It is possible that when the physical link is tear down,
1047 * timer start request is in Q and could start again.
1048 */
1049 if (CONNECTED == instanceVar->stateVar)
1050 {
1051 WLANBAP_StartTxPacketMonitorTimer(pBtampCtx);
1052 }
1053}/*WLANBAP_TxPacketMonitorHandler*/
1054