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