blob: 5c35b4b648e86c7671485ca05ff046796a50f2ad [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*===========================================================================
23
24 b a p A p i D a t a . C
25
26 OVERVIEW:
27
28 This software unit holds the implementation of the WLAN BAP modules
29 "platform independent" Data path functions.
30
31 The functions externalized by this module are to be called ONLY by other
32 WLAN modules (HDD) that properly register with the BAP Layer initially.
33
34 DEPENDENCIES:
35
36 Are listed for each API below.
37
38
39 Copyright (c) 2008 QUALCOMM Incorporated.
40 All Rights Reserved.
41 Qualcomm Confidential and Proprietary
42===========================================================================*/
43
44/*===========================================================================
45
46 EDIT HISTORY FOR FILE
47
48
49 This section contains comments describing changes made to the module.
50 Notice that changes are listed in reverse chronological order.
51
52
53 $Header: /cygdrive/e/Builds/M7201JSDCAAPAD52240B/WM/platform/msm7200/Src/Drivers/SD/ClientDrivers/WLAN/QCT/CORE/BAP/src/bapApiData.c,v 1.4 2008/11/10 22:34:22 jzmuda Exp jzmuda $$DateTime$$Author: jzmuda $
54
55
56 when who what, where, why
57---------- --- --------------------------------------------------------
582008-09-15 jez Created module
59
60===========================================================================*/
61
62/*----------------------------------------------------------------------------
63 * Include Files
64 * -------------------------------------------------------------------------*/
65//#include "wlan_qct_tl.h"
66#include "vos_trace.h"
67//I need the TL types and API
68#include "wlan_qct_tl.h"
69
70#include "wlan_qct_hal.h"
71
72/* BT-AMP PAL API header file */
73#include "bapApi.h"
74#include "bapInternal.h"
75#include "bapApiTimer.h"
76
77//#define BAP_DEBUG
78/*----------------------------------------------------------------------------
79 * Preprocessor Definitions and Constants
80 * -------------------------------------------------------------------------*/
81/*Endian-ness definitions*/
82
83#undef BAP_LITTLE_BIT_ENDIAN
84#define BAP_LITTLE_BIT_ENDIAN
85
86/*LLC header definitions*/
87
88/* Length of the LLC header*/
89#define WLANBAP_LLC_HEADER_LEN 8
90#if 0
91/*Offset of the OUI field inside the LLC/SNAP header*/
92#define WLANBAP_LLC_OUI_OFFSET 3
93
94/*Size of the OUI type field inside the LLC/SNAP header*/
95#define WLANBAP_LLC_OUI_SIZE 3
96
97/*Offset of the protocol type field inside the LLC/SNAP header*/
98#define WLANBAP_LLC_PROTO_TYPE_OFFSET WLANBAP_LLC_OUI_OFFSET + WLANBAP_LLC_OUI_SIZE
99
100/*Size of the protocol type field inside the LLC/SNAP header*/
101#define WLANBAP_LLC_PROTO_TYPE_SIZE 2
102#endif
103
104/*BT-AMP protocol type values*/
105/*BT-AMP packet of type data*/
106#define WLANBAP_BT_AMP_TYPE_DATA 0x0001
107
108/*BT-AMP packet of type activity report*/
109#define WLANBAP_BT_AMP_TYPE_AR 0x0002
110
111/*BT-AMP packet of type security frame*/
112#define WLANBAP_BT_AMP_TYPE_SEC 0x0003
113
114/*802.3 header definitions*/
115#define WLANBAP_802_3_HEADER_LEN 14
116
117/* Offset of DA field in a 802.3 header*/
118#define WLANBAP_802_3_HEADER_DA_OFFSET 0
119
120//*BT-AMP packet LLC OUI value*/
121const v_U8_t WLANBAP_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
122
123/*LLC header value*/
124static v_U8_t WLANBAP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
125
126/* HCI header definitions*/
127
128// Define the length of the ACL data packet HCI header
129#define WLANBAP_HCI_ACL_HEADER_LEN 4
130
131// Debug related defines
132//#define DBGLOG printf
133#define DUMPLOG_ON
134#ifdef DUMPLOG_ON
135#define DUMPLOG(n, name1, name2, aStr, size) \
136 if (1) \
137{\
138 int i;\
139 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"%d. %s: %s = \n", n, name1, name2); \
140 for (i = 0; i < size; i++) \
141 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"%2.2x%s", ((unsigned char *)aStr)[i], i % 16 == 15 ? "\n" : " "); \
142 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,"\n"); \
143}
144#else
145#define DUMPLOG(n, name1, name2, aStr, size)
146#endif
147
148#if 0
149// Debug related defines
150#define DBGLOG printf
151#define DUMPLOG
152#if defined DUMPLOG
153#define DUMPLOG(n, name1, name2, aStr, size) \
154 if (1) \
155{\
156 int i;\
157 DBGLOG("%d. %s: %s = \n", n, name1, name2); \
158 for (i = 0; i < size; i++) \
159 DBGLOG("%2.2x%s", ((unsigned char *)aStr)[i], i % 16 == 15 ? "\n" : " "); \
160 DBGLOG("\n"); \
161}
162#else
163#define DUMPLOG(n, name1, name2, aStr, size)
164#endif
165#endif
166
167/*----------------------------------------------------------------------------
168 * Type Declarations
169 * -------------------------------------------------------------------------*/
170// Don't we have this type defined somewhere?
171#if 0
172/* 802.3 header */
173typedef struct
174{
175 /* Destination address field */
176 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
177
178 /* Source address field */
179 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
180
181 /* Length field */
182 v_U16_t usLenType; /* Num bytes in info field (i.e., exclude 802.3 hdr) */
183 /* Max length 1500 (0x5dc) (What about 0x5ee? That
184 * includes 802.3 Header and FCS.) */
185}WLANBAP_8023HeaderType;
186#endif
187
188/**
189 * \brief HCI ACL Data packet format
190 *
191 * 0 7 8 15 16 23 24 31
192 * +--------+----+----+--------+--------+
193 * | phy_ |log_| PB/| Data Total |
194 * | link_ |lnk_| BC | Length |
195 * | handle |hndl|Flag| |
196 * +--------+----+----+--------+--------+
197 * | |
198 * | Data |
199 * ~ ~
200 * +--------+---------+--------+--------+
201 *
202 * NB:
203 * This is in little-endian
204 * 1) phy_link_handle is the first 8 bits
205 * 2) log_link_handle is the next 4 bits
206 * 3) PB flag is the next 2 bits
207 * 4) BC flags is the next 2 bits
208 * 5) Total length of the data field is the next 16 bits
209 *
210 */
211
212typedef struct
213{
214
215#ifndef BAP_LITTLE_BIT_ENDIAN
216
217 v_U8_t phyLinkHandle; /* do I have to reverse the byte? I think so... */
218
219 v_U8_t BCFlag :2;
220 v_U8_t PBFlag :2;
221 v_U8_t logLinkHandle :4;
222
223 v_U16_t dataLength; /* do I have to reverse each byte? and then reverse the two bytes? I think so... */
224
225#else
226
227 v_U8_t phyLinkHandle;
228
229 v_U8_t logLinkHandle :4;
230 v_U8_t PBFlag :2;
231 v_U8_t BCFlag :2;
232
233 v_U16_t dataLength; /* Max length WLANBAP_MAX_80211_PAL_PDU_SIZE (1492) */
234
235#endif
236
237} WLANBAP_HCIACLHeaderType;
238
239
240
241/*----------------------------------------------------------------------------
242 * Global Data Definitions
243 * -------------------------------------------------------------------------*/
244
245/*----------------------------------------------------------------------------
246 * Static Variable Definitions
247 * -------------------------------------------------------------------------*/
248
249/*----------------------------------------------------------------------------
250 * Static Function Declarations and Definitions
251 * -------------------------------------------------------------------------*/
252
253/*----------------------------------------------------------------------------
254 * Externalized Function Definitions
255* -------------------------------------------------------------------------*/
256
257/*----------------------------------------------------------------------------
258 * Function Declarations and Documentation
259 * -------------------------------------------------------------------------*/
260
261#define WLANBAP_DEBUG_FRAME_BYTE_PER_LINE 16
262#define WLANBAP_DEBUG_FRAME_BYTE_PER_BYTE 4
263
264/*===========================================================================
265
266 FUNCTION WLANBAP_XlateTxDataPkt
267
268 DESCRIPTION
269
270 HDD will call this API when it has a HCI Data Packet and it wants
271 to translate it into a 802.3 LLC frame - ready to send using TL.
272
273
274 PARAMETERS
275
276 btampHandle: The BT-AMP PAL handle returned in WLANBAP_GetNewHndl.
277 phy_link_handle: Used by BAP to indentify the WLAN assoc. (StaId)
278
279 pucAC: Pointer to return the access category
280 vosDataBuff: The data buffer containing the BT-AMP packet to be
281 translated to an 802.3 LLC frame
282 tlMetaInfo: return meta info gleaned from the outgoing frame, here.
283
284 RETURN VALUE
285
286 The result code associated with performing the operation
287
288 VOS_STATUS_E_INVAL: Input parameters are invalid
289 VOS_STATUS_E_FAULT: BAP handle is NULL
290 VOS_STATUS_SUCCESS: Everything is good :)
291
292 SIDE EFFECTS
293
294============================================================================*/
295VOS_STATUS
296WLANBAP_XlateTxDataPkt
297(
298 ptBtampHandle btampHandle, /* Used by BAP to identify the actual session
299 and therefore addresses */
300 v_U8_t phy_link_handle, /* Used by BAP to indentify the WLAN assoc. (StaId) */
301 WLANTL_ACEnumType *pucAC, /* Return the AC here */
302 WLANTL_MetaInfoType *tlMetaInfo, /* Return the MetaInfo here. An assist to WLANBAP_STAFetchPktCBType */
303 vos_pkt_t *vosDataBuff
304)
305{
306 ptBtampContext pBtampCtx = (ptBtampContext) btampHandle;
307 tpBtampLogLinkCtx pLogLinkContext;
308 WLANBAP_8023HeaderType w8023Header;
309 WLANBAP_HCIACLHeaderType hciACLHeader;
310 v_U8_t aucLLCHeader[WLANBAP_LLC_HEADER_LEN];
311 VOS_STATUS vosStatus;
312 v_U8_t ucSTAId; /* The StaId (used by TL, PE, and HAL) */
313 v_PVOID_t pHddHdl; /* Handle to return BSL context in */
314 v_U16_t headerLength; /* The 802.3 frame length*/
315 v_U16_t protoType = WLANBAP_BT_AMP_TYPE_DATA; /* The protocol type bytes*/
316 v_U32_t value = 0;
317 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
318
319
320 /*------------------------------------------------------------------------
321 Sanity check params
322 ------------------------------------------------------------------------*/
323 if ( NULL == pBtampCtx)
324 {
325 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
326 "Invalid BAP handle value in %s", __FUNCTION__);
327 return VOS_STATUS_E_FAULT;
328 }
329
330 // Here, I have to make the assumption that this is an
331 // HCI ACL Data packet that I am being handed.
332 vosStatus = vos_pkt_pop_head( vosDataBuff, &hciACLHeader, WLANBAP_HCI_ACL_HEADER_LEN);
333
334 if ( VOS_STATUS_SUCCESS != vosStatus )
335 {
336 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
337 "WLAN BAP: Failed to pop HCI ACL header from packet %d",
338 vosStatus);
339
340 return vosStatus;
341 }
342
343 // JEZ081003: Remove this after debugging
344 // Sanity check the phy_link_handle value
345
346 if ( phy_link_handle != hciACLHeader.phyLinkHandle )
347 {
348 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
349 "WLAN BAP: phy_link_handle mismatch in %s phy_link_handle=%d hciACLHeader.phyLinkHandle=%d",
350 __FUNCTION__, phy_link_handle, hciACLHeader.phyLinkHandle);
351 return VOS_STATUS_E_INVAL;
352 }
353
354
355 /* Lookup the StaId using the phy_link_handle and the BAP context */
356
357 vosStatus = WLANBAP_GetStaIdFromLinkCtx (
358 btampHandle, /* btampHandle value in */
359 phy_link_handle, /* phy_link_handle value in */
360 &ucSTAId, /* The StaId (used by TL, PE, and HAL) */
361 &pHddHdl); /* Handle to return BSL context */
362 if ( VOS_STATUS_SUCCESS != vosStatus )
363 {
364 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
365 "Unable to retrieve STA Id from BAP context and phy_link_handle in %s", __FUNCTION__);
366 return VOS_STATUS_E_FAULT;
367 }
368
369 // JEZ081003: Remove this after debugging
370 // Sanity check the log_link_handle value
371 if (!BTAMP_VALID_LOG_LINK( hciACLHeader.logLinkHandle))
372 {
373 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
374 "WLAN BAP: Invalid logical link handle (%d) in %s. Corrected.",
375 hciACLHeader.logLinkHandle,
376 __FUNCTION__);
377
378 // JEZ090123: Insure that the logical link value is good
379 hciACLHeader.logLinkHandle = 1;
380 //return VOS_STATUS_E_INVAL;
381 }
382
383 /* Use the log_link_handle to retrieve the logical link context */
384 /* JEZ081006: abstract this with a proc. So you can change the impl later */
385 pLogLinkContext = &(pBtampCtx->btampLogLinkCtx[ hciACLHeader.logLinkHandle ]);
386
387 // JEZ081003: Remove this after debugging
388 // Sanity check the log_link_handle value
389 // JEZ081113: I changed this to fail on an UNOCCUPIED entry
390 if ( pLogLinkContext->present != VOS_TRUE)
391 {
392 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
393 "WLAN BAP: Invalid logical link entry in %s",
394 __FUNCTION__);
395
396 return VOS_STATUS_E_INVAL;
397 }
398
399 // Return the AC and MetaInfo
400
401 // Now copy the AC values from the Logical Link context
402 *pucAC = pLogLinkContext->btampAC;
403 // Now copy the values from the Logical Link context to the MetaInfo
404 tlMetaInfo->ucTID = pLogLinkContext->ucTID;
405 tlMetaInfo->ucUP = pLogLinkContext->ucUP;
406 tlMetaInfo->ucIsEapol = VOS_FALSE;
407 tlMetaInfo->ucDisableFrmXtl = VOS_FALSE;
408 tlMetaInfo->ucBcast = VOS_FALSE; /* hciACLHeader.BCFlag; */ /* Don't I want to use the BCFlag? */
409 tlMetaInfo->ucMcast = VOS_FALSE;
410 tlMetaInfo->ucType = 0x00; /* What is this really ?? */
411// tlMetaInfo->usTimeStamp = 0x00; /* Ravi, shouldn't you be setting this? It's in the VOS packet. */
412
413 // Form the 802.3 header
414
415 vos_mem_copy( w8023Header.vDA, pBtampCtx->peer_mac_addr, VOS_MAC_ADDR_SIZE);
416 vos_mem_copy( w8023Header.vSA, pBtampCtx->self_mac_addr, VOS_MAC_ADDR_SIZE);
417
418 /* Now this length passed down in HCI...is in little-endian */
419 headerLength = vos_le16_to_cpu(hciACLHeader.dataLength);
420 headerLength += WLANBAP_LLC_HEADER_LEN;
421 /* Now the 802.3 length field is big-endian?! */
422 w8023Header.usLenType = vos_cpu_to_be16(headerLength);
423
424 /* Now adjust the protocol type bytes*/
425 protoType = vos_cpu_to_be16( protoType);
426
427 /* Now form the LLC header */
428 vos_mem_copy(aucLLCHeader,
429 WLANBAP_LLC_HEADER,
430 sizeof(WLANBAP_LLC_HEADER));
431 vos_mem_copy(&aucLLCHeader[WLANBAP_LLC_OUI_OFFSET],
432 WLANBAP_BT_AMP_OUI,
433 WLANBAP_LLC_OUI_SIZE);
434 vos_mem_copy(&aucLLCHeader[WLANBAP_LLC_PROTO_TYPE_OFFSET],
435 &protoType, //WLANBAP_BT_AMP_TYPE_DATA
436 WLANBAP_LLC_PROTO_TYPE_SIZE);
437
438 /* Push on the LLC header */
439 vos_pkt_push_head(vosDataBuff,
440 aucLLCHeader,
441 WLANBAP_LLC_HEADER_LEN);
442
443 /* Push on the 802.3 header */
444 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
445
446
447 /*Set the logical link handle as user data so that we can retrieve it on
448 Tx Complete */
449 value = (v_U32_t)hciACLHeader.logLinkHandle;
450 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAP,
451 (v_VOID_t *)value);
452
453 return VOS_STATUS_SUCCESS;
454}/*WLANBAP_XlateTxDataPkt*/
455
456/*===========================================================================
457
458 FUNCTION WLANBAP_GetAcFromTxDataPkt
459
460 DESCRIPTION
461
462 HDD will call this API when it has a HCI Data Packet (SKB) and it wants
463 to find AC type of the data frame from the HCI header on the data pkt
464 - to be send using TL.
465
466
467 PARAMETERS
468
469 btampHandle: The BT-AMP PAL handle returned in WLANBAP_GetNewHndl.
470
471 pHciData: Pointer to the HCI data frame
472
473 pucAC: Pointer to return the access category
474
475 RETURN VALUE
476
477 The result code associated with performing the operation
478
479 VOS_STATUS_E_INVAL: Input parameters are invalid
480 VOS_STATUS_E_FAULT: BAP handle is NULL
481 VOS_STATUS_SUCCESS: Everything is good :)
482
483 SIDE EFFECTS
484
485============================================================================*/
486VOS_STATUS
487WLANBAP_GetAcFromTxDataPkt
488(
489 ptBtampHandle btampHandle, /* Used by BAP to identify the actual session
490 and therefore addresses */
491 void *pHciData, /* Pointer to the HCI data frame */
492 WLANTL_ACEnumType *pucAC /* Return the AC here */
493)
494{
495 ptBtampContext pBtampCtx;
496 tpBtampLogLinkCtx pLogLinkContext;
497 WLANBAP_HCIACLHeaderType hciACLHeader;
498 /*------------------------------------------------------------------------
499 Sanity check params
500 ------------------------------------------------------------------------*/
501 if (( NULL == btampHandle) || (NULL == pHciData) || (NULL == pucAC))
502 {
503 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
504 "Invalid params in %s", __FUNCTION__);
505 return VOS_STATUS_E_FAULT;
506 }
507 pBtampCtx = (ptBtampContext) btampHandle;
508
509 vos_mem_copy( &hciACLHeader, pHciData, WLANBAP_HCI_ACL_HEADER_LEN);
510 // Sanity check the log_link_handle value
511 if (!BTAMP_VALID_LOG_LINK( hciACLHeader.logLinkHandle))
512 {
513 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
514 "WLAN BAP: Invalid logical link handle (%d) in %s",
515 hciACLHeader.logLinkHandle,
516 __FUNCTION__);
517
518 return VOS_STATUS_E_INVAL;
519 }
520
521 /* Use the log_link_handle to retrieve the logical link context */
522 /* JEZ081006: abstract this with a proc. So you can change the impl later */
523 pLogLinkContext = &(pBtampCtx->btampLogLinkCtx[ hciACLHeader.logLinkHandle ]);
524
525 // Sanity check the log_link_handle value
526 // JEZ081113: I changed this to fail on an UNOCCUPIED entry
527 if ( pLogLinkContext->present != VOS_TRUE)
528 {
529 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
530 "WLAN BAP: Invalid logical link entry in %s",
531 __FUNCTION__);
532
533 return VOS_STATUS_E_INVAL;
534 }
535
536 // Return the AC
537
538 // Now copy the AC values from the Logical Link context
539 *pucAC = pLogLinkContext->btampAC;
540
541 return VOS_STATUS_SUCCESS;
542}
543
544/*===========================================================================
545
546 FUNCTION WLANBAP_XlateRxDataPkt
547
548 DESCRIPTION
549
550 HDD will call this API when it has received a 802.3 (TL/UMA has
551 Xlated from 802.11) frame from TL and it wants to form a
552 BT HCI Data Packet - ready to signal up to the BT stack application.
553
554
555 PARAMETERS
556
557 btampHandle: The BT-AMP PAL handle returned in WLANBAP_GetNewHndl.
558 pucAC: Pointer to return the access category
559 vosDataBuff: The data buffer containing the 802.3 frame to be
560 translated to BT HCI Data Packet
561
562 RETURN VALUE
563
564 The result code associated with performing the operation
565
566 VOS_STATUS_E_INVAL: Input parameters are invalid
567 VOS_STATUS_E_FAULT: BAP handle is NULL
568 VOS_STATUS_SUCCESS: Everything is good :)
569
570 SIDE EFFECTS
571
572============================================================================*/
573VOS_STATUS
574WLANBAP_XlateRxDataPkt
575(
576 ptBtampHandle btampHandle,
577 v_U8_t phy_link_handle, /* Used by BAP to indentify the WLAN assoc. (StaId) */
578 WLANTL_ACEnumType *pucAC, /* Return the AC here. I don't think this is needed */
579 vos_pkt_t *vosDataBuff
580)
581{
582 WLANBAP_8023HeaderType w8023Header;
583 WLANBAP_HCIACLHeaderType hciACLHeader;
584 v_U8_t aucLLCHeader[WLANBAP_LLC_HEADER_LEN];
585 ptBtampContext pBtampCtx = (ptBtampContext) btampHandle;
586 VOS_STATUS vosStatus;
587 //v_PVOID_t pHddHdl; /* Handle to return BSL context in */
588 v_U16_t hciDataLength; /* The HCI packet data length*/
589 v_U16_t protoType = WLANBAP_BT_AMP_TYPE_DATA; /* The protocol type bytes*/
590 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
591
592 /*------------------------------------------------------------------------
593 Sanity check params
594 ------------------------------------------------------------------------*/
595 if ( NULL == pBtampCtx)
596 {
597 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
598 "Invalid BAP handle value in %s", __FUNCTION__);
599 return VOS_STATUS_E_FAULT;
600 }
601
602 // Here, I have to make the assumption that this is an
603 // 802.3 header followed by an LLC/SNAP packet.
604 vos_mem_set( &w8023Header, sizeof(w8023Header), 0 );
605 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header, sizeof(w8023Header));
606
607 if ( VOS_STATUS_SUCCESS != vosStatus )
608 {
609 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
610 "WLAN BAP: Failed to pop 802.3 header from packet %d",
611 vosStatus);
612
613 return vosStatus;
614 }
615
616 // Here, is that LLC/SNAP header.
617 // With the BT SIG OUI that I am being handed.
618 vos_mem_set( aucLLCHeader, WLANBAP_LLC_HEADER_LEN, 0 );
619 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader, WLANBAP_LLC_HEADER_LEN);
620
621 if ( VOS_STATUS_SUCCESS != vosStatus )
622 {
623 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
624 "WLAN BAP: Failed to pop LLC/SNAP header from packet %d",
625 vosStatus);
626
627 return vosStatus;
628 }
629
630#ifdef BAP_DEBUG
631 // JEZ081003: Remove this after debugging
632 // Should I double check that I am getting the BT SIG OUI ?
633 if ( !(vos_mem_compare( aucLLCHeader,
634 WLANBAP_LLC_HEADER,
635 sizeof(WLANBAP_LLC_HEADER)
636 - WLANBAP_LLC_OUI_SIZE) /* Don't check the last three bytes here */
637 && vos_mem_compare( &aucLLCHeader[WLANBAP_LLC_OUI_OFFSET],
638 (v_VOID_t*)WLANBAP_BT_AMP_OUI,
639 WLANBAP_LLC_OUI_SIZE))) /* check them here */
640 {
641
642 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
643 "Invalid LLC header for BT-AMP packet in %s", __FUNCTION__);
644 return VOS_STATUS_E_FAULT;
645 }
646#endif //BAP_DEBUG
647
648 /* Now adjust the protocol type bytes*/
649 protoType = vos_cpu_to_be16( protoType);
650 // check if this is a data frame or other, internal to BAP, type...
651 // we are only handling data frames in here...
652 // The others (Security and AR) are handled by TLs BAP client API.
653 // (Verify with TL)
654 if ( !(vos_mem_compare( &aucLLCHeader[WLANBAP_LLC_PROTO_TYPE_OFFSET],
655 &protoType, //WLANBAP_BT_AMP_TYPE_DATA
656 WLANBAP_LLC_PROTO_TYPE_SIZE)))
657 {
658
659 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
660 "Invalid (non-data) frame type in %s", __FUNCTION__);
661 return VOS_STATUS_E_FAULT;
662 }
663
664#ifdef BAP_DEBUG
665 // JEZ081003: Remove this after debugging
666 /*------------------------------------------------------------------------
667 Sanity check the MAC address in the physical link context
668 against the value in the incoming Rx Frame.
669 ------------------------------------------------------------------------*/
670 if ( !(vos_mem_compare( w8023Header.vDA, pBtampCtx->self_mac_addr, VOS_MAC_ADDR_SIZE)
671 && vos_mem_compare( w8023Header.vSA, pBtampCtx->peer_mac_addr, VOS_MAC_ADDR_SIZE)))
672 {
673
674 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
675 "MAC address mismatch in %s", __FUNCTION__);
676 return VOS_STATUS_E_FAULT;
677 }
678#endif //BAP_DEBUG
679
680 /* No lookup is needed. Because TL has already told WLANBAP_STARxCB
681 * the StaId. And I told WLANBAP_STARxCBType the corresponding BSL context
682 * Which he used to lookup the phy_link_handle value.
683 */
684
685
686 // Start filling in the HCI header
687 hciACLHeader.phyLinkHandle = phy_link_handle;
688
689 // Continue filling in the HCI header
690 //JEZ100913: On Rx the Logical Link is ALWAYS 0. See Vol 2, Sec E, 5.4.2 of spec.
691 hciACLHeader.logLinkHandle = 0;
692 hciACLHeader.PBFlag = WLANBAP_HCI_PKT_AMP;
693 hciACLHeader.BCFlag = 0;
694
695 /* Now the length field is big-endian?! */
696 hciDataLength = vos_be16_to_cpu(w8023Header.usLenType);
697 /* Max length WLANBAP_MAX_80211_PAL_PDU_SIZE (1492) */
698 hciDataLength -= WLANBAP_LLC_HEADER_LEN;
699 /* The HCI packet data length is Little-endian */
700 hciACLHeader.dataLength = vos_cpu_to_le16(hciDataLength);
701
702 /* Return the AC here.
703 * (I can't because there is no way to figure out what it is.)
704 */
705 *pucAC = 0;
706
707 /* Push on the HCI header */
708 vos_pkt_push_head(vosDataBuff, &hciACLHeader, WLANBAP_HCI_ACL_HEADER_LEN);
709
710 return VOS_STATUS_SUCCESS;
711} /* WLANBAP_XlateRxDataPkt */
712
713/*----------------------------------------------------------------------------
714
715 FUNCTION WLANBAP_STAFetchPktCB
716
717 DESCRIPTION
718 The fetch packet callback registered with TL.
719
720 It is called by the TL when the scheduling algorithms allows for
721 transmission of another packet to the module.
722 It will be called in the context of the BAL fetch transmit packet
723 function, initiated by the bus lower layer.
724
725
726 PARAMETERS
727
728 IN
729 pvosGCtx: pointer to the global vos context; a handle
730 to TL's or HDD's control block can be extracted
731 from its context
732
733 IN/OUT
734 pucSTAId: the Id of the station for which TL is requesting a
735 packet, in case HDD does not maintain per station
736 queues it can give the next packet in its queue
737 and put in the right value for the
738 pucAC: access category requested by TL, if HDD does not have
739 packets on this AC it can choose to service another AC
740 queue in the order of priority
741
742 OUT
743 vosDataBuff: pointer to the VOSS data buffer that was transmitted
744 tlMetaInfo: meta info related to the data frame
745
746
747
748 RETURN VALUE
749 The result code associated with performing the operation
750
751----------------------------------------------------------------------------*/
752VOS_STATUS
753WLANBAP_STAFetchPktCB
754(
755 v_PVOID_t pvosGCtx,
756 v_U8_t* pucSTAId,
757 v_U8_t ucAC,
758 vos_pkt_t** vosDataBuff,
759 WLANTL_MetaInfoType* tlMetaInfo
760)
761{
762 VOS_STATUS vosStatus;
763 ptBtampHandle bapHdl; /* holds ptBtampHandle value returned */
764 ptBtampContext bapContext; /* Holds the btampContext value returned */
765 v_PVOID_t pHddHdl; /* Handle to return BSL context in */
766
767 /* Lookup the BSL and BAP contexts using the StaId */
768
769 vosStatus = WLANBAP_GetCtxFromStaId (
770 *pucSTAId, /* The StaId (used by TL, PE, and HAL) */
771 &bapHdl, /* "handle" to return ptBtampHandle value in */
772 &bapContext, /* "handle" to return ptBtampContext value in */
773 &pHddHdl); /* "handle" to return BSL context in */
774 if ( VOS_STATUS_SUCCESS != vosStatus )
775 {
776 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
777 "Unable to retrieve BSL or BAP context from STA Id in WLANBAP_STAFetchPktCB");
778 return VOS_STATUS_E_FAULT;
779 }
780
781 /* Invoke the callback that BSL registered with me */
782 vosStatus = (*bapContext->pfnBtampFetchPktCB)(
783 pHddHdl,
784 (WLANTL_ACEnumType) ucAC, /* typecast it for now */
785 vosDataBuff,
786 tlMetaInfo);
787 if ( VOS_STATUS_SUCCESS != vosStatus )
788 {
789 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
790 "Callback registered by BSL failed to fetch pkt in WLANNBAP_STAFetchPktCB");
791 return VOS_STATUS_E_FAULT;
792 }
793
794 return vosStatus;
795} /* WLANBAP_STAFetchPktCB */
796
797/*----------------------------------------------------------------------------
798
799 FUNCTION WLANBAP_STARxCB
800
801 DESCRIPTION
802 The receive callback registered with TL.
803
804 TL will call this to notify the client when a packet was received
805 for a registered STA.
806
807 PARAMETERS
808
809 IN
810 pvosGCtx: pointer to the global vos context; a handle to
811 TL's or HDD's control block can be extracted from
812 its context
813 vosDataBuff: pointer to the VOSS data buffer that was received
814 (it may be a linked list)
815 ucSTAId: station id
816 pRxMetaInfo: meta info for the received packet(s)
817
818 RETURN VALUE
819 The result code associated with performing the operation
820
821----------------------------------------------------------------------------*/
822VOS_STATUS
823WLANBAP_STARxCB
824(
825 v_PVOID_t pvosGCtx,
826 vos_pkt_t* vosDataBuff,
827 v_U8_t ucSTAId,
828 WLANTL_RxMetaInfoType* pRxMetaInfo
829)
830{
831 VOS_STATUS vosStatus;
832 ptBtampHandle bapHdl; /* holds ptBtampHandle value returned */
833 ptBtampContext bapContext; /* Holds the btampContext value returned */
834 v_PVOID_t pHddHdl; /* Handle to return BSL context in */
835 ptBtampHandle btampHandle;
836 WLANBAP_8023HeaderType w8023Header;
837 v_U8_t aucLLCHeader[WLANBAP_LLC_HEADER_LEN];
838 v_U16_t protoType ;
839 v_SIZE_t llcHeaderLen = WLANBAP_LLC_HEADER_LEN ;
840
841 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
842 "In WLANBAP_STARxCB");
843
844 /* Lookup the BSL and BAP contexts using the StaId */
845
846 vosStatus = WLANBAP_GetCtxFromStaId (
847 ucSTAId, /* The StaId (used by TL, PE, and HAL) */
848 &bapHdl, /* "handle" to return ptBtampHandle value in */
849 &bapContext, /* "handle" to return ptBtampContext value in */
850 &pHddHdl); /* "handle" to return BSL context in */
851 if ( VOS_STATUS_SUCCESS != vosStatus )
852 {
853 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
854 "Unable to retrieve BSL or BAP context from STA Id in WLANBAP_STARxCB");
855 /* Drop packet */
856 vos_pkt_return_packet(vosDataBuff);
857 return VOS_STATUS_E_FAULT;
858 }
859
860
861 vosStatus = vos_pkt_extract_data( vosDataBuff, sizeof(w8023Header), (v_VOID_t *)aucLLCHeader,
862 &llcHeaderLen);
863
864 if ( NULL == aucLLCHeader/*LLC Header*/ )
865 {
866 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
867 "WLANBAP_STARxCB:Cannot extract LLC header");
868 /* Drop packet */
869 vos_pkt_return_packet(vosDataBuff);
870 return VOS_STATUS_E_FAULT;
871 }
872
873 vos_mem_copy(&protoType,&aucLLCHeader[WLANBAP_LLC_PROTO_TYPE_OFFSET],WLANBAP_LLC_PROTO_TYPE_SIZE);
874 protoType = vos_be16_to_cpu(protoType);
875
876 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
877 "%s: received : %d, => BAP",__FUNCTION__,
878 protoType);
879
880 if(WLANBAP_BT_AMP_TYPE_DATA == protoType)
881 {
882 if (bapContext->bapLinkSupervisionTimerInterval)
883 {
884 /* Reset Link Supervision timer */
885 //vosStatus = WLANBAP_StopLinkSupervisionTimer(bapContext);
886 //vosStatus = WLANBAP_StartLinkSupervisionTimer(bapContext,7000);
887 bapContext->dataPktPending = VOS_TRUE;//Indication for LinkSupervision module that data is pending
888 /* Invoke the callback that BSL registered with me */
889 vosStatus = (*bapContext->pfnBtamp_STARxCB)(
890 pHddHdl,
891 vosDataBuff,
892 pRxMetaInfo);
893 }
894 else
895 {
896 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
897 "WLANBAP_STARxCB:bapLinkSupervisionTimerInterval is 0");
898 /* Drop packet */
899 vos_pkt_return_packet(vosDataBuff);
900 }
901 }
902 else
903 {
904 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
905 "%s: link Supervision packet received over TL: %d, => BAP",
906 __FUNCTION__,protoType);
907 btampHandle = (ptBtampHandle)bapContext;
908 vosStatus = WLANBAP_RxProcLsPkt(
909 btampHandle,
910 bapContext->phy_link_handle,
911 protoType,
912 vosDataBuff
913 );
914 }
915
916 return vosStatus;
917} /* WLANBAP_STARxCB */
918
919
920/*----------------------------------------------------------------------------
921
922 FUNCTION WLANBAP_TxCompCB
923
924 DESCRIPTION
925 The tx complete callback registered with TL.
926
927 TL will call this to notify the client when a transmission for a
928 packet has ended.
929
930 PARAMETERS
931
932 IN
933 pvosGCtx: pointer to the global vos context; a handle to
934 TL/HAL/PE/BAP/HDD control block can be extracted from
935 its context
936 vosDataBuff: pointer to the VOSS data buffer that was transmitted
937 wTxSTAtus: status of the transmission
938
939
940 RETURN VALUE
941 The result code associated with performing the operation
942
943----------------------------------------------------------------------------*/
944VOS_STATUS
945WLANBAP_TxCompCB
946(
947 v_PVOID_t pvosGCtx,
948 vos_pkt_t* vosDataBuff,
949 VOS_STATUS wTxSTAtus
950)
951{
952 VOS_STATUS vosStatus;
953 ptBtampHandle bapHdl; /* holds ptBtampHandle value returned */
954 ptBtampContext bapContext; /* Holds the btampContext value returned */
955 v_PVOID_t pHddHdl; /* Handle to return BSL context in */
956 v_PVOID_t pvlogLinkHandle = NULL;
957 v_U32_t value;
958
959 WLANBAP_HCIACLHeaderType hciACLHeader;
960
961 /* retrieve the BSL and BAP contexts */
962
963 /* I don't really know how to do this - in the general case. */
964 /* So, for now, I will just use something that works. */
965 /* (In general, I will have to keep a list of the outstanding transmit */
966 /* buffers, in order to determine which assoc they are with.) */
967 //vosStatus = WLANBAP_GetCtxFromStaId (
968 // ucSTAId, /* The StaId (used by TL, PE, and HAL) */
969 // &bapHdl, /* "handle" to return ptBtampHandle value in */
970 // &bapContext, /* "handle" to return ptBtampContext value in */
971 // &pHddHdl); /* "handle" to return BSL context in */
972 /* Temporarily we do the following*/
973 //bapHdl = &btampCtx;
974 bapHdl = (v_PVOID_t)gpBtampCtx;
975 /* Typecast the handle into a context. Works as we have only one link*/
976 bapContext = ((ptBtampContext) bapHdl);
977
978 /*------------------------------------------------------------------------
979 Sanity check params
980 ------------------------------------------------------------------------*/
981 if ( NULL == vosDataBuff)
982 {
983 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
984 "Invalid vosDataBuff value in %s", __FUNCTION__);
985 return VOS_STATUS_E_FAULT;
986 }
987
988 if ( NULL == bapContext)
989 {
990 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
991 "Invalid bapContext value in %s", __FUNCTION__);
992 vos_pkt_return_packet( vosDataBuff );
993 return VOS_STATUS_E_FAULT;
994 }
995
996 pHddHdl = bapContext->pHddHdl;
997 vosStatus = VOS_STATUS_SUCCESS;
998 if ( VOS_STATUS_SUCCESS != vosStatus )
999 {
1000 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
1001 "Unable to retrieve BSL or BAP context from STA Id in WLANBAP_TxCompCB");
1002 vos_pkt_return_packet( vosDataBuff );
1003 return VOS_STATUS_E_FAULT;
1004 }
1005
1006 /*Get the logical link handle from the vos user data*/
1007 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAP,
1008 &pvlogLinkHandle);
1009
1010 value = (v_U32_t)pvlogLinkHandle;
1011 hciACLHeader.logLinkHandle = value;
1012
1013#ifdef BAP_DEBUG
1014 /* Trace the bapContext referenced. */
1015 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
1016 "WLAN BAP Context Monitor: bapContext value = %p in %s:%d. vosDataBuff=%p", bapContext, __FUNCTION__, __LINE__, vosDataBuff );
1017#endif //BAP_DEBUG
1018
1019 // Sanity check the log_link_handle value
1020// JEZ100722: Temporary changes.
1021 if (BTAMP_VALID_LOG_LINK( hciACLHeader.logLinkHandle))
1022 {
1023 vos_atomic_increment_U32(
1024 &bapContext->btampLogLinkCtx[hciACLHeader.logLinkHandle].uTxPktCompleted);
1025// &bapContext->btampLogLinkCtx[0].uTxPktCompleted);
1026// vos_atomic_increment_U32(
1027// &bapContext->btampLogLinkCtx[1].uTxPktCompleted);
1028 } else
1029 {
1030 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1031 "In %s:%d: Invalid logical link handle: %d", __FUNCTION__, __LINE__, hciACLHeader.logLinkHandle);
1032 }
1033
1034 /* Invoke the callback that BSL registered with me */
1035 vosStatus = (*bapContext->pfnBtampTxCompCB)(
1036 pHddHdl,
1037 vosDataBuff,
1038 wTxSTAtus);
1039
1040 return vosStatus;
1041} /* WLANBAP_TxCompCB */
1042
1043/*==========================================================================
1044
1045 FUNCTION WLANBAP_RegisterDataPlane
1046
1047 DESCRIPTION
1048 The HDD calls this routine to register the "data plane" routines
1049 for Tx, Rx, and Tx complete with BT-AMP. For now, with only one
1050 physical association supported at a time, this COULD be called
1051 by HDD at the same time as WLANBAP_GetNewHndl. But, in general
1052 it needs to be called upon each new physical link establishment.
1053
1054 This registration is really two part. The routines themselves are
1055 registered here. But, the mapping between the BSL context and the
1056 actual physical link takes place during WLANBAP_PhysicalLinkCreate.
1057
1058 DEPENDENCIES
1059
1060 PARAMETERS
1061
1062 IN
1063 btampHandle: The BT-AMP PAL handle returned in WLANBAP_GetNewHndl.
1064
1065 RETURN VALUE
1066 The result code associated with performing the operation
1067
1068 VOS_STATUS_E_FAULT: pointer to BAP cb is NULL ; access would cause a page
1069 fault
1070 VOS_STATUS_SUCCESS: Everything is good :)
1071
1072 SIDE EFFECTS
1073
1074============================================================================*/
1075VOS_STATUS
1076WLANBAP_RegisterDataPlane
1077(
1078 ptBtampHandle btampHandle, /* BTAMP context */
1079 WLANBAP_STAFetchPktCBType pfnBtampFetchPktCB,
1080 WLANBAP_STARxCBType pfnBtamp_STARxCB,
1081 WLANBAP_TxCompCBType pfnBtampTxCompCB,
1082 // phy_link_handle, of course, doesn't come until much later. At Physical Link create.
1083 v_PVOID_t pHddHdl /* BSL specific context */
1084)
1085{
1086 ptBtampContext pBtampCtx = (ptBtampContext) btampHandle;
1087
1088
1089 /*------------------------------------------------------------------------
1090 Sanity check params
1091 ------------------------------------------------------------------------*/
1092 if ( NULL == pBtampCtx)
1093 {
1094 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1095 "Invalid BAP handle value in WLANBAP_RegisterDataPlane");
1096 return VOS_STATUS_E_FAULT;
1097 }
1098
1099 // Include the HDD BAP Shim Layer callbacks for Fetch, TxComp, and RxPkt
1100 pBtampCtx->pfnBtampFetchPktCB = pfnBtampFetchPktCB;
1101 pBtampCtx->pfnBtamp_STARxCB = pfnBtamp_STARxCB;
1102 pBtampCtx->pfnBtampTxCompCB = pfnBtampTxCompCB;
1103
1104 // (Right now, there is only one)
1105 pBtampCtx->pHddHdl = pHddHdl;
1106 /* Set the default data transfer mode */
1107 pBtampCtx->ucDataTrafficMode = WLANBAP_FLOW_CONTROL_MODE_BLOCK_BASED;
1108
1109 return VOS_STATUS_SUCCESS;
1110} /* WLANBAP_RegisterDataPlane */
1111
1112
1113/*===========================================================================
1114
1115 FUNCTION WLANBAP_STAPktPending
1116
1117 DESCRIPTION
1118
1119 HDD will call this API when a packet is pending transmission in its
1120 queues. HDD uses this instead of WLANTL_STAPktPending because he is
1121 not aware of the mapping from session to STA ID.
1122
1123 DEPENDENCIES
1124
1125 HDD must have called WLANBAP_GetNewHndl before calling this API.
1126
1127 PARAMETERS
1128
1129 btampHandle: The BT-AMP PAL handle returned in WLANBAP_GetNewHndl.
1130 BSL can obtain this from the physical handle value in the
1131 downgoing HCI Data Packet. He, after all, was there
1132 when the PhysicalLink was created. He knew the btampHandle
1133 value returned by WLANBAP_GetNewHndl. He knows as well, his
1134 own pHddHdl (see next).
1135 phy_link_handle: Used by BAP to indentify the WLAN assoc. (StaId)
1136 ucAc: The access category for the pending frame
1137
1138 RETURN VALUE
1139
1140 The result code associated with performing the operation
1141
1142 VOS_STATUS_E_INVAL: Input parameters are invalid
1143 VOS_STATUS_E_FAULT: BAP handle is NULL
1144 VOS_STATUS_SUCCESS: Everything is good :)
1145
1146 SIDE EFFECTS
1147
1148============================================================================*/
1149VOS_STATUS
1150WLANBAP_STAPktPending
1151(
1152 ptBtampHandle btampHandle, /* Used by BAP to identify the app context and VOSS ctx (!?) */
1153 v_U8_t phy_link_handle, /* Used by BAP to indentify the WLAN assoc. (StaId) */
1154 WLANTL_ACEnumType ucAc /* This is the first instance of a TL type in bapApi.h */
1155)
1156{
1157 VOS_STATUS vosStatus;
1158 ptBtampContext pBtampCtx = (ptBtampContext) btampHandle;
1159 v_PVOID_t pvosGCtx;
1160 v_U8_t ucSTAId; /* The StaId (used by TL, PE, and HAL) */
1161 v_PVOID_t pHddHdl; /* Handle to return BSL context in */
1162
1163
1164#ifdef BAP_DEBUG
1165 /* Trace the tBtampCtx being passed in. */
1166 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO_HIGH,
1167 "WLAN BAP Context Monitor: pBtampCtx value = %p in %s:%d", pBtampCtx, __FUNCTION__, __LINE__ );
1168#endif //BAP_DEBUG
1169
1170 /*------------------------------------------------------------------------
1171 Sanity check params
1172 ------------------------------------------------------------------------*/
1173 if ( NULL == pBtampCtx)
1174 {
1175 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1176 "Invalid BAP handle value in WLANBAP_STAPktPending");
1177 return VOS_STATUS_E_FAULT;
1178 }
1179
1180 // Retrieve the VOSS context
1181 pvosGCtx = pBtampCtx->pvosGCtx;
1182
1183 /* Lookup the StaId using the phy_link_handle and the BAP context */
1184
1185 vosStatus = WLANBAP_GetStaIdFromLinkCtx (
1186 btampHandle, /* btampHandle value in */
1187 phy_link_handle, /* phy_link_handle value in */
1188 &ucSTAId, /* The StaId (used by TL, PE, and HAL) */
1189 &pHddHdl); /* Handle to return BSL context */
1190 if ( VOS_STATUS_SUCCESS != vosStatus )
1191 {
1192 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_INFO,
1193 "Unable to retrieve STA Id from BAP context and phy_link_handle in WLANBAP_STAPktPending");
1194 return VOS_STATUS_E_FAULT;
1195 }
1196
1197
1198 // Let TL know we have a packet to send...
1199 vosStatus = WLANTL_STAPktPending(
1200 pvosGCtx,
1201 ucSTAId,
1202 ucAc);
1203 if ( VOS_STATUS_SUCCESS != vosStatus )
1204 {
1205 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1206 "Tx: Packet rejected by TL in WLANBAP_STAPktPending");
1207 return vosStatus;
1208 }
1209 pBtampCtx->dataPktPending = VOS_TRUE;//Indication for LinkSupervision module that data is pending
1210 return VOS_STATUS_SUCCESS;
1211} /* WLANBAP_STAPktPending */
1212
1213/*----------------------------------------------------------------------------
1214
1215 FUNCTION WLAN_BAPRegisterBAPCallbacks()
1216
1217 DESCRIPTION
1218 Register the BAP "Event" callbacks.
1219 Return the per instance handle.
1220
1221 DEPENDENCIES
1222 NA.
1223
1224 PARAMETERS
1225
1226 IN
1227 btampHandle: The BT-AMP PAL handle returned in WLANBAP_GetNewHndl.
1228 pBapHCIEventCB: pointer to the Event callback
1229 pAppHdl: The context passed in by caller. (I.E., BSL app specific context.)
1230
1231
1232 RETURN VALUE
1233 The result code associated with performing the operation
1234
1235 VOS_STATUS_E_FAULT: pointer to pBapHCIEventCB is NULL
1236 VOS_STATUS_SUCCESS: Success
1237
1238 SIDE EFFECTS
1239
1240----------------------------------------------------------------------------*/
1241VOS_STATUS
1242WLAN_BAPRegisterBAPCallbacks
1243(
1244 ptBtampHandle btampHandle, /* BSL uses my handle to talk to me */
1245 /* Returned from WLANBAP_GetNewHndl() */
1246 /* It's like each of us is using the other */
1247 /* guys reference when invoking him. */
1248 tpWLAN_BAPEventCB pBapHCIEventCB, /*Implements the callback for ALL asynchronous events. */
1249 v_PVOID_t pAppHdl // Per-app BSL context
1250)
1251{
1252 ptBtampContext pBtampCtx = (ptBtampContext) btampHandle;
1253
1254
1255 /*------------------------------------------------------------------------
1256 Sanity check params
1257 ------------------------------------------------------------------------*/
1258 if ( NULL == pBtampCtx)
1259 {
1260 VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
1261 "Invalid BAP handle value in WLAN_BAPRegisterBAPCallbacks");
1262 return VOS_STATUS_E_FAULT;
1263 }
1264
1265 // Save the Event callback
1266 pBtampCtx->pBapHCIEventCB = pBapHCIEventCB;
1267
1268 // (Right now, there is only one)
1269 pBtampCtx->pAppHdl = pAppHdl;
1270
1271 return VOS_STATUS_SUCCESS;
1272} /* WLAN_BAPRegisterBAPCallbacks */
1273
1274