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