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