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