blob: e4710c70e81cd45c7e79a792fffa2a553a04c6c6 [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
45 W L A N _ Q C T _ T L . C
46
47 OVERVIEW:
48
49 This software unit holds the implementation of the WLAN Transport Layer.
50
51 The functions externalized by this module are to be called ONLY by other
52 WLAN modules that properly register with the Transport 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$$DateTime$$Author$
74
75
76 when who what, where, why
77---------- --- --------------------------------------------------------
782010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
79 WAI frame sent out during rekeying had the protected bit
80 set to 1.
812010-05-06 rnair Changed name of variable from usLlcType to usEtherType
82 Changed function name from GetLLCType to GetEtherType
83 Fixed 802.3 to 802.11 frame translation issue where two
84 bytes of the LLC header was getting overwritten in the
85 non-Qos path
862010-05-06 rnair RxAuth path fix for modifying the header before ether
87 type is retreived (Detected while testing rekeying
88 in WAPI Volans)
892010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
902010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
91 does frame translation.
922010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
93 being set in the TL control block in the RegisterSTA func.
942010-01-08 lti Added TL Data Caching
952009-11-04 rnair WAPI: Moving common functionality to a seperate function
96 called WLANTL_GetLLCType
972009-10-15 rnair WAPI: Featurizing WAPI code
982009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
992009-10-06 rnair Adding support for WAPI
1002009-09-22 lti Add deregistration API for management client
1012009-07-16 rnair Temporary fix to let TL fetch packets when multiple
102 peers exist in an IBSS
1032009-06-10 lti Fix for checking TID value of meta info on TX - prevent
104 memory overwrite
105 Fix for properly checking the sta id for resuming trigger
106 frame generation
1072009-05-14 lti Fix for sending out trigger frames
1082009-05-15 lti Addr3 filtering
1092009-04-13 lti Assert if packet larger then allowed
110 Drop packet that fails flatten
1112009-04-02 lti Performance fixes for TL
1122009-02-19 lti Added fix for LLC management on Rx Connect
1132009-01-16 lti Replaced peek data with extract data for non BD opertions
114 Extracted frame control in Tl and pass to HAL for frame
115 type evaluation
1162009-02-02 sch Add handoff support
1172008-12-09 lti Fixes for AMSS compilation
118 Removed assert on receive when there is no station
1192008-12-02 lti Fix fo trigger frame generation
1202008-10-31 lti Fix fo TL tx suspend
1212008-10-01 lti Merged in fixes from reordering
122 Disabled part of UAPSD functionality in TL
123 (will be re-enabled once UAPSD is tested)
124 Fix for UAPSD multiple enable
1252008-08-10 lti Fixes following UAPSD testing
126 Fixed infinite loop on mask computation when STA no reg
1272008-08-06 lti Fixes after QOS unit testing
1282008-08-06 lti Added QOS support
1292008-07-23 lti Fix for vos packet draining
1302008-07-17 lti Fix for data type value
131 Added frame translation code in TL
132 Avoid returning failure to PE in case previous frame is
133 still pending; fail previous and cache new one for tx
134 Get frames returning boolean true if more frames are pending
1352008-07-03 lti Fixes following pre-integration testing
1362008-06-26 lti Fixes following unit testing
137 Added alloc and free for TL context
138 Using atomic set u8 instead of u32
1392008-05-16 lti Created module
140
141===========================================================================*/
142
143/*----------------------------------------------------------------------------
144 * Include Files
145 * -------------------------------------------------------------------------*/
146#include "wlan_qct_tl.h"
147#include "wlan_qct_wda.h"
148#include "wlan_qct_tli.h"
149#include "wlan_qct_tli_ba.h"
150#include "wlan_qct_tl_hosupport.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700151#include "tlDebug.h"
152#ifdef FEATURE_WLAN_WAPI
153/*Included to access WDI_RxBdType */
154#include "wlan_qct_wdi_bd.h"
155#endif
156/*Enables debugging behavior in TL*/
157#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700158/*Enables debugging FC control frame in TL*/
159//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700160//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700161//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700162#ifdef TL_DEBUG_FC
163#include <wlan_qct_pal_status.h>
164#include <wlan_qct_pal_device.h> // wpalReadRegister
165#endif
166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167/*----------------------------------------------------------------------------
168 * Preprocessor Definitions and Constants
169 * -------------------------------------------------------------------------*/
170/*LLC header value*/
171static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
172
173#ifdef FEATURE_WLAN_CCX
174/*Aironet SNAP header value*/
175static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
176#endif //FEATURE_WLAN_CCX
177
178/*BT-AMP packet LLC OUI value*/
179const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
180
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530181#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700182
183#ifdef VOLANS_PERF
184#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
185#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
186
187/* TL BD/PDU threshold to enable interrupt */
188int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
189int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
190#endif /* VOLANS_PERF */
191
192/*-----------------------------------*
193 | Type(2b) | Sub-type(4b) |
194 *-----------------------------------*/
195#define WLANTL_IS_DATA_FRAME(_type_sub) \
196 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
197
198#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
199 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
200 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
201
202#define WLANTL_IS_MGMT_FRAME(_type_sub) \
203 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
204
205#define WLANTL_IS_CTRL_FRAME(_type_sub) \
206 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
207
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800208#ifdef FEATURE_WLAN_TDLS
209#define WLANTL_IS_TDLS_FRAME(_eth_type) \
210 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
211#endif
212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800214#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216#define WLANTL_MASK_AC 0x03
217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218//some flow_control define
219//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
220#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
221
222//Get enough sample to do the LWM related calculation
223#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
224
225//Maximal on-fly packet per station in LWM mode
226#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
227
228#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800229#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700230
231/* UINT32 type endian swap */
232#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
233 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
234
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530235/* Maximum value of SNR that can be calculated by the HW */
236#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700237
238/*--------------------------------------------------------------------------
239 TID to AC mapping in TL
240 --------------------------------------------------------------------------*/
241const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID] = { WLANTL_AC_BE,
242 WLANTL_AC_BK,
243 WLANTL_AC_BK,
244 WLANTL_AC_BE,
245 WLANTL_AC_VI,
246 WLANTL_AC_VI,
247 WLANTL_AC_VO,
248 WLANTL_AC_VO };
249
250/*----------------------------------------------------------------------------
251 * Type Declarations
252 * -------------------------------------------------------------------------*/
253#define TL_LITTLE_BIT_ENDIAN
254
255typedef struct
256{
257
258#ifndef TL_LITTLE_BIT_ENDIAN
259
260 v_U8_t subType :4;
261 v_U8_t type :2;
262 v_U8_t protVer :2;
263
264 v_U8_t order :1;
265 v_U8_t wep :1;
266 v_U8_t moreData :1;
267 v_U8_t powerMgmt :1;
268 v_U8_t retry :1;
269 v_U8_t moreFrag :1;
270 v_U8_t fromDS :1;
271 v_U8_t toDS :1;
272
273#else
274
275 v_U8_t protVer :2;
276 v_U8_t type :2;
277 v_U8_t subType :4;
278
279 v_U8_t toDS :1;
280 v_U8_t fromDS :1;
281 v_U8_t moreFrag :1;
282 v_U8_t retry :1;
283 v_U8_t powerMgmt :1;
284 v_U8_t moreData :1;
285 v_U8_t wep :1;
286 v_U8_t order :1;
287
288#endif
289
290} WLANTL_MACFCType;
291
292/* 802.11 header */
293typedef struct
294{
295 /* Frame control field */
296 WLANTL_MACFCType wFrmCtrl;
297
298 /* Duration ID */
299 v_U16_t usDurationId;
300
301 /* Address 1 field */
302 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
303
304 /* Address 2 field */
305 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
306
307 /* Address 3 field */
308 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
309
310 /* Sequence control field */
311 v_U16_t usSeqCtrl;
312
313 // Find the size of the mandatory header size.
314#define WLAN80211_MANDATORY_HEADER_SIZE \
315 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
316 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
317 sizeof(v_U16_t))
318
319 /* Optional A4 address */
320 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
321
322 /* Optional QOS control field */
323 v_U16_t usQosCtrl;
324}WLANTL_80211HeaderType;
325
326/* 802.3 header */
327typedef struct
328{
329 /* Destination address field */
330 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
331
332 /* Source address field */
333 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
334
335 /* Length field */
336 v_U16_t usLenType;
337}WLANTL_8023HeaderType;
338
339/*----------------------------------------------------------------------------
340 * Global Data Definitions
341 * -------------------------------------------------------------------------*/
342#define WLAN_TL_INVALID_U_SIG 255
343#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530344#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
345
Jeff Johnson295189b2012-06-20 16:38:30 -0700346#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
347 do\
348 {\
349 _ucACMask = 0; \
350 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
351 { \
352 if ( 0 != (_pSTA)->aucACMask[i] ) \
353 { \
354 _ucACMask |= ( 1 << i ); \
355 } \
356 } \
357 } while (0);
358
359/*----------------------------------------------------------------------------
360 * Static Variable Definitions
361 * -------------------------------------------------------------------------*/
362
363/*----------------------------------------------------------------------------
364 * Static Function Declarations and Definitions
365 * -------------------------------------------------------------------------*/
366
367static VOS_STATUS
368WLANTL_GetEtherType
369(
370 v_U8_t * aucBDHeader,
371 vos_pkt_t * vosDataBuff,
372 v_U8_t ucMPDUHLen,
373 v_U16_t * usEtherType
374);
375
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800376#ifdef FEATURE_WLAN_TDLS_INTERNAL
377/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
378But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
379wherease TDLS expect vosDataBuff->offset should still points to RxBd.
380So far, data frmae stripped RxBD and passed to data frame handler.
381(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
382handler, where RX BD should be preserved)
383To avoid breaking existing functionality, for now, I temporarily rename to
384WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
385*/
386static VOS_STATUS
387WLANTL_GetEtherType_2
388(
389 v_U8_t * aucBDHeader,
390 vos_pkt_t * vosDataBuff,
391 v_U8_t ucMPDUHLen,
392 v_U16_t * usEtherType
393);
394#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700395#ifdef FEATURE_WLAN_WAPI
396/*---------------------------------------------------------------------------
397 * Adding a global variable to be used when doing frame translation in TxAuth
398 * state so as to not set the protected bit to 1 in the case of WAI frames
399 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700400v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700401#endif
402
403/*----------------------------------------------------------------------------
404 * Externalized Function Definitions
405* -------------------------------------------------------------------------*/
406
407/*----------------------------------------------------------------------------
408 * Function Declarations and Documentation
409 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530410/*==========================================================================
411
412 FUNCTION WLANTL_FreeClientMemory
413
414 DESCRIPTION
415 It frees up the memory allocated to all the STA clients in TLCB block
416 Can be called inside Close, Stop or when some FAULT occurs
417
418 DEPENDENCIES
419
420 PARAMETERS
421
422 IN
423 pClientSTA: Pointer to the global client pointer array
424
425 RETURN VALUE
426
427 SIDE EFFECTS
428
429============================================================================*/
430void WLANTL_FreeClientMemory
431(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
432{
433 v_U32_t i = 0;
434 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
435 {
436 if( NULL != pClientSTA[i] )
437 {
438 vos_mem_free(pClientSTA[i]);
439 }
440 pClientSTA[i] = NULL;
441 }
442 return;
443}
Jeff Johnson295189b2012-06-20 16:38:30 -0700444
445/*==========================================================================
446
447 FUNCTION WLANTL_Open
448
449 DESCRIPTION
450 Called by HDD at driver initialization. TL will initialize all its
451 internal resources and will wait for the call to start to register
452 with the other modules.
453
454 DEPENDENCIES
455
456 PARAMETERS
457
458 IN
459 pvosGCtx: pointer to the global vos context; a handle to TL's
460 control block can be extracted from its context
461 pTLConfig: TL Configuration
462
463 RETURN VALUE
464 The result code associated with performing the operation
465
466 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
467 fault
468 VOS_STATUS_SUCCESS: Everything is good :)
469
470 SIDE EFFECTS
471
472============================================================================*/
473VOS_STATUS
474WLANTL_Open
475(
476 v_PVOID_t pvosGCtx,
477 WLANTL_ConfigInfoType* pTLConfig
478)
479{
480 WLANTL_CbType* pTLCb = NULL;
481 v_U8_t ucIndex;
482 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530483 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700484#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
485 VOS_STATUS status = VOS_STATUS_SUCCESS;
486#endif
487 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
488
489 /*------------------------------------------------------------------------
490 Sanity check
491 Extract TL control block
492 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530493 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
495 (void*)&pTLCb, sizeof(WLANTL_CbType));
496
497 pTLCb = VOS_GET_TL_CB(pvosGCtx);
498 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
499 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700500 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530501 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 return VOS_STATUS_E_FAULT;
503 }
504
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700505 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
506 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
509 if ( NULL == smeContext )
510 {
511 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700512 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 return VOS_STATUS_E_FAULT;
514 }
515
516 /* Zero out the memory so we are OK, when CleanCB is called.*/
517 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
518
519 /*------------------------------------------------------------------------
520 Clean up TL control block, initialize all values
521 ------------------------------------------------------------------------*/
522 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
523 "WLAN TL:WLANTL_Open"));
524
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530525 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530527 if ( i < WLAN_NON32_STA_COUNT )
528 {
529 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
530 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
531 if ( NULL == pTLCb->atlSTAClients[i] )
532 {
533 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
534 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
535 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
536 return VOS_STATUS_E_FAULT;
537 }
538 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
539 }
540 else
541 {
542 pTLCb->atlSTAClients[i] = NULL;
543 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 }
545
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
547 if (NULL == pTLCb->reorderBufferPool)
548 {
549 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: Reorder buffer allocation failed\n"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530550 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
552 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 }
554
555 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
556
557 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
558
559 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
560 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530561 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 }
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 // scheduling init to be the last one of previous round
565 pTLCb->uCurServedAC = WLANTL_AC_BK;
566 pTLCb->ucCurLeftWeight = 1;
567 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
568
569#if 0
570 //flow control field init
571 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
572 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
573 pTLCb->tlFCInfo.fcConfig = 0x1;
574#endif
575
576 pTLCb->vosTxFCBuf = NULL;
577 pTLCb->tlConfigInfo.uMinFramesProcThres =
578 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Sunil Ravid5406f22013-01-22 00:18:31 -0800580#ifdef FEATURE_WLAN_TDLS
581 pTLCb->ucTdlsPeerCount = 0;
582#endif
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
585 pTLConfig->uDelayedTriggerFrmInt;
586
587 /*------------------------------------------------------------------------
588 Allocate internal resources
589 ------------------------------------------------------------------------*/
590 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
591 1/*true*/,NULL, NULL);
592
593 WLANTL_InitBAReorderBuffer(pvosGCtx);
594#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
595 /* Initialize Handoff support modue
596 * RSSI measure and Traffic state monitoring */
597 status = WLANTL_HSInit(pvosGCtx);
598 if(!VOS_IS_STATUS_SUCCESS(status))
599 {
600 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
601 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530602 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 vos_mem_free(pTLCb->reorderBufferPool);
604 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
605 return status;
606 }
607#endif
608
609 pTLCb->isBMPS = VOS_FALSE;
610 pmcRegisterDeviceStateUpdateInd( smeContext,
611 WLANTL_PowerStateChangedCB, pvosGCtx );
612
613 return VOS_STATUS_SUCCESS;
614}/* WLANTL_Open */
615
616/*==========================================================================
617
618 FUNCTION WLANTL_Start
619
620 DESCRIPTION
621 Called by HDD as part of the overall start procedure. TL will use this
622 call to register with BAL as a transport layer entity.
623
624 DEPENDENCIES
625
626 PARAMETERS
627
628 IN
629 pvosGCtx: pointer to the global vos context; a handle to TL's
630 control block can be extracted from its context
631
632 RETURN VALUE
633 The result code associated with performing the operation
634
635 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
636 fault
637 VOS_STATUS_SUCCESS: Everything is good :)
638
639 Other codes can be returned as a result of a BAL failure; see BAL API
640 for more info
641
642 SIDE EFFECTS
643
644============================================================================*/
645VOS_STATUS
646WLANTL_Start
647(
648 v_PVOID_t pvosGCtx
649)
650{
651 WLANTL_CbType* pTLCb = NULL;
652 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
653 VOS_STATUS vosStatus;
654 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
655
656 /*------------------------------------------------------------------------
657 Sanity check
658 Extract TL control block
659 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530660 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 pTLCb = VOS_GET_TL_CB(pvosGCtx);
662 if ( NULL == pTLCb )
663 {
664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
665 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
666 return VOS_STATUS_E_FAULT;
667 }
668
669 /*------------------------------------------------------------------------
670 Register with WDA as transport layer client
671 Request resources for tx from bus
672 ------------------------------------------------------------------------*/
673 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
674 "WLAN TL:WLAN TL:WLANTL_Start"));
675
676 vosStatus = WDA_DS_Register( pvosGCtx,
677 WLANTL_TxComp,
678 WLANTL_RxFrames,
679 WLANTL_GetFrames,
680 WLANTL_ResourceCB,
681 WDA_TLI_MIN_RES_DATA,
682 pvosGCtx,
683 &uResCount );
684
685 if ( VOS_STATUS_SUCCESS != vosStatus )
686 {
687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
688 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
689 vosStatus));
690 return vosStatus;
691 }
692
693 /* Enable transmission */
694 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
695
696 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 return VOS_STATUS_SUCCESS;
698}/* WLANTL_Start */
699
700/*==========================================================================
701
702 FUNCTION WLANTL_Stop
703
704 DESCRIPTION
705 Called by HDD to stop operation in TL, before close. TL will suspend all
706 frame transfer operation and will wait for the close request to clean up
707 its resources.
708
709 DEPENDENCIES
710
711 PARAMETERS
712
713 IN
714 pvosGCtx: pointer to the global vos context; a handle to TL's
715 control block can be extracted from its context
716
717 RETURN VALUE
718 The result code associated with performing the operation
719
720 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
721 fault
722 VOS_STATUS_SUCCESS: Everything is good :)
723
724 SIDE EFFECTS
725
726============================================================================*/
727VOS_STATUS
728WLANTL_Stop
729(
730 v_PVOID_t pvosGCtx
731)
732{
733 WLANTL_CbType* pTLCb = NULL;
734 v_U8_t ucIndex;
735 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
736
737 /*------------------------------------------------------------------------
738 Sanity check
739 Extract TL control block
740 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530741 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 pTLCb = VOS_GET_TL_CB(pvosGCtx);
743 if ( NULL == pTLCb )
744 {
745 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
746 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
747 return VOS_STATUS_E_FAULT;
748 }
749
750 /*------------------------------------------------------------------------
751 Stop TL and empty Station list
752 ------------------------------------------------------------------------*/
753 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
754 "WLAN TL:WLANTL_Stop"));
755
756 /* Disable transmission */
757 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
758
759 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
760 {
761 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
762 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
763 }
764
765 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
766 {
767 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
768 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
769 }
770
771#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
772 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
773 {
774 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
775 "Handoff Support module stop fail"));
776 }
777#endif
778
779 /*-------------------------------------------------------------------------
780 Clean client stations
781 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530782 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530784 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
785 {
786 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
787 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 }
789
790
791 return VOS_STATUS_SUCCESS;
792}/* WLANTL_Stop */
793
794/*==========================================================================
795
796 FUNCTION WLANTL_Close
797
798 DESCRIPTION
799 Called by HDD during general driver close procedure. TL will clean up
800 all the internal resources.
801
802 DEPENDENCIES
803
804 PARAMETERS
805
806 IN
807 pvosGCtx: pointer to the global vos context; a handle to TL's
808 control block can be extracted from its context
809
810 RETURN VALUE
811 The result code associated with performing the operation
812
813 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
814 fault
815 VOS_STATUS_SUCCESS: Everything is good :)
816
817 SIDE EFFECTS
818
819============================================================================*/
820VOS_STATUS
821WLANTL_Close
822(
823 v_PVOID_t pvosGCtx
824)
825{
826 WLANTL_CbType* pTLCb = NULL;
827 tHalHandle smeContext;
828 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
829
830 /*------------------------------------------------------------------------
831 Sanity check
832 Extract TL control block
833 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530834 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 pTLCb = VOS_GET_TL_CB(pvosGCtx);
836 if ( NULL == pTLCb )
837 {
838 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
839 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
840 return VOS_STATUS_E_FAULT;
841 }
842 /*------------------------------------------------------------------------
843 Deregister from PMC
844 ------------------------------------------------------------------------*/
845 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
846 if ( NULL == smeContext )
847 {
848 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700849 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 // continue so that we can cleanup as much as possible
851 }
852 else
853 {
854 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
855 }
856
857#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
858 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
859 {
860 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
861 "Handoff Support module DeInit fail"));
862 }
863#endif
864
865 /*------------------------------------------------------------------------
866 Cleanup TL control block.
867 ------------------------------------------------------------------------*/
868 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
869 "WLAN TL: WLANTL_Close"));
870 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
871
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530872 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
873
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 vos_mem_free(pTLCb->reorderBufferPool);
875
876 /*------------------------------------------------------------------------
877 Free TL context from VOSS global
878 ------------------------------------------------------------------------*/
879 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
880 return VOS_STATUS_SUCCESS;
881}/* WLANTL_Close */
882
883/*----------------------------------------------------------------------------
884 INTERACTION WITH HDD
885 ---------------------------------------------------------------------------*/
886/*==========================================================================
887
888 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
889
890 DESCRIPTION
891 Function to disable/enable frame translation for all association stations.
892
893 DEPENDENCIES
894
895 PARAMETERS
896 IN
897 pvosGCtx: VOS context
898 EnableFrameXlation TRUE means enable SW translation for all stations.
899 .
900
901 RETURN VALUE
902
903 void.
904
905============================================================================*/
906void
907WLANTL_ConfigureSwFrameTXXlationForAll
908(
909 v_PVOID_t pvosGCtx,
910 v_BOOL_t enableFrameXlation
911)
912{
913 v_U8_t ucIndex;
914 /*------------------------------------------------------------------------
915 Extract TL control block
916 ------------------------------------------------------------------------*/
917 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530918 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 if ( NULL == pTLCb )
920 {
921 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
922 "WLAN TL:Invalid TL pointer from pvosGCtx on "
923 "WLANTL_ConfigureSwFrameTXXlationForAll"));
924 return;
925 }
926
927 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
928 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
929 enableFrameXlation));
930
931 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
932 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530933 pClientSTA = pTLCb->atlSTAClients[ucIndex];
934 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 {
936#ifdef WLAN_SOFTAP_VSTA_FEATURE
937 // if this station was not allocated resources to perform HW-based
938 // TX frame translation then force SW-based TX frame translation
939 // otherwise use the frame translation supplied by the client
940 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
941 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530942 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 }
944 else
945#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530946 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 }
948 }
949}
950
951/*===========================================================================
952
953 FUNCTION WLANTL_StartForwarding
954
955 DESCRIPTION
956
957 This function is used to ask serialization through TX thread of the
958 cached frame forwarding (if statation has been registered in the mean while)
959 or flushing (if station has not been registered by the time)
960
961 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
962 and doesn't need to call this function explicitly. TL will handle this inside
963 WLANTL_RegisterSTAClient().
964
965 In case of flushing, upper layer is required to call this function explicitly
966
967 DEPENDENCIES
968
969 TL must have been initialized before this gets called.
970
971
972 PARAMETERS
973
974 ucSTAId: station id
975
976 RETURN VALUE
977
978 The result code associated with performing the operation
979 Please check return values of vos_tx_mq_serialize.
980
981 SIDE EFFECTS
982 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
983 either WLANTL_RegisterSTAClient() or this function must be called
984 within reasonable time. Otherwise, TL will keep cached vos buffer until
985 one of this function is called, and may end up with system buffer exhasution.
986
987 It's an upper layer's responsibility to call this function in case of
988 flushing
989
990============================================================================*/
991
992VOS_STATUS
993WLANTL_StartForwarding
994(
995 v_U8_t ucSTAId,
996 v_U8_t ucUcastSig,
997 v_U8_t ucBcastSig
998)
999{
1000 vos_msg_t sMessage;
1001 v_U32_t uData;
1002 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
1003
1004 /* Signal the OS to serialize our event */
1005 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1006 "Serializing TL Start Forwarding Cached for control STA %d",
1007 ucSTAId );
1008
1009 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
1010
1011 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -08001012 sMessage.bodyval = uData;
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 sMessage.type = WLANTL_TX_FWD_CACHED;
1014
1015 return vos_tx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
1016
1017} /* WLANTL_StartForwarding() */
1018
1019/*===========================================================================
1020
1021 FUNCTION WLANTL_AssocFailed
1022
1023 DESCRIPTION
1024
1025 This function is used by PE to notify TL that cache needs to flushed'
1026 when association is not successfully completed
1027
1028 Internally, TL post a message to TX_Thread to serialize the request to
1029 keep lock-free mechanism.
1030
1031
1032 DEPENDENCIES
1033
1034 TL must have been initialized before this gets called.
1035
1036
1037 PARAMETERS
1038
1039 ucSTAId: station id
1040
1041 RETURN VALUE
1042
1043 none
1044
1045 SIDE EFFECTS
1046 There may be race condition that PE call this API and send another association
1047 request immediately with same staId before TX_thread can process the message.
1048
1049 To avoid this, we might need PE to wait for TX_thread process the message,
1050 but this is not currently implemented.
1051
1052============================================================================*/
1053void WLANTL_AssocFailed(v_U8_t staId)
1054{
1055 // flushing frames and forwarding frames uses the same message
1056 // the only difference is what happens when the message is processed
1057 // if the STA exist, the frames will be forwarded
1058 // and if it doesn't exist, the frames will be flushed
1059 // in this case we know it won't exist so the DPU index signature values don't matter
1060 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1061 {
1062 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001063 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 }
1065}
1066
1067 /*===========================================================================
1068
1069 FUNCTION WLANTL_Finish_ULA
1070
1071 DESCRIPTION
1072 This function is used by HDD to notify TL to finish Upper layer authentication
1073 incase the last EAPOL packet is pending in the TL queue.
1074 To avoid the race condition between sme set key and the last EAPOL packet
1075 the HDD module calls this function just before calling the sme_RoamSetKey.
1076
1077 DEPENDENCIES
1078
1079 TL must have been initialized before this gets called.
1080
1081 PARAMETERS
1082
1083 callbackRoutine: HDD Callback function.
1084 callbackContext : HDD userdata context.
1085
1086 RETURN VALUE
1087
1088 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1089
1090 SIDE EFFECTS
1091
1092============================================================================*/
1093
1094VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001095 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001096{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001097 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001098}
1099
1100
1101/*===========================================================================
1102
1103 FUNCTION WLANTL_RegisterSTAClient
1104
1105 DESCRIPTION
1106
1107 This function is used by HDD to register as a client for data services
1108 with TL. HDD will call this API for each new station that it adds,
1109 thus having the flexibility of registering different callback for each
1110 STA it services.
1111
1112 DEPENDENCIES
1113
1114 TL must have been initialized before this gets called.
1115
1116 Restriction:
1117 Main thread will have higher priority that Tx and Rx threads thus
1118 guaranteeing that a station will be added before any data can be
1119 received for it. (This enables TL to be lock free)
1120
1121 PARAMETERS
1122
1123 pvosGCtx: pointer to the global vos context; a handle to TL's
1124 control block can be extracted from its context
1125 pfnStARx: function pointer to the receive packet handler from HDD
1126 pfnSTATxComp: function pointer to the transmit complete confirmation
1127 handler from HDD
1128 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1129 wSTADescType: STA Descriptor, contains information related to the
1130 new added STA
1131
1132 RETURN VALUE
1133
1134 The result code associated with performing the operation
1135
1136 VOS_STATUS_E_INVAL: Input parameters are invalid
1137 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1138 TL cb is NULL ; access would cause a page fault
1139 VOS_STATUS_E_EXISTS: Station was already registered
1140 VOS_STATUS_SUCCESS: Everything is good :)
1141
1142 SIDE EFFECTS
1143
1144============================================================================*/
1145VOS_STATUS
1146WLANTL_RegisterSTAClient
1147(
1148 v_PVOID_t pvosGCtx,
1149 WLANTL_STARxCBType pfnSTARx,
1150 WLANTL_TxCompCBType pfnSTATxComp,
1151 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1152 WLAN_STADescType* pwSTADescType,
1153 v_S7_t rssi
1154)
1155{
1156 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301157 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1160
1161 /*------------------------------------------------------------------------
1162 Sanity check
1163 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301164 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1166 ( NULL == pfnSTAFetchPkt ))
1167 {
1168 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1169 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1170 return VOS_STATUS_E_INVAL;
1171 }
1172
1173 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1174 {
1175 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1176 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1177 return VOS_STATUS_E_FAULT;
1178 }
1179
1180 /*------------------------------------------------------------------------
1181 Extract TL control block
1182 ------------------------------------------------------------------------*/
1183 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1184 if ( NULL == pTLCb )
1185 {
1186 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1187 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1188 return VOS_STATUS_E_FAULT;
1189 }
1190
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301191 //Code for checking and allocating memory for new STA
1192 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1193 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1194 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1195 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1196 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1197 return VOS_STATUS_E_FAILURE;
1198 }
1199 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1200 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1201 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1202 }
1203
1204 //Assigning the pointer to local variable for easy access in future
1205 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1206 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301208 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1210 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1211 return VOS_STATUS_E_EXISTS;
1212 }
1213
1214 /*------------------------------------------------------------------------
1215 Register station with TL
1216 ------------------------------------------------------------------------*/
1217 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1218 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1219
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301220 pClientSTA->pfnSTARx = pfnSTARx;
1221 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001222
1223 /* Only register if different from NULL - TL default Tx Comp Cb will
1224 release the vos packet */
1225 if ( NULL != pfnSTATxComp )
1226 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301227 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 }
1229
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301230 pClientSTA->tlState = WLANTL_STA_INIT;
1231 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1232 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301233 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001234
1235 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1236 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1237 pwSTADescType->ucSTAId,
1238 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1239
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301240 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301242 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001243
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301244 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001245
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301246 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
1248#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301249 pClientSTA->wSTADesc.ucIsCcxSta = pwSTADescType->ucIsCcxSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001250
1251 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1252 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d CcxSta %d",
1253 pwSTADescType->ucSTAId,
1254 pwSTADescType->ucQosEnabled,
1255 pwSTADescType->ucAddRmvLLC,
1256 pwSTADescType->ucProtectedFrame,
1257 pwSTADescType->ucIsCcxSta));
1258#else
1259
1260 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1261 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1262 pwSTADescType->ucSTAId,
1263 pwSTADescType->ucQosEnabled,
1264 pwSTADescType->ucAddRmvLLC,
1265 pwSTADescType->ucProtectedFrame));
1266
1267#endif //FEATURE_WLAN_CCX
1268#ifdef WLAN_SOFTAP_VSTA_FEATURE
1269 // if this station was not allocated resources to perform HW-based
1270 // TX frame translation then force SW-based TX frame translation
1271 // otherwise use the frame translation supplied by the client
1272
1273 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1274 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1275 {
1276 pwSTADescType->ucSwFrameTXXlation = 1;
1277 }
1278#endif
1279
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301280 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1281 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001282
1283#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301284 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001285#endif /* FEATURE_WLAN_WAPI */
1286
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301287 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001288
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301289 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301291 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301294 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1295 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001296/*Clear replay counters of the STA on all TIDs*/
1297 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1298 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301299 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001301
1302 /*--------------------------------------------------------------------
1303 Set the AC for the registered station to the highest priority AC
1304 Even if this AC is not supported by the station, correction will be
1305 made in the main TL loop after the supported mask is properly
1306 updated in the pending packets call
1307 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301308 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1309 pClientSTA->ucCurrentWeight = 0;
1310 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1311 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001312
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301313 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001314
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301315 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
1317 /*--------------------------------------------------------------------
1318 Reordering info and AMSDU de-aggregation
1319 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301320 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1321 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 WLAN_MAX_TID);
1323
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301324 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 WLANTL_MPDU_HEADER_LEN);
1326
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301327 pClientSTA->ucMPDUHeaderLen = 0;
1328 pClientSTA->vosAMSDUChain = NULL;
1329 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001330
1331
1332 /*--------------------------------------------------------------------
1333 Stats info
1334 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301335 vos_mem_zero( pClientSTA->auRxCount,
1336 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 WLAN_MAX_TID);
1338
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301339 vos_mem_zero( pClientSTA->auTxCount,
1340 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 WLAN_MAX_TID);
1342 /* Initial RSSI is always reported as zero because TL doesnt have enough
1343 data to calculate RSSI. So to avoid reporting zero, we are initializing
1344 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301345 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001346#ifdef FEATURE_WLAN_TDLS
1347 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1348 {
1349 /* If client is TDLS, use TDLS specific alpha */
1350 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1351 }
1352 else
1353 {
1354 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1355 }
1356#else
1357 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1358#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
1360 /*Tx not suspended and station fully registered*/
1361 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301362 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001363
1364 /* Used until multiple station support will be added*/
1365 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1366
1367 /* Save the BAP station ID for future usage */
1368 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1369 {
1370 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1371 }
1372
1373 /*------------------------------------------------------------------------
1374 Statistics info
1375 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301376 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1378
1379
1380 /*------------------------------------------------------------------------
1381 Start with the state suggested by client caller
1382 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301383 pClientSTA->tlState = pwSTADescType->ucInitState;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301384 pClientSTA->ucRxBlocked = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 /*-----------------------------------------------------------------------
1386 After all the init is complete we can mark the existance flag
1387 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301388 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301391 pClientSTA->ucLwmModeEnabled = FALSE;
1392 pClientSTA->ucLwmEventReported = FALSE;
1393 pClientSTA->bmuMemConsumed = 0;
1394 pClientSTA->uIngress_length = 0;
1395 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301397 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001398
1399 //@@@ HDDSOFTAP does not queue unregistered packet for now
1400 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1401 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 /*------------------------------------------------------------------------
1403 Forward received frames while STA was not yet registered
1404 - ----------------------------------------------------------------------*/
1405 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1406 pwSTADescType->ucUcastSig,
1407 pwSTADescType->ucBcastSig)))
1408 {
1409 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001410 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001412#ifdef FEATURE_WLAN_TDLS
1413 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1414 pTLCb->ucTdlsPeerCount++;
1415#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 return VOS_STATUS_SUCCESS;
1418}/* WLANTL_RegisterSTAClient */
1419
1420/*===========================================================================
1421
1422 FUNCTION WLANTL_ClearSTAClient
1423
1424 DESCRIPTION
1425
1426 HDD will call this API when it no longer needs data services for the
1427 particular station.
1428
1429 DEPENDENCIES
1430
1431 A station must have been registered before the clear registration is
1432 called.
1433
1434 PARAMETERS
1435
1436 pvosGCtx: pointer to the global vos context; a handle to TL's
1437 control block can be extracted from its context
1438 ucSTAId: identifier for the STA to be cleared
1439
1440 RETURN VALUE
1441
1442 The result code associated with performing the operation
1443
1444 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1445 TL cb is NULL ; access would cause a page fault
1446 VOS_STATUS_E_EXISTS: Station was not registered
1447 VOS_STATUS_SUCCESS: Everything is good :)
1448
1449 SIDE EFFECTS
1450
1451============================================================================*/
1452VOS_STATUS
1453WLANTL_ClearSTAClient
1454(
1455 v_PVOID_t pvosGCtx,
1456 v_U8_t ucSTAId
1457)
1458{
1459 WLANTL_CbType* pTLCb = NULL;
1460 v_U8_t ucIndex;
1461 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1462
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301463 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 /*------------------------------------------------------------------------
1465 Sanity check
1466 ------------------------------------------------------------------------*/
1467 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1468 {
1469 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1470 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1471 return VOS_STATUS_E_FAULT;
1472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 /*------------------------------------------------------------------------
1474 Extract TL control block
1475 ------------------------------------------------------------------------*/
1476 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1477 if ( NULL == pTLCb )
1478 {
1479 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1480 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1481 return VOS_STATUS_E_FAULT;
1482 }
1483
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301484 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1485 {
1486 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1487 "WLAN TL:Client Memory was not allocated on %s", __func__));
1488 return VOS_STATUS_E_FAILURE;
1489 }
1490
1491 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 {
1493 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1494 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
1495 return VOS_STATUS_E_EXISTS;
1496 }
1497
1498 /* Delete BA sessions on all TID's */
1499 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
1500 {
1501 WLANTL_BaSessionDel (pvosGCtx, ucSTAId, ucIndex);
1502 }
1503
Sunil Ravid5406f22013-01-22 00:18:31 -08001504#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301505 /* decrement ucTdlsPeerCount only if it is non-zero */
1506 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001507 && pTLCb->ucTdlsPeerCount)
1508 pTLCb->ucTdlsPeerCount--;
1509#endif
1510
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 /*------------------------------------------------------------------------
1512 Clear station
1513 ------------------------------------------------------------------------*/
1514 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1515 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301516 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001517
1518 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1519 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1520 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1521 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1522
1523 return VOS_STATUS_SUCCESS;
1524}/* WLANTL_ClearSTAClient */
1525
1526/*===========================================================================
1527
1528 FUNCTION WLANTL_ChangeSTAState
1529
1530 DESCRIPTION
1531
1532 HDD will make this notification whenever a change occurs in the
1533 connectivity state of a particular STA.
1534
1535 DEPENDENCIES
1536
1537 A station must have been registered before the change state can be
1538 called.
1539
1540 RESTRICTION: A station is being notified as authenticated before the
1541 keys are installed in HW. This way if a frame is received
1542 before the keys are installed DPU will drop that frame.
1543
1544 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1545 the following:
1546 - a station will be in assoc state in TL before TL receives any data
1547 for it
1548
1549 PARAMETERS
1550
1551 pvosGCtx: pointer to the global vos context; a handle to TL's
1552 control block can be extracted from its context
1553 ucSTAId: identifier for the STA that is pending transmission
1554 tlSTAState: the new state of the connection to the given station
1555
1556
1557 RETURN VALUE
1558
1559 The result code associated with performing the operation
1560
1561 VOS_STATUS_E_INVAL: Input parameters are invalid
1562 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1563 TL cb is NULL ; access would cause a page fault
1564 VOS_STATUS_E_EXISTS: Station was not registered
1565 VOS_STATUS_SUCCESS: Everything is good :)
1566
1567 SIDE EFFECTS
1568
1569============================================================================*/
1570VOS_STATUS
1571WLANTL_ChangeSTAState
1572(
1573 v_PVOID_t pvosGCtx,
1574 v_U8_t ucSTAId,
1575 WLANTL_STAStateType tlSTAState
1576)
1577{
1578 WLANTL_CbType* pTLCb = NULL;
1579 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1580
1581 /*------------------------------------------------------------------------
1582 Sanity check
1583 ------------------------------------------------------------------------*/
1584 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1585 {
1586 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1587 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1588 return VOS_STATUS_E_INVAL;
1589 }
1590
1591 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1592 {
1593 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1594 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1595 return VOS_STATUS_E_FAULT;
1596 }
1597
1598 /*------------------------------------------------------------------------
1599 Extract TL control block and check existance
1600 ------------------------------------------------------------------------*/
1601 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1602 if ( NULL == pTLCb )
1603 {
1604 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1605 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1606 return VOS_STATUS_E_FAULT;
1607 }
1608
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301609 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1610 {
1611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1612 "WLAN TL:Client Memory was not allocated on %s", __func__));
1613 return VOS_STATUS_E_FAILURE;
1614 }
1615
1616 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 {
1618 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1619 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1620 return VOS_STATUS_E_EXISTS;
1621 }
1622
1623 /*------------------------------------------------------------------------
1624 Change STA state
1625 No need to lock this operation, see restrictions above
1626 ------------------------------------------------------------------------*/
1627 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1628 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301629 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001630
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301631 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001632
1633 return VOS_STATUS_SUCCESS;
1634}/* WLANTL_ChangeSTAState */
1635
1636/*===========================================================================
1637
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301638 FUNCTION WLANTL_STAPtkInstalled
1639
1640 DESCRIPTION
1641
1642 HDD will make this notification whenever PTK is installed for the STA
1643
1644 DEPENDENCIES
1645
1646 A station must have been registered before the change state can be
1647 called.
1648
1649 PARAMETERS
1650
1651 pvosGCtx: pointer to the global vos context; a handle to TL's
1652 control block can be extracted from its context
1653 ucSTAId: identifier for the STA for which Pairwise key is
1654 installed
1655
1656 RETURN VALUE
1657
1658 The result code associated with performing the operation
1659
1660 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1661 TL cb is NULL ; access would cause a page fault
1662 VOS_STATUS_E_EXISTS: Station was not registered
1663 VOS_STATUS_SUCCESS: Everything is good :)
1664
1665 SIDE EFFECTS
1666
1667============================================================================*/
1668VOS_STATUS
1669WLANTL_STAPtkInstalled
1670(
1671 v_PVOID_t pvosGCtx,
1672 v_U8_t ucSTAId
1673)
1674{
1675 WLANTL_CbType* pTLCb = NULL;
1676 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1677
1678 /*------------------------------------------------------------------------
1679 Sanity check
1680 ------------------------------------------------------------------------*/
1681
1682 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1683 {
1684 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1685 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1686 return VOS_STATUS_E_FAULT;
1687 }
1688
1689 /*------------------------------------------------------------------------
1690 Extract TL control block and check existance
1691 ------------------------------------------------------------------------*/
1692 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1693 if ( NULL == pTLCb )
1694 {
1695 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1696 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1697 return VOS_STATUS_E_FAULT;
1698 }
1699
1700 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1701 {
1702 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1703 FL("WLAN TL:Client Memory was not allocated")));
1704 return VOS_STATUS_E_FAILURE;
1705 }
1706
1707 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1708 {
1709 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1710 FL("WLAN TL:Station was not previously registered")));
1711 return VOS_STATUS_E_EXISTS;
1712 }
1713
1714 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1715
1716 return VOS_STATUS_SUCCESS;
1717}/* WLANTL_STAPtkInstalled */
1718
1719/*===========================================================================
1720
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001721 FUNCTION WLANTL_GetSTAState
1722
1723 DESCRIPTION
1724
1725 Returns connectivity state of a particular STA.
1726
1727 DEPENDENCIES
1728
1729 A station must have been registered before its state can be retrieved.
1730
1731
1732 PARAMETERS
1733
1734 IN
1735 pvosGCtx: pointer to the global vos context; a handle to TL's
1736 control block can be extracted from its context
1737 ucSTAId: identifier of the station
1738
1739 OUT
1740 ptlSTAState: the current state of the connection to the given station
1741
1742
1743 RETURN VALUE
1744
1745 The result code associated with performing the operation
1746
1747 VOS_STATUS_E_INVAL: Input parameters are invalid
1748 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1749 TL cb is NULL ; access would cause a page fault
1750 VOS_STATUS_E_EXISTS: Station was not registered
1751 VOS_STATUS_SUCCESS: Everything is good :)
1752
1753 SIDE EFFECTS
1754
1755============================================================================*/
1756VOS_STATUS
1757WLANTL_GetSTAState
1758(
1759 v_PVOID_t pvosGCtx,
1760 v_U8_t ucSTAId,
1761 WLANTL_STAStateType *ptlSTAState
1762)
1763{
1764 WLANTL_CbType* pTLCb = NULL;
1765 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1766
1767 /*------------------------------------------------------------------------
1768 Sanity check
1769 ------------------------------------------------------------------------*/
1770 if ( NULL == ptlSTAState )
1771 {
1772 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1773 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1774 return VOS_STATUS_E_INVAL;
1775 }
1776
1777 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1778 {
1779 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1780 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1781 return VOS_STATUS_E_FAULT;
1782 }
1783
1784 /*------------------------------------------------------------------------
1785 Extract TL control block and check existance
1786 ------------------------------------------------------------------------*/
1787 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1788 if ( NULL == pTLCb )
1789 {
1790 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1791 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1792 return VOS_STATUS_E_FAULT;
1793 }
1794
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301795 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1796 {
1797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1798 "WLAN TL:Client Memory was not allocated on %s", __func__));
1799 return VOS_STATUS_E_FAILURE;
1800 }
1801
1802 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001803 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001804 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001805 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1806 return VOS_STATUS_E_EXISTS;
1807 }
1808
1809 /*------------------------------------------------------------------------
1810 Get STA state
1811 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301812 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001813
1814 return VOS_STATUS_SUCCESS;
1815}/* WLANTL_GetSTAState */
1816
Shailender Karmuchia734f332013-04-19 14:02:48 -07001817/*==========================================================================
1818 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1819
1820 DESCRIPTION
1821 HDD will call this API to update the BSSID for this Station.
1822
1823 DEPENDENCIES
1824 The HDD Should registered the staID with TL before calling this function.
1825
1826 PARAMETERS
1827
1828 IN
1829 pvosGCtx: Pointer to the global vos context; a handle to TL's
1830 or WDA's control block can be extracted from its context
1831 IN
1832 ucSTAId The Station ID for Bssid to be updated
1833 IN
1834 pBssid BSSID to be updated
1835
1836 RETURN VALUE
1837 The result code associated with performing the operation
1838
1839 VOS_STATUS_E_INVAL: Input parameters are invalid
1840 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1841 TL cb is NULL ; access would cause a page fault
1842 VOS_STATUS_E_EXISTS: Station was not registered
1843 VOS_STATUS_SUCCESS: Everything is good :)
1844
1845 SIDE EFFECTS
1846============================================================================*/
1847
1848
1849VOS_STATUS
1850WLANTL_UpdateSTABssIdforIBSS
1851(
1852 v_PVOID_t pvosGCtx,
1853 v_U8_t ucSTAId,
1854 v_U8_t *pBssid
1855)
1856{
1857 WLANTL_CbType* pTLCb = NULL;
1858 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1859
1860 /*------------------------------------------------------------------------
1861 Sanity check
1862 ------------------------------------------------------------------------*/
1863 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1864 {
1865 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1866 "WLAN TL:Invalid station id requested %s", __func__));
1867 return VOS_STATUS_E_FAULT;
1868 }
1869
1870 /*------------------------------------------------------------------------
1871 Extract TL control block and check existance
1872 ------------------------------------------------------------------------*/
1873 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1874 if ( NULL == pTLCb )
1875 {
1876 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1877 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1878 return VOS_STATUS_E_FAULT;
1879 }
1880
1881 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1882 {
1883 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1884 "WLAN TL:Client Memory was not allocated on %s", __func__));
1885 return VOS_STATUS_E_FAILURE;
1886 }
1887
1888 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1889 {
1890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1891 "WLAN TL:Station was not previously registered %s", __func__));
1892 return VOS_STATUS_E_EXISTS;
1893 }
1894
1895 /*------------------------------------------------------------------------
1896 Update the IBSS BSSID
1897 ------------------------------------------------------------------------*/
1898 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1899 pBssid, sizeof(v_MACADDR_t));
1900
1901 return VOS_STATUS_SUCCESS;
1902}
1903
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001904/*===========================================================================
1905
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 FUNCTION WLANTL_STAPktPending
1907
1908 DESCRIPTION
1909
1910 HDD will call this API when a packet is pending transmission in its
1911 queues.
1912
1913 DEPENDENCIES
1914
1915 A station must have been registered before the packet pending
1916 notification can be sent.
1917
1918 RESTRICTION: TL will not count packets for pending notification.
1919 HDD is expected to send the notification only when
1920 non-empty event gets triggered. Worst case scenario
1921 is that TL might end up making a call when Hdds
1922 queues are actually empty.
1923
1924 PARAMETERS
1925
1926 pvosGCtx: pointer to the global vos context; a handle to TL's
1927 control block can be extracted from its context
1928 ucSTAId: identifier for the STA that is pending transmission
1929
1930 RETURN VALUE
1931
1932 The result code associated with performing the operation
1933
1934 VOS_STATUS_E_INVAL: Input parameters are invalid
1935 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1936 to TL cb is NULL ; access would cause a page fault
1937 VOS_STATUS_E_EXISTS: Station was not registered
1938 VOS_STATUS_SUCCESS: Everything is good :)
1939
1940 SIDE EFFECTS
1941
1942============================================================================*/
1943VOS_STATUS
1944WLANTL_STAPktPending
1945(
1946 v_PVOID_t pvosGCtx,
1947 v_U8_t ucSTAId,
1948 WLANTL_ACEnumType ucAc
1949)
1950{
1951 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301952 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1955
1956 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1957 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
1958
1959 /*------------------------------------------------------------------------
1960 Sanity check
1961 ------------------------------------------------------------------------*/
1962 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1963 {
1964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1965 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
1966 return VOS_STATUS_E_FAULT;
1967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 /*------------------------------------------------------------------------
1969 Extract TL control block and check existance
1970 ------------------------------------------------------------------------*/
1971 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1972 if ( NULL == pTLCb )
1973 {
1974 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1975 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
1976 return VOS_STATUS_E_FAULT;
1977 }
1978
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301979 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
1980
1981 if ( NULL == pClientSTA )
1982 {
1983 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1984 "WLAN TL:Client Memory was not allocated on %s", __func__));
1985 return VOS_STATUS_E_FAILURE;
1986 }
1987
1988 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 {
1990 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1991 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
1992 return VOS_STATUS_E_EXISTS;
1993 }
1994
1995 /*---------------------------------------------------------------------
1996 Temporary fix to enable TL to fetch packets when multiple peers join
1997 an IBSS. To fix CR177301. Needs to go away when the actual fix of
1998 going through all STA's in round robin fashion gets merged in from
1999 BT AMP branch.
2000 --------------------------------------------------------------------*/
2001 pTLCb->ucRegisteredStaId = ucSTAId;
2002
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302003 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002004 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2005 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2006 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2007 to make sure TL is indeed waiting for EAPOL.
2008 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302009 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002010
2011 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002012 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302013 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002014 }
2015
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 /*-----------------------------------------------------------------------
2017 Enable this AC in the AC mask in order for TL to start servicing it
2018 Set packet pending flag
2019 To avoid race condition, serialize the updation of AC and AC mask
2020 through WLANTL_TX_STAID_AC_IND message.
2021 -----------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08002022#ifdef FETURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302023 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08002024 !(vos_concurrent_sessions_running()) &&
2025 !pTLCb->ucTdlsPeerCount)
2026 {
2027#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302028 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002029 !(vos_concurrent_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 {
2031#endif
2032
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302033 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002034
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302035 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 /*------------------------------------------------------------------------
2038 Check if there are enough resources for transmission and tx is not
2039 suspended.
2040 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07002041 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2042 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 {
2044 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2045 "Issuing Xmit start request to BAL"));
2046 WDA_DS_StartXmit(pvosGCtx);
2047 }
2048 else
2049 {
2050 /*---------------------------------------------------------------------
2051 No error code is sent because TL will resume tx autonomously if
2052 resources become available or tx gets resumed
2053 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002054 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002056 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 else
2060 {
2061 vosMsg.reserved = 0;
2062 vosMsg.bodyval = 0;
2063 vosMsg.bodyval = (ucAc | (ucSTAId << WLANTL_STAID_OFFSET));
2064 vosMsg.type = WLANTL_TX_STAID_AC_IND;
2065 return vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg);
2066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 return VOS_STATUS_SUCCESS;
2068}/* WLANTL_STAPktPending */
2069
2070/*==========================================================================
2071
2072 FUNCTION WLANTL_SetSTAPriority
2073
2074 DESCRIPTION
2075
2076 TL exposes this API to allow upper layers a rough control over the
2077 priority of transmission for a given station when supporting multiple
2078 connections.
2079
2080 DEPENDENCIES
2081
2082 A station must have been registered before the change in priority can be
2083 called.
2084
2085 PARAMETERS
2086
2087 pvosGCtx: pointer to the global vos context; a handle to TL's
2088 control block can be extracted from its context
2089 ucSTAId: identifier for the STA that has to change priority
2090
2091 RETURN VALUE
2092
2093 The result code associated with performing the operation
2094
2095 VOS_STATUS_E_INVAL: Input parameters are invalid
2096 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2097 to TL cb is NULL ; access would cause a page fault
2098 VOS_STATUS_E_EXISTS: Station was not registered
2099 VOS_STATUS_SUCCESS: Everything is good :)
2100
2101 SIDE EFFECTS
2102
2103============================================================================*/
2104VOS_STATUS
2105WLANTL_SetSTAPriority
2106(
2107 v_PVOID_t pvosGCtx,
2108 v_U8_t ucSTAId,
2109 WLANTL_STAPriorityType tlSTAPri
2110)
2111{
2112 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302113 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2115
2116 /*------------------------------------------------------------------------
2117 Sanity check
2118 ------------------------------------------------------------------------*/
2119 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2120 {
2121 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2122 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2123 return VOS_STATUS_E_FAULT;
2124 }
2125
2126 /*------------------------------------------------------------------------
2127 Extract TL control block
2128 ------------------------------------------------------------------------*/
2129 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2130 if ( NULL == pTLCb )
2131 {
2132 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2133 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2134 return VOS_STATUS_E_FAULT;
2135 }
2136
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302137 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2138
2139 if ( NULL == pClientSTA )
2140 {
2141 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2142 "WLAN TL:Client Memory was not allocated on %s", __func__));
2143 return VOS_STATUS_E_FAILURE;
2144 }
2145
2146 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 {
2148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2149 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2150 return VOS_STATUS_E_EXISTS;
2151 }
2152
2153 /*------------------------------------------------------------------------
2154 Re-analize if lock is needed when adding multiple stations
2155 ------------------------------------------------------------------------*/
2156 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2157 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302158 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2159 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161 return VOS_STATUS_SUCCESS;
2162}/* WLANTL_SetSTAPriority */
2163
2164
2165/*----------------------------------------------------------------------------
2166 INTERACTION WITH BAP
2167 ---------------------------------------------------------------------------*/
2168
2169/*==========================================================================
2170
2171 FUNCTION WLANTL_RegisterBAPClient
2172
2173 DESCRIPTION
2174 Called by SME to register itself as client for non-data BT-AMP packets.
2175
2176 DEPENDENCIES
2177 TL must be initialized before this function can be called.
2178
2179 PARAMETERS
2180
2181 IN
2182 pvosGCtx: pointer to the global vos context; a handle to TL's
2183 or SME's control block can be extracted from its context
2184 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2185 BT-AMP packets
2186 pfnFlushOpCompleteCb:
2187 pointer to the call back function, for the Flush operation
2188 completion.
2189
2190
2191 RETURN VALUE
2192
2193 The result code associated with performing the operation
2194
2195 VOS_STATUS_E_INVAL: Input parameters are invalid
2196 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2197 to TL cb is NULL ; access would cause a page fault
2198 VOS_STATUS_E_EXISTS: BAL client was already registered
2199 VOS_STATUS_SUCCESS: Everything is good :)
2200
2201 SIDE EFFECTS
2202
2203============================================================================*/
2204VOS_STATUS
2205WLANTL_RegisterBAPClient
2206(
2207 v_PVOID_t pvosGCtx,
2208 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2209 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2210)
2211{
2212 WLANTL_CbType* pTLCb = NULL;
2213 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2214
2215 /*------------------------------------------------------------------------
2216 Sanity check
2217 ------------------------------------------------------------------------*/
2218 if ( NULL == pfnTlBAPRxFrm )
2219 {
2220 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2221 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2222 return VOS_STATUS_E_INVAL;
2223 }
2224
2225 if ( NULL == pfnFlushOpCompleteCb )
2226 {
2227 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2228 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2229 return VOS_STATUS_E_INVAL;
2230 }
2231
2232 /*------------------------------------------------------------------------
2233 Extract TL control block
2234 ------------------------------------------------------------------------*/
2235 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2236 if ( NULL == pTLCb )
2237 {
2238 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2239 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2240 return VOS_STATUS_E_FAULT;
2241 }
2242
2243 /*------------------------------------------------------------------------
2244 Make sure this is the first registration attempt
2245 ------------------------------------------------------------------------*/
2246 if ( 0 != pTLCb->tlBAPClient.ucExists )
2247 {
2248 pTLCb->tlBAPClient.ucExists++;
2249 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2250 "WLAN TL:BAP client was already registered"));
2251 return VOS_STATUS_E_EXISTS;
2252 }
2253
2254 /*------------------------------------------------------------------------
2255 Register station with TL
2256 ------------------------------------------------------------------------*/
2257 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2258 "WLAN TL:Registering BAP Client" ));
2259
2260 pTLCb->tlBAPClient.ucExists++;
2261
2262 if ( NULL != pfnTlBAPRxFrm )
2263 {
2264 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2265 }
2266
2267 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2268
2269 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2270
2271 return VOS_STATUS_SUCCESS;
2272}/* WLANTL_RegisterBAPClient */
2273
2274
2275/*==========================================================================
2276
2277 FUNCTION WLANTL_TxBAPFrm
2278
2279 DESCRIPTION
2280 BAP calls this when it wants to send a frame to the module
2281
2282 DEPENDENCIES
2283 BAP must be registered with TL before this function can be called.
2284
2285 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2286 a tx complete from the previous packet, that means BAP
2287 sends one packet, wait for tx complete and then
2288 sends another one
2289
2290 If BAP sends another packet before TL manages to process the
2291 previously sent packet call will end in failure
2292
2293 PARAMETERS
2294
2295 IN
2296 pvosGCtx: pointer to the global vos context; a handle to TL's
2297 or BAP's control block can be extracted from its context
2298 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2299 transmitted
2300 pMetaInfo: meta information about the packet
2301 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2302 the result of the operation over the bus
2303
2304 RETURN VALUE
2305 The result code associated with performing the operation
2306
2307 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2308 page fault
2309 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2310 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2311 VOS_STATUS_SUCCESS: Everything is good :)
2312
2313 Other failure messages may be returned from the BD header handling
2314 routines, please check apropriate API for more info.
2315
2316 SIDE EFFECTS
2317
2318============================================================================*/
2319VOS_STATUS
2320WLANTL_TxBAPFrm
2321(
2322 v_PVOID_t pvosGCtx,
2323 vos_pkt_t* vosDataBuff,
2324 WLANTL_MetaInfoType* pMetaInfo,
2325 WLANTL_TxCompCBType pfnTlBAPTxComp
2326)
2327{
2328 WLANTL_CbType* pTLCb = NULL;
2329 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2330 v_MACADDR_t vDestMacAddr;
2331 v_U16_t usPktLen;
2332 v_U8_t ucStaId = 0;
2333 v_U8_t extraHeadSpace = 0;
2334 v_U8_t ucWDSEnabled = 0;
2335 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2336
2337 /*------------------------------------------------------------------------
2338 Sanity check
2339 Extract TL control block
2340 ------------------------------------------------------------------------*/
2341 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2342 if ( NULL == pTLCb )
2343 {
2344 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2345 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2346 return VOS_STATUS_E_FAULT;
2347 }
2348
2349 /*------------------------------------------------------------------------
2350 Ensure that BAP client was registered previously
2351 ------------------------------------------------------------------------*/
2352 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2353 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2354 {
2355 pTLCb->tlBAPClient.ucExists++;
2356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2357 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2358 return VOS_STATUS_E_EXISTS;
2359 }
2360
2361 /*------------------------------------------------------------------------
2362 Check if any BT-AMP Frm is pending
2363 ------------------------------------------------------------------------*/
2364 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2365 {
2366 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2367 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2368 return VOS_STATUS_E_BUSY;
2369 }
2370
2371 /*------------------------------------------------------------------------
2372 Save buffer and notify BAL; no lock is needed if the above restriction
2373 is met
2374 Save the tx complete fnct pointer as tl specific data in the vos buffer
2375 ------------------------------------------------------------------------*/
2376
2377 /*------------------------------------------------------------------------
2378 Translate 802.3 frame to 802.11
2379 ------------------------------------------------------------------------*/
2380 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302381 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2382 {
2383 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2384 "WLAN TL:Client Memory was not allocated on %s", __func__));
2385 return VOS_STATUS_E_FAILURE;
2386 }
2387 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2388 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002390 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2391 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002392 pMetaInfo, &ucWDSEnabled,
2393 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394
2395 if ( VOS_STATUS_SUCCESS != vosStatus )
2396 {
2397 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2398 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2399
2400 return vosStatus;
2401 }
2402
2403 pMetaInfo->ucDisableFrmXtl = 1;
2404 }
2405
2406 /*-------------------------------------------------------------------------
2407 Call HAL to fill BD header
2408 -------------------------------------------------------------------------*/
2409
2410 /* Adding Type, SubType which was missing for EAPOL from BAP */
2411 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2412 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2413
2414 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2415 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302416 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302418 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002420 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002421
2422 if ( VOS_STATUS_SUCCESS != vosStatus )
2423 {
2424 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2425 "WLAN TL:Failed while building TX header %d", vosStatus));
2426 return vosStatus;
2427 }
2428
2429 if ( NULL != pfnTlBAPTxComp )
2430 {
2431 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2432 (v_PVOID_t)pfnTlBAPTxComp);
2433 }
2434 else
2435 {
2436 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2437 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2438
2439 }
2440
2441 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2442 (v_U32_t)vosDataBuff);
2443
2444 /*------------------------------------------------------------------------
2445 Check if thre are enough resources for transmission and tx is not
2446 suspended.
2447 ------------------------------------------------------------------------*/
2448 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2449 ( 0 == pTLCb->ucTxSuspended ))
2450 {
2451 WDA_DS_StartXmit(pvosGCtx);
2452 }
2453 else
2454 {
2455 /*---------------------------------------------------------------------
2456 No error code is sent because TL will resume tx autonomously if
2457 resources become available or tx gets resumed
2458 ---------------------------------------------------------------------*/
2459 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2460 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2461 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2462 }
2463
2464 return VOS_STATUS_SUCCESS;
2465}/* WLANTL_TxBAPFrm */
2466
2467
2468/*----------------------------------------------------------------------------
2469 INTERACTION WITH SME
2470 ---------------------------------------------------------------------------*/
2471
2472/*==========================================================================
2473
2474 FUNCTION WLANTL_GetRssi
2475
2476 DESCRIPTION
2477 TL will extract the RSSI information from every data packet from the
2478 ongoing traffic and will store it. It will provide the result to SME
2479 upon request.
2480
2481 DEPENDENCIES
2482
2483 WARNING: the read and write of this value will not be protected
2484 by locks, therefore the information obtained after a read
2485 might not always be consistent.
2486
2487 PARAMETERS
2488
2489 IN
2490 pvosGCtx: pointer to the global vos context; a handle to TL's
2491 or SME's control block can be extracted from its context
2492 ucSTAId: station identifier for the requested value
2493
2494 OUT
2495 puRssi: the average value of the RSSI
2496
2497
2498 RETURN VALUE
2499 The result code associated with performing the operation
2500
2501 VOS_STATUS_E_INVAL: Input parameters are invalid
2502 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2503 to TL cb is NULL ; access would cause a page fault
2504 VOS_STATUS_E_EXISTS: STA was not yet registered
2505 VOS_STATUS_SUCCESS: Everything is good :)
2506
2507 SIDE EFFECTS
2508
2509============================================================================*/
2510VOS_STATUS
2511WLANTL_GetRssi
2512(
2513 v_PVOID_t pvosGCtx,
2514 v_U8_t ucSTAId,
2515 v_S7_t* pRssi
2516)
2517{
2518 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302519 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2521
2522 /*------------------------------------------------------------------------
2523 Sanity check
2524 ------------------------------------------------------------------------*/
2525 if ( NULL == pRssi )
2526 {
2527 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2528 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2529 return VOS_STATUS_E_INVAL;
2530 }
2531
2532 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2533 {
2534 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2535 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2536 return VOS_STATUS_E_FAULT;
2537 }
2538
2539 /*------------------------------------------------------------------------
2540 Extract TL control block and check existance
2541 ------------------------------------------------------------------------*/
2542 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2543 if ( NULL == pTLCb )
2544 {
2545 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2546 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2547 return VOS_STATUS_E_FAULT;
2548 }
2549
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302550 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2551
2552 if ( NULL == pClientSTA )
2553 {
2554 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2555 "WLAN TL:Client Memory was not allocated on %s", __func__));
2556 return VOS_STATUS_E_FAILURE;
2557 }
2558
2559 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 {
2561 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2562 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2563 return VOS_STATUS_E_EXISTS;
2564 }
2565
2566 /*------------------------------------------------------------------------
2567 Copy will not be locked; please read restriction
2568 ------------------------------------------------------------------------*/
2569 if(pTLCb->isBMPS)
2570 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302571 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2573 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2574 might not have happend by that time. Hence reading the most recent Rssi
2575 calcluated by TL*/
2576 if(0 == *pRssi)
2577 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302578 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 }
2581 else
2582 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302583 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 }
2585
2586 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002587 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2588 ucSTAId, *pRssi,
2589 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002590
2591 return VOS_STATUS_SUCCESS;
2592}/* WLANTL_GetRssi */
2593
2594/*==========================================================================
2595
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302596 FUNCTION WLANTL_GetSnr
2597
2598 DESCRIPTION
2599 TL will extract the SNR information from every data packet from the
2600 ongoing traffic and will store it. It will provide the result to SME
2601 upon request.
2602
2603 DEPENDENCIES
2604
2605 WARNING: the read and write of this value will not be protected
2606 by locks, therefore the information obtained after a read
2607 might not always be consistent.
2608
2609 PARAMETERS
2610
2611 IN
2612 pvosGCtx: pointer to the global vos context; a handle to TL's
2613 or SME's control block can be extracted from its context
2614 ucSTAId: station identifier for the requested value
2615
2616 OUT
2617 pSnr: the average value of the SNR
2618
2619
2620 RETURN VALUE
2621 The result code associated with performing the operation
2622
2623 VOS_STATUS_E_INVAL: Input parameters are invalid
2624 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2625 to TL cb is NULL ; access would cause a page fault
2626 VOS_STATUS_E_EXISTS: STA was not yet registered
2627 VOS_STATUS_SUCCESS: Everything is good :)
2628
2629 SIDE EFFECTS
2630
2631============================================================================*/
2632VOS_STATUS
2633WLANTL_GetSnr
2634(
2635 tANI_U8 ucSTAId,
2636 tANI_S8* pSnr
2637)
2638{
2639 WLANTL_CbType* pTLCb = NULL;
2640 WLANTL_STAClientType* pClientSTA = NULL;
2641 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2642
2643 /*------------------------------------------------------------------------
2644 Sanity check
2645 ------------------------------------------------------------------------*/
2646 if (NULL == pSnr)
2647 {
2648 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2649 "WLAN TL:Invalid parameter sent on %s", __func__));
2650 return VOS_STATUS_E_INVAL;
2651 }
2652
2653 if (WLANTL_STA_ID_INVALID(ucSTAId))
2654 {
2655 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2656 "WLAN TL:Invalid station id requested on %s", __func__));
2657 return VOS_STATUS_E_FAULT;
2658 }
2659
2660 /*------------------------------------------------------------------------
2661 Extract TL control block and check existance
2662 ------------------------------------------------------------------------*/
2663 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2664 if (NULL == pTLCb)
2665 {
2666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2667 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2668 return VOS_STATUS_E_FAULT;
2669 }
2670
2671 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2672
2673 if (NULL == pClientSTA)
2674 {
2675 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2676 "WLAN TL:Client Memory was not allocated on %s", __func__));
2677 return VOS_STATUS_E_FAILURE;
2678 }
2679
2680 if (0 == pClientSTA->ucExists)
2681 {
2682 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2683 "WLAN TL:Station was not previously registered on %s", __func__));
2684 return VOS_STATUS_E_EXISTS;
2685 }
2686
2687 /*------------------------------------------------------------------------
2688 Copy will not be locked; please read restriction
2689 ------------------------------------------------------------------------*/
2690 if (pTLCb->isBMPS)
2691 {
2692 *pSnr = pClientSTA->snrAvgBmps;
2693 }
2694 else
2695 {
2696 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2697 * data samples (snridx) to calculate the average then return the
2698 * average for the window of prevoius 20 packets. And if there aren't
2699 * enough samples and the average for previous window of 20 packets is
2700 * not available then return a predefined value
2701 *
2702 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2703 * team reveal that the SNR value has a ceiling well below 127 dBm,
2704 * so if SNR has value of 127 the userspace applications can know that
2705 * the SNR has not been computed yet because enough data was not
2706 * available for SNR calculation
2707 */
2708 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2709 || !(pClientSTA->prevSnrAvg))
2710 {
2711 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2712 }
2713 else if (pClientSTA->prevSnrAvg)
2714 {
2715 *pSnr = pClientSTA->prevSnrAvg;
2716 }
2717 else
2718 {
2719 *pSnr = SNR_HACK_BMPS;
2720 }
2721 }
2722
2723 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2724 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2725 ucSTAId, *pSnr,
2726 pTLCb->isBMPS ? " in BMPS" : "");
2727
2728 return VOS_STATUS_SUCCESS;
2729}/* WLANTL_GetSnr */
2730/*==========================================================================
2731
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 FUNCTION WLANTL_GetLinkQuality
2733
2734 DESCRIPTION
2735 TL will extract the SNR information from every data packet from the
2736 ongoing traffic and will store it. It will provide the result to SME
2737 upon request.
2738
2739 DEPENDENCIES
2740
2741 WARNING: the read and write of this value will not be protected
2742 by locks, therefore the information obtained after a read
2743 might not always be consistent.
2744
2745 PARAMETERS
2746
2747 IN
2748 pvosGCtx: pointer to the global vos context; a handle to TL's
2749 or SME's control block can be extracted from its context
2750 ucSTAId: station identifier for the requested value
2751
2752 OUT
2753 puLinkQuality: the average value of the SNR
2754
2755
2756 RETURN VALUE
2757 The result code associated with performing the operation
2758
2759 VOS_STATUS_E_INVAL: Input parameters are invalid
2760 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2761 to TL cb is NULL ; access would cause a page fault
2762 VOS_STATUS_E_EXISTS: STA was not yet registered
2763 VOS_STATUS_SUCCESS: Everything is good :)
2764
2765 SIDE EFFECTS
2766
2767============================================================================*/
2768VOS_STATUS
2769WLANTL_GetLinkQuality
2770(
2771 v_PVOID_t pvosGCtx,
2772 v_U8_t ucSTAId,
2773 v_U32_t* puLinkQuality
2774)
2775{
2776 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302777 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002778
2779 /*------------------------------------------------------------------------
2780 Sanity check
2781 ------------------------------------------------------------------------*/
2782 if ( NULL == puLinkQuality )
2783 {
2784 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2785 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2786 return VOS_STATUS_E_INVAL;
2787 }
2788
2789 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2790 {
2791 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2792 "Invalid station id requested on WLANTL_GetLinkQuality"));
2793 return VOS_STATUS_E_FAULT;
2794 }
2795
2796 /*------------------------------------------------------------------------
2797 Extract TL control block and check existance
2798 ------------------------------------------------------------------------*/
2799 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2800 if ( NULL == pTLCb )
2801 {
2802 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2803 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2804 return VOS_STATUS_E_FAULT;
2805 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302806 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002807
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302808 if ( NULL == pClientSTA )
2809 {
2810 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2811 "WLAN TL:Client Memory was not allocated on %s", __func__));
2812 return VOS_STATUS_E_FAILURE;
2813 }
2814
2815 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 {
2817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2818 "Station was not previously registered on WLANTL_GetLinkQuality"));
2819 return VOS_STATUS_E_EXISTS;
2820 }
2821
2822 /*------------------------------------------------------------------------
2823 Copy will not be locked; please read restriction
2824 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302825 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002826
2827 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2828 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2829
2830 return VOS_STATUS_SUCCESS;
2831}/* WLANTL_GetLinkQuality */
2832
2833/*==========================================================================
2834
2835 FUNCTION WLANTL_FlushStaTID
2836
2837 DESCRIPTION
2838 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2839 message to HAL. This API is called by the SME inorder to perform a flush
2840 operation.
2841
2842 DEPENDENCIES
2843
2844 PARAMETERS
2845
2846 IN
2847 pvosGCtx: pointer to the global vos context; a handle to TL's
2848 or SME's control block can be extracted from its context
2849 ucSTAId: station identifier for the requested value
2850 ucTid: Tspec ID for the new BA session
2851
2852 OUT
2853 The response for this post is received in the main thread, via a response
2854 message from HAL to TL.
2855
2856 RETURN VALUE
2857 VOS_STATUS_SUCCESS: Everything is good :)
2858
2859 SIDE EFFECTS
2860============================================================================*/
2861VOS_STATUS
2862WLANTL_FlushStaTID
2863(
2864 v_PVOID_t pvosGCtx,
2865 v_U8_t ucSTAId,
2866 v_U8_t ucTid
2867)
2868{
2869 WLANTL_CbType* pTLCb = NULL;
2870 tpFlushACReq FlushACReqPtr = NULL;
2871 vos_msg_t vosMessage;
2872
2873
2874 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2875 {
2876 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2877 "Invalid station id requested on WLANTL_FlushStaTID"));
2878 return VOS_STATUS_E_FAULT;
2879 }
2880
2881 /*------------------------------------------------------------------------
2882 Extract TL control block and check existance
2883 ------------------------------------------------------------------------*/
2884 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2885 if ( NULL == pTLCb )
2886 {
2887 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2888 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2889 return VOS_STATUS_E_FAULT;
2890 }
2891
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302892 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2893 {
2894 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2895 "WLAN TL:Client Memory was not allocated on %s", __func__));
2896 return VOS_STATUS_E_FAILURE;
2897 }
2898
2899 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 {
2901 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2902 "Station was not previously registered on WLANTL_FlushStaTID"));
2903 return VOS_STATUS_E_EXISTS;
2904 }
2905
2906 /*------------------------------------------------------------------------
2907 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2908 ------------------------------------------------------------------------*/
2909 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2910
2911 if ( NULL == FlushACReqPtr )
2912 {
2913 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2914 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2915 VOS_ASSERT(0);
2916 return VOS_STATUS_E_NOMEM;
2917 }
2918
2919 // Start constructing the message for HAL
2920 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2921 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2922 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2923 FlushACReqPtr->ucSTAId = ucSTAId;
2924 FlushACReqPtr->ucTid = ucTid;
2925
2926 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2927 vosMessage.bodyptr = (void *)FlushACReqPtr;
2928
2929 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2930 return VOS_STATUS_SUCCESS;
2931}
2932
2933
2934/*----------------------------------------------------------------------------
2935 INTERACTION WITH PE
2936 ---------------------------------------------------------------------------*/
2937
2938/*==========================================================================
2939
2940 FUNCTION WLANTL_RegisterMgmtFrmClient
2941
2942 DESCRIPTION
2943 Called by PE to register as a client for management frames delivery.
2944
2945 DEPENDENCIES
2946 TL must be initialized before this API can be called.
2947
2948 PARAMETERS
2949
2950 IN
2951 pvosGCtx: pointer to the global vos context; a handle to
2952 TL's control block can be extracted from its context
2953 pfnTlMgmtFrmRx: pointer to the receive processing routine for
2954 management frames
2955
2956 RETURN VALUE
2957 The result code associated with performing the operation
2958
2959 VOS_STATUS_E_INVAL: Input parameters are invalid
2960 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2961 page fault
2962 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
2963 VOS_STATUS_SUCCESS: Everything is good :)
2964
2965 SIDE EFFECTS
2966
2967============================================================================*/
2968VOS_STATUS
2969WLANTL_RegisterMgmtFrmClient
2970(
2971 v_PVOID_t pvosGCtx,
2972 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
2973)
2974{
2975 WLANTL_CbType* pTLCb = NULL;
2976 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2977
2978 /*------------------------------------------------------------------------
2979 Sanity check
2980 ------------------------------------------------------------------------*/
2981 if ( NULL == pfnTlMgmtFrmRx )
2982 {
2983 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2984 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
2985 return VOS_STATUS_E_INVAL;
2986 }
2987
2988 /*------------------------------------------------------------------------
2989 Extract TL control block
2990 ------------------------------------------------------------------------*/
2991 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2992 if ( NULL == pTLCb )
2993 {
2994 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2995 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
2996 return VOS_STATUS_E_FAULT;
2997 }
2998
2999 /*------------------------------------------------------------------------
3000 Make sure this is the first registration attempt
3001 ------------------------------------------------------------------------*/
3002 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3003 {
3004 pTLCb->tlMgmtFrmClient.ucExists++;
3005 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3006 "WLAN TL:Management frame client was already registered"));
3007 return VOS_STATUS_E_EXISTS;
3008 }
3009
3010 /*------------------------------------------------------------------------
3011 Register station with TL
3012 ------------------------------------------------------------------------*/
3013 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3014 "WLAN TL:Registering Management Frame Client" ));
3015
3016 pTLCb->tlMgmtFrmClient.ucExists++;
3017
3018 if ( NULL != pfnTlMgmtFrmRx )
3019 {
3020 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3021 }
3022
3023 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3024
3025 return VOS_STATUS_SUCCESS;
3026}/* WLANTL_RegisterMgmtFrmClient */
3027
3028/*==========================================================================
3029
3030 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3031
3032 DESCRIPTION
3033 Called by PE to deregister as a client for management frames delivery.
3034
3035 DEPENDENCIES
3036 TL must be initialized before this API can be called.
3037
3038 PARAMETERS
3039
3040 IN
3041 pvosGCtx: pointer to the global vos context; a handle to
3042 TL's control block can be extracted from its context
3043 RETURN VALUE
3044 The result code associated with performing the operation
3045
3046 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3047 page fault
3048 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3049 VOS_STATUS_SUCCESS: Everything is good :)
3050
3051 SIDE EFFECTS
3052
3053============================================================================*/
3054VOS_STATUS
3055WLANTL_DeRegisterMgmtFrmClient
3056(
3057 v_PVOID_t pvosGCtx
3058)
3059{
3060 WLANTL_CbType* pTLCb = NULL;
3061 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3062
3063 /*------------------------------------------------------------------------
3064 Extract TL control block
3065 ------------------------------------------------------------------------*/
3066 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3067 if ( NULL == pTLCb )
3068 {
3069 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3070 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3071 return VOS_STATUS_E_FAULT;
3072 }
3073
3074 /*------------------------------------------------------------------------
3075 Make sure this is the first registration attempt
3076 ------------------------------------------------------------------------*/
3077 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3078 {
3079 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3080 "WLAN TL:Management frame client was never registered"));
3081 return VOS_STATUS_E_EXISTS;
3082 }
3083
3084 /*------------------------------------------------------------------------
3085 Clear registration with TL
3086 ------------------------------------------------------------------------*/
3087 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3088 "WLAN TL:Deregistering Management Frame Client" ));
3089
3090 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3091 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3092 {
3093 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3094 "WLAN TL:Management cache buffer not empty on deregistering"
3095 " - dropping packet" ));
3096 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3097
3098 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3099 }
3100
3101 pTLCb->tlMgmtFrmClient.ucExists = 0;
3102
3103 return VOS_STATUS_SUCCESS;
3104}/* WLANTL_RegisterMgmtFrmClient */
3105
3106/*==========================================================================
3107
3108 FUNCTION WLANTL_TxMgmtFrm
3109
3110 DESCRIPTION
3111 Called by PE when it want to send out a management frame.
3112 HAL will also use this API for the few frames it sends out, they are not
3113 management frames howevere it is accepted that an exception will be
3114 allowed ONLY for the usage of HAL.
3115 Generic data frames SHOULD NOT travel through this function.
3116
3117 DEPENDENCIES
3118 TL must be initialized before this API can be called.
3119
3120 RESTRICTION: If PE sends another packet before TL manages to process the
3121 previously sent packet call will end in failure
3122
3123 Frames comming through here must be 802.11 frames, frame
3124 translation in UMA will be automatically disabled.
3125
3126 PARAMETERS
3127
3128 IN
3129 pvosGCtx: pointer to the global vos context;a handle to TL's
3130 control block can be extracted from its context
3131 vosFrmBuf: pointer to a vOSS buffer containing the management
3132 frame to be transmitted
3133 usFrmLen: the length of the frame to be transmitted; information
3134 is already included in the vOSS buffer
3135 wFrmType: the type of the frame being transmitted
3136 tid: tid used to transmit this frame
3137 pfnCompTxFunc: function pointer to the transmit complete routine
3138 pvBDHeader: pointer to the BD header, if NULL it means it was not
3139 yet constructed and it lies within TL's responsibility
3140 to do so; if not NULL it is expected that it was
3141 already packed inside the vos packet
3142 ucAckResponse: flag notifying it an interrupt is needed for the
3143 acknowledgement received when the frame is sent out
3144 the air and ; the interrupt will be processed by HAL,
3145 only one such frame can be pending in the system at
3146 one time.
3147
3148
3149 RETURN VALUE
3150 The result code associated with performing the operation
3151
3152 VOS_STATUS_E_INVAL: Input parameters are invalid
3153 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3154 page fault
3155 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3156 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3157 VOS_STATUS_SUCCESS: Everything is good :)
3158
3159 Other failure messages may be returned from the BD header handling
3160 routines, please check apropriate API for more info.
3161
3162 SIDE EFFECTS
3163
3164============================================================================*/
3165VOS_STATUS
3166WLANTL_TxMgmtFrm
3167(
3168 v_PVOID_t pvosGCtx,
3169 vos_pkt_t* vosFrmBuf,
3170 v_U16_t usFrmLen,
3171 v_U8_t wFrmType,
3172 v_U8_t ucTid,
3173 WLANTL_TxCompCBType pfnCompTxFunc,
3174 v_PVOID_t pvBDHeader,
3175 v_U8_t ucAckResponse
3176)
3177{
3178 WLANTL_CbType* pTLCb = NULL;
3179 v_MACADDR_t vDestMacAddr;
3180 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3181 v_U16_t usPktLen;
3182 v_U32_t usTimeStamp = 0;
3183 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3184
3185 /*------------------------------------------------------------------------
3186 Sanity check
3187 ------------------------------------------------------------------------*/
3188 if ( NULL == vosFrmBuf )
3189 {
3190 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3191 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3192 return VOS_STATUS_E_INVAL;
3193 }
3194
3195 /*------------------------------------------------------------------------
3196 Extract TL control block
3197 ------------------------------------------------------------------------*/
3198 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3199 if ( NULL == pTLCb )
3200 {
3201 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3202 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3203 return VOS_STATUS_E_FAULT;
3204 }
3205
3206 /*------------------------------------------------------------------------
3207 Ensure that management frame client was previously registered
3208 ------------------------------------------------------------------------*/
3209 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3210 {
3211 pTLCb->tlMgmtFrmClient.ucExists++;
3212 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3213 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3214 return VOS_STATUS_E_EXISTS;
3215 }
3216
3217 /*------------------------------------------------------------------------
3218 Check if any Mgmt Frm is pending
3219 ------------------------------------------------------------------------*/
3220 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3221 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3222 {
3223
3224 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3225 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3226
3227
3228 /*Failing the tx for the previous packet enqued by PE*/
3229 //vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3230 // (v_U32_t)NULL);
3231
3232 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3233 // (v_PVOID_t)&pfnTxComp);
3234
3235 /*it should never be NULL - default handler should be registered if none*/
3236 //if ( NULL == pfnTxComp )
3237 //{
3238 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3239 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3240 // VOS_ASSERT(0);
3241 // return VOS_STATUS_E_FAULT;
3242 //}
3243
3244 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3245 //return VOS_STATUS_E_BUSY;
3246
3247
3248 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3249 return VOS_STATUS_E_RESOURCES;
3250 }
3251
3252
3253 /*------------------------------------------------------------------------
3254 Check if BD header was build, if not construct
3255 ------------------------------------------------------------------------*/
3256 if ( NULL == pvBDHeader )
3257 {
3258 v_MACADDR_t* pvAddr2MacAddr;
3259 v_U8_t uQosHdr = VOS_FALSE;
3260
3261 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3262 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3263 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3264 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3265
3266 if ( VOS_STATUS_SUCCESS != vosStatus )
3267 {
3268 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3269 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3270 return vosStatus;
3271 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303272
3273 /* CCX IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 * for management functionality comes through route.
3275 */
3276 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3277 {
3278 uQosHdr = VOS_TRUE;
3279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 /*----------------------------------------------------------------------
3281 Call WDA to build TX header
3282 ----------------------------------------------------------------------*/
3283 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3284 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
3285 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
3286 ucAckResponse, usTimeStamp, 0, 0 );
3287
3288
3289 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3290 {
3291 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3292 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3293 return vosStatus;
3294 }
3295 }/* if BD header not present */
3296
3297 /*------------------------------------------------------------------------
3298 Save buffer and notify BAL; no lock is needed if the above restriction
3299 is met
3300 Save the tx complete fnct pointer as tl specific data in the vos buffer
3301 ------------------------------------------------------------------------*/
3302 if ( NULL != pfnCompTxFunc )
3303 {
3304 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3305 (v_PVOID_t)pfnCompTxFunc);
3306 }
3307 else
3308 {
3309 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3310 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3311
3312 }
3313
3314 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3315 (v_U32_t)vosFrmBuf);
3316
3317 /*------------------------------------------------------------------------
3318 Check if thre are enough resources for transmission and tx is not
3319 suspended.
3320 ------------------------------------------------------------------------*/
3321 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3322 {
3323 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3324 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3325 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3326 if(VOS_STATUS_SUCCESS != vosStatus)
3327 {
3328 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3329 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
3330 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
3331 }
3332 return vosStatus;
3333
3334 }
3335 else
3336 {
3337 /*---------------------------------------------------------------------
3338 No error code is sent because TL will resume tx autonomously if
3339 resources become available or tx gets resumed
3340 ---------------------------------------------------------------------*/
3341 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3342 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3343 pTLCb->uResCount));
3344 }
3345
3346 return VOS_STATUS_SUCCESS;
3347}/* WLANTL_TxMgmtFrm */
3348
3349/*----------------------------------------------------------------------------
3350 INTERACTION WITH HAL
3351 ---------------------------------------------------------------------------*/
3352
3353/*==========================================================================
3354
3355 FUNCTION WLANTL_ResetNotification
3356
3357 DESCRIPTION
3358 HAL notifies TL when the module is being reset.
3359 Currently not used.
3360
3361 DEPENDENCIES
3362
3363 PARAMETERS
3364
3365 IN
3366 pvosGCtx: pointer to the global vos context; a handle to TL's
3367 control block can be extracted from its context
3368
3369
3370 RETURN VALUE
3371 The result code associated with performing the operation
3372
3373 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3374 page fault
3375 VOS_STATUS_SUCCESS: Everything is good :)
3376
3377 SIDE EFFECTS
3378
3379============================================================================*/
3380VOS_STATUS
3381WLANTL_ResetNotification
3382(
3383 v_PVOID_t pvosGCtx
3384)
3385{
3386 WLANTL_CbType* pTLCb = NULL;
3387 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3388
3389 /*------------------------------------------------------------------------
3390 Sanity check
3391 Extract TL control block
3392 ------------------------------------------------------------------------*/
3393 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3394 if ( NULL == pTLCb )
3395 {
3396 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3397 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3398 return VOS_STATUS_E_FAULT;
3399 }
3400
3401 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3402 return VOS_STATUS_SUCCESS;
3403}/* WLANTL_ResetNotification */
3404
3405/*==========================================================================
3406
3407 FUNCTION WLANTL_SuspendDataTx
3408
3409 DESCRIPTION
3410 HAL calls this API when it wishes to suspend transmission for a
3411 particular STA.
3412
3413 DEPENDENCIES
3414 The STA for which the request is made must be first registered with
3415 TL by HDD.
3416
3417 RESTRICTION: In case of a suspend, the flag write and read will not be
3418 locked: worst case scenario one more packet can get
3419 through before the flag gets updated (we can make this
3420 write atomic as well to guarantee consistency)
3421
3422 PARAMETERS
3423
3424 IN
3425 pvosGCtx: pointer to the global vos context; a handle to TL's
3426 control block can be extracted from its context
3427 pucSTAId: identifier of the station for which the request is made;
3428 a value of NULL assumes suspend on all active station
3429 pfnSuspendTxCB: pointer to the suspend result notification in case the
3430 call is asynchronous
3431
3432
3433 RETURN VALUE
3434 The result code associated with performing the operation
3435
3436 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3437 to TL cb is NULL ; access would cause a page fault
3438 VOS_STATUS_E_EXISTS: Station was not registered
3439 VOS_STATUS_SUCCESS: Everything is good :)
3440
3441 SIDE EFFECTS
3442
3443============================================================================*/
3444
3445VOS_STATUS
3446WLANTL_SuspendDataTx
3447(
3448 v_PVOID_t pvosGCtx,
3449 v_U8_t* pucSTAId,
3450 WLANTL_SuspendCBType pfnSuspendTx
3451)
3452{
3453 WLANTL_CbType* pTLCb = NULL;
3454 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003455
3456 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3457
3458 /*------------------------------------------------------------------------
3459 Sanity check
3460 Extract TL control block
3461 ------------------------------------------------------------------------*/
3462 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003463 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 {
3465 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3466 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3467 return VOS_STATUS_E_FAULT;
3468 }
3469
3470 /*------------------------------------------------------------------------
3471 Check the type of request: generic suspend, or per station suspend
3472 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003473 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 {
3475 /* General Suspend Request received */
3476 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3477 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003478 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3480 }
3481 else
3482 {
Hoonki Lee14621352013-04-16 17:51:19 -07003483 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 {
Hoonki Lee14621352013-04-16 17:51:19 -07003485 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3486 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3487 return VOS_STATUS_E_FAULT;
3488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003489
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303490 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3491 {
3492 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3493 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3494 "WLANTL_SuspendDataTx", *pucSTAId));
3495 return VOS_STATUS_E_FAULT;
3496 }
3497
3498 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003499 {
3500 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3501 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3502 return VOS_STATUS_E_EXISTS;
3503 }
3504
3505 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3506 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3507 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 vosMsg.reserved = *pucSTAId;
3509 }
3510
3511 /*------------------------------------------------------------------------
3512 Serialize request through TX thread
3513 ------------------------------------------------------------------------*/
3514 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3515 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3516
3517 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3518 {
3519 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003520 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522
3523 return VOS_STATUS_SUCCESS;
3524}/* WLANTL_SuspendDataTx */
3525
3526/*==========================================================================
3527
3528 FUNCTION WLANTL_ResumeDataTx
3529
3530 DESCRIPTION
3531 Called by HAL to resume data transmission for a given STA.
3532
3533 WARNING: If a station was individually suspended a global resume will
3534 not resume that station
3535
3536 DEPENDENCIES
3537
3538 PARAMETERS
3539
3540 IN
3541 pvosGCtx: pointer to the global vos context; a handle to TL's
3542 control block can be extracted from its context
3543 pucSTAId: identifier of the station which is being resumed; NULL
3544 translates into global resume
3545
3546 RETURN VALUE
3547 The result code associated with performing the operation
3548
3549 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3550 to TL cb is NULL ; access would cause a page fault
3551 VOS_STATUS_E_EXISTS: Station was not registered
3552 VOS_STATUS_SUCCESS: Everything is good :)
3553
3554 SIDE EFFECTS
3555
3556============================================================================*/
3557
3558VOS_STATUS
3559WLANTL_ResumeDataTx
3560(
3561 v_PVOID_t pvosGCtx,
3562 v_U8_t* pucSTAId
3563)
3564{
3565 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3567
3568 /*------------------------------------------------------------------------
3569 Sanity check
3570 Extract TL control block
3571 ------------------------------------------------------------------------*/
3572 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003573 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 {
3575 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3576 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3577 return VOS_STATUS_E_FAULT;
3578 }
3579
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 /*------------------------------------------------------------------------
3581 Check to see the type of resume
3582 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003583 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 {
3585 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3586 "WLAN TL:General resume requested"));
3587 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 }
3589 else
3590 {
Hoonki Lee14621352013-04-16 17:51:19 -07003591 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 {
Hoonki Lee14621352013-04-16 17:51:19 -07003593 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3594 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3595 return VOS_STATUS_E_FAULT;
3596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003597
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303598 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3599 {
3600 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3601 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3602 "WLANTL_ResumeDataTx", *pucSTAId));
3603 return VOS_STATUS_E_FAULT;
3604 }
3605
3606 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003607 {
3608 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3609 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3610 return VOS_STATUS_E_EXISTS;
3611 }
3612
3613 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3614 "WLAN TL:Resume request for station: %d", *pucSTAId));
3615 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 }
3617
3618 /*------------------------------------------------------------------------
3619 Resuming transmission
3620 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003621 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3622 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 {
3624 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3625 "WLAN TL:Resuming transmission"));
3626 return WDA_DS_StartXmit(pvosGCtx);
3627 }
3628
3629 return VOS_STATUS_SUCCESS;
3630}/* WLANTL_ResumeDataTx */
3631
3632/*==========================================================================
3633 FUNCTION WLANTL_SuspendCB
3634
3635 DESCRIPTION
3636 Callback function for serializing Suspend signal through Tx thread
3637
3638 DEPENDENCIES
3639 Just notify HAL that suspend in TL is complete.
3640
3641 PARAMETERS
3642
3643 IN
3644 pvosGCtx: pointer to the global vos context; a handle to TL's
3645 control block can be extracted from its context
3646 pUserData: user data sent with the callback
3647
3648 RETURN VALUE
3649 The result code associated with performing the operation
3650
3651 VOS_STATUS_E_INVAL: invalid input parameters
3652 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3653 page fault
3654 VOS_STATUS_SUCCESS: Everything is good :)
3655
3656
3657 SIDE EFFECTS
3658
3659============================================================================*/
3660VOS_STATUS
3661WLANTL_SuspendCB
3662(
3663 v_PVOID_t pvosGCtx,
3664 WLANTL_SuspendCBType pfnSuspendCB,
3665 v_U16_t usReserved
3666)
3667{
3668 WLANTL_CbType* pTLCb = NULL;
3669 v_U8_t ucSTAId = (v_U8_t)usReserved;
3670 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3671
3672 /*------------------------------------------------------------------------
3673 Sanity check
3674 ------------------------------------------------------------------------*/
3675 if ( NULL == pfnSuspendCB )
3676 {
3677 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3678 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3679 return VOS_STATUS_SUCCESS;
3680 }
3681
3682 /*------------------------------------------------------------------------
3683 Extract TL control block
3684 ------------------------------------------------------------------------*/
3685 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3686 if ( NULL == pTLCb )
3687 {
3688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3689 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3690 return VOS_STATUS_E_FAULT;
3691 }
3692
3693 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3694 {
3695 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3696 }
3697 else
3698 {
3699 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3700 }
3701
3702 return VOS_STATUS_SUCCESS;
3703}/*WLANTL_SuspendCB*/
3704
3705
3706/*----------------------------------------------------------------------------
3707 CLIENT INDEPENDENT INTERFACE
3708 ---------------------------------------------------------------------------*/
3709
3710/*==========================================================================
3711
3712 FUNCTION WLANTL_GetTxPktCount
3713
3714 DESCRIPTION
3715 TL will provide the number of transmitted packets counted per
3716 STA per TID.
3717
3718 DEPENDENCIES
3719
3720 PARAMETERS
3721
3722 IN
3723 pvosGCtx: pointer to the global vos context; a handle to TL's
3724 control block can be extracted from its context
3725 ucSTAId: identifier of the station
3726 ucTid: identifier of the tspec
3727
3728 OUT
3729 puTxPktCount: the number of packets tx packet for this STA and TID
3730
3731 RETURN VALUE
3732 The result code associated with performing the operation
3733
3734 VOS_STATUS_E_INVAL: Input parameters are invalid
3735 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3736 to TL cb is NULL ; access would cause a page fault
3737 VOS_STATUS_E_EXISTS: Station was not registered
3738 VOS_STATUS_SUCCESS: Everything is good :)
3739
3740 SIDE EFFECTS
3741
3742============================================================================*/
3743VOS_STATUS
3744WLANTL_GetTxPktCount
3745(
3746 v_PVOID_t pvosGCtx,
3747 v_U8_t ucSTAId,
3748 v_U8_t ucTid,
3749 v_U32_t* puTxPktCount
3750)
3751{
3752 WLANTL_CbType* pTLCb = NULL;
3753 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3754
3755 /*------------------------------------------------------------------------
3756 Sanity check
3757 ------------------------------------------------------------------------*/
3758 if ( NULL == puTxPktCount )
3759 {
3760 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3761 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3762 return VOS_STATUS_E_INVAL;
3763 }
3764
3765 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3766 {
3767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3768 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3769 ucSTAId, ucTid));
3770 return VOS_STATUS_E_FAULT;
3771 }
3772
3773 /*------------------------------------------------------------------------
3774 Extract TL control block and check if station exists
3775 ------------------------------------------------------------------------*/
3776 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3777 if ( NULL == pTLCb )
3778 {
3779 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3780 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3781 return VOS_STATUS_E_FAULT;
3782 }
3783
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303784 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3785 {
3786 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3787 "WLAN TL:Client Memory was not allocated on %s", __func__));
3788 return VOS_STATUS_E_FAILURE;
3789 }
3790
3791 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 {
3793 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3794 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3795 ucSTAId));
3796 return VOS_STATUS_E_EXISTS;
3797 }
3798
3799 /*------------------------------------------------------------------------
3800 Return data
3801 ------------------------------------------------------------------------*/
3802 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3803 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3804 // ucSTAId, ucTid);
3805
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303806 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003807
3808 return VOS_STATUS_SUCCESS;
3809}/* WLANTL_GetTxPktCount */
3810
3811/*==========================================================================
3812
3813 FUNCTION WLANTL_GetRxPktCount
3814
3815 DESCRIPTION
3816 TL will provide the number of received packets counted per
3817 STA per TID.
3818
3819 DEPENDENCIES
3820
3821 PARAMETERS
3822
3823 IN
3824 pvosGCtx: pointer to the global vos context; a handle to TL's
3825 control block can be extracted from its context
3826 ucSTAId: identifier of the station
3827 ucTid: identifier of the tspec
3828
3829 OUT
3830 puTxPktCount: the number of packets rx packet for this STA and TID
3831
3832 RETURN VALUE
3833 The result code associated with performing the operation
3834
3835 VOS_STATUS_E_INVAL: Input parameters are invalid
3836 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3837 to TL cb is NULL ; access would cause a page fault
3838 VOS_STATUS_E_EXISTS: Station was not registered
3839 VOS_STATUS_SUCCESS: Everything is good :)
3840
3841 SIDE EFFECTS
3842
3843============================================================================*/
3844VOS_STATUS
3845WLANTL_GetRxPktCount
3846(
3847 v_PVOID_t pvosGCtx,
3848 v_U8_t ucSTAId,
3849 v_U8_t ucTid,
3850 v_U32_t* puRxPktCount
3851)
3852{
3853 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303854 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3856
3857 /*------------------------------------------------------------------------
3858 Sanity check
3859 ------------------------------------------------------------------------*/
3860 if ( NULL == puRxPktCount )
3861 {
3862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3863 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3864 return VOS_STATUS_E_INVAL;
3865 }
3866
3867 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3868 {
3869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3870 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
3871 ucSTAId, ucTid));
3872 return VOS_STATUS_E_FAULT;
3873 }
3874
3875 /*------------------------------------------------------------------------
3876 Extract TL control block and existance
3877 ------------------------------------------------------------------------*/
3878 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3879 if ( NULL == pTLCb )
3880 {
3881 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3882 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
3883 return VOS_STATUS_E_FAULT;
3884 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303885 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003886
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303887 if ( NULL == pClientSTA )
3888 {
3889 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3890 "WLAN TL:Client Memory was not allocated on %s", __func__));
3891 return VOS_STATUS_E_FAILURE;
3892 }
3893
3894 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 {
3896 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3897 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
3898 return VOS_STATUS_E_EXISTS;
3899 }
3900
3901 /*------------------------------------------------------------------------
3902 Return data
3903 ------------------------------------------------------------------------*/
3904 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3905 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
3906 ucSTAId, ucTid));
3907
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303908 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003909
3910 return VOS_STATUS_SUCCESS;
3911}/* WLANTL_GetRxPktCount */
3912
Jeff Johnson295189b2012-06-20 16:38:30 -07003913VOS_STATUS
3914WLANTL_TxFCFrame
3915(
3916 v_PVOID_t pvosGCtx
3917);
Jeff Johnson295189b2012-06-20 16:38:30 -07003918/*============================================================================
3919 TL INTERNAL API DEFINITION
3920============================================================================*/
3921
3922/*==========================================================================
3923
3924 FUNCTION WLANTL_GetFrames
3925
3926 DESCRIPTION
3927
3928 BAL calls this function at the request of the lower bus interface.
3929 When this request is being received TL will retrieve packets from HDD
3930 in accordance with the priority rules and the count supplied by BAL.
3931
3932 DEPENDENCIES
3933
3934 HDD must have registered with TL at least one STA before this function
3935 can be called.
3936
3937 PARAMETERS
3938
3939 IN
3940 pvosGCtx: pointer to the global vos context; a handle to TL's
3941 or BAL's control block can be extracted from its context
3942 uSize: maximum size accepted by the lower layer
3943 uFlowMask TX flow control mask for Prima. Each bit is defined as
3944 WDA_TXFlowEnumType
3945
3946 OUT
3947 vosDataBuff: it will contain a pointer to the first buffer supplied
3948 by TL, if there is more than one packet supplied, TL
3949 will chain them through vOSS buffers
3950
3951 RETURN VALUE
3952
3953 The result code associated with performing the operation
3954
3955 1 or more: number of required resources if there are still frames to fetch
3956 0 : error or HDD queues are drained
3957
3958 SIDE EFFECTS
3959
3960 NOTE
3961
3962 Featurized uFlowMask. If we want to remove featurization, we need to change
3963 BAL on Volans.
3964
3965============================================================================*/
3966v_U32_t
3967WLANTL_GetFrames
3968(
3969 v_PVOID_t pvosGCtx,
3970 vos_pkt_t **ppFrameDataBuff,
3971 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 v_BOOL_t* pbUrgent
3974)
3975{
3976 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
3977 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303978 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 v_U32_t uRemaining = uSize;
3980 vos_pkt_t* vosRoot;
3981 vos_pkt_t* vosTempBuf;
3982 WLANTL_STAFuncType pfnSTAFsm;
3983 v_U16_t usPktLen;
3984 v_U32_t uResLen;
3985 v_U8_t ucSTAId;
3986 v_U8_t ucAC;
3987 vos_pkt_t* vosDataBuff;
3988 v_U32_t uTotalPktLen;
3989 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08003990 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 v_U32_t ucResult = 0;
3992 VOS_STATUS vosStatus;
3993 WLANTL_STAEventType wSTAEvent;
3994 tBssSystemRole systemRole;
3995 tpAniSirGlobal pMac;
3996 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3997
3998 /*------------------------------------------------------------------------
3999 Sanity check
4000 Extract TL control block
4001 ------------------------------------------------------------------------*/
4002 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4003 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4004 {
4005 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4006 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4007 return ucResult;
4008 }
4009
4010 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4011 if ( NULL == pMac )
4012 {
4013 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004014 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 return ucResult;
4016 }
4017
4018 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4019 each iteration */
4020
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004022
4023 /*-----------------------------------------------------------------------
4024 Save the root as we will walk this chain as we fill it
4025 -----------------------------------------------------------------------*/
4026 vosRoot = vosDataBuff;
4027
4028 /*-----------------------------------------------------------------------
4029 There is still data - until FSM function says otherwise
4030 -----------------------------------------------------------------------*/
4031 pTLCb->bUrgent = FALSE;
4032
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4034 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 {
4036 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004037#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4038/* FIXME: The code has been disabled since it is creating issues in power save */
4039 if (eSYSTEM_AP_ROLE == systemRole)
4040 {
4041 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4042 {
4043 WLANTL_TxFCFrame (pvosGCtx);
4044 pTLCb->done_once ++;
4045 }
4046 }
4047 if ( NULL != pTLCb->vosTxFCBuf )
4048 {
4049 //there is flow control packet waiting to be sent
4050 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4051
4052 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004053 ( uRemaining > uTotalPktLen ) &&
4054 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 {
4056 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4057 "WLAN TL:Chaining FC frame first on GetFrame"));
4058
4059 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4060
4061 vos_atomic_set_U32( (v_U32_t*)&pTLCb->vosTxFCBuf, (v_U32_t)NULL);
4062
4063 /*FC frames cannot be delayed*/
4064 pTLCb->bUrgent = TRUE;
4065
4066 /*Update remaining len from SSC */
4067 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4068
4069 /*Update resource count */
4070 pTLCb->uResCount -= uResLen;
4071 }
4072 else
4073 {
4074 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004075 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4077 break; /* Out of resources or reached max len */
4078 }
4079 }
4080 else
4081#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004083 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4084 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 {
4086 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4087 usPktLen, uResLen, uTotalPktLen);
4088
4089 VOS_ASSERT(usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4090
4091 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004092 ( uRemaining > uTotalPktLen ) &&
4093 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4096 "WLAN TL:Chaining management frame on GetFrame"));
4097
4098 vos_pkt_chain_packet( vosDataBuff,
4099 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4100 1 /*true*/ );
4101
4102 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.
4103 vosPendingDataBuff, (v_U32_t)NULL);
4104
4105 /*management frames cannot be delayed*/
4106 pTLCb->bUrgent = TRUE;
4107
4108 /*Update remaining len from SSC */
4109 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4110
4111 /*Update resource count */
4112 pTLCb->uResCount -= uResLen;
4113 }
4114 else
4115 {
4116 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4117 break; /* Out of resources or reached max len */
4118 }
4119 }
4120 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4121 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004122 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 {
4124 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4125 usPktLen, uResLen, uTotalPktLen);
4126
4127 VOS_ASSERT(usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4128
4129 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4130 ( uRemaining > uTotalPktLen ))
4131 {
4132 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4133 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4134
4135 vos_pkt_chain_packet( vosDataBuff,
4136 pTLCb->tlBAPClient.vosPendingDataBuff,
4137 1 /*true*/ );
4138
4139 /*BAP frames cannot be delayed*/
4140 pTLCb->bUrgent = TRUE;
4141
4142 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4143 (v_U32_t)NULL);
4144
4145 /*Update remaining len from SSC */
4146 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4147
4148 /*Update resource count */
4149 pTLCb->uResCount -= uResLen;
4150 }
4151 else
4152 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 break; /* Out of resources or reached max len */
4155 }
4156 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004157 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4158 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4159 by default, EAPOL will be treated as higher priority, which means
4160 use mgmt_pool and DXE_TX_HI prority channel.
4161 this is introduced to address EAPOL failure under high background traffic
4162 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4163 see CR#387009 and WCNSOS-8
4164 */
4165 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4166 ( 0 == pTLCb->ucTxSuspended ) &&
4167 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4168 )
4169 {
4170 vosTempBuf = NULL;
4171 /*---------------------------------------------------------------------
4172 Check to see if there was any EAPOL packet is pending
4173 *--------------------------------------------------------------------*/
4174 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4175 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304176 if ((NULL != pTLCb->atlSTAClients[i]) &&
4177 (pTLCb->atlSTAClients[i]->ucExists) &&
4178 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004179 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4180 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004181 )
4182 break;
4183 }
4184
4185 if (i >= WLAN_MAX_STA_COUNT)
4186 {
4187 /* No More to Serve Exit Get Frames */
4188 break;
4189 }
4190 /* Serve EAPOL frame with HI_FLOW_MASK */
4191 ucSTAId = i;
4192
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004193 for (j = WLANTL_MAX_AC ; j > 0; j--)
4194 {
4195 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4196 {
4197 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4198 pTLCb->uCurServedAC = j-1;
4199 }
4200 }
4201
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304202 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4203
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004204 wSTAEvent = WLANTL_TX_EVENT;
4205
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304206 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004207 pfnSTATbl[wSTAEvent];
4208
4209 if ( NULL != pfnSTAFsm )
4210 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304211 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004212 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004213
4214 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4215 ( NULL != vosTempBuf ))
4216 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304217 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004218 vosTempBuf = NULL;
4219 break;
4220 }/* status success*/
4221 }
4222
4223 if (NULL != vosTempBuf)
4224 {
4225 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4226
4227 VOS_ASSERT( usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4228
4229 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4230 "WLAN TL:Resources needed by frame: %d", uResLen));
4231
4232 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4233 ( uRemaining > uTotalPktLen )
4234 )
4235 {
4236 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4237 "WLAN TL:Chaining data frame on GetFrame"));
4238
4239 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4240
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004241 /*EAPOL frame cannot be delayed*/
4242 pTLCb->bUrgent = TRUE;
4243
4244 vosTempBuf = NULL;
4245
4246 /*Update remaining len from SSC */
4247 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4248
4249 /*Update resource count */
4250 pTLCb->uResCount -= uResLen;
4251
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004252 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304253 pClientSTA->uIngress_length += uResLen;
4254 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4255 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004256 pClientSTA->ucEapolPktPending = 0;
4257 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4258 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4259 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004260 }
4261 }
4262 else
4263 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004264 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4265 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4266 ucSTAId));
4267 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004268 }
4269 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004270
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004271 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4272 ( 0 == pTLCb->ucTxSuspended ) &&
4273 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4274 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4275 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4276 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 {
4278 /*---------------------------------------------------------------------
4279 Check to see if there was any packet left behind previously due to
4280 size constraints
4281 ---------------------------------------------------------------------*/
4282 vosTempBuf = NULL;
4283
4284 if ( NULL != pTLCb->vosTempBuf )
4285 {
4286 vosTempBuf = pTLCb->vosTempBuf;
4287 pTLCb->vosTempBuf = NULL;
4288 ucSTAId = pTLCb->ucCachedSTAId;
4289 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304290
4291 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4292 {
4293 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4294 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304295 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304296 }
4297
4298 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304299 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004300
4301 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4302 "WLAN TL:Chaining cached data frame on GetFrame"));
4303 }
4304 else
4305 {
4306 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4307 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4308 {
4309 /* Packets start coming in even after insmod Without *
4310 starting Hostapd or Interface being up *
4311 During which cases STAID is invaled and hence
4312 the check. HalMsg_ScnaComplete Triggers */
4313
4314 break;
4315 }
4316 /* ucCurrentAC should have correct AC to be served by calling
4317 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304318 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304319 if ( NULL == pClientSTA )
4320 {
4321 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4322 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304323 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304324 }
4325
4326 ucAC = pClientSTA->ucCurrentAC;
4327
4328 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004330 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 /*-------------------------------------------------------------------
4332 Check to see that STA is valid and tx is not suspended
4333 -------------------------------------------------------------------*/
4334 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304335 ( 0 == pClientSTA->ucTxSuspended ) &&
4336 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 {
4338 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004339 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 wSTAEvent = WLANTL_TX_EVENT;
4341
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304342 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 pfnSTATbl[wSTAEvent];
4344
4345 if ( NULL != pfnSTAFsm )
4346 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304347 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004348 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004349
4350 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4351 ( NULL != vosTempBuf ))
4352 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304353 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 vosTempBuf,
4355 vosStatus );
4356 vosTempBuf = NULL;
4357 }/* status success*/
4358 }/*NULL function state*/
4359 }/* valid STA id and ! suspended*/
4360 else
4361 {
4362 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4363 {
4364 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4365 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4366 ucSTAId));
4367 }
4368 }
4369 }/* data */
4370
4371 if ( NULL != vosTempBuf )
4372 {
4373 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4374
4375 VOS_ASSERT( usPktLen <= WLANTL_MAX_ALLOWED_LEN);
4376
4377 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4378 "WLAN TL:Resources needed by frame: %d", uResLen));
4379
4380 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004381 ( uRemaining > uTotalPktLen ) &&
4382 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 {
4384 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4385 "WLAN TL:Chaining data frame on GetFrame"));
4386
4387 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4388 vosTempBuf = NULL;
4389
4390 /*Update remaining len from SSC */
4391 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4392
4393 /*Update resource count */
4394 pTLCb->uResCount -= uResLen;
4395
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304397 pClientSTA->uIngress_length += uResLen;
4398 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4399 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004400
4401 }
4402 else
4403 {
4404 /* Store this for later tx - already fetched from HDD */
4405 pTLCb->vosTempBuf = vosTempBuf;
4406 pTLCb->ucCachedSTAId = ucSTAId;
4407 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4409 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4410 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 break; /* Out of resources or reached max len */
4412 }
4413 }
4414 else
4415 {
4416 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4417 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304418 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4419 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 {
4421 /* There is station to be Served */
4422 break;
4423 }
4424 }
4425 if (i >= WLAN_MAX_STA_COUNT)
4426 {
4427 /* No More to Serve Exit Get Frames */
4428 break;
4429 }
4430 else
4431 {
4432 /* More to be Served */
4433 continue;
4434 }
4435 }
4436 }
4437 else
4438 {
4439 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4440 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4441 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 /* TL is starving even when DXE is not in low resource condition
4443 Return min resource number required and Let DXE deceide what to do */
4444 if(( 0 == pTLCb->ucTxSuspended ) &&
4445 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4446 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4447 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4448 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4449 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004450 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 "WLAN TL:Returning from GetFrame: resources = %d",
4452 pTLCb->uResCount));
4453 ucResult = WDA_TLI_MIN_RES_DATA;
4454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 break; /*out of min data resources*/
4456 }
4457
4458 pTLCb->usPendingTxCompleteCount++;
4459 /* Move data buffer up one packet */
4460 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4461 }
4462
4463 /*----------------------------------------------------------------------
4464 Packet chain starts at root + 1
4465 ----------------------------------------------------------------------*/
4466 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4467
4468 *pvosDataBuff = vosDataBuff;
4469 VOS_ASSERT( pbUrgent );
4470 *pbUrgent = pTLCb->bUrgent;
4471 return ucResult;
4472}/* WLANTL_GetFrames */
4473
4474
4475/*==========================================================================
4476
4477 FUNCTION WLANTL_TxComp
4478
4479 DESCRIPTION
4480 It is being called by BAL upon asynchronous notification of the packet
4481 or packets being sent over the bus.
4482
4483 DEPENDENCIES
4484 Tx complete cannot be called without a previous transmit.
4485
4486 PARAMETERS
4487
4488 IN
4489 pvosGCtx: pointer to the global vos context; a handle to TL's
4490 or BAL's control block can be extracted from its context
4491 vosDataBuff: it will contain a pointer to the first buffer for which
4492 the BAL report is being made, if there is more then one
4493 packet they will be chained using vOSS buffers.
4494 wTxStatus: the status of the transmitted packet, see above chapter
4495 on HDD interaction for a list of possible values
4496
4497 RETURN VALUE
4498 The result code associated with performing the operation
4499
4500 VOS_STATUS_E_INVAL: Input parameters are invalid
4501 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4502 page fault
4503 VOS_STATUS_E_EXISTS: Station was not registered
4504 VOS_STATUS_SUCCESS: Everything is good :)
4505
4506 SIDE EFFECTS
4507
4508============================================================================*/
4509VOS_STATUS
4510WLANTL_TxComp
4511(
4512 v_PVOID_t pvosGCtx,
4513 vos_pkt_t *pFrameDataBuff,
4514 VOS_STATUS wTxStatus
4515)
4516{
4517 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4518 WLANTL_CbType* pTLCb = NULL;
4519 WLANTL_TxCompCBType pfnTxComp = NULL;
4520 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 vos_pkt_t* vosTempTx = NULL;
4522
4523 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4524
4525 /*------------------------------------------------------------------------
4526 Sanity check
4527 ------------------------------------------------------------------------*/
4528 if ( NULL == vosDataBuff )
4529 {
4530 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4531 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4532 return VOS_STATUS_E_INVAL;
4533 }
4534
4535 /*------------------------------------------------------------------------
4536 Extract TL control block
4537 ------------------------------------------------------------------------*/
4538 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4539 if ( NULL == pTLCb )
4540 {
4541 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4542 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4543 return VOS_STATUS_E_FAULT;
4544 }
4545
4546 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4547 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4548 ( NULL != vosDataBuff))
4549 {
4550 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4551 (v_PVOID_t)&pfnTxComp);
4552
4553 /*it should never be NULL - default handler should be registered if none*/
4554 if ( NULL == pfnTxComp )
4555 {
4556 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4557 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4558 VOS_ASSERT(0);
4559 return VOS_STATUS_E_FAULT;
4560 }
4561
4562 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304563 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 vosDataBuff, pfnTxComp));
4565
4566 vosTempTx = vosDataBuff;
4567 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4568 &vosDataBuff, 1/*true*/);
4569
4570 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4571
4572 pTLCb->usPendingTxCompleteCount--;
4573 }
4574
Jeff Johnson295189b2012-06-20 16:38:30 -07004575
4576 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4577 "WLAN TL: current TL values are: resources = %d "
4578 "pTLCb->usPendingTxCompleteCount = %d",
4579 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4580
4581 return VOS_STATUS_SUCCESS;
4582}/* WLANTL_TxComp */
4583
4584/*==========================================================================
4585
4586 FUNCTION WLANTL_CacheSTAFrame
4587
4588 DESCRIPTION
4589 Internal utility function for for caching incoming data frames that do
4590 not have a registered station yet.
4591
4592 DEPENDENCIES
4593 TL must be initiailized before this function gets called.
4594 In order to benefit from thsi caching, the components must ensure that
4595 they will only register with TL at the moment when they are fully setup
4596 and ready to receive incoming data
4597
4598 PARAMETERS
4599
4600 IN
4601
4602 pTLCb: TL control block
4603 ucSTAId: station id
4604 vosTempBuff: the data packet
4605 uDPUSig: DPU signature of the incoming packet
4606 bBcast: true if packet had the MC/BC bit set
4607
4608 RETURN VALUE
4609 The result code associated with performing the operation
4610
4611 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4612 would cause a page fault
4613 VOS_STATUS_SUCCESS: Everything is good :)
4614
4615 SIDE EFFECTS
4616
4617============================================================================*/
4618static VOS_STATUS
4619WLANTL_CacheSTAFrame
4620(
4621 WLANTL_CbType* pTLCb,
4622 v_U8_t ucSTAId,
4623 vos_pkt_t* vosTempBuff,
4624 v_U32_t uDPUSig,
4625 v_U8_t bBcast,
4626 v_U8_t ucFrmType
4627)
4628{
4629 v_U8_t ucUcastSig;
4630 v_U8_t ucBcastSig;
4631 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304632 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4634
4635 /*-------------------------------------------------------------------------
4636 Sanity check
4637 -------------------------------------------------------------------------*/
4638 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4639 {
4640 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304641 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4642 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 return VOS_STATUS_E_FAULT;
4644 }
4645
4646 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4647 {
4648 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4649 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4650 return VOS_STATUS_E_FAULT;
4651 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304652 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4653
4654 if ( NULL == pClientSTA )
4655 {
4656 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4657 "WLAN TL:Client Memory was not allocated on %s", __func__));
4658 return VOS_STATUS_E_FAILURE;
4659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004660
4661 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4662 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4663 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304664 pClientSTA->wSTADesc.ucUcastSig,
4665 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004666
4667 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4668 {
4669 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4670 "WLAN TL: No need to cache CTRL frame. Dropping"));
4671 vos_pkt_return_packet(vosTempBuff);
4672 return VOS_STATUS_SUCCESS;
4673 }
4674
4675 /*-------------------------------------------------------------------------
4676 Check if the packet that we are trying to cache belongs to the old
4677 registered station (if any) or the new (potentially)upcoming station
4678
4679 - If the STA with this Id was never registered with TL - the signature
4680 will be invalid;
4681 - If the STA was previously registered TL will have cached the former
4682 set of DPU signatures
4683 -------------------------------------------------------------------------*/
4684 if ( bBcast )
4685 {
4686 ucBcastSig = (v_U8_t)uDPUSig;
4687 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304688 pClientSTA->wSTADesc.ucBcastSig ) &&
4689 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 }
4691 else
4692 {
4693 ucUcastSig = (v_U8_t)uDPUSig;
4694 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304695 pClientSTA->wSTADesc.ucUcastSig ) &&
4696 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 }
4698
4699 /*------------------------------------------------------------------------
4700 If the value of the DPU SIG matches the old, this packet will not
4701 be cached as it belonged to the former association
4702 In case the SIG does not match - this is a packet for a potentially new
4703 associated station
4704 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004705 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 {
4707 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4708 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4709 "BC: %d - dropping",
4710 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304711 pClientSTA->wSTADesc.ucUcastSig,
4712 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 vos_pkt_return_packet(vosTempBuff);
4714 }
4715 else
4716 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304717 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 {
4719 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304720 pClientSTA->vosBegCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 }
4722 else
4723 {
4724 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304725 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 vosTempBuff, VOS_TRUE);
4727 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304728 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 }/*else new packet*/
4730
4731 return VOS_STATUS_SUCCESS;
4732}/*WLANTL_CacheSTAFrame*/
4733
4734/*==========================================================================
4735
4736 FUNCTION WLANTL_FlushCachedFrames
4737
4738 DESCRIPTION
4739 Internal utility function used by TL to flush the station cache
4740
4741 DEPENDENCIES
4742 TL must be initiailized before this function gets called.
4743
4744 PARAMETERS
4745
4746 IN
4747
4748 vosDataBuff: it will contain a pointer to the first cached buffer
4749 received,
4750
4751 RETURN VALUE
4752 The result code associated with performing the operation
4753
4754 VOS_STATUS_SUCCESS: Everything is good :)
4755
4756 SIDE EFFECTS
4757
4758 NOTE
4759 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4760 responsibility to do so, if required, after this function call.
4761 Because of this restriction, we decide to make this function to static
4762 so that upper layer doesn't need to be aware of this restriction.
4763
4764============================================================================*/
4765static VOS_STATUS
4766WLANTL_FlushCachedFrames
4767(
4768 vos_pkt_t* vosDataBuff
4769)
4770{
4771 /*----------------------------------------------------------------------
4772 Return the entire chain to vos if there are indeed cache frames
4773 ----------------------------------------------------------------------*/
4774 if ( NULL != vosDataBuff )
4775 {
4776 vos_pkt_return_packet(vosDataBuff);
4777 }
4778
4779 return VOS_STATUS_SUCCESS;
4780}/*WLANTL_FlushCachedFrames*/
4781
4782/*==========================================================================
4783
4784 FUNCTION WLANTL_ForwardSTAFrames
4785
4786 DESCRIPTION
4787 Internal utility function for either forwarding cached data to the station after
4788 the station has been registered, or flushing cached data if the station has not
4789 been registered.
4790
4791
4792 DEPENDENCIES
4793 TL must be initiailized before this function gets called.
4794
4795 PARAMETERS
4796
4797 IN
4798
4799 pTLCb: TL control block
4800 ucSTAId: station id
4801
4802 RETURN VALUE
4803 The result code associated with performing the operation
4804
4805 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4806 page fault
4807 VOS_STATUS_SUCCESS: Everything is good :)
4808
4809 SIDE EFFECTS
4810 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4811 responsibility to do so, if required, after this function call.
4812 Because of this restriction, we decide to make this function to static
4813 so that upper layer doesn't need to be aware of this restriction.
4814
4815============================================================================*/
4816static VOS_STATUS
4817WLANTL_ForwardSTAFrames
4818(
4819 void* pvosGCtx,
4820 v_U8_t ucSTAId,
4821 v_U8_t ucUcastSig,
4822 v_U8_t ucBcastSig
4823)
4824{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304825 WLANTL_CbType* pTLCb = NULL;
4826 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4828
4829 /*-------------------------------------------------------------------------
4830 Sanity check
4831 -------------------------------------------------------------------------*/
4832 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4833 if ( NULL == pTLCb )
4834 {
4835 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304836 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 pTLCb ));
4838 return VOS_STATUS_E_FAULT;
4839 }
4840
4841 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4842 {
4843 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4844 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
4845 return VOS_STATUS_E_FAULT;
4846 }
4847
4848 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4849
4850 /*------------------------------------------------------------------------
4851 Check if station has not been registered in the mean while
4852 if not registered, flush cached frames.
4853 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304854 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4855
4856 if ( NULL == pClientSTA )
4857 {
4858 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4859 "WLAN TL:Client Memory was not allocated on %s", __func__));
4860 return VOS_STATUS_E_FAILURE;
4861 }
4862
4863 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 {
4865 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4866 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304867 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 goto done;
4869 }
4870
4871 /*------------------------------------------------------------------------
4872 Forwarding cache frames received while the station was in the process
4873 of being registered with the rest of the SW components
4874
4875 Access to the cache must be locked; similarly updating the signature and
4876 the existence flag must be synchronized because these values are checked
4877 during cached
4878 ------------------------------------------------------------------------*/
4879 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4880 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
4881
4882 /*-----------------------------------------------------------------------
4883 Save the new signature values
4884 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304885 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
4886 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004887
4888 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4889 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
4890 ucSTAId, ucUcastSig, ucBcastSig));
4891
4892 /*-------------------------------------------------------------------------
4893 Check to see if we have any cached data to forward
4894 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304895 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 {
4897 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4898 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
4899
4900 WLANTL_RxCachedFrames( pTLCb,
4901 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304902 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 }
4904 else
4905 {
4906 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4907 "WLAN TL: NO cached packets for station %d", ucSTAId ));
4908 }
4909
4910done:
4911 /*-------------------------------------------------------------------------
4912 Clear the station cache
4913 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304914 pClientSTA->vosBegCachedFrame = NULL;
4915 pClientSTA->vosEndCachedFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004916
4917 /*-----------------------------------------------------------------------
4918 After all the init is complete we can mark the existance flag
4919 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304920 pClientSTA->ucRxBlocked = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004921
4922 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4923 return VOS_STATUS_SUCCESS;
4924
4925}/*WLANTL_ForwardSTAFrames*/
4926
4927
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004928#if defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004929/*==========================================================================
4930
4931 FUNCTION WLANTL_IsIAPPFrame
4932
4933 DESCRIPTION
4934 Internal utility function for detecting incoming CCX IAPP frames
4935
4936 DEPENDENCIES
4937
4938 PARAMETERS
4939
4940 IN
4941
4942 pvBDHeader: pointer to the BD header
4943 vosTempBuff: the data packet
4944
4945 IN/OUT
4946 pFirstDataPktArrived: static from caller function; used for rssi
4947 computation
4948 RETURN VALUE
4949 The result code associated with performing the operation
4950
4951 VOS_TRUE: It is a IAPP frame
4952 VOS_FALSE: It is NOT IAPP frame
4953
4954 SIDE EFFECTS
4955
4956============================================================================*/
4957v_BOOL_t
4958WLANTL_IsIAPPFrame
4959(
4960 v_PVOID_t pvBDHeader,
4961 vos_pkt_t* vosTempBuff
4962)
4963{
4964 v_U16_t usMPDUDOffset;
4965 v_U8_t ucOffset;
4966 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
4967 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
4968 VOS_STATUS vosStatus;
4969
4970 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4971
4972 /*------------------------------------------------------------------------
4973 Check if OUI field is present.
4974 -------------------------------------------------------------------------*/
4975 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
4976 {
4977 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4978 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
4979 "dropping pkt"));
4980 /* Drop packet */
4981 vos_pkt_return_packet(vosTempBuff);
4982 return VOS_TRUE;
4983 }
4984 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
4985 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
4986
4987 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
4988 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
4989
4990 if (( VOS_STATUS_SUCCESS != vosStatus))
4991 {
4992 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4993 "Unable to extract Snap Hdr of data packet -"
4994 "dropping pkt"));
4995 return VOS_FALSE;
4996 }
4997
4998 /*------------------------------------------------------------------------
4999 Check if this is IAPP frame by matching Aironet Snap hdr.
5000 -------------------------------------------------------------------------*/
5001 // Compare returns 1 if values are same and 0
5002 // if not the same.
5003 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5004 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5005 WLANTL_LLC_SNAP_SIZE ) ))
5006 {
5007 return VOS_FALSE;
5008 }
5009
5010 return VOS_TRUE;
5011
5012}
5013#endif //FEATURE_WLAN_CCX
5014
5015/*==========================================================================
5016
5017 FUNCTION WLANTL_ProcessBAPFrame
5018
5019 DESCRIPTION
5020 Internal utility function for processing incoming BT-AMP frames
5021
5022 DEPENDENCIES
5023 TL must be initiailized before this function gets called.
5024 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5025 registered with TL.
5026
5027 PARAMETERS
5028
5029 IN
5030
5031 pvBDHeader: pointer to the BD header
5032 vosTempBuff: the data packet
5033 pTLCb: TL control block
5034 ucSTAId: station id
5035
5036 IN/OUT
5037 pFirstDataPktArrived: static from caller function; used for rssi
5038 computation
5039 RETURN VALUE
5040 The result code associated with performing the operation
5041
5042 VOS_STATUS_E_INVAL: Input parameters are invalid
5043 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5044 page fault
5045 VOS_STATUS_SUCCESS: Everything is good :)
5046
5047 SIDE EFFECTS
5048
5049============================================================================*/
5050v_BOOL_t
5051WLANTL_ProcessBAPFrame
5052(
5053 v_PVOID_t pvBDHeader,
5054 vos_pkt_t* vosTempBuff,
5055 WLANTL_CbType* pTLCb,
5056 v_U8_t* pFirstDataPktArrived,
5057 v_U8_t ucSTAId
5058)
5059{
5060 v_U16_t usMPDUDOffset;
5061 v_U8_t ucOffset;
5062 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5063 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5064 VOS_STATUS vosStatus;
5065 v_U16_t usType;
5066 v_SIZE_t usTypeLen = sizeof(usType);
5067 v_U8_t ucMPDUHOffset;
5068 v_U8_t ucMPDUHLen = 0;
5069 v_U16_t usActualHLen = 0;
5070
5071 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5072
5073 /*------------------------------------------------------------------------
5074 Extract OUI and type from LLC and validate; if non-data send to BAP
5075 -------------------------------------------------------------------------*/
5076 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5077 {
5078 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5079 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5080 "dropping pkt"));
5081 /* Drop packet */
5082 vos_pkt_return_packet(vosTempBuff);
5083 return VOS_TRUE;
5084 }
5085
5086 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5087 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5088 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5089 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5090
5091 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5092 (v_PVOID_t)ucOUI, &usOUISize);
5093
5094#if 0
5095 // Compare returns 1 if values are same and 0
5096 // if not the same.
5097 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5098 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5099 WLANTL_LLC_OUI_SIZE ) ))
5100 {
5101 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5102 "LLC header points to diff OUI in BT-AMP station -"
5103 "dropping pkt"));
5104 /* Drop packet */
5105 vos_pkt_return_packet(vosTempBuff);
5106 return VOS_TRUE;
5107 }
5108#endif
5109 /*------------------------------------------------------------------------
5110 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5111 ------------------------------------------------------------------------*/
5112 vosStatus = vos_pkt_extract_data( vosTempBuff,
5113 ucOffset + WLANTL_LLC_OUI_SIZE,
5114 (v_PVOID_t)&usType, &usTypeLen);
5115
5116 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5117 ( sizeof(usType) != usTypeLen ))
5118 {
5119 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5120 "Unable to extract type on incoming BAP packet -"
5121 "dropping pkt"));
5122 /* Drop packet */
5123 vos_pkt_return_packet(vosTempBuff);
5124 return VOS_TRUE;
5125 }
5126
5127 /*------------------------------------------------------------------------
5128 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5129 ------------------------------------------------------------------------*/
5130 usType = vos_be16_to_cpu(usType);
5131
5132 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5133 {
5134 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5135 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5136 usType));
5137
5138 /*Flatten packet as BAP expects to be able to peek*/
5139 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5140 {
5141 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5142 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5143 /* Drop packet */
5144 vos_pkt_return_packet(vosTempBuff);
5145 return VOS_TRUE;
5146 }
5147
5148 /* Send packet to BAP client*/
5149
5150 VOS_ASSERT(pTLCb->tlBAPClient.pfnTlBAPRx != NULL);
5151
5152 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5153 {
5154 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5155 "WLAN TL:BD header corrupted - dropping packet"));
5156 /* Drop packet */
5157 vos_pkt_return_packet(vosTempBuff);
5158 return VOS_TRUE;
5159 }
5160
5161 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5162 {
5163 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5164 "Non-data packet received over BT-AMP link: Sending it for "
5165 "frame Translation"));
5166
5167 if (usMPDUDOffset > ucMPDUHOffset)
5168 {
5169 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5170 }
5171
5172 /* software frame translation for BTAMP WDS.*/
5173 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005174 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005175
5176 }
5177 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5178 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5179 vosTempBuff,
5180 (WLANTL_BAPFrameEnumType)usType );
5181
5182 return VOS_TRUE;
5183 }
5184 else
5185 {
5186 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5187 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5188 usType));
5189 /*!!!FIX ME!!*/
5190 #if 0
5191 /*--------------------------------------------------------------------
5192 For data packet collect phy stats RSSI and Link Quality
5193 Calculate the RSSI average and save it. Continuous average is done.
5194 --------------------------------------------------------------------*/
5195 if ( *pFirstDataPktArrived == 0)
5196 {
5197 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5198 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5199 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5200 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5201
5202 // Rcvd 1st pkt, start average from next time
5203 *pFirstDataPktArrived = 1;
5204 }
5205 else
5206 {
5207 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5208 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5209 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5210 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5211 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5212 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5213 }/*Else, first data packet*/
5214 #endif
5215 }/*BT-AMP data packet*/
5216
5217 return VOS_FALSE;
5218}/*WLANTL_ProcessBAPFrame*/
5219
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221/*==========================================================================
5222
5223 FUNCTION WLANTL_ProcessFCFrame
5224
5225 DESCRIPTION
5226 Internal utility function for processing incoming Flow Control frames. Enable
5227 or disable LWM mode based on the information.
5228
5229 DEPENDENCIES
5230 TL must be initiailized before this function gets called.
5231 FW sends up special flow control frame.
5232
5233 PARAMETERS
5234
5235 IN
5236 pvosGCtx pointer to vos global context
5237 pvBDHeader: pointer to the BD header
5238 pTLCb: TL control block
5239 pvBDHeader pointer to BD header.
5240
5241 IN/OUT
5242 pFirstDataPktArrived: static from caller function; used for rssi
5243 computation
5244 RETURN VALUE
5245 The result code associated with performing the operation
5246
5247 VOS_STATUS_E_INVAL: Input frame are invalid
5248 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5249 page fault
5250 VOS_STATUS_SUCCESS: Everything is good :)
5251
5252 SIDE EFFECTS
5253 The ingress and egress of each station will be updated. If needed, LWM mode will
5254 be enabled or disabled based on the flow control algorithm.
5255
5256============================================================================*/
5257v_BOOL_t
5258WLANTL_ProcessFCFrame
5259(
5260 v_PVOID_t pvosGCtx,
5261 vos_pkt_t* pvosDataBuff,
5262 v_PVOID_t pvBDHeader
5263)
5264{
5265#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5266 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005267 v_U8_t ucSTAId;
5268 v_U16_t ucStaValidBitmap;
5269 v_U16_t ucStaTxDisabledBitmap;
5270 WLANTL_CbType* pTLCb = NULL;
5271 #ifdef TL_DEBUG_FC
5272 v_U32_t rxTimeStamp;
5273 v_U32_t curTick;
5274 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005276 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 ------------------------------------------------------------------------*/
5278 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5279 if ( NULL == pTLCb )
5280 {
5281 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5282 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5283 return VOS_STATUS_E_FAULT;
5284 }
Hoonki Lee14621352013-04-16 17:51:19 -07005285 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5286 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5287#ifdef TL_DEBUG_FC
5288 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5289 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5290 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005291
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee14621352013-04-16 17:51:19 -07005293 "%ld (%ld-%ld): Disabled %x Valid %x\n", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
5294 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5295#endif
5296 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 {
Hoonki Lee14621352013-04-16 17:51:19 -07005298 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5299 continue;
5300
5301 if (ucStaTxDisabledBitmap & 0x1)
5302 {
5303 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5304 }
5305 else
5306 {
5307 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 }
5310
5311#else
5312 VOS_STATUS vosStatus;
5313 tpHalFcRxBd pvFcRxBd = NULL;
5314 v_U8_t ucBitCheck = 0x1;
5315 v_U8_t ucStaValid = 0;
5316 v_U8_t ucSTAId = 0;
5317
5318 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5319 "Received FC Response");
5320 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5321 {
5322 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005323 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 return VOS_STATUS_E_FAULT;
5325 }
5326 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5327 sizeof(tHalFcRxBd));
5328
5329 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5330 {
5331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5332 "WLAN TL:wrong FC Rx packet"));
5333 return VOS_STATUS_E_INVAL;
5334 }
5335
5336 // need to swap bytes in the FC contents.
5337 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5338
5339 //logic to enable/disable LWM mode for each station
5340 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5341 {
5342 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5343 {
5344 continue;
5345 }
5346
5347 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5348 {
5349 //LWM event is reported by FW. Able to fetch more packet
5350 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5351 {
5352 //Now memory usage is below LWM. Station can send more packets.
5353 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5354 }
5355 else
5356 {
5357 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
5358 "WLAN TL: FW report LWM event but the station %d is not in LWM mode \n", ucSTAId));
5359 }
5360 }
5361
5362 //calculate uEgress_length/uIngress_length only after receiving enough packets
5363 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5364 {
5365 //check memory usage info to see whether LWM mode should be enabled for the station
5366 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5367 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5368
5369 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5370 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5371 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5372 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5373 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5374 )
5375 {
5376 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5377 "WLAN TL:Enable LWM mode for station %d\n", ucSTAId));
5378 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5379 }
5380 else
5381 {
5382 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5383 {
5384 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5385 "WLAN TL:Disable LWM mode for station %d\n", ucSTAId));
5386 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5387 }
5388
5389 }
5390
5391 //remember memory usage in FW starting from this round
5392 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5393 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5394 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5395
5396 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5397 {
5398 //always update current maximum allowed memeory usage
5399 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5400 pvFcRxBd->fcSTATxQLen[ucSTAId];
5401 }
5402
5403 }
5404#endif
5405
5406 return VOS_STATUS_SUCCESS;
5407}
Jeff Johnson295189b2012-06-20 16:38:30 -07005408
5409
5410/*==========================================================================
5411
5412 FUNCTION WLANTL_RxFrames
5413
5414 DESCRIPTION
5415 Callback registered by TL and called by BAL when a packet is received
5416 over the bus. Upon the call of this function TL will make the necessary
5417 decision with regards to the forwarding or queuing of this packet and
5418 the layer it needs to be delivered to.
5419
5420 DEPENDENCIES
5421 TL must be initiailized before this function gets called.
5422 If the frame carried is a data frame then the station for which it is
5423 destined to must have been previously registered with TL.
5424
5425 PARAMETERS
5426
5427 IN
5428 pvosGCtx: pointer to the global vos context; a handle to TL's
5429 or BAL's control block can be extracted from its context
5430
5431 vosDataBuff: it will contain a pointer to the first buffer received,
5432 if there is more then one packet they will be chained
5433 using vOSS buffers.
5434
5435 RETURN VALUE
5436 The result code associated with performing the operation
5437
5438 VOS_STATUS_E_INVAL: Input parameters are invalid
5439 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5440 page fault
5441 VOS_STATUS_SUCCESS: Everything is good :)
5442
5443 SIDE EFFECTS
5444
5445============================================================================*/
5446VOS_STATUS
5447WLANTL_RxFrames
5448(
5449 v_PVOID_t pvosGCtx,
5450 vos_pkt_t *pFrameDataBuff
5451)
5452{
5453 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5454 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305455 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 WLANTL_STAFuncType pfnSTAFsm;
5457 vos_pkt_t* vosTempBuff;
5458 v_U8_t ucSTAId;
5459 VOS_STATUS vosStatus;
5460 v_U8_t ucFrmType;
5461 v_PVOID_t pvBDHeader = NULL;
5462 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5463 v_U8_t ucTid = 0;
5464 v_BOOL_t broadcast = VOS_FALSE;
5465 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005466 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005469#ifdef FEATURE_WLAN_TDLS_INTERNAL
5470 v_U8_t ucMPDUHLen = 0 ;
5471 v_U16_t usEtherType = 0;
5472#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005473 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
5474
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5476
5477 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5478 "WLAN TL:TL Receive Frames called"));
5479
5480 /*------------------------------------------------------------------------
5481 Sanity check
5482 ------------------------------------------------------------------------*/
5483 if ( NULL == vosDataBuff )
5484 {
5485 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5486 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5487 return VOS_STATUS_E_INVAL;
5488 }
5489
5490 /*------------------------------------------------------------------------
5491 Extract TL control block
5492 ------------------------------------------------------------------------*/
5493 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5494 if ( NULL == pTLCb )
5495 {
5496 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5497 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5498 return VOS_STATUS_E_FAULT;
5499 }
5500
5501 /*---------------------------------------------------------------------
5502 Save the initial buffer - this is the first received buffer
5503 ---------------------------------------------------------------------*/
5504 vosTempBuff = vosDataBuff;
5505
5506 while ( NULL != vosTempBuff )
5507 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005508 broadcast = VOS_FALSE;
5509 selfBcastLoopback = VOS_FALSE;
5510
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5512
5513 /*---------------------------------------------------------------------
5514 Peek at BD header - do not remove
5515 !!! Optimize me: only part of header is needed; not entire one
5516 ---------------------------------------------------------------------*/
5517 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5518
5519 if ( NULL == pvBDHeader )
5520 {
5521 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5522 "WLAN TL:Cannot extract BD header"));
5523 /* Drop packet */
5524 vos_pkt_return_packet(vosTempBuff);
5525 vosTempBuff = vosDataBuff;
5526 continue;
5527 }
5528
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 /*---------------------------------------------------------------------
5530 Check if FC frame reported from FW
5531 ---------------------------------------------------------------------*/
5532 if(WDA_IS_RX_FC(pvBDHeader))
5533 {
5534 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5535 "WLAN TL:receive one FC frame"));
5536
5537 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5538 /* Drop packet */
5539 vos_pkt_return_packet(vosTempBuff);
5540 vosTempBuff = vosDataBuff;
5541 continue;
5542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005543
5544 /* AMSDU HW bug fix
5545 * After 2nd AMSDU subframe HW could not handle BD correctly
5546 * HAL workaround is needed */
5547 if(WDA_GET_RX_ASF(pvBDHeader))
5548 {
5549 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5550 }
5551
5552 /*---------------------------------------------------------------------
5553 Extract frame control field from 802.11 header if present
5554 (frame translation not done)
5555 ---------------------------------------------------------------------*/
5556
5557 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5558 pvBDHeader, &ucFrmType );
5559 if ( VOS_STATUS_SUCCESS != vosStatus )
5560 {
5561 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5562 "WLAN TL:Cannot extract Frame Control Field"));
5563 /* Drop packet */
5564 vos_pkt_return_packet(vosTempBuff);
5565 vosTempBuff = vosDataBuff;
5566 continue;
5567 }
5568
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005569#ifdef FEATURE_WLAN_TDLS_INTERNAL
5570 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5571 {
5572 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5573 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5574 }
5575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005577
5578 /*---------------------------------------------------------------------
5579 Check if management and send to PE
5580 ---------------------------------------------------------------------*/
5581
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005582 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5583#ifdef FEATURE_WLAN_TDLS_INTERNAL
5584 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5585#endif
5586 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 {
5588 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5589 "WLAN TL:Sending packet to management client"));
5590 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5591 {
5592 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5593 "WLAN TL:Cannot flatten packet - dropping"));
5594 /* Drop packet */
5595 vos_pkt_return_packet(vosTempBuff);
5596 vosTempBuff = vosDataBuff;
5597 continue;
5598 }
5599 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5600 /* Read RSSI and update */
5601 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5602 {
5603#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5604 /* Read RSSI and update */
5605 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5606 WLANTL_MGMT_FRAME_TYPE,
5607 pvBDHeader,
5608 ucSTAId,
5609 VOS_FALSE,
5610 NULL);
5611#else
5612 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5613#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305614 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5615 {
5616 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5617 "Handle RX Management Frame fail within Handoff "
5618 "support module"));
5619 /* Do Not Drop packet at here
5620 * Revisit why HO module return fail
5621 * vos_pkt_return_packet(vosTempBuff);
5622 * vosTempBuff = vosDataBuff;
5623 * continue;
5624 */
5625 }
5626 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5627
5628 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5629 {
5630 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5631 FL("Failed to Read SNR")));
5632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 }
5634
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5636 }
5637 else /* Data Frame */
5638 {
5639 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5640 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5641
5642 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5643 "WLAN TL:Data packet received for STA %d", ucSTAId));
5644
5645 /*------------------------------------------------------------------
5646 This should be corrected when multipe sta support is added !!!
5647 for now bcast frames will be sent to the last registered STA
5648 ------------------------------------------------------------------*/
5649 if ( WDA_IS_RX_BCAST(pvBDHeader))
5650 {
5651 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5652 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5653 broadcast = VOS_TRUE;
5654
5655 /*-------------------------------------------------------------------
5656 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5657 pkt we sent looping back to us. To be dropped if we are non BTAMP
5658 -------------------------------------------------------------------*/
5659 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5660 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5661 {
5662 selfBcastLoopback = VOS_TRUE;
5663 }
5664 }/*if bcast*/
5665
5666 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5667 {
5668 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5669 "WLAN TL:STA ID invalid - dropping pkt"));
5670 /* Drop packet */
5671 vos_pkt_return_packet(vosTempBuff);
5672 vosTempBuff = vosDataBuff;
5673 continue;
5674 }
5675
5676 /*----------------------------------------------------------------------
5677 No need to lock cache access because cache manipulation only happens
5678 in the transport thread/task context
5679 - These frames are to be forwarded to the station upon registration
5680 which happens in the main thread context
5681 The caching here can happen in either Tx or Rx thread depending
5682 on the current SSC scheduling
5683 - also we need to make sure that the frames in the cache are fwd-ed to
5684 the station before the new incoming ones
5685 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305686 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5687 if (NULL == pClientSTA)
5688 {
5689 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5690 "WLAN TL:STA not allocated memory. Dropping packet"));
5691 vos_pkt_return_packet(vosTempBuff);
5692 vosTempBuff = vosDataBuff;
5693 continue;
5694 }
5695
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005696#ifdef FEATURE_WLAN_TDLS
5697 if (( pClientSTA->ucExists ) &&
5698 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5699 (pClientSTA->ucTxSuspended))
5700 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5701 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5702 {
5703 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5704
5705 /* from the direct peer while it is not registered to TL yet */
5706 if ( (pMacHeader->fc.fromDS == 0) &&
5707 (pMacHeader->fc.toDS == 0) )
5708 {
5709 v_U8_t ucAddr3STAId;
5710
5711 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5712
5713 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5714 {
5715 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5716 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5717 /* Drop packet */
5718 vos_pkt_return_packet(vosTempBuff);
5719 vosTempBuff = vosDataBuff;
5720 continue;
5721 }
5722
5723 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5724 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5725 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5726 {
5727 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5728 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet\n", __func__,
5729 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5730 vos_pkt_return_packet(vosTempBuff);
5731 vosTempBuff = vosDataBuff;
5732 continue;
5733 }
5734 else
5735 {
5736 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5737 "%s: staId %d doesn't exist, but mapped to AP staId %d \n", __func__,
5738 ucSTAId, ucAddr3STAId));
5739 ucSTAId = ucAddr3STAId;
5740 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5741 }
5742 }
5743 }
5744#endif
5745
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305746 if ((( 0 == pClientSTA->ucExists ) ||
5747 ( (0 != pClientSTA->ucRxBlocked)
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 ///@@@: xg: no checking in SOFTAP for now, will revisit later
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305749 && (WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 ) ||
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305751 ( WLANTL_STA_DISCONNECTED == pClientSTA->tlState)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5753 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5754 * So it will lead to low resource condition in Rx Data Path.*/
5755 ((WDA_IS_RX_BCAST(pvBDHeader) == 0)))
5756 {
5757 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5758 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005759 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5760 "%s: staId %d exist %d tlState %d cache rx frame \n", __func__, ucSTAId,
5761 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5763 vosTempBuff = vosDataBuff;
5764 continue;
5765 }
5766
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005767#ifdef FEATURE_WLAN_CCX_UPLOAD
5768 if ((pClientSTA->wSTADesc.ucIsCcxSta)|| broadcast)
5769 {
5770 /*--------------------------------------------------------------------
5771 Filter the IAPP frames for CCX connection;
5772 if data it will return false and it
5773 will be routed through the regular data path
5774 --------------------------------------------------------------------*/
5775 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5776 vosTempBuff))
5777 {
5778 bForwardIAPPwithLLC = VOS_TRUE;
5779 }
5780 }
5781#endif
5782
5783#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305784 if ((pClientSTA->wSTADesc.ucIsCcxSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 {
5786 /*--------------------------------------------------------------------
5787 Filter the IAPP frames for CCX connection;
5788 if data it will return false and it
5789 will be routed through the regular data path
5790 --------------------------------------------------------------------*/
5791 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5792 vosTempBuff))
5793 {
5794 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5795 {
5796 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5797 "WLAN TL:Cannot flatten packet - dropping"));
5798 /* Drop packet */
5799 vos_pkt_return_packet(vosTempBuff);
5800 } else {
5801
5802 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5803 "WLAN TL: Received CCX IAPP Frame"));
5804
5805 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5806 }
5807 vosTempBuff = vosDataBuff;
5808 continue;
5809 }
5810 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005811#endif /* defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005812
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305813 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 {
5815 /*--------------------------------------------------------------------
5816 Process the ctrl BAP frame; if data it will return false and it
5817 will be routed through the regular data path
5818 --------------------------------------------------------------------*/
5819 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5820 vosTempBuff,
5821 pTLCb,
5822 &first_data_pkt_arrived,
5823 ucSTAId))
5824 {
5825 vosTempBuff = vosDataBuff;
5826 continue;
5827 }
5828 }/*if BT-AMP station*/
5829 else if(selfBcastLoopback == VOS_TRUE)
5830 {
5831 /* Drop packet */
5832 vos_pkt_return_packet(vosTempBuff);
5833 vosTempBuff = vosDataBuff;
5834 continue;
5835 }
5836
5837 /*---------------------------------------------------------------------
5838 Data packet received, send to state machine
5839 ---------------------------------------------------------------------*/
5840 wSTAEvent = WLANTL_RX_EVENT;
5841
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305842 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 pfnSTATbl[wSTAEvent];
5844
5845 if ( NULL != pfnSTAFsm )
5846 {
5847#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5848 /* Read RSSI and update */
5849 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5850 WLANTL_DATA_FRAME_TYPE,
5851 pvBDHeader,
5852 ucSTAId,
5853 broadcast,
5854 vosTempBuff);
5855 broadcast = VOS_FALSE;
5856#else
5857 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5858#endif /*FEATURE_WLAN_GEN6_ROAMING*/
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305859 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 {
5861 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5862 "Handle RX Data Frame fail within Handoff support module"));
5863 /* Do Not Drop packet at here
5864 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305865 * vos_pkt_return_packet(vosTempBuff);
5866 * vosTempBuff = vosDataBuff;
5867 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 */
5869 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305870 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5871
5872 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5873 {
5874 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5875 FL("Failed to Read SNR")));
5876 }
5877
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005878 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 }
5880 else
5881 {
5882 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5883 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305884 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 /* Drop packet */
5886 vos_pkt_return_packet(vosTempBuff);
5887 vosTempBuff = vosDataBuff;
5888 continue;
5889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 }/* else data frame*/
5891
5892 vosTempBuff = vosDataBuff;
5893 }/*while chain*/
5894
5895 return VOS_STATUS_SUCCESS;
5896}/* WLANTL_RxFrames */
5897
5898
5899/*==========================================================================
5900
5901 FUNCTION WLANTL_RxCachedFrames
5902
5903 DESCRIPTION
5904 Utility function used by TL to forward the cached frames to a particular
5905 station;
5906
5907 DEPENDENCIES
5908 TL must be initiailized before this function gets called.
5909 If the frame carried is a data frame then the station for which it is
5910 destined to must have been previously registered with TL.
5911
5912 PARAMETERS
5913
5914 IN
5915 pTLCb: pointer to TL handle
5916
5917 ucSTAId: station for which we need to forward the packets
5918
5919 vosDataBuff: it will contain a pointer to the first cached buffer
5920 received, if there is more then one packet they will be
5921 chained using vOSS buffers.
5922
5923 RETURN VALUE
5924 The result code associated with performing the operation
5925
5926 VOS_STATUS_E_INVAL: Input parameters are invalid
5927 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5928 page fault
5929 VOS_STATUS_SUCCESS: Everything is good :)
5930
5931 SIDE EFFECTS
5932
5933============================================================================*/
5934VOS_STATUS
5935WLANTL_RxCachedFrames
5936(
5937 WLANTL_CbType* pTLCb,
5938 v_U8_t ucSTAId,
5939 vos_pkt_t* vosDataBuff
5940)
5941{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305942 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 WLANTL_STAFuncType pfnSTAFsm;
5944 vos_pkt_t* vosTempBuff;
5945 VOS_STATUS vosStatus;
5946 v_PVOID_t pvBDHeader = NULL;
5947 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5948 v_U8_t ucTid = 0;
5949 v_BOOL_t broadcast = VOS_FALSE;
5950 v_BOOL_t bSigMatch = VOS_FALSE;
5951 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005952 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 v_U32_t uDPUSig;
5954 v_U8_t ucUcastSig;
5955 v_U8_t ucBcastSig;
5956 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5957
5958 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5959 "WLAN TL:TL Receive Cached Frames called"));
5960
5961 /*------------------------------------------------------------------------
5962 Sanity check
5963 ------------------------------------------------------------------------*/
5964 if ( NULL == vosDataBuff )
5965 {
5966 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5967 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5968 return VOS_STATUS_E_INVAL;
5969 }
5970
5971 /*---------------------------------------------------------------------
5972 Save the initial buffer - this is the first received buffer
5973 ---------------------------------------------------------------------*/
5974 vosTempBuff = vosDataBuff;
5975
5976 while ( NULL != vosTempBuff )
5977 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005978 broadcast = VOS_FALSE;
5979 selfBcastLoopback = VOS_FALSE;
5980
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5982
5983 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5984 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
5985 /*---------------------------------------------------------------------
5986 Peek at BD header - do not remove
5987 !!! Optimize me: only part of header is needed; not entire one
5988 ---------------------------------------------------------------------*/
5989 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
5990
5991 if ( NULL == pvBDHeader )
5992 {
5993 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5994 "WLAN TL:Cannot extract BD header"));
5995 /* Drop packet */
5996 vos_pkt_return_packet(vosTempBuff);
5997 vosTempBuff = vosDataBuff;
5998 continue;
5999 }
6000
6001 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6002
6003 /* AMSDU HW bug fix
6004 * After 2nd AMSDU subframe HW could not handle BD correctly
6005 * HAL workaround is needed */
6006 if(WDA_GET_RX_ASF(pvBDHeader))
6007 {
6008 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6009 pvBDHeader);
6010 }
6011
6012 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6013
6014 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6015 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6016
6017 /*------------------------------------------------------------------
6018 This should be corrected when multipe sta support is added !!!
6019 for now bcast frames will be sent to the last registered STA
6020 ------------------------------------------------------------------*/
6021 if ( WDA_IS_RX_BCAST(pvBDHeader))
6022 {
6023 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6024 "WLAN TL:TL rx Bcast frame "));
6025 broadcast = VOS_TRUE;
6026
6027 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6028 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6029 */
6030 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6031 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6032 {
6033 selfBcastLoopback = VOS_TRUE;
6034 }
6035 }/*if bcast*/
6036
6037 /*-------------------------------------------------------------------------
6038 Check if the packet that we cached matches the DPU signature of the
6039 newly added station
6040 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306041 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6042
6043
6044 if ( NULL == pClientSTA )
6045 {
6046 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6047 "WLAN TL:Client Memory was not allocated on %s", __func__));
6048 return VOS_STATUS_E_FAILURE;
6049 }
6050
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 if ( broadcast )
6052 {
6053 ucBcastSig = (v_U8_t)uDPUSig;
6054 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306055 pClientSTA->wSTADesc.ucBcastSig ) &&
6056 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 }
6058 else
6059 {
6060 ucUcastSig = (v_U8_t)uDPUSig;
6061 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306062 pClientSTA->wSTADesc.ucUcastSig ) &&
6063 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 }
6065
6066 /*-------------------------------------------------------------------------
6067 If the packet doesn't match - drop it
6068 -------------------------------------------------------------------------*/
6069 if ( !bSigMatch )
6070 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006071 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6073 " DPU Sig %d UC %d BC %d B %d",
6074 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306075 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006076 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 broadcast));
6078
6079 /* Drop packet */
6080 vos_pkt_return_packet(vosTempBuff);
6081 vosTempBuff = vosDataBuff;
6082 continue;
6083
6084 }/*if signature mismatch*/
6085
6086 /*------------------------------------------------------------------------
6087 Check if BT-AMP frame:
6088 - additional processing needed in this case to separate BT-AMP date
6089 from BT-AMP Ctrl path
6090 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306091 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 {
6093 /*--------------------------------------------------------------------
6094 Process the ctrl BAP frame; if data it will return false and it
6095 will be routed through the regular data path
6096 --------------------------------------------------------------------*/
6097 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6098 vosTempBuff,
6099 pTLCb,
6100 &first_data_pkt_arrived,
6101 ucSTAId))
6102 {
6103 vosTempBuff = vosDataBuff;
6104 continue;
6105 }
6106 }/*if BT-AMP station*/
6107 else if(selfBcastLoopback == VOS_TRUE)
6108 {
6109 /* Drop packet */
6110 vos_pkt_return_packet(vosTempBuff);
6111 vosTempBuff = vosDataBuff;
6112 continue;
6113 }
6114
6115 /*---------------------------------------------------------------------
6116 Data packet received, send to state machine
6117 ---------------------------------------------------------------------*/
6118 wSTAEvent = WLANTL_RX_EVENT;
6119
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306120 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 pfnSTATbl[wSTAEvent];
6122
6123 if ( NULL != pfnSTAFsm )
6124 {
6125#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6126 /* Read RSSI and update */
6127 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6128 VOS_MODULE_ID_TL,pTLCb),
6129 WLANTL_DATA_FRAME_TYPE,
6130 pvBDHeader,
6131 ucSTAId,
6132 broadcast,
6133 vosTempBuff);
6134 broadcast = VOS_FALSE;
6135#else
6136 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
6137#endif /*FEATURE_WLAN_GEN6_ROAMING*/
6138 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6139 {
6140 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6141 "Handle RX Data Frame fail within Handoff support module"));
6142 /* Do Not Drop packet at here
6143 * Revisit why HO module return fail
6144 vos_pkt_return_packet(vosTempBuff);
6145 vosTempBuff = vosDataBuff;
6146 continue;
6147 */
6148 }
6149 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006150 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 }
6152 else
6153 {
6154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6155 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306156 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 /* Drop packet */
6158 vos_pkt_return_packet(vosTempBuff);
6159 vosTempBuff = vosDataBuff;
6160 continue;
6161 }
6162
6163 vosTempBuff = vosDataBuff;
6164 }/*while chain*/
6165
6166 return VOS_STATUS_SUCCESS;
6167}/* WLANTL_RxCachedFrames */
6168
6169/*==========================================================================
6170 FUNCTION WLANTL_ResourceCB
6171
6172 DESCRIPTION
6173 Called by the TL when it has packets available for transmission.
6174
6175 DEPENDENCIES
6176 The TL must be registered with BAL before this function can be called.
6177
6178 PARAMETERS
6179
6180 IN
6181 pvosGCtx: pointer to the global vos context; a handle to TL's
6182 or BAL's control block can be extracted from its context
6183
6184 RETURN VALUE
6185 The result code associated with performing the operation
6186
6187 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6188 page fault
6189 VOS_STATUS_SUCCESS: Everything is good :)
6190
6191 SIDE EFFECTS
6192
6193============================================================================*/
6194VOS_STATUS
6195WLANTL_ResourceCB
6196(
6197 v_PVOID_t pvosGCtx,
6198 v_U32_t uCount
6199)
6200{
6201 WLANTL_CbType* pTLCb = NULL;
6202 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6203
6204 /*------------------------------------------------------------------------
6205 Sanity check
6206 Extract TL control block
6207 ------------------------------------------------------------------------*/
6208 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6209 if ( NULL == pTLCb )
6210 {
6211 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6212 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6213 return VOS_STATUS_E_FAULT;
6214 }
6215
6216 pTLCb->uResCount = uCount;
6217
6218
6219 /*-----------------------------------------------------------------------
6220 Resume Tx if enough res and not suspended
6221 -----------------------------------------------------------------------*/
6222 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6223 ( 0 == pTLCb->ucTxSuspended ))
6224 {
6225 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6226 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6227 return WDA_DS_StartXmit(pvosGCtx);
6228 }
6229
6230 return VOS_STATUS_SUCCESS;
6231}/* WLANTL_ResourceCB */
6232
6233
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006234/*==========================================================================
6235 FUNCTION WLANTL_IsTxXmitPending
6236
6237 DESCRIPTION
6238 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6239 is pending in TL msg queue
6240
6241 DEPENDENCIES
6242 The TL must be registered with WDA before this function can be called.
6243
6244 PARAMETERS
6245
6246 IN
6247 pvosGCtx: pointer to the global vos context; a handle to TL's
6248 or WDA's control block can be extracted from its context
6249
6250 RETURN VALUE
6251 The result code associated with performing the operation
6252
6253 0: No WDA_DS_TX_START_XMIT msg pending
6254 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6255
6256 SIDE EFFECTS
6257
6258============================================================================*/
6259v_BOOL_t
6260WLANTL_IsTxXmitPending
6261(
6262 v_PVOID_t pvosGCtx
6263)
6264{
6265
6266 WLANTL_CbType* pTLCb = NULL;
6267 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6268
6269 /*------------------------------------------------------------------------
6270 Sanity check
6271 Extract TL control block
6272 ------------------------------------------------------------------------*/
6273 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6274 if ( NULL == pTLCb )
6275 {
6276 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6277 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6278 return FALSE;
6279 }
6280
6281 return pTLCb->isTxTranmitMsgPending;
6282
6283}/*WLANTL_IsTxXmitPending */
6284
6285/*==========================================================================
6286 FUNCTION WLANTL_SetTxXmitPending
6287
6288 DESCRIPTION
6289 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6290 is pending in TL msg queue
6291
6292 DEPENDENCIES
6293 The TL must be registered with WDA before this function can be called.
6294
6295 PARAMETERS
6296
6297 IN
6298 pvosGCtx: pointer to the global vos context; a handle to TL's
6299 or WDA's control block can be extracted from its context
6300
6301 RETURN VALUE None
6302
6303 SIDE EFFECTS
6304
6305============================================================================*/
6306
6307v_VOID_t
6308WLANTL_SetTxXmitPending
6309(
6310 v_PVOID_t pvosGCtx
6311)
6312{
6313
6314 WLANTL_CbType* pTLCb = NULL;
6315 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6316
6317 /*------------------------------------------------------------------------
6318 Sanity check
6319 Extract TL control block
6320 ------------------------------------------------------------------------*/
6321 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6322 if ( NULL == pTLCb )
6323 {
6324 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6325 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6326 return;
6327 }
6328
6329 pTLCb->isTxTranmitMsgPending = 1;
6330 return;
6331
6332}/*WLANTL_SetTxXmitPending */
6333
6334/*==========================================================================
6335 FUNCTION WLANTL_ClearTxXmitPending
6336
6337 DESCRIPTION
6338 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6339 is pending in TL msg queue
6340
6341 DEPENDENCIES
6342 The TL must be registered with WDA before this function can be called.
6343
6344 PARAMETERS
6345
6346 IN
6347 pvosGCtx: pointer to the global vos context; a handle to TL's
6348 or WDA's control block can be extracted from its context
6349
6350 RETURN VALUE None
6351
6352 SIDE EFFECTS
6353
6354============================================================================*/
6355
6356v_VOID_t
6357WLANTL_ClearTxXmitPending
6358(
6359 v_PVOID_t pvosGCtx
6360)
6361{
6362
6363 WLANTL_CbType* pTLCb = NULL;
6364 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6365
6366 /*------------------------------------------------------------------------
6367 Sanity check
6368 Extract TL control block
6369 ------------------------------------------------------------------------*/
6370 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6371 if ( NULL == pTLCb )
6372 {
6373 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6374 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6375 return;
6376 }
6377
6378 pTLCb->isTxTranmitMsgPending = 0;
6379 return;
6380}/*WLANTL_ClearTxXmitPending */
6381
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306382/*==========================================================================
6383 FUNCTION WLANTL_TxThreadDebugHandler
6384
6385 DESCRIPTION
6386 Printing TL Snapshot dump, processed under TxThread context, currently
6387 information regarding the global TlCb struture. Dumps information related
6388 to per active STA connection currently in use by TL.
6389
6390 DEPENDENCIES
6391 The TL must be initialized before this gets called.
6392
6393 PARAMETERS
6394
6395 IN
6396 pvosGCtx: pointer to the global vos context; a handle to TL's
6397 or WDA's control block can be extracted from its context
6398
6399 RETURN VALUE None
6400
6401 SIDE EFFECTS
6402
6403============================================================================*/
6404
6405v_VOID_t
6406WLANTL_TxThreadDebugHandler
6407(
6408 v_PVOID_t *pVosContext
6409)
6410{
6411 WLANTL_CbType* pTLCb = NULL;
6412 WLANTL_STAClientType* pClientSTA = NULL;
6413 int i = 0;
6414 tWDA_CbContext *pWDA = NULL;
6415
6416 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6417 "WLAN TL: %s Enter ", __func__));
6418
6419 pTLCb = VOS_GET_TL_CB(pVosContext);
6420 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6421
6422 if ( NULL == pVosContext || NULL == pTLCb )
6423 {
6424 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6425 "Global VoS Context or TL Context are NULL"));
6426 return;
6427 }
6428
6429 if (NULL != pWDA)
6430 {
6431 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6432 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6433 }
6434 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6435 "************************TL DUMP INFORMATION**************"));
6436
6437 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6438 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6439 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6440 pTLCb->tlConfigInfo.uMinFramesProcThres));
6441
6442 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6443 "Management Frame Client exists: %d",
6444 pTLCb->tlMgmtFrmClient.ucExists));
6445 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6446 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6447 pTLCb->usPendingTxCompleteCount,
6448 pTLCb->ucTxSuspended));
6449
6450 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6451 "uResCount: %d", pTLCb->uResCount));
6452
6453 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6454 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6455 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6456
6457 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6458 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6459 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6460
6461 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6462 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6463 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6464
6465#ifdef FEATURE_WLAN_TDLS
6466 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6467 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6468#endif
6469
6470 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6471 "++++++++++++++++++++Registerd Client Information++++++++++"));
6472
6473 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6474 {
6475 pClientSTA = pTLCb->atlSTAClients[i];
6476 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6477 {
6478 continue;
6479 }
6480
6481 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6482 "######################STA Index: %d ############################",i));
6483 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6484 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6485 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6486 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6487 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6488 "STA Type: %d\tProtectedFrame: %d",
6489 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6490 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6491 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6492 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6493 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6494 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6495 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6496 pClientSTA->wSTADesc.ucBcastSig));
6497
6498 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6499 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6500 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6501 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6502 pClientSTA->tlPri));
6503 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6504 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6505 pClientSTA->ucPktPending));
6506 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6507 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6508 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6509 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6510 "ucRxBlocked: %d\t fcStaTxDisabled: %d", pClientSTA->ucRxBlocked,
6511 pClientSTA->fcStaTxDisabled));
6512 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6513 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6514 pClientSTA->ucServicedAC));
6515 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6516 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6517 pClientSTA->auRxCount[0]));
6518 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6519 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6520 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6521 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6522 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6523 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6524
6525 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6526 {
6527 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6528 "TrafficStatistics for SOFTAP Station:"));
6529 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6530 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6531 pClientSTA->trafficStatistics.rxMCFcnt,
6532 pClientSTA->trafficStatistics.rxBCFcnt));
6533 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6534 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6535 pClientSTA->trafficStatistics.rxMCBcnt,
6536 pClientSTA->trafficStatistics.rxBCBcnt));
6537 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6538 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6539 pClientSTA->trafficStatistics.txMCFcnt,
6540 pClientSTA->trafficStatistics.txBCFcnt));
6541 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6542 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6543 pClientSTA->trafficStatistics.txMCBcnt,
6544 pClientSTA->trafficStatistics.txBCBcnt));
6545 }
6546 }
6547 return;
6548}
6549
6550/*==========================================================================
6551 FUNCTION WLANTL_TLDebugMessage
6552
6553 DESCRIPTION
6554 Post a TL Snapshot request, posts message in TxThread.
6555
6556 DEPENDENCIES
6557 The TL must be initialized before this gets called.
6558
6559 PARAMETERS
6560
6561 IN
6562 displaySnapshot Boolean showing whether to dump the snapshot or not.
6563
6564 RETURN VALUE None
6565
6566 SIDE EFFECTS
6567
6568============================================================================*/
6569
6570v_VOID_t
6571WLANTL_TLDebugMessage
6572(
6573 v_BOOL_t displaySnapshot
6574)
6575{
6576 vos_msg_t vosMsg;
6577 VOS_STATUS status;
6578
6579 if(displaySnapshot)
6580 {
6581 vosMsg.reserved = 0;
6582 vosMsg.bodyptr = NULL;
6583 vosMsg.type = WLANTL_TX_SNAPSHOT;
6584
6585 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6586 if(status != VOS_STATUS_SUCCESS)
6587 {
6588 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
6589 return;
6590 }
6591 }
6592 return;
6593}
Jeff Johnson295189b2012-06-20 16:38:30 -07006594
6595/*============================================================================
6596 TL STATE MACHINE
6597============================================================================*/
6598
6599/*==========================================================================
6600 FUNCTION WLANTL_STATxConn
6601
6602 DESCRIPTION
6603 Transmit in connected state - only EAPOL and WAI packets allowed
6604
6605 DEPENDENCIES
6606 The STA must be registered with TL before this function can be called.
6607
6608 PARAMETERS
6609
6610 IN
6611 pvosGCtx: pointer to the global vos context; a handle to TL's
6612 control block can be extracted from its context
6613 ucSTAId: identifier of the station being processed
6614 vosDataBuff: pointer to the tx vos buffer
6615
6616 RETURN VALUE
6617 The result code associated with performing the operation
6618
6619 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6620 page fault
6621 VOS_STATUS_SUCCESS: Everything is good :)
6622
6623 Other return values are possible coming from the called functions.
6624 Please check API for additional info.
6625
6626 SIDE EFFECTS
6627
6628============================================================================*/
6629VOS_STATUS
6630WLANTL_STATxConn
6631(
6632 v_PVOID_t pvosGCtx,
6633 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006634 vos_pkt_t** pvosDataBuff,
6635 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07006636)
6637{
6638 v_U16_t usPktLen;
6639 VOS_STATUS vosStatus;
6640 v_MACADDR_t vDestMacAddr;
6641 vos_pkt_t* vosDataBuff = NULL;
6642 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306643 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 WLANTL_MetaInfoType tlMetaInfo;
6645 v_U8_t ucTypeSubtype = 0;
6646 v_U8_t ucTid;
6647 v_U8_t extraHeadSpace = 0;
6648 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006649 v_U8_t ucAC, ucACMask, i;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306650 v_U8_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6652
6653 /*------------------------------------------------------------------------
6654 Sanity check
6655 Extract TL control block
6656 ------------------------------------------------------------------------*/
6657 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6658 if ( NULL == pTLCb )
6659 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006660 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6661 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 *pvosDataBuff = NULL;
6663 return VOS_STATUS_E_FAULT;
6664 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306665 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6666
6667 if ( NULL == pClientSTA )
6668 {
6669 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6670 "WLAN TL:Client Memory was not allocated on %s", __func__));
6671 return VOS_STATUS_E_FAILURE;
6672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006673
6674 /*-------------------------------------------------------------------
6675 Disable AC temporary - if successfull retrieve re-enable
6676 The order is justified because of the possible scenario
6677 - TL tryes to fetch packet for AC and it returns NULL
6678 - TL analyzes the data it has received to see if there are
6679 any more pkts available for AC -> if not TL will disable AC
6680 - however it is possible that while analyzing results TL got
6681 preempted by a pending indication where the mask was again set
6682 TL will not check again and as a result when it resumes
6683 execution it will disable AC
6684 To prevent this the AC will be disabled here and if retrieve
6685 is successfull it will be re-enabled
6686 -------------------------------------------------------------------*/
6687
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006688
6689 //LTI:pTLCb->atlSTAClients[ucSTAId].
6690 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
6691
6692 /*------------------------------------------------------------------------
6693 Fetch packet from HDD
6694 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006695#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306696 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006697 (!vos_concurrent_sessions_running()) &&
6698 !pTLCb->ucTdlsPeerCount)
6699 {
6700#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306701 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006702 (!vos_concurrent_sessions_running()))
6703 {
Sunil Ravid5406f22013-01-22 00:18:31 -08006704#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306705 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006706
6707 /*-------------------------------------------------------------------
6708 Disable AC temporary - if successfull retrieve re-enable
6709 The order is justified because of the possible scenario
6710 - TL tryes to fetch packet for AC and it returns NULL
6711 - TL analyzes the data it has received to see if there are
6712 any more pkts available for AC -> if not TL will disable AC
6713 - however it is possible that while analyzing results TL got
6714 preempted by a pending indication where the mask was again set
6715 TL will not check again and as a result when it resumes
6716 execution it will disable AC
6717 To prevent this the AC will be disabled here and if retrieve
6718 is successfull it will be re-enabled
6719 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306720 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006721 }
6722 else
6723 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306724 //softap case
6725 ucAC = pTLCb->uCurServedAC;
6726 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006728
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306729 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306731 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306733 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6734 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
6735 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
6736 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306737 /*You make an initial assumption that HDD has no more data and if the
6738 assumption was wrong you reset the flags to their original state
6739 This will prevent from exposing a race condition between checking with HDD
6740 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006741 if ( 0 == ucACMask )
6742 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306743 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006744 }
6745 else
6746 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306747 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006748 }
6749
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006750
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006751 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006752 "WLAN TL: WLANTL_STATxConn fetching packet from HDD for AC: %d AC Mask: %d Pkt Pending: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306753 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07006754
6755 /*------------------------------------------------------------------------
6756 Fetch tx packet from HDD
6757 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006758//LTI
6759#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 if (WLAN_STA_SOFTAP != pTLCb->atlSTAClients[ucSTAId].wSTADesc.wSTAType &&
6761 (!vos_concurrent_sessions_running()))
6762 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 // don't set 0.
6764 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6765 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6766 &ucSTAId,
6767 pTLCb->atlSTAClients[ucSTAId].ucCurrentAC,
6768 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 }
6770 else
6771 {
6772 //softap case
6773 WLANTL_ACEnumType ucAC = pTLCb->uCurServedAC;
6774 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6775 &ucSTAId,
6776 ucAC,
6777 &vosDataBuff, &tlMetaInfo );
6778 }
6779#endif
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006780
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306781 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006782 &ucSTAId,
6783 ucAC,
6784 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006785
6786 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
6787 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006788 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 "WLAN TL:No more data at HDD status %d", vosStatus));
6790 *pvosDataBuff = NULL;
6791
6792 /*--------------------------------------------------------------------
6793 Reset AC for the serviced station to the highest priority AC
6794 -> due to no more data at the station
6795 Even if this AC is not supported by the station, correction will be
6796 made in the main TL loop
6797 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306798 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
6799 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006800
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08006801 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006802 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
6803 ucAC, ucACMask);
6804
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 return vosStatus;
6806 }
6807
6808 /*There are still packets in HDD - set back the pending packets and
6809 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306810 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
6811 pClientSTA->ucNoMoreData = 0;
6812 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006813
Jeff Johnson295189b2012-06-20 16:38:30 -07006814#ifdef WLAN_PERF
6815 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
6816 (v_PVOID_t)0);
6817
6818#endif /*WLAN_PERF*/
6819
6820
6821#ifdef FEATURE_WLAN_WAPI
6822 /*------------------------------------------------------------------------
6823 If the packet is neither an Eapol packet nor a WAI packet then drop it
6824 ------------------------------------------------------------------------*/
6825 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
6826 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006827 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006828 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
6829
6830 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306831 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 VOS_STATUS_E_BADMSG);
6833 vosDataBuff = NULL;
6834 *pvosDataBuff = NULL;
6835 return VOS_STATUS_SUCCESS;
6836 }
6837#else
6838 if ( 0 == tlMetaInfo.ucIsEapol )
6839 {
6840 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6841 "WLAN TL:Received non EAPOL packet before authentication"));
6842
6843 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306844 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 VOS_STATUS_E_BADMSG);
6846 vosDataBuff = NULL;
6847 *pvosDataBuff = NULL;
6848 return VOS_STATUS_SUCCESS;
6849 }
6850#endif /* FEATURE_WLAN_WAPI */
6851
6852 /*-------------------------------------------------------------------------
6853 Check TID
6854 -------------------------------------------------------------------------*/
6855 ucTid = tlMetaInfo.ucTID;
6856
6857 /*Make sure TID is valid*/
6858 if ( WLANTL_TID_INVALID(ucTid))
6859 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07006860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
6862 ucTid));
6863 ucTid = 0;
6864 }
6865
6866 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6867 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
6868
6869#ifdef FEATURE_WLAN_WAPI
6870 /*------------------------------------------------------------------------
6871 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
6872 frame is a WAI frame.
6873 ------------------------------------------------------------------------*/
6874 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
6875 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
6876#else
6877 /*------------------------------------------------------------------------
6878 Translate 802.3 frame to 802.11 if Frame translation is enabled
6879 ------------------------------------------------------------------------*/
6880 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306881 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006882#endif //#ifdef FEATURE_WLAN_WAPI
6883 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08006884 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
6885 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07006886 &tlMetaInfo, &ucWDSEnabled,
6887 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 if ( VOS_STATUS_SUCCESS != vosStatus )
6889 {
6890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6891 "WLAN TL:Error when translating header WLANTL_STATxConn"));
6892
6893 return vosStatus;
6894 }
6895
6896 tlMetaInfo.ucDisableFrmXtl = 1;
6897 }
6898
6899 /*-------------------------------------------------------------------------
6900 Call HAL to fill BD header
6901 -------------------------------------------------------------------------*/
6902 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
6903
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306904 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 {
6906 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
6907 }
6908
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306909#ifdef FEATURE_WLAN_WAPI
6910 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
6911 * case of WPA where GTK handshake is done after the 4 way handshake, the
6912 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
6913 * the TL is in authenticated state. Since the PTK has been installed
6914 * already (after the 4 way handshake) we make sure that all traffic
6915 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
6916 * we will only allow EAPOL data or WAI in case of WAPI)
6917 */
6918 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
6919 {
6920 txFlag = 0;
6921 }
6922#else
6923 if (pClientSTA->ptkInstalled)
6924 {
6925 txFlag = 0;
6926 }
6927#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006928
6929 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
6930 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306931 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306933 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306934 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07006935 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07006936
6937 if ( VOS_STATUS_SUCCESS != vosStatus )
6938 {
6939 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6940 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
6941 *pvosDataBuff = NULL;
6942 return vosStatus;
6943 }
6944
6945 /*-----------------------------------------------------------------------
6946 Update tx counter for BA session query for tx side
6947 !1 - should this be done for EAPOL frames?
6948 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306949 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07006950
6951 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306952 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07006953
6954 /*------------------------------------------------------------------------
6955 Save data to input pointer for TL core
6956 ------------------------------------------------------------------------*/
6957 *pvosDataBuff = vosDataBuff;
6958 /*security frames cannot be delayed*/
6959 pTLCb->bUrgent = TRUE;
6960
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 /* TX Statistics */
6962 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
6963 {
6964 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306965 pClientSTA->trafficStatistics.txUCFcnt++;
6966 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006968
6969 return VOS_STATUS_SUCCESS;
6970}/* WLANTL_STATxConn */
6971
6972
6973/*==========================================================================
6974 FUNCTION WLANTL_STATxAuth
6975
6976 DESCRIPTION
6977 Transmit in authenticated state - all data allowed
6978
6979 DEPENDENCIES
6980 The STA must be registered with TL before this function can be called.
6981
6982 PARAMETERS
6983
6984 IN
6985 pvosGCtx: pointer to the global vos context; a handle to TL's
6986 control block can be extracted from its context
6987 ucSTAId: identifier of the station being processed
6988 vosDataBuff: pointer to the tx vos buffer
6989
6990 RETURN VALUE
6991 The result code associated with performing the operation
6992
6993 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6994 page fault
6995 VOS_STATUS_SUCCESS: Everything is good :)
6996
6997 Other return values are possible coming from the called functions.
6998 Please check API for additional info.
6999
7000 SIDE EFFECTS
7001
7002============================================================================*/
7003VOS_STATUS
7004WLANTL_STATxAuth
7005(
7006 v_PVOID_t pvosGCtx,
7007 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007008 vos_pkt_t** pvosDataBuff,
7009 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007010)
7011{
7012 v_U16_t usPktLen;
7013 VOS_STATUS vosStatus;
7014 v_MACADDR_t vDestMacAddr;
7015 vos_pkt_t* vosDataBuff = NULL;
7016 WLANTL_CbType* pTLCb = NULL;
7017 WLANTL_MetaInfoType tlMetaInfo;
7018 v_U8_t ucTypeSubtype = 0;
7019 WLANTL_ACEnumType ucAC;
7020 WLANTL_ACEnumType ucNextAC;
7021 v_U8_t ucTid;
7022 v_U8_t ucSwFrmXtl = 0;
7023 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307024 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 v_U8_t ucWDSEnabled = 0;
7026 v_U8_t ucTxFlag = 0;
7027 v_U8_t ucACMask, i;
7028 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7029
7030 /*------------------------------------------------------------------------
7031 Sanity check
7032 Extract TL control block
7033 ------------------------------------------------------------------------*/
7034 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7035 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7036 {
7037 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007038 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 pTLCb, pvosDataBuff));
7040 if (NULL != pvosDataBuff)
7041 {
7042 *pvosDataBuff = NULL;
7043 }
7044 if(NULL != pTLCb)
7045 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307046 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7047 {
7048 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7049 "WLAN TL:Client Memory was not allocated on %s", __func__));
7050 return VOS_STATUS_E_FAILURE;
7051 }
7052 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 }
7054 return VOS_STATUS_E_FAULT;
7055 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307056 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007057
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307058 if ( NULL == pStaClient )
7059 {
7060 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7061 "WLAN TL:Client Memory was not allocated on %s", __func__));
7062 return VOS_STATUS_E_FAILURE;
7063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007064
7065 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7066 /*------------------------------------------------------------------------
7067 Fetch packet from HDD
7068 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007069#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307070 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007071 (!vos_concurrent_sessions_running()) &&
7072 !pTLCb->ucTdlsPeerCount)
7073 {
7074#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
7076 (!vos_concurrent_sessions_running()))
7077 {
7078#endif
7079 ucAC = pStaClient->ucCurrentAC;
7080
7081 /*-------------------------------------------------------------------
7082 Disable AC temporary - if successfull retrieve re-enable
7083 The order is justified because of the possible scenario
7084 - TL tryes to fetch packet for AC and it returns NULL
7085 - TL analyzes the data it has received to see if there are
7086 any more pkts available for AC -> if not TL will disable AC
7087 - however it is possible that while analyzing results TL got
7088 preempted by a pending indication where the mask was again set
7089 TL will not check again and as a result when it resumes
7090 execution it will disable AC
7091 To prevent this the AC will be disabled here and if retrieve
7092 is successfull it will be re-enabled
7093 -------------------------------------------------------------------*/
7094 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7095
7096 // don't reset it, as other AC queues in HDD may have packets
7097 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 }
7099 else
7100 {
7101 //softap case
7102 ucAC = pTLCb->uCurServedAC;
7103 pStaClient->aucACMask[ucAC] = 0;
7104
7105 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007107
7108 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 /*You make an initial assumption that HDD has no more data and if the
7110 assumption was wrong you reset the flags to their original state
7111 This will prevent from exposing a race condition between checking with HDD
7112 for packets and setting the flags to false*/
7113 if ( 0 == ucACMask )
7114 {
7115 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7116 pStaClient->ucNoMoreData = 1;
7117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007118
7119 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7120 &ucSTAId,
7121 ucAC,
7122 &vosDataBuff, &tlMetaInfo );
7123
7124
7125 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7126 {
7127
7128 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
7129 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
7130 vosStatus);
7131 *pvosDataBuff = NULL;
7132 /*--------------------------------------------------------------------
7133 Reset AC for the serviced station to the highest priority AC
7134 -> due to no more data at the station
7135 Even if this AC is not supported by the station, correction will be
7136 made in the main TL loop
7137 --------------------------------------------------------------------*/
7138 pStaClient->ucCurrentAC = WLANTL_AC_VO;
7139 pStaClient->ucCurrentWeight = 0;
7140
7141 return vosStatus;
7142 }
7143
Jeff Johnsone7245742012-09-05 17:12:55 -07007144 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007145
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 /*There are still packets in HDD - set back the pending packets and
7147 the no more data assumption*/
7148 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7149 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007150
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7152 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 // don't need to set it, as we don't reset it in this function.
7154 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007156
7157#ifdef WLAN_PERF
7158 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7159 (v_PVOID_t)0);
7160#endif /*WLAN_PERF*/
7161
7162 /*-------------------------------------------------------------------------
7163 Check TID
7164 -------------------------------------------------------------------------*/
7165 ucTid = tlMetaInfo.ucTID;
7166
7167 /*Make sure TID is valid*/
7168 if ( WLANTL_TID_INVALID(ucTid))
7169 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007170 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7172 ucTid));
7173 ucTid = 0;
7174 }
7175
7176 /*Save for UAPSD timer consideration*/
7177 pStaClient->ucServicedAC = ucAC;
7178
7179 if ( ucAC == pStaClient->ucCurrentAC )
7180 {
7181 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7182 pStaClient->ucCurrentWeight--;
7183 }
7184 else
7185 {
7186 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307187 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007188
7189 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7190
7191 }
7192
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7194 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 if ( 0 == pStaClient->ucCurrentWeight )
7196 {
7197 WLANTL_ACEnumType tempAC = ucAC;
7198 /*-----------------------------------------------------------------------
7199 Choose next AC - !!! optimize me
7200 -----------------------------------------------------------------------*/
7201 while ( 0 != ucACMask )
7202 {
7203 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7204 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7205 {
7206 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307207 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007208
7209 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7210 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7211 pStaClient->ucCurrentAC ,
7212 pStaClient->ucCurrentWeight));
7213 break;
7214 }
7215 tempAC = ucNextAC;
7216 }
7217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007219
7220 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7221 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7222
7223 /*------------------------------------------------------------------------
7224 Translate 802.3 frame to 802.11
7225 ------------------------------------------------------------------------*/
7226 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7227 {
7228 /* Needs frame translation */
7229 // if the client has not enabled SW-only frame translation
7230 // and if the frame is a unicast frame
7231 // (HW frame translation does not support multiple broadcast domains
7232 // so we use SW frame translation for broadcast/multicast frames)
7233#ifdef FEATURE_WLAN_WAPI
7234 // and if the frame is not a WAPI frame
7235#endif
7236 // then use HW_based frame translation
7237
7238 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7239 ( 0 == tlMetaInfo.ucBcast ) &&
7240 ( 0 == tlMetaInfo.ucMcast )
7241#ifdef FEATURE_WLAN_WAPI
7242 && ( tlMetaInfo.ucIsWai != 1 )
7243#endif
7244 )
7245 {
7246#ifdef WLAN_PERF
7247 v_U32_t uFastFwdOK = 0;
7248
7249 /* HW based translation. See if the frame could be fast forwarded */
7250 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7251 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7252
7253 if( VOS_STATUS_SUCCESS == vosStatus )
7254 {
7255 if(uFastFwdOK)
7256 {
7257 /* Packet could be fast forwarded now */
7258 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7259 (v_PVOID_t)pStaClient->pfnSTATxComp );
7260
7261 *pvosDataBuff = vosDataBuff;
7262
7263 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7264 stats for every pkt? */
7265 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7266 return vosStatus;
7267 }
7268 /* can't be fast forwarded, fall through normal (slow) path. */
7269 }
7270 else
7271 {
7272
7273 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7274 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7275 *pvosDataBuff = NULL;
7276 return vosStatus;
7277 }
7278#endif /*WLAN_PERF*/
7279 }
7280 else
7281 {
7282 /* SW based translation */
7283
7284#ifdef FEATURE_WLAN_WAPI
7285 gUcIsWai = tlMetaInfo.ucIsWai,
7286#endif
7287
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007288 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7289 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007290 &tlMetaInfo, &ucWDSEnabled,
7291 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 if ( VOS_STATUS_SUCCESS != vosStatus )
7293 {
7294 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7295 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7296 return vosStatus;
7297 }
7298
7299 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
7300 "WLAN TL software translation success \n"));
7301 ucSwFrmXtl = 1;
7302 tlMetaInfo.ucDisableFrmXtl = 1;
7303 }
7304 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307305#ifdef FEATURE_WLAN_TDLS
7306 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7307 change. so update the pStaClient accordingly */
7308 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007309
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307310 if ( NULL == pStaClient )
7311 {
7312 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7313 "pStaClient is NULL %s", __func__));
7314 return VOS_STATUS_E_FAILURE;
7315 }
7316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 /*-------------------------------------------------------------------------
7318 Call HAL to fill BD header
7319 -------------------------------------------------------------------------*/
7320 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7321
7322 if ( pStaClient->wSTADesc.ucQosEnabled )
7323 {
7324 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7325 }
7326
7327 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7328 HAL_TRIGGER_ENABLED_AC_MASK:0;
7329
7330#ifdef FEATURE_WLAN_WAPI
7331 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7332 {
7333#ifdef LIBRA_WAPI_SUPPORT
7334 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7335#endif //LIBRA_WAPI_SUPPORT
7336 if ( tlMetaInfo.ucIsWai == 1 )
7337 {
7338 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7339 }
7340 }
7341#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007342#ifdef FEATURE_WLAN_TDLS
7343 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7344 {
7345 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7346 }
7347#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07007348
7349 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7350 vosDataBuff , &vDestMacAddr,
7351 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7352 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7353 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307354 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7356 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7357
7358 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7359 {
7360 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7361 "Fill TX BD Error status %d", vosStatus));
7362
7363 return vosStatus;
7364 }
7365
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 /* TX Statistics */
7367 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7368 {
7369 /* This is TX UC frame */
7370 pStaClient->trafficStatistics.txUCFcnt++;
7371 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007373
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007374#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 /*-----------------------------------------------------------------------
7376 Update tx counter for BA session query for tx side
7377 -----------------------------------------------------------------------*/
7378 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007379#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307380 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007381#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007382
7383 /* This code is to send traffic with lower priority AC when we does not
7384 get admitted to send it. Today HAL does not downgrade AC so this code
7385 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7386 statement is always false.)
7387 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7388 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7389 then there will be no need for any AC downgrade logic in TL/WDI. */
7390#if 0
7391 if (( ucTid != tlMetaInfo.ucTID ) &&
7392 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7393 ( 0 != ucSwFrmXtl ))
7394 {
7395 /*---------------------------------------------------------------------
7396 !! FIX me: Once downgrading is clear put in the proper change
7397 ---------------------------------------------------------------------*/
7398 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7399
7400 //!!!Fix this replace peek with extract
7401 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7402 sizeof(*pucQosCtrl));
7403 *pucQosCtrl = ucTid; //? proper byte order
7404 }
7405#endif
7406
7407 if ( VOS_STATUS_SUCCESS != vosStatus )
7408 {
7409 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7410 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7411 *pvosDataBuff = NULL;
7412 return vosStatus;
7413 }
7414
7415 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7416 (v_PVOID_t)pStaClient->pfnSTATxComp );
7417
7418 *pvosDataBuff = vosDataBuff;
7419
7420 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7421 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7422 {
7423 pTLCb->bUrgent= TRUE;
7424 }
7425
7426 return VOS_STATUS_SUCCESS;
7427}/* WLANTL_STATxAuth */
7428
7429/*==========================================================================
7430 FUNCTION WLANTL_STATxDisc
7431
7432 DESCRIPTION
7433 Transmit in disconnected state - no data allowed
7434
7435 DEPENDENCIES
7436 The STA must be registered with TL before this function can be called.
7437
7438 PARAMETERS
7439
7440 IN
7441 pvosGCtx: pointer to the global vos context; a handle to TL's
7442 control block can be extracted from its context
7443 ucSTAId: identifier of the station being processed
7444 vosDataBuff: pointer to the tx vos buffer
7445
7446 RETURN VALUE
7447 The result code associated with performing the operation
7448
7449 VOS_STATUS_SUCCESS: Everything is good :)
7450
7451 SIDE EFFECTS
7452
7453============================================================================*/
7454VOS_STATUS
7455WLANTL_STATxDisc
7456(
7457 v_PVOID_t pvosGCtx,
7458 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007459 vos_pkt_t** pvosDataBuff,
7460 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007461)
7462{
7463 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307464 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7466
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 /*------------------------------------------------------------------------
7468 Sanity check
7469 Extract TL control block
7470 ------------------------------------------------------------------------*/
7471 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7472 if ( NULL == pTLCb )
7473 {
7474 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7475 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7476 *pvosDataBuff = NULL;
7477 return VOS_STATUS_E_FAULT;
7478 }
7479
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307480 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7481
7482 if ( NULL == pClientSTA )
7483 {
7484 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7485 "WLAN TL:Client Memory was not allocated on %s", __func__));
7486 return VOS_STATUS_E_FAILURE;
7487 }
7488
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 /*------------------------------------------------------------------------
7490 Error
7491 ------------------------------------------------------------------------*/
7492 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7493 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7494 " request"));
7495
7496 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307497 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007498
7499 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307500 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007501
7502 return VOS_STATUS_SUCCESS;
7503}/* WLANTL_STATxDisc */
7504
7505/*==========================================================================
7506 FUNCTION WLANTL_STARxConn
7507
7508 DESCRIPTION
7509 Receive in connected state - only EAPOL
7510
7511 DEPENDENCIES
7512 The STA must be registered with TL before this function can be called.
7513
7514 PARAMETERS
7515
7516 IN
7517 pvosGCtx: pointer to the global vos context; a handle to TL's
7518 control block can be extracted from its context
7519 ucSTAId: identifier of the station being processed
7520 vosDataBuff: pointer to the tx/rx vos buffer
7521
7522 RETURN VALUE
7523 The result code associated with performing the operation
7524
7525 VOS_STATUS_E_INVAL: invalid input parameters
7526 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7527 page fault
7528 VOS_STATUS_SUCCESS: Everything is good :)
7529
7530 SIDE EFFECTS
7531
7532============================================================================*/
7533VOS_STATUS
7534WLANTL_STARxConn
7535(
7536 v_PVOID_t pvosGCtx,
7537 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007538 vos_pkt_t** pvosDataBuff,
7539 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007540)
7541{
7542 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307543 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 v_U16_t usEtherType = 0;
7545 v_U16_t usPktLen;
7546 v_U8_t ucMPDUHOffset;
7547 v_U16_t usMPDUDOffset;
7548 v_U16_t usMPDULen;
7549 v_U8_t ucMPDUHLen;
7550 v_U16_t usActualHLen = 0;
7551 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7552 vos_pkt_t* vosDataBuff;
7553 v_PVOID_t aucBDHeader;
7554 v_U8_t ucTid;
7555 WLANTL_RxMetaInfoType wRxMetaInfo;
7556 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7557
7558 /*------------------------------------------------------------------------
7559 Sanity check
7560 ------------------------------------------------------------------------*/
7561 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7562 {
7563 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7564 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
7565 return VOS_STATUS_E_INVAL;
7566 }
7567
7568 /*------------------------------------------------------------------------
7569 Extract TL control block
7570 ------------------------------------------------------------------------*/
7571 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7572 if ( NULL == pTLCb )
7573 {
7574 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7575 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7576 return VOS_STATUS_E_FAULT;
7577 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307578 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7579
7580 if ( NULL == pClientSTA )
7581 {
7582 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7583 "WLAN TL:Client Memory was not allocated on %s", __func__));
7584 return VOS_STATUS_E_FAILURE;
7585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007586
7587 /*------------------------------------------------------------------------
7588 Extract BD header and check if valid
7589 ------------------------------------------------------------------------*/
7590 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
7591
7592 if ( NULL == aucBDHeader )
7593 {
7594 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7595 "WLAN TL:Cannot extract BD header"));
7596 VOS_ASSERT( 0 );
7597 return VOS_STATUS_E_FAULT;
7598 }
7599
7600
7601 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7602 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7603 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7604 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7605 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7606
7607 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7608
7609 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7610 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
7611 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
7612
7613 /*It will cut out the 802.11 header if not used*/
7614 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7615 {
7616 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7617 "WLAN TL:BD header corrupted - dropping packet"));
7618 /* Drop packet */
7619 vos_pkt_return_packet(vosDataBuff);
7620 return VOS_STATUS_SUCCESS;
7621 }
7622
7623 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
7624
7625 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7626 {
7627#ifdef FEATURE_WLAN_WAPI
7628 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
7629 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
7630 /* that we get an EAPOL packet in WAPI mode or vice versa? */
7631 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
7632 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007633 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007634 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07007635 /* Drop packet */
7636 vos_pkt_return_packet(vosDataBuff);
7637 }
7638#else
7639 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
7640 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007641 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7642 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 /* Drop packet */
7644 vos_pkt_return_packet(vosDataBuff);
7645 }
7646#endif /* FEATURE_WLAN_WAPI */
7647 else /* Frame is an EAPOL frame or a WAI frame*/
7648 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007649
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007650 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007651 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
7652
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307654 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 {
7656 if (usMPDUDOffset > ucMPDUHOffset)
7657 {
7658 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7659 }
7660
7661 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007662 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07007663
7664 if ( VOS_STATUS_SUCCESS != vosStatus )
7665 {
7666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7667 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7668 /* Drop packet */
7669 vos_pkt_return_packet(vosDataBuff);
7670 return vosStatus;
7671 }
7672 }
7673 /*-------------------------------------------------------------------
7674 Increment receive counter
7675 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007676 if ( !WLANTL_TID_INVALID( ucTid) )
7677 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307678 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007679 }
7680 else
7681 {
7682 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7683 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7684 ucTid, ucSTAId, __func__));
7685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007686
7687 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7688 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
7689
7690 /*-------------------------------------------------------------------
7691 !!!Assuming TID = UP mapping
7692 -------------------------------------------------------------------*/
7693 wRxMetaInfo.ucUP = ucTid;
7694
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007696 "WLAN TL %s:Sending data chain to station \n", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307697 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 {
7699 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307700 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 &wRxMetaInfo );
7702 }
7703 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307704 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 &wRxMetaInfo );
7706 }/*EAPOL frame or WAI frame*/
7707 }/*vos status success*/
7708
7709 return VOS_STATUS_SUCCESS;
7710}/* WLANTL_STARxConn */
7711
Jeff Johnson295189b2012-06-20 16:38:30 -07007712/*==========================================================================
7713 FUNCTION WLANTL_FwdPktToHDD
7714
7715 DESCRIPTION
7716 Determine the Destation Station ID and route the Frame to Upper Layer
7717
7718 DEPENDENCIES
7719
7720 PARAMETERS
7721
7722 IN
7723 pvosGCtx: pointer to the global vos context; a handle to TL's
7724 control block can be extracted from its context
7725 ucSTAId: identifier of the station being processed
7726 vosDataBuff: pointer to the rx vos buffer
7727
7728 RETURN VALUE
7729 The result code associated with performing the operation
7730
7731 VOS_STATUS_E_INVAL: invalid input parameters
7732 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7733 page fault
7734 VOS_STATUS_SUCCESS: Everything is good :)
7735
7736 SIDE EFFECTS
7737
7738============================================================================*/
7739
7740VOS_STATUS
7741WLANTL_FwdPktToHDD
7742(
7743 v_PVOID_t pvosGCtx,
7744 vos_pkt_t* pvosDataBuff,
7745 v_U8_t ucSTAId
7746)
7747{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307748 v_MACADDR_t DestMacAddress;
7749 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
7750 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307752 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007753 vos_pkt_t* vosDataBuff ;
7754 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307755 v_U32_t STAMetaInfo;
7756 vos_pkt_t* vosNextDataBuff ;
7757 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 WLANTL_RxMetaInfoType wRxMetaInfo;
7759
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 /*------------------------------------------------------------------------
7761 Sanity check
7762 ------------------------------------------------------------------------*/
7763 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
7764 {
7765 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7766 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
7767 return VOS_STATUS_E_INVAL;
7768 }
7769
7770 /*------------------------------------------------------------------------
7771 Extract TL control block
7772 ------------------------------------------------------------------------*/
7773 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7774 if ( NULL == pTLCb )
7775 {
7776 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7777 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
7778 return VOS_STATUS_E_FAULT;
7779 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307780
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07007781 if(WLANTL_STA_ID_INVALID(ucSTAId))
7782 {
7783 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
7784 ucSTAId));
7785 return VOS_STATUS_E_INVAL;
7786 }
7787
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307788 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7789
7790 if ( NULL == pClientSTA )
7791 {
7792 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7793 "WLAN TL:Client Memory was not allocated on %s", __func__));
7794 return VOS_STATUS_E_FAILURE;
7795 }
7796
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
7798 may have packets destined to multiple destinations we have to process each packet
7799 at a time and determine its Destination. So the Voschain provided by Reorder code
7800 is unchain and forwarded to Upper Layer after Determining the Destination */
7801
7802 vosDataBuff = pvosDataBuff;
7803 while (vosDataBuff != NULL)
7804 {
7805 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
7806 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7807 (v_PVOID_t *)&STAMetaInfo );
7808 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007809 ucDesSTAId = (v_U8_t)((STAMetaInfo) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07007810
7811 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
7812 if ( VOS_STATUS_SUCCESS != vosStatus )
7813 {
7814 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7815 "WLAN TL: recv corrupted data packet\n"));
7816 vos_pkt_return_packet(vosDataBuff);
7817 return vosStatus;
7818 }
7819
7820 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,"station mac 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n",
7821 pDestMacAddress->bytes[0], pDestMacAddress->bytes[1], pDestMacAddress->bytes[2],
7822 pDestMacAddress->bytes[3], pDestMacAddress->bytes[4], pDestMacAddress->bytes[5]));
7823
7824 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
7825 {
7826 // destination is mc/bc station
7827 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
7828 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007829 "%s: BC/MC packet, id %d\n", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 }
7831 else
7832 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307833 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 {
7835 // destination is AP itself
7836 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7837 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007838 "%s: packet to AP itself, id %d\n", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05307840 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 {
7842 // destination station is something else
7843 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007844 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d\n", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7846 }
7847
7848
7849 //loopback unicast station comes here
7850 }
7851
7852 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
7853 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
7854
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307855 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307857 if ( VOS_STATUS_SUCCESS != vosStatus )
7858 {
7859 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 "WLAN TL: failed to send pkt to HDD \n"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307861 vos_pkt_return_packet(vosDataBuff);
7862
7863 return vosStatus;
7864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 vosDataBuff = vosNextDataBuff;
7866 }
7867 return VOS_STATUS_SUCCESS;
7868}
Jeff Johnson295189b2012-06-20 16:38:30 -07007869
7870/*==========================================================================
7871 FUNCTION WLANTL_STARxAuth
7872
7873 DESCRIPTION
7874 Receive in authenticated state - all data allowed
7875
7876 DEPENDENCIES
7877 The STA must be registered with TL before this function can be called.
7878
7879 PARAMETERS
7880
7881 IN
7882 pvosGCtx: pointer to the global vos context; a handle to TL's
7883 control block can be extracted from its context
7884 ucSTAId: identifier of the station being processed
7885 vosDataBuff: pointer to the rx vos buffer
7886
7887 RETURN VALUE
7888 The result code associated with performing the operation
7889
7890 VOS_STATUS_E_INVAL: invalid input parameters
7891 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7892 page fault
7893 VOS_STATUS_SUCCESS: Everything is good :)
7894
7895 SIDE EFFECTS
7896
7897============================================================================*/
7898VOS_STATUS
7899WLANTL_STARxAuth
7900(
7901 v_PVOID_t pvosGCtx,
7902 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007903 vos_pkt_t** pvosDataBuff,
7904 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007905)
7906{
7907 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307908 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 v_U8_t ucAsf; /* AMSDU sub frame */
7910 v_U16_t usMPDUDOffset;
7911 v_U8_t ucMPDUHOffset;
7912 v_U16_t usMPDULen;
7913 v_U8_t ucMPDUHLen;
7914 v_U16_t usActualHLen = 0;
7915 v_U8_t ucTid;
7916#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07007917 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007918#endif
7919 v_U16_t usPktLen;
7920 vos_pkt_t* vosDataBuff ;
7921 v_PVOID_t aucBDHeader;
7922 VOS_STATUS vosStatus;
7923 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007924 static v_U8_t ucPMPDUHLen;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007925 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
7927 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
7928 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
7929 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007930 struct _BARFrmStruct *pBarFrame = NULL;
7931
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7933
7934 /*------------------------------------------------------------------------
7935 Sanity check
7936 ------------------------------------------------------------------------*/
7937 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7938 {
7939 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7940 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
7941 return VOS_STATUS_E_INVAL;
7942 }
7943
7944 /*------------------------------------------------------------------------
7945 Extract TL control block
7946 ------------------------------------------------------------------------*/
7947 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7948 if ( NULL == pTLCb )
7949 {
7950 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7951 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
7952 return VOS_STATUS_E_FAULT;
7953 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307954 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7955
7956 if ( NULL == pClientSTA )
7957 {
7958 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7959 "WLAN TL:Client Memory was not allocated on %s", __func__));
7960 return VOS_STATUS_E_FAILURE;
7961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007962
7963 /*------------------------------------------------------------------------
7964 Extract BD header and check if valid
7965 ------------------------------------------------------------------------*/
7966 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
7967
7968 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7969 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7970 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7971 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7972 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7973
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007974 /* Fix for a hardware bug.
7975 * H/W does not update the tid field in BD header for BAR frames.
7976 * Fix is to read the tid field from MAC header of BAR frame */
7977 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
7978 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
7979 {
7980 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
7981 ucTid = pBarFrame->barControl.numTID;
7982 }
7983
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 /*Host based replay check is needed for unicast data frames*/
7985 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 if(0 != ucMPDUHLen)
7987 {
7988 ucPMPDUHLen = ucMPDUHLen;
7989 }
7990
7991 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7992 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
7993 " Tid %d BD %d",
7994 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
7995 WLANHAL_RX_BD_HEADER_SIZE));
7996
7997 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7998
7999 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8000 {
8001 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8002 {
8003 /* AMSDU case, ucMPDUHOffset = 0
8004 * it should be hancdled seperatly */
8005 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8006 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8007 ( !WLANTL_TID_INVALID(ucTid) ))
8008 {
8009 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8010 }
8011 else
8012 {
8013 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8014 "WLAN TL:BD header corrupted - dropping packet"));
8015 /* Drop packet */
8016 vos_pkt_return_packet(vosDataBuff);
8017 return VOS_STATUS_SUCCESS;
8018 }
8019 }
8020 else
8021 {
8022 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8023 "WLAN TL:BD header corrupted - dropping packet"));
8024 /* Drop packet */
8025 vos_pkt_return_packet(vosDataBuff);
8026 return VOS_STATUS_SUCCESS;
8027 }
8028 }
8029
8030#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308031 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 {
8033 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8034 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8035 {
8036 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8037 {
8038 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8039 {
8040 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8041 "WLAN TL:WAI frame was received encrypted - dropping"));
8042 /* Drop packet */
8043 /*Temporary fix added to fix wapi rekey issue*/
8044 //vos_pkt_return_packet(vosDataBuff);
8045 //return vosStatus; //returning success
8046 }
8047 }
8048 else
8049 {
8050 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8051 {
8052 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8053 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8054 /* Drop packet */
8055 vos_pkt_return_packet(vosDataBuff);
8056 return vosStatus; //returning success
8057 }
8058 }
8059 }
8060 else //could not extract EtherType - this should not happen
8061 {
8062 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008063 "WLAN TL:Could not extract EtherType"));
8064 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 }
8067 }
8068#endif /* FEATURE_WLAN_WAPI */
8069
8070 /*----------------------------------------------------------------------
8071 Increment receive counter
8072 !! not sure this is the best place to increase this - pkt might be
8073 dropped below or delayed in TL's queues
8074 - will leave it here for now
8075 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008076 if ( !WLANTL_TID_INVALID( ucTid) )
8077 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308078 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008079 }
8080 else
8081 {
8082 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8083 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8084 ucTid, ucSTAId, __func__));
8085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008086
8087 /*------------------------------------------------------------------------
8088 Check if AMSDU and send for processing if so
8089 ------------------------------------------------------------------------*/
8090 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8091
8092 if ( 0 != ucAsf )
8093 {
8094 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8095 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8096 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8097 ucMPDUHLen, usMPDULen );
8098 if(NULL == vosDataBuff)
8099 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008100 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 return VOS_STATUS_SUCCESS;
8102 }
8103 }
8104 /* After AMSDU header handled
8105 * AMSDU frame just same with normal frames */
8106 /*-------------------------------------------------------------------
8107 Translating header if necesary
8108 !! Fix me: rmv comments below
8109 ----------------------------------------------------------------------*/
8110 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308111 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8113 {
8114 if(0 == ucMPDUHLen)
8115 {
8116 ucMPDUHLen = ucPMPDUHLen;
8117 }
8118 if (usMPDUDOffset > ucMPDUHOffset)
8119 {
8120 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8121 }
8122 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008123 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008124
8125 if ( VOS_STATUS_SUCCESS != vosStatus )
8126 {
8127 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8128 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8129 /* Drop packet */
8130 vos_pkt_return_packet(vosDataBuff);
8131 return vosStatus;
8132 }
8133 }
8134 /* Softap requires additional Info such as Destination STAID and Access
8135 Category. Voschain or Buffer returned by BA would be unchain and this
8136 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308137 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 {
Gopichand Nakkala976e3252013-01-03 15:45:56 -08008139 STAMetaInfoPtr = (v_U32_t *)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8141 (v_PVOID_t)STAMetaInfoPtr);
8142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008143
8144 /*------------------------------------------------------------------------
8145 Check to see if re-ordering session is in place
8146 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308147 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 {
8149 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8150 }
8151
Jeff Johnson295189b2012-06-20 16:38:30 -07008152if(0 == ucUnicastBroadcastType
8153#ifdef FEATURE_ON_CHIP_REORDERING
8154 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8155#endif
8156)
8157{
8158 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308159 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 {
8161 /* replay check is needed for the station */
8162
8163 /* check whether frame is AMSDU frame */
8164 if ( 0 != ucAsf )
8165 {
8166 /* Since virgo can't send AMSDU frames this leg of the code
8167 was not tested properly, it needs to be tested properly*/
8168 /* Frame is AMSDU frame. As per 802.11n only first
8169 subframe will have replay counter */
8170 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8171 if( 0 != ucEsf )
8172 {
8173 v_BOOL_t status;
8174 /* Getting 48-bit replay counter from the RX BD */
8175 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8176
8177 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8178 "WLAN TL: AMSDU currentReplayCounter [0x%llX]\n",ullcurrentReplayCounter);
8179
8180 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308181 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008182
8183 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8184 "WLAN TL: AMSDU previousReplayCounter [0x%llX]\n",ullpreviousReplayCounter);
8185
8186 /* It is first subframe of AMSDU thus it
8187 conatains replay counter perform the
8188 replay check for this first subframe*/
8189 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8190 if(VOS_FALSE == status)
8191 {
8192 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308193 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 }
8195 else
8196 {
8197 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8198 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]\n",ullcurrentReplayCounter);
8199
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308200 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08008202 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]\n",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308203 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008204
8205 /* Drop the packet */
8206 vos_pkt_return_packet(vosDataBuff);
8207 return VOS_STATUS_SUCCESS;
8208 }
8209 }
8210 }
8211 else
8212 {
8213 v_BOOL_t status;
8214
8215 /* Getting 48-bit replay counter from the RX BD */
8216 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8217
8218 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8219 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]\n",ullcurrentReplayCounter);
8220
8221 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308222 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008223
8224 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
8225 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]\n",ullpreviousReplayCounter);
8226
8227 /* It is not AMSDU frame so perform
8228 reaply check for each packet, as
8229 each packet contains valid replay counter*/
8230 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8231 if(VOS_FALSE == status)
8232 {
8233 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308234 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 }
8236 else
8237 {
8238 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8239 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]\n",ullcurrentReplayCounter);
8240
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308241 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08008243 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]\n",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308244 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008245
8246 /* Repaly packet, drop the packet */
8247 vos_pkt_return_packet(vosDataBuff);
8248 return VOS_STATUS_SUCCESS;
8249 }
8250 }
8251 }
8252}
8253/*It is a broadast packet DPU has already done replay check for
8254 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008255
8256 if ( NULL != vosDataBuff )
8257 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308258 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 {
8260 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8261 }
8262 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 {
8264 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008265 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308266#ifdef FEATURE_WLAN_TDLS
8267 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8268 {
8269 wRxMetaInfo.isStaTdls = TRUE;
8270 }
8271 else
8272 {
8273 wRxMetaInfo.isStaTdls = FALSE;
8274 }
8275#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308276 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 &wRxMetaInfo );
8278 }
8279 }/* if not NULL */
8280
8281 return VOS_STATUS_SUCCESS;
8282}/* WLANTL_STARxAuth */
8283
8284
8285/*==========================================================================
8286 FUNCTION WLANTL_STARxDisc
8287
8288 DESCRIPTION
8289 Receive in disconnected state - no data allowed
8290
8291 DEPENDENCIES
8292 The STA must be registered with TL before this function can be called.
8293
8294 PARAMETERS
8295
8296 IN
8297 pvosGCtx: pointer to the global vos context; a handle to TL's
8298 control block can be extracted from its context
8299 ucSTAId: identifier of the station being processed
8300 vosDataBuff: pointer to the rx vos buffer
8301
8302 RETURN VALUE
8303 The result code associated with performing the operation
8304
8305 VOS_STATUS_SUCCESS: Everything is good :)
8306
8307 SIDE EFFECTS
8308
8309============================================================================*/
8310VOS_STATUS
8311WLANTL_STARxDisc
8312(
8313 v_PVOID_t pvosGCtx,
8314 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008315 vos_pkt_t** pvosDataBuff,
8316 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008317)
8318{
8319 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8320
8321 /*------------------------------------------------------------------------
8322 Sanity check
8323 ------------------------------------------------------------------------*/
8324 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8325 {
8326 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8327 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8328 return VOS_STATUS_E_INVAL;
8329 }
8330
8331 /*------------------------------------------------------------------------
8332 Error - drop packet
8333 ------------------------------------------------------------------------*/
8334 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8335 "WLAN TL:Packet should not be received in state disconnected"
8336 " - dropping"));
8337 vos_pkt_return_packet(*pvosDataBuff);
8338 *pvosDataBuff = NULL;
8339
8340 return VOS_STATUS_SUCCESS;
8341}/* WLANTL_STARxDisc */
8342
8343/*==========================================================================
8344 Processing main loops for MAIN and TX threads
8345 ==========================================================================*/
8346
8347/*==========================================================================
8348 FUNCTION WLANTL_McProcessMsg
8349
8350 DESCRIPTION
8351 Called by VOSS when a message was serialized for TL through the
8352 main thread/task.
8353
8354 DEPENDENCIES
8355 The TL must be initialized before this function can be called.
8356
8357 PARAMETERS
8358
8359 IN
8360 pvosGCtx: pointer to the global vos context; a handle to TL's
8361 control block can be extracted from its context
8362 message: type and content of the message
8363
8364
8365 RETURN VALUE
8366 The result code associated with performing the operation
8367
8368 VOS_STATUS_E_INVAL: invalid input parameters
8369 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8370 page fault
8371 VOS_STATUS_SUCCESS: Everything is good :)
8372
8373 SIDE EFFECTS
8374
8375============================================================================*/
8376VOS_STATUS
8377WLANTL_McProcessMsg
8378(
8379 v_PVOID_t pvosGCtx,
8380 vos_msg_t* message
8381)
8382{
8383 WLANTL_CbType* pTLCb = NULL;
8384 tAddBAInd* ptAddBaInd = NULL;
8385 tDelBAInd* ptDelBaInd = NULL;
8386 tAddBARsp* ptAddBaRsp = NULL;
8387 vos_msg_t vosMessage;
8388 VOS_STATUS vosStatus;
8389 tpFlushACRsp FlushACRspPtr;
8390 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8391
8392 /*------------------------------------------------------------------------
8393 Sanity check
8394 ------------------------------------------------------------------------*/
8395 if ( NULL == message )
8396 {
8397 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8398 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8399 return VOS_STATUS_E_INVAL;
8400 }
8401
8402 /*------------------------------------------------------------------------
8403 Extract TL control block
8404 ------------------------------------------------------------------------*/
8405 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8406 if ( NULL == pTLCb )
8407 {
8408 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8409 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8410 return VOS_STATUS_E_FAULT;
8411 }
8412
8413 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8414 "WLAN TL:Received message: %d through main flow", message->type));
8415
8416 switch( message->type )
8417 {
8418 case WDA_TL_FLUSH_AC_RSP:
8419 // Extract the message from the message body
8420 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8421 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008422 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8423 {
8424 VOS_ASSERT(0);
8425 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8426 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8427 return VOS_STATUS_E_FAULT;
8428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008429
8430 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8431 "Received message: Flush complete received by TL"));
8432
8433 // Since we have the response back from HAL, just call the BAP client
8434 // registered call back from TL. There is only 1 possible
8435 // BAP client. So directly reference tlBAPClient
8436 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8437 FlushACRspPtr->ucSTAId,
8438 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8439
8440 // Free the PAL memory, we are done with it.
8441 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8442 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8443 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8444 break;
8445
8446 case WDA_HDD_ADDBA_REQ:
8447 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8448 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8449 ptAddBaInd->baSession.baSessionID,
8450 ptAddBaInd->baSession.STAID,
8451 ptAddBaInd->baSession.baTID,
8452 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8453 ptAddBaInd->baSession.winSize,
8454 ptAddBaInd->baSession.SSN);
8455 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8456
8457 if ( NULL == ptAddBaRsp )
8458 {
8459 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8460 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8461 VOS_ASSERT(0);
8462 return VOS_STATUS_E_NOMEM;
8463 }
8464
8465 if ( VOS_STATUS_SUCCESS == vosStatus )
8466 {
8467 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8468 "WLAN TL: Sending success indication to HAL for ADD BA"));
8469 /*Send success*/
8470 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8471 vosMessage.type = WDA_HDD_ADDBA_RSP;
8472 }
8473 else
8474 {
8475 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8476 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8477
8478 /*Send failure*/
8479 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8480 vosMessage.type = WDA_BA_FAIL_IND;
8481 }
8482
8483 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8484 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8485 /* This is default, reply win size has to be handled BA module, FIX THIS */
8486 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8487 vosMessage.bodyptr = ptAddBaRsp;
8488
8489 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8490 WLANTL_McFreeMsg (pvosGCtx, message);
8491 break;
8492 case WDA_DELETEBA_IND:
8493 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8494 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8495 ptDelBaInd->staIdx,
8496 ptDelBaInd->baTID);
8497
8498 if ( VOS_STATUS_SUCCESS != vosStatus )
8499 {
8500 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8501 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8502 ptDelBaInd->staIdx,
8503 ptDelBaInd->baTID,
8504 vosStatus));
8505 }
8506 WLANTL_McFreeMsg (pvosGCtx, message);
8507 break;
8508 default:
8509 /*no processing for now*/
8510 break;
8511 }
8512
8513 return VOS_STATUS_SUCCESS;
8514}/* WLANTL_ProcessMainMessage */
8515
8516/*==========================================================================
8517 FUNCTION WLANTL_McFreeMsg
8518
8519 DESCRIPTION
8520 Called by VOSS to free a given TL message on the Main thread when there
8521 are messages pending in the queue when the whole system is been reset.
8522 For now, TL does not allocate any body so this function shout translate
8523 into a NOOP
8524
8525 DEPENDENCIES
8526 The TL must be initialized before this function can be called.
8527
8528 PARAMETERS
8529
8530 IN
8531 pvosGCtx: pointer to the global vos context; a handle to TL's
8532 control block can be extracted from its context
8533 message: type and content of the message
8534
8535
8536 RETURN VALUE
8537 The result code associated with performing the operation
8538
8539 VOS_STATUS_SUCCESS: Everything is good :)
8540
8541 SIDE EFFECTS
8542
8543============================================================================*/
8544VOS_STATUS
8545WLANTL_McFreeMsg
8546(
8547 v_PVOID_t pvosGCtx,
8548 vos_msg_t* message
8549)
8550{
8551 WLANTL_CbType* pTLCb = NULL;
8552 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8553
8554 /*------------------------------------------------------------------------
8555 Sanity check
8556 ------------------------------------------------------------------------*/
8557 if ( NULL == message )
8558 {
8559 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8560 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
8561 return VOS_STATUS_E_INVAL;
8562 }
8563
8564 /*------------------------------------------------------------------------
8565 Extract TL control block
8566 ------------------------------------------------------------------------*/
8567 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8568 if ( NULL == pTLCb )
8569 {
8570 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8571 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
8572 return VOS_STATUS_E_FAULT;
8573 }
8574
8575 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8576 "WLAN TL:Received message: %d through main free", message->type));
8577
8578 switch( message->type )
8579 {
8580 case WDA_HDD_ADDBA_REQ:
8581 case WDA_DELETEBA_IND:
8582 /*vos free body pointer*/
8583 vos_mem_free(message->bodyptr);
8584 message->bodyptr = NULL;
8585 break;
8586 default:
8587 /*no processing for now*/
8588 break;
8589 }
8590
8591 return VOS_STATUS_SUCCESS;
8592}/*WLANTL_McFreeMsg*/
8593
8594/*==========================================================================
8595 FUNCTION WLANTL_TxProcessMsg
8596
8597 DESCRIPTION
8598 Called by VOSS when a message was serialized for TL through the
8599 tx thread/task.
8600
8601 DEPENDENCIES
8602 The TL must be initialized before this function can be called.
8603
8604 PARAMETERS
8605
8606 IN
8607 pvosGCtx: pointer to the global vos context; a handle to TL's
8608 control block can be extracted from its context
8609 message: type and content of the message
8610
8611
8612 RETURN VALUE
8613 The result code associated with performing the operation
8614
8615 VOS_STATUS_E_INVAL: invalid input parameters
8616 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8617 page fault
8618 VOS_STATUS_SUCCESS: Everything is good :)
8619
8620 Other values can be returned as a result of a function call, please check
8621 corresponding API for more info.
8622 SIDE EFFECTS
8623
8624============================================================================*/
8625VOS_STATUS
8626WLANTL_TxProcessMsg
8627(
8628 v_PVOID_t pvosGCtx,
8629 vos_msg_t* message
8630)
8631{
8632 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8633 v_U32_t uData;
8634 v_U8_t ucSTAId;
8635 v_U8_t ucUcastSig;
8636 v_U8_t ucBcastSig;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308637 WLANTL_CbType* pTLCb = NULL;
8638 WLANTL_STAClientType* pClientSTA = NULL;
8639 WLANTL_ACEnumType ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07008640 void (*callbackRoutine) (void *callbackContext);
8641 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008642 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8643
8644 /*------------------------------------------------------------------------
8645 Sanity check
8646 ------------------------------------------------------------------------*/
8647 if ( NULL == message )
8648 {
8649 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8650 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
8651 return VOS_STATUS_E_INVAL;
8652 }
8653
8654 /*------------------------------------------------------------------------
8655 Process message
8656 ------------------------------------------------------------------------*/
8657 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8658 "WLAN TL:Received message: %d through tx flow", message->type));
8659
8660 switch( message->type )
8661 {
8662 case WLANTL_TX_SIG_SUSPEND:
8663 vosStatus = WLANTL_SuspendCB( pvosGCtx,
8664 (WLANTL_SuspendCBType)message->bodyptr,
8665 message->reserved);
8666 break;
8667 case WLANTL_TX_RES_NEEDED:
8668 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
8669 break;
8670
8671 case WLANTL_TX_FWD_CACHED:
8672 /*---------------------------------------------------------------------
8673 The data sent with the message has the following structure:
8674 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
8675 each field above is one byte
8676 ---------------------------------------------------------------------*/
Jeff Johnsond86c05a2013-11-10 18:50:34 -08008677 uData = message->bodyval;
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 ucSTAId = ( uData & 0x000000FF);
8679 ucUcastSig = ( uData & 0x0000FF00)>>8;
8680 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
8681 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
8682 ucUcastSig, ucBcastSig);
8683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 case WLANTL_TX_STAID_AC_IND:
8685 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8686 if ( NULL == pTLCb )
8687 {
8688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8689 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
8690 return VOS_STATUS_E_FAULT;
8691 }
8692
8693 ucAC = message->bodyval & WLANTL_AC_MASK;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08008694 ucSTAId = (v_U8_t)(message->bodyval >> WLANTL_STAID_OFFSET);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308695 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008696
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308697 if ( NULL == pClientSTA )
8698 {
8699 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8700 "WLAN TL:Client Memory was not allocated on %s", __func__));
8701 return VOS_STATUS_E_FAILURE;
8702 }
8703
8704 pClientSTA->aucACMask[ucAC] = 1;
8705
8706 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8708 break;
Jeff Johnson017fdc32013-02-27 09:22:30 -08008709
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308711 WLANTL_ClearTxXmitPending(pvosGCtx);
8712 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 break;
8714
8715 case WDA_DS_FINISH_ULA:
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08008716 callbackContext = (void *)message->bodyval;
8717 callbackRoutine = message->bodyptr;
8718 callbackRoutine(callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008720
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308721 case WLANTL_TX_SNAPSHOT:
8722 /*Dumping TL State and then continuing to print
8723 the DXE Dump*/
8724 WLANTL_TxThreadDebugHandler(pvosGCtx);
8725 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
8726 break;
8727
Jeff Johnson295189b2012-06-20 16:38:30 -07008728 default:
8729 /*no processing for now*/
8730 break;
8731 }
8732
8733 return vosStatus;
8734}/* WLANTL_TxProcessMsg */
8735
8736/*==========================================================================
8737 FUNCTION WLANTL_McFreeMsg
8738
8739 DESCRIPTION
8740 Called by VOSS to free a given TL message on the Main thread when there
8741 are messages pending in the queue when the whole system is been reset.
8742 For now, TL does not allocate any body so this function shout translate
8743 into a NOOP
8744
8745 DEPENDENCIES
8746 The TL must be initialized before this function can be called.
8747
8748 PARAMETERS
8749
8750 IN
8751 pvosGCtx: pointer to the global vos context; a handle to TL's
8752 control block can be extracted from its context
8753 message: type and content of the message
8754
8755
8756 RETURN VALUE
8757 The result code associated with performing the operation
8758
8759 VOS_STATUS_SUCCESS: Everything is good :)
8760
8761 SIDE EFFECTS
8762
8763============================================================================*/
8764VOS_STATUS
8765WLANTL_TxFreeMsg
8766(
8767 v_PVOID_t pvosGCtx,
8768 vos_msg_t* message
8769)
8770{
8771 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8772
8773 /*Nothing to do for now!!!*/
8774 return VOS_STATUS_SUCCESS;
8775}/*WLANTL_TxFreeMsg*/
8776
Jeff Johnson295189b2012-06-20 16:38:30 -07008777/*==========================================================================
8778
8779 FUNCTION WLANTL_TxFCFrame
8780
8781 DESCRIPTION
8782 Internal utility function to send FC frame. Enable
8783 or disable LWM mode based on the information.
8784
8785 DEPENDENCIES
8786 TL must be initiailized before this function gets called.
8787 FW sends up special flow control frame.
8788
8789 PARAMETERS
8790
8791 IN
8792 pvosGCtx: pointer to the global vos context; a handle to TL's
8793 control block can be extracted from its context
8794
8795 RETURN VALUE
8796 The result code associated with performing the operation
8797
8798 VOS_STATUS_E_INVAL: Input pointers are NULL.
8799 VOS_STATUS_E_FAULT: Something is wrong.
8800 VOS_STATUS_SUCCESS: Everything is good.
8801
8802 SIDE EFFECTS
8803 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
8804 be released.
8805
8806============================================================================*/
8807VOS_STATUS
8808WLANTL_TxFCFrame
8809(
8810 v_PVOID_t pvosGCtx
8811)
8812{
8813#if 0
8814 WLANTL_CbType* pTLCb = NULL;
8815 VOS_STATUS vosStatus;
8816 tpHalFcTxBd pvFcTxBd = NULL;
8817 vos_pkt_t * pPacket = NULL;
8818 v_U8_t ucSTAId = 0;
8819 v_U8_t ucBitCheck = 1;
8820
8821 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008822 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008823
8824 /*------------------------------------------------------------------------
8825 Sanity check
8826 ------------------------------------------------------------------------*/
8827 if ( NULL == pvosGCtx )
8828 {
8829 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008830 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 return VOS_STATUS_E_INVAL;
8832 }
8833 /*------------------------------------------------------------------------
8834 Extract TL control block
8835 ------------------------------------------------------------------------*/
8836 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8837
8838 if (NULL == pTLCb)
8839 {
8840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008841 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 return VOS_STATUS_E_INVAL;
8843 }
8844
8845 //Get one voss packet
8846 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
8847 VOS_FALSE, NULL, NULL );
8848
8849 if ( VOS_STATUS_SUCCESS != vosStatus )
8850 {
8851 return VOS_STATUS_E_INVAL;
8852 }
8853
8854 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
8855
8856 if( VOS_STATUS_SUCCESS != vosStatus )
8857 {
8858 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008859 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 vos_pkt_return_packet( pPacket );
8861 return VOS_STATUS_E_FAULT;
8862 }
8863
8864 //Generate most recent tlFCInfo. Most fields are correct.
8865 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
8866 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
8867 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
8868 {
8869 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
8870 {
8871 continue;
8872 }
8873
8874 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
8875 {
8876 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
8877 }
8878
8879 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
8880 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
8881 {
8882 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
8883
8884 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
8885
8886 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
8887 }
8888
8889 }
8890
8891 //request immediate feedback
8892 pTLCb->tlFCInfo.fcConfig |= 0x4;
8893
8894 //fill in BD to sent
8895 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
8896
8897 if( VOS_STATUS_SUCCESS != vosStatus )
8898 {
8899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008900 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 vos_pkt_return_packet( pPacket );
8902 return VOS_STATUS_E_FAULT;
8903 }
8904
8905 if (NULL != pTLCb->vosTxFCBuf)
8906 {
8907 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008908 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
8910 }
8911
8912 pTLCb->vosTxFCBuf = pPacket;
8913
8914 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
8915 (v_PVOID_t)WLANTL_TxCompDefaultCb);
8916 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8917
8918 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008919 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008920#endif
8921 return VOS_STATUS_SUCCESS;
8922}
8923
Jeff Johnson295189b2012-06-20 16:38:30 -07008924
8925/*==========================================================================
8926 FUNCTION WLANTL_GetTxResourcesCB
8927
8928 DESCRIPTION
8929 Processing function for Resource needed signal. A request will be issued
8930 to BAL to get more tx resources.
8931
8932 DEPENDENCIES
8933 The TL must be initialized before this function can be called.
8934
8935 PARAMETERS
8936
8937 IN
8938 pvosGCtx: pointer to the global vos context; a handle to TL's
8939 control block can be extracted from its context
8940
8941
8942 RETURN VALUE
8943 The result code associated with performing the operation
8944
8945 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8946 page fault
8947 VOS_STATUS_SUCCESS: Everything is good :)
8948
8949 Other values can be returned as a result of a function call, please check
8950 corresponding API for more info.
8951 SIDE EFFECTS
8952
8953============================================================================*/
8954VOS_STATUS
8955WLANTL_GetTxResourcesCB
8956(
8957 v_PVOID_t pvosGCtx
8958)
8959{
8960 WLANTL_CbType* pTLCb = NULL;
8961 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
8962 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8963 v_U8_t ucMgmt = 0;
8964 v_U8_t ucBAP = 0;
8965 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008966#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8967 tBssSystemRole systemRole;
8968 tpAniSirGlobal pMac;
8969#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8971 /*------------------------------------------------------------------------
8972 Extract TL control block
8973 ------------------------------------------------------------------------*/
8974 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8975 if ( NULL == pTLCb )
8976 {
8977 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8978 "WLAN TL:Invalid TL pointer from pvosGCtx on"
8979 " WLANTL_ProcessTxMessage"));
8980 return VOS_STATUS_E_FAULT;
8981 }
8982
8983 /*------------------------------------------------------------------------
8984 Get tx resources from BAL
8985 ------------------------------------------------------------------------*/
8986 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
8987
8988 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
8989 {
8990 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8991 "WLAN TL:TL failed to get resources from BAL, Err: %d",
8992 vosStatus));
8993 return vosStatus;
8994 }
8995
8996 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
8997 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
8998 changes should be done in BAL code of AMSS and WM */
8999 if (VOS_STATUS_E_RESOURCES == vosStatus)
9000 {
9001#ifdef VOLANS_PERF
9002 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
9003 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9004 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9005#else
9006 return VOS_STATUS_E_FAILURE;
9007#endif
9008 }
9009
9010 pTLCb->uResCount = uResCount;
9011
9012
Jeff Johnson295189b2012-06-20 16:38:30 -07009013#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9014 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9015 pTLCb->sendFCFrame ++;
9016 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9017 systemRole = wdaGetGlobalSystemRole(pMac);
9018 if (eSYSTEM_AP_ROLE == systemRole)
9019 {
9020 if (pTLCb->sendFCFrame % 16 == 0)
9021 {
9022 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9023 "Transmit FC"));
9024 WLANTL_TxFCFrame (pvosGCtx);
9025 }
9026 }
9027#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009028
9029 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9030 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9031 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9032 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9033 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9034
9035 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9036 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9037 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9038
9039 if (( 0 == pTLCb->ucTxSuspended ) &&
9040 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9041 {
9042 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9043 "Issuing Xmit start request to BAL for avail res SYNC"));
9044 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9045 }
9046 return vosStatus;
9047}/*WLANTL_GetTxResourcesCB*/
9048
9049/*==========================================================================
9050 Utility functions
9051 ==========================================================================*/
9052
9053/*==========================================================================
9054 FUNCTION WLANTL_Translate8023To80211Header
9055
9056 DESCRIPTION
9057 Inline function for translating and 802.11 header into an 802.3 header.
9058
9059 DEPENDENCIES
9060
9061
9062 PARAMETERS
9063
9064 IN
9065 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009066 IN/OUT
9067 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9068 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009069
9070 IN/OUT
9071 vosDataBuff: vos data buffer, will contain the new header on output
9072
9073 OUT
9074 pvosStatus: status of the operation
9075
9076 RETURN VALUE
9077
9078 VOS_STATUS_SUCCESS: Everything is good :)
9079
9080 Other error codes might be returned from the vos api used in the function
9081 please check those return values.
9082
9083 SIDE EFFECTS
9084
9085============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009086VOS_STATUS
9087WLANTL_Translate8023To80211Header
9088(
9089 vos_pkt_t* vosDataBuff,
9090 VOS_STATUS* pvosStatus,
9091 WLANTL_CbType* pTLCb,
9092 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009093 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009094 v_U8_t *ucWDSEnabled,
9095 v_U8_t *extraHeadSpace
9096)
Jeff Johnson295189b2012-06-20 16:38:30 -07009097{
9098 WLANTL_8023HeaderType w8023Header;
9099 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9100 VOS_STATUS vosStatus;
9101 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9102 v_U8_t ucHeaderSize = 0;
9103 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309104 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009105 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009106 v_U8_t ucStaId;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009107#ifdef FEATURE_WLAN_CCX_UPLOAD
9108 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9109 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9110 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 *ucWDSEnabled = 0; // default WDS off.
9113 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9114 sizeof(w8023Header));
9115
9116 if ( VOS_STATUS_SUCCESS != vosStatus )
9117 {
9118 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9119 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9120 return vosStatus;
9121 }
9122
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009123 if( NULL == pucStaId )
9124 {
9125 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9126 "WLAN TL: Invalid pointer for StaId"));
9127 return VOS_STATUS_E_INVAL;
9128 }
9129 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309130 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9131
9132 if ( NULL == pClientSTA )
9133 {
9134 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9135 "WLAN TL:Client Memory was not allocated on %s", __func__));
9136 return VOS_STATUS_E_FAILURE;
9137 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009138
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009139#ifdef FEATURE_WLAN_TDLS
9140
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309141 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9142 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009143 {
9144 v_U8_t ucIndex = 0;
9145 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9146 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309147 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309148 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9149 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309150 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009151 (void*)w8023Header.vDA, 6) )
9152 {
9153 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9154 "WLAN TL: Got a TDLS station. Using that index"));
9155 ucStaId = ucIndex;
9156 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309157 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9158 if ( NULL == pClientSTA )
9159 {
9160 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9161 "WLAN TL:Client Memory was not allocated on %s", __func__));
9162 return VOS_STATUS_E_FAILURE;
9163 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009164 break;
9165 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009166 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009167 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009168#endif
9169
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009170#ifdef FEATURE_WLAN_CCX_UPLOAD
9171if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsCcxSta))
9172{
9173 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9174 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9175 {
9176 /*The SNAP and the protocol type are already in the data buffer.
9177 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9178 bIAPPTxwithLLC = VOS_TRUE;
9179 }
9180 else
9181 {
9182 bIAPPTxwithLLC = VOS_FALSE;
9183 }
9184}
9185#endif /* FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009186
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009187 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
9188#ifdef FEATURE_WLAN_CCX_UPLOAD
9189 && (!bIAPPTxwithLLC)
9190#endif /* FEATURE_WLAN_CCX_UPLOAD */
9191 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 {
9193 /* Push the length */
9194 vosStatus = vos_pkt_push_head(vosDataBuff,
9195 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9196
9197 if ( VOS_STATUS_SUCCESS != vosStatus )
9198 {
9199 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9200 "WLAN TL: Packet push ether type fails on"
9201 " WLANTL_Translate8023To80211Header"));
9202 return vosStatus;
9203 }
9204
9205#ifdef BTAMP_TEST
9206 // The STA side will execute this, a hack to test BTAMP by using the
9207 // infra setup. On real BTAMP this will come from BAP itself.
9208 {
9209 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9210 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9211 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9212
9213 if ( VOS_STATUS_SUCCESS != vosStatus )
9214 {
9215 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9216 "WLAN TL: Packet push LLC header fails on"
9217 " WLANTL_Translate8023To80211Header"));
9218 return vosStatus;
9219 }
9220 }
9221#else
9222 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9223 sizeof(WLANTL_LLC_HEADER));
9224
9225 if ( VOS_STATUS_SUCCESS != vosStatus )
9226 {
9227 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9228 "WLAN TL: Packet push LLC header fails on"
9229 " WLANTL_Translate8023To80211Header"));
9230 return vosStatus;
9231 }
9232#endif
9233 }/*If add LLC is enabled*/
9234 else
9235 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009236#ifdef FEATURE_WLAN_CCX_UPLOAD
9237 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
9238#endif /* FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9240 "WLAN TL: STA Client registered to not remove LLC"
9241 " WLANTL_Translate8023To80211Header"));
9242 }
9243
9244#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309245 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009246#endif
9247
9248 // Find the space required for the 802.11 header format
9249 // based on the frame control fields.
9250 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309251 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 {
9253 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9254 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309255 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 {
9257 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 }
9260
9261 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9262 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9263
9264 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9265 if ( NULL == ppvBDHeader )
9266 {
9267 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9268 "WLAN TL:VOSS packet corrupted "));
9269 *pvosStatus = VOS_STATUS_E_INVAL;
9270 return *pvosStatus;
9271 }
9272
Jeff Johnson295189b2012-06-20 16:38:30 -07009273
9274 // OK now we have the space. Fill the 80211 header
9275 /* Fill A2 */
9276 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9277 // only clear the required space.
9278 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9279 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9280
9281
9282#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309283 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9284 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009285#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309286 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9287 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009288#endif
9289 {
9290 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309291 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 }
9293
9294 pw80211Header->usDurationId = 0;
9295 pw80211Header->usSeqCtrl = 0;
9296
9297 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9298
9299
9300
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309301 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 {
9303 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9304
Ravi Joshid0699502013-07-08 15:48:47 -07009305 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009306
9307 }
9308 else
9309 {
9310 pw80211Header->wFrmCtrl.subType = 0;
9311
9312 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9313 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9314 // pw80211Header->usQosCtrl = 0;
9315 }
9316
9317
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309318 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 {
Ravi Joshid0699502013-07-08 15:48:47 -07009320 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009321 pw80211Header->wFrmCtrl.toDS = 0;
9322 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009323
9324 /*
9325 * If the frame is a multicast frame, then, the Address1
9326 * should be the destination address filled in the packet. Which is
9327 * the multicast address. Otherwise, set it to BSSID
9328 */
9329 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9330 {
9331 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9332 (v_MACADDR_t*)&w8023Header.vDA);
9333 }
9334 else
9335 {
9336 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9337 &pClientSTA->wSTADesc.vSTAMACAddress);
9338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309340 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 VOS_MAC_ADDR_SIZE);
9342 break;
9343
Ravi Joshid0699502013-07-08 15:48:47 -07009344 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 *ucWDSEnabled = 1; // WDS on.
9346 pw80211Header->wFrmCtrl.toDS = 1;
9347 pw80211Header->wFrmCtrl.fromDS = 1;
9348 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309349 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009351 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309353 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 /* fill the optional A4 header */
9355 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009356 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009358 "BTAMP CASE NOW ---------staid=%d\n",
9359 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 break;
9361
Ravi Joshid0699502013-07-08 15:48:47 -07009362 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 *ucWDSEnabled = 0; // WDS off.
9364 pw80211Header->wFrmCtrl.toDS = 0;
9365 pw80211Header->wFrmCtrl.fromDS = 1;
9366 /*Copy the DA to A1*/
9367 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9368 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309369 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009371 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009373 "sw 802 to 80211 softap case ---------staid=%d\n",
9374 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009376#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009377 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009378 pw80211Header->wFrmCtrl.toDS = 0;
9379 pw80211Header->wFrmCtrl.fromDS = 0;
9380 /*Fix me*/
9381 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309382 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009383 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309384 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009385 VOS_MAC_ADDR_SIZE);
9386 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009387 ("TL:TDLS CASE NOW ---------staid=%d\n"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009388 break;
9389#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009390 case WLAN_STA_INFRA:
9391 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 pw80211Header->wFrmCtrl.toDS = 1;
9393 pw80211Header->wFrmCtrl.fromDS = 0;
9394 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309395 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009396 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9397 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Ravi Joshid0699502013-07-08 15:48:47 -07009398 "REGULAR INFRA LINK CASE---------staid=%d\n",
9399 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 break;
9401 }
9402 // OK now we have the space. Fill the 80211 header
9403 /* Fill A2 */
9404 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9405 return VOS_STATUS_SUCCESS;
9406}/*WLANTL_Translate8023To80211Header*/
9407
9408
9409/*=============================================================================
9410 BEGIN LOG FUNCTION !!! Remove me or clean me
9411=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009412#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009413
9414#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9415#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9416
9417static v_VOID_t WLANTL_DebugFrame
9418(
9419 v_PVOID_t dataPointer,
9420 v_U32_t dataSize
9421)
9422{
9423 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9424 v_U32_t numLines;
9425 v_U32_t numBytes;
9426 v_U32_t idx;
9427 v_U8_t *linePointer;
9428
9429 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9430 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9431 linePointer = (v_U8_t *)dataPointer;
9432
9433 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9434 for(idx = 0; idx < numLines; idx++)
9435 {
9436 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9437 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9438 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9439 "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x 0x%2x",
9440 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9441 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9442 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9443 }
9444
9445 if(0 == numBytes)
9446 return;
9447
9448 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9449 memcpy(lineBuffer, linePointer, numBytes);
9450 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9451 {
9452 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9453 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9454 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9455 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9456 break;
9457 }
9458
9459 return;
9460}
9461#endif
9462
9463/*=============================================================================
9464 END LOG FUNCTION
9465=============================================================================*/
9466
9467/*==========================================================================
9468 FUNCTION WLANTL_Translate80211To8023Header
9469
9470 DESCRIPTION
9471 Inline function for translating and 802.11 header into an 802.3 header.
9472
9473 DEPENDENCIES
9474
9475
9476 PARAMETERS
9477
9478 IN
9479 pTLCb: TL control block
9480 ucStaId: station ID
9481 ucHeaderLen: Length of the header from BD
9482 ucActualHLen: Length of header including padding or any other trailers
9483
9484 IN/OUT
9485 vosDataBuff: vos data buffer, will contain the new header on output
9486
9487 OUT
9488 pvosStatus: status of the operation
9489
9490 RETURN VALUE
9491
9492 The result code associated with performing the operation
9493 VOS_STATUS_SUCCESS: Everything is good :)
9494
9495 SIDE EFFECTS
9496
9497============================================================================*/
9498VOS_STATUS
9499WLANTL_Translate80211To8023Header
9500(
9501 vos_pkt_t* vosDataBuff,
9502 VOS_STATUS* pvosStatus,
9503 v_U16_t usActualHLen,
9504 v_U8_t ucHeaderLen,
9505 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009506 v_U8_t ucSTAId,
9507 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009508)
9509{
9510 WLANTL_8023HeaderType w8023Header;
9511 WLANTL_80211HeaderType w80211Header;
9512 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9513 VOS_STATUS vosStatus;
9514 v_U16_t usDataStartOffset = 0;
9515 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9516
9517 if ( sizeof(w80211Header) < ucHeaderLen )
9518 {
9519 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9520 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9521 sizeof(w80211Header), ucHeaderLen));
9522 ucHeaderLen = sizeof(w80211Header);
9523 }
9524
9525 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9526 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9527 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9528
9529 if ( VOS_STATUS_SUCCESS != vosStatus )
9530 {
9531 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9532 "WLAN TL: Failed to pop 80211 header from packet %d",
9533 vosStatus));
9534
9535 return vosStatus;
9536 }
9537
9538 switch ( w80211Header.wFrmCtrl.fromDS )
9539 {
9540 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 if ( w80211Header.wFrmCtrl.toDS )
9542 {
9543 //SoftAP AP mode
9544 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9545 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9546 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9547 "WLAN TL SoftAP: 802 3 DA %08x SA %08x \n",
9548 w8023Header.vDA, w8023Header.vSA));
9549 }
9550 else
9551 {
9552 /* IBSS */
9553 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9554 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 break;
9557 case 1:
9558 if ( w80211Header.wFrmCtrl.toDS )
9559 {
9560 /* BT-AMP case */
9561 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9562 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9563 }
9564 else
9565 { /* Infra */
9566 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9567 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9568 }
9569 break;
9570 }
9571
9572 if( usActualHLen > ucHeaderLen )
9573 {
9574 usDataStartOffset = usActualHLen - ucHeaderLen;
9575 }
9576
9577 if ( 0 < usDataStartOffset )
9578 {
9579 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
9580
9581 if ( VOS_STATUS_SUCCESS != vosStatus )
9582 {
9583 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9584 "WLAN TL: Failed to trim header from packet %d",
9585 vosStatus));
9586 return vosStatus;
9587 }
9588 }
9589
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309590 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9591 {
9592 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9593 "WLAN TL:Client Memory was not allocated on %s", __func__));
9594 return VOS_STATUS_E_FAILURE;
9595 }
9596
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009597 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
9598#ifdef FEATURE_WLAN_CCX_UPLOAD
9599 && (!bForwardIAPPwithLLC)
9600#endif /* FEATURE_WLAN_CCX_UPLOAD */
9601 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 {
9603 // Extract the LLC header
9604 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
9605 WLANTL_LLC_HEADER_LEN);
9606
9607 if ( VOS_STATUS_SUCCESS != vosStatus )
9608 {
9609 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9610 "WLAN TL: Failed to pop LLC header from packet %d",
9611 vosStatus));
9612
9613 return vosStatus;
9614 }
9615
9616 //Extract the length
9617 vos_mem_copy(&w8023Header.usLenType,
9618 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
9619 sizeof(w8023Header.usLenType) );
9620 }
9621 else
9622 {
9623 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
9624 &w8023Header.usLenType);
9625
9626 if ( VOS_STATUS_SUCCESS != vosStatus )
9627 {
9628 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9629 "WLAN TL: Failed to get packet length %d",
9630 vosStatus));
9631
9632 return vosStatus;
9633 }
9634
9635 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9636 "WLAN TL: BTAMP len (ethertype) fld = %d",
9637 w8023Header.usLenType));
9638 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
9639 }
9640
9641 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
9642
9643#ifdef BTAMP_TEST
9644 {
9645 // AP side will execute this.
9646 v_U8_t *temp_w8023Header = NULL;
9647 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
9648 &temp_w8023Header, sizeof(w8023Header) );
9649 }
9650#endif
9651#if 0 /*TL_DEBUG*/
9652 vos_pkt_get_packet_length(vosDataBuff, &usLen);
9653 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
9654
9655 WLANTL_DebugFrame(aucData, usLen);
9656
9657 vos_pkt_push_head(vosDataBuff, aucData, usLen);
9658
9659#endif
9660
9661 *pvosStatus = VOS_STATUS_SUCCESS;
9662
9663 return VOS_STATUS_SUCCESS;
9664}/*WLANTL_Translate80211To8023Header*/
9665
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009666/*==========================================================================
9667 FUNCTION WLANTL_FindFrameTypeBcMcUc
9668
9669 DESCRIPTION
9670 Utility function to find whether received frame is broadcast, multicast
9671 or unicast.
9672
9673 DEPENDENCIES
9674 The STA must be registered with TL before this function can be called.
9675
9676 PARAMETERS
9677
9678 IN
9679 pTLCb: pointer to the TL's control block
9680 ucSTAId: identifier of the station being processed
9681 vosDataBuff: pointer to the vos buffer
9682
9683 IN/OUT
9684 pucBcMcUc: pointer to buffer, will contain frame type on return
9685
9686 RETURN VALUE
9687 The result code associated with performing the operation
9688
9689 VOS_STATUS_E_INVAL: invalid input parameters
9690 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
9691 VOS_STATUS_SUCCESS: success
9692
9693 SIDE EFFECTS
9694 None.
9695============================================================================*/
9696VOS_STATUS
9697WLANTL_FindFrameTypeBcMcUc
9698(
9699 WLANTL_CbType *pTLCb,
9700 v_U8_t ucSTAId,
9701 vos_pkt_t *vosDataBuff,
9702 v_U8_t *pucBcMcUc
9703)
9704{
9705 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9706 v_PVOID_t aucBDHeader;
9707 v_PVOID_t pvPeekData;
9708 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9709
9710 /*------------------------------------------------------------------------
9711 Sanity check
9712 ------------------------------------------------------------------------*/
9713 if ((NULL == pTLCb) ||
9714 (NULL == vosDataBuff) ||
9715 (NULL == pucBcMcUc))
9716 {
9717 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9718 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
9719 return VOS_STATUS_E_INVAL;
9720 }
9721
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309722 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9723 {
9724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9725 "WLAN TL:Client Memory was not allocated on %s", __func__));
9726 return VOS_STATUS_E_FAILURE;
9727 }
9728
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009729 /*------------------------------------------------------------------------
9730 Extract BD header and check if valid
9731 ------------------------------------------------------------------------*/
9732 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
9733
9734 if (NULL == aucBDHeader)
9735 {
9736 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9737 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
9738 VOS_ASSERT(0);
9739 return VOS_STATUS_E_BADMSG;
9740 }
9741
9742 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309743 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009744 {
9745 /* Its an 802.11 frame, extract MAC address 1 */
9746 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9747 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
9748 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
9749 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9750 }
9751 else
9752 {
9753 /* Its an 802.3 frame, extract Destination MAC address */
9754 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9755 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
9756 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
9757 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9758 }
9759
9760 if (VOS_STATUS_SUCCESS != vosStatus)
9761 {
9762 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9763 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
9764 return vosStatus;
9765 }
9766
9767 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
9768 {
9769 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
9770 }
9771 else
9772 {
9773 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
9774 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
9775 else
9776 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
9777 }
9778
9779 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9780 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
9781 ((tANI_U8 *)pvPeekData)[0]));
9782
9783 return VOS_STATUS_SUCCESS;
9784}
9785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786#if 0
9787#ifdef WLAN_PERF
9788/*==========================================================================
9789 FUNCTION WLANTL_FastHwFwdDataFrame
9790
9791 DESCRIPTION
9792 Fast path function to quickly forward a data frame if HAL determines BD
9793 signature computed here matches the signature inside current VOSS packet.
9794 If there is a match, HAL and TL fills in the swapped packet length into
9795 BD header and DxE header, respectively. Otherwise, packet goes back to
9796 normal (slow) path and a new BD signature would be tagged into BD in this
9797 VOSS packet later by the WLANHAL_FillTxBd() function.
9798
9799 DEPENDENCIES
9800
9801 PARAMETERS
9802
9803 IN
9804 pvosGCtx VOS context
9805 vosDataBuff Ptr to VOSS packet
9806 pMetaInfo For getting frame's TID
9807 pStaInfo For checking STA type
9808
9809 OUT
9810 pvosStatus returned status
9811 puFastFwdOK Flag to indicate whether frame could be fast forwarded
9812
9813 RETURN VALUE
9814 No return.
9815
9816 SIDE EFFECTS
9817
9818============================================================================*/
9819static void
9820WLANTL_FastHwFwdDataFrame
9821(
9822 v_PVOID_t pvosGCtx,
9823 vos_pkt_t* vosDataBuff,
9824 VOS_STATUS* pvosStatus,
9825 v_U32_t* puFastFwdOK,
9826 WLANTL_MetaInfoType* pMetaInfo,
9827 WLAN_STADescType* pStaInfo
9828
9829)
9830{
9831 v_PVOID_t pvPeekData;
9832 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
9833 v_U8_t ucIsUnicast;
9834 WLANBAL_sDXEHeaderType *pDxEHeader;
9835 v_PVOID_t pvBDHeader;
9836 v_PVOID_t pucBuffPtr;
9837 v_U16_t usPktLen;
9838
9839 /*-----------------------------------------------------------------------
9840 Extract packet length
9841 -----------------------------------------------------------------------*/
9842
9843 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9844
9845 /*-----------------------------------------------------------------------
9846 Extract MAC address
9847 -----------------------------------------------------------------------*/
9848 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
9849 WLANTL_MAC_ADDR_ALIGN(0),
9850 (v_PVOID_t)&pvPeekData,
9851 VOS_MAC_ADDR_SIZE );
9852
9853 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9854 {
9855 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9856 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9857 *pvosStatus));
9858 *pvosStatus = VOS_STATUS_E_INVAL;
9859 return;
9860 }
9861
9862 /*-----------------------------------------------------------------------
9863 Reserve head room for DxE header, BD, and WLAN header
9864 -----------------------------------------------------------------------*/
9865
9866 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
9867 ucDxEBDWLANHeaderLen );
9868 if ( NULL == pucBuffPtr )
9869 {
9870 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9871 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
9872 *pvosStatus = VOS_STATUS_E_INVAL;
9873 return;
9874 }
9875 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
9876 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
9877
9878 /* UMA Tx acceleration is enabled.
9879 * UMA would help convert frames to 802.11, fill partial BD fields and
9880 * construct LLC header. To further accelerate this kind of frames,
9881 * HAL would attempt to reuse the BD descriptor if the BD signature
9882 * matches to the saved BD descriptor.
9883 */
9884 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
9885 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
9886 else
9887 ucIsUnicast = 1;
9888
9889 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
9890
9891 /* Can't be fast forwarded. Trim the VOS head back to original location. */
9892 if(! *puFastFwdOK){
9893 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
9894 }else{
9895 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
9896 */
9897 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
9898 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
9899 (v_PVOID_t)uPacketSize);
9900 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
9901 }
9902 *pvosStatus = VOS_STATUS_SUCCESS;
9903 return;
9904}
9905#endif /*WLAN_PERF*/
9906#endif
9907
9908#if 0
9909/*==========================================================================
9910 FUNCTION WLANTL_PrepareBDHeader
9911
9912 DESCRIPTION
9913 Inline function for preparing BD header before HAL processing.
9914
9915 DEPENDENCIES
9916 Just notify HAL that suspend in TL is complete.
9917
9918 PARAMETERS
9919
9920 IN
9921 vosDataBuff: vos data buffer
9922 ucDisableFrmXtl: is frame xtl disabled
9923
9924 OUT
9925 ppvBDHeader: it will contain the BD header
9926 pvDestMacAdddr: it will contain the destination MAC address
9927 pvosStatus: status of the combined processing
9928 pusPktLen: packet len.
9929
9930 RETURN VALUE
9931 No return.
9932
9933 SIDE EFFECTS
9934
9935============================================================================*/
9936void
9937WLANTL_PrepareBDHeader
9938(
9939 vos_pkt_t* vosDataBuff,
9940 v_PVOID_t* ppvBDHeader,
9941 v_MACADDR_t* pvDestMacAdddr,
9942 v_U8_t ucDisableFrmXtl,
9943 VOS_STATUS* pvosStatus,
9944 v_U16_t* pusPktLen,
9945 v_U8_t ucQosEnabled,
9946 v_U8_t ucWDSEnabled,
9947 v_U8_t extraHeadSpace
9948)
9949{
9950 v_U8_t ucHeaderOffset;
9951 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
9953
9954 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9955 /*-------------------------------------------------------------------------
9956 Get header pointer from VOSS
9957 !!! make sure reserve head zeros out the memory
9958 -------------------------------------------------------------------------*/
9959 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
9960
9961 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
9962 {
9963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9964 "WLAN TL: Length of the packet smaller than expected network"
9965 " header %d", *pusPktLen ));
9966
9967 *pvosStatus = VOS_STATUS_E_INVAL;
9968 return;
9969 }
9970
9971 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
9972 ucBDHeaderLen );
9973 if ( NULL == *ppvBDHeader )
9974 {
9975 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9976 "WLAN TL:VOSS packet corrupted on Attach BD header"));
9977 *pvosStatus = VOS_STATUS_E_INVAL;
9978 return;
9979 }
9980
9981 /*-----------------------------------------------------------------------
9982 Extract MAC address
9983 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009984 {
9985 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
9986 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
9987 ucBDHeaderLen +
9988 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
9989 (v_PVOID_t)pvDestMacAdddr,
9990 &usMacAddrSize );
9991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9993 {
9994 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9995 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9996 *pvosStatus));
9997 }
9998 else
9999 {
10000 /*---------------------------------------------------------------------
10001 Fill MPDU info fields:
10002 - MPDU data start offset
10003 - MPDU header start offset
10004 - MPDU header length
10005 - MPDU length - this is a 16b field - needs swapping
10006 --------------------------------------------------------------------*/
10007 ucHeaderOffset = ucBDHeaderLen;
10008 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10009
10010 if ( 0 != ucDisableFrmXtl )
10011 {
10012 if ( 0 != ucQosEnabled )
10013 {
10014 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10015 }
10016
10017 // Similar to Qos we need something for WDS format !
10018 if ( ucWDSEnabled != 0 )
10019 {
10020 // If we have frame translation enabled
10021 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10022 }
10023 if ( extraHeadSpace != 0 )
10024 {
10025 // Decrease the packet length with the extra padding after the header
10026 *pusPktLen = *pusPktLen - extraHeadSpace;
10027 }
10028 }
10029
10030 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10031 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10032 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10033 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10034 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10035
10036 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10037 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10038 ucHeaderLen, ucHeaderOffset,
10039 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10040 *pusPktLen, extraHeadSpace));
10041 }/* if peek MAC success*/
10042
10043}/* WLANTL_PrepareBDHeader */
10044#endif
10045
Jeff Johnson295189b2012-06-20 16:38:30 -070010046//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10047/*==========================================================================
10048 FUNCTION WLAN_TLGetNextTxIds
10049
10050 DESCRIPTION
10051 Gets the next station and next AC in the list that should be served by the TL.
10052
10053 Multiple Station Scheduling and TL queue management.
10054
10055 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10056 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10057 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10058 or not.
10059
10060 Stations are served in a round-robin fashion from highest priority to lowest priority.
10061 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10062 the traffic of different prioirty. As such, stations can not provide low priority packets if
10063 high priority packets are all served.
10064
10065 DEPENDENCIES
10066
10067 PARAMETERS
10068
10069 IN
10070 pvosGCtx: pointer to the global vos context; a handle to TL's
10071 control block can be extracted from its context
10072
10073 OUT
10074 pucSTAId: Station ID
10075
10076 RETURN VALUE
10077 The result code associated with performing the operation
10078
10079 VOS_STATUS_SUCCESS: Everything is good
10080
10081 SIDE EFFECTS
10082
10083 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10084 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10085 When existing from the function, these three fields are changed accordingly.
10086
10087============================================================================*/
10088VOS_STATUS
10089WLAN_TLAPGetNextTxIds
10090(
10091 v_PVOID_t pvosGCtx,
10092 v_U8_t* pucSTAId
10093)
10094{
10095 WLANTL_CbType* pTLCb;
10096 v_U8_t ucACFilter = 1;
10097 v_U8_t ucNextSTA ;
10098 v_BOOL_t isServed = TRUE; //current round has find a packet or not
10099 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
10100 v_U8_t uFlowMask; // TX FlowMask from WDA
10101 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010102 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 /*------------------------------------------------------------------------
10104 Extract TL control block
10105 ------------------------------------------------------------------------*/
10106 //ENTER();
10107
10108 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10109 if ( NULL == pTLCb )
10110 {
10111 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10112 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10113 return VOS_STATUS_E_FAULT;
10114 }
10115
10116 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10117 {
10118 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10119 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10120 return VOS_STATUS_E_FAULT;
10121 }
10122
10123 ucNextSTA = pTLCb->ucCurrentSTA;
10124
10125 ++ucNextSTA;
10126
10127 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10128 {
10129 //one round is done.
10130 ucNextSTA = 0;
10131 pTLCb->ucCurLeftWeight--;
10132 isServed = FALSE;
10133 if ( 0 == pTLCb->ucCurLeftWeight )
10134 {
10135 //current prioirty is done
10136 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10137 {
10138 //end of current VO, VI, BE, BK loop. Reset priority.
10139 pTLCb->uCurServedAC = WLANTL_AC_VO;
10140 }
10141 else
10142 {
10143 pTLCb->uCurServedAC --;
10144 }
10145
10146 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10147
10148 } // (0 == pTLCb->ucCurLeftWeight)
10149 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10150
10151 //decide how many loops to go. if current loop is partial, do one extra to make sure
10152 //we cover every station
10153 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10154 {
10155 ucACLoopNum ++; // now is 5 loops
10156 }
10157
10158 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10159 all have previous values.*/
10160 for (; ucACLoopNum > 0; ucACLoopNum--)
10161 {
10162
10163 ucACFilter = 1 << pTLCb->uCurServedAC;
10164
10165 // pTLCb->ucCurLeftWeight keeps previous results.
10166 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
10167 {
10168
10169 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10170 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010171 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10172 {
10173 continue;
10174 }
10175 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010176
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010177 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10178 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 (0 == (ucACMask & ucACFilter)) )
10180
10181 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010182 //current station does not exist or have any packet to serve.
10183 continue;
10184 }
10185
10186 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10187 {
10188 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10189 "%s Sta %d not in auth state so skipping it.",
10190 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 continue;
10192 }
10193
10194 //go to next station if current station can't send due to flow control
10195 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10196 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10197 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010198 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10199 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10200 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010201 )
10202 {
10203 continue;
10204 }
10205
10206
10207 // Find a station. Weight is updated already.
10208 *pucSTAId = ucNextSTA;
10209 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010210 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010211
10212 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10213 " TL serve one station AC: %d W: %d StaId: %d",
10214 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10215
10216 return VOS_STATUS_SUCCESS;
10217 } //STA loop
10218
10219 ucNextSTA = 0;
10220 if ( FALSE == isServed )
10221 {
10222 //current loop finds no packet.no need to repeat for the same priority
10223 break;
10224 }
10225 //current loop is partial loop. go for one more loop.
10226 isServed = FALSE;
10227
10228 } //Weight loop
10229
10230 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10231 {
10232 pTLCb->uCurServedAC = WLANTL_AC_VO;
10233 }
10234 else
10235 {
10236 pTLCb->uCurServedAC--;
10237 }
10238 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10239
10240 }// AC loop
10241
10242 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10243 " TL can't find one station to serve \n" ));
10244
10245 pTLCb->uCurServedAC = WLANTL_AC_BK;
10246 pTLCb->ucCurLeftWeight = 1;
10247 //invalid number will be captured by caller
10248 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10249
10250 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 return VOS_STATUS_E_FAULT;
10252}
10253
10254
10255/*==========================================================================
10256 FUNCTION WLAN_TLGetNextTxIds
10257
10258 DESCRIPTION
10259 Gets the next station and next AC in the list
10260
10261 DEPENDENCIES
10262
10263 PARAMETERS
10264
10265 IN
10266 pvosGCtx: pointer to the global vos context; a handle to TL's
10267 control block can be extracted from its context
10268
10269 OUT
10270 pucSTAId: Station ID
10271
10272
10273 RETURN VALUE
10274 The result code associated with performing the operation
10275
10276 VOS_STATUS_SUCCESS: Everything is good :)
10277
10278 SIDE EFFECTS
10279
10280============================================================================*/
10281VOS_STATUS
10282WLAN_TLGetNextTxIds
10283(
10284 v_PVOID_t pvosGCtx,
10285 v_U8_t* pucSTAId
10286)
10287{
10288 WLANTL_CbType* pTLCb;
10289 v_U8_t ucNextAC;
10290 v_U8_t ucNextSTA;
10291 v_U8_t ucCount;
10292 v_U8_t uFlowMask; // TX FlowMask from WDA
10293 v_U8_t ucACMask = 0;
10294 v_U8_t i = 0;
10295
10296 tBssSystemRole systemRole; //RG HACK to be removed
10297 tpAniSirGlobal pMac;
10298
10299 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10300 if ( NULL == pMac )
10301 {
10302 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010303 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 return VOS_STATUS_E_FAULT;
10305 }
10306
10307 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010308
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 /*------------------------------------------------------------------------
10310 Extract TL control block
10311 ------------------------------------------------------------------------*/
10312 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10313 if ( NULL == pTLCb )
10314 {
10315 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10316 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10317 return VOS_STATUS_E_FAULT;
10318 }
10319
Sunil Ravid5406f22013-01-22 00:18:31 -080010320#ifdef FEATURE_WLAN_TDLS
10321 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()) || pTLCb->ucTdlsPeerCount)
10322#else
10323 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()))
10324#endif
10325 {
10326 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10327 }
10328
10329
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10331 {
10332 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10333 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10334 return VOS_STATUS_E_FAULT;
10335 }
10336
10337 /*STA id - no priority yet implemented */
10338 /*-----------------------------------------------------------------------
10339 Choose the next STA for tx - for now go in a round robin fashion
10340 through all the stations that have pending packets
10341 -------------------------------------------------------------------------*/
10342 ucNextSTA = pTLCb->ucCurrentSTA;
10343
10344 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10345 for ( ucCount = 0;
10346 ucCount < WLAN_MAX_STA_COUNT;
10347 ucCount++ )
10348 {
10349 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010350 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10351 {
10352 continue;
10353 }
10354 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10355 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010357 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10358 {
10359 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10360 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10361 pTLCb->ucCurrentSTA = ucNextSTA;
10362 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010363 }
10364 else
10365 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010366 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10367 "%s Sta %d is not in auth state, skipping this sta.",
10368 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 }
10371 }
10372
10373 *pucSTAId = pTLCb->ucCurrentSTA;
10374
10375 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10376 {
10377 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10378 "WLAN TL:No station registered with TL at this point"));
10379
10380 return VOS_STATUS_E_FAULT;
10381
10382 }
10383
10384 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010385 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010386
10387 if ( 0 == ucACMask )
10388 {
10389 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10390 "WLAN TL: Mask 0 "
10391 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10392
10393 /*setting STA id to invalid if mask is 0*/
10394 *pucSTAId = WLAN_MAX_STA_COUNT;
10395
10396 return VOS_STATUS_E_FAULT;
10397 }
10398
10399 /*-----------------------------------------------------------------------
10400 AC is updated whenever a packet is fetched from HDD -> the current
10401 weight of such an AC cannot be 0 -> in this case TL is expected to
10402 exit this function at this point during the main Tx loop
10403 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010404 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 {
10406 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10407 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010408 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10409 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 return VOS_STATUS_SUCCESS;
10411 }
10412
10413 /*-----------------------------------------------------------------------
10414 Choose highest priority AC - !!! optimize me
10415 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010416 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10418 "Next AC: %d", ucNextAC));
10419
10420 while ( 0 != ucACMask )
10421 {
10422 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10423 " AC Mask: %d Next: %d Res : %d",
10424 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10425
10426 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10427 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010428 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010430 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010431 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10432
10433 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10434 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010435 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10436 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 break;
10438 }
10439
10440 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10441
10442 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10443 "Next AC %d", ucNextAC));
10444
10445 }
10446
10447 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10448 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010449 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10450 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010451
10452 return VOS_STATUS_SUCCESS;
10453}/* WLAN_TLGetNextTxIds */
10454
Jeff Johnson295189b2012-06-20 16:38:30 -070010455
10456
10457/*==========================================================================
10458 DEFAULT HANDLERS: Registered at initialization with TL
10459 ==========================================================================*/
10460
10461/*==========================================================================
10462
10463 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10464
10465 DESCRIPTION
10466 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10467 called it means there is no registered rx cb pointer for Mgmt Frm.
10468
10469 DEPENDENCIES
10470
10471 PARAMETERS
10472 Not used.
10473
10474 RETURN VALUE
10475
10476 VOS_STATUS_E_FAILURE: Always FAILURE.
10477
10478============================================================================*/
10479VOS_STATUS
10480WLANTL_MgmtFrmRxDefaultCb
10481(
10482 v_PVOID_t pvosGCtx,
10483 v_PVOID_t vosBuff
10484)
10485{
10486 if ( NULL != vosBuff )
10487 {
10488 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10489 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10490 /* Drop packet */
10491 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10492 }
10493
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10495 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010496
10497 return VOS_STATUS_E_FAILURE;
10498}/*WLANTL_MgmtFrmRxDefaultCb*/
10499
10500/*==========================================================================
10501
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010502 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070010503
10504 DESCRIPTION
10505 Default BAP rx callback: asserts all the time. If this function gets
10506 called it means there is no registered rx cb pointer for BAP.
10507
10508 DEPENDENCIES
10509
10510 PARAMETERS
10511 Not used.
10512
10513 RETURN VALUE
10514
10515 VOS_STATUS_E_FAILURE: Always FAILURE.
10516
10517============================================================================*/
10518VOS_STATUS
10519WLANTL_BAPRxDefaultCb
10520(
10521 v_PVOID_t pvosGCtx,
10522 vos_pkt_t* vosDataBuff,
10523 WLANTL_BAPFrameEnumType frameType
10524)
10525{
10526 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10527 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10528#ifndef BTAMP_TEST
10529 VOS_ASSERT(0);
10530#endif
10531 return VOS_STATUS_E_FAILURE;
10532}/*WLANTL_MgmtFrmRxDefaultCb*/
10533
10534/*==========================================================================
10535
10536 FUNCTION WLANTL_STARxDefaultCb
10537
10538 DESCRIPTION
10539 Default STA rx callback: asserts all the time. If this function gets
10540 called it means there is no registered rx cb pointer for station.
10541 (Mem corruption most likely, it should never happen)
10542
10543 DEPENDENCIES
10544
10545 PARAMETERS
10546 Not used.
10547
10548 RETURN VALUE
10549
10550 VOS_STATUS_E_FAILURE: Always FAILURE.
10551
10552============================================================================*/
10553VOS_STATUS
10554WLANTL_STARxDefaultCb
10555(
10556 v_PVOID_t pvosGCtx,
10557 vos_pkt_t* vosDataBuff,
10558 v_U8_t ucSTAId,
10559 WLANTL_RxMetaInfoType* pRxMetaInfo
10560)
10561{
10562 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10563 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10564 ucSTAId));
10565 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010566 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010567}/*WLANTL_MgmtFrmRxDefaultCb*/
10568
10569
10570/*==========================================================================
10571
10572 FUNCTION WLANTL_STAFetchPktDefaultCb
10573
10574 DESCRIPTION
10575 Default fetch callback: asserts all the time. If this function gets
10576 called it means there is no registered fetch cb pointer for station.
10577 (Mem corruption most likely, it should never happen)
10578
10579 DEPENDENCIES
10580
10581 PARAMETERS
10582 Not used.
10583
10584 RETURN VALUE
10585
10586 VOS_STATUS_E_FAILURE: Always FAILURE.
10587
10588============================================================================*/
10589VOS_STATUS
10590WLANTL_STAFetchPktDefaultCb
10591(
10592 v_PVOID_t pvosGCtx,
10593 v_U8_t* pucSTAId,
10594 WLANTL_ACEnumType ucAC,
10595 vos_pkt_t** vosDataBuff,
10596 WLANTL_MetaInfoType* tlMetaInfo
10597)
10598{
10599 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10600 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
10601 VOS_ASSERT(0);
10602 return VOS_STATUS_E_FAILURE;
10603}/*WLANTL_MgmtFrmRxDefaultCb*/
10604
10605/*==========================================================================
10606
10607 FUNCTION WLANTL_TxCompDefaultCb
10608
10609 DESCRIPTION
10610 Default tx complete handler. It will release the completed pkt to
10611 prevent memory leaks.
10612
10613 PARAMETERS
10614
10615 IN
10616 pvosGCtx: pointer to the global vos context; a handle to
10617 TL/HAL/PE/BAP/HDD control block can be extracted from
10618 its context
10619 vosDataBuff: pointer to the VOSS data buffer that was transmitted
10620 wTxSTAtus: status of the transmission
10621
10622
10623 RETURN VALUE
10624 The result code associated with performing the operation; please
10625 check vos_pkt_return_packet for possible error codes.
10626
10627 Please check vos_pkt_return_packet API for possible return values.
10628
10629============================================================================*/
10630VOS_STATUS
10631WLANTL_TxCompDefaultCb
10632(
10633 v_PVOID_t pvosGCtx,
10634 vos_pkt_t* vosDataBuff,
10635 VOS_STATUS wTxSTAtus
10636)
10637{
10638 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10639 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
10640 return vos_pkt_return_packet(vosDataBuff);
10641}/*WLANTL_TxCompDefaultCb*/
10642
10643
10644/*==========================================================================
10645 Cleanup functions
10646 ==========================================================================*/
10647
10648/*==========================================================================
10649
10650 FUNCTION WLANTL_CleanCB
10651
10652 DESCRIPTION
10653 Cleans TL control block
10654
10655 DEPENDENCIES
10656
10657 PARAMETERS
10658
10659 IN
10660 pTLCb: pointer to TL's control block
10661 ucEmpty: set if TL has to clean up the queues and release pedning pkts
10662
10663 RETURN VALUE
10664 The result code associated with performing the operation
10665
10666 VOS_STATUS_E_INVAL: invalid input parameters
10667 VOS_STATUS_SUCCESS: Everything is good :)
10668
10669 SIDE EFFECTS
10670
10671============================================================================*/
10672VOS_STATUS
10673WLANTL_CleanCB
10674(
10675 WLANTL_CbType* pTLCb,
10676 v_U8_t ucEmpty
10677)
10678{
10679 v_U8_t ucIndex;
10680 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10681
10682 /*-------------------------------------------------------------------------
10683 Sanity check
10684 -------------------------------------------------------------------------*/
10685 if ( NULL == pTLCb )
10686 {
10687 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10688 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
10689 return VOS_STATUS_E_INVAL;
10690 }
10691
10692 /* number of packets sent to BAL waiting for tx complete confirmation */
10693 pTLCb->usPendingTxCompleteCount = 0;
10694
10695 /* global suspend flag */
10696 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
10697
10698 /* resource flag */
10699 pTLCb->uResCount = 0;
10700
10701
10702 /*-------------------------------------------------------------------------
10703 Client stations
10704 -------------------------------------------------------------------------*/
10705 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10706 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010707 if(NULL != pTLCb->atlSTAClients[ucIndex])
10708 {
10709 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
10710 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 }
10712
10713 /*-------------------------------------------------------------------------
10714 Management Frame client
10715 -------------------------------------------------------------------------*/
10716 pTLCb->tlMgmtFrmClient.ucExists = 0;
10717
10718 if ( ( 0 != ucEmpty) &&
10719 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
10720 {
10721 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
10722 }
10723
10724 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
10725
10726 /* set to a default cb in order to prevent constant checking for NULL */
10727 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
10728
10729 /*-------------------------------------------------------------------------
10730 BT AMP client
10731 -------------------------------------------------------------------------*/
10732 pTLCb->tlBAPClient.ucExists = 0;
10733
10734 if (( 0 != ucEmpty) &&
10735 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
10736 {
10737 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
10738 }
10739
10740 if (( 0 != ucEmpty) &&
10741 ( NULL != pTLCb->vosDummyBuf ))
10742 {
10743 vos_pkt_return_packet(pTLCb->vosDummyBuf);
10744 }
10745
10746 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
10747
10748 pTLCb->vosDummyBuf = NULL;
10749 pTLCb->vosTempBuf = NULL;
10750 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
10751
10752 /* set to a default cb in order to prevent constant checking for NULL */
10753 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
10754
10755 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
10756
10757 return VOS_STATUS_SUCCESS;
10758
10759}/* WLANTL_CleanCB*/
10760
10761/*==========================================================================
10762
10763 FUNCTION WLANTL_CleanSTA
10764
10765 DESCRIPTION
10766 Cleans a station control block.
10767
10768 DEPENDENCIES
10769
10770 PARAMETERS
10771
10772 IN
10773 pvosGCtx: pointer to the global vos context; a handle to TL's
10774 control block can be extracted from its context
10775 ucEmpty: if set the queues and pending pkts will be emptyed
10776
10777 RETURN VALUE
10778 The result code associated with performing the operation
10779
10780 VOS_STATUS_E_INVAL: invalid input parameters
10781 VOS_STATUS_SUCCESS: Everything is good :)
10782
10783 SIDE EFFECTS
10784
10785============================================================================*/
10786VOS_STATUS
10787WLANTL_CleanSTA
10788(
10789 WLANTL_STAClientType* ptlSTAClient,
10790 v_U8_t ucEmpty
10791)
10792{
10793 v_U8_t ucIndex;
10794 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10795
10796 /*-------------------------------------------------------------------------
10797 Sanity check
10798 -------------------------------------------------------------------------*/
10799 if ( NULL == ptlSTAClient )
10800 {
10801 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10802 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
10803 return VOS_STATUS_E_INVAL;
10804 }
10805
10806 /*------------------------------------------------------------------------
10807 Clear station from TL
10808 ------------------------------------------------------------------------*/
10809 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10810 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
10811 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
10812
10813 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
10814 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
10815 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
10816
10817 ptlSTAClient->tlState = WLANTL_STA_INIT;
10818 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
10819
10820 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
10821 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
10822 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
10823
10824 ptlSTAClient->wSTADesc.ucSTAId = 0;
10825 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
10826
10827 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
10828 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
10829 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
10830 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
10831 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
10832
10833 /*-------------------------------------------------------------------------
10834 AMSDU information for the STA
10835 -------------------------------------------------------------------------*/
10836 if ( ( 0 != ucEmpty ) &&
10837 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
10838 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010839 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080010840 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010841 "suspecting a memory corruption"));
10842
Jeff Johnson295189b2012-06-20 16:38:30 -070010843 }
10844
10845 ptlSTAClient->vosAMSDUChain = NULL;
10846 ptlSTAClient->vosAMSDUChainRoot = NULL;
10847
10848 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
10849 WLANTL_MPDU_HEADER_LEN);
10850 ptlSTAClient->ucMPDUHeaderLen = 0;
10851
10852 /*-------------------------------------------------------------------------
10853 Reordering information for the STA
10854 -------------------------------------------------------------------------*/
10855 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
10856 {
10857 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
10858 {
10859 continue;
10860 }
10861 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
10862 {
10863 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
10864 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
10865 }
10866 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
10867 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
10868 }
10869
10870 /*-------------------------------------------------------------------------
10871 QOS information for the STA
10872 -------------------------------------------------------------------------*/
10873 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
10874 ptlSTAClient->ucCurrentWeight = 0;
10875 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
10876
10877 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
10878 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
10879
10880
10881 /*--------------------------------------------------------------------
10882 Stats info
10883 --------------------------------------------------------------------*/
10884 vos_mem_zero( ptlSTAClient->auRxCount,
10885 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
10886 vos_mem_zero( ptlSTAClient->auTxCount,
10887 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
10888 ptlSTAClient->rssiAvg = 0;
10889
10890 /*Tx not suspended and station fully registered*/
10891 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
10892 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
10893
10894 if ( 0 == ucEmpty )
10895 {
10896 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
10897 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
10898 }
10899
10900 ptlSTAClient->ucExists = 0;
10901
10902 /*--------------------------------------------------------------------
10903 Statistics info
10904 --------------------------------------------------------------------*/
10905 memset(&ptlSTAClient->trafficStatistics,
10906 0,
10907 sizeof(WLANTL_TRANSFER_STA_TYPE));
10908
10909 /*fix me!!: add new values from the TL Cb for cleanup */
10910 return VOS_STATUS_SUCCESS;
10911}/* WLANTL_CleanSTA */
10912
10913
10914/*==========================================================================
10915 FUNCTION WLANTL_EnableUAPSDForAC
10916
10917 DESCRIPTION
10918 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
10919 logic in FW/SLM to start sending trigger frames. Previously TL had the
10920 trigger frame logic which later moved down to FW. Hence
10921 HDD -> TL -> WDA -> FW call flow.
10922
10923 DEPENDENCIES
10924 The TL must be initialized before this function can be called.
10925
10926 PARAMETERS
10927
10928 IN
10929 pvosGCtx: pointer to the global vos context; a handle to TL's
10930 control block can be extracted from its context
10931 ucSTAId: station Id
10932 ucAC: AC for which U-APSD is being enabled
10933 ucTid: TID for which U-APSD is setup
10934 ucUP: used to place in the trigger frame generation
10935 ucServiceInt: service interval used by TL to send trigger frames
10936 ucSuspendInt: suspend interval used by TL to determine that an
10937 app is idle and should start sending trigg frms less often
10938 wTSDir: direction of TSpec
10939
10940 RETURN VALUE
10941 The result code associated with performing the operation
10942
10943 VOS_STATUS_SUCCESS: Everything is good :)
10944
10945 SIDE EFFECTS
10946
10947============================================================================*/
10948VOS_STATUS
10949WLANTL_EnableUAPSDForAC
10950(
10951 v_PVOID_t pvosGCtx,
10952 v_U8_t ucSTAId,
10953 WLANTL_ACEnumType ucAC,
10954 v_U8_t ucTid,
10955 v_U8_t ucUP,
10956 v_U32_t uServiceInt,
10957 v_U32_t uSuspendInt,
10958 WLANTL_TSDirType wTSDir
10959)
10960{
10961
10962 WLANTL_CbType* pTLCb = NULL;
10963 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10964 tUapsdInfo halUAPSDInfo;
10965 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10966
10967 /*------------------------------------------------------------------------
10968 Sanity check
10969 Extract TL control block
10970 ------------------------------------------------------------------------*/
10971 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10972 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010973 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070010974 {
10975 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10976 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010977 " TL: %p STA: %d AC: %d",
10978 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 return VOS_STATUS_E_FAULT;
10980 }
10981
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010982 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10983 {
10984 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10985 "WLAN TL:Client Memory was not allocated on %s", __func__));
10986 return VOS_STATUS_E_FAILURE;
10987 }
10988
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010990 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010991
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010992#ifdef FEATURE_WLAN_TDLS
10993 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
10994#endif
10995 {
10996 if( 0 == uServiceInt )
10997 {
10998 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053010999 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011000 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011001 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011002
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011003 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11004 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11005 "DI: %d",
11006 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11007 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011008
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011009 /*Save all info for HAL*/
11010 halUAPSDInfo.staidx = ucSTAId;
11011 halUAPSDInfo.ac = ucAC;
11012 halUAPSDInfo.up = ucUP;
11013 halUAPSDInfo.srvInterval = uServiceInt;
11014 halUAPSDInfo.susInterval = uSuspendInt;
11015 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11016
11017 /*Notify HAL*/
11018 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 return vosStatus;
11021
11022}/*WLANTL_EnableUAPSDForAC*/
11023
11024
11025/*==========================================================================
11026 FUNCTION WLANTL_DisableUAPSDForAC
11027
11028 DESCRIPTION
11029 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11030 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11031 trigger frame logic which later moved down to FW. Hence
11032 HDD -> TL -> WDA -> FW call flow.
11033
11034 DEPENDENCIES
11035 The TL must be initialized before this function can be called.
11036
11037 PARAMETERS
11038
11039 IN
11040 pvosGCtx: pointer to the global vos context; a handle to TL's
11041 control block can be extracted from its context
11042 ucSTAId: station Id
11043 ucAC: AC for which U-APSD is being enabled
11044
11045
11046 RETURN VALUE
11047 The result code associated with performing the operation
11048
11049 VOS_STATUS_SUCCESS: Everything is good :)
11050
11051 SIDE EFFECTS
11052
11053============================================================================*/
11054VOS_STATUS
11055WLANTL_DisableUAPSDForAC
11056(
11057 v_PVOID_t pvosGCtx,
11058 v_U8_t ucSTAId,
11059 WLANTL_ACEnumType ucAC
11060)
11061{
11062 WLANTL_CbType* pTLCb;
11063 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11064
11065 /*------------------------------------------------------------------------
11066 Sanity check
11067 Extract TL control block
11068 ------------------------------------------------------------------------*/
11069 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11070 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11071 || WLANTL_AC_INVALID(ucAC) )
11072 {
11073 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11074 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011075 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 return VOS_STATUS_E_FAULT;
11077 }
11078
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011079 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11080 {
11081 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11082 "WLAN TL:Client Memory was not allocated on %s", __func__));
11083 return VOS_STATUS_E_FAILURE;
11084 }
11085
Jeff Johnson295189b2012-06-20 16:38:30 -070011086 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011087 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011088
11089 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11090 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11091 ucSTAId, ucAC));
11092
11093 /*Notify HAL*/
11094 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11095
11096 return VOS_STATUS_SUCCESS;
11097}/* WLANTL_DisableUAPSDForAC */
11098
11099#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11100/*==========================================================================
11101 FUNCTION WLANTL_RegRSSIIndicationCB
11102
11103 DESCRIPTION Registration function to get notification if RSSI cross
11104 threshold.
11105 Client should register threshold, direction, and notification
11106 callback function pointer
11107
11108 DEPENDENCIES NONE
11109
11110 PARAMETERS in pAdapter - Global handle
11111 in rssiValue - RSSI threshold value
11112 in triggerEvent - Cross direction should be notified
11113 UP, DOWN, and CROSS
11114 in crossCBFunction - Notification CB Function
11115 in usrCtxt - user context
11116
11117 RETURN VALUE VOS_STATUS
11118
11119 SIDE EFFECTS NONE
11120
11121============================================================================*/
11122VOS_STATUS WLANTL_RegRSSIIndicationCB
11123(
11124 v_PVOID_t pAdapter,
11125 v_S7_t rssiValue,
11126 v_U8_t triggerEvent,
11127 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11128 VOS_MODULE_ID moduleID,
11129 v_PVOID_t usrCtxt
11130)
11131{
11132 VOS_STATUS status = VOS_STATUS_SUCCESS;
11133
11134 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11135 rssiValue,
11136 triggerEvent,
11137 crossCBFunction,
11138 moduleID,
11139 usrCtxt);
11140
11141 return status;
11142}
11143
11144/*==========================================================================
11145 FUNCTION WLANTL_DeregRSSIIndicationCB
11146
11147 DESCRIPTION Remove specific threshold from list
11148
11149 DEPENDENCIES NONE
11150
11151 PARAMETERS in pAdapter - Global handle
11152 in rssiValue - RSSI threshold value
11153 in triggerEvent - Cross direction should be notified
11154 UP, DOWN, and CROSS
11155
11156 RETURN VALUE VOS_STATUS
11157
11158 SIDE EFFECTS NONE
11159
11160============================================================================*/
11161VOS_STATUS WLANTL_DeregRSSIIndicationCB
11162(
11163 v_PVOID_t pAdapter,
11164 v_S7_t rssiValue,
11165 v_U8_t triggerEvent,
11166 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11167 VOS_MODULE_ID moduleID
11168)
11169{
11170 VOS_STATUS status = VOS_STATUS_SUCCESS;
11171
11172 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11173 rssiValue,
11174 triggerEvent,
11175 crossCBFunction,
11176 moduleID);
11177 return status;
11178}
11179
11180/*==========================================================================
11181 FUNCTION WLANTL_SetAlpha
11182
11183 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11184 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11185 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11186 (10 - ALPHA)% of newRSSI weight
11187 This portion is dynamically configurable.
11188 Default is ?
11189
11190 DEPENDENCIES NONE
11191
11192 PARAMETERS in pAdapter - Global handle
11193 in valueAlpah - ALPHA
11194
11195 RETURN VALUE VOS_STATUS
11196
11197 SIDE EFFECTS NONE
11198
11199============================================================================*/
11200VOS_STATUS WLANTL_SetAlpha
11201(
11202 v_PVOID_t pAdapter,
11203 v_U8_t valueAlpha
11204)
11205{
11206 VOS_STATUS status = VOS_STATUS_SUCCESS;
11207
11208 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11209 return status;
11210}
11211
11212/*==========================================================================
11213
11214 FUNCTION
11215
11216 DESCRIPTION
11217
11218 PARAMETERS
11219
11220 RETURN VALUE
11221
11222============================================================================*/
11223VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11224(
11225 v_PVOID_t pAdapter,
11226 tpSirRSSINotification pRSSINotification
11227)
11228{
11229 VOS_STATUS status = VOS_STATUS_SUCCESS;
11230
11231 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11232 return status;
11233}
11234
11235/*==========================================================================
11236 FUNCTION WLANTL_RegGetTrafficStatus
11237
11238 DESCRIPTION Registration function for traffic status monitoring
11239 During measure period count data frames.
11240 If frame count is larger then IDLE threshold set as traffic ON
11241 or OFF.
11242 And traffic status is changed send report to client with
11243 registered callback function
11244
11245 DEPENDENCIES NONE
11246
11247 PARAMETERS in pAdapter - Global handle
11248 in idleThreshold - Traffic on or off threshold
11249 in measurePeriod - Traffic state check period
11250 in trfficStatusCB - traffic status changed notification
11251 CB function
11252 in usrCtxt - user context
11253
11254 RETURN VALUE VOS_STATUS
11255
11256 SIDE EFFECTS NONE
11257
11258============================================================================*/
11259VOS_STATUS WLANTL_RegGetTrafficStatus
11260(
11261 v_PVOID_t pAdapter,
11262 v_U32_t idleThreshold,
11263 v_U32_t measurePeriod,
11264 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11265 v_PVOID_t usrCtxt
11266)
11267{
11268 VOS_STATUS status = VOS_STATUS_SUCCESS;
11269
11270 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11271 idleThreshold,
11272 measurePeriod,
11273 trfficStatusCB,
11274 usrCtxt);
11275 return status;
11276}
11277#endif
11278/*==========================================================================
11279 FUNCTION WLANTL_GetStatistics
11280
11281 DESCRIPTION Get traffic statistics for identified station
11282
11283 DEPENDENCIES NONE
11284
11285 PARAMETERS in pAdapter - Global handle
11286 in statType - specific statistics field to reset
11287 out statBuffer - traffic statistics buffer
11288
11289 RETURN VALUE VOS_STATUS
11290
11291 SIDE EFFECTS NONE
11292
11293============================================================================*/
11294VOS_STATUS WLANTL_GetStatistics
11295(
11296 v_PVOID_t pAdapter,
11297 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11298 v_U8_t STAid
11299)
11300{
11301 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011302 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 VOS_STATUS status = VOS_STATUS_SUCCESS;
11304 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11305
11306 /*------------------------------------------------------------------------
11307 Sanity check
11308 Extract TL control block
11309 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011310 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 {
11312 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11313 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11314 return VOS_STATUS_E_FAULT;
11315 }
11316
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011317 pClientSTA = pTLCb->atlSTAClients[STAid];
11318
11319 if ( NULL == pClientSTA )
11320 {
11321 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11322 "WLAN TL:Client Memory was not allocated on %s", __func__));
11323 return VOS_STATUS_E_FAILURE;
11324 }
11325
11326 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011327 {
11328 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11329 "WLAN TL: %d STA ID does not exist", STAid));
11330 return VOS_STATUS_E_INVAL;
11331 }
11332
11333 if(NULL == statBuffer)
11334 {
11335 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11336 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11337 return VOS_STATUS_E_INVAL;
11338 }
11339
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011340 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 memcpy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11342
11343 return status;
11344}
11345
11346/*==========================================================================
11347 FUNCTION WLANTL_ResetStatistics
11348
11349 DESCRIPTION Reset statistics structure for identified station ID
11350 Reset means set values as 0
11351
11352 DEPENDENCIES NONE
11353
11354 PARAMETERS in pAdapter - Global handle
11355 in statType - specific statistics field to reset
11356
11357 RETURN VALUE VOS_STATUS
11358
11359 SIDE EFFECTS NONE
11360
11361============================================================================*/
11362VOS_STATUS WLANTL_ResetStatistics
11363(
11364 v_PVOID_t pAdapter,
11365 v_U8_t STAid
11366)
11367{
11368 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011369 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011370 VOS_STATUS status = VOS_STATUS_SUCCESS;
11371 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11372
11373 /*------------------------------------------------------------------------
11374 Sanity check
11375 Extract TL control block
11376 ------------------------------------------------------------------------*/
11377 if (NULL == pTLCb)
11378 {
11379 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11380 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11381 return VOS_STATUS_E_FAULT;
11382 }
11383
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011384 pClientSTA = pTLCb->atlSTAClients[STAid];
11385
11386 if ( NULL == pClientSTA )
11387 {
11388 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11389 "WLAN TL:Client Memory was not allocated on %s", __func__));
11390 return VOS_STATUS_E_FAILURE;
11391 }
11392
11393 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 {
11395 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11396 "WLAN TL: %d STA ID does not exist", STAid));
11397 return VOS_STATUS_E_INVAL;
11398 }
11399
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011400 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11402
11403 return status;
11404}
11405
11406/*==========================================================================
11407 FUNCTION WLANTL_GetSpecStatistic
11408
11409 DESCRIPTION Get specific field within statistics structure for
11410 identified station ID
11411
11412 DEPENDENCIES NONE
11413
11414 PARAMETERS in pAdapter - Global handle
11415 in statType - specific statistics field to reset
11416 in STAid - Station ID
11417 out buffer - Statistic value
11418
11419 RETURN VALUE VOS_STATUS
11420
11421 SIDE EFFECTS NONE
11422
11423============================================================================*/
11424VOS_STATUS WLANTL_GetSpecStatistic
11425(
11426 v_PVOID_t pAdapter,
11427 WLANTL_TRANSFER_STATIC_TYPE statType,
11428 v_U32_t *buffer,
11429 v_U8_t STAid
11430)
11431{
11432 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011433 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 VOS_STATUS status = VOS_STATUS_SUCCESS;
11435 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11436
11437 /*------------------------------------------------------------------------
11438 Sanity check
11439 Extract TL control block
11440 ------------------------------------------------------------------------*/
11441 if (NULL == pTLCb)
11442 {
11443 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11444 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11445 return VOS_STATUS_E_FAULT;
11446 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011447 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011448
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011449 if ( NULL == pClientSTA )
11450 {
11451 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11452 "WLAN TL:Client Memory was not allocated on %s", __func__));
11453 return VOS_STATUS_E_FAILURE;
11454 }
11455
11456 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 {
11458 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11459 "WLAN TL: %d STA ID does not exist", STAid));
11460 return VOS_STATUS_E_INVAL;
11461 }
11462
11463 if(NULL == buffer)
11464 {
11465 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11466 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11467 return VOS_STATUS_E_INVAL;
11468 }
11469
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011470 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 switch(statType)
11472 {
11473 case WLANTL_STATIC_TX_UC_FCNT:
11474 *buffer = statistics->txUCFcnt;
11475 break;
11476
11477 case WLANTL_STATIC_TX_MC_FCNT:
11478 *buffer = statistics->txMCFcnt;
11479 break;
11480
11481 case WLANTL_STATIC_TX_BC_FCNT:
11482 *buffer = statistics->txBCFcnt;
11483 break;
11484
11485 case WLANTL_STATIC_TX_UC_BCNT:
11486 *buffer = statistics->txUCBcnt;
11487 break;
11488
11489 case WLANTL_STATIC_TX_MC_BCNT:
11490 *buffer = statistics->txMCBcnt;
11491 break;
11492
11493 case WLANTL_STATIC_TX_BC_BCNT:
11494 *buffer = statistics->txBCBcnt;
11495 break;
11496
11497 case WLANTL_STATIC_RX_UC_FCNT:
11498 *buffer = statistics->rxUCFcnt;
11499 break;
11500
11501 case WLANTL_STATIC_RX_MC_FCNT:
11502 *buffer = statistics->rxMCFcnt;
11503 break;
11504
11505 case WLANTL_STATIC_RX_BC_FCNT:
11506 *buffer = statistics->rxBCFcnt;
11507 break;
11508
11509 case WLANTL_STATIC_RX_UC_BCNT:
11510 *buffer = statistics->rxUCBcnt;
11511 break;
11512
11513 case WLANTL_STATIC_RX_MC_BCNT:
11514 *buffer = statistics->rxMCBcnt;
11515 break;
11516
11517 case WLANTL_STATIC_RX_BC_BCNT:
11518 *buffer = statistics->rxBCBcnt;
11519 break;
11520
11521 case WLANTL_STATIC_RX_BCNT:
11522 *buffer = statistics->rxBcnt;
11523 break;
11524
11525 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11526 *buffer = statistics->rxBcntCRCok;
11527 break;
11528
11529 case WLANTL_STATIC_RX_RATE:
11530 *buffer = statistics->rxRate;
11531 break;
11532
11533 default:
11534 *buffer = 0;
11535 status = VOS_STATUS_E_INVAL;
11536 break;
11537 }
11538
11539
11540 return status;
11541}
11542
11543/*==========================================================================
11544 FUNCTION WLANTL_ResetSpecStatistic
11545
11546 DESCRIPTION Reset specific field within statistics structure for
11547 identified station ID
11548 Reset means set as 0
11549
11550 DEPENDENCIES NONE
11551
11552 PARAMETERS in pAdapter - Global handle
11553 in statType - specific statistics field to reset
11554 in STAid - Station ID
11555
11556 RETURN VALUE VOS_STATUS
11557
11558 SIDE EFFECTS NONE
11559
11560============================================================================*/
11561VOS_STATUS WLANTL_ResetSpecStatistic
11562(
11563 v_PVOID_t pAdapter,
11564 WLANTL_TRANSFER_STATIC_TYPE statType,
11565 v_U8_t STAid
11566)
11567{
11568 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011569 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 VOS_STATUS status = VOS_STATUS_SUCCESS;
11571 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11572
11573 /*------------------------------------------------------------------------
11574 Sanity check
11575 Extract TL control block
11576 ------------------------------------------------------------------------*/
11577 if (NULL == pTLCb)
11578 {
11579 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11580 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11581 return VOS_STATUS_E_FAULT;
11582 }
11583
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011584 pClientSTA = pTLCb->atlSTAClients[STAid];
11585
11586 if ( NULL == pClientSTA )
11587 {
11588 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11589 "WLAN TL:Client Memory was not allocated on %s", __func__));
11590 return VOS_STATUS_E_FAILURE;
11591 }
11592
11593 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 {
11595 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11596 "WLAN TL: %d STA ID does not exist", STAid));
11597 return VOS_STATUS_E_INVAL;
11598 }
11599
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011600 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 switch(statType)
11602 {
11603 case WLANTL_STATIC_TX_UC_FCNT:
11604 statistics->txUCFcnt = 0;
11605 break;
11606
11607 case WLANTL_STATIC_TX_MC_FCNT:
11608 statistics->txMCFcnt = 0;
11609 break;
11610
11611 case WLANTL_STATIC_TX_BC_FCNT:
11612 statistics->txBCFcnt = 0;
11613 break;
11614
11615 case WLANTL_STATIC_TX_UC_BCNT:
11616 statistics->txUCBcnt = 0;
11617 break;
11618
11619 case WLANTL_STATIC_TX_MC_BCNT:
11620 statistics->txMCBcnt = 0;
11621 break;
11622
11623 case WLANTL_STATIC_TX_BC_BCNT:
11624 statistics->txBCBcnt = 0;
11625 break;
11626
11627 case WLANTL_STATIC_RX_UC_FCNT:
11628 statistics->rxUCFcnt = 0;
11629 break;
11630
11631 case WLANTL_STATIC_RX_MC_FCNT:
11632 statistics->rxMCFcnt = 0;
11633 break;
11634
11635 case WLANTL_STATIC_RX_BC_FCNT:
11636 statistics->rxBCFcnt = 0;
11637 break;
11638
11639 case WLANTL_STATIC_RX_UC_BCNT:
11640 statistics->rxUCBcnt = 0;
11641 break;
11642
11643 case WLANTL_STATIC_RX_MC_BCNT:
11644 statistics->rxMCBcnt = 0;
11645 break;
11646
11647 case WLANTL_STATIC_RX_BC_BCNT:
11648 statistics->rxBCBcnt = 0;
11649 break;
11650
11651 case WLANTL_STATIC_RX_BCNT:
11652 statistics->rxBcnt = 0;
11653 break;
11654
11655 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11656 statistics->rxBcntCRCok = 0;
11657 break;
11658
11659 case WLANTL_STATIC_RX_RATE:
11660 statistics->rxRate = 0;
11661 break;
11662
11663 default:
11664 status = VOS_STATUS_E_INVAL;
11665 break;
11666 }
11667
11668 return status;
11669}
11670
11671
11672/*==========================================================================
11673
11674 FUNCTION
11675
11676 DESCRIPTION Read RSSI value out of a RX BD
11677
11678 PARAMETERS: Caller must validate all parameters
11679
11680 RETURN VALUE
11681
11682============================================================================*/
11683VOS_STATUS WLANTL_ReadRSSI
11684(
11685 v_PVOID_t pAdapter,
11686 v_PVOID_t pBDHeader,
11687 v_U8_t STAid
11688)
11689{
11690 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11691 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
11692
11693
11694 if(NULL == tlCtxt)
11695 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011696 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 return VOS_STATUS_E_INVAL;
11698 }
11699
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011700 if ( NULL == tlCtxt->atlSTAClients[STAid] )
11701 {
11702 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11703 "WLAN TL:Client Memory was not allocated on %s", __func__));
11704 return VOS_STATUS_E_FAILURE;
11705 }
11706
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
11708 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
11709 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
11710
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011711 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070011712
11713 return VOS_STATUS_SUCCESS;
11714}
11715
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011716/*==========================================================================
11717
11718 FUNCTION
11719
11720 DESCRIPTION Read SNR value out of a RX BD
11721
11722 PARAMETERS: Caller must validate all parameters
11723
11724 RETURN VALUE
11725
11726============================================================================*/
11727VOS_STATUS WLANTL_ReadSNR
11728(
11729 v_PVOID_t pAdapter,
11730 v_PVOID_t pBDHeader,
11731 v_U8_t STAid
11732)
11733{
11734 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11735 v_S7_t currentSNR;
11736
11737
11738 if (NULL == tlCtxt)
11739 {
11740 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11741 "%s Invalid TL handle", __func__));
11742 return VOS_STATUS_E_INVAL;
11743 }
11744
11745 if (NULL == tlCtxt->atlSTAClients[STAid])
11746 {
11747 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11748 "WLAN TL:Client Memory was not allocated on %s", __func__));
11749 return VOS_STATUS_E_FAILURE;
11750 }
11751
11752 currentSNR = WLANTL_GETSNR(pBDHeader);
11753
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053011754 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
11755 * Get the correct SNR value
11756 */
11757 currentSNR = currentSNR >> 1;
11758
11759 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
11760 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
11761 WLANTL_MAX_HW_SNR);
11762
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011763 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11764 "%s: snrsum: %d snridx: %d prevsnravg: %d",
11765 __func__,
11766 tlCtxt->atlSTAClients[STAid]->snrSum,
11767 tlCtxt->atlSTAClients[STAid]->snrIdx,
11768 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
11769
11770 /* The SNR returned for all purposes is the average SNR over
11771 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
11772 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
11773 * store the average of the samples in prevSnrAvg
11774 * and start a new averaging window. The prevSnrAvg is used when
11775 * enough data samples are not available when applications
11776 * actually query for SNR.
11777 *
11778 * SEE: WLANTL_GetSnr()
11779 */
11780 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
11781 {
11782 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
11783 tlCtxt->atlSTAClients[STAid]->snrSum /
11784 tlCtxt->atlSTAClients[STAid]->snrIdx;
11785 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
11786 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
11787 }
11788 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
11789 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
11790
11791 return VOS_STATUS_SUCCESS;
11792}
Jeff Johnson295189b2012-06-20 16:38:30 -070011793
11794/*
11795 DESCRIPTION
11796 TL returns the weight currently maintained in TL.
11797 IN
11798 pvosGCtx: pointer to the global vos context; a handle to TL's
11799 or SME's control block can be extracted from its context
11800
11801 OUT
11802 pACWeights: Caller allocated memory for filling in weights
11803
11804 RETURN VALUE VOS_STATUS
11805*/
11806VOS_STATUS
11807WLANTL_GetACWeights
11808(
11809 v_PVOID_t pvosGCtx,
11810 v_U8_t* pACWeights
11811)
11812{
11813 WLANTL_CbType* pTLCb = NULL;
11814 v_U8_t ucIndex;
11815 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11816
11817 /*------------------------------------------------------------------------
11818 Sanity check
11819 ------------------------------------------------------------------------*/
11820 if ( NULL == pACWeights )
11821 {
11822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11823 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11824 return VOS_STATUS_E_INVAL;
11825 }
11826
11827 /*------------------------------------------------------------------------
11828 Extract TL control block and check existance
11829 ------------------------------------------------------------------------*/
11830 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11831 if ( NULL == pTLCb )
11832 {
11833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11834 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11835 return VOS_STATUS_E_FAULT;
11836 }
11837 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11838 {
11839 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
11840 }
11841
11842 return VOS_STATUS_SUCCESS;
11843}
11844
11845
11846
11847/*
11848 DESCRIPTION
11849 Change the weight currently maintained by TL.
11850 IN
11851 pvosGCtx: pointer to the global vos context; a handle to TL's
11852 or SME's control block can be extracted from its context
11853 pACWeights: Caller allocated memory contain the weights to use
11854
11855
11856 RETURN VALUE VOS_STATUS
11857*/
11858VOS_STATUS
11859WLANTL_SetACWeights
11860(
11861 v_PVOID_t pvosGCtx,
11862 v_U8_t* pACWeights
11863)
11864{
11865 WLANTL_CbType* pTLCb = NULL;
11866 v_U8_t ucIndex;
11867 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11868
11869 /*------------------------------------------------------------------------
11870 Sanity check
11871 ------------------------------------------------------------------------*/
11872 if ( NULL == pACWeights )
11873 {
11874 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11875 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11876 return VOS_STATUS_E_INVAL;
11877 }
11878
11879 /*------------------------------------------------------------------------
11880 Extract TL control block and check existance
11881 ------------------------------------------------------------------------*/
11882 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11883 if ( NULL == pTLCb )
11884 {
11885 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11886 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11887 return VOS_STATUS_E_FAULT;
11888 }
11889 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11890 {
11891 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
11892 }
11893
11894 return VOS_STATUS_SUCCESS;
11895}
11896
11897
11898/*==========================================================================
11899
11900 FUNCTION
11901
11902 DESCRIPTION
11903
11904 PARAMETERS
11905
11906 RETURN VALUE
11907
11908============================================================================*/
11909void WLANTL_PowerStateChangedCB
11910(
11911 v_PVOID_t pAdapter,
11912 tPmcState newState
11913)
11914{
11915 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11916
11917 if (NULL == tlCtxt)
11918 {
11919 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011920 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 return;
11922 }
11923
11924 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
11925 switch(newState)
11926 {
11927 case FULL_POWER:
11928 tlCtxt->isBMPS = VOS_FALSE;
11929 break;
11930
11931 case BMPS:
11932#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11933 WLANTL_SetFWRSSIThresholds(pAdapter);
11934#endif
11935
11936 tlCtxt->isBMPS = VOS_TRUE;
11937 break;
11938
11939 case IMPS:
11940 case LOW_POWER:
11941 case REQUEST_BMPS:
11942 case REQUEST_FULL_POWER:
11943 case REQUEST_IMPS:
11944 case STOPPED:
11945 case REQUEST_START_UAPSD:
11946 case REQUEST_STOP_UAPSD:
11947 case UAPSD:
11948 case REQUEST_STANDBY:
11949 case STANDBY:
11950 case REQUEST_ENTER_WOWL:
11951 case REQUEST_EXIT_WOWL:
11952 case WOWL:
11953 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
11954 break;
11955
11956 default:
11957 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
11958 break;
11959 }
11960
11961 return;
11962}
11963/*==========================================================================
11964 FUNCTION WLANTL_GetEtherType
11965
11966 DESCRIPTION Extract Ether type information from the BD
11967
11968 DEPENDENCIES NONE
11969
11970 PARAMETERS in aucBDHeader - BD header
11971 in vosDataBuff - data buffer
11972 in ucMPDUHLen - MPDU header length
11973 out pUsEtherType - pointer to Ethertype
11974
11975 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
11976 VOS_STATUS_FAILURE : if the EtherType extraction failed and
11977 the packet was dropped
11978
11979 SIDE EFFECTS NONE
11980
11981============================================================================*/
11982static VOS_STATUS WLANTL_GetEtherType
11983(
11984 v_U8_t * aucBDHeader,
11985 vos_pkt_t * vosDataBuff,
11986 v_U8_t ucMPDUHLen,
11987 v_U16_t * pUsEtherType
11988)
11989{
11990 v_U8_t ucOffset;
11991 v_U16_t usEtherType = *pUsEtherType;
11992 v_SIZE_t usLLCSize = sizeof(usEtherType);
11993 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11994
11995 /*------------------------------------------------------------------------
11996 Check if LLC is present - if not, TL is unable to determine type
11997 ------------------------------------------------------------------------*/
11998 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
11999 {
12000 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12001 }
12002 else
12003 {
12004 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12005 }
12006
12007 /*------------------------------------------------------------------------
12008 Extract LLC type
12009 ------------------------------------------------------------------------*/
12010 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12011 (v_PVOID_t)&usEtherType, &usLLCSize);
12012
12013 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12014 ( sizeof(usEtherType) != usLLCSize ))
12015
12016 {
12017 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12018 "WLAN TL:Error extracting Ether type from data packet"));
12019 /* Drop packet */
12020 vos_pkt_return_packet(vosDataBuff);
12021 vosStatus = VOS_STATUS_E_FAILURE;
12022 }
12023 else
12024 {
12025 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12026 "WLAN TL:Ether type retrieved before endianess conv: %d",
12027 usEtherType));
12028
12029 usEtherType = vos_be16_to_cpu(usEtherType);
12030 *pUsEtherType = usEtherType;
12031
12032 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12033 "WLAN TL:Ether type retrieved: %d", usEtherType));
12034 }
12035
12036 return vosStatus;
12037}
12038
Jeff Johnson295189b2012-06-20 16:38:30 -070012039/*==========================================================================
12040 FUNCTION WLANTL_GetSoftAPStatistics
12041
12042 DESCRIPTION Collect the cumulative statistics for all Softap stations
12043
12044 DEPENDENCIES NONE
12045
12046 PARAMETERS in pvosGCtx - Pointer to the global vos context
12047 bReset - If set TL statistics will be cleared after reading
12048 out statsSum - pointer to collected statistics
12049
12050 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12051
12052 SIDE EFFECTS NONE
12053
12054============================================================================*/
12055VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12056{
12057 v_U8_t i = 0;
12058 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12059 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12060 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12061 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12062 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12063
12064
12065 if ( NULL == pTLCb )
12066 {
12067 return VOS_STATUS_E_FAULT;
12068 }
12069
12070 // Sum up all the statistics for stations of Soft AP from TL
12071 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12072 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012073 if ( NULL == pTLCb->atlSTAClients[i])
12074 {
12075 continue;
12076 }
12077 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 {
12079 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12080
12081 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12082 return VOS_STATUS_E_FAULT;
12083
12084 // Add to the counters
12085 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12086 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12087 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12088 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12089 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12090 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12091 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12092 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12093 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12094 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12095 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12096 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12097
12098 if (bReset)
12099 {
12100 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12101 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12102 return VOS_STATUS_E_FAULT;
12103 }
12104 }
12105 }
12106
12107 return vosStatus;
12108}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012109#ifdef FEATURE_WLAN_TDLS_INTERNAL
12110/*==========================================================================
12111 FUNCTION WLANTL_GetEtherType_2
12112
12113 DESCRIPTION Extract Ether type information from the BD
12114
12115 DEPENDENCIES NONE
12116
12117 PARAMETERS in aucBDHeader - BD header
12118 in vosDataBuff - data buffer
12119 in ucMPDUHLen - MPDU header length
12120 out pUsEtherType - pointer to Ethertype
12121
12122 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12123 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12124 the packet was dropped
12125
12126 SIDE EFFECTS NONE
12127
12128============================================================================*/
12129static VOS_STATUS WLANTL_GetEtherType_2
12130(
12131 v_U8_t * aucBDHeader,
12132 vos_pkt_t * vosDataBuff,
12133 v_U8_t ucMPDUHLen,
12134 v_U16_t * pUsEtherType
12135)
12136{
12137 v_U8_t ucOffset;
12138 v_U16_t usEtherType = *pUsEtherType;
12139 v_SIZE_t usLLCSize = sizeof(usEtherType);
12140 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12141 //v_U8_t ucLLCHeader;
12142 v_U8_t ucMPDUHOffset ;
12143 /*------------------------------------------------------------------------
12144 Check if LLC is present - if not, TL is unable to determine type
12145 ------------------------------------------------------------------------*/
12146 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12147 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12148 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12149
12150 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12151 {
12152 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12153 }
12154 else
12155 {
12156 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12157 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12158 }
12159
12160 /*------------------------------------------------------------------------
12161 Extract LLC type
12162 ------------------------------------------------------------------------*/
12163 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12164 (v_PVOID_t)&usEtherType, &usLLCSize);
12165
12166 /* TODO: Do it in better way */
12167 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12168 {
12169 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12170 ("TDLS frame llc %x \n"), vos_be16_to_cpu(usEtherType)) ;
12171 }
12172
12173 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12174 "WLAN TL:Ether type retrieved before endianess conv: %d",
12175 usEtherType);
12176
12177 usEtherType = vos_be16_to_cpu(usEtherType);
12178 *pUsEtherType = usEtherType;
12179
12180 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12181 "WLAN TL:Ether type retrieved: %d", usEtherType);
12182
12183 return vosStatus;
12184}
12185#endif /* FEATURE_WLAN_TDLS */
12186
Jeff Johnson295189b2012-06-20 16:38:30 -070012187/*===============================================================================
12188 FUNCTION WLANTL_IsReplayPacket
12189
12190 DESCRIPTION This function does replay check for valid stations
12191
12192 DEPENDENCIES Validity of replay check must be done before the function
12193 is called
12194
12195 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12196 previousReplayCounter previous replay counter taken from TL CB
12197
12198 RETRUN VOS_TRUE packet is a replay packet
12199 VOS_FALSE packet is not a replay packet
12200
12201 SIDE EFFECTS none
12202 ===============================================================================*/
12203v_BOOL_t
12204WLANTL_IsReplayPacket
12205(
12206 v_U64_t ullcurrentReplayCounter,
12207 v_U64_t ullpreviousReplayCounter
12208)
12209{
12210 /* Do the replay check by comparing previous received replay counter with
12211 current received replay counter*/
12212 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12213 {
12214 /* Valid packet not replay */
12215 return VOS_FALSE;
12216 }
12217 else
12218 {
12219
12220 /* Current packet number is less than or equal to previuos received
12221 packet no, this means current packet is replay packet */
12222 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12223 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12224
12225 return VOS_TRUE;
12226 }
12227}
12228
12229#if 0
12230/*===============================================================================
12231 FUNCTION WLANTL_GetReplayCounterFromRxBD
12232
12233 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12234
12235 DEPENDENCIES Validity of replay check must be done before the function
12236 is called
12237
12238 PARAMETERS pucRxHeader pointer to RX BD header
12239
12240 RETRUN v_U64_t Packet number extarcted from RX BD
12241
12242 SIDE EFFECTS none
12243 ===============================================================================*/
12244v_U64_t
12245WLANTL_GetReplayCounterFromRxBD
12246(
12247 v_U8_t *pucRxBDHeader
12248)
12249{
12250/* 48-bit replay counter is created as follows
12251 from RX BD 6 byte PMI command:
12252 Addr : AES/TKIP
12253 0x38 : pn3/tsc3
12254 0x39 : pn2/tsc2
12255 0x3a : pn1/tsc1
12256 0x3b : pn0/tsc0
12257
12258 0x3c : pn5/tsc5
12259 0x3d : pn4/tsc4 */
12260
12261#ifdef ANI_BIG_BYTE_ENDIAN
12262 v_U64_t ullcurrentReplayCounter = 0;
12263 /* Getting 48-bit replay counter from the RX BD */
12264 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12265 ullcurrentReplayCounter <<= 16;
12266 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12267 return ullcurrentReplayCounter;
12268#else
12269 v_U64_t ullcurrentReplayCounter = 0;
12270 /* Getting 48-bit replay counter from the RX BD */
12271 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12272 ullcurrentReplayCounter <<= 32;
12273 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12274 return ullcurrentReplayCounter;
12275#endif
12276}
12277#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012278
12279/*===============================================================================
12280 FUNCTION WLANTL_PostResNeeded
12281
12282 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12283
12284 DEPENDENCIES None
12285
12286 PARAMETERS pvosGCtx
12287
12288 RETURN None
12289
12290 SIDE EFFECTS none
12291 ===============================================================================*/
12292
12293void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12294{
12295 vos_msg_t vosMsg;
12296
12297 vosMsg.reserved = 0;
12298 vosMsg.bodyptr = NULL;
12299 vosMsg.type = WLANTL_TX_RES_NEEDED;
12300 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12301 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12302 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12303 {
12304 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012305 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 }
12307}
12308
12309/*===============================================================================
12310 FUNCTION WLANTL_UpdateRssiBmps
12311
12312 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12313
12314 DEPENDENCIES None
12315
12316 PARAMETERS
12317
12318 pvosGCtx VOS context VOS Global context
12319 staId Station ID Station ID
12320 rssi RSSI (BMPS mode) RSSI in BMPS mode
12321
12322 RETURN None
12323
12324 SIDE EFFECTS none
12325 ===============================================================================*/
12326
12327void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12328{
12329 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12330
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012331 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012333 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 }
12335}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012336
12337/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012338 FUNCTION WLANTL_UpdateSnrBmps
12339
12340 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
12341
12342 DEPENDENCIES None
12343
12344 PARAMETERS
12345
12346 pvosGCtx VOS context VOS Global context
12347 staId Station ID Station ID
12348 snr SNR (BMPS mode) SNR in BMPS mode
12349
12350 RETURN None
12351
12352 SIDE EFFECTS none
12353 ===============================================================================*/
12354
12355void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
12356{
12357 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12358
12359 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12360 {
12361 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
12362 }
12363}
12364
12365/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012366 FUNCTION WLANTL_UpdateLinkCapacity
12367
12368 DESCRIPTION This function updates the STA's Link Capacity in TL
12369
12370 DEPENDENCIES None
12371
12372 PARAMETERS
12373
12374 pvosGCtx VOS context VOS Global context
12375 staId Station ID Station ID
12376 linkCapacity linkCapacity Link Capacity
12377
12378 RETURN None
12379
12380 SIDE EFFECTS none
12381 ===============================================================================*/
12382
12383void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12384{
12385 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12386
12387 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12388 {
12389 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12390 }
12391}
12392
12393
12394/*===========================================================================
12395
12396 FUNCTION WLANTL_GetSTALinkCapacity
12397
12398 DESCRIPTION
12399
12400 Returns Link Capacity of a particular STA.
12401
12402 DEPENDENCIES
12403
12404 A station must have been registered before its state can be retrieved.
12405
12406
12407 PARAMETERS
12408
12409 IN
12410 pvosGCtx: pointer to the global vos context; a handle to TL's
12411 control block can be extracted from its context
12412 ucSTAId: identifier of the station
12413
12414 OUT
12415 plinkCapacity: the current link capacity the connection to
12416 the given station
12417
12418
12419 RETURN VALUE
12420
12421 The result code associated with performing the operation
12422
12423 VOS_STATUS_E_INVAL: Input parameters are invalid
12424 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12425 TL cb is NULL ; access would cause a page fault
12426 VOS_STATUS_E_EXISTS: Station was not registered
12427 VOS_STATUS_SUCCESS: Everything is good :)
12428
12429 SIDE EFFECTS
12430
12431============================================================================*/
12432VOS_STATUS
12433WLANTL_GetSTALinkCapacity
12434(
12435 v_PVOID_t pvosGCtx,
12436 v_U8_t ucSTAId,
12437 v_U32_t *plinkCapacity
12438)
12439{
12440 WLANTL_CbType* pTLCb = NULL;
12441 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12442
12443 /*------------------------------------------------------------------------
12444 Sanity check
12445 ------------------------------------------------------------------------*/
12446 if ( NULL == plinkCapacity )
12447 {
12448 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12449 FL("WLAN TL:Invalid parameter")));
12450 return VOS_STATUS_E_INVAL;
12451 }
12452
12453 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12454 {
12455 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12456 FL("WLAN TL:Invalid station id")));
12457 return VOS_STATUS_E_FAULT;
12458 }
12459
12460 /*------------------------------------------------------------------------
12461 Extract TL control block and check existance
12462 ------------------------------------------------------------------------*/
12463 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12464 if ( NULL == pTLCb )
12465 {
12466 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12467 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12468 return VOS_STATUS_E_FAULT;
12469 }
12470
12471 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12472 {
12473 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12474 FL("WLAN TL:Client Memory was not allocated")));
12475 return VOS_STATUS_E_FAILURE;
12476 }
12477
12478 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12479 {
12480 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12481 FL("WLAN TL:Station was not previously registered")));
12482 return VOS_STATUS_E_EXISTS;
12483 }
12484
12485 /*------------------------------------------------------------------------
12486 Get STA state
12487 ------------------------------------------------------------------------*/
12488 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12489
12490 return VOS_STATUS_SUCCESS;
12491}/* WLANTL_GetSTALinkCapacity */