blob: 7fbddf9433fd457feeab23d493d28d05e756e1b8 [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 \file bap_hdd_main.c
25
26 \brief 802.11 BT-AMP PAL Host Device Driver implementation
27
28 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
29
30 Qualcomm Confidential and Proprietary.
31
32 ========================================================================*/
33
34/**=========================================================================
35
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42
43 $Header: /prj/qct/asw/engbuilds/scl/users02/jzmuda/gb-bluez/vendor/qcom/proprietary/wlan/libra/CORE/HDD/src/bap_hdd_main.c,v 1.63 2011/04/01 15:24:20 jzmuda Exp jzmuda $ $DateTime: $ $Author: jzmuda $
44
45
46 when who what, where, why
47 -------- --- --------------------------------------------------------
48 12/1/09 JZmuda Created module.
49
50 ==========================================================================*/
51
52/*--------------------------------------------------------------------------
53 Include Files
54 ------------------------------------------------------------------------*/
55#ifdef WLAN_BTAMP_FEATURE
56#include <linux/kernel.h>
57#include <linux/types.h>
58#include <linux/miscdevice.h>
59#include <linux/platform_device.h>
60#include <linux/fs.h>
61#include <linux/file.h>
62#include <linux/spinlock.h>
63//#include <linux/delay.h>
64#include <linux/uaccess.h>
65#include <linux/io.h>
66//#include <wlan_qct_driver.h>
67#include <wlan_hdd_includes.h>
68#include <wlan_hdd_dp_utils.h>
69/* -------------------------------------------------------------------------*/
70#include <bap_hdd_main.h>
71#include <vos_api.h>
72#include <bapApi.h>
73#include <btampHCI.h>
74/* -------------------------------------------------------------------------*/
75#include <net/bluetooth/bluetooth.h>
76#include <net/bluetooth/hci_core.h>
77
78#ifdef WLAN_SOFTAP_FEATURE
79#include <wlan_hdd_misc.h>
80#endif
81/*----------------------------------------------------------------------------
82 * Preprocessor Definitions and Constants
83 * -------------------------------------------------------------------------*/
84
85// the difference between the next two is that the first is the max
86// number we support in our current implementation while the second is
87// the max allowed by the spec
88#define BSL_MAX_PHY_LINKS ( BSL_MAX_CLIENTS * BSL_MAX_PHY_LINK_PER_CLIENT )
89#define BSL_MAX_ALLOWED_PHY_LINKS 255
90
91// these likely will need tuning based on experiments
92#define BSL_MAX_RX_PKT_DESCRIPTOR 100
93#define BSL_MAX_TX_PKT_DESCRIPTOR 100
94
95// these caps are in place to not have run-away queues, again needs empirical tuning
96#define BSL_MAX_SIZE_TX_ACL_QUEUE 50
97#define BSL_MAX_SIZE_RX_ACL_QUEUE 50
98#define BSL_MAX_SIZE_RX_EVT_QUEUE 50
99
100#if 0
101What are the maximum sizes of a command packet, an event packet and an ACL
102data packet?
103
104[JimZ]: Sizes:
1051. Cmd Maximum size is slightly greater than 672 btyes. But I am pretty sure
106right now that I will never have more than 240 bytes to send down at a time. And
107that is good. Because some rather unpleasant things happen at the HCI interface
108if I exceed that. ( Think 8-bit CPUs. And the limitations of an 8-bit length
109 field. )
110
1112. Event - Ditto.
112
1133. Data 1492 bytes
114#endif
115
116// jimz
117// TLV related defines
118
119#define USE_FINAL_FRAMESC
120//#undef USE_FINAL_FRAMESC
121// jimz
122// TLV related defines
123
124#ifndef USE_FINAL_FRAMESC //USE_FINAL_FRAMESC
125// AMP ASSOC TLV related defines
126#define AMP_ASSOC_TLV_TYPE_SIZE 2
127#define AMP_ASSOC_TLV_LEN_SIZE 2
128#define AMP_ASSOC_TLV_TYPE_AND_LEN_SIZE (AMP_ASSOC_TLV_TYPE_SIZE + AMP_ASSOC_TLV_LEN_SIZE)
129
130// FLOW SPEC TLV related defines
131#define FLOWSPEC_TYPE_SIZE 2
132#define FLOWSPEC_LEN_SIZE 2
133#define FLOWSPEC_TYPE_AND_LEN_SIZE (FLOWSPEC_TYPE_SIZE + FLOWSPEC_LEN_SIZE)
134
135// CMD TLV related defines
136#define CMD_TLV_TYPE_SIZE 2
137#define CMD_TLV_LEN_SIZE 2
138#define CMD_TLV_TYPE_AND_LEN_SIZE (CMD_TLV_TYPE_SIZE + CMD_TLV_LEN_SIZE)
139
140// Event TLV related defines
141#define EVENT_TLV_TYPE_SIZE 2
142#define EVENT_TLV_LEN_SIZE 2
143#define EVENT_TLV_TYPE_AND_LEN_SIZE (EVENT_TLV_TYPE_SIZE + EVENT_TLV_LEN_SIZE)
144
145// Data header size related defines
146#define DATA_HEADER_SIZE 4
147
148#else //USE_FINAL_FRAMESC
149
150// AMP ASSOC TLV related defines
151#define AMP_ASSOC_TLV_TYPE_SIZE 1
152#define AMP_ASSOC_TLV_LEN_SIZE 2
153#define AMP_ASSOC_TLV_TYPE_AND_LEN_SIZE (AMP_ASSOC_TLV_TYPE_SIZE + AMP_ASSOC_TLV_LEN_SIZE)
154
155// FLOW SPEC TLV related defines
156#define FLOWSPEC_TYPE_SIZE 1
157#define FLOWSPEC_LEN_SIZE 1
158#define FLOWSPEC_TYPE_AND_LEN_SIZE (FLOWSPEC_TYPE_SIZE + FLOWSPEC_LEN_SIZE)
159
160// CMD TLV related defines
161#define CMD_TLV_TYPE_SIZE 2
162#define CMD_TLV_LEN_SIZE 1
163#define CMD_TLV_TYPE_AND_LEN_SIZE (CMD_TLV_TYPE_SIZE + CMD_TLV_LEN_SIZE)
164
165// Event TLV related defines
166#define EVENT_TLV_TYPE_SIZE 1
167#define EVENT_TLV_LEN_SIZE 1
168#define EVENT_TLV_TYPE_AND_LEN_SIZE (EVENT_TLV_TYPE_SIZE + EVENT_TLV_LEN_SIZE)
169
170// Data header size related defines
171#define DATA_HEADER_SIZE 4
172
173#endif // USE_FINAL_FRAMESC
174// jimz
175
176#define BSL_MAX_EVENT_SIZE 700
177
178#define BSL_DEV_HANDLE 0x1234
179
180// Debug related defines
181#define DBGLOG printf
182//#define DUMPLOG
183#if defined DUMPLOG
184#define DUMPLOG(n, name1, name2, aStr, size) \
185 if (1) \
186{\
187 int i;\
188 DBGLOG("%d. %s: %s = \n", n, name1, name2); \
189 for (i = 0; i < size; i++) \
190 DBGLOG("%2.2x%s", ((unsigned char *)aStr)[i], i % 16 == 15 ? "\n" : " "); \
191 DBGLOG("\n"); \
192}
193#else
194#define DUMPLOG(n, name1, name2, aStr, size)
195#endif
196
197// These are required to replace some Microsoft specific specifiers
198//#define UNALIGNED __align
199#define UNALIGNED
200#define INFINITE 0
201
202#define BT_AMP_HCI_CTX_MAGIC 0x48434949 // "HCII"
203
204/*----------------------------------------------------------------------------
205 * Type Declarations
206 * -------------------------------------------------------------------------*/
207
208// Temporary Windows types
209typedef int BOOL;
210typedef unsigned char BYTE;
211typedef unsigned short WORD;
212typedef unsigned long DWORD;
213typedef void * HANDLE;
214typedef char TCHAR;
215typedef void *LPVOID;
216typedef const void *LPCVOID;
217
218typedef struct
219{
220 BOOL used; // is this a valid context?
221 vos_event_t ReadableEvt; // the event a ReadFile can block on
222 ptBtampHandle bapHdl; // our handle in BAP
223 vos_list_t PhyLinks; // a list of all associations setup by this client
224// Newly added for BlueZ
225 struct hci_dev *hdev; // the BlueZ HCI device structure
226
227 /* I don't know how many of these Tx fields we need */
228 spinlock_t lock; /* For serializing operations */
229
230 struct sk_buff_head txq; /* We need the ACL Data Tx queue */
231
232 /* We definitely need some of these rx_skb fields */
233 unsigned long rx_state;
234 unsigned long rx_count;
235 struct sk_buff *rx_skb;
236
237 struct net_device *p_dev; // Our parent wlan network device
238
239} BslClientCtxType;
240
241typedef struct
242{
243 BslClientCtxType* pctx;
244 /* Tx skb queue and the workstructure for handling Tx as deferred work. */
245 struct sk_buff *tx_skb;
246
247 struct work_struct hciInterfaceProcessing;
248 v_U32_t magic;
249
250} BslHciWorkStructure;
251
252typedef struct
253{
254 TCHAR* ValueName; // name of the value
255 DWORD Type; // type of value
256 DWORD DwordValue; // DWORD value
257 TCHAR* StringValue; // string value
258
259} BslRegEntry;
260
261typedef struct
262{
263 BOOL used; // is this a valid context?
264 hdd_list_t ACLTxQueue[WLANTL_MAX_AC]; // the TX ACL queues
265 BslClientCtxType* pClientCtx; // ptr to application context that spawned
266 // this association
267 v_U8_t PhyLinkHdl; // BAP handle for this association
268 void* pPhyLinkDescNode; // ptr to node in list of assoc in client ctx
269 // real type BslPhyLinksNodeType*
270
271} BslPhyLinkCtxType;
272
273typedef struct
274{
275 vos_list_node_t node; // MUST be first element
276 BslPhyLinkCtxType* pPhy; // ptr to an association context
277
278} BslPhyLinksNodeType;
279
280typedef struct
281{
282 vos_list_node_t node; // MUST be first element
283 vos_pkt_t* pVosPkt; // ptr to a RX VoS pkt which can hold an HCI event or ACL data
284
285} BslRxListNodeType;
286
287// Borrowed from wlan_hdd_dp_utils.h
288typedef struct
289{
290 hdd_list_node_t node; // MUST be first element
291 struct sk_buff * skb; // ptr to the ACL data
292
293} BslTxListNodeType;
294
295typedef struct
296{
297 BslPhyLinkCtxType* ptr; // ptr to the association context for this phy_link_handle
298
299} BslPhyLinkMapEntryType;
300
301/*----------------------------------------------------------------------------
302 * Global Data Definitions
303 * -------------------------------------------------------------------------*/
304BslClientCtxType* gpBslctx;
305
306/*----------------------------------------------------------------------------
307 * Static Variable Definitions
308 * -------------------------------------------------------------------------*/
309// Temporary (until multi-phy link) pointer to BT-AMP context
310static void *gpCtx;
311
312// an efficient lookup from phy_link_handle to phy link context
313static BslPhyLinkMapEntryType BslPhyLinkMap[BSL_MAX_ALLOWED_PHY_LINKS];
314
315//static HANDLE hBsl = NULL; //INVALID_HANDLE_VALUE;
316static BOOL bBslInited = FALSE;
317
318static BslClientCtxType BslClientCtx[BSL_MAX_CLIENTS];
319//static vos_lock_t BslClientLock;
320
321static BslPhyLinkCtxType BslPhyLinkCtx[BSL_MAX_PHY_LINKS];
322//static vos_lock_t BslPhyLock;
323
324// the pool for association contexts
325static vos_list_t BslPhyLinksDescPool;
326static BslPhyLinksNodeType BslPhyLinksDesc[BSL_MAX_PHY_LINKS];
327
328//static v_U32_t Eventlen = 0;
329
330/*---------------------------------------------------------------------------
331 * Forward declarations
332 *-------------------------------------------------------------------------*/
333static void bslWriteFinish(struct work_struct *work);
334
335/*---------------------------------------------------------------------------
336 * Driver Entry points and Structure definitions
337 *-------------------------------------------------------------------------*/
338static int BSL_Open (struct hci_dev *hdev);
339static int BSL_Close (struct hci_dev *hdev);
340static int BSL_Flush(struct hci_dev *hdev);
341static int BSL_IOControl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
342static int BSL_Write(struct sk_buff *skb);
343#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
344static void BSL_Destruct(struct hci_dev *hdev);
345#endif
346
347
348/*----------------------------------------------------------------------------
349 * Static Function Declarations and Definitions
350 * -------------------------------------------------------------------------*/
351static v_BOOL_t WLANBAP_AmpConnectionAllowed(void)
352{
353 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
354 hdd_context_t *pHddCtx;
355 v_BOOL_t retVal = VOS_FALSE;
356
357 if (NULL != pVosContext)
358 {
359 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
360 if (NULL != pHddCtx)
361 {
362 return pHddCtx->isAmpAllowed;
363 }
364 else
365 {
366 return retVal;
367 }
368 }
369 return retVal;
370}
371
372/**
373 @brief WLANBAP_STAFetchPktCB() - The fetch packet callback registered
374 with BAP by HDD.
375
376 It is called by the BAP immediately upon the underlying
377 WLANTL_STAFetchPktCBType routine being called. Which is called by
378 TL when the scheduling algorithms allows for transmission of another
379 packet to the module.
380
381 This function is here to "wrap" or abstract WLANTL_STAFetchPktCBType.
382 Because the BAP-specific HDD "shim" layer (BSL) doesn't know anything
383 about STAIds, or other parameters required by TL.
384
385 @param pHddHdl: [in] The HDD(BSL) specific context for this association.
386 Use the STAId passed to me by TL in WLANTL_STAFetchCBType to retreive
387 this value.
388 @param pucAC: [inout] access category requested by TL, if HDD does not
389 have packets on this AC it can choose to service another AC queue in
390 the order of priority
391 @param vosDataBuff: [out] pointer to the VOSS data buffer that was
392 transmitted
393 @param tlMetaInfo: [out] meta info related to the data frame
394
395 @return
396 The result code associated with performing the operation
397*/
398static VOS_STATUS WLANBAP_STAFetchPktCB
399(
400 v_PVOID_t pHddHdl,
401 WLANTL_ACEnumType ucAC,
402 vos_pkt_t** vosDataBuff,
403 WLANTL_MetaInfoType* tlMetaInfo
404)
405{
406 BslPhyLinkCtxType* pPhyCtx;
407 VOS_STATUS VosStatus;
408 v_U8_t AcIdxStart;
409 v_U8_t AcIdx;
410 hdd_list_node_t *pLink;
411 BslTxListNodeType *pNode;
412 struct sk_buff * skb;
413 BslClientCtxType* pctx;
414 WLANTL_ACEnumType Ac;
415 vos_pkt_t* pVosPkt;
416 WLANTL_MetaInfoType TlMetaInfo;
417 pctx = &BslClientCtx[0];
418
419 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "WLANBAP_STAFetchPktCB\n" );
420
421 // sanity checking
422 if( pHddHdl == NULL || vosDataBuff == NULL ||
423 tlMetaInfo == NULL || ucAC >= WLANTL_MAX_AC || ucAC < 0 )
424 {
425 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_STAFetchPktCB bad input\n" );
426 return VOS_STATUS_E_FAILURE;
427 }
428
429 // Initialize the VOSS packet returned to NULL - in case of error
430 *vosDataBuff = NULL;
431
432 pPhyCtx = (BslPhyLinkCtxType *)pHddHdl;
433 AcIdx = AcIdxStart = ucAC;
434
435 spin_lock_bh(&pPhyCtx->ACLTxQueue[AcIdx].lock);
436 VosStatus = hdd_list_remove_front( &pPhyCtx->ACLTxQueue[AcIdx], &pLink );
437 spin_unlock_bh(&pPhyCtx->ACLTxQueue[AcIdx].lock);
438
439 if ( VOS_STATUS_E_EMPTY == VosStatus )
440 {
441 do
442 {
443 AcIdx = (AcIdx + 1) % WLANTL_MAX_AC;
444
445 spin_lock_bh(&pPhyCtx->ACLTxQueue[AcIdx].lock);
446 VosStatus = hdd_list_remove_front( &pPhyCtx->ACLTxQueue[AcIdx], &pLink );
447 spin_unlock_bh(&pPhyCtx->ACLTxQueue[AcIdx].lock);
448
449 }
450 while ( VosStatus == VOS_STATUS_E_EMPTY && AcIdx != AcIdxStart );
451
452 if ( VosStatus == VOS_STATUS_E_EMPTY )
453 {
454 // Queue is empty. This can happen. Just return NULL back to TL...
455 return(VOS_STATUS_E_EMPTY);
456 }
457 else if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
458 {
459 VOS_ASSERT( 0 );
460 }
461 }
462
463 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
464 {
465 VOS_ASSERT( 0 );
466 }
467
468 pNode = (BslTxListNodeType *)pLink;
469 skb = pNode->skb;
470
471 // I will access the skb in a VOSS packet
472 // Wrap the OS provided skb in a VOSS packet
473 // Attach skb to VOS packet.
474 VosStatus = vos_pkt_wrap_data_packet( &pVosPkt,
475 VOS_PKT_TYPE_TX_802_3_DATA,
476 skb,
477 NULL,
478 NULL);
479
480 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
481 {
482 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_STAFetchPktCB vos_pkt_wrap_data_packet "
483 "failed status =%d\n", VosStatus );
484 kfree_skb(skb);
485 return VosStatus;
486 }
487
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700488 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO, "%s: pVosPkt(vos_pkt_t *)=%p\n", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 pVosPkt );
490
491 VosStatus = WLANBAP_XlateTxDataPkt( pctx->bapHdl, pPhyCtx->PhyLinkHdl,
492 &Ac, &TlMetaInfo, pVosPkt);
493
494 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
495 {
496 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_STAFetchPktCB WLANBAP_XlateTxDataPkt "
497 "failed status =%d\n", VosStatus );
498
499 // return the packet
500 VosStatus = vos_pkt_return_packet( pVosPkt );
501 kfree_skb(skb);
502 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
503
504 return VosStatus;
505 }
506 // give TL the VoS pkt
507 *vosDataBuff = pVosPkt;
508
509 // provide the meta-info BAP provided previously
510 *tlMetaInfo = TlMetaInfo;
511
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700512 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: *vosDataBuff(vos_pkt_t *)=%p\n", __func__, *vosDataBuff );
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
514 return(VOS_STATUS_SUCCESS);
515} // WLANBAP_STAFetchPktCB()
516
517/**
518 @brief WLANBAP_STARxCB() - The receive callback registered with BAP by HDD.
519
520 It is called by the BAP immediately upon the underlying
521 WLANTL_STARxCBType routine being called. Which is called by
522 TL to notify when a packet was received for a registered STA.
523
524 @param pHddHdl: [in] The HDD(BSL) specific context for this association.
525 Use the STAId passed to me by TL in WLANTL_STARxCBType to retrieve this value.
526 @param vosDataBuff: [in] pointer to the VOSS data buffer that was received
527 (it may be a linked list)
528 @param pRxMetaInfo: [in] Rx meta info related to the data frame
529
530 @return
531 The result code associated with performing the operation
532*/
533static VOS_STATUS WLANBAP_STARxCB
534(
535 v_PVOID_t pHddHdl,
536 vos_pkt_t* vosDataBuff,
537 WLANTL_RxMetaInfoType* pRxMetaInfo
538)
539{
540 BslPhyLinkCtxType* pctx;
541 BslClientCtxType* ppctx;
542 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
543 WLANTL_ACEnumType Ac; // this is not needed really
544 struct sk_buff *skb = NULL;
545 vos_pkt_t* pVosPacket;
546 vos_pkt_t* pNextVosPacket;
547
548 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "WLANBAP_STARxCB\n" );
549
550 // sanity checking
551 if ( pHddHdl == NULL || vosDataBuff == NULL || pRxMetaInfo == NULL )
552 {
553 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_STARxCB bad input\n" );
554 if(NULL != vosDataBuff)
555 {
556 VosStatus = vos_pkt_return_packet( vosDataBuff );
557 }
558 return VOS_STATUS_E_FAILURE;
559 }
560
561 pctx = (BslPhyLinkCtxType *)pHddHdl;
562 ppctx = pctx->pClientCtx;
563
564 if( NULL == ppctx )
565 {
566 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_STARxCB ClientCtx is NULL\n" );
567 VosStatus = vos_pkt_return_packet( vosDataBuff );
568 return VOS_STATUS_E_FAILURE;
569 }
570
571 // walk the chain until all are processed
572 pVosPacket = vosDataBuff;
573 do
574 {
575 // get the pointer to the next packet in the chain
576 // (but don't unlink the packet since we free the entire chain later)
577 VosStatus = vos_pkt_walk_packet_chain( pVosPacket, &pNextVosPacket, VOS_FALSE);
578
579 // both "success" and "empty" are acceptable results
580 if (!((VosStatus == VOS_STATUS_SUCCESS) || (VosStatus == VOS_STATUS_E_EMPTY)))
581 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,"%s: Failure walking packet chain", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 return VOS_STATUS_E_FAILURE;
584 }
585
586 // process the packet
587 VosStatus = WLANBAP_XlateRxDataPkt( ppctx->bapHdl, pctx->PhyLinkHdl,
588 &Ac, pVosPacket );
589
590 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
591 {
592 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_FATAL, "WLANBAP_STARxCB WLANBAP_XlateRxDataPkt "
593 "failed status = %d\n", VosStatus );
594
595 VosStatus = VOS_STATUS_E_FAILURE;
596
597 break;
598 }
599
600 // Extract the OS packet (skb).
601 // Tell VOS to detach the OS packet from the VOS packet
602 VosStatus = vos_pkt_get_os_packet( pVosPacket, (v_VOID_t **)&skb, VOS_TRUE );
603 if(!VOS_IS_STATUS_SUCCESS( VosStatus ))
604 {
605 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s: Failure extracting skb from vos pkt. "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700606 "VosStatus = %d\n", __func__, VosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700607
608 VosStatus = VOS_STATUS_E_FAILURE;
609
610 break;
611 }
612
613 //JEZ100809: While an skb is being handled by the kernel, is "skb->dev" de-ref'd?
614 skb->dev = (struct net_device *) gpBslctx->hdev;
615 bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
616 //skb->protocol = eth_type_trans(skb, skb->dev);
617 //skb->ip_summed = CHECKSUM_UNNECESSARY;
618
619 // This is my receive skb pointer
620 gpBslctx->rx_skb = skb;
621
622 // This is how data and events are passed up to BlueZ
623 hci_recv_frame(gpBslctx->rx_skb);
624
625 // now process the next packet in the chain
626 pVosPacket = pNextVosPacket;
627
628 } while (pVosPacket);
629
630
631 //JEZ100922: We are free to return the enclosing VOSS packet.
632 VosStatus = vos_pkt_return_packet( vosDataBuff );
633 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
634
635
636 return(VOS_STATUS_SUCCESS);
637} // WLANBAP_STARxCB()
638
639/**
640 @brief WLANBAP_TxCompCB() - The Tx complete callback registered with BAP by HDD.
641
642 It is called by the BAP immediately upon the underlying
643 WLANTL_TxCompCBType routine being called. Which is called by
644 TL to notify when a transmission for a packet has ended.
645
646 @param pHddHdl: [in] The HDD(BSL) specific context for this association
647 @param vosDataBuff: [in] pointer to the VOSS data buffer that was transmitted
648 @param wTxSTAtus: [in] status of the transmission
649
650 @return
651 The result code associated with performing the operation
652*/
653extern v_VOID_t WLANBAP_TxPacketMonitorHandler ( v_PVOID_t ); // our handle in BAP
654
655static VOS_STATUS WLANBAP_TxCompCB
656(
657 v_PVOID_t pHddHdl,
658 vos_pkt_t* vosDataBuff,
659 VOS_STATUS wTxSTAtus
660)
661{
662 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
663 //BslTxListNodeType* pTxNode;
664 void* pOsPkt = NULL;
665 BslPhyLinkCtxType* pctx;
666 BslClientCtxType* ppctx;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700667 static int num_packets;
Jeff Johnson295189b2012-06-20 16:38:30 -0700668
669 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO, "WLANBAP_TxCompCB. vosDataBuff(vos_pkt_t *)=%p\n", vosDataBuff );
670
671 // be aware that pHddHdl can be NULL or can point to the per association
672 // BSL context from the register data plane. In either case it does not
673 // matter since we will simply free the VoS pkt and reclaim the TX
674 // descriptor
675
676 // sanity checking
677 if ( vosDataBuff == NULL )
678 {
679 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_TxCompCB bad input\n" );
680 return VOS_STATUS_E_FAILURE;
681 }
682
683 //Return the skb to the OS
684 VosStatus = vos_pkt_get_os_packet( vosDataBuff, &pOsPkt, VOS_TRUE );
685 if(!VOS_IS_STATUS_SUCCESS( VosStatus ))
686 {
687 //This is bad but still try to free the VOSS resources if we can
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: Failure extracting skb from vos pkt", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 vos_pkt_return_packet( vosDataBuff );
690 return VOS_STATUS_E_FAILURE;
691 }
692
693 kfree_skb((struct sk_buff *)pOsPkt);
694
695 //Return the VOS packet resources.
696 VosStatus = vos_pkt_return_packet( vosDataBuff );
697
698 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
699 {
700 VOS_ASSERT(0);
701 }
702
703 // JEZ110330: Now signal the layer above me...that I have released some packets.
704 pctx = (BslPhyLinkCtxType *)pHddHdl;
705 ppctx = pctx->pClientCtx;
706 num_packets = (num_packets + 1) % 4;
707 if (num_packets == 0 )
708 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700709 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO, "%s: Sending up number of completed packets. num_packets = %d.\n", __func__, num_packets );
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 WLANBAP_TxPacketMonitorHandler ( (v_PVOID_t) ppctx->bapHdl ); // our handle in BAP
711 }
712
713 return(VOS_STATUS_SUCCESS);
714} // WLANBAP_TxCompCB()
715
716/**
717 @brief BslFlushTxQueues() - flush the Tx queues
718
719 @param pPhyCtx : [in] ptr to the phy context whose queues need to be flushed
720
721 @return
722 VOS_STATUS
723
724*/
725static VOS_STATUS BslFlushTxQueues
726(
727 BslPhyLinkCtxType* pPhyCtx
728)
729{
730 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
731 v_SINT_t i = -1;
732 hdd_list_node_t* pLink;
733 BslTxListNodeType *pNode;
734
735
736 if(TRUE == pPhyCtx->used)
737 {
738 while (++i != WLANTL_MAX_AC)
739 {
740 //Free up any packets in the Tx queue
741 spin_lock_bh(&pPhyCtx->ACLTxQueue[i].lock);
742 while (true)
743 {
744 VosStatus = hdd_list_remove_front(&pPhyCtx->ACLTxQueue[i], &pLink );
745 if(VOS_STATUS_E_EMPTY != VosStatus)
746 {
747 pNode = (BslTxListNodeType *)pLink;
748 kfree_skb(pNode->skb);
749 continue;
750 }
751 break;
752 }
753 spin_unlock_bh(&pPhyCtx->ACLTxQueue[i].lock);
754 }
755 }
756 return(VOS_STATUS_SUCCESS);
757} // BslFlushTxQueues
758
759
760/**
761 @brief BslReleasePhyCtx() - this function will free up an association context
762
763 @param pPhyCtx : [in] ptr to the phy context to release
764
765 @return
766 None
767
768*/
769static void BslReleasePhyCtx
770(
771 BslPhyLinkCtxType* pPhyCtx
772)
773{
774 v_U32_t OldMapVal;
775 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
776
777 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslReleasePhyCtx\n" );
778
779 pPhyCtx->used = FALSE;
780
781
782 if (BslPhyLinkMap[pPhyCtx->PhyLinkHdl].ptr == NULL) return;
783
784
785 // update the phy link handle based map so TX data is stopped from flowing through
786 OldMapVal = vos_atomic_set_U32( (v_U32_t *) (BslPhyLinkMap[pPhyCtx->PhyLinkHdl].ptr),
787 (v_U32_t) 0 );
788
789 // clear out the Tx Queues
790 VosStatus = BslFlushTxQueues(pPhyCtx);
791
792 // clear out the parent ptr
793 // pPhyCtx->pClientCtx = NULL;//commented to debug exception
794
795 // we also need to remove this assocation from the list of active
796 // associations maintained in the application context
797 if( pPhyCtx->pPhyLinkDescNode )
798 {
799 VosStatus = vos_list_remove_node( &pPhyCtx->pClientCtx->PhyLinks,
800 &((BslPhyLinksNodeType*)pPhyCtx->pPhyLinkDescNode)->node);
801 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
802 //Return the PhyLink handle to the free pool
803 VosStatus = vos_list_insert_front(&BslPhyLinksDescPool,&((BslPhyLinksNodeType*)pPhyCtx->pPhyLinkDescNode)->node);
804 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
805
806 pPhyCtx->pPhyLinkDescNode = NULL;
807 }
808 pPhyCtx->pClientCtx = NULL;//Moved here to bebug the exception
809
810 pPhyCtx->used = FALSE;
811
812} // BslReleasePhyCtx()
813
814/**
815 @brief WLAN_BAPEventCB() - Implements the callback for ALL asynchronous events.
816
817 Including Events resulting from:
818 * HCI Create Physical Link,
819 * Disconnect Physical Link,
820 * Create Logical Link,
821 * Flow Spec Modify,
822 * HCI Reset,
823 * HCI Flush,...
824
825 Also used to return sync events locally by BSL
826
827 @param pHddHdl: [in] The HDD(BSL) specific context for this association.
828 BSL gets this from the downgoing packets Physical handle value.
829 @param pBapHCIEvent: [in] pointer to the union of "HCI Event" structures.
830 Contains all info needed for HCI event.
831 @param AssocSpecificEvent: [in] flag indicates assoc-specific (1) or
832 global (0) event
833
834 @return
835 The result code associated with performing the operation
836
837 VOS_STATUS_E_FAULT: pointer to pBapHCIEvent is NULL
838 VOS_STATUS_SUCCESS: Success
839*/
840static VOS_STATUS WLANBAP_EventCB
841(
842 v_PVOID_t pHddHdl, /* this could refer to either the BSL per
843 association context which got passed in during
844 register data plane OR the BSL per application
845 context passed in during register BAP callbacks
846 based on setting of the Boolean flag below */
847 tpBtampHCI_Event pBapHCIEvent, /* This now encodes ALL event types including
848 Command Complete and Command Status*/
849 v_BOOL_t AssocSpecificEvent /* Flag to indicate global or assoc-specific event */
850)
851{
852 BslClientCtxType* pctx;
853 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
854 vos_pkt_t* pVosPkt;
855 v_U32_t PackStatus;
856 static v_U8_t Buff[BSL_MAX_EVENT_SIZE]; // stack overflow?
857 v_U32_t Written = 0; // FramesC REQUIRES this
858 v_U32_t OldMapVal;
859 struct sk_buff *skb = NULL;
860
861 // sanity checking
862 if ( pBapHCIEvent == NULL )
863 {
864 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB bad input\n" );
865 return VOS_STATUS_E_FAILURE;
866 }
867
868 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB event=%d "
869 "assoc_specific=%d\n", pBapHCIEvent->bapHCIEventCode, AssocSpecificEvent );
870
871 if ( pHddHdl == NULL )
872 {
873 /* Consider the following error scenarios to bypass the NULL check:
874 - create LL without a call for create PL before
875 - delete LL or PL when no AMP connection has been established yet
876 Client context is unimportant from HCI point of view, only needed by the TLV API in BAP
877 TODO: Change the TLV APIs to not to carry the client context; it doesn't use it anyway
878 */
879 if (( AssocSpecificEvent ) &&
880 (BTAMP_TLV_HCI_PHYSICAL_LINK_COMPLETE_EVENT != pBapHCIEvent->bapHCIEventCode) &&
881 (BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_COMPLETE_EVENT != pBapHCIEvent->bapHCIEventCode))
882 {
883 pctx = gpBslctx;
884 }
885 else
886 {
887 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_FATAL, "WLANBAP_EventCB bad input\n" );
888 return VOS_STATUS_E_FAILURE;
889 }
890 }
891
892
893 if(NULL != pHddHdl)
894 {
895 if ( AssocSpecificEvent )
896 {
897 // get the app context from the assoc context
898 pctx = ((BslPhyLinkCtxType *)pHddHdl)->pClientCtx;
899 }
900 else
901 {
902 pctx = (BslClientCtxType *)pHddHdl;
903 }
904 }
905
906 if(NULL == pctx)
907 {
908 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700909 "pctx is NULL in %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
911 return VOS_STATUS_E_FAULT;
912
913 }
914
915 VosStatus = vos_pkt_get_packet( &pVosPkt, VOS_PKT_TYPE_RX_RAW,
916 BSL_MAX_EVENT_SIZE, 1, 0, NULL, NULL);
917
918 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
919 {
920 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB vos_pkt_get_packet "
921 "failed status=%d\n", VosStatus );
922 return(VosStatus);
923 }
924
925 switch ( pBapHCIEvent->bapHCIEventCode )
926 {
927 /** BT events */
928 case BTAMP_TLV_HCI_COMMAND_COMPLETE_EVENT:
929 {
930 /*
931 BTAMP_TLV_HCI_RESET_CMD:
932 BTAMP_TLV_HCI_FLUSH_CMD:
933 BTAMP_TLV_HCI_LOGICAL_LINK_CANCEL_CMD:
934 BTAMP_TLV_HCI_SET_EVENT_MASK_CMD:
935 BTAMP_TLV_HCI_READ_CONNECTION_ACCEPT_TIMEOUT_CMD:
936 BTAMP_TLV_HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_CMD:
937 BTAMP_TLV_HCI_READ_LINK_SUPERVISION_TIMEOUT_CMD:
938 BTAMP_TLV_HCI_WRITE_LINK_SUPERVISION_TIMEOUT_CMD:
939 BTAMP_TLV_HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_CMD:
940 BTAMP_TLV_HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_CMD:
941 BTAMP_TLV_HCI_SET_EVENT_MASK_PAGE_2_CMD:
942 BTAMP_TLV_HCI_READ_LOCATION_DATA_CMD:
943 BTAMP_TLV_HCI_WRITE_LOCATION_DATA_CMD:
944 BTAMP_TLV_HCI_READ_FLOW_CONTROL_MODE_CMD:
945 BTAMP_TLV_HCI_WRITE_FLOW_CONTROL_MODE_CMD:
946 BTAMP_TLV_HCI_READ_BEST_EFFORT_FLUSH_TO_CMD:
947 BTAMP_TLV_HCI_WRITE_BEST_EFFORT_FLUSH_TO_CMD:
948 BTAMP_TLV_HCI_SET_SHORT_RANGE_MODE_CMD:
949 BTAMP_TLV_HCI_READ_LOCAL_VERSION_INFORMATION_CMD:
950 BTAMP_TLV_HCI_READ_LOCAL_SUPPORTED_COMMANDS_CMD:
951 BTAMP_TLV_HCI_READ_BUFFER_SIZE_CMD:
952 BTAMP_TLV_HCI_READ_DATA_BLOCK_SIZE_CMD:
953 BTAMP_TLV_HCI_READ_FAILED_CONTACT_COUNTER_CMD:
954 BTAMP_TLV_HCI_RESET_FAILED_CONTACT_COUNTER_CMD:
955 BTAMP_TLV_HCI_READ_LINK_QUALITY_CMD:
956 BTAMP_TLV_HCI_READ_RSSI_CMD:
957 BTAMP_TLV_HCI_READ_LOCAL_AMP_INFORMATION_CMD:
958 BTAMP_TLV_HCI_READ_LOCAL_AMP_ASSOC_CMD:
959 BTAMP_TLV_HCI_WRITE_REMOTE_AMP_ASSOC_CMD:
960 BTAMP_TLV_HCI_READ_LOOPBACK_MODE_CMD:
961 BTAMP_TLV_HCI_WRITE_LOOPBACK_MODE_CMD:
962 BTAMP_TLV_HCI_VENDOR_SPECIFIC_CMD_0:
963
964 */
965
966 // pack
967 PackStatus = btampPackTlvHCI_Command_Complete_Event( pctx,
968 &pBapHCIEvent->u.btampCommandCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
969
970 if ( !BTAMP_SUCCEEDED( PackStatus ) )
971 {
972 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampPackTlvHCI_Command_Complete_Event failed status %d", PackStatus);
973 // handle the error
974 VosStatus = vos_pkt_return_packet( pVosPkt );
975
976 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
977
978 return(VOS_STATUS_E_FAILURE);
979 }
980
981 break;
982 }
983 case BTAMP_TLV_HCI_COMMAND_STATUS_EVENT:
984 {
985 // pack
986 PackStatus = btampPackTlvHCI_Command_Status_Event( pctx,
987 &pBapHCIEvent->u.btampCommandStatusEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
988
989 if ( !BTAMP_SUCCEEDED( PackStatus ) )
990 {
991 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampPackTlvHCI_Command_Status_Event failed status %d", PackStatus);
992 // handle the error
993 VosStatus = vos_pkt_return_packet( pVosPkt );
994
995 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
996
997 return(VOS_STATUS_E_FAILURE);
998 }
999
1000 break;
1001 }
1002 case BTAMP_TLV_HCI_NUM_OF_COMPLETED_PKTS_EVENT:
1003 {
1004 // pack
1005 PackStatus = btampPackTlvHCI_Num_Completed_Pkts_Event( pctx,
1006 &pBapHCIEvent->u.btampNumOfCompletedPktsEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1007
1008 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1009 {
1010 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampPackTlvHCI_Num_Completed_Pkts_Event failed status %d", PackStatus);
1011 // handle the error
1012 VosStatus = vos_pkt_return_packet( pVosPkt );
1013
1014 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1015
1016 return(VOS_STATUS_E_FAILURE);
1017 }
1018
1019 break;
1020 }
1021 case BTAMP_TLV_HCI_NUM_OF_COMPLETED_DATA_BLOCKS_EVENT:
1022 {
1023 // pack
1024 PackStatus = btampPackTlvHCI_Num_Completed_Data_Blocks_Event( pctx,
1025 &pBapHCIEvent->u.btampNumOfCompletedDataBlocksEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1026
1027 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1028 {
1029 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampPackTlvHCI_Num_Completed_Data_Blocks_Event failed status %d", PackStatus);
1030 // handle the error
1031 VosStatus = vos_pkt_return_packet( pVosPkt );
1032
1033 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1034
1035 return(VOS_STATUS_E_FAILURE);
1036 }
1037
1038 break;
1039 }
1040 case BTAMP_TLV_HCI_HARDWARE_ERROR_EVENT:
1041 {
1042 // pack
1043 PackStatus = btampPackTlvHCI_Hardware_Error_Event( pctx,
1044 &pBapHCIEvent->u.btampHardwareErrorEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1045
1046 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1047 {
1048 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1049 // handle the error
1050 VosStatus = vos_pkt_return_packet( pVosPkt );
1051
1052 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1053
1054 return(VOS_STATUS_E_FAILURE);
1055 }
1056
1057 break;
1058 }
1059 case BTAMP_TLV_HCI_FLUSH_OCCURRED_EVENT:
1060 {
1061 // pack
1062 PackStatus = btampPackTlvHCI_Flush_Occurred_Event( pctx,
1063 &pBapHCIEvent->u.btampFlushOccurredEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1064
1065 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1066 {
1067 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampPackTlvHCI_Flush_Occurred_Event failed status %d", PackStatus);
1068 // handle the error
1069 VosStatus = vos_pkt_return_packet( pVosPkt );
1070
1071 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1072
1073 return(VOS_STATUS_E_FAILURE);
1074 }
1075
1076 break;
1077 }
1078 case BTAMP_TLV_HCI_ENHANCED_FLUSH_COMPLETE_EVENT:
1079 {
1080 // pack
1081 PackStatus = btampPackTlvHCI_Enhanced_Flush_Complete_Event( pctx,
1082 &pBapHCIEvent->u.btampEnhancedFlushCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1083
1084 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1085 {
1086 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampPackTlvHCI_Enhanced_Flush_Complete_Event failed status %d", PackStatus);
1087 // handle the error
1088 VosStatus = vos_pkt_return_packet( pVosPkt );
1089
1090 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1091
1092 return(VOS_STATUS_E_FAILURE);
1093 }
1094
1095 break;
1096 }
1097 case BTAMP_TLV_HCI_LOOPBACK_COMMAND_EVENT:
1098 {
1099 // pack
1100 PackStatus = btampPackTlvHCI_Loopback_Command_Event( pctx,
1101 &pBapHCIEvent->u.btampLoopbackCommandEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1102
1103 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1104 {
1105 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1106 // handle the error
1107 VosStatus = vos_pkt_return_packet( pVosPkt );
1108
1109 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1110
1111 return(VOS_STATUS_E_FAILURE);
1112 }
1113
1114 break;
1115 }
1116 case BTAMP_TLV_HCI_DATA_BUFFER_OVERFLOW_EVENT:
1117 {
1118 // pack
1119 PackStatus = btampPackTlvHCI_Data_Buffer_Overflow_Event( pctx,
1120 &pBapHCIEvent->u.btampDataBufferOverflowEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1121
1122 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1123 {
1124 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1125 // handle the error
1126 VosStatus = vos_pkt_return_packet( pVosPkt );
1127
1128 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1129
1130 return(VOS_STATUS_E_FAILURE);
1131 }
1132
1133 break;
1134 }
1135 case BTAMP_TLV_HCI_QOS_VIOLATION_EVENT:
1136 {
1137 // pack
1138 PackStatus = btampPackTlvHCI_Qos_Violation_Event( pctx,
1139 &pBapHCIEvent->u.btampQosViolationEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1140
1141 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1142 {
1143 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1144 // handle the error
1145 VosStatus = vos_pkt_return_packet( pVosPkt );
1146
1147 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1148
1149 return(VOS_STATUS_E_FAILURE);
1150 }
1151
1152 break;
1153 }
1154 /** BT v3.0 events */
1155 case BTAMP_TLV_HCI_GENERIC_AMP_LINK_KEY_NOTIFICATION_EVENT:
1156 {
1157 // pack
1158 PackStatus = btampPackTlvHCI_Generic_AMP_Link_Key_Notification_Event( pctx,
1159 &pBapHCIEvent->u.btampGenericAMPLinkKeyNotificationEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1160
1161 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1162 {
1163 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1164 // handle the error
1165 VosStatus = vos_pkt_return_packet( pVosPkt );
1166
1167 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1168
1169 return(VOS_STATUS_E_FAILURE);
1170 }
1171
1172 break;
1173 }
1174 case BTAMP_TLV_HCI_PHYSICAL_LINK_COMPLETE_EVENT:
1175 {
1176 // pack
1177 PackStatus = btampPackTlvHCI_Physical_Link_Complete_Event( pctx,
1178 &pBapHCIEvent->u.btampPhysicalLinkCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1179
1180 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1181 {
1182 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1183 // handle the error
1184 VosStatus = vos_pkt_return_packet( pVosPkt );
1185
1186 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1187
1188 return(VOS_STATUS_E_FAILURE);
1189 }
1190
1191 // look at this event to determine whether to cleanup the PHY context
1192 if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1193 WLANBAP_STATUS_SUCCESS )
1194 {
1195 // register the data plane now
1196 VosStatus = WLANBAP_RegisterDataPlane( pctx->bapHdl,
1197 WLANBAP_STAFetchPktCB,
1198 WLANBAP_STARxCB,
1199 WLANBAP_TxCompCB,
1200 (BslPhyLinkCtxType *)pHddHdl );
1201
1202 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1203 {
1204 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB WLANBAP_RegisterDataPlane "
1205 "failed status = %d\n", VosStatus );
1206 // we still want to send the event upto app so do not bail
1207 }
1208 else
1209 {
1210 // update the phy link handle based map so TX data can start flowing through
1211 OldMapVal = vos_atomic_set_U32( (v_U32_t *)BslPhyLinkMap+pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.phy_link_handle,
1212 (v_U32_t) pHddHdl );
1213
1214// VOS_ASSERT( OldMapVal == 0 );//Commented to test reconnect
1215 }
1216 }
1217 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1218 WLANBAP_ERROR_HOST_REJ_RESOURCES )
1219 {
1220 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1221 }
1222 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1223 WLANBAP_ERROR_HOST_TIMEOUT )
1224 {
1225 //We need to update the phy link handle here to be able to reissue physical link accept
1226 // update the phy link handle based map so TX data can start flowing through
1227 OldMapVal = vos_atomic_set_U32( (v_U32_t *)BslPhyLinkMap+pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.phy_link_handle,
1228 (v_U32_t) pHddHdl );
1229
1230// VOS_ASSERT( OldMapVal == 0 );//Commented to test reconnect
1231
1232 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1233 }
1234 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1235 WLANBAP_ERROR_MAX_NUM_CNCTS )
1236 {
1237 //We need to update the phy link handle here to be able to reissue physical link /create/accept
1238 // update the phy link handle based map so TX data can start flowing through
1239 OldMapVal = vos_atomic_set_U32( (v_U32_t *)BslPhyLinkMap+pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.phy_link_handle,
1240 (v_U32_t) pHddHdl );
1241// VOS_ASSERT( OldMapVal == 0 );//Commented to test reconnect
1242
1243 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1244 }
1245 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1246 WLANBAP_ERROR_HOST_TIMEOUT )
1247 {
1248 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1249 }
1250 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1251 0x16 /* WLANBAP_ERROR_FAILED_CONNECTION? */ )
1252 {
1253 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1254 }
1255 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1256 0x8 /* WLANBAP_ERROR_AUTH_FAILED? */ )
1257 {
1258 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1259 }
1260 else if ( pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status ==
1261 WLANBAP_ERROR_NO_CNCT )
1262 {
1263 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1264 }
1265 else
1266 {
1267 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB unexpected HCI Phy Link Comp Evt "
1268 "status =%d\n", pBapHCIEvent->u.btampPhysicalLinkCompleteEvent.status );
1269 }
1270
1271 break;
1272 }
1273 case BTAMP_TLV_HCI_CHANNEL_SELECTED_EVENT:
1274 {
1275 // pack
1276 PackStatus = btampPackTlvHCI_Channel_Selected_Event( pctx,
1277 &pBapHCIEvent->u.btampChannelSelectedEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1278
1279 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1280 {
1281 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1282 // handle the error
1283 VosStatus = vos_pkt_return_packet( pVosPkt );
1284
1285 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1286
1287 return(VOS_STATUS_E_FAILURE);
1288 }
1289
1290 break;
1291 }
1292 case BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_COMPLETE_EVENT:
1293 {
1294 // pack
1295 PackStatus = btampPackTlvHCI_Disconnect_Physical_Link_Complete_Event( pctx,
1296 &pBapHCIEvent->u.btampDisconnectPhysicalLinkCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1297
1298 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1299 {
1300 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1301 // handle the error
1302 VosStatus = vos_pkt_return_packet( pVosPkt );
1303
1304 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1305
1306 return(VOS_STATUS_E_FAILURE);
1307 }
1308
1309 // we need to cleanup the PHY context always but have these checks to make
1310 // sure we catch unexpected behavior, strangely enough even when peer triggers
1311 // the disconnect the reason code is still 0x16, weird
1312 if ( pBapHCIEvent->u.btampDisconnectPhysicalLinkCompleteEvent.status == WLANBAP_STATUS_SUCCESS &&
1313 pBapHCIEvent->u.btampDisconnectPhysicalLinkCompleteEvent.reason == WLANBAP_ERROR_TERM_BY_LOCAL_HOST )
1314 {
1315 BslReleasePhyCtx( (BslPhyLinkCtxType *)pHddHdl );
1316 }
1317 else
1318 {
1319 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB unexpected HCI Dis Phy Link Comp Evt "
1320 "status =%d reason =%d\n", pBapHCIEvent->u.btampDisconnectPhysicalLinkCompleteEvent.status,
1321 pBapHCIEvent->u.btampDisconnectPhysicalLinkCompleteEvent.reason );
1322 }
1323
1324 break;
1325 }
1326 case BTAMP_TLV_HCI_PHYSICAL_LINK_LOSS_WARNING_EVENT:
1327 {
1328 // pack
1329 PackStatus = btampPackTlvHCI_Physical_Link_Loss_Warning_Event( pctx,
1330 &pBapHCIEvent->u.btampPhysicalLinkLossWarningEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1331
1332 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1333 {
1334 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1335 // handle the error
1336 VosStatus = vos_pkt_return_packet( pVosPkt );
1337
1338 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1339
1340 return(VOS_STATUS_E_FAILURE);
1341 }
1342
1343 break;
1344 }
1345 case BTAMP_TLV_HCI_PHYSICAL_LINK_RECOVERY_EVENT:
1346 {
1347 // pack
1348 PackStatus = btampPackTlvHCI_Physical_Link_Recovery_Event( pctx,
1349 &pBapHCIEvent->u.btampPhysicalLinkRecoveryEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1350
1351 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1352 {
1353 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1354 // handle the error
1355 VosStatus = vos_pkt_return_packet( pVosPkt );
1356
1357 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1358
1359 return(VOS_STATUS_E_FAILURE);
1360 }
1361
1362 break;
1363 }
1364 case BTAMP_TLV_HCI_LOGICAL_LINK_COMPLETE_EVENT:
1365 {
1366 // pack
1367 PackStatus = btampPackTlvHCI_Logical_Link_Complete_Event( pctx,
1368 &pBapHCIEvent->u.btampLogicalLinkCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1369
1370 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1371 {
1372 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1373 // handle the error
1374 VosStatus = vos_pkt_return_packet( pVosPkt );
1375
1376 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1377
1378 return(VOS_STATUS_E_FAILURE);
1379 }
1380
1381 break;
1382 }
1383 case BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_COMPLETE_EVENT:
1384 {
1385 // pack
1386 PackStatus = btampPackTlvHCI_Disconnect_Logical_Link_Complete_Event( pctx,
1387 &pBapHCIEvent->u.btampDisconnectLogicalLinkCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1388
1389 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1390 {
1391 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1392 // handle the error
1393 VosStatus = vos_pkt_return_packet( pVosPkt );
1394
1395 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1396
1397 return(VOS_STATUS_E_FAILURE);
1398 }
1399
1400 break;
1401 }
1402 case BTAMP_TLV_HCI_FLOW_SPEC_MODIFY_COMPLETE_EVENT:
1403 {
1404 // pack
1405 PackStatus = btampPackTlvHCI_Flow_Spec_Modify_Complete_Event( pctx,
1406 &pBapHCIEvent->u.btampFlowSpecModifyCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1407
1408 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1409 {
1410 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1411 // handle the error
1412 VosStatus = vos_pkt_return_packet( pVosPkt );
1413
1414 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1415
1416 return(VOS_STATUS_E_FAILURE);
1417 }
1418
1419 break;
1420 }
1421 case BTAMP_TLV_HCI_SHORT_RANGE_MODE_CHANGE_COMPLETE_EVENT:
1422 {
1423 // pack
1424 PackStatus = btampPackTlvHCI_Short_Range_Mode_Change_Complete_Event( pctx,
1425 &pBapHCIEvent->u.btampShortRangeModeChangeCompleteEvent, Buff, BSL_MAX_EVENT_SIZE, &Written );
1426
1427 if ( !BTAMP_SUCCEEDED( PackStatus ) )
1428 {
1429 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANBAP_EventCB: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", PackStatus);
1430 // handle the error
1431 VosStatus = vos_pkt_return_packet( pVosPkt );
1432
1433 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1434
1435 return(VOS_STATUS_E_FAILURE);
1436 }
1437
1438 break;
1439 }
1440 default:
1441 {
1442 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB unexpected event\n" );
1443
1444 VosStatus = vos_pkt_return_packet( pVosPkt );
1445
1446 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1447
1448 return(VOS_STATUS_E_FAILURE);
1449 break;
1450 }
1451 }
1452
1453 VOS_ASSERT(Written <= BSL_MAX_EVENT_SIZE);
1454
1455 // stick the event into a VoS pkt
1456 VosStatus = vos_pkt_push_head( pVosPkt, Buff, Written );
1457
1458 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1459 {
1460 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_EventCB vos_pkt_push_head "
1461 "status =%d\n", VosStatus );
1462
1463 // return the packet
1464 VosStatus = vos_pkt_return_packet( pVosPkt );
1465 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1466
1467 return(VOS_STATUS_E_FAILURE);
1468 }
1469
1470 // Extract the OS packet (skb).
1471 // Tell VOS to detach the OS packet from the VOS packet
1472 VosStatus = vos_pkt_get_os_packet( pVosPkt, (v_VOID_t **)&skb, VOS_TRUE );
1473 if(!VOS_IS_STATUS_SUCCESS( VosStatus ))
1474 {
1475 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s: Failure extracting skb from vos pkt. "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001476 "VosStatus = %d\n", __func__, VosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001477
1478 // return the packet
1479 VosStatus = vos_pkt_return_packet( pVosPkt );
1480 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1481
1482 return(VOS_STATUS_E_FAILURE);
1483 }
1484
1485 //JEZ100922: We are free to return the enclosing VOSS packet.
1486 VosStatus = vos_pkt_return_packet( pVosPkt );
1487 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ));
1488
1489 //JEZ100809: While an skb is being handled by the kernel, is "skb->dev" de-ref'd?
1490 skb->dev = (struct net_device *) gpBslctx->hdev;
1491 bt_cb(skb)->pkt_type = HCI_EVENT_PKT;
1492 //skb->protocol = eth_type_trans(skb, skb->dev);
1493 //skb->ip_summed = CHECKSUM_UNNECESSARY;
1494
1495 // This is my receive skb pointer
1496 gpBslctx->rx_skb = skb;
1497
1498 // This is how data and events are passed up to BlueZ
1499 hci_recv_frame(gpBslctx->rx_skb);
1500
1501 return(VOS_STATUS_SUCCESS);
1502} // WLANBAP_EventCB()
1503
1504static VOS_STATUS
1505WLANBAP_PhyLinkFailure
1506(
1507 BslClientCtxType* pctx,
1508 v_U8_t phy_link_handle
1509)
1510{
1511 VOS_STATUS vosStatus;
1512 tBtampHCI_Event bapHCIEvent;
1513
1514 /* Format the Physical Link Complete event to return... */
1515 bapHCIEvent.bapHCIEventCode = BTAMP_TLV_HCI_PHYSICAL_LINK_COMPLETE_EVENT;
1516 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.present = 1;
1517 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.status = WLANBAP_ERROR_UNSPECIFIED_ERROR;
1518 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.phy_link_handle
1519 = phy_link_handle;
1520 bapHCIEvent.u.btampPhysicalLinkCompleteEvent.ch_number
1521 = 0;
1522 //TBD: Could be a cleaner way to get the PhyLinkCtx handle; For now works
1523 BslPhyLinkCtx[0].pClientCtx = pctx;
1524 vosStatus = WLANBAP_EventCB( &BslPhyLinkCtx[0], &bapHCIEvent, TRUE );
1525
1526 return vosStatus;
1527}
1528
1529/**
1530 @brief BslFindAndInitClientCtx() - This function will find and initialize a client
1531 a.k.a app context
1532
1533 @param pctx : [inout] ptr to the client context
1534
1535 @return
1536 TRUE if all OK, FALSE otherwise
1537
1538*/
1539static BOOL BslFindAndInitClientCtx
1540(
1541 BslClientCtxType** pctx_
1542)
1543{
1544 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
1545 BslClientCtxType* pctx;
1546 v_U8_t i;
1547
1548 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslFindAndInitClientCtx\n" );
1549
1550 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1551 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001552 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,"%s:BslClientLock already inited",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 // return(0);
1554 }
1555
1556 for ( i=0; i < BSL_MAX_CLIENTS; i++ )
1557 {
1558 if ( !BslClientCtx[i].used )
1559 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001560 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,"%s:BslClientCtx[%d] selected",__func__, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07001561 BslClientCtx[i].used = TRUE;
1562 break;
1563 }
1564 }
1565
1566 if ( i == BSL_MAX_CLIENTS )
1567 {
1568 // no more clients can be supported
1569 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslFindAndInitClientCtx no more "
1570 "clients can be supported MAX=%d\n", BSL_MAX_CLIENTS );
1571 return FALSE;
1572 }
1573
1574 //pctx = BslClientCtx + i;
1575 pctx = gpBslctx;
1576
1577 // get a handle from BAP
1578 VosStatus = WLANBAP_GetNewHndl(&pctx->bapHdl);
1579
1580 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1581 {
1582 pctx->used = FALSE;
1583
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001584 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s:WLAN_GetNewHndl Failed",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
1586 return(FALSE);
1587 }
1588
1589 // register the event cb with BAP, this cb is used for BOTH association
1590 // specific and non-association specific event notifications by BAP.
1591 // However association specific events will be called with a different
1592 // cookie that is passed in during the physical link create/accept
1593 VosStatus = WLAN_BAPRegisterBAPCallbacks( pctx->bapHdl, WLANBAP_EventCB, pctx );
1594
1595 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1596 {
1597 pctx->used = FALSE;
1598
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001599 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s:WLAN_BAPRegsiterBAPCallaback Failed",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001600
1601 return(FALSE);
1602 }
1603
1604 // init the PhyLinks queue to keep track of the assoc's of this client
1605 VosStatus = vos_list_init( &pctx->PhyLinks );
1606 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
1607
1608 *pctx_ = pctx;
1609
1610 return(TRUE);
1611} //BslFindAndInitClientCtx()
1612
1613/**
1614 @brief BslReleaseClientCtx() - This function will release a client a.k.a. app
1615 context
1616
1617 @param pctx : [in] ptr to the client context
1618
1619 @return
1620 None
1621
1622*/
1623//#if 0
1624static void BslReleaseClientCtx
1625(
1626 BslClientCtxType* pctx
1627)
1628{
1629 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
1630 vos_list_node_t* pLink;
1631 BslPhyLinksNodeType *pPhyNode;
1632
1633 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "BslReleaseClientCtx\n" );
1634
1635 // an app can do this without cleaning up after itself i.e. it can have active associations and
1636 // data pending, we need to cleanup its mess
1637
1638 // first tell BAP we dont want the handle anymore, BAP will cleanup all the associations and
1639 // consume resulting HCI events, so after this we will not get any HCI events. we will also
1640 // not see any FetchPktCB and RxPktCB. We can still expect TxCompletePktCB
1641 VosStatus = WLANBAP_ReleaseHndl( pctx->bapHdl );
1642 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
1643
1644
1645 // find and free all of the association contexts belonging to this app
1646 while ( VOS_IS_STATUS_SUCCESS( VosStatus = vos_list_remove_front( &pctx->PhyLinks, &pLink ) ) )
1647 {
1648 pPhyNode = (BslPhyLinksNodeType *)pLink;
1649
1650 // since the phy link has already been removed from the list of active
1651 // associations, make sure we dont attempt to do this again
1652 pPhyNode->pPhy->pPhyLinkDescNode = NULL;
1653
1654 BslReleasePhyCtx( pPhyNode->pPhy );
1655 }
1656
1657 VOS_ASSERT( VosStatus == VOS_STATUS_E_EMPTY );
1658
1659 // destroy the PhyLinks queue
1660 VosStatus = vos_list_destroy( &pctx->PhyLinks );
1661 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
1662
1663 pctx->used = FALSE;
1664
1665} // BslReleaseClientCtx()
1666//#endif
1667
1668/**
1669 @brief BslInitPhyCtx() - Initialize the Phy Context array.
1670
1671
1672 @return
1673 TRUE if all OK, FALSE otherwise
1674
1675*/
1676static BOOL BslInitPhyCtx (void)
1677{
1678 v_U16_t i;
1679 // free PHY context
1680
1681 for ( i=0; i<BSL_MAX_PHY_LINKS; i++ )
1682 {
1683 BslPhyLinkCtx[i].used = FALSE;
1684 }
1685
1686 return (TRUE);
1687} // BslInitPhyCtx()
1688
1689
1690/**
1691 @brief BslFindAndInitPhyCtx() - This function will try to find a free physical
1692 link a.k.a assocation context and if successful, then init that context
1693
1694 @param pctx : [in] the client context
1695 @param PhyLinkHdl : [in] the physical link handle chosen by application
1696 @param ppPhyCtx : [inout] ptr to the physical link context
1697
1698 @return
1699 TRUE if all OK, FALSE otherwise
1700
1701*/
1702static BOOL BslFindAndInitPhyCtx
1703(
1704 BslClientCtxType* pctx,
1705 v_U8_t PhyLinkHdl,
1706 BslPhyLinkCtxType** ppPhyCtx
1707)
1708{
1709 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
1710 v_U16_t i;
1711 v_U16_t j;
1712 vos_list_node_t* pLink;
1713 BslPhyLinksNodeType *pNode;
1714
1715 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "BslFindAndInitPhyCtx\n" );
1716
1717 for ( i=0; i<BSL_MAX_PHY_LINKS; i++ )
1718 {
1719 if ( !BslPhyLinkCtx[i].used )
1720 {
1721 BslPhyLinkCtx[i].used = TRUE;
1722 break;
1723 }
1724 }
1725
1726 if ( i==BSL_MAX_PHY_LINKS )
1727 {
1728 return(FALSE);
1729 }
1730 else
1731 {
1732
1733 // now init this context
1734
1735 *ppPhyCtx = BslPhyLinkCtx + i;
1736
1737 // setup a ptr to the app context that this assocation specific context lives in
1738 BslPhyLinkCtx[i].pClientCtx = pctx;
1739
1740 // Mark as used
1741 (*ppPhyCtx)->used = TRUE;
1742
1743 // store the PHY link handle
1744 BslPhyLinkCtx[i].PhyLinkHdl = PhyLinkHdl;
1745
1746 // init the TX queues
1747 for ( j=0; j<WLANTL_MAX_AC; j++ )
1748 {
1749 hdd_list_init( &BslPhyLinkCtx[i].ACLTxQueue[j], HDD_TX_QUEUE_MAX_LEN );
1750 //VosStatus = vos_list_init( &BslPhyLinkCtx[i].ACLTxQueue[j] );
1751 //VosStatus = vos_list_init( &(BslPhyLinkCtx+i)->ACLTxQueue );
1752 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
1753 }
1754
1755 // need to add this Phy context to the client list of associations,
1756 // useful during Close operation
1757
1758 // get a pkt desc
1759 VosStatus = vos_list_remove_front( &BslPhyLinksDescPool, &pLink );
1760
1761 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1762 {
1763 // this could happen due to pool not being big enough, etc
1764 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "BslFindAndInitPhyCtx failed to "
1765 "get node from BslPhyLinksDescPool vstatus=%d\n", VosStatus );
1766 BslReleasePhyCtx( *ppPhyCtx );
1767 return FALSE;
1768 }
1769
1770 // stick the VOS pkt into the node
1771 pNode = (BslPhyLinksNodeType *) pLink;
1772 pNode->node = *pLink;
1773 pNode->pPhy = *ppPhyCtx;
1774
1775
1776 // now queue the pkt into the correct queue
1777 VosStatus = vos_list_insert_back( &pctx->PhyLinks, pLink );
1778
1779 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1780 {
1781 VOS_ASSERT(0);
1782 }
1783
1784 // need to record the desc for this assocation in the list of
1785 // active assocations in client context to allow cleanup later
1786 (*ppPhyCtx)->pPhyLinkDescNode = pNode;
1787
1788 return(TRUE);
1789 }
1790} // BslFindAndInitPhyCtx()
1791
1792/**
1793 @brief BslProcessHCICommand() - This function will process an HCI command i.e
1794 take an HCI command buffer, unpack it and then call the appropriate BAP API
1795
1796 @param pctx : [in] ptr to the client context
1797 @param pBuffer_ : [in] the input buffer containing the HCI command
1798 @param Count_ : [in] size of the HCI command buffer
1799
1800 @return
1801 TRUE if all OK, FALSE otherwise
1802
1803*/
1804static BOOL BslProcessHCICommand
1805(
1806 BslClientCtxType* pctx,
1807 LPCVOID pBuffer_,
1808 DWORD Count_
1809)
1810{
1811 LPVOID pBuffer = (LPVOID) pBuffer_; // castaway the const-ness of the ptr
1812 v_U16_t Count = (v_U16_t) Count_; // this should be OK max size < 1500
1813 v_U32_t UnpackStatus;
1814 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
1815 BOOL Status;
1816 BslPhyLinkCtxType* pPhyCtx;
1817 tBtampHCI_Event HCIEvt;
1818 v_U16_t x = 1;
1819 int i = 0;
1820
1821 // the opcode is in LE, if we are LE too then this is fine else we need some
1822 // byte swapping
1823 v_U16_t cmdOpcode = *(UNALIGNED v_U16_t *)pBuffer;
1824 v_U8_t *pBuf = (v_U8_t *)pBuffer;
1825 v_U8_t *pTmp = (v_U8_t *)pBuf;
1826
1827 // TODO: do we really need to do this per call even though the op is quite cheap
1828 if(*(v_U8_t *)&x == 0)
1829 {
1830 // BE
1831 cmdOpcode = ( cmdOpcode & 0xFF ) << 8 | ( cmdOpcode & 0xFF00 ) >> 8;
1832 }
1833
1834 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "BslProcessHCICommand: cmdOpcode = %hx\n", cmdOpcode );
1835
1836 for(i=0; i<4; i++)
1837 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: *pBuf before advancepTmp[%x] = %x\n", i,pTmp[i] );
1838
1839 pBuf+=CMD_TLV_TYPE_AND_LEN_SIZE;
1840
1841
1842 switch ( cmdOpcode )
1843 {
1844 /** BT v3.0 Link Control commands */
1845 case BTAMP_TLV_HCI_CREATE_PHYSICAL_LINK_CMD:
1846 {
1847 tBtampTLVHCI_Create_Physical_Link_Cmd CreatePhysicalLinkCmd;
1848 // unpack
1849 UnpackStatus = btampUnpackTlvHCI_Create_Physical_Link_Cmd( NULL,
1850 pBuf, Count, &CreatePhysicalLinkCmd );
1851
1852 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
1853 {
1854 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Create_Physical_Link_Cmd failed status %d", UnpackStatus);
1855 // handle the error
1856 return(FALSE);
1857 }
1858
1859 if(VOS_FALSE == WLANBAP_AmpConnectionAllowed())
1860 {
1861 VosStatus = WLANBAP_PhyLinkFailure(pctx, CreatePhysicalLinkCmd.phy_link_handle);
1862 if ( VOS_STATUS_SUCCESS != VosStatus )
1863 {
1864 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessHCICommand: WLANBAP_PhyLinkFailure failed");
1865 // handle the error
1866 return(FALSE);
1867 }
1868 break;
1869 }
1870
1871 // setup the per PHY link BAP context
1872 Status = BslFindAndInitPhyCtx( pctx, CreatePhysicalLinkCmd.phy_link_handle,
1873 &pPhyCtx );
1874
1875 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "CreatePhysicalLinkCmd.phy_link_handle=%d\n",CreatePhysicalLinkCmd.phy_link_handle);
1876
1877 if ( !Status )
1878 {
1879 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: BslFindAndInitPhyCtx failed");
1880 // handle the error
1881 return(FALSE);
1882 }
1883
1884 VosStatus = WLAN_BAPPhysicalLinkCreate( pctx->bapHdl,
1885 &CreatePhysicalLinkCmd, pPhyCtx, &HCIEvt );
1886
1887
1888 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1889 {
1890 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPPhysicalLinkCreate failed status %d", VosStatus);
1891 // handle the error
1892 BslReleasePhyCtx( pPhyCtx );
1893 return(FALSE);
1894 }
1895
1896 // this may look strange as this is the function registered
1897 // with BAP for the EventCB but we are also going to use it
1898 // as a helper function. The difference is that this invocation
1899 // runs in HCI command sending caller context while the callback
1900 // will happen in BAP's context whatever that may be
1901 VosStatus = WLANBAP_EventCB( pPhyCtx, &HCIEvt, TRUE );
1902
1903 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1904 {
1905 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
1906 // handle the error
1907 BslReleasePhyCtx( pPhyCtx );
1908 return(FALSE);
1909 }
1910
1911 break;
1912 }
1913 case BTAMP_TLV_HCI_ACCEPT_PHYSICAL_LINK_CMD:
1914 {
1915 tBtampTLVHCI_Accept_Physical_Link_Cmd AcceptPhysicalLinkCmd;
1916 // unpack
1917 UnpackStatus = btampUnpackTlvHCI_Accept_Physical_Link_Cmd( NULL,
1918 pBuf, Count, &AcceptPhysicalLinkCmd );
1919
1920 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
1921 {
1922 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Accept_Physical_Link_Cmd failed status %d", UnpackStatus);
1923 // handle the error
1924 return(FALSE);
1925 }
1926
1927 if(VOS_FALSE == WLANBAP_AmpConnectionAllowed())
1928 {
1929 VosStatus = WLANBAP_PhyLinkFailure(pctx, AcceptPhysicalLinkCmd.phy_link_handle);
1930 if ( VOS_STATUS_SUCCESS != VosStatus )
1931 {
1932 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessHCICommand: WLANBAP_PhyLinkFailure failed");
1933 // handle the error
1934 return(FALSE);
1935 }
1936 break;
1937 }
1938
1939 // setup the per PHY link BAP context
1940 Status = BslFindAndInitPhyCtx( pctx, AcceptPhysicalLinkCmd.phy_link_handle,
1941 &pPhyCtx );
1942
1943 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "AcceptPhysicalLinkCmd.phy_link_handle=%d\n",AcceptPhysicalLinkCmd.phy_link_handle);
1944
1945 if ( !Status )
1946 {
1947 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: BslFindAndInitPhyCtx failed");
1948 // handle the error
1949 return(FALSE);
1950 }
1951
1952 VosStatus = WLAN_BAPPhysicalLinkAccept( pctx->bapHdl,
1953 &AcceptPhysicalLinkCmd, pPhyCtx, &HCIEvt );
1954
1955 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1956 {
1957 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPPhysicalLinkAccept failed status %d", VosStatus);
1958 // handle the error
1959 BslReleasePhyCtx( pPhyCtx );
1960 return(FALSE);
1961 }
1962
1963 // this may look strange as this is the function registered
1964 // with BAP for the EventCB but we are also going to use it
1965 // as a helper function. The difference is that this invocation
1966 // runs in HCI command sending caller context while the callback
1967 // will happen in BAP's context whatever that may be
1968 VosStatus = WLANBAP_EventCB( pPhyCtx, &HCIEvt, TRUE );
1969
1970 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
1971 {
1972 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
1973 // handle the error
1974 BslReleasePhyCtx( pPhyCtx );
1975 return(FALSE);
1976 }
1977
1978 break;
1979 }
1980 case BTAMP_TLV_HCI_DISCONNECT_PHYSICAL_LINK_CMD:
1981 {
1982 tBtampTLVHCI_Disconnect_Physical_Link_Cmd DisconnectPhysicalLinkCmd;
1983 Count = Count - 3;//Type and length field lengths are not needed
1984 pTmp = pBuf;
1985 for(i=0; i<4; i++)
1986 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: *pBuf in Disconnect phy link pTmp[%x] = %x\n", i,pTmp[i] );
1987 // unpack
1988 UnpackStatus = btampUnpackTlvHCI_Disconnect_Physical_Link_Cmd( NULL,
1989 pBuf, Count, &DisconnectPhysicalLinkCmd );
1990
1991 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
1992 {
1993 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Disconnect_Physical_Link_Cmd failed status %d", UnpackStatus);
1994 // handle the error
1995 return(FALSE);
1996 }
1997
1998 VosStatus = WLAN_BAPPhysicalLinkDisconnect( pctx->bapHdl,
1999 &DisconnectPhysicalLinkCmd, &HCIEvt );
2000
2001 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2002 {
2003 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPPhysicalLinkDisconnect failed status %d", VosStatus);
2004 // handle the error
2005 return(FALSE);
2006 }
2007
2008 // this may look strange as this is the function registered
2009 // with BAP for the EventCB but we are also going to use it
2010 // as a helper function. The difference is that this invocation
2011 // runs in HCI command sending caller context while the callback
2012 // will happen in BAP's context whatever that may be
2013 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2014
2015 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2016 {
2017 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2018 // handle the error
2019 return(FALSE);
2020 }
2021
2022 break;
2023 }
2024 case BTAMP_TLV_HCI_CREATE_LOGICAL_LINK_CMD:
2025 {
2026 tBtampTLVHCI_Create_Logical_Link_Cmd CreateLogicalLinkCmd;
2027 Count -= 3; //To send the correct length to unpack event
2028 // unpack
2029 UnpackStatus = btampUnpackTlvHCI_Create_Logical_Link_Cmd( NULL,
2030 pBuf, Count, &CreateLogicalLinkCmd );
2031
2032 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2033 {
2034 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Create_Logical_Link_Cmd failed status %d", UnpackStatus);
2035 // handle the error
2036 return(FALSE);
2037 }
2038
2039 VosStatus = WLAN_BAPLogicalLinkCreate( pctx->bapHdl,
2040 &CreateLogicalLinkCmd, &HCIEvt );
2041
2042 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2043 {
2044 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPLogicalLinkCreate failed status %d", VosStatus);
2045 // handle the error
2046 return(FALSE);
2047 }
2048
2049 // this may look strange as this is the function registered
2050 // with BAP for the EventCB but we are also going to use it
2051 // as a helper function. The difference is that this invocation
2052 // runs in HCI command sending caller context while the callback
2053 // will happen in BAP's context whatever that may be
2054 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2055
2056 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2057 {
2058 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2059 // handle the error
2060 return(FALSE);
2061 }
2062
2063 break;
2064 }
2065 case BTAMP_TLV_HCI_ACCEPT_LOGICAL_LINK_CMD:
2066 {
2067 tBtampTLVHCI_Accept_Logical_Link_Cmd AcceptLogicalLinkCmd;
2068 Count = Count - 3;//Subtract Type and Length fields
2069 // unpack
2070 UnpackStatus = btampUnpackTlvHCI_Accept_Logical_Link_Cmd( NULL,
2071 pBuf, Count, &AcceptLogicalLinkCmd );
2072
2073 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2074 {
2075 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Accept_Logical_Link_Cmd failed status %d", UnpackStatus);
2076 // handle the error
2077 return(FALSE);
2078 }
2079
2080 VosStatus = WLAN_BAPLogicalLinkAccept( pctx->bapHdl,
2081 &AcceptLogicalLinkCmd, &HCIEvt );
2082
2083 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2084 {
2085 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPLogicalLinkAccept failed status %d", VosStatus);
2086 // handle the error
2087 return(FALSE);
2088 }
2089
2090 // this may look strange as this is the function registered
2091 // with BAP for the EventCB but we are also going to use it
2092 // as a helper function. The difference is that this invocation
2093 // runs in HCI command sending caller context while the callback
2094 // will happen in BAP's context whatever that may be
2095 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2096
2097 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2098 {
2099 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2100 // handle the error
2101 return(FALSE);
2102 }
2103
2104 break;
2105 }
2106 case BTAMP_TLV_HCI_DISCONNECT_LOGICAL_LINK_CMD:
2107 {
2108 tBtampTLVHCI_Disconnect_Logical_Link_Cmd DisconnectLogicalLinkCmd;
2109 // unpack
2110 UnpackStatus = btampUnpackTlvHCI_Disconnect_Logical_Link_Cmd( NULL,
2111 pBuf, Count, &DisconnectLogicalLinkCmd );
2112
2113 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2114 {
2115 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Disconnect_Logical_Link_Cmd failed status %d", UnpackStatus);
2116 // handle the error
2117 return(FALSE);
2118 }
2119
2120 VosStatus = WLAN_BAPLogicalLinkDisconnect( pctx->bapHdl,
2121 &DisconnectLogicalLinkCmd, &HCIEvt );
2122
2123 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2124 {
2125 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPLogicalLinkDisconnect failed status %d", VosStatus);
2126 // handle the error
2127 return(FALSE);
2128 }
2129
2130 // this may look strange as this is the function registered
2131 // with BAP for the EventCB but we are also going to use it
2132 // as a helper function. The difference is that this invocation
2133 // runs in HCI command sending caller context while the callback
2134 // will happen in BAP's context whatever that may be
2135 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2136
2137 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2138 {
2139 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2140 // handle the error
2141 return(FALSE);
2142 }
2143
2144 break;
2145 }
2146 case BTAMP_TLV_HCI_LOGICAL_LINK_CANCEL_CMD:
2147 {
2148 tBtampTLVHCI_Logical_Link_Cancel_Cmd LogicalLinkCancelCmd;
2149 // unpack
2150 UnpackStatus = btampUnpackTlvHCI_Logical_Link_Cancel_Cmd( NULL,
2151 pBuf, Count, &LogicalLinkCancelCmd );
2152
2153 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2154 {
2155 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Logical_Link_Cancel_Cmd failed status %d", UnpackStatus);
2156 // handle the error
2157 return(FALSE);
2158 }
2159
2160 VosStatus = WLAN_BAPLogicalLinkCancel( pctx->bapHdl,
2161 &LogicalLinkCancelCmd, &HCIEvt );
2162
2163 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2164 {
2165 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPLogicalLinkCancel failed status %d", VosStatus);
2166 // handle the error
2167 return(FALSE);
2168 }
2169
2170 // this may look strange as this is the function registered
2171 // with BAP for the EventCB but we are also going to use it
2172 // as a helper function. The difference is that this invocation
2173 // runs in HCI command sending caller context while the callback
2174 // will happen in BAP's context whatever that may be
2175 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2176
2177 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2178 {
2179 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2180 // handle the error
2181 return(FALSE);
2182 }
2183
2184 break;
2185 }
2186 case BTAMP_TLV_HCI_FLOW_SPEC_MODIFY_CMD:
2187 {
2188 tBtampTLVHCI_Flow_Spec_Modify_Cmd FlowSpecModifyCmd;
2189 // unpack
2190 UnpackStatus = btampUnpackTlvHCI_Flow_Spec_Modify_Cmd( NULL,
2191 pBuf, Count, &FlowSpecModifyCmd );
2192
2193 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2194 {
2195 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Flow_Spec_Modify_Cmd failed status %d", UnpackStatus);
2196 // handle the error
2197 return(FALSE);
2198 }
2199
2200 VosStatus = WLAN_BAPFlowSpecModify( pctx->bapHdl,
2201 &FlowSpecModifyCmd, &HCIEvt );
2202
2203 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2204 {
2205 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPFlowSpecModify failed status %d", VosStatus);
2206 // handle the error
2207 return(FALSE);
2208 }
2209
2210 // this may look strange as this is the function registered
2211 // with BAP for the EventCB but we are also going to use it
2212 // as a helper function. The difference is that this invocation
2213 // runs in HCI command sending caller context while the callback
2214 // will happen in BAP's context whatever that may be
2215 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2216
2217 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2218 {
2219 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2220 // handle the error
2221 return(FALSE);
2222 }
2223
2224 break;
2225 }
2226 /*
2227 Host Controller and Baseband Commands
2228 */
2229 case BTAMP_TLV_HCI_RESET_CMD:
2230 {
2231 VosStatus = WLAN_BAPReset( pctx->bapHdl );
2232
2233 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2234 {
2235 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReset failed status %d", VosStatus);
2236 // handle the error
2237 return(FALSE);
2238 }
2239
2240 break;
2241 }
2242 case BTAMP_TLV_HCI_SET_EVENT_MASK_CMD:
2243 {
2244 tBtampTLVHCI_Set_Event_Mask_Cmd SetEventMaskCmd;
2245 // unpack
2246 UnpackStatus = btampUnpackTlvHCI_Set_Event_Mask_Cmd( NULL,
2247 pBuf, Count, &SetEventMaskCmd );
2248
2249 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2250 {
2251 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Set_Event_Mask_Cmd failed status %d", UnpackStatus);
2252 // handle the error
2253 return(FALSE);
2254 }
2255
2256 VosStatus = WLAN_BAPSetEventMask( pctx->bapHdl,
2257 &SetEventMaskCmd, &HCIEvt );
2258
2259 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2260 {
2261 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPSetEventMask failed status %d", VosStatus);
2262 // handle the error
2263 return(FALSE);
2264 }
2265
2266 // this may look strange as this is the function registered
2267 // with BAP for the EventCB but we are also going to use it
2268 // as a helper function. The difference is that this invocation
2269 // runs in HCI command sending caller context while the callback
2270 // will happen in BAP's context whatever that may be
2271 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2272
2273 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2274 {
2275 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2276 // handle the error
2277 return(FALSE);
2278 }
2279
2280 break;
2281 }
2282 case BTAMP_TLV_HCI_FLUSH_CMD:
2283 {
2284 tBtampTLVHCI_Flush_Cmd FlushCmd;
2285
2286 // unpack
2287 UnpackStatus = btampUnpackTlvHCI_Flush_Cmd( NULL,
2288 pBuf, Count, &FlushCmd );
2289
2290 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2291 {
2292 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Flush_Cmd failed status %d", UnpackStatus);
2293 // handle the error
2294 return(FALSE);
2295 }
2296
2297 /* Flush the TX queue */
2298//#ifdef BAP_DEBUG
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002299 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s:HCI Flush command - will flush Tx Queue", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300//#endif //BAP_DEBUG
2301 // JEZ100604: Temporary short cut
2302 pPhyCtx = &BslPhyLinkCtx[0];
2303 VosStatus = BslFlushTxQueues ( pPhyCtx);
2304
2305 /* Acknowledge the command */
2306 VosStatus = WLAN_BAPFlush( pctx->bapHdl, &FlushCmd );
2307
2308 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2309 {
2310 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessHCICommand: WLAN_BAPFlush failed status %d", VosStatus);
2311 // handle the error
2312 return(FALSE);
2313 }
2314
2315 break;
2316 }
2317 case BTAMP_TLV_HCI_ENHANCED_FLUSH_CMD:
2318 {
2319 tBtampTLVHCI_Enhanced_Flush_Cmd FlushCmd;
2320
2321 // unpack
2322 UnpackStatus = btampUnpackTlvHCI_Enhanced_Flush_Cmd( NULL,
2323 pBuf, Count, &FlushCmd );
2324
2325 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2326 {
2327 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessHCICommand: btampUnpackTlvHCI_Enhanced_Flush_Cmd failed status %d", UnpackStatus);
2328 // handle the error
2329 return(FALSE);
2330 }
2331
2332 /* Flush the TX queue */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002333 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s:HCI Flush command - will flush Tx Queue for pkt type %d", __func__, FlushCmd.packet_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 // We support BE traffic only
2335 if(WLANTL_AC_BE == FlushCmd.packet_type)
2336 {
2337 pPhyCtx = &BslPhyLinkCtx[0];
2338 VosStatus = BslFlushTxQueues ( pPhyCtx);
2339 }
2340
2341 /* Acknowledge the command */
2342 VosStatus = WLAN_EnhancedBAPFlush( pctx->bapHdl, &FlushCmd, &HCIEvt );
2343
2344 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2345 {
2346 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessHCICommand: WLAN_EnahncedBAPFlush failed status %d", VosStatus);
2347 // handle the error
2348 return(FALSE);
2349 }
2350
2351 // this may look strange as this is the function registered
2352 // with BAP for the EventCB but we are also going to use it
2353 // as a helper function. The difference is that this invocation
2354 // runs in HCI command sending caller context while the callback
2355 // will happen in BAP's context whatever that may be
2356 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2357
2358 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2359 {
2360 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2361 // handle the error
2362 return(FALSE);
2363 }
2364
2365 break;
2366 }
2367 case BTAMP_TLV_HCI_READ_CONNECTION_ACCEPT_TIMEOUT_CMD:
2368 {
2369 VosStatus = WLAN_BAPReadConnectionAcceptTimeout( pctx->bapHdl, &HCIEvt );
2370
2371 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2372 {
2373 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadConnectionAcceptTimeout failed status %d", VosStatus);
2374 // handle the error
2375 return(FALSE);
2376 }
2377
2378 // this may look strange as this is the function registered
2379 // with BAP for the EventCB but we are also going to use it
2380 // as a helper function. The difference is that this invocation
2381 // runs in HCI command sending caller context while the callback
2382 // will happen in BAP's context whatever that may be
2383 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2384
2385 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2386 {
2387 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2388 // handle the error
2389 return(FALSE);
2390 }
2391
2392 break;
2393 }
2394 case BTAMP_TLV_HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_CMD:
2395 {
2396 tBtampTLVHCI_Write_Connection_Accept_Timeout_Cmd WriteConnectionAcceptTimeoutCmd;
2397 // unpack
2398 UnpackStatus = btampUnpackTlvHCI_Write_Connection_Accept_Timeout_Cmd( NULL,
2399 pBuf, Count, &WriteConnectionAcceptTimeoutCmd );
2400
2401 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2402 {
2403 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Connection_Accept_Timeout_Cmd failed status %d", UnpackStatus);
2404 // handle the error
2405 return(FALSE);
2406 }
2407
2408 VosStatus = WLAN_BAPWriteConnectionAcceptTimeout( pctx->bapHdl,
2409 &WriteConnectionAcceptTimeoutCmd, &HCIEvt );
2410
2411 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2412 {
2413 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteConnectionAcceptTimeout failed status %d", VosStatus);
2414 // handle the error
2415 return(FALSE);
2416 }
2417
2418 // this may look strange as this is the function registered
2419 // with BAP for the EventCB but we are also going to use it
2420 // as a helper function. The difference is that this invocation
2421 // runs in HCI command sending caller context while the callback
2422 // will happen in BAP's context whatever that may be
2423 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2424
2425 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2426 {
2427 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2428 // handle the error
2429 return(FALSE);
2430 }
2431
2432 break;
2433 }
2434 case BTAMP_TLV_HCI_READ_LINK_SUPERVISION_TIMEOUT_CMD:
2435 {
2436 tBtampTLVHCI_Read_Link_Supervision_Timeout_Cmd ReadLinkSupervisionTimeoutCmd;
2437 // unpack
2438 UnpackStatus = btampUnpackTlvHCI_Read_Link_Supervision_Timeout_Cmd( NULL,
2439 pBuf, Count, &ReadLinkSupervisionTimeoutCmd );
2440
2441 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2442 {
2443 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Link_Supervision_Timeout_Cmd failed status %d", UnpackStatus);
2444 // handle the error
2445 return(FALSE);
2446 }
2447
2448 VosStatus = WLAN_BAPReadLinkSupervisionTimeout( pctx->bapHdl,
2449 &ReadLinkSupervisionTimeoutCmd, &HCIEvt );
2450
2451 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2452 {
2453 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLinkSupervisionTimeout failed status %d", VosStatus);
2454 // handle the error
2455 return(FALSE);
2456 }
2457
2458 // this may look strange as this is the function registered
2459 // with BAP for the EventCB but we are also going to use it
2460 // as a helper function. The difference is that this invocation
2461 // runs in HCI command sending caller context while the callback
2462 // will happen in BAP's context whatever that may be
2463 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2464
2465 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2466 {
2467 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2468 // handle the error
2469 return(FALSE);
2470 }
2471
2472 break;
2473 }
2474 case BTAMP_TLV_HCI_WRITE_LINK_SUPERVISION_TIMEOUT_CMD:
2475 {
2476 tBtampTLVHCI_Write_Link_Supervision_Timeout_Cmd WriteLinkSupervisionTimeoutCmd;
2477 // unpack
2478 UnpackStatus = btampUnpackTlvHCI_Write_Link_Supervision_Timeout_Cmd( NULL,
2479 pBuf, Count, &WriteLinkSupervisionTimeoutCmd );
2480
2481 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2482 {
2483 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Link_Supervision_Timeout_Cmd failed status %d", UnpackStatus);
2484 // handle the error
2485 return(FALSE);
2486 }
2487
2488 VosStatus = WLAN_BAPWriteLinkSupervisionTimeout( pctx->bapHdl,
2489 &WriteLinkSupervisionTimeoutCmd, &HCIEvt );
2490
2491 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2492 {
2493 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteLinkSupervisionTimeout failed status %d", VosStatus);
2494 // handle the error
2495 return(FALSE);
2496 }
2497
2498 // this may look strange as this is the function registered
2499 // with BAP for the EventCB but we are also going to use it
2500 // as a helper function. The difference is that this invocation
2501 // runs in HCI command sending caller context while the callback
2502 // will happen in BAP's context whatever that may be
2503 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2504
2505 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2506 {
2507 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2508 // handle the error
2509 return(FALSE);
2510 }
2511
2512 break;
2513 }
2514 /* v3.0 Host Controller and Baseband Commands */
2515 case BTAMP_TLV_HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_CMD:
2516 {
2517 VosStatus = WLAN_BAPReadLogicalLinkAcceptTimeout( pctx->bapHdl, &HCIEvt );
2518
2519 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2520 {
2521 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLogicalLinkAcceptTimeout failed status %d", VosStatus);
2522 // handle the error
2523 return(FALSE);
2524 }
2525
2526 // this may look strange as this is the function registered
2527 // with BAP for the EventCB but we are also going to use it
2528 // as a helper function. The difference is that this invocation
2529 // runs in HCI command sending caller context while the callback
2530 // will happen in BAP's context whatever that may be
2531 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2532
2533 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2534 {
2535 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2536 // handle the error
2537 return(FALSE);
2538 }
2539
2540 break;
2541 }
2542 case BTAMP_TLV_HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_CMD:
2543 {
2544 tBtampTLVHCI_Write_Logical_Link_Accept_Timeout_Cmd WriteLogicalLinkAcceptTimeoutCmd;
2545 // unpack
2546 UnpackStatus = btampUnpackTlvHCI_Write_Logical_Link_Accept_Timeout_Cmd( NULL,
2547 pBuf, Count, &WriteLogicalLinkAcceptTimeoutCmd );
2548
2549 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2550 {
2551 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Logical_Link_Accept_Timeout_Cmd failed status %d", UnpackStatus);
2552 // handle the error
2553 return(FALSE);
2554 }
2555
2556 VosStatus = WLAN_BAPWriteLogicalLinkAcceptTimeout( pctx->bapHdl,
2557 &WriteLogicalLinkAcceptTimeoutCmd, &HCIEvt );
2558
2559 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2560 {
2561 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteLogicalLinkAcceptTimeout failed status %d", VosStatus);
2562 // handle the error
2563 return(FALSE);
2564 }
2565
2566 // this may look strange as this is the function registered
2567 // with BAP for the EventCB but we are also going to use it
2568 // as a helper function. The difference is that this invocation
2569 // runs in HCI command sending caller context while the callback
2570 // will happen in BAP's context whatever that may be
2571 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2572
2573 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2574 {
2575 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2576 // handle the error
2577 return(FALSE);
2578 }
2579
2580 break;
2581 }
2582 case BTAMP_TLV_HCI_SET_EVENT_MASK_PAGE_2_CMD:
2583 {
2584 tBtampTLVHCI_Set_Event_Mask_Page_2_Cmd SetEventMaskPage2Cmd;
2585 // unpack
2586 UnpackStatus = btampUnpackTlvHCI_Set_Event_Mask_Page_2_Cmd( NULL,
2587 pBuf, Count, &SetEventMaskPage2Cmd );
2588
2589 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2590 {
2591 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Set_Event_Mask_Page_2_Cmd failed status %d", UnpackStatus);
2592 // handle the error
2593 return(FALSE);
2594 }
2595
2596 VosStatus = WLAN_BAPSetEventMaskPage2( pctx->bapHdl,
2597 &SetEventMaskPage2Cmd, &HCIEvt );
2598
2599 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2600 {
2601 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPSetEventMaskPage2 failed status %d", VosStatus);
2602 // handle the error
2603 return(FALSE);
2604 }
2605
2606 // this may look strange as this is the function registered
2607 // with BAP for the EventCB but we are also going to use it
2608 // as a helper function. The difference is that this invocation
2609 // runs in HCI command sending caller context while the callback
2610 // will happen in BAP's context whatever that may be
2611 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2612
2613 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2614 {
2615 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2616 // handle the error
2617 return(FALSE);
2618 }
2619
2620 break;
2621 }
2622 case BTAMP_TLV_HCI_READ_LOCATION_DATA_CMD:
2623 {
2624 VosStatus = WLAN_BAPReadLocationData( pctx->bapHdl, &HCIEvt );
2625
2626 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2627 {
2628 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLocationData failed status %d", VosStatus);
2629 // handle the error
2630 return(FALSE);
2631 }
2632
2633 // this may look strange as this is the function registered
2634 // with BAP for the EventCB but we are also going to use it
2635 // as a helper function. The difference is that this invocation
2636 // runs in HCI command sending caller context while the callback
2637 // will happen in BAP's context whatever that may be
2638 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2639
2640 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2641 {
2642 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2643 // handle the error
2644 return(FALSE);
2645 }
2646
2647 break;
2648 }
2649 case BTAMP_TLV_HCI_WRITE_LOCATION_DATA_CMD:
2650 {
2651 tBtampTLVHCI_Write_Location_Data_Cmd WriteLocationDataCmd;
2652 // unpack
2653 UnpackStatus = btampUnpackTlvHCI_Write_Location_Data_Cmd( NULL,
2654 pBuf, Count, &WriteLocationDataCmd );
2655
2656 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2657 {
2658 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Location_Data_Cmd failed status %d", UnpackStatus);
2659 // handle the error
2660 return(FALSE);
2661 }
2662
2663 VosStatus = WLAN_BAPWriteLocationData( pctx->bapHdl,
2664 &WriteLocationDataCmd, &HCIEvt );
2665
2666 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2667 {
2668 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteLocationData failed status %d", VosStatus);
2669 // handle the error
2670 return(FALSE);
2671 }
2672
2673 // this may look strange as this is the function registered
2674 // with BAP for the EventCB but we are also going to use it
2675 // as a helper function. The difference is that this invocation
2676 // runs in HCI command sending caller context while the callback
2677 // will happen in BAP's context whatever that may be
2678 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2679
2680 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2681 {
2682 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2683 // handle the error
2684 return(FALSE);
2685 }
2686
2687 break;
2688 }
2689 case BTAMP_TLV_HCI_READ_FLOW_CONTROL_MODE_CMD:
2690 {
2691 VosStatus = WLAN_BAPReadFlowControlMode( pctx->bapHdl, &HCIEvt );
2692
2693 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2694 {
2695 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadFlowControlMode failed status %d", VosStatus);
2696 // handle the error
2697 return(FALSE);
2698 }
2699
2700 // this may look strange as this is the function registered
2701 // with BAP for the EventCB but we are also going to use it
2702 // as a helper function. The difference is that this invocation
2703 // runs in HCI command sending caller context while the callback
2704 // will happen in BAP's context whatever that may be
2705 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2706
2707 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2708 {
2709 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2710 // handle the error
2711 return(FALSE);
2712 }
2713
2714 break;
2715 }
2716 case BTAMP_TLV_HCI_WRITE_FLOW_CONTROL_MODE_CMD:
2717 {
2718 tBtampTLVHCI_Write_Flow_Control_Mode_Cmd WriteFlowControlModeCmd;
2719 // unpack
2720 UnpackStatus = btampUnpackTlvHCI_Write_Flow_Control_Mode_Cmd( NULL,
2721 pBuf, Count, &WriteFlowControlModeCmd );
2722
2723 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2724 {
2725 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Flow_Control_Mode_Cmd failed status %d", UnpackStatus);
2726 // handle the error
2727 return(FALSE);
2728 }
2729
2730 VosStatus = WLAN_BAPWriteFlowControlMode( pctx->bapHdl,
2731 &WriteFlowControlModeCmd, &HCIEvt );
2732
2733 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2734 {
2735 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteFlowControlMode failed status %d", VosStatus);
2736 // handle the error
2737 return(FALSE);
2738 }
2739
2740 // this may look strange as this is the function registered
2741 // with BAP for the EventCB but we are also going to use it
2742 // as a helper function. The difference is that this invocation
2743 // runs in HCI command sending caller context while the callback
2744 // will happen in BAP's context whatever that may be
2745 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2746
2747 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2748 {
2749 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2750 // handle the error
2751 return(FALSE);
2752 }
2753
2754 break;
2755 }
2756 case BTAMP_TLV_HCI_READ_BEST_EFFORT_FLUSH_TIMEOUT_CMD:
2757 {
2758 tBtampTLVHCI_Read_Best_Effort_Flush_Timeout_Cmd ReadBestEffortFlushTimeoutCmd;
2759 // unpack
2760 UnpackStatus = btampUnpackTlvHCI_Read_Best_Effort_Flush_Timeout_Cmd( NULL,
2761 pBuf, Count, &ReadBestEffortFlushTimeoutCmd );
2762
2763 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2764 {
2765 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Best_Effort_Flush_Timeout_Cmd failed status %d", UnpackStatus);
2766 // handle the error
2767 return(FALSE);
2768 }
2769
2770 VosStatus = WLAN_BAPReadBestEffortFlushTimeout( pctx->bapHdl,
2771 &ReadBestEffortFlushTimeoutCmd, &HCIEvt );
2772
2773 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2774 {
2775 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadBestEffortFlushTimeout failed status %d", VosStatus);
2776 // handle the error
2777 return(FALSE);
2778 }
2779
2780 // this may look strange as this is the function registered
2781 // with BAP for the EventCB but we are also going to use it
2782 // as a helper function. The difference is that this invocation
2783 // runs in HCI command sending caller context while the callback
2784 // will happen in BAP's context whatever that may be
2785 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2786
2787 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2788 {
2789 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2790 // handle the error
2791 return(FALSE);
2792 }
2793
2794 break;
2795 }
2796 case BTAMP_TLV_HCI_WRITE_BEST_EFFORT_FLUSH_TIMEOUT_CMD:
2797 {
2798 tBtampTLVHCI_Write_Best_Effort_Flush_Timeout_Cmd WriteBestEffortFlushTimeoutCmd;
2799 // unpack
2800 UnpackStatus = btampUnpackTlvHCI_Write_Best_Effort_Flush_Timeout_Cmd( NULL,
2801 pBuf, Count, &WriteBestEffortFlushTimeoutCmd);
2802
2803 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2804 {
2805 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Best_Effort_Flush_Timeout_Cmd failed status %d", UnpackStatus);
2806 // handle the error
2807 return(FALSE);
2808 }
2809
2810 VosStatus = WLAN_BAPWriteBestEffortFlushTimeout( pctx->bapHdl,
2811 &WriteBestEffortFlushTimeoutCmd, &HCIEvt );
2812
2813 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2814 {
2815 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteBestEffortFlushTimeout failed status %d", VosStatus);
2816 // handle the error
2817 return(FALSE);
2818 }
2819
2820 // this may look strange as this is the function registered
2821 // with BAP for the EventCB but we are also going to use it
2822 // as a helper function. The difference is that this invocation
2823 // runs in HCI command sending caller context while the callback
2824 // will happen in BAP's context whatever that may be
2825 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2826
2827 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2828 {
2829 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2830 // handle the error
2831 return(FALSE);
2832 }
2833
2834 break;
2835 }
2836 /** opcode definition for this command from AMP HCI CR D9r4 markup */
2837 case BTAMP_TLV_HCI_SET_SHORT_RANGE_MODE_CMD:
2838 {
2839 tBtampTLVHCI_Set_Short_Range_Mode_Cmd SetShortRangeModeCmd;
2840 // unpack
2841 UnpackStatus = btampUnpackTlvHCI_Set_Short_Range_Mode_Cmd( NULL,
2842 pBuf, Count, &SetShortRangeModeCmd);
2843
2844 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
2845 {
2846 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Set_Short_Range_Mode_Cmd failed status %d", UnpackStatus);
2847 // handle the error
2848 return(FALSE);
2849 }
2850
2851 VosStatus = WLAN_BAPSetShortRangeMode( pctx->bapHdl,
2852 &SetShortRangeModeCmd, &HCIEvt );
2853
2854 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2855 {
2856 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPSetShortRangeMode failed status %d", VosStatus);
2857 // handle the error
2858 return(FALSE);
2859 }
2860
2861 // this may look strange as this is the function registered
2862 // with BAP for the EventCB but we are also going to use it
2863 // as a helper function. The difference is that this invocation
2864 // runs in HCI command sending caller context while the callback
2865 // will happen in BAP's context whatever that may be
2866 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2867
2868 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2869 {
2870 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2871 // handle the error
2872 return(FALSE);
2873 }
2874
2875 break;
2876 }
2877 /* End of v3.0 Host Controller and Baseband Commands */
2878 /*
2879 Informational Parameters
2880 */
2881 case BTAMP_TLV_HCI_READ_LOCAL_VERSION_INFO_CMD:
2882 {
2883 VosStatus = WLAN_BAPReadLocalVersionInfo( pctx->bapHdl, &HCIEvt );
2884
2885 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2886 {
2887 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLocalVersionInfo failed status %d", VosStatus);
2888 // handle the error
2889 return(FALSE);
2890 }
2891
2892 // this may look strange as this is the function registered
2893 // with BAP for the EventCB but we are also going to use it
2894 // as a helper function. The difference is that this invocation
2895 // runs in HCI command sending caller context while the callback
2896 // will happen in BAP's context whatever that may be
2897 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2898
2899 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2900 {
2901 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2902 // handle the error
2903 return(FALSE);
2904 }
2905
2906 break;
2907 }
2908 case BTAMP_TLV_HCI_READ_LOCAL_SUPPORTED_CMDS_CMD:
2909 {
2910 VosStatus = WLAN_BAPReadLocalSupportedCmds( pctx->bapHdl, &HCIEvt );
2911
2912 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2913 {
2914 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLocalSupportedCmds failed status %d", VosStatus);
2915 // handle the error
2916 return(FALSE);
2917 }
2918
2919 // this may look strange as this is the function registered
2920 // with BAP for the EventCB but we are also going to use it
2921 // as a helper function. The difference is that this invocation
2922 // runs in HCI command sending caller context while the callback
2923 // will happen in BAP's context whatever that may be
2924 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2925
2926 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2927 {
2928 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2929 // handle the error
2930 return(FALSE);
2931 }
2932
2933 break;
2934 }
2935 case BTAMP_TLV_HCI_READ_BUFFER_SIZE_CMD:
2936 {
2937 VosStatus = WLAN_BAPReadBufferSize( pctx->bapHdl, &HCIEvt );
2938
2939 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2940 {
2941 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadBufferSize failed status %d", VosStatus);
2942 // handle the error
2943 return(FALSE);
2944 }
2945
2946 // this may look strange as this is the function registered
2947 // with BAP for the EventCB but we are also going to use it
2948 // as a helper function. The difference is that this invocation
2949 // runs in HCI command sending caller context while the callback
2950 // will happen in BAP's context whatever that may be
2951 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2952
2953 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2954 {
2955 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2956 // handle the error
2957 return(FALSE);
2958 }
2959
2960 break;
2961 }
2962 /* v3.0 Informational commands */
2963 case BTAMP_TLV_HCI_READ_DATA_BLOCK_SIZE_CMD:
2964 {
2965 VosStatus = WLAN_BAPReadDataBlockSize( pctx->bapHdl, &HCIEvt );
2966
2967 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2968 {
2969 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadDataBlockSize failed status %d", VosStatus);
2970 // handle the error
2971 return(FALSE);
2972 }
2973
2974 // this may look strange as this is the function registered
2975 // with BAP for the EventCB but we are also going to use it
2976 // as a helper function. The difference is that this invocation
2977 // runs in HCI command sending caller context while the callback
2978 // will happen in BAP's context whatever that may be
2979 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
2980
2981 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
2982 {
2983 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
2984 // handle the error
2985 return(FALSE);
2986 }
2987
2988 break;
2989 }
2990 /*
2991 Status Parameters
2992 */
2993 case BTAMP_TLV_HCI_READ_FAILED_CONTACT_COUNTER_CMD:
2994 {
2995 tBtampTLVHCI_Read_Failed_Contact_Counter_Cmd ReadFailedContactCounterCmd;
2996 // unpack
2997 UnpackStatus = btampUnpackTlvHCI_Read_Failed_Contact_Counter_Cmd( NULL,
2998 pBuf, Count, &ReadFailedContactCounterCmd );
2999
3000 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3001 {
3002 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Failed_Contact_Counter_Cmd failed status %d", UnpackStatus);
3003 // handle the error
3004 return(FALSE);
3005 }
3006
3007 VosStatus = WLAN_BAPReadFailedContactCounter( pctx->bapHdl,
3008 &ReadFailedContactCounterCmd, &HCIEvt );
3009
3010 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3011 {
3012 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadFailedContactCounter failed status %d", VosStatus);
3013 // handle the error
3014 return(FALSE);
3015 }
3016
3017 // this may look strange as this is the function registered
3018 // with BAP for the EventCB but we are also going to use it
3019 // as a helper function. The difference is that this invocation
3020 // runs in HCI command sending caller context while the callback
3021 // will happen in BAP's context whatever that may be
3022 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3023
3024 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3025 {
3026 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3027 // handle the error
3028 return(FALSE);
3029 }
3030
3031 break;
3032 }
3033 case BTAMP_TLV_HCI_RESET_FAILED_CONTACT_COUNTER_CMD:
3034 {
3035 tBtampTLVHCI_Reset_Failed_Contact_Counter_Cmd ResetFailedContactCounterCmd;
3036 // unpack
3037 UnpackStatus = btampUnpackTlvHCI_Reset_Failed_Contact_Counter_Cmd( NULL,
3038 pBuf, Count, &ResetFailedContactCounterCmd);
3039
3040 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3041 {
3042 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Reset_Failed_Contact_Counter_Cmd failed status %d", UnpackStatus);
3043 // handle the error
3044 return(FALSE);
3045 }
3046
3047 VosStatus = WLAN_BAPResetFailedContactCounter( pctx->bapHdl,
3048 &ResetFailedContactCounterCmd, &HCIEvt );
3049
3050 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3051 {
3052 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPResetFailedContactCounter failed status %d", VosStatus);
3053 // handle the error
3054 return(FALSE);
3055 }
3056
3057 // this may look strange as this is the function registered
3058 // with BAP for the EventCB but we are also going to use it
3059 // as a helper function. The difference is that this invocation
3060 // runs in HCI command sending caller context while the callback
3061 // will happen in BAP's context whatever that may be
3062 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3063
3064 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3065 {
3066 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3067 // handle the error
3068 return(FALSE);
3069 }
3070
3071 break;
3072 }
3073 case BTAMP_TLV_HCI_READ_LINK_QUALITY_CMD:
3074 {
3075 tBtampTLVHCI_Read_Link_Quality_Cmd ReadLinkQualityCmd;
3076 // unpack
3077 UnpackStatus = btampUnpackTlvHCI_Read_Link_Quality_Cmd( NULL,
3078 pBuf, Count, &ReadLinkQualityCmd );
3079
3080 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3081 {
3082 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Link_Quality_Cmd failed status %d", UnpackStatus);
3083 // handle the error
3084 return(FALSE);
3085 }
3086
3087 VosStatus = WLAN_BAPReadLinkQuality( pctx->bapHdl,
3088 &ReadLinkQualityCmd, &HCIEvt );
3089
3090 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3091 {
3092 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLinkQuality failed status %d", VosStatus);
3093 // handle the error
3094 return(FALSE);
3095 }
3096
3097 // this may look strange as this is the function registered
3098 // with BAP for the EventCB but we are also going to use it
3099 // as a helper function. The difference is that this invocation
3100 // runs in HCI command sending caller context while the callback
3101 // will happen in BAP's context whatever that may be
3102 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3103
3104 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3105 {
3106 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3107 // handle the error
3108 return(FALSE);
3109 }
3110
3111 break;
3112 }
3113 case BTAMP_TLV_HCI_READ_RSSI_CMD:
3114 {
3115 tBtampTLVHCI_Read_RSSI_Cmd ReadRssiCmd;
3116 // unpack
3117 UnpackStatus = btampUnpackTlvHCI_Read_RSSI_Cmd( NULL,
3118 pBuf, Count, &ReadRssiCmd );
3119
3120 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3121 {
3122 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_RSSI_Cmd failed status %d", UnpackStatus);
3123 // handle the error
3124 return(FALSE);
3125 }
3126
3127 VosStatus = WLAN_BAPReadRSSI( pctx->bapHdl,
3128 &ReadRssiCmd, &HCIEvt );
3129
3130 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3131 {
3132 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadRSSI failed status %d", VosStatus);
3133 // handle the error
3134 return(FALSE);
3135 }
3136
3137 // this may look strange as this is the function registered
3138 // with BAP for the EventCB but we are also going to use it
3139 // as a helper function. The difference is that this invocation
3140 // runs in HCI command sending caller context while the callback
3141 // will happen in BAP's context whatever that may be
3142 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3143
3144 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3145 {
3146 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3147 // handle the error
3148 return(FALSE);
3149 }
3150
3151 break;
3152 }
3153 case BTAMP_TLV_HCI_READ_LOCAL_AMP_INFORMATION_CMD:
3154 {
3155 tBtampTLVHCI_Read_Local_AMP_Information_Cmd ReadLocalAmpInformationCmd;
3156 // unpack
3157 UnpackStatus = btampUnpackTlvHCI_Read_Local_AMP_Information_Cmd( NULL,
3158 pBuf, Count, &ReadLocalAmpInformationCmd );
3159
3160 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3161 {
3162 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Local_AMP_Information_Cmd failed status %d", UnpackStatus);
3163 // handle the error
3164 return(FALSE);
3165 }
3166
3167 VosStatus = WLAN_BAPReadLocalAMPInfo( pctx->bapHdl,
3168 &ReadLocalAmpInformationCmd, &HCIEvt );
3169
3170 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3171 {
3172 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLocalAMPInfo failed status %d", VosStatus);
3173 // handle the error
3174 return(FALSE);
3175 }
3176
3177 // this may look strange as this is the function registered
3178 // with BAP for the EventCB but we are also going to use it
3179 // as a helper function. The difference is that this invocation
3180 // runs in HCI command sending caller context while the callback
3181 // will happen in BAP's context whatever that may be
3182 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3183
3184 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3185 {
3186 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3187 // handle the error
3188 return(FALSE);
3189 }
3190
3191 break;
3192 }
3193 case BTAMP_TLV_HCI_READ_LOCAL_AMP_ASSOC_CMD:
3194 {
3195 tBtampTLVHCI_Read_Local_AMP_Assoc_Cmd ReadLocalAmpAssocCmd;
3196 // unpack
3197 UnpackStatus = btampUnpackTlvHCI_Read_Local_AMP_Assoc_Cmd( NULL,
3198 pBuf, Count, &ReadLocalAmpAssocCmd );
3199
3200 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3201 {
3202 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Local_AMP_Assoc_Cmd failed status %d", UnpackStatus);
3203 // handle the error
3204 return(FALSE);
3205 }
3206
3207 VosStatus = WLAN_BAPReadLocalAMPAssoc( pctx->bapHdl,
3208 &ReadLocalAmpAssocCmd, &HCIEvt );
3209
3210 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3211 {
3212 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLocalAMPAssoc failed status %d", VosStatus);
3213 // handle the error
3214 return(FALSE);
3215 }
3216
3217 // this may look strange as this is the function registered
3218 // with BAP for the EventCB but we are also going to use it
3219 // as a helper function. The difference is that this invocation
3220 // runs in HCI command sending caller context while the callback
3221 // will happen in BAP's context whatever that may be
3222 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3223
3224 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3225 {
3226 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3227 // handle the error
3228 return(FALSE);
3229 }
3230
3231 break;
3232 }
3233 case BTAMP_TLV_HCI_WRITE_REMOTE_AMP_ASSOC_CMD:
3234 {
3235 tBtampTLVHCI_Write_Remote_AMP_ASSOC_Cmd WriteRemoteAmpAssocCmd;
3236 // unpack
3237
3238 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: HCI_Write_Remote_AMP_ASSOC_Cmd Count = %d", Count);
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003239 DUMPLOG(1, __func__, "HCI_Write_Remote_AMP_ASSOC cmd",
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 pBuf,
3241 Count);
3242
3243 UnpackStatus = btampUnpackTlvHCI_Write_Remote_AMP_ASSOC_Cmd( NULL,
3244 pBuf, Count, &WriteRemoteAmpAssocCmd );
3245
3246 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WriteRemoteAmpAssocCmd.amp_assoc_remaining_length = %d",
3247 WriteRemoteAmpAssocCmd.amp_assoc_remaining_length
3248 );
3249
3250 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3251 {
3252 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Remote_AMP_ASSOC_Cmd failed status %d", UnpackStatus);
3253 // handle the error
3254 return(FALSE);
3255 }
3256
3257//#define BAP_UNIT_TEST
3258#ifdef BAP_UNIT_TEST
3259 {
3260 unsigned char test_amp_assoc_fragment[] =
3261 {
3262 0x01, 0x00, 0x06, 0x00, 0x00, 0xde, 0xad, 0xbe,
3263 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
3264 0x0c, 0x00, 0x55, 0x53, 0x20, 0xc9, 0x0c, 0x00,
3265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3266 0x00, 0x00, 0x03, 0x00, 0x06, 0x00, 0x55, 0x53,
3267 0x20, 0xc9, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
3268 0x04, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00,
3269 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00,
3270 0x00, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3271 0x00, 0x00
3272 };
3273 WriteRemoteAmpAssocCmd.present = 1;
3274 WriteRemoteAmpAssocCmd.phy_link_handle = 1;
3275 WriteRemoteAmpAssocCmd.length_so_far = 0;
3276 WriteRemoteAmpAssocCmd.amp_assoc_remaining_length = 74;
3277 /* Set the amp_assoc_fragment to the right values of MAC addr and
3278 * channels
3279 */
3280 vos_mem_copy(
3281 WriteRemoteAmpAssocCmd.amp_assoc_fragment,
3282 test_amp_assoc_fragment,
3283 sizeof( test_amp_assoc_fragment));
3284
3285 }
3286#endif
3287
3288 VosStatus = WLAN_BAPWriteRemoteAMPAssoc( pctx->bapHdl,
3289 &WriteRemoteAmpAssocCmd, &HCIEvt );
3290
3291 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3292 {
3293 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteRemoteAMPAssoc failed status %d", VosStatus);
3294 // handle the error
3295 return(FALSE);
3296 }
3297
3298 // this may look strange as this is the function registered
3299 // with BAP for the EventCB but we are also going to use it
3300 // as a helper function. The difference is that this invocation
3301 // runs in HCI command sending caller context while the callback
3302 // will happen in BAP's context whatever that may be
3303 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3304
3305 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3306 {
3307 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3308 // handle the error
3309 return(FALSE);
3310 }
3311
3312 break;
3313 }
3314 /*
3315 Debug Commands
3316 */
3317 case BTAMP_TLV_HCI_READ_LOOPBACK_MODE_CMD:
3318 {
3319 tBtampTLVHCI_Read_Loopback_Mode_Cmd ReadLoopbackModeCmd;
3320 // unpack
3321 UnpackStatus = btampUnpackTlvHCI_Read_Loopback_Mode_Cmd( NULL,
3322 pBuf, Count, &ReadLoopbackModeCmd );
3323
3324 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3325 {
3326 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Read_Loopback_Mode_Cmd failed status %d", UnpackStatus);
3327 // handle the error
3328 return(FALSE);
3329 }
3330
3331 VosStatus = WLAN_BAPReadLoopbackMode( pctx->bapHdl,
3332 &ReadLoopbackModeCmd, &HCIEvt );
3333
3334 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3335 {
3336 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPReadLoopbackMode failed status %d", VosStatus);
3337 // handle the error
3338 return(FALSE);
3339 }
3340
3341 // this may look strange as this is the function registered
3342 // with BAP for the EventCB but we are also going to use it
3343 // as a helper function. The difference is that this invocation
3344 // runs in HCI command sending caller context while the callback
3345 // will happen in BAP's context whatever that may be
3346 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3347
3348 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3349 {
3350 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3351 // handle the error
3352 return(FALSE);
3353 }
3354
3355 break;
3356 }
3357 case BTAMP_TLV_HCI_WRITE_LOOPBACK_MODE_CMD:
3358 {
3359 tBtampTLVHCI_Write_Loopback_Mode_Cmd WriteLoopbackModeCmd;
3360 // unpack
3361 UnpackStatus = btampUnpackTlvHCI_Write_Loopback_Mode_Cmd( NULL,
3362 pBuf, Count, &WriteLoopbackModeCmd );
3363
3364 if ( !BTAMP_SUCCEEDED( UnpackStatus ) )
3365 {
3366 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: btampUnpackTlvHCI_Write_Loopback_Mode_Cmd failed status %d", UnpackStatus);
3367 // handle the error
3368 return(FALSE);
3369 }
3370
3371 VosStatus = WLAN_BAPWriteLoopbackMode( pctx->bapHdl,
3372 &WriteLoopbackModeCmd, &HCIEvt );
3373
3374 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3375 {
3376 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPWriteLoopbackMode failed status %d", VosStatus);
3377 // handle the error
3378 return(FALSE);
3379 }
3380
3381 // this may look strange as this is the function registered
3382 // with BAP for the EventCB but we are also going to use it
3383 // as a helper function. The difference is that this invocation
3384 // runs in HCI command sending caller context while the callback
3385 // will happen in BAP's context whatever that may be
3386 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3387
3388 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3389 {
3390 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3391 // handle the error
3392 return(FALSE);
3393 }
3394
3395 break;
3396 }
3397 case BTAMP_TLV_HCI_VENDOR_SPECIFIC_CMD_0:
3398 {
3399 VosStatus = WLAN_BAPVendorSpecificCmd0( pctx->bapHdl, &HCIEvt );
3400
3401 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3402 {
3403 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPVendorSpecificCmd0 failed status %d", VosStatus);
3404 // handle the error
3405 return(FALSE);
3406 }
3407
3408 // this may look strange as this is the function registered
3409 // with BAP for the EventCB but we are also going to use it
3410 // as a helper function. The difference is that this invocation
3411 // runs in HCI command sending caller context while the callback
3412 // will happen in BAP's context whatever that may be
3413 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3414
3415 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3416 {
3417 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3418 // handle the error
3419 return(FALSE);
3420 }
3421
3422 break;
3423 }
3424 case BTAMP_TLV_HCI_VENDOR_SPECIFIC_CMD_1:
3425 {
3426 VosStatus = WLAN_BAPVendorSpecificCmd1( pctx->bapHdl, &HCIEvt );
3427
3428 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3429 {
3430 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLAN_BAPVendorSpecificCmd1 failed status %d", VosStatus);
3431 // handle the error
3432 return(FALSE);
3433 }
3434
3435 // this may look strange as this is the function registered
3436 // with BAP for the EventCB but we are also going to use it
3437 // as a helper function. The difference is that this invocation
3438 // runs in HCI command sending caller context while the callback
3439 // will happen in BAP's context whatever that may be
3440 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3441
3442 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3443 {
3444 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3445 // handle the error
3446 return(FALSE);
3447 }
3448
3449 break;
3450 }
3451 default:
3452 {
3453 /* Unknow opcode. Return a command status event...with "Unknown Opcode" status */
3454
3455 /* Format the command status event to return... */
3456 HCIEvt.bapHCIEventCode = BTAMP_TLV_HCI_COMMAND_STATUS_EVENT;
3457 HCIEvt.u.btampCommandStatusEvent.present = 1;
3458 HCIEvt.u.btampCommandStatusEvent.status = WLANBAP_ERROR_UNKNOWN_HCI_CMND;
3459 HCIEvt.u.btampCommandStatusEvent.num_hci_command_packets = 1;
3460 HCIEvt.u.btampCommandStatusEvent.command_opcode
3461 = cmdOpcode;
3462
3463 // this may look strange as this is the function registered
3464 // with BAP for the EventCB but we are also going to use it
3465 // as a helper function. The difference is that this invocation
3466 // runs in HCI command sending caller context while the callback
3467 // will happen in BAP's context whatever that may be
3468 VosStatus = WLANBAP_EventCB( pctx, &HCIEvt, FALSE );
3469
3470 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3471 {
3472 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BslProcessHCICommand: WLANBAP_EventCB failed status %d", VosStatus);
3473 // handle the error
3474 return(FALSE);
3475 }
3476
3477
3478 break;
3479 }
3480 }
3481
3482 return(TRUE);
3483} // BslProcessHCICommand()
3484
3485
3486/**
3487 @brief BslProcessACLDataTx() - This function will process an egress ACL data packet
3488
3489 @param pctx : [in] ptr to the client context
3490 @param pBuffer_ : [in] ptr to the buffer containing the ACL data packet
3491 @param pCount : [in] size of the ACL data packet buffer
3492
3493 @return
3494 TRUE if all OK, FALSE otherwise
3495
3496*/
3497#define BTAMP_USE_VOS_WRAPPER
3498//#undef BTAMP_USE_VOS_WRAPPER
3499#ifdef BTAMP_USE_VOS_WRAPPER
3500static BOOL BslProcessACLDataTx
3501(
3502 BslClientCtxType* pctx,
3503 struct sk_buff *skb,
3504 v_SIZE_t* pCount
3505)
3506#else
3507static BOOL BslProcessACLDataTx
3508(
3509 BslClientCtxType* pctx,
3510 LPCVOID pBuffer_,
3511 v_SIZE_t* pCount
3512)
3513#endif
3514{
3515#ifndef BTAMP_USE_VOS_WRAPPER
3516 LPVOID pBuffer = (LPVOID) pBuffer_; // castaway const-ness of ptr
3517#endif
3518 BOOL findPhyStatus;
3519 BslPhyLinkCtxType* pPhyCtx;
3520 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
3521 WLANTL_ACEnumType Ac;
3522 hdd_list_node_t* pLink;
3523 BslTxListNodeType *pNode;
3524 v_SIZE_t ListSize;
3525 // I will access the skb in a VOSS packet
3526#ifndef BTAMP_USE_VOS_WRAPPER
3527 struct sk_buff *skb;
3528#endif
3529#if 0
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07003530 static int num_packets;
Jeff Johnson295189b2012-06-20 16:38:30 -07003531#endif
3532
3533 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "BslProcessACLDataTx\n" );
3534
3535 // need to find the PHY link for this ACL data pkt based on phy_link_handle
3536 // TODO need some endian-ness check?
3537 ////findPhyStatus = BslFindPhyCtx( pctx, *(v_U8_t *)skb->data, &pPhyCtx );
3538 //findPhyStatus = BslFindPhyCtx( pctx, *(v_U8_t *)pBuffer, &pPhyCtx );
3539 // JEZ100604: Temporary short cut
3540 pPhyCtx = &BslPhyLinkCtx[0];
3541 findPhyStatus = VOS_TRUE;
3542
3543 if ( findPhyStatus )
3544 {
3545 //Use the skb->cb field to hold the list node information
3546 pNode = (BslTxListNodeType *) &skb->cb;
3547
3548 // This list node info includes the VOS pkt
3549 pNode->skb = skb;
3550
3551 // stick the SKB into the node
3552 pLink = (hdd_list_node_t *) pNode;
3553 VosStatus = WLANBAP_GetAcFromTxDataPkt(pctx->bapHdl, skb->data, &Ac);
3554 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3555 {
3556 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessACLDataTx WLANBAP_GetAcFromTxDataPkt "
3557 "failed status =%d\n", VosStatus );
3558
3559 Ac = WLANTL_AC_BE;
3560 }
3561
3562 // now queue the pkt into the correct queue
3563 // We will want to insert a node of type BslTxListNodeType (was going to be vos_pkt_list_node_t)
3564 spin_lock_bh(&pPhyCtx->ACLTxQueue[Ac].lock);
3565 VosStatus = hdd_list_insert_back( &pPhyCtx->ACLTxQueue[Ac], pLink );
3566 spin_unlock_bh(&pPhyCtx->ACLTxQueue[Ac].lock);
3567
3568 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3569 {
3570 VOS_ASSERT(0);
3571 }
3572
3573 // determine if there is a need to signal TL through BAP
3574 hdd_list_size( &pPhyCtx->ACLTxQueue[Ac], &ListSize );
3575
3576 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3577 {
3578 VOS_ASSERT(0);
3579 }
3580
3581 if ( ListSize == 1 )
3582 {
3583 // Let TL know we have a packet to send for this AC
3584 VosStatus = WLANBAP_STAPktPending( pctx->bapHdl, pPhyCtx->PhyLinkHdl, Ac );
3585
3586 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3587 {
3588 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessACLDataTx WLANBAP_STAPktPending "
3589 "failed status =%d\n", VosStatus );
3590 VOS_ASSERT(0);
3591 }
3592 }
3593
3594 return(TRUE);
3595 }
3596 else
3597 {
3598 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BslProcessACLDataTx attempting to send "
3599 "data for a non-existant assocation\n" );
3600
3601 return(FALSE);
3602 }
3603
3604
3605} // BslProcessACLDataTx()
3606
3607
3608static inline void *hci_get_drvdata(struct hci_dev *hdev)
3609{
3610 return hdev->driver_data;
3611}
3612
3613static inline void hci_set_drvdata(struct hci_dev *hdev, void *data)
3614{
3615 hdev->driver_data = data;
3616}
3617
3618/*---------------------------------------------------------------------------
3619 * Function definitions
3620 *-------------------------------------------------------------------------*/
3621
3622/**---------------------------------------------------------------------------
3623
3624 \brief BSL_Init() - Initialize the BSL Misc char driver
3625
3626 This is called in vos_open(), right after WLANBAP_Open(), as part of
3627 bringing up the BT-AMP PAL (BAP)
3628 vos_open() will pass in the VOS context. In which a BSL context can be created.
3629
3630 \param - NA
3631
3632 \return - 0 for success non-zero for failure
3633
3634 --------------------------------------------------------------------------*/
3635//int BSL_Init (void *pCtx)
3636int BSL_Init ( v_PVOID_t pvosGCtx )
3637{
3638 BslClientCtxType* pctx = NULL;
3639 ptBtampHandle bapHdl = NULL; // our handle in BAP
3640 //ptBtampContext pBtampCtx = NULL;
3641 int err = 0;
3642 struct hci_dev *hdev = NULL;
3643 //struct net_device *dev = NULL; // Our parent wlan network device
3644 hdd_adapter_t *pAdapter = NULL; // Used to retrieve the parent WLAN device
3645 hdd_context_t *pHddCtx = NULL;
3646 hdd_config_t *pConfig = NULL;
3647 hdd_adapter_list_node_t *pAdapterNode = NULL;
3648 VOS_STATUS status;
3649
3650 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_Init");
3651
3652 /*------------------------------------------------------------------------
3653 Allocate (and sanity check?!) BSL control block
3654 ------------------------------------------------------------------------*/
3655 //vos_alloc_context(pvosGCtx, VOS_MODULE_ID_BSL, (v_VOID_t**)&pctx, sizeof(BslClientCtxType));
3656 pctx = &BslClientCtx[0];
3657
3658 bapHdl = vos_get_context( VOS_MODULE_ID_BAP, pvosGCtx);
3659 if ( NULL == bapHdl )
3660 {
3661 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
3662 "Invalid BAP pointer from pvosGCtx on BSL_Init");
3663 return VOS_STATUS_E_FAULT;
3664 }
3665 // Save away the btamp (actually the vos) context
3666 gpCtx = pvosGCtx;
3667
3668 /* Save away the pointer to the BT-AMP PAL context in the BSL driver context */
3669 pctx->bapHdl = bapHdl;
3670
3671 /* Save away the pointer to the BSL driver context in a global (fix this) */
3672 gpBslctx = pctx;
3673
3674 /* Initialize all the Phy Contexts to un-used */
3675 BslInitPhyCtx();
3676
3677 /* Initialize the Rx fields in the HCI driver context */
3678 //pctx->rx_state = RECV_WAIT_PACKET_TYPE;
3679 pctx->rx_count = 0;
3680 pctx->rx_skb = NULL;
3681
3682 /* JEZ100713: Temporarily the Tx skb queue will have depth one.*/
3683 // Don't disturb tx_skb
3684 //pctx->tx_skb = NULL;
3685 //pctx->tx_skb = alloc_skb(WLANBAP_MAX_80211_PAL_PDU_SIZE+12, GFP_ATOMIC);
3686
3687 pctx->hdev = NULL;
3688 //Get the HDD context.
3689 pHddCtx = (hdd_context_t *)vos_get_context( VOS_MODULE_ID_HDD, pvosGCtx );
3690 if(NULL != pHddCtx)
3691 {
3692 pConfig = pHddCtx->cfg_ini;
3693 }
3694 if(NULL == pConfig)
3695 {
3696 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
3697 "Didn't register as HCI device");
3698 return 0;
3699 }
3700 else if(0 == pConfig->enableBtAmp)
3701 {
3702 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
3703 "Didn't register as HCI device, user option(gEnableBtAmp) is set to 0");
3704 return 0;
3705 }
3706
3707#ifdef WLAN_SOFTAP_FEATURE
3708 if (VOS_STA_SAP_MODE == hdd_get_conparam())
3709 {
3710 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
3711 if ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
3712 {
3713 if ( WLAN_HDD_SOFTAP == pAdapterNode->pAdapter->device_mode)
3714 {
3715 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
3716 }
3717 else if (WLAN_HDD_P2P_GO == pAdapterNode->pAdapter->device_mode)
3718 {
3719 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO);
3720 }
3721 }
3722 }
3723 else
3724#endif
3725 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
3726
3727
3728 if ( NULL == pAdapter )
3729 {
3730 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
3731 "Invalid HDD Adapter pointer from pvosGCtx on BSL_Init");
3732 return VOS_STATUS_E_FAULT;
3733 }
3734
3735 /* Save away the pointer to the parent WLAN device in BSL driver context */
3736 pctx->p_dev = pAdapter->dev;
3737
3738 /* Initialize HCI device */
3739 hdev = hci_alloc_dev();
3740 if (!hdev)
3741 {
3742 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
3743 "Can't allocate HCI device in BSL_Init");
3744 return VOS_STATUS_E_FAULT;
3745 }
3746
3747 /* Save away the HCI device pointer in the BSL driver context */
3748 pctx->hdev = hdev;
3749
3750#if defined HCI_80211 || defined HCI_AMP
3751#define BUILD_FOR_BLUETOOTH_NEXT_2_6
3752#else
3753#undef BUILD_FOR_BLUETOOTH_NEXT_2_6
3754#endif
3755
3756#ifdef BUILD_FOR_BLUETOOTH_NEXT_2_6
3757 /* HCI "bus type" of HCI_VIRTUAL should apply */
3758 hdev->bus = HCI_VIRTUAL;
3759 /* Set the dev_type to BT-AMP 802.11 */
3760#ifdef HCI_80211
3761 hdev->dev_type = HCI_80211;
3762#else
3763 hdev->dev_type = HCI_AMP;
3764#endif
3765#ifdef FEATURE_WLAN_BTAMP_UT
3766 /* For the "real" BlueZ build, DON'T Set the device "quirks" to indicate RAW */
3767 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
3768#endif
3769#else //BUILD_FOR_BLUETOOTH_NEXT_2_6
3770 /* HCI "bus type" of HCI_VIRTUAL should apply */
3771 hdev->type = HCI_VIRTUAL;
3772 /* Set the dev_type to BT-AMP 802.11 */
3773 //hdev->dev_type = HCI_80211;
3774 ////hdev->dev_type = HCI_AMP;
3775 /* For the "temporary" BlueZ build, Set the device "quirks" to indicate RAW */
3776 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
3777#endif //BUILD_FOR_BLUETOOTH_NEXT_2_6
3778 /* Save away the BSL driver pointer in the HCI device context */
3779
3780 hci_set_drvdata(hdev, pctx);
3781 /* Set the parent device for this HCI device. This is our WLAN net_device */
3782 SET_HCIDEV_DEV(hdev, &pctx->p_dev->dev);
3783
3784 hdev->open = BSL_Open;
3785 hdev->close = BSL_Close;
3786 hdev->flush = BSL_Flush;
3787 hdev->send = BSL_Write;
3788#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3789 hdev->destruct = BSL_Destruct;
3790 hdev->owner = THIS_MODULE;
3791#endif
3792 hdev->ioctl = BSL_IOControl;
3793
3794
3795 /* Timeout before it is safe to send the first HCI packet */
3796 msleep(1000);
3797
3798 /* Register HCI device */
3799 err = hci_register_dev(hdev);
3800 if (err < 0)
3801 {
3802 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
3803 "Unable to register HCI device, err=%d\n", err);
3804 pctx->hdev = NULL;
3805 hci_free_dev(hdev);
3806 return -ENODEV;
3807 }
3808
3809 pHddCtx->isAmpAllowed = VOS_TRUE;
3810 return 0;
3811} // BSL_Init()
3812
3813/**---------------------------------------------------------------------------
3814
3815 \brief BSL_Deinit() - De-initialize the BSL Misc char driver
3816
3817 This is called in by WLANBAP_Close() as part of bringing down the BT-AMP PAL (BAP)
3818
3819 \param - NA
3820
3821 \return - 0 for success non-zero for failure
3822
3823 --------------------------------------------------------------------------*/
3824
3825int BSL_Deinit( v_PVOID_t pvosGCtx )
3826{
3827 //int err = 0;
3828 struct hci_dev *hdev;
3829 BslClientCtxType* pctx = NULL;
3830
3831 //pctx = vos_get_context( VOS_MODULE_ID_BSL, pvosGCtx);
3832 pctx = gpBslctx;
3833
3834 if ( NULL == pctx )
3835 {
3836 //VOS_TRACE( VOS_MODULE_ID_BSL, VOS_TRACE_LEVEL_ERROR,
3837 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
3838 "Invalid BSL pointer from pvosGCtx on BSL_Init");
3839 return VOS_STATUS_E_FAULT;
3840 }
3841
3842 /* Retrieve the HCI device pointer from the BSL driver context */
3843 hdev = pctx->hdev;
3844
3845 if (!hdev)
3846 return 0;
3847
3848 /* hci_unregister_dev is called again here, in case user didn't call it */
3849 /* Unregister device from BlueZ; fcn sends us HCI commands before it returns */
3850 /* And then the registered hdev->close fcn should be called by BlueZ (BSL_Close) */
3851 hci_unregister_dev(hdev);
3852 /* BSL_Close is called again here, in case BlueZ didn't call it */
3853 BSL_Close(hdev);
3854 hci_free_dev(hdev);
3855 pctx->hdev = NULL;
3856
3857 return 0;
3858} // BSL_Deinit()
3859
3860
3861/**
3862 @brief BSL_Open() - This function opens a device for reading, and writing.
3863 An application indirectly invokes this function when it calls the fopen()
3864 system call to open a special device file names.
3865
3866 @param *hdev : [in] pointer to the open HCI device structure.
3867 BSL_Init (Device Manager) function creates and stores this HCI
3868 device context in the BSL context.
3869
3870 @return
3871 This function returns a status code. Negative codes are failures.
3872
3873 NB: I don't seem to be following this convention.
3874*/
3875//static int BSL_Open(struct inode *pInode, struct file *pFile)
3876static int BSL_Open( struct hci_dev *hdev )
3877{
3878 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
3879 BslClientCtxType* pctx = (BslClientCtxType *)(hci_get_drvdata(hdev));
3880 v_U16_t i;
3881 BOOL rval;
3882
3883 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_Open");
3884
3885 /* you can only open a btamp device one time */
3886 if (bBslInited)
3887 {
3888 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "BSL_Open: Already Opened.");
3889 return -EPERM; /* Operation not permitted */
3890 }
3891
3892 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3893 {
3894 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSLClientLock already inited");
3895 // return -EIO; /* I/O error */
3896 return 0;
3897 }
3898
3899 VosStatus = vos_list_init( &BslPhyLinksDescPool );
3900
3901 if ( !VOS_IS_STATUS_SUCCESS( VosStatus ) )
3902 {
3903 //return -EIO; /* I/O error */
3904 return 0;
3905 }
3906
3907 // now we need to populate this pool with the free pkt desc from the array
3908 for ( i=0; i<BSL_MAX_PHY_LINKS; i++ )
3909 {
3910 VosStatus = vos_list_insert_front( &BslPhyLinksDescPool, &BslPhyLinksDesc[i].node );
3911 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
3912 }
3913
3914 // This is redundent. See the check above on (fp->private_data != NULL)
3915 bBslInited = TRUE;
3916
3917 rval = BslFindAndInitClientCtx( &pctx );
3918
3919 if(rval != TRUE)
3920 {
3921 // Where is the clean-up in case the above BslFindAndInitClientCtx() call
3922 // fails?
3923 //return -EIO; /* I/O error */
3924 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSLFindAndInitClientContext failed");
3925 return 0;
3926 }
3927
3928
3929 /* Let Linux fopen() know everything is all right */
3930 return 0;
3931} // BSL_Open()
3932
3933/**
3934 @brief BSL_Close() - This function closes a device context created by
3935 BSL_Open(). May be called more than once during AMP PAL shut down.
3936
3937 @param *hdev : [in] pointer to the open HCI device structure.
3938 BSL_Init (Device Manager) function creates and stores this HCI
3939 device context in the BSL context.
3940
3941 @return
3942 TRUE indicates success. FALSE indicates failure.
3943*/
3944//static int BSL_Close (struct inode *pInode, struct file *pFile)
3945static int BSL_Close ( struct hci_dev *hdev )
3946{
3947 VOS_STATUS VosStatus = VOS_STATUS_SUCCESS;
3948 BslClientCtxType* pctx;
3949 vos_list_node_t* pLink;
3950 v_U16_t i;
3951 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
3952 hdd_context_t *pHddCtx;
3953
3954 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_Close");
3955 if (NULL != pVosContext)
3956 {
3957 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
3958 if (NULL != pHddCtx)
3959 {
3960 pHddCtx->isAmpAllowed = VOS_FALSE;
3961 }
3962 }
3963
3964 // it may seem there is some risk here because we are using a value
3965 // passed into us as a pointer. what if this pointer is 0 or points to
3966 // someplace bad? as it turns out the caller is device manager and not
3967 // the application. kernel should trap such invalid access but we will check
3968 // for NULL pointer
3969 if ( hdev == NULL )
3970 {
3971 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_Close: NULL hdev specified");
3972 return FALSE;
3973 }
3974
3975 pctx = (BslClientCtxType *)(hci_get_drvdata(hdev));
3976
3977 if ( pctx == NULL || !bBslInited)
3978 {
3979 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_LOW, "BSL_Close: %s is not open", hdev->name);
3980 return TRUE;
3981 }
3982
3983 // need to cleanup any per PHY state and the common RX state
3984 BslReleaseClientCtx( pctx );
3985 for ( i=0; i<BslPhyLinksDescPool.count; i++ )
3986 {
3987 VosStatus = vos_list_remove_front( &BslPhyLinksDescPool, &pLink );
3988 //nothing to free as the nodes came from BslPhyLinksDesc, which is a static
3989 //this is needed to allow vos_list_destroy() to go through
3990 }
3991 VosStatus = vos_list_destroy( &BslPhyLinksDescPool );
3992
3993 VOS_ASSERT(VOS_IS_STATUS_SUCCESS( VosStatus ) );
3994
3995
3996 bBslInited = FALSE;
3997
3998// The next line is temporary
3999 return(0);
4000} //BSL_Close()
4001
4002/**
4003 @brief BSL_IOControl() - This function sends a command to a device.
4004
4005 @param *hdev : [in] pointer to the open HCI device structure.
4006 @param cmd : [in] I/O control operation to perform. These codes are
4007 device-specific and are usually exposed to developers through a header file.
4008 @param arg : [in] Additional input parameter.
4009
4010 @return
4011 TRUE indicates success. FALSE indicates failure.
4012*/
4013//static long BSL_IOControl(struct file *pFile, unsigned int cmd, unsigned long arg)
4014static int BSL_IOControl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
4015{
4016 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_IOControl - not supported");
4017 return(TRUE);
4018} // BSL_IOControl()
4019
4020/**
4021 @brief BSL_Flush() - This function flushes all pending commands on a device.
4022
4023 @param *hdev : [in] pointer to the open HCI device structure.
4024
4025 @return
4026 TRUE indicates success. FALSE indicates failure.
4027*/
4028static int BSL_Flush(struct hci_dev *hdev)
4029{
4030 VOS_STATUS VosStatus;
4031 BslPhyLinkCtxType* pPhyCtx;
4032
4033 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_Flush - will flush ALL Tx Queues");
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004034 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s - will flush ALL Tx Queues", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035
4036 /* Flush the TX queue */
4037 // JEZ100604: Temporary short cut
4038 pPhyCtx = &BslPhyLinkCtx[0];
4039
4040 VosStatus = BslFlushTxQueues ( pPhyCtx);
4041
4042 //return(TRUE);
4043 return(0);
4044} // BSL_Flush()
4045
4046/**
4047 @brief BSL_Destruct() - This function destroys an HCI device.
4048
4049 @param *hdev : [in] pointer to the open HCI device structure.
4050
4051 @return
4052 TRUE indicates success. FALSE indicates failure.
4053*/
4054#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
4055static void BSL_Destruct(struct hci_dev *hdev)
4056{
4057 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "BSL_Destruct - not supported");
4058 return; //(TRUE);
4059} // BSL_Destruct()
4060#endif
4061
4062
4063/**
4064 @brief BSL_Write() - This function writes data to the device.
4065 An application indirectly invokes this function when it calls the fwrite()
4066 system call to write to a special device file.
4067
4068 @param *skb : [in] pointer to the skb being transmitted. This skb contains
4069 the HCI command or HCI data. Also a pointer (hdev) to the HCI device struct
4070
4071 @return
4072 The number of bytes written indicates success.
4073 Negative values indicate various failures.
4074*/
4075//static ssize_t BSL_Write(struct file *pFile, const char __user *pBuffer,
4076// size_t Count, loff_t *pOff)
4077static int BSL_Write(struct sk_buff *skb)
4078{
4079 struct hci_dev *hdev;
4080 BslClientCtxType* pctx;
4081 v_SIZE_t written = 0;
4082 BOOL status;
4083 //char *bslBuff = NULL;
4084 BslHciWorkStructure *pHciContext;
4085
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004086 //VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004087
4088 // Sanity check inputs
4089 if ( skb == NULL )
4090 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004091 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: skb is bad i/p", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 //return -EFAULT; /* Bad address */
4093 return 0;
4094 }
4095
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004096 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Count (skb->len)=%d", __func__, skb->len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004097
4098 // Sanity check inputs
4099 if ( 0 == skb->len )
4100 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004101 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: skb is empty", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 //return -EFAULT; /* Bad address */
4103 return 0;
4104 }
4105
4106 hdev = (struct hci_dev *)(skb->dev);
4107
4108 // Sanity check the HCI device in the skb
4109 if ( hdev == NULL )
4110 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004111 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Frame for Unknown HCI device (hdev=NULL)", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 //return -ENODEV; /* no device */
4113 return 0;
4114 }
4115
4116 pctx = (BslClientCtxType *)hci_get_drvdata(hdev);
4117
4118 // Sanity check inputs
4119 if ( pctx == NULL )
4120 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004121 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: pctx is bad i/p", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 //return -EFAULT; /* Bad address */
4123 return 0;
4124 /* Maybe I should return "no device" */
4125 //return -ENODEV; /* no device */
4126 }
4127
4128 // Switch for each case of packet type
4129 switch (bt_cb(skb)->pkt_type)
4130 {
4131 case HCI_ACLDATA_PKT:
4132 // Directly execute the data write
4133 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
4134 "%s: HCI ACL data tx, skb=%p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004135 __func__, skb);
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 // ACL data
4137 hdev->stat.acl_tx++;
4138 // Correct way of doing this...
4139 written = skb->len;
4140#ifdef BTAMP_USE_VOS_WRAPPER
4141 status = BslProcessACLDataTx( pctx, skb, &written );
4142#else
4143 status = BslProcessACLDataTx( pctx, skb->data, &written );
4144 // Free up the skb
4145 kfree_skb(skb);
4146#endif //BTAMP_USE_VOS_WRAPPER
4147 break;
4148 case HCI_COMMAND_PKT:
4149 // Defer the HCI command writes
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004150 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HCI command", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 hdev->stat.cmd_tx++;
4152
4153 // Allocate an HCI context. To use as a "container" for the "work" to be deferred.
4154 pHciContext = kmalloc(sizeof(*pHciContext), GFP_ATOMIC);
4155 if (NULL == pHciContext)
4156 {
4157 // no memory for HCI context. Nothing we can do but drop
4158 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004159 "%s: Unable to allocate context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 kfree_skb(skb);
4161 return 0;
4162 }
4163
4164 // save away the tx skb in the HCI context...so it can be
4165 // retrieved by the work procedure.
4166 pHciContext->tx_skb = skb;
4167 // save away the pctx context...so it can be retrieved by the work procedure.
4168 pHciContext->pctx = pctx;
4169 pHciContext->magic = BT_AMP_HCI_CTX_MAGIC;
4170 INIT_WORK(&pHciContext->hciInterfaceProcessing,
4171 bslWriteFinish);
4172
4173 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
4174 "%s: Scheduling work for skb %p, BT-AMP Client context %p, work %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004175 __func__, skb, pctx, pHciContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07004176
4177 status = schedule_work(&pHciContext->hciInterfaceProcessing);
4178
4179 // Check result
4180 if ( 0 == status )
4181 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004182 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "%s: hciInterfaceProcessing work already queued. This should never happen.", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 }
4184
4185
4186 // Temporary way of doing this
4187 //written = skb->len-CMD_TLV_TYPE_AND_LEN_SIZE;
4188 written = skb->len;
4189 break;
4190 case HCI_SCODATA_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004191 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: unknown type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 hdev->stat.sco_tx++;
4193 // anything else including HCI events and SCO data
4194 status = FALSE;
4195 // Free up the skb
4196 kfree_skb(skb);
4197 break;
4198 default:
4199 // anything else including HCI events and SCO data
4200 status = FALSE;
4201 // Free up the skb
4202 kfree_skb(skb);
4203 break;
4204 };
4205
4206
4207 // JEZ100809: For the HCI command, will the caller need to wait until the work takes place and
4208 // return the ACTUAL amount of data written.
4209
4210// The next line is temporary
4211 //written = skb->len;
4212 return(written);
4213} // BSL_Write()
4214
4215/**
4216 @brief bslWriteFinish() - This function finished the writes operation
4217 started by BSL_Write().
4218
4219 @param work : [in] pointer to work structure
4220
4221 @return : void
4222
4223*/
4224static void bslWriteFinish(struct work_struct *work)
4225{
4226 //BslClientCtxType* pctx =
4227 // container_of(work, BslClientCtxType, hciInterfaceProcessing);
4228 BslHciWorkStructure *pHciContext =
4229 container_of(work, BslHciWorkStructure, hciInterfaceProcessing);
4230 BslClientCtxType* pctx = pHciContext->pctx;
4231 VOS_STATUS status;
4232 struct sk_buff *skb;
4233 struct hci_dev *hdev;
4234 //char *bslBuff = NULL;
4235 v_SIZE_t written = 0;
4236
4237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_LOW,
4238 "%s: Entered, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004239 __func__, pctx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004240
4241 // Sanity check inputs
4242 if ( pctx == NULL )
4243 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004244 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: pctx is bad i/p", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 return; // -EFAULT; /* Bad address */
4246 }
4247
4248 //skb = pctx->tx_skb;
4249 skb = pHciContext->tx_skb;
4250 kfree( pHciContext);
4251
4252 // Sanity check inputs
4253 if ( skb == NULL )
4254 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004255 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: skb is bad i/p", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 return; // -EFAULT; /* Bad address */
4257 }
4258
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004259 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Count (skb->len)=%d", __func__, skb->len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004260
4261 hdev = (struct hci_dev *)(skb->dev);
4262
4263 // Sanity check the HCI device in the skb
4264 if ( hdev == NULL )
4265 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004266 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Frame for Unknown HCI device (hdev=NULL)", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 return; // -ENODEV; /* no device */
4268 }
4269
4270
4271 // Sanity check inputs
4272 if ( pctx != (BslClientCtxType *)hci_get_drvdata(hdev));
4273 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004274 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: pctx and hdev not consistent - bad i/p", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 return; // -EFAULT; /* Bad address */
4276 /* Maybe I should return "no device" */
4277 //return -ENODEV; /* no device */
4278 }
4279
4280 // Switch for each case of packet type
4281 switch (bt_cb(skb)->pkt_type)
4282 {
4283 case HCI_COMMAND_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004284 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HCI command", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 hdev->stat.cmd_tx++;
4286 // HCI command
4287 status = BslProcessHCICommand( pctx, skb->data, skb->len-CMD_TLV_TYPE_AND_LEN_SIZE);
4288 // Temporary way of doing this
4289 //written = skb->len-CMD_TLV_TYPE_AND_LEN_SIZE;
4290 written = skb->len;
4291 break;
4292 case HCI_SCODATA_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004293 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: unknown type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 hdev->stat.sco_tx++;
4295 // anything else including HCI events and SCO data
4296 status = FALSE;
4297 break;
4298 default:
4299 // anything else including HCI events and SCO data
4300 status = FALSE;
4301 break;
4302 };
4303
4304 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
4305 "%s: Freeing skb %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004306 __func__, skb);
Jeff Johnson295189b2012-06-20 16:38:30 -07004307
4308 consume_skb(skb);
4309
4310// How do I return the actual number of bytes written to the caller?
4311// return(written);
4312 return;
4313} //bslWriteFinish()
4314
4315VOS_STATUS WLANBAP_SetConfig
4316(
4317 WLANBAP_ConfigType *pConfig
4318)
4319{
4320 BslClientCtxType* pctx;
4321 VOS_STATUS status;
4322 // sanity checking
4323 if ( pConfig == NULL )
4324 {
4325 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_SetConfig bad input\n" );
4326 return VOS_STATUS_E_FAILURE;
4327 }
4328 pctx = gpBslctx;
4329 if ( NULL == pctx )
4330 {
4331 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4332 "Invalid BSL pointer from pctx on WLANBAP_SetConfig");
4333 return VOS_STATUS_E_FAULT;
4334 }
4335
4336 // get a handle from BAP
4337 status = WLANBAP_GetNewHndl(&pctx->bapHdl);
4338 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4339 {
4340 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_SetConfig can't get BAP handle\n" );
4341 return VOS_STATUS_E_FAILURE;
4342 }
4343
4344
4345 status = WLAN_BAPSetConfig(pctx->bapHdl, pConfig);
4346 if ( !VOS_IS_STATUS_SUCCESS( status ) )
4347 {
4348 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "WLANBAP_SetConfig can't set BAP config\n" );
4349 return VOS_STATUS_E_FAILURE;
4350 }
4351
4352 return(VOS_STATUS_SUCCESS);
4353}
4354
4355VOS_STATUS WLANBAP_RegisterWithHCI(hdd_adapter_t *pAdapter)
4356{
4357 struct hci_dev *hdev = NULL;
4358 BslClientCtxType* pctx = NULL;
4359 int err = 0;
4360 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
4361 hdd_context_t *pHddCtx;
4362
4363 pctx = gpBslctx;
4364
4365 if ( NULL == pctx )
4366 {
4367 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4368 "Invalid BSL pointer from pctx on WLANBAP_RegisterWithHCI");
4369 return VOS_STATUS_E_FAULT;
4370 }
4371 if ( NULL == pAdapter )
4372 {
4373 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4374 "Invalid HDD Adapter pointer from pvosGCtx on WLANBAP_RegisterWithHCI");
4375 return VOS_STATUS_E_FAULT;
4376 }
4377
4378 if(NULL != pctx->hdev)
4379 {
4380 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_WARN,
4381 "Already registered as HCI device\n");
4382 return VOS_STATUS_SUCCESS;
4383 }
4384
4385
4386
4387 /* Save away the pointer to the parent WLAN device in BSL driver context */
4388 pctx->p_dev = pAdapter->dev;
4389
4390 /* Initialize HCI device */
4391 hdev = hci_alloc_dev();
4392 if (!hdev)
4393 {
4394 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4395 "Can't allocate HCI device in WLANBAP_RegisterWithHCI");
4396 return VOS_STATUS_E_FAULT;
4397 }
4398
4399 /* Save away the HCI device pointer in the BSL driver context */
4400 pctx->hdev = hdev;
4401
4402#if defined HCI_80211 || defined HCI_AMP
4403#define BUILD_FOR_BLUETOOTH_NEXT_2_6
4404#else
4405#undef BUILD_FOR_BLUETOOTH_NEXT_2_6
4406#endif
4407
4408#ifdef BUILD_FOR_BLUETOOTH_NEXT_2_6
4409 /* HCI "bus type" of HCI_VIRTUAL should apply */
4410 hdev->bus = HCI_VIRTUAL;
4411 /* Set the dev_type to BT-AMP 802.11 */
4412#ifdef HCI_80211
4413 hdev->dev_type = HCI_80211;
4414#else
4415 hdev->dev_type = HCI_AMP;
4416#endif
4417#ifdef FEATURE_WLAN_BTAMP_UT
4418 /* For the "real" BlueZ build, DON'T Set the device "quirks" to indicate RAW */
4419 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
4420#endif
4421#else //BUILD_FOR_BLUETOOTH_NEXT_2_6
4422 /* HCI "bus type" of HCI_VIRTUAL should apply */
4423 hdev->type = HCI_VIRTUAL;
4424 /* Set the dev_type to BT-AMP 802.11 */
4425 //hdev->dev_type = HCI_80211;
4426 ////hdev->dev_type = HCI_AMP;
4427 /* For the "temporary" BlueZ build, Set the device "quirks" to indicate RAW */
4428 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
4429#endif //BUILD_FOR_BLUETOOTH_NEXT_2_6
4430 /* Save away the BSL driver pointer in the HCI device context */
4431 hci_set_drvdata(hdev, pctx);
4432 /* Set the parent device for this HCI device. This is our WLAN net_device */
4433 SET_HCIDEV_DEV(hdev, &pctx->p_dev->dev);
4434
4435 hdev->open = BSL_Open;
4436 hdev->close = BSL_Close;
4437 hdev->flush = BSL_Flush;
4438 hdev->send = BSL_Write;
4439#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
4440 hdev->owner = THIS_MODULE;
4441 hdev->destruct = BSL_Destruct;
4442#endif
4443 hdev->ioctl = BSL_IOControl;
4444
4445
4446 /* Timeout before it is safe to send the first HCI packet */
4447 msleep(1000);
4448
4449 /* Register HCI device */
4450 err = hci_register_dev(hdev);
4451 if (err < 0)
4452 {
4453 VOS_TRACE(VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4454 "Unable to register HCI device, err=%d\n", err);
4455 pctx->hdev = NULL;
4456 hci_free_dev(hdev);
4457 return VOS_STATUS_E_FAULT;
4458 }
4459 if (NULL != pVosContext)
4460 {
4461 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
4462 if (NULL != pHddCtx)
4463 {
4464 pHddCtx->isAmpAllowed = VOS_TRUE;
4465 }
4466 }
4467
4468 return VOS_STATUS_SUCCESS;
4469}
4470
4471VOS_STATUS WLANBAP_DeregisterFromHCI(void)
4472{
4473 struct hci_dev *hdev;
4474 BslClientCtxType* pctx = NULL;
4475
4476 pctx = gpBslctx;
4477
4478 if ( NULL == pctx )
4479 {
4480 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4481 "Invalid BSL pointer from pvosGCtx on WLANBAP_DeregisterFromHCI");
4482 return VOS_STATUS_E_FAULT;
4483 }
4484
4485 /* Retrieve the HCI device pointer from the BSL driver context */
4486 hdev = pctx->hdev;
4487
4488 if (!hdev)
4489 return VOS_STATUS_E_FAULT;
4490
4491 /* Unregister device from BlueZ; fcn sends us HCI commands before it returns */
4492 /* And then the registered hdev->close fcn should be called by BlueZ (BSL_Close) */
4493 hci_unregister_dev(hdev);
4494
4495 /* BSL_Close is called again here, in case BlueZ didn't call it */
4496 BSL_Close(hdev);
4497 hci_free_dev(hdev);
4498 pctx->hdev = NULL;
4499
4500 return VOS_STATUS_SUCCESS;
4501}
4502
4503VOS_STATUS WLANBAP_StopAmp(void)
4504{
4505 BslClientCtxType* pctx;
4506 VOS_STATUS status = VOS_STATUS_SUCCESS;
4507
4508 pctx = gpBslctx;
4509
4510 if(NULL == pctx)
4511 {
4512 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4513 "Invalid BSL pointer from pvosGCtx on WLANBAP_StopAmp");
4514 status = VOS_STATUS_E_FAULT;
4515 }
4516 else
4517 {
4518 //is AMP session on, if so disconnect
4519 if(VOS_TRUE == WLAN_BAPSessionOn(pctx->bapHdl))
4520 {
4521 status = WLAN_BAPDisconnect(pctx->bapHdl);
4522 }
4523 }
4524 return status;
4525}
4526
4527v_BOOL_t WLANBAP_AmpSessionOn(void)
4528{
4529 BslClientCtxType* pctx;
4530
4531 pctx = gpBslctx;
4532 if(NULL == pctx)
4533 {
4534 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
4535 "Invalid BSL pointer from pvosGCtx on WLANBAP_AmpSessionOn");
4536 return VOS_FALSE;
4537 }
4538 else
4539 {
4540 return( WLAN_BAPSessionOn(pctx->bapHdl));
4541 }
4542}
4543
4544
4545#endif // WLAN_BTAMP_FEATURE