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