blob: 50eb1b85f8ff223a83907b89cda2dc8ae85fa535 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/*===========================================================================
7
8
9 W L A N _ Q C T _ T L . C
10
11 OVERVIEW:
12
13 This software unit holds the implementation of the WLAN Transport Layer.
14
15 The functions externalized by this module are to be called ONLY by other
16 WLAN modules that properly register with the Transport Layer initially.
17
18 DEPENDENCIES:
19
20 Are listed for each API below.
21
22
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 Copyright (c) 2008 QUALCOMM Incorporated.
24 All Rights Reserved.
25 Qualcomm Confidential and Proprietary
Jeff Johnson295189b2012-06-20 16:38:30 -070026===========================================================================*/
27
28/*===========================================================================
29
30 EDIT HISTORY FOR FILE
31
32
33 This section contains comments describing changes made to the module.
34 Notice that changes are listed in reverse chronological order.
35
36
37 $Header$$DateTime$$Author$
38
39
40 when who what, where, why
41---------- --- --------------------------------------------------------
422010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
43 WAI frame sent out during rekeying had the protected bit
44 set to 1.
452010-05-06 rnair Changed name of variable from usLlcType to usEtherType
46 Changed function name from GetLLCType to GetEtherType
47 Fixed 802.3 to 802.11 frame translation issue where two
48 bytes of the LLC header was getting overwritten in the
49 non-Qos path
502010-05-06 rnair RxAuth path fix for modifying the header before ether
51 type is retreived (Detected while testing rekeying
52 in WAPI Volans)
532010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
542010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
55 does frame translation.
562010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
57 being set in the TL control block in the RegisterSTA func.
582010-01-08 lti Added TL Data Caching
592009-11-04 rnair WAPI: Moving common functionality to a seperate function
60 called WLANTL_GetLLCType
612009-10-15 rnair WAPI: Featurizing WAPI code
622009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
632009-10-06 rnair Adding support for WAPI
642009-09-22 lti Add deregistration API for management client
652009-07-16 rnair Temporary fix to let TL fetch packets when multiple
66 peers exist in an IBSS
672009-06-10 lti Fix for checking TID value of meta info on TX - prevent
68 memory overwrite
69 Fix for properly checking the sta id for resuming trigger
70 frame generation
712009-05-14 lti Fix for sending out trigger frames
722009-05-15 lti Addr3 filtering
732009-04-13 lti Assert if packet larger then allowed
74 Drop packet that fails flatten
752009-04-02 lti Performance fixes for TL
762009-02-19 lti Added fix for LLC management on Rx Connect
772009-01-16 lti Replaced peek data with extract data for non BD opertions
78 Extracted frame control in Tl and pass to HAL for frame
79 type evaluation
802009-02-02 sch Add handoff support
812008-12-09 lti Fixes for AMSS compilation
82 Removed assert on receive when there is no station
832008-12-02 lti Fix fo trigger frame generation
842008-10-31 lti Fix fo TL tx suspend
852008-10-01 lti Merged in fixes from reordering
86 Disabled part of UAPSD functionality in TL
87 (will be re-enabled once UAPSD is tested)
88 Fix for UAPSD multiple enable
892008-08-10 lti Fixes following UAPSD testing
90 Fixed infinite loop on mask computation when STA no reg
912008-08-06 lti Fixes after QOS unit testing
922008-08-06 lti Added QOS support
932008-07-23 lti Fix for vos packet draining
942008-07-17 lti Fix for data type value
95 Added frame translation code in TL
96 Avoid returning failure to PE in case previous frame is
97 still pending; fail previous and cache new one for tx
98 Get frames returning boolean true if more frames are pending
992008-07-03 lti Fixes following pre-integration testing
1002008-06-26 lti Fixes following unit testing
101 Added alloc and free for TL context
102 Using atomic set u8 instead of u32
1032008-05-16 lti Created module
104
105===========================================================================*/
106
107/*----------------------------------------------------------------------------
108 * Include Files
109 * -------------------------------------------------------------------------*/
110#include "wlan_qct_tl.h"
111#include "wlan_qct_wda.h"
112#include "wlan_qct_tli.h"
113#include "wlan_qct_tli_ba.h"
114#include "wlan_qct_tl_hosupport.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700115#include "tlDebug.h"
116#ifdef FEATURE_WLAN_WAPI
117/*Included to access WDI_RxBdType */
118#include "wlan_qct_wdi_bd.h"
119#endif
120/*Enables debugging behavior in TL*/
121#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700122/*Enables debugging FC control frame in TL*/
123//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700124//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700125//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700126#ifdef TL_DEBUG_FC
127#include <wlan_qct_pal_status.h>
128#include <wlan_qct_pal_device.h> // wpalReadRegister
129#endif
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/*----------------------------------------------------------------------------
132 * Preprocessor Definitions and Constants
133 * -------------------------------------------------------------------------*/
134/*LLC header value*/
135static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
136
137#ifdef FEATURE_WLAN_CCX
138/*Aironet SNAP header value*/
139static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
140#endif //FEATURE_WLAN_CCX
141
142/*BT-AMP packet LLC OUI value*/
143const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
144
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530145#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700146
147#ifdef VOLANS_PERF
148#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
149#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
150
151/* TL BD/PDU threshold to enable interrupt */
152int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
153int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
154#endif /* VOLANS_PERF */
155
156/*-----------------------------------*
157 | Type(2b) | Sub-type(4b) |
158 *-----------------------------------*/
159#define WLANTL_IS_DATA_FRAME(_type_sub) \
160 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
161
162#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
163 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
164 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
165
166#define WLANTL_IS_MGMT_FRAME(_type_sub) \
167 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
168
169#define WLANTL_IS_CTRL_FRAME(_type_sub) \
170 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
171
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800172#ifdef FEATURE_WLAN_TDLS
173#define WLANTL_IS_TDLS_FRAME(_eth_type) \
174 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
175#endif
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800178#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700179
180#define WLANTL_MASK_AC 0x03
181
Jeff Johnson295189b2012-06-20 16:38:30 -0700182//some flow_control define
183//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
184#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
185
186//Get enough sample to do the LWM related calculation
187#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
188
189//Maximal on-fly packet per station in LWM mode
190#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
191
192#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800193#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700194
195/* UINT32 type endian swap */
196#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
197 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
198
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530199/* Maximum value of SNR that can be calculated by the HW */
200#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
Jeff Johnson295189b2012-06-20 16:38:30 -0700202/*----------------------------------------------------------------------------
203 * Type Declarations
204 * -------------------------------------------------------------------------*/
205#define TL_LITTLE_BIT_ENDIAN
206
207typedef struct
208{
209
210#ifndef TL_LITTLE_BIT_ENDIAN
211
212 v_U8_t subType :4;
213 v_U8_t type :2;
214 v_U8_t protVer :2;
215
216 v_U8_t order :1;
217 v_U8_t wep :1;
218 v_U8_t moreData :1;
219 v_U8_t powerMgmt :1;
220 v_U8_t retry :1;
221 v_U8_t moreFrag :1;
222 v_U8_t fromDS :1;
223 v_U8_t toDS :1;
224
225#else
226
227 v_U8_t protVer :2;
228 v_U8_t type :2;
229 v_U8_t subType :4;
230
231 v_U8_t toDS :1;
232 v_U8_t fromDS :1;
233 v_U8_t moreFrag :1;
234 v_U8_t retry :1;
235 v_U8_t powerMgmt :1;
236 v_U8_t moreData :1;
237 v_U8_t wep :1;
238 v_U8_t order :1;
239
240#endif
241
242} WLANTL_MACFCType;
243
244/* 802.11 header */
245typedef struct
246{
247 /* Frame control field */
248 WLANTL_MACFCType wFrmCtrl;
249
250 /* Duration ID */
251 v_U16_t usDurationId;
252
253 /* Address 1 field */
254 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
255
256 /* Address 2 field */
257 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
258
259 /* Address 3 field */
260 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
261
262 /* Sequence control field */
263 v_U16_t usSeqCtrl;
264
265 // Find the size of the mandatory header size.
266#define WLAN80211_MANDATORY_HEADER_SIZE \
267 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
268 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
269 sizeof(v_U16_t))
270
271 /* Optional A4 address */
272 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
273
274 /* Optional QOS control field */
275 v_U16_t usQosCtrl;
276}WLANTL_80211HeaderType;
277
278/* 802.3 header */
279typedef struct
280{
281 /* Destination address field */
282 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
283
284 /* Source address field */
285 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
286
287 /* Length field */
288 v_U16_t usLenType;
289}WLANTL_8023HeaderType;
290
291/*----------------------------------------------------------------------------
292 * Global Data Definitions
293 * -------------------------------------------------------------------------*/
294#define WLAN_TL_INVALID_U_SIG 255
295#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530296#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
297
Jeff Johnson295189b2012-06-20 16:38:30 -0700298#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
299 do\
300 {\
301 _ucACMask = 0; \
302 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
303 { \
304 if ( 0 != (_pSTA)->aucACMask[i] ) \
305 { \
306 _ucACMask |= ( 1 << i ); \
307 } \
308 } \
309 } while (0);
310
311/*----------------------------------------------------------------------------
312 * Static Variable Definitions
313 * -------------------------------------------------------------------------*/
314
315/*----------------------------------------------------------------------------
316 * Static Function Declarations and Definitions
317 * -------------------------------------------------------------------------*/
318
319static VOS_STATUS
320WLANTL_GetEtherType
321(
322 v_U8_t * aucBDHeader,
323 vos_pkt_t * vosDataBuff,
324 v_U8_t ucMPDUHLen,
325 v_U16_t * usEtherType
326);
327
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800328#ifdef FEATURE_WLAN_TDLS_INTERNAL
329/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
330But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
331wherease TDLS expect vosDataBuff->offset should still points to RxBd.
332So far, data frmae stripped RxBD and passed to data frame handler.
333(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
334handler, where RX BD should be preserved)
335To avoid breaking existing functionality, for now, I temporarily rename to
336WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
337*/
338static VOS_STATUS
339WLANTL_GetEtherType_2
340(
341 v_U8_t * aucBDHeader,
342 vos_pkt_t * vosDataBuff,
343 v_U8_t ucMPDUHLen,
344 v_U16_t * usEtherType
345);
346#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700347#ifdef FEATURE_WLAN_WAPI
348/*---------------------------------------------------------------------------
349 * Adding a global variable to be used when doing frame translation in TxAuth
350 * state so as to not set the protected bit to 1 in the case of WAI frames
351 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700352v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700353#endif
354
355/*----------------------------------------------------------------------------
356 * Externalized Function Definitions
357* -------------------------------------------------------------------------*/
358
359/*----------------------------------------------------------------------------
360 * Function Declarations and Documentation
361 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530362/*==========================================================================
363
364 FUNCTION WLANTL_FreeClientMemory
365
366 DESCRIPTION
367 It frees up the memory allocated to all the STA clients in TLCB block
368 Can be called inside Close, Stop or when some FAULT occurs
369
370 DEPENDENCIES
371
372 PARAMETERS
373
374 IN
375 pClientSTA: Pointer to the global client pointer array
376
377 RETURN VALUE
378
379 SIDE EFFECTS
380
381============================================================================*/
382void WLANTL_FreeClientMemory
383(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
384{
385 v_U32_t i = 0;
386 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
387 {
388 if( NULL != pClientSTA[i] )
389 {
390 vos_mem_free(pClientSTA[i]);
391 }
392 pClientSTA[i] = NULL;
393 }
394 return;
395}
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
397/*==========================================================================
398
399 FUNCTION WLANTL_Open
400
401 DESCRIPTION
402 Called by HDD at driver initialization. TL will initialize all its
403 internal resources and will wait for the call to start to register
404 with the other modules.
405
406 DEPENDENCIES
407
408 PARAMETERS
409
410 IN
411 pvosGCtx: pointer to the global vos context; a handle to TL's
412 control block can be extracted from its context
413 pTLConfig: TL Configuration
414
415 RETURN VALUE
416 The result code associated with performing the operation
417
418 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
419 fault
420 VOS_STATUS_SUCCESS: Everything is good :)
421
422 SIDE EFFECTS
423
424============================================================================*/
425VOS_STATUS
426WLANTL_Open
427(
428 v_PVOID_t pvosGCtx,
429 WLANTL_ConfigInfoType* pTLConfig
430)
431{
432 WLANTL_CbType* pTLCb = NULL;
433 v_U8_t ucIndex;
434 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530435 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700436#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
437 VOS_STATUS status = VOS_STATUS_SUCCESS;
438#endif
439 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
440
441 /*------------------------------------------------------------------------
442 Sanity check
443 Extract TL control block
444 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530445 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
447 (void*)&pTLCb, sizeof(WLANTL_CbType));
448
449 pTLCb = VOS_GET_TL_CB(pvosGCtx);
450 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
451 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700452 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530453 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 return VOS_STATUS_E_FAULT;
455 }
456
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700457 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
458 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
461 if ( NULL == smeContext )
462 {
463 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700464 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 return VOS_STATUS_E_FAULT;
466 }
467
468 /* Zero out the memory so we are OK, when CleanCB is called.*/
469 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
470
471 /*------------------------------------------------------------------------
472 Clean up TL control block, initialize all values
473 ------------------------------------------------------------------------*/
474 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
475 "WLAN TL:WLANTL_Open"));
476
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530477 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530479 if ( i < WLAN_NON32_STA_COUNT )
480 {
481 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
482 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
483 if ( NULL == pTLCb->atlSTAClients[i] )
484 {
485 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
486 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
487 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
488 return VOS_STATUS_E_FAULT;
489 }
490 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
491 }
492 else
493 {
494 pTLCb->atlSTAClients[i] = NULL;
495 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 }
497
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
499 if (NULL == pTLCb->reorderBufferPool)
500 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800501 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: Reorder buffer allocation failed"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530502 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
504 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 }
506
507 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
508
509 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
510
511 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
512 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530513 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 }
515
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800516 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
517 {
518 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
519 }
520
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 // scheduling init to be the last one of previous round
522 pTLCb->uCurServedAC = WLANTL_AC_BK;
523 pTLCb->ucCurLeftWeight = 1;
524 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
525
526#if 0
527 //flow control field init
528 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
529 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
530 pTLCb->tlFCInfo.fcConfig = 0x1;
531#endif
532
533 pTLCb->vosTxFCBuf = NULL;
534 pTLCb->tlConfigInfo.uMinFramesProcThres =
535 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700536
Sunil Ravid5406f22013-01-22 00:18:31 -0800537#ifdef FEATURE_WLAN_TDLS
538 pTLCb->ucTdlsPeerCount = 0;
539#endif
540
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
542 pTLConfig->uDelayedTriggerFrmInt;
543
544 /*------------------------------------------------------------------------
545 Allocate internal resources
546 ------------------------------------------------------------------------*/
547 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
548 1/*true*/,NULL, NULL);
549
550 WLANTL_InitBAReorderBuffer(pvosGCtx);
551#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
552 /* Initialize Handoff support modue
553 * RSSI measure and Traffic state monitoring */
554 status = WLANTL_HSInit(pvosGCtx);
555 if(!VOS_IS_STATUS_SUCCESS(status))
556 {
557 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
558 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530559 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 vos_mem_free(pTLCb->reorderBufferPool);
561 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
562 return status;
563 }
564#endif
565
566 pTLCb->isBMPS = VOS_FALSE;
567 pmcRegisterDeviceStateUpdateInd( smeContext,
568 WLANTL_PowerStateChangedCB, pvosGCtx );
569
570 return VOS_STATUS_SUCCESS;
571}/* WLANTL_Open */
572
573/*==========================================================================
574
575 FUNCTION WLANTL_Start
576
577 DESCRIPTION
578 Called by HDD as part of the overall start procedure. TL will use this
579 call to register with BAL as a transport layer entity.
580
581 DEPENDENCIES
582
583 PARAMETERS
584
585 IN
586 pvosGCtx: pointer to the global vos context; a handle to TL's
587 control block can be extracted from its context
588
589 RETURN VALUE
590 The result code associated with performing the operation
591
592 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
593 fault
594 VOS_STATUS_SUCCESS: Everything is good :)
595
596 Other codes can be returned as a result of a BAL failure; see BAL API
597 for more info
598
599 SIDE EFFECTS
600
601============================================================================*/
602VOS_STATUS
603WLANTL_Start
604(
605 v_PVOID_t pvosGCtx
606)
607{
608 WLANTL_CbType* pTLCb = NULL;
609 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
610 VOS_STATUS vosStatus;
611 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
612
613 /*------------------------------------------------------------------------
614 Sanity check
615 Extract TL control block
616 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530617 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 pTLCb = VOS_GET_TL_CB(pvosGCtx);
619 if ( NULL == pTLCb )
620 {
621 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
622 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
623 return VOS_STATUS_E_FAULT;
624 }
625
626 /*------------------------------------------------------------------------
627 Register with WDA as transport layer client
628 Request resources for tx from bus
629 ------------------------------------------------------------------------*/
630 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
631 "WLAN TL:WLAN TL:WLANTL_Start"));
632
633 vosStatus = WDA_DS_Register( pvosGCtx,
634 WLANTL_TxComp,
635 WLANTL_RxFrames,
636 WLANTL_GetFrames,
637 WLANTL_ResourceCB,
638 WDA_TLI_MIN_RES_DATA,
639 pvosGCtx,
640 &uResCount );
641
642 if ( VOS_STATUS_SUCCESS != vosStatus )
643 {
644 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
645 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
646 vosStatus));
647 return vosStatus;
648 }
649
650 /* Enable transmission */
651 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
652
653 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 return VOS_STATUS_SUCCESS;
655}/* WLANTL_Start */
656
657/*==========================================================================
658
659 FUNCTION WLANTL_Stop
660
661 DESCRIPTION
662 Called by HDD to stop operation in TL, before close. TL will suspend all
663 frame transfer operation and will wait for the close request to clean up
664 its resources.
665
666 DEPENDENCIES
667
668 PARAMETERS
669
670 IN
671 pvosGCtx: pointer to the global vos context; a handle to TL's
672 control block can be extracted from its context
673
674 RETURN VALUE
675 The result code associated with performing the operation
676
677 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
678 fault
679 VOS_STATUS_SUCCESS: Everything is good :)
680
681 SIDE EFFECTS
682
683============================================================================*/
684VOS_STATUS
685WLANTL_Stop
686(
687 v_PVOID_t pvosGCtx
688)
689{
690 WLANTL_CbType* pTLCb = NULL;
691 v_U8_t ucIndex;
692 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
693
694 /*------------------------------------------------------------------------
695 Sanity check
696 Extract TL control block
697 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530698 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 pTLCb = VOS_GET_TL_CB(pvosGCtx);
700 if ( NULL == pTLCb )
701 {
702 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
703 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
704 return VOS_STATUS_E_FAULT;
705 }
706
707 /*------------------------------------------------------------------------
708 Stop TL and empty Station list
709 ------------------------------------------------------------------------*/
710 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
711 "WLAN TL:WLANTL_Stop"));
712
713 /* Disable transmission */
714 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
715
716 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
717 {
718 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
719 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
720 }
721
722 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
723 {
724 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
725 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
726 }
727
728#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
729 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
730 {
731 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
732 "Handoff Support module stop fail"));
733 }
734#endif
735
736 /*-------------------------------------------------------------------------
737 Clean client stations
738 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530739 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530741 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
742 {
743 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
744 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 }
746
747
748 return VOS_STATUS_SUCCESS;
749}/* WLANTL_Stop */
750
751/*==========================================================================
752
753 FUNCTION WLANTL_Close
754
755 DESCRIPTION
756 Called by HDD during general driver close procedure. TL will clean up
757 all the internal resources.
758
759 DEPENDENCIES
760
761 PARAMETERS
762
763 IN
764 pvosGCtx: pointer to the global vos context; a handle to TL's
765 control block can be extracted from its context
766
767 RETURN VALUE
768 The result code associated with performing the operation
769
770 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
771 fault
772 VOS_STATUS_SUCCESS: Everything is good :)
773
774 SIDE EFFECTS
775
776============================================================================*/
777VOS_STATUS
778WLANTL_Close
779(
780 v_PVOID_t pvosGCtx
781)
782{
783 WLANTL_CbType* pTLCb = NULL;
784 tHalHandle smeContext;
785 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
786
787 /*------------------------------------------------------------------------
788 Sanity check
789 Extract TL control block
790 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530791 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 pTLCb = VOS_GET_TL_CB(pvosGCtx);
793 if ( NULL == pTLCb )
794 {
795 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
796 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
797 return VOS_STATUS_E_FAULT;
798 }
799 /*------------------------------------------------------------------------
800 Deregister from PMC
801 ------------------------------------------------------------------------*/
802 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
803 if ( NULL == smeContext )
804 {
805 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700806 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 // continue so that we can cleanup as much as possible
808 }
809 else
810 {
811 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
812 }
813
814#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
815 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
816 {
817 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
818 "Handoff Support module DeInit fail"));
819 }
820#endif
821
822 /*------------------------------------------------------------------------
823 Cleanup TL control block.
824 ------------------------------------------------------------------------*/
825 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
826 "WLAN TL: WLANTL_Close"));
827 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
828
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530829 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
830
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 vos_mem_free(pTLCb->reorderBufferPool);
832
833 /*------------------------------------------------------------------------
834 Free TL context from VOSS global
835 ------------------------------------------------------------------------*/
836 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
837 return VOS_STATUS_SUCCESS;
838}/* WLANTL_Close */
839
840/*----------------------------------------------------------------------------
841 INTERACTION WITH HDD
842 ---------------------------------------------------------------------------*/
843/*==========================================================================
844
845 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
846
847 DESCRIPTION
848 Function to disable/enable frame translation for all association stations.
849
850 DEPENDENCIES
851
852 PARAMETERS
853 IN
854 pvosGCtx: VOS context
855 EnableFrameXlation TRUE means enable SW translation for all stations.
856 .
857
858 RETURN VALUE
859
860 void.
861
862============================================================================*/
863void
864WLANTL_ConfigureSwFrameTXXlationForAll
865(
866 v_PVOID_t pvosGCtx,
867 v_BOOL_t enableFrameXlation
868)
869{
870 v_U8_t ucIndex;
871 /*------------------------------------------------------------------------
872 Extract TL control block
873 ------------------------------------------------------------------------*/
874 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530875 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 if ( NULL == pTLCb )
877 {
878 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
879 "WLAN TL:Invalid TL pointer from pvosGCtx on "
880 "WLANTL_ConfigureSwFrameTXXlationForAll"));
881 return;
882 }
883
884 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
885 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
886 enableFrameXlation));
887
888 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
889 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530890 pClientSTA = pTLCb->atlSTAClients[ucIndex];
891 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 {
893#ifdef WLAN_SOFTAP_VSTA_FEATURE
894 // if this station was not allocated resources to perform HW-based
895 // TX frame translation then force SW-based TX frame translation
896 // otherwise use the frame translation supplied by the client
897 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
898 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530899 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 }
901 else
902#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530903 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 }
905 }
906}
907
908/*===========================================================================
909
910 FUNCTION WLANTL_StartForwarding
911
912 DESCRIPTION
913
914 This function is used to ask serialization through TX thread of the
915 cached frame forwarding (if statation has been registered in the mean while)
916 or flushing (if station has not been registered by the time)
917
918 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
919 and doesn't need to call this function explicitly. TL will handle this inside
920 WLANTL_RegisterSTAClient().
921
922 In case of flushing, upper layer is required to call this function explicitly
923
924 DEPENDENCIES
925
926 TL must have been initialized before this gets called.
927
928
929 PARAMETERS
930
931 ucSTAId: station id
932
933 RETURN VALUE
934
935 The result code associated with performing the operation
936 Please check return values of vos_tx_mq_serialize.
937
938 SIDE EFFECTS
939 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
940 either WLANTL_RegisterSTAClient() or this function must be called
941 within reasonable time. Otherwise, TL will keep cached vos buffer until
942 one of this function is called, and may end up with system buffer exhasution.
943
944 It's an upper layer's responsibility to call this function in case of
945 flushing
946
947============================================================================*/
948
949VOS_STATUS
950WLANTL_StartForwarding
951(
952 v_U8_t ucSTAId,
953 v_U8_t ucUcastSig,
954 v_U8_t ucBcastSig
955)
956{
957 vos_msg_t sMessage;
958 v_U32_t uData;
959 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
960
961 /* Signal the OS to serialize our event */
962 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
963 "Serializing TL Start Forwarding Cached for control STA %d",
964 ucSTAId );
965
966 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
967
968 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -0800969 sMessage.bodyval = uData;
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 sMessage.type = WLANTL_TX_FWD_CACHED;
971
972 return vos_tx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
973
974} /* WLANTL_StartForwarding() */
975
976/*===========================================================================
977
978 FUNCTION WLANTL_AssocFailed
979
980 DESCRIPTION
981
982 This function is used by PE to notify TL that cache needs to flushed'
983 when association is not successfully completed
984
985 Internally, TL post a message to TX_Thread to serialize the request to
986 keep lock-free mechanism.
987
988
989 DEPENDENCIES
990
991 TL must have been initialized before this gets called.
992
993
994 PARAMETERS
995
996 ucSTAId: station id
997
998 RETURN VALUE
999
1000 none
1001
1002 SIDE EFFECTS
1003 There may be race condition that PE call this API and send another association
1004 request immediately with same staId before TX_thread can process the message.
1005
1006 To avoid this, we might need PE to wait for TX_thread process the message,
1007 but this is not currently implemented.
1008
1009============================================================================*/
1010void WLANTL_AssocFailed(v_U8_t staId)
1011{
1012 // flushing frames and forwarding frames uses the same message
1013 // the only difference is what happens when the message is processed
1014 // if the STA exist, the frames will be forwarded
1015 // and if it doesn't exist, the frames will be flushed
1016 // in this case we know it won't exist so the DPU index signature values don't matter
1017 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1018 {
1019 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001020 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 }
1022}
1023
1024 /*===========================================================================
1025
1026 FUNCTION WLANTL_Finish_ULA
1027
1028 DESCRIPTION
1029 This function is used by HDD to notify TL to finish Upper layer authentication
1030 incase the last EAPOL packet is pending in the TL queue.
1031 To avoid the race condition between sme set key and the last EAPOL packet
1032 the HDD module calls this function just before calling the sme_RoamSetKey.
1033
1034 DEPENDENCIES
1035
1036 TL must have been initialized before this gets called.
1037
1038 PARAMETERS
1039
1040 callbackRoutine: HDD Callback function.
1041 callbackContext : HDD userdata context.
1042
1043 RETURN VALUE
1044
1045 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1046
1047 SIDE EFFECTS
1048
1049============================================================================*/
1050
1051VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001052 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001053{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001054 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001055}
1056
1057
1058/*===========================================================================
1059
1060 FUNCTION WLANTL_RegisterSTAClient
1061
1062 DESCRIPTION
1063
1064 This function is used by HDD to register as a client for data services
1065 with TL. HDD will call this API for each new station that it adds,
1066 thus having the flexibility of registering different callback for each
1067 STA it services.
1068
1069 DEPENDENCIES
1070
1071 TL must have been initialized before this gets called.
1072
1073 Restriction:
1074 Main thread will have higher priority that Tx and Rx threads thus
1075 guaranteeing that a station will be added before any data can be
1076 received for it. (This enables TL to be lock free)
1077
1078 PARAMETERS
1079
1080 pvosGCtx: pointer to the global vos context; a handle to TL's
1081 control block can be extracted from its context
1082 pfnStARx: function pointer to the receive packet handler from HDD
1083 pfnSTATxComp: function pointer to the transmit complete confirmation
1084 handler from HDD
1085 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1086 wSTADescType: STA Descriptor, contains information related to the
1087 new added STA
1088
1089 RETURN VALUE
1090
1091 The result code associated with performing the operation
1092
1093 VOS_STATUS_E_INVAL: Input parameters are invalid
1094 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1095 TL cb is NULL ; access would cause a page fault
1096 VOS_STATUS_E_EXISTS: Station was already registered
1097 VOS_STATUS_SUCCESS: Everything is good :)
1098
1099 SIDE EFFECTS
1100
1101============================================================================*/
1102VOS_STATUS
1103WLANTL_RegisterSTAClient
1104(
1105 v_PVOID_t pvosGCtx,
1106 WLANTL_STARxCBType pfnSTARx,
1107 WLANTL_TxCompCBType pfnSTATxComp,
1108 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1109 WLAN_STADescType* pwSTADescType,
1110 v_S7_t rssi
1111)
1112{
1113 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301114 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1117
1118 /*------------------------------------------------------------------------
1119 Sanity check
1120 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301121 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1123 ( NULL == pfnSTAFetchPkt ))
1124 {
1125 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1126 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1127 return VOS_STATUS_E_INVAL;
1128 }
1129
1130 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1131 {
1132 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1133 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1134 return VOS_STATUS_E_FAULT;
1135 }
1136
1137 /*------------------------------------------------------------------------
1138 Extract TL control block
1139 ------------------------------------------------------------------------*/
1140 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1141 if ( NULL == pTLCb )
1142 {
1143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1144 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1145 return VOS_STATUS_E_FAULT;
1146 }
1147
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301148 //Code for checking and allocating memory for new STA
1149 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1150 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1151 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1152 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1153 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1154 return VOS_STATUS_E_FAILURE;
1155 }
1156 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1157 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1158 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1159 }
1160
1161 //Assigning the pointer to local variable for easy access in future
1162 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1163 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301165 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1167 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1168 return VOS_STATUS_E_EXISTS;
1169 }
1170
1171 /*------------------------------------------------------------------------
1172 Register station with TL
1173 ------------------------------------------------------------------------*/
1174 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1175 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1176
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301177 pClientSTA->pfnSTARx = pfnSTARx;
1178 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001179
1180 /* Only register if different from NULL - TL default Tx Comp Cb will
1181 release the vos packet */
1182 if ( NULL != pfnSTATxComp )
1183 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301184 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 }
1186
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301187 pClientSTA->tlState = WLANTL_STA_INIT;
1188 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1189 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301190 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001191
1192 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1193 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1194 pwSTADescType->ucSTAId,
1195 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1196
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301197 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001198
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301199 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001200
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301201 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001202
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301203 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001204
1205#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301206 pClientSTA->wSTADesc.ucIsCcxSta = pwSTADescType->ucIsCcxSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001207
1208 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1209 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d CcxSta %d",
1210 pwSTADescType->ucSTAId,
1211 pwSTADescType->ucQosEnabled,
1212 pwSTADescType->ucAddRmvLLC,
1213 pwSTADescType->ucProtectedFrame,
1214 pwSTADescType->ucIsCcxSta));
1215#else
1216
1217 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1218 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1219 pwSTADescType->ucSTAId,
1220 pwSTADescType->ucQosEnabled,
1221 pwSTADescType->ucAddRmvLLC,
1222 pwSTADescType->ucProtectedFrame));
1223
1224#endif //FEATURE_WLAN_CCX
1225#ifdef WLAN_SOFTAP_VSTA_FEATURE
1226 // if this station was not allocated resources to perform HW-based
1227 // TX frame translation then force SW-based TX frame translation
1228 // otherwise use the frame translation supplied by the client
1229
1230 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1231 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1232 {
1233 pwSTADescType->ucSwFrameTXXlation = 1;
1234 }
1235#endif
1236
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301237 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1238 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
1240#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301241 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242#endif /* FEATURE_WLAN_WAPI */
1243
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301244 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001245
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301246 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301248 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001249
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301251 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1252 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001253/*Clear replay counters of the STA on all TIDs*/
1254 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1255 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301256 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 /*--------------------------------------------------------------------
1260 Set the AC for the registered station to the highest priority AC
1261 Even if this AC is not supported by the station, correction will be
1262 made in the main TL loop after the supported mask is properly
1263 updated in the pending packets call
1264 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301265 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1266 pClientSTA->ucCurrentWeight = 0;
1267 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1268 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001269
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301270 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301272 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001273
1274 /*--------------------------------------------------------------------
1275 Reordering info and AMSDU de-aggregation
1276 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301277 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1278 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 WLAN_MAX_TID);
1280
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301281 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 WLANTL_MPDU_HEADER_LEN);
1283
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301284 pClientSTA->ucMPDUHeaderLen = 0;
1285 pClientSTA->vosAMSDUChain = NULL;
1286 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001287
1288
1289 /*--------------------------------------------------------------------
1290 Stats info
1291 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301292 vos_mem_zero( pClientSTA->auRxCount,
1293 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 WLAN_MAX_TID);
1295
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301296 vos_mem_zero( pClientSTA->auTxCount,
1297 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 WLAN_MAX_TID);
1299 /* Initial RSSI is always reported as zero because TL doesnt have enough
1300 data to calculate RSSI. So to avoid reporting zero, we are initializing
1301 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301302 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001303#ifdef FEATURE_WLAN_TDLS
1304 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1305 {
1306 /* If client is TDLS, use TDLS specific alpha */
1307 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1308 }
1309 else
1310 {
1311 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1312 }
1313#else
1314 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1315#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
1317 /*Tx not suspended and station fully registered*/
1318 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301319 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
1321 /* Used until multiple station support will be added*/
1322 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1323
1324 /* Save the BAP station ID for future usage */
1325 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1326 {
1327 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1328 }
1329
1330 /*------------------------------------------------------------------------
1331 Statistics info
1332 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301333 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1335
1336
1337 /*------------------------------------------------------------------------
1338 Start with the state suggested by client caller
1339 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301340 pClientSTA->tlState = pwSTADescType->ucInitState;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301341 pClientSTA->ucRxBlocked = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 /*-----------------------------------------------------------------------
1343 After all the init is complete we can mark the existance flag
1344 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301345 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001346
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301348 pClientSTA->ucLwmModeEnabled = FALSE;
1349 pClientSTA->ucLwmEventReported = FALSE;
1350 pClientSTA->bmuMemConsumed = 0;
1351 pClientSTA->uIngress_length = 0;
1352 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001353
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301354 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001355
1356 //@@@ HDDSOFTAP does not queue unregistered packet for now
1357 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1358 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 /*------------------------------------------------------------------------
1360 Forward received frames while STA was not yet registered
1361 - ----------------------------------------------------------------------*/
1362 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1363 pwSTADescType->ucUcastSig,
1364 pwSTADescType->ucBcastSig)))
1365 {
1366 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001367 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001369#ifdef FEATURE_WLAN_TDLS
1370 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1371 pTLCb->ucTdlsPeerCount++;
1372#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 return VOS_STATUS_SUCCESS;
1375}/* WLANTL_RegisterSTAClient */
1376
1377/*===========================================================================
1378
1379 FUNCTION WLANTL_ClearSTAClient
1380
1381 DESCRIPTION
1382
1383 HDD will call this API when it no longer needs data services for the
1384 particular station.
1385
1386 DEPENDENCIES
1387
1388 A station must have been registered before the clear registration is
1389 called.
1390
1391 PARAMETERS
1392
1393 pvosGCtx: pointer to the global vos context; a handle to TL's
1394 control block can be extracted from its context
1395 ucSTAId: identifier for the STA to be cleared
1396
1397 RETURN VALUE
1398
1399 The result code associated with performing the operation
1400
1401 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1402 TL cb is NULL ; access would cause a page fault
1403 VOS_STATUS_E_EXISTS: Station was not registered
1404 VOS_STATUS_SUCCESS: Everything is good :)
1405
1406 SIDE EFFECTS
1407
1408============================================================================*/
1409VOS_STATUS
1410WLANTL_ClearSTAClient
1411(
1412 v_PVOID_t pvosGCtx,
1413 v_U8_t ucSTAId
1414)
1415{
1416 WLANTL_CbType* pTLCb = NULL;
1417 v_U8_t ucIndex;
1418 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1419
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301420 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 /*------------------------------------------------------------------------
1422 Sanity check
1423 ------------------------------------------------------------------------*/
1424 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1425 {
1426 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1427 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1428 return VOS_STATUS_E_FAULT;
1429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 /*------------------------------------------------------------------------
1431 Extract TL control block
1432 ------------------------------------------------------------------------*/
1433 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1434 if ( NULL == pTLCb )
1435 {
1436 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1437 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1438 return VOS_STATUS_E_FAULT;
1439 }
1440
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301441 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1442 {
1443 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1444 "WLAN TL:Client Memory was not allocated on %s", __func__));
1445 return VOS_STATUS_E_FAILURE;
1446 }
1447
1448 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 {
1450 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1451 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
1452 return VOS_STATUS_E_EXISTS;
1453 }
1454
1455 /* Delete BA sessions on all TID's */
1456 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
1457 {
1458 WLANTL_BaSessionDel (pvosGCtx, ucSTAId, ucIndex);
1459 }
1460
Sunil Ravid5406f22013-01-22 00:18:31 -08001461#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301462 /* decrement ucTdlsPeerCount only if it is non-zero */
1463 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001464 && pTLCb->ucTdlsPeerCount)
1465 pTLCb->ucTdlsPeerCount--;
1466#endif
1467
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 /*------------------------------------------------------------------------
1469 Clear station
1470 ------------------------------------------------------------------------*/
1471 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1472 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301473 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001474
1475 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1476 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1477 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1478 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1479
1480 return VOS_STATUS_SUCCESS;
1481}/* WLANTL_ClearSTAClient */
1482
1483/*===========================================================================
1484
1485 FUNCTION WLANTL_ChangeSTAState
1486
1487 DESCRIPTION
1488
1489 HDD will make this notification whenever a change occurs in the
1490 connectivity state of a particular STA.
1491
1492 DEPENDENCIES
1493
1494 A station must have been registered before the change state can be
1495 called.
1496
1497 RESTRICTION: A station is being notified as authenticated before the
1498 keys are installed in HW. This way if a frame is received
1499 before the keys are installed DPU will drop that frame.
1500
1501 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1502 the following:
1503 - a station will be in assoc state in TL before TL receives any data
1504 for it
1505
1506 PARAMETERS
1507
1508 pvosGCtx: pointer to the global vos context; a handle to TL's
1509 control block can be extracted from its context
1510 ucSTAId: identifier for the STA that is pending transmission
1511 tlSTAState: the new state of the connection to the given station
1512
1513
1514 RETURN VALUE
1515
1516 The result code associated with performing the operation
1517
1518 VOS_STATUS_E_INVAL: Input parameters are invalid
1519 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1520 TL cb is NULL ; access would cause a page fault
1521 VOS_STATUS_E_EXISTS: Station was not registered
1522 VOS_STATUS_SUCCESS: Everything is good :)
1523
1524 SIDE EFFECTS
1525
1526============================================================================*/
1527VOS_STATUS
1528WLANTL_ChangeSTAState
1529(
1530 v_PVOID_t pvosGCtx,
1531 v_U8_t ucSTAId,
1532 WLANTL_STAStateType tlSTAState
1533)
1534{
1535 WLANTL_CbType* pTLCb = NULL;
1536 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1537
1538 /*------------------------------------------------------------------------
1539 Sanity check
1540 ------------------------------------------------------------------------*/
1541 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1542 {
1543 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1544 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1545 return VOS_STATUS_E_INVAL;
1546 }
1547
1548 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1549 {
1550 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1551 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1552 return VOS_STATUS_E_FAULT;
1553 }
1554
1555 /*------------------------------------------------------------------------
1556 Extract TL control block and check existance
1557 ------------------------------------------------------------------------*/
1558 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1559 if ( NULL == pTLCb )
1560 {
1561 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1562 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1563 return VOS_STATUS_E_FAULT;
1564 }
1565
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301566 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1567 {
1568 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1569 "WLAN TL:Client Memory was not allocated on %s", __func__));
1570 return VOS_STATUS_E_FAILURE;
1571 }
1572
1573 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 {
1575 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1576 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1577 return VOS_STATUS_E_EXISTS;
1578 }
1579
1580 /*------------------------------------------------------------------------
1581 Change STA state
1582 No need to lock this operation, see restrictions above
1583 ------------------------------------------------------------------------*/
1584 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1585 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301586 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001587
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301588 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001589
1590 return VOS_STATUS_SUCCESS;
1591}/* WLANTL_ChangeSTAState */
1592
1593/*===========================================================================
1594
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301595 FUNCTION WLANTL_STAPtkInstalled
1596
1597 DESCRIPTION
1598
1599 HDD will make this notification whenever PTK is installed for the STA
1600
1601 DEPENDENCIES
1602
1603 A station must have been registered before the change state can be
1604 called.
1605
1606 PARAMETERS
1607
1608 pvosGCtx: pointer to the global vos context; a handle to TL's
1609 control block can be extracted from its context
1610 ucSTAId: identifier for the STA for which Pairwise key is
1611 installed
1612
1613 RETURN VALUE
1614
1615 The result code associated with performing the operation
1616
1617 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1618 TL cb is NULL ; access would cause a page fault
1619 VOS_STATUS_E_EXISTS: Station was not registered
1620 VOS_STATUS_SUCCESS: Everything is good :)
1621
1622 SIDE EFFECTS
1623
1624============================================================================*/
1625VOS_STATUS
1626WLANTL_STAPtkInstalled
1627(
1628 v_PVOID_t pvosGCtx,
1629 v_U8_t ucSTAId
1630)
1631{
1632 WLANTL_CbType* pTLCb = NULL;
1633 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1634
1635 /*------------------------------------------------------------------------
1636 Sanity check
1637 ------------------------------------------------------------------------*/
1638
1639 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1640 {
1641 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1642 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1643 return VOS_STATUS_E_FAULT;
1644 }
1645
1646 /*------------------------------------------------------------------------
1647 Extract TL control block and check existance
1648 ------------------------------------------------------------------------*/
1649 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1650 if ( NULL == pTLCb )
1651 {
1652 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1653 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1654 return VOS_STATUS_E_FAULT;
1655 }
1656
1657 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1658 {
1659 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1660 FL("WLAN TL:Client Memory was not allocated")));
1661 return VOS_STATUS_E_FAILURE;
1662 }
1663
1664 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1665 {
1666 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1667 FL("WLAN TL:Station was not previously registered")));
1668 return VOS_STATUS_E_EXISTS;
1669 }
1670
1671 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1672
1673 return VOS_STATUS_SUCCESS;
1674}/* WLANTL_STAPtkInstalled */
1675
1676/*===========================================================================
1677
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001678 FUNCTION WLANTL_GetSTAState
1679
1680 DESCRIPTION
1681
1682 Returns connectivity state of a particular STA.
1683
1684 DEPENDENCIES
1685
1686 A station must have been registered before its state can be retrieved.
1687
1688
1689 PARAMETERS
1690
1691 IN
1692 pvosGCtx: pointer to the global vos context; a handle to TL's
1693 control block can be extracted from its context
1694 ucSTAId: identifier of the station
1695
1696 OUT
1697 ptlSTAState: the current state of the connection to the given station
1698
1699
1700 RETURN VALUE
1701
1702 The result code associated with performing the operation
1703
1704 VOS_STATUS_E_INVAL: Input parameters are invalid
1705 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1706 TL cb is NULL ; access would cause a page fault
1707 VOS_STATUS_E_EXISTS: Station was not registered
1708 VOS_STATUS_SUCCESS: Everything is good :)
1709
1710 SIDE EFFECTS
1711
1712============================================================================*/
1713VOS_STATUS
1714WLANTL_GetSTAState
1715(
1716 v_PVOID_t pvosGCtx,
1717 v_U8_t ucSTAId,
1718 WLANTL_STAStateType *ptlSTAState
1719)
1720{
1721 WLANTL_CbType* pTLCb = NULL;
1722 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1723
1724 /*------------------------------------------------------------------------
1725 Sanity check
1726 ------------------------------------------------------------------------*/
1727 if ( NULL == ptlSTAState )
1728 {
1729 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1730 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1731 return VOS_STATUS_E_INVAL;
1732 }
1733
1734 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1735 {
1736 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1737 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1738 return VOS_STATUS_E_FAULT;
1739 }
1740
1741 /*------------------------------------------------------------------------
1742 Extract TL control block and check existance
1743 ------------------------------------------------------------------------*/
1744 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1745 if ( NULL == pTLCb )
1746 {
1747 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1748 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1749 return VOS_STATUS_E_FAULT;
1750 }
1751
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301752 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1753 {
1754 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1755 "WLAN TL:Client Memory was not allocated on %s", __func__));
1756 return VOS_STATUS_E_FAILURE;
1757 }
1758
1759 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001760 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001761 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001762 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1763 return VOS_STATUS_E_EXISTS;
1764 }
1765
1766 /*------------------------------------------------------------------------
1767 Get STA state
1768 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301769 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001770
1771 return VOS_STATUS_SUCCESS;
1772}/* WLANTL_GetSTAState */
1773
Shailender Karmuchia734f332013-04-19 14:02:48 -07001774/*==========================================================================
1775 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1776
1777 DESCRIPTION
1778 HDD will call this API to update the BSSID for this Station.
1779
1780 DEPENDENCIES
1781 The HDD Should registered the staID with TL before calling this function.
1782
1783 PARAMETERS
1784
1785 IN
1786 pvosGCtx: Pointer to the global vos context; a handle to TL's
1787 or WDA's control block can be extracted from its context
1788 IN
1789 ucSTAId The Station ID for Bssid to be updated
1790 IN
1791 pBssid BSSID to be updated
1792
1793 RETURN VALUE
1794 The result code associated with performing the operation
1795
1796 VOS_STATUS_E_INVAL: Input parameters are invalid
1797 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1798 TL cb is NULL ; access would cause a page fault
1799 VOS_STATUS_E_EXISTS: Station was not registered
1800 VOS_STATUS_SUCCESS: Everything is good :)
1801
1802 SIDE EFFECTS
1803============================================================================*/
1804
1805
1806VOS_STATUS
1807WLANTL_UpdateSTABssIdforIBSS
1808(
1809 v_PVOID_t pvosGCtx,
1810 v_U8_t ucSTAId,
1811 v_U8_t *pBssid
1812)
1813{
1814 WLANTL_CbType* pTLCb = NULL;
1815 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1816
1817 /*------------------------------------------------------------------------
1818 Sanity check
1819 ------------------------------------------------------------------------*/
1820 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1821 {
1822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1823 "WLAN TL:Invalid station id requested %s", __func__));
1824 return VOS_STATUS_E_FAULT;
1825 }
1826
1827 /*------------------------------------------------------------------------
1828 Extract TL control block and check existance
1829 ------------------------------------------------------------------------*/
1830 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1831 if ( NULL == pTLCb )
1832 {
1833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1834 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1835 return VOS_STATUS_E_FAULT;
1836 }
1837
1838 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1839 {
1840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1841 "WLAN TL:Client Memory was not allocated on %s", __func__));
1842 return VOS_STATUS_E_FAILURE;
1843 }
1844
1845 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1846 {
1847 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1848 "WLAN TL:Station was not previously registered %s", __func__));
1849 return VOS_STATUS_E_EXISTS;
1850 }
1851
1852 /*------------------------------------------------------------------------
1853 Update the IBSS BSSID
1854 ------------------------------------------------------------------------*/
1855 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1856 pBssid, sizeof(v_MACADDR_t));
1857
1858 return VOS_STATUS_SUCCESS;
1859}
1860
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001861/*===========================================================================
1862
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 FUNCTION WLANTL_STAPktPending
1864
1865 DESCRIPTION
1866
1867 HDD will call this API when a packet is pending transmission in its
1868 queues.
1869
1870 DEPENDENCIES
1871
1872 A station must have been registered before the packet pending
1873 notification can be sent.
1874
1875 RESTRICTION: TL will not count packets for pending notification.
1876 HDD is expected to send the notification only when
1877 non-empty event gets triggered. Worst case scenario
1878 is that TL might end up making a call when Hdds
1879 queues are actually empty.
1880
1881 PARAMETERS
1882
1883 pvosGCtx: pointer to the global vos context; a handle to TL's
1884 control block can be extracted from its context
1885 ucSTAId: identifier for the STA that is pending transmission
1886
1887 RETURN VALUE
1888
1889 The result code associated with performing the operation
1890
1891 VOS_STATUS_E_INVAL: Input parameters are invalid
1892 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1893 to TL cb is NULL ; access would cause a page fault
1894 VOS_STATUS_E_EXISTS: Station was not registered
1895 VOS_STATUS_SUCCESS: Everything is good :)
1896
1897 SIDE EFFECTS
1898
1899============================================================================*/
1900VOS_STATUS
1901WLANTL_STAPktPending
1902(
1903 v_PVOID_t pvosGCtx,
1904 v_U8_t ucSTAId,
1905 WLANTL_ACEnumType ucAc
1906)
1907{
1908 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301909 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1912
1913 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1914 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
1915
1916 /*------------------------------------------------------------------------
1917 Sanity check
1918 ------------------------------------------------------------------------*/
1919 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1920 {
1921 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1922 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
1923 return VOS_STATUS_E_FAULT;
1924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 /*------------------------------------------------------------------------
1926 Extract TL control block and check existance
1927 ------------------------------------------------------------------------*/
1928 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1929 if ( NULL == pTLCb )
1930 {
1931 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1932 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
1933 return VOS_STATUS_E_FAULT;
1934 }
1935
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301936 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
1937
1938 if ( NULL == pClientSTA )
1939 {
1940 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1941 "WLAN TL:Client Memory was not allocated on %s", __func__));
1942 return VOS_STATUS_E_FAILURE;
1943 }
1944
1945 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 {
1947 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1948 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
1949 return VOS_STATUS_E_EXISTS;
1950 }
1951
1952 /*---------------------------------------------------------------------
1953 Temporary fix to enable TL to fetch packets when multiple peers join
1954 an IBSS. To fix CR177301. Needs to go away when the actual fix of
1955 going through all STA's in round robin fashion gets merged in from
1956 BT AMP branch.
1957 --------------------------------------------------------------------*/
1958 pTLCb->ucRegisteredStaId = ucSTAId;
1959
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301960 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001961 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
1962 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
1963 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
1964 to make sure TL is indeed waiting for EAPOL.
1965 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301966 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001967
1968 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07001969 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301970 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07001971 }
1972
Jeff Johnson295189b2012-06-20 16:38:30 -07001973 /*-----------------------------------------------------------------------
1974 Enable this AC in the AC mask in order for TL to start servicing it
1975 Set packet pending flag
1976 To avoid race condition, serialize the updation of AC and AC mask
1977 through WLANTL_TX_STAID_AC_IND message.
1978 -----------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08001979#ifdef FETURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301980 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08001981 !(vos_concurrent_sessions_running()) &&
1982 !pTLCb->ucTdlsPeerCount)
1983 {
1984#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301985 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001986 !(vos_concurrent_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 {
1988#endif
1989
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301990 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001991
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301992 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001993
1994 /*------------------------------------------------------------------------
1995 Check if there are enough resources for transmission and tx is not
1996 suspended.
1997 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07001998 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
1999 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 {
2001 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2002 "Issuing Xmit start request to BAL"));
2003 WDA_DS_StartXmit(pvosGCtx);
2004 }
2005 else
2006 {
2007 /*---------------------------------------------------------------------
2008 No error code is sent because TL will resume tx autonomously if
2009 resources become available or tx gets resumed
2010 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002011 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002013 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 }
2016 else
2017 {
2018 vosMsg.reserved = 0;
2019 vosMsg.bodyval = 0;
2020 vosMsg.bodyval = (ucAc | (ucSTAId << WLANTL_STAID_OFFSET));
2021 vosMsg.type = WLANTL_TX_STAID_AC_IND;
2022 return vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg);
2023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 return VOS_STATUS_SUCCESS;
2025}/* WLANTL_STAPktPending */
2026
2027/*==========================================================================
2028
2029 FUNCTION WLANTL_SetSTAPriority
2030
2031 DESCRIPTION
2032
2033 TL exposes this API to allow upper layers a rough control over the
2034 priority of transmission for a given station when supporting multiple
2035 connections.
2036
2037 DEPENDENCIES
2038
2039 A station must have been registered before the change in priority can be
2040 called.
2041
2042 PARAMETERS
2043
2044 pvosGCtx: pointer to the global vos context; a handle to TL's
2045 control block can be extracted from its context
2046 ucSTAId: identifier for the STA that has to change priority
2047
2048 RETURN VALUE
2049
2050 The result code associated with performing the operation
2051
2052 VOS_STATUS_E_INVAL: Input parameters are invalid
2053 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2054 to TL cb is NULL ; access would cause a page fault
2055 VOS_STATUS_E_EXISTS: Station was not registered
2056 VOS_STATUS_SUCCESS: Everything is good :)
2057
2058 SIDE EFFECTS
2059
2060============================================================================*/
2061VOS_STATUS
2062WLANTL_SetSTAPriority
2063(
2064 v_PVOID_t pvosGCtx,
2065 v_U8_t ucSTAId,
2066 WLANTL_STAPriorityType tlSTAPri
2067)
2068{
2069 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302070 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2072
2073 /*------------------------------------------------------------------------
2074 Sanity check
2075 ------------------------------------------------------------------------*/
2076 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2077 {
2078 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2079 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2080 return VOS_STATUS_E_FAULT;
2081 }
2082
2083 /*------------------------------------------------------------------------
2084 Extract TL control block
2085 ------------------------------------------------------------------------*/
2086 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2087 if ( NULL == pTLCb )
2088 {
2089 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2090 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2091 return VOS_STATUS_E_FAULT;
2092 }
2093
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302094 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2095
2096 if ( NULL == pClientSTA )
2097 {
2098 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2099 "WLAN TL:Client Memory was not allocated on %s", __func__));
2100 return VOS_STATUS_E_FAILURE;
2101 }
2102
2103 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 {
2105 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2106 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2107 return VOS_STATUS_E_EXISTS;
2108 }
2109
2110 /*------------------------------------------------------------------------
2111 Re-analize if lock is needed when adding multiple stations
2112 ------------------------------------------------------------------------*/
2113 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2114 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302115 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2116 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002117
2118 return VOS_STATUS_SUCCESS;
2119}/* WLANTL_SetSTAPriority */
2120
2121
2122/*----------------------------------------------------------------------------
2123 INTERACTION WITH BAP
2124 ---------------------------------------------------------------------------*/
2125
2126/*==========================================================================
2127
2128 FUNCTION WLANTL_RegisterBAPClient
2129
2130 DESCRIPTION
2131 Called by SME to register itself as client for non-data BT-AMP packets.
2132
2133 DEPENDENCIES
2134 TL must be initialized before this function can be called.
2135
2136 PARAMETERS
2137
2138 IN
2139 pvosGCtx: pointer to the global vos context; a handle to TL's
2140 or SME's control block can be extracted from its context
2141 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2142 BT-AMP packets
2143 pfnFlushOpCompleteCb:
2144 pointer to the call back function, for the Flush operation
2145 completion.
2146
2147
2148 RETURN VALUE
2149
2150 The result code associated with performing the operation
2151
2152 VOS_STATUS_E_INVAL: Input parameters are invalid
2153 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2154 to TL cb is NULL ; access would cause a page fault
2155 VOS_STATUS_E_EXISTS: BAL client was already registered
2156 VOS_STATUS_SUCCESS: Everything is good :)
2157
2158 SIDE EFFECTS
2159
2160============================================================================*/
2161VOS_STATUS
2162WLANTL_RegisterBAPClient
2163(
2164 v_PVOID_t pvosGCtx,
2165 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2166 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2167)
2168{
2169 WLANTL_CbType* pTLCb = NULL;
2170 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2171
2172 /*------------------------------------------------------------------------
2173 Sanity check
2174 ------------------------------------------------------------------------*/
2175 if ( NULL == pfnTlBAPRxFrm )
2176 {
2177 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2178 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2179 return VOS_STATUS_E_INVAL;
2180 }
2181
2182 if ( NULL == pfnFlushOpCompleteCb )
2183 {
2184 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2185 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2186 return VOS_STATUS_E_INVAL;
2187 }
2188
2189 /*------------------------------------------------------------------------
2190 Extract TL control block
2191 ------------------------------------------------------------------------*/
2192 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2193 if ( NULL == pTLCb )
2194 {
2195 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2196 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2197 return VOS_STATUS_E_FAULT;
2198 }
2199
2200 /*------------------------------------------------------------------------
2201 Make sure this is the first registration attempt
2202 ------------------------------------------------------------------------*/
2203 if ( 0 != pTLCb->tlBAPClient.ucExists )
2204 {
2205 pTLCb->tlBAPClient.ucExists++;
2206 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2207 "WLAN TL:BAP client was already registered"));
2208 return VOS_STATUS_E_EXISTS;
2209 }
2210
2211 /*------------------------------------------------------------------------
2212 Register station with TL
2213 ------------------------------------------------------------------------*/
2214 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2215 "WLAN TL:Registering BAP Client" ));
2216
2217 pTLCb->tlBAPClient.ucExists++;
2218
2219 if ( NULL != pfnTlBAPRxFrm )
2220 {
2221 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2222 }
2223
2224 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2225
2226 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2227
2228 return VOS_STATUS_SUCCESS;
2229}/* WLANTL_RegisterBAPClient */
2230
2231
2232/*==========================================================================
2233
2234 FUNCTION WLANTL_TxBAPFrm
2235
2236 DESCRIPTION
2237 BAP calls this when it wants to send a frame to the module
2238
2239 DEPENDENCIES
2240 BAP must be registered with TL before this function can be called.
2241
2242 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2243 a tx complete from the previous packet, that means BAP
2244 sends one packet, wait for tx complete and then
2245 sends another one
2246
2247 If BAP sends another packet before TL manages to process the
2248 previously sent packet call will end in failure
2249
2250 PARAMETERS
2251
2252 IN
2253 pvosGCtx: pointer to the global vos context; a handle to TL's
2254 or BAP's control block can be extracted from its context
2255 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2256 transmitted
2257 pMetaInfo: meta information about the packet
2258 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2259 the result of the operation over the bus
2260
2261 RETURN VALUE
2262 The result code associated with performing the operation
2263
2264 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2265 page fault
2266 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2267 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2268 VOS_STATUS_SUCCESS: Everything is good :)
2269
2270 Other failure messages may be returned from the BD header handling
2271 routines, please check apropriate API for more info.
2272
2273 SIDE EFFECTS
2274
2275============================================================================*/
2276VOS_STATUS
2277WLANTL_TxBAPFrm
2278(
2279 v_PVOID_t pvosGCtx,
2280 vos_pkt_t* vosDataBuff,
2281 WLANTL_MetaInfoType* pMetaInfo,
2282 WLANTL_TxCompCBType pfnTlBAPTxComp
2283)
2284{
2285 WLANTL_CbType* pTLCb = NULL;
2286 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2287 v_MACADDR_t vDestMacAddr;
2288 v_U16_t usPktLen;
2289 v_U8_t ucStaId = 0;
2290 v_U8_t extraHeadSpace = 0;
2291 v_U8_t ucWDSEnabled = 0;
2292 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2293
2294 /*------------------------------------------------------------------------
2295 Sanity check
2296 Extract TL control block
2297 ------------------------------------------------------------------------*/
2298 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2299 if ( NULL == pTLCb )
2300 {
2301 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2302 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2303 return VOS_STATUS_E_FAULT;
2304 }
2305
2306 /*------------------------------------------------------------------------
2307 Ensure that BAP client was registered previously
2308 ------------------------------------------------------------------------*/
2309 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2310 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2311 {
2312 pTLCb->tlBAPClient.ucExists++;
2313 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2314 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2315 return VOS_STATUS_E_EXISTS;
2316 }
2317
2318 /*------------------------------------------------------------------------
2319 Check if any BT-AMP Frm is pending
2320 ------------------------------------------------------------------------*/
2321 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2322 {
2323 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2324 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2325 return VOS_STATUS_E_BUSY;
2326 }
2327
2328 /*------------------------------------------------------------------------
2329 Save buffer and notify BAL; no lock is needed if the above restriction
2330 is met
2331 Save the tx complete fnct pointer as tl specific data in the vos buffer
2332 ------------------------------------------------------------------------*/
2333
2334 /*------------------------------------------------------------------------
2335 Translate 802.3 frame to 802.11
2336 ------------------------------------------------------------------------*/
2337 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302338 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2339 {
2340 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2341 "WLAN TL:Client Memory was not allocated on %s", __func__));
2342 return VOS_STATUS_E_FAILURE;
2343 }
2344 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2345 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002347 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2348 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002349 pMetaInfo, &ucWDSEnabled,
2350 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351
2352 if ( VOS_STATUS_SUCCESS != vosStatus )
2353 {
2354 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2355 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2356
2357 return vosStatus;
2358 }
2359
2360 pMetaInfo->ucDisableFrmXtl = 1;
2361 }
2362
2363 /*-------------------------------------------------------------------------
2364 Call HAL to fill BD header
2365 -------------------------------------------------------------------------*/
2366
2367 /* Adding Type, SubType which was missing for EAPOL from BAP */
2368 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2369 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2370
2371 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2372 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302373 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302375 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002377 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
2379 if ( VOS_STATUS_SUCCESS != vosStatus )
2380 {
2381 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2382 "WLAN TL:Failed while building TX header %d", vosStatus));
2383 return vosStatus;
2384 }
2385
2386 if ( NULL != pfnTlBAPTxComp )
2387 {
2388 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2389 (v_PVOID_t)pfnTlBAPTxComp);
2390 }
2391 else
2392 {
2393 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2394 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2395
2396 }
2397
2398 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2399 (v_U32_t)vosDataBuff);
2400
2401 /*------------------------------------------------------------------------
2402 Check if thre are enough resources for transmission and tx is not
2403 suspended.
2404 ------------------------------------------------------------------------*/
2405 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2406 ( 0 == pTLCb->ucTxSuspended ))
2407 {
2408 WDA_DS_StartXmit(pvosGCtx);
2409 }
2410 else
2411 {
2412 /*---------------------------------------------------------------------
2413 No error code is sent because TL will resume tx autonomously if
2414 resources become available or tx gets resumed
2415 ---------------------------------------------------------------------*/
2416 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2417 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2418 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2419 }
2420
2421 return VOS_STATUS_SUCCESS;
2422}/* WLANTL_TxBAPFrm */
2423
2424
2425/*----------------------------------------------------------------------------
2426 INTERACTION WITH SME
2427 ---------------------------------------------------------------------------*/
2428
2429/*==========================================================================
2430
2431 FUNCTION WLANTL_GetRssi
2432
2433 DESCRIPTION
2434 TL will extract the RSSI information from every data packet from the
2435 ongoing traffic and will store it. It will provide the result to SME
2436 upon request.
2437
2438 DEPENDENCIES
2439
2440 WARNING: the read and write of this value will not be protected
2441 by locks, therefore the information obtained after a read
2442 might not always be consistent.
2443
2444 PARAMETERS
2445
2446 IN
2447 pvosGCtx: pointer to the global vos context; a handle to TL's
2448 or SME's control block can be extracted from its context
2449 ucSTAId: station identifier for the requested value
2450
2451 OUT
2452 puRssi: the average value of the RSSI
2453
2454
2455 RETURN VALUE
2456 The result code associated with performing the operation
2457
2458 VOS_STATUS_E_INVAL: Input parameters are invalid
2459 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2460 to TL cb is NULL ; access would cause a page fault
2461 VOS_STATUS_E_EXISTS: STA was not yet registered
2462 VOS_STATUS_SUCCESS: Everything is good :)
2463
2464 SIDE EFFECTS
2465
2466============================================================================*/
2467VOS_STATUS
2468WLANTL_GetRssi
2469(
2470 v_PVOID_t pvosGCtx,
2471 v_U8_t ucSTAId,
2472 v_S7_t* pRssi
2473)
2474{
2475 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302476 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2478
2479 /*------------------------------------------------------------------------
2480 Sanity check
2481 ------------------------------------------------------------------------*/
2482 if ( NULL == pRssi )
2483 {
2484 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2485 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2486 return VOS_STATUS_E_INVAL;
2487 }
2488
2489 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2490 {
2491 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2492 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2493 return VOS_STATUS_E_FAULT;
2494 }
2495
2496 /*------------------------------------------------------------------------
2497 Extract TL control block and check existance
2498 ------------------------------------------------------------------------*/
2499 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2500 if ( NULL == pTLCb )
2501 {
2502 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2503 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2504 return VOS_STATUS_E_FAULT;
2505 }
2506
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302507 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2508
2509 if ( NULL == pClientSTA )
2510 {
2511 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2512 "WLAN TL:Client Memory was not allocated on %s", __func__));
2513 return VOS_STATUS_E_FAILURE;
2514 }
2515
2516 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 {
2518 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2519 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2520 return VOS_STATUS_E_EXISTS;
2521 }
2522
2523 /*------------------------------------------------------------------------
2524 Copy will not be locked; please read restriction
2525 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302526 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302528 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2530 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2531 might not have happend by that time. Hence reading the most recent Rssi
2532 calcluated by TL*/
2533 if(0 == *pRssi)
2534 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302535 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 }
2538 else
2539 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302540 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 }
2542
2543 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002544 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2545 ucSTAId, *pRssi,
2546 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
2548 return VOS_STATUS_SUCCESS;
2549}/* WLANTL_GetRssi */
2550
2551/*==========================================================================
2552
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302553 FUNCTION WLANTL_GetSnr
2554
2555 DESCRIPTION
2556 TL will extract the SNR information from every data packet from the
2557 ongoing traffic and will store it. It will provide the result to SME
2558 upon request.
2559
2560 DEPENDENCIES
2561
2562 WARNING: the read and write of this value will not be protected
2563 by locks, therefore the information obtained after a read
2564 might not always be consistent.
2565
2566 PARAMETERS
2567
2568 IN
2569 pvosGCtx: pointer to the global vos context; a handle to TL's
2570 or SME's control block can be extracted from its context
2571 ucSTAId: station identifier for the requested value
2572
2573 OUT
2574 pSnr: the average value of the SNR
2575
2576
2577 RETURN VALUE
2578 The result code associated with performing the operation
2579
2580 VOS_STATUS_E_INVAL: Input parameters are invalid
2581 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2582 to TL cb is NULL ; access would cause a page fault
2583 VOS_STATUS_E_EXISTS: STA was not yet registered
2584 VOS_STATUS_SUCCESS: Everything is good :)
2585
2586 SIDE EFFECTS
2587
2588============================================================================*/
2589VOS_STATUS
2590WLANTL_GetSnr
2591(
2592 tANI_U8 ucSTAId,
2593 tANI_S8* pSnr
2594)
2595{
2596 WLANTL_CbType* pTLCb = NULL;
2597 WLANTL_STAClientType* pClientSTA = NULL;
2598 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2599
2600 /*------------------------------------------------------------------------
2601 Sanity check
2602 ------------------------------------------------------------------------*/
2603 if (NULL == pSnr)
2604 {
2605 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2606 "WLAN TL:Invalid parameter sent on %s", __func__));
2607 return VOS_STATUS_E_INVAL;
2608 }
2609
2610 if (WLANTL_STA_ID_INVALID(ucSTAId))
2611 {
2612 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2613 "WLAN TL:Invalid station id requested on %s", __func__));
2614 return VOS_STATUS_E_FAULT;
2615 }
2616
2617 /*------------------------------------------------------------------------
2618 Extract TL control block and check existance
2619 ------------------------------------------------------------------------*/
2620 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2621 if (NULL == pTLCb)
2622 {
2623 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2624 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2625 return VOS_STATUS_E_FAULT;
2626 }
2627
2628 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2629
2630 if (NULL == pClientSTA)
2631 {
2632 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2633 "WLAN TL:Client Memory was not allocated on %s", __func__));
2634 return VOS_STATUS_E_FAILURE;
2635 }
2636
2637 if (0 == pClientSTA->ucExists)
2638 {
2639 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2640 "WLAN TL:Station was not previously registered on %s", __func__));
2641 return VOS_STATUS_E_EXISTS;
2642 }
2643
2644 /*------------------------------------------------------------------------
2645 Copy will not be locked; please read restriction
2646 ------------------------------------------------------------------------*/
2647 if (pTLCb->isBMPS)
2648 {
2649 *pSnr = pClientSTA->snrAvgBmps;
2650 }
2651 else
2652 {
2653 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2654 * data samples (snridx) to calculate the average then return the
2655 * average for the window of prevoius 20 packets. And if there aren't
2656 * enough samples and the average for previous window of 20 packets is
2657 * not available then return a predefined value
2658 *
2659 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2660 * team reveal that the SNR value has a ceiling well below 127 dBm,
2661 * so if SNR has value of 127 the userspace applications can know that
2662 * the SNR has not been computed yet because enough data was not
2663 * available for SNR calculation
2664 */
2665 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2666 || !(pClientSTA->prevSnrAvg))
2667 {
2668 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2669 }
2670 else if (pClientSTA->prevSnrAvg)
2671 {
2672 *pSnr = pClientSTA->prevSnrAvg;
2673 }
2674 else
2675 {
2676 *pSnr = SNR_HACK_BMPS;
2677 }
2678 }
2679
2680 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2681 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2682 ucSTAId, *pSnr,
2683 pTLCb->isBMPS ? " in BMPS" : "");
2684
2685 return VOS_STATUS_SUCCESS;
2686}/* WLANTL_GetSnr */
2687/*==========================================================================
2688
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 FUNCTION WLANTL_GetLinkQuality
2690
2691 DESCRIPTION
2692 TL will extract the SNR information from every data packet from the
2693 ongoing traffic and will store it. It will provide the result to SME
2694 upon request.
2695
2696 DEPENDENCIES
2697
2698 WARNING: the read and write of this value will not be protected
2699 by locks, therefore the information obtained after a read
2700 might not always be consistent.
2701
2702 PARAMETERS
2703
2704 IN
2705 pvosGCtx: pointer to the global vos context; a handle to TL's
2706 or SME's control block can be extracted from its context
2707 ucSTAId: station identifier for the requested value
2708
2709 OUT
2710 puLinkQuality: the average value of the SNR
2711
2712
2713 RETURN VALUE
2714 The result code associated with performing the operation
2715
2716 VOS_STATUS_E_INVAL: Input parameters are invalid
2717 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2718 to TL cb is NULL ; access would cause a page fault
2719 VOS_STATUS_E_EXISTS: STA was not yet registered
2720 VOS_STATUS_SUCCESS: Everything is good :)
2721
2722 SIDE EFFECTS
2723
2724============================================================================*/
2725VOS_STATUS
2726WLANTL_GetLinkQuality
2727(
2728 v_PVOID_t pvosGCtx,
2729 v_U8_t ucSTAId,
2730 v_U32_t* puLinkQuality
2731)
2732{
2733 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302734 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002735
2736 /*------------------------------------------------------------------------
2737 Sanity check
2738 ------------------------------------------------------------------------*/
2739 if ( NULL == puLinkQuality )
2740 {
2741 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2742 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2743 return VOS_STATUS_E_INVAL;
2744 }
2745
2746 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2747 {
2748 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2749 "Invalid station id requested on WLANTL_GetLinkQuality"));
2750 return VOS_STATUS_E_FAULT;
2751 }
2752
2753 /*------------------------------------------------------------------------
2754 Extract TL control block and check existance
2755 ------------------------------------------------------------------------*/
2756 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2757 if ( NULL == pTLCb )
2758 {
2759 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2760 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2761 return VOS_STATUS_E_FAULT;
2762 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302763 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002764
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302765 if ( NULL == pClientSTA )
2766 {
2767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2768 "WLAN TL:Client Memory was not allocated on %s", __func__));
2769 return VOS_STATUS_E_FAILURE;
2770 }
2771
2772 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 {
2774 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2775 "Station was not previously registered on WLANTL_GetLinkQuality"));
2776 return VOS_STATUS_E_EXISTS;
2777 }
2778
2779 /*------------------------------------------------------------------------
2780 Copy will not be locked; please read restriction
2781 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302782 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002783
2784 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2785 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2786
2787 return VOS_STATUS_SUCCESS;
2788}/* WLANTL_GetLinkQuality */
2789
2790/*==========================================================================
2791
2792 FUNCTION WLANTL_FlushStaTID
2793
2794 DESCRIPTION
2795 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2796 message to HAL. This API is called by the SME inorder to perform a flush
2797 operation.
2798
2799 DEPENDENCIES
2800
2801 PARAMETERS
2802
2803 IN
2804 pvosGCtx: pointer to the global vos context; a handle to TL's
2805 or SME's control block can be extracted from its context
2806 ucSTAId: station identifier for the requested value
2807 ucTid: Tspec ID for the new BA session
2808
2809 OUT
2810 The response for this post is received in the main thread, via a response
2811 message from HAL to TL.
2812
2813 RETURN VALUE
2814 VOS_STATUS_SUCCESS: Everything is good :)
2815
2816 SIDE EFFECTS
2817============================================================================*/
2818VOS_STATUS
2819WLANTL_FlushStaTID
2820(
2821 v_PVOID_t pvosGCtx,
2822 v_U8_t ucSTAId,
2823 v_U8_t ucTid
2824)
2825{
2826 WLANTL_CbType* pTLCb = NULL;
2827 tpFlushACReq FlushACReqPtr = NULL;
2828 vos_msg_t vosMessage;
2829
2830
2831 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2832 {
2833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2834 "Invalid station id requested on WLANTL_FlushStaTID"));
2835 return VOS_STATUS_E_FAULT;
2836 }
2837
2838 /*------------------------------------------------------------------------
2839 Extract TL control block and check existance
2840 ------------------------------------------------------------------------*/
2841 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2842 if ( NULL == pTLCb )
2843 {
2844 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2845 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2846 return VOS_STATUS_E_FAULT;
2847 }
2848
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302849 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2850 {
2851 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2852 "WLAN TL:Client Memory was not allocated on %s", __func__));
2853 return VOS_STATUS_E_FAILURE;
2854 }
2855
2856 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 {
2858 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2859 "Station was not previously registered on WLANTL_FlushStaTID"));
2860 return VOS_STATUS_E_EXISTS;
2861 }
2862
2863 /*------------------------------------------------------------------------
2864 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2865 ------------------------------------------------------------------------*/
2866 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2867
2868 if ( NULL == FlushACReqPtr )
2869 {
2870 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2871 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2872 VOS_ASSERT(0);
2873 return VOS_STATUS_E_NOMEM;
2874 }
2875
2876 // Start constructing the message for HAL
2877 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2878 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2879 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2880 FlushACReqPtr->ucSTAId = ucSTAId;
2881 FlushACReqPtr->ucTid = ucTid;
2882
2883 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2884 vosMessage.bodyptr = (void *)FlushACReqPtr;
2885
2886 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2887 return VOS_STATUS_SUCCESS;
2888}
2889
2890
2891/*----------------------------------------------------------------------------
2892 INTERACTION WITH PE
2893 ---------------------------------------------------------------------------*/
2894
2895/*==========================================================================
2896
2897 FUNCTION WLANTL_RegisterMgmtFrmClient
2898
2899 DESCRIPTION
2900 Called by PE to register as a client for management frames delivery.
2901
2902 DEPENDENCIES
2903 TL must be initialized before this API can be called.
2904
2905 PARAMETERS
2906
2907 IN
2908 pvosGCtx: pointer to the global vos context; a handle to
2909 TL's control block can be extracted from its context
2910 pfnTlMgmtFrmRx: pointer to the receive processing routine for
2911 management frames
2912
2913 RETURN VALUE
2914 The result code associated with performing the operation
2915
2916 VOS_STATUS_E_INVAL: Input parameters are invalid
2917 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2918 page fault
2919 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
2920 VOS_STATUS_SUCCESS: Everything is good :)
2921
2922 SIDE EFFECTS
2923
2924============================================================================*/
2925VOS_STATUS
2926WLANTL_RegisterMgmtFrmClient
2927(
2928 v_PVOID_t pvosGCtx,
2929 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
2930)
2931{
2932 WLANTL_CbType* pTLCb = NULL;
2933 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2934
2935 /*------------------------------------------------------------------------
2936 Sanity check
2937 ------------------------------------------------------------------------*/
2938 if ( NULL == pfnTlMgmtFrmRx )
2939 {
2940 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2941 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
2942 return VOS_STATUS_E_INVAL;
2943 }
2944
2945 /*------------------------------------------------------------------------
2946 Extract TL control block
2947 ------------------------------------------------------------------------*/
2948 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2949 if ( NULL == pTLCb )
2950 {
2951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2952 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
2953 return VOS_STATUS_E_FAULT;
2954 }
2955
2956 /*------------------------------------------------------------------------
2957 Make sure this is the first registration attempt
2958 ------------------------------------------------------------------------*/
2959 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
2960 {
2961 pTLCb->tlMgmtFrmClient.ucExists++;
2962 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2963 "WLAN TL:Management frame client was already registered"));
2964 return VOS_STATUS_E_EXISTS;
2965 }
2966
2967 /*------------------------------------------------------------------------
2968 Register station with TL
2969 ------------------------------------------------------------------------*/
2970 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2971 "WLAN TL:Registering Management Frame Client" ));
2972
2973 pTLCb->tlMgmtFrmClient.ucExists++;
2974
2975 if ( NULL != pfnTlMgmtFrmRx )
2976 {
2977 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
2978 }
2979
2980 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
2981
2982 return VOS_STATUS_SUCCESS;
2983}/* WLANTL_RegisterMgmtFrmClient */
2984
2985/*==========================================================================
2986
2987 FUNCTION WLANTL_DeRegisterMgmtFrmClient
2988
2989 DESCRIPTION
2990 Called by PE to deregister as a client for management frames delivery.
2991
2992 DEPENDENCIES
2993 TL must be initialized before this API can be called.
2994
2995 PARAMETERS
2996
2997 IN
2998 pvosGCtx: pointer to the global vos context; a handle to
2999 TL's control block can be extracted from its context
3000 RETURN VALUE
3001 The result code associated with performing the operation
3002
3003 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3004 page fault
3005 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3006 VOS_STATUS_SUCCESS: Everything is good :)
3007
3008 SIDE EFFECTS
3009
3010============================================================================*/
3011VOS_STATUS
3012WLANTL_DeRegisterMgmtFrmClient
3013(
3014 v_PVOID_t pvosGCtx
3015)
3016{
3017 WLANTL_CbType* pTLCb = NULL;
3018 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3019
3020 /*------------------------------------------------------------------------
3021 Extract TL control block
3022 ------------------------------------------------------------------------*/
3023 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3024 if ( NULL == pTLCb )
3025 {
3026 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3027 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3028 return VOS_STATUS_E_FAULT;
3029 }
3030
3031 /*------------------------------------------------------------------------
3032 Make sure this is the first registration attempt
3033 ------------------------------------------------------------------------*/
3034 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3035 {
3036 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3037 "WLAN TL:Management frame client was never registered"));
3038 return VOS_STATUS_E_EXISTS;
3039 }
3040
3041 /*------------------------------------------------------------------------
3042 Clear registration with TL
3043 ------------------------------------------------------------------------*/
3044 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3045 "WLAN TL:Deregistering Management Frame Client" ));
3046
3047 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3048 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3049 {
3050 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3051 "WLAN TL:Management cache buffer not empty on deregistering"
3052 " - dropping packet" ));
3053 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3054
3055 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3056 }
3057
3058 pTLCb->tlMgmtFrmClient.ucExists = 0;
3059
3060 return VOS_STATUS_SUCCESS;
3061}/* WLANTL_RegisterMgmtFrmClient */
3062
3063/*==========================================================================
3064
3065 FUNCTION WLANTL_TxMgmtFrm
3066
3067 DESCRIPTION
3068 Called by PE when it want to send out a management frame.
3069 HAL will also use this API for the few frames it sends out, they are not
3070 management frames howevere it is accepted that an exception will be
3071 allowed ONLY for the usage of HAL.
3072 Generic data frames SHOULD NOT travel through this function.
3073
3074 DEPENDENCIES
3075 TL must be initialized before this API can be called.
3076
3077 RESTRICTION: If PE sends another packet before TL manages to process the
3078 previously sent packet call will end in failure
3079
3080 Frames comming through here must be 802.11 frames, frame
3081 translation in UMA will be automatically disabled.
3082
3083 PARAMETERS
3084
3085 IN
3086 pvosGCtx: pointer to the global vos context;a handle to TL's
3087 control block can be extracted from its context
3088 vosFrmBuf: pointer to a vOSS buffer containing the management
3089 frame to be transmitted
3090 usFrmLen: the length of the frame to be transmitted; information
3091 is already included in the vOSS buffer
3092 wFrmType: the type of the frame being transmitted
3093 tid: tid used to transmit this frame
3094 pfnCompTxFunc: function pointer to the transmit complete routine
3095 pvBDHeader: pointer to the BD header, if NULL it means it was not
3096 yet constructed and it lies within TL's responsibility
3097 to do so; if not NULL it is expected that it was
3098 already packed inside the vos packet
3099 ucAckResponse: flag notifying it an interrupt is needed for the
3100 acknowledgement received when the frame is sent out
3101 the air and ; the interrupt will be processed by HAL,
3102 only one such frame can be pending in the system at
3103 one time.
3104
3105
3106 RETURN VALUE
3107 The result code associated with performing the operation
3108
3109 VOS_STATUS_E_INVAL: Input parameters are invalid
3110 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3111 page fault
3112 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3113 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3114 VOS_STATUS_SUCCESS: Everything is good :)
3115
3116 Other failure messages may be returned from the BD header handling
3117 routines, please check apropriate API for more info.
3118
3119 SIDE EFFECTS
3120
3121============================================================================*/
3122VOS_STATUS
3123WLANTL_TxMgmtFrm
3124(
3125 v_PVOID_t pvosGCtx,
3126 vos_pkt_t* vosFrmBuf,
3127 v_U16_t usFrmLen,
3128 v_U8_t wFrmType,
3129 v_U8_t ucTid,
3130 WLANTL_TxCompCBType pfnCompTxFunc,
3131 v_PVOID_t pvBDHeader,
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303132 v_U32_t ucAckResponse
Jeff Johnson295189b2012-06-20 16:38:30 -07003133)
3134{
3135 WLANTL_CbType* pTLCb = NULL;
3136 v_MACADDR_t vDestMacAddr;
3137 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3138 v_U16_t usPktLen;
3139 v_U32_t usTimeStamp = 0;
3140 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3141
3142 /*------------------------------------------------------------------------
3143 Sanity check
3144 ------------------------------------------------------------------------*/
3145 if ( NULL == vosFrmBuf )
3146 {
3147 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3148 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3149 return VOS_STATUS_E_INVAL;
3150 }
3151
3152 /*------------------------------------------------------------------------
3153 Extract TL control block
3154 ------------------------------------------------------------------------*/
3155 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3156 if ( NULL == pTLCb )
3157 {
3158 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3159 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3160 return VOS_STATUS_E_FAULT;
3161 }
3162
3163 /*------------------------------------------------------------------------
3164 Ensure that management frame client was previously registered
3165 ------------------------------------------------------------------------*/
3166 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3167 {
3168 pTLCb->tlMgmtFrmClient.ucExists++;
3169 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3170 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3171 return VOS_STATUS_E_EXISTS;
3172 }
3173
3174 /*------------------------------------------------------------------------
3175 Check if any Mgmt Frm is pending
3176 ------------------------------------------------------------------------*/
3177 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3178 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3179 {
3180
3181 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3182 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3183
3184
3185 /*Failing the tx for the previous packet enqued by PE*/
3186 //vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3187 // (v_U32_t)NULL);
3188
3189 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3190 // (v_PVOID_t)&pfnTxComp);
3191
3192 /*it should never be NULL - default handler should be registered if none*/
3193 //if ( NULL == pfnTxComp )
3194 //{
3195 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3196 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3197 // VOS_ASSERT(0);
3198 // return VOS_STATUS_E_FAULT;
3199 //}
3200
3201 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3202 //return VOS_STATUS_E_BUSY;
3203
3204
3205 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3206 return VOS_STATUS_E_RESOURCES;
3207 }
3208
3209
3210 /*------------------------------------------------------------------------
3211 Check if BD header was build, if not construct
3212 ------------------------------------------------------------------------*/
3213 if ( NULL == pvBDHeader )
3214 {
3215 v_MACADDR_t* pvAddr2MacAddr;
3216 v_U8_t uQosHdr = VOS_FALSE;
3217
3218 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3219 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3220 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3221 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3222
3223 if ( VOS_STATUS_SUCCESS != vosStatus )
3224 {
3225 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3226 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3227 return vosStatus;
3228 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303229
3230 /* CCX IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 * for management functionality comes through route.
3232 */
3233 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3234 {
3235 uQosHdr = VOS_TRUE;
3236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 /*----------------------------------------------------------------------
3238 Call WDA to build TX header
3239 ----------------------------------------------------------------------*/
3240 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3241 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
3242 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
3243 ucAckResponse, usTimeStamp, 0, 0 );
3244
3245
3246 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3247 {
3248 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3249 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3250 return vosStatus;
3251 }
3252 }/* if BD header not present */
3253
3254 /*------------------------------------------------------------------------
3255 Save buffer and notify BAL; no lock is needed if the above restriction
3256 is met
3257 Save the tx complete fnct pointer as tl specific data in the vos buffer
3258 ------------------------------------------------------------------------*/
3259 if ( NULL != pfnCompTxFunc )
3260 {
3261 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3262 (v_PVOID_t)pfnCompTxFunc);
3263 }
3264 else
3265 {
3266 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3267 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3268
3269 }
3270
3271 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3272 (v_U32_t)vosFrmBuf);
3273
3274 /*------------------------------------------------------------------------
3275 Check if thre are enough resources for transmission and tx is not
3276 suspended.
3277 ------------------------------------------------------------------------*/
3278 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3279 {
3280 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3281 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3282 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3283 if(VOS_STATUS_SUCCESS != vosStatus)
3284 {
3285 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3286 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
3287 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
3288 }
3289 return vosStatus;
3290
3291 }
3292 else
3293 {
3294 /*---------------------------------------------------------------------
3295 No error code is sent because TL will resume tx autonomously if
3296 resources become available or tx gets resumed
3297 ---------------------------------------------------------------------*/
3298 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3299 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3300 pTLCb->uResCount));
3301 }
3302
3303 return VOS_STATUS_SUCCESS;
3304}/* WLANTL_TxMgmtFrm */
3305
3306/*----------------------------------------------------------------------------
3307 INTERACTION WITH HAL
3308 ---------------------------------------------------------------------------*/
3309
3310/*==========================================================================
3311
3312 FUNCTION WLANTL_ResetNotification
3313
3314 DESCRIPTION
3315 HAL notifies TL when the module is being reset.
3316 Currently not used.
3317
3318 DEPENDENCIES
3319
3320 PARAMETERS
3321
3322 IN
3323 pvosGCtx: pointer to the global vos context; a handle to TL's
3324 control block can be extracted from its context
3325
3326
3327 RETURN VALUE
3328 The result code associated with performing the operation
3329
3330 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3331 page fault
3332 VOS_STATUS_SUCCESS: Everything is good :)
3333
3334 SIDE EFFECTS
3335
3336============================================================================*/
3337VOS_STATUS
3338WLANTL_ResetNotification
3339(
3340 v_PVOID_t pvosGCtx
3341)
3342{
3343 WLANTL_CbType* pTLCb = NULL;
3344 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3345
3346 /*------------------------------------------------------------------------
3347 Sanity check
3348 Extract TL control block
3349 ------------------------------------------------------------------------*/
3350 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3351 if ( NULL == pTLCb )
3352 {
3353 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3354 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3355 return VOS_STATUS_E_FAULT;
3356 }
3357
3358 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3359 return VOS_STATUS_SUCCESS;
3360}/* WLANTL_ResetNotification */
3361
3362/*==========================================================================
3363
3364 FUNCTION WLANTL_SuspendDataTx
3365
3366 DESCRIPTION
3367 HAL calls this API when it wishes to suspend transmission for a
3368 particular STA.
3369
3370 DEPENDENCIES
3371 The STA for which the request is made must be first registered with
3372 TL by HDD.
3373
3374 RESTRICTION: In case of a suspend, the flag write and read will not be
3375 locked: worst case scenario one more packet can get
3376 through before the flag gets updated (we can make this
3377 write atomic as well to guarantee consistency)
3378
3379 PARAMETERS
3380
3381 IN
3382 pvosGCtx: pointer to the global vos context; a handle to TL's
3383 control block can be extracted from its context
3384 pucSTAId: identifier of the station for which the request is made;
3385 a value of NULL assumes suspend on all active station
3386 pfnSuspendTxCB: pointer to the suspend result notification in case the
3387 call is asynchronous
3388
3389
3390 RETURN VALUE
3391 The result code associated with performing the operation
3392
3393 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3394 to TL cb is NULL ; access would cause a page fault
3395 VOS_STATUS_E_EXISTS: Station was not registered
3396 VOS_STATUS_SUCCESS: Everything is good :)
3397
3398 SIDE EFFECTS
3399
3400============================================================================*/
3401
3402VOS_STATUS
3403WLANTL_SuspendDataTx
3404(
3405 v_PVOID_t pvosGCtx,
3406 v_U8_t* pucSTAId,
3407 WLANTL_SuspendCBType pfnSuspendTx
3408)
3409{
3410 WLANTL_CbType* pTLCb = NULL;
3411 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003412
3413 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3414
3415 /*------------------------------------------------------------------------
3416 Sanity check
3417 Extract TL control block
3418 ------------------------------------------------------------------------*/
3419 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003420 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 {
3422 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3423 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3424 return VOS_STATUS_E_FAULT;
3425 }
3426
3427 /*------------------------------------------------------------------------
3428 Check the type of request: generic suspend, or per station suspend
3429 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003430 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 {
3432 /* General Suspend Request received */
3433 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3434 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003435 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3437 }
3438 else
3439 {
Hoonki Lee14621352013-04-16 17:51:19 -07003440 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 {
Hoonki Lee14621352013-04-16 17:51:19 -07003442 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3443 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3444 return VOS_STATUS_E_FAULT;
3445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003446
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303447 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3448 {
3449 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3450 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3451 "WLANTL_SuspendDataTx", *pucSTAId));
3452 return VOS_STATUS_E_FAULT;
3453 }
3454
3455 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003456 {
3457 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3458 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3459 return VOS_STATUS_E_EXISTS;
3460 }
3461
3462 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3463 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3464 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 vosMsg.reserved = *pucSTAId;
3466 }
3467
3468 /*------------------------------------------------------------------------
3469 Serialize request through TX thread
3470 ------------------------------------------------------------------------*/
3471 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3472 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3473
3474 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3475 {
3476 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003477 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 }
3479
3480 return VOS_STATUS_SUCCESS;
3481}/* WLANTL_SuspendDataTx */
3482
3483/*==========================================================================
3484
3485 FUNCTION WLANTL_ResumeDataTx
3486
3487 DESCRIPTION
3488 Called by HAL to resume data transmission for a given STA.
3489
3490 WARNING: If a station was individually suspended a global resume will
3491 not resume that station
3492
3493 DEPENDENCIES
3494
3495 PARAMETERS
3496
3497 IN
3498 pvosGCtx: pointer to the global vos context; a handle to TL's
3499 control block can be extracted from its context
3500 pucSTAId: identifier of the station which is being resumed; NULL
3501 translates into global resume
3502
3503 RETURN VALUE
3504 The result code associated with performing the operation
3505
3506 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3507 to TL cb is NULL ; access would cause a page fault
3508 VOS_STATUS_E_EXISTS: Station was not registered
3509 VOS_STATUS_SUCCESS: Everything is good :)
3510
3511 SIDE EFFECTS
3512
3513============================================================================*/
3514
3515VOS_STATUS
3516WLANTL_ResumeDataTx
3517(
3518 v_PVOID_t pvosGCtx,
3519 v_U8_t* pucSTAId
3520)
3521{
3522 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3524
3525 /*------------------------------------------------------------------------
3526 Sanity check
3527 Extract TL control block
3528 ------------------------------------------------------------------------*/
3529 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003530 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 {
3532 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3533 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3534 return VOS_STATUS_E_FAULT;
3535 }
3536
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 /*------------------------------------------------------------------------
3538 Check to see the type of resume
3539 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003540 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 {
3542 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3543 "WLAN TL:General resume requested"));
3544 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 }
3546 else
3547 {
Hoonki Lee14621352013-04-16 17:51:19 -07003548 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 {
Hoonki Lee14621352013-04-16 17:51:19 -07003550 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3551 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3552 return VOS_STATUS_E_FAULT;
3553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003554
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303555 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3556 {
3557 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3558 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3559 "WLANTL_ResumeDataTx", *pucSTAId));
3560 return VOS_STATUS_E_FAULT;
3561 }
3562
3563 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003564 {
3565 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3566 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3567 return VOS_STATUS_E_EXISTS;
3568 }
3569
3570 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3571 "WLAN TL:Resume request for station: %d", *pucSTAId));
3572 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 }
3574
3575 /*------------------------------------------------------------------------
3576 Resuming transmission
3577 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003578 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3579 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 {
3581 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3582 "WLAN TL:Resuming transmission"));
3583 return WDA_DS_StartXmit(pvosGCtx);
3584 }
3585
3586 return VOS_STATUS_SUCCESS;
3587}/* WLANTL_ResumeDataTx */
3588
3589/*==========================================================================
3590 FUNCTION WLANTL_SuspendCB
3591
3592 DESCRIPTION
3593 Callback function for serializing Suspend signal through Tx thread
3594
3595 DEPENDENCIES
3596 Just notify HAL that suspend in TL is complete.
3597
3598 PARAMETERS
3599
3600 IN
3601 pvosGCtx: pointer to the global vos context; a handle to TL's
3602 control block can be extracted from its context
3603 pUserData: user data sent with the callback
3604
3605 RETURN VALUE
3606 The result code associated with performing the operation
3607
3608 VOS_STATUS_E_INVAL: invalid input parameters
3609 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3610 page fault
3611 VOS_STATUS_SUCCESS: Everything is good :)
3612
3613
3614 SIDE EFFECTS
3615
3616============================================================================*/
3617VOS_STATUS
3618WLANTL_SuspendCB
3619(
3620 v_PVOID_t pvosGCtx,
3621 WLANTL_SuspendCBType pfnSuspendCB,
3622 v_U16_t usReserved
3623)
3624{
3625 WLANTL_CbType* pTLCb = NULL;
3626 v_U8_t ucSTAId = (v_U8_t)usReserved;
3627 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3628
3629 /*------------------------------------------------------------------------
3630 Sanity check
3631 ------------------------------------------------------------------------*/
3632 if ( NULL == pfnSuspendCB )
3633 {
3634 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3635 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3636 return VOS_STATUS_SUCCESS;
3637 }
3638
3639 /*------------------------------------------------------------------------
3640 Extract TL control block
3641 ------------------------------------------------------------------------*/
3642 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3643 if ( NULL == pTLCb )
3644 {
3645 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3646 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3647 return VOS_STATUS_E_FAULT;
3648 }
3649
3650 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3651 {
3652 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3653 }
3654 else
3655 {
3656 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3657 }
3658
3659 return VOS_STATUS_SUCCESS;
3660}/*WLANTL_SuspendCB*/
3661
3662
3663/*----------------------------------------------------------------------------
3664 CLIENT INDEPENDENT INTERFACE
3665 ---------------------------------------------------------------------------*/
3666
3667/*==========================================================================
3668
3669 FUNCTION WLANTL_GetTxPktCount
3670
3671 DESCRIPTION
3672 TL will provide the number of transmitted packets counted per
3673 STA per TID.
3674
3675 DEPENDENCIES
3676
3677 PARAMETERS
3678
3679 IN
3680 pvosGCtx: pointer to the global vos context; a handle to TL's
3681 control block can be extracted from its context
3682 ucSTAId: identifier of the station
3683 ucTid: identifier of the tspec
3684
3685 OUT
3686 puTxPktCount: the number of packets tx packet for this STA and TID
3687
3688 RETURN VALUE
3689 The result code associated with performing the operation
3690
3691 VOS_STATUS_E_INVAL: Input parameters are invalid
3692 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3693 to TL cb is NULL ; access would cause a page fault
3694 VOS_STATUS_E_EXISTS: Station was not registered
3695 VOS_STATUS_SUCCESS: Everything is good :)
3696
3697 SIDE EFFECTS
3698
3699============================================================================*/
3700VOS_STATUS
3701WLANTL_GetTxPktCount
3702(
3703 v_PVOID_t pvosGCtx,
3704 v_U8_t ucSTAId,
3705 v_U8_t ucTid,
3706 v_U32_t* puTxPktCount
3707)
3708{
3709 WLANTL_CbType* pTLCb = NULL;
3710 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3711
3712 /*------------------------------------------------------------------------
3713 Sanity check
3714 ------------------------------------------------------------------------*/
3715 if ( NULL == puTxPktCount )
3716 {
3717 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3718 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3719 return VOS_STATUS_E_INVAL;
3720 }
3721
3722 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3723 {
3724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3725 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3726 ucSTAId, ucTid));
3727 return VOS_STATUS_E_FAULT;
3728 }
3729
3730 /*------------------------------------------------------------------------
3731 Extract TL control block and check if station exists
3732 ------------------------------------------------------------------------*/
3733 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3734 if ( NULL == pTLCb )
3735 {
3736 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3737 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3738 return VOS_STATUS_E_FAULT;
3739 }
3740
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303741 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3742 {
3743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3744 "WLAN TL:Client Memory was not allocated on %s", __func__));
3745 return VOS_STATUS_E_FAILURE;
3746 }
3747
3748 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 {
3750 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3751 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3752 ucSTAId));
3753 return VOS_STATUS_E_EXISTS;
3754 }
3755
3756 /*------------------------------------------------------------------------
3757 Return data
3758 ------------------------------------------------------------------------*/
3759 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3760 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3761 // ucSTAId, ucTid);
3762
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303763 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003764
3765 return VOS_STATUS_SUCCESS;
3766}/* WLANTL_GetTxPktCount */
3767
3768/*==========================================================================
3769
3770 FUNCTION WLANTL_GetRxPktCount
3771
3772 DESCRIPTION
3773 TL will provide the number of received packets counted per
3774 STA per TID.
3775
3776 DEPENDENCIES
3777
3778 PARAMETERS
3779
3780 IN
3781 pvosGCtx: pointer to the global vos context; a handle to TL's
3782 control block can be extracted from its context
3783 ucSTAId: identifier of the station
3784 ucTid: identifier of the tspec
3785
3786 OUT
3787 puTxPktCount: the number of packets rx packet for this STA and TID
3788
3789 RETURN VALUE
3790 The result code associated with performing the operation
3791
3792 VOS_STATUS_E_INVAL: Input parameters are invalid
3793 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3794 to TL cb is NULL ; access would cause a page fault
3795 VOS_STATUS_E_EXISTS: Station was not registered
3796 VOS_STATUS_SUCCESS: Everything is good :)
3797
3798 SIDE EFFECTS
3799
3800============================================================================*/
3801VOS_STATUS
3802WLANTL_GetRxPktCount
3803(
3804 v_PVOID_t pvosGCtx,
3805 v_U8_t ucSTAId,
3806 v_U8_t ucTid,
3807 v_U32_t* puRxPktCount
3808)
3809{
3810 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303811 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3813
3814 /*------------------------------------------------------------------------
3815 Sanity check
3816 ------------------------------------------------------------------------*/
3817 if ( NULL == puRxPktCount )
3818 {
3819 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3820 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3821 return VOS_STATUS_E_INVAL;
3822 }
3823
3824 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3825 {
3826 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3827 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
3828 ucSTAId, ucTid));
3829 return VOS_STATUS_E_FAULT;
3830 }
3831
3832 /*------------------------------------------------------------------------
3833 Extract TL control block and existance
3834 ------------------------------------------------------------------------*/
3835 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3836 if ( NULL == pTLCb )
3837 {
3838 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3839 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
3840 return VOS_STATUS_E_FAULT;
3841 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303842 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003843
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303844 if ( NULL == pClientSTA )
3845 {
3846 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3847 "WLAN TL:Client Memory was not allocated on %s", __func__));
3848 return VOS_STATUS_E_FAILURE;
3849 }
3850
3851 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 {
3853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3854 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
3855 return VOS_STATUS_E_EXISTS;
3856 }
3857
3858 /*------------------------------------------------------------------------
3859 Return data
3860 ------------------------------------------------------------------------*/
3861 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3862 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
3863 ucSTAId, ucTid));
3864
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303865 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003866
3867 return VOS_STATUS_SUCCESS;
3868}/* WLANTL_GetRxPktCount */
3869
Jeff Johnson295189b2012-06-20 16:38:30 -07003870VOS_STATUS
3871WLANTL_TxFCFrame
3872(
3873 v_PVOID_t pvosGCtx
3874);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875/*============================================================================
3876 TL INTERNAL API DEFINITION
3877============================================================================*/
3878
3879/*==========================================================================
3880
3881 FUNCTION WLANTL_GetFrames
3882
3883 DESCRIPTION
3884
3885 BAL calls this function at the request of the lower bus interface.
3886 When this request is being received TL will retrieve packets from HDD
3887 in accordance with the priority rules and the count supplied by BAL.
3888
3889 DEPENDENCIES
3890
3891 HDD must have registered with TL at least one STA before this function
3892 can be called.
3893
3894 PARAMETERS
3895
3896 IN
3897 pvosGCtx: pointer to the global vos context; a handle to TL's
3898 or BAL's control block can be extracted from its context
3899 uSize: maximum size accepted by the lower layer
3900 uFlowMask TX flow control mask for Prima. Each bit is defined as
3901 WDA_TXFlowEnumType
3902
3903 OUT
3904 vosDataBuff: it will contain a pointer to the first buffer supplied
3905 by TL, if there is more than one packet supplied, TL
3906 will chain them through vOSS buffers
3907
3908 RETURN VALUE
3909
3910 The result code associated with performing the operation
3911
3912 1 or more: number of required resources if there are still frames to fetch
3913 0 : error or HDD queues are drained
3914
3915 SIDE EFFECTS
3916
3917 NOTE
3918
3919 Featurized uFlowMask. If we want to remove featurization, we need to change
3920 BAL on Volans.
3921
3922============================================================================*/
3923v_U32_t
3924WLANTL_GetFrames
3925(
3926 v_PVOID_t pvosGCtx,
3927 vos_pkt_t **ppFrameDataBuff,
3928 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 v_BOOL_t* pbUrgent
3931)
3932{
3933 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
3934 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303935 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 v_U32_t uRemaining = uSize;
3937 vos_pkt_t* vosRoot;
3938 vos_pkt_t* vosTempBuf;
3939 WLANTL_STAFuncType pfnSTAFsm;
3940 v_U16_t usPktLen;
3941 v_U32_t uResLen;
3942 v_U8_t ucSTAId;
3943 v_U8_t ucAC;
3944 vos_pkt_t* vosDataBuff;
3945 v_U32_t uTotalPktLen;
3946 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08003947 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 v_U32_t ucResult = 0;
3949 VOS_STATUS vosStatus;
3950 WLANTL_STAEventType wSTAEvent;
3951 tBssSystemRole systemRole;
3952 tpAniSirGlobal pMac;
3953 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3954
3955 /*------------------------------------------------------------------------
3956 Sanity check
3957 Extract TL control block
3958 ------------------------------------------------------------------------*/
3959 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3960 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
3961 {
3962 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3963 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3964 return ucResult;
3965 }
3966
3967 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
3968 if ( NULL == pMac )
3969 {
3970 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003971 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 return ucResult;
3973 }
3974
3975 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
3976 each iteration */
3977
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979
3980 /*-----------------------------------------------------------------------
3981 Save the root as we will walk this chain as we fill it
3982 -----------------------------------------------------------------------*/
3983 vosRoot = vosDataBuff;
3984
3985 /*-----------------------------------------------------------------------
3986 There is still data - until FSM function says otherwise
3987 -----------------------------------------------------------------------*/
3988 pTLCb->bUrgent = FALSE;
3989
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
3991 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 {
3993 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003994#ifdef WLAN_SOFTAP_FLOWCTRL_EN
3995/* FIXME: The code has been disabled since it is creating issues in power save */
3996 if (eSYSTEM_AP_ROLE == systemRole)
3997 {
3998 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
3999 {
4000 WLANTL_TxFCFrame (pvosGCtx);
4001 pTLCb->done_once ++;
4002 }
4003 }
4004 if ( NULL != pTLCb->vosTxFCBuf )
4005 {
4006 //there is flow control packet waiting to be sent
4007 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4008
4009 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004010 ( uRemaining > uTotalPktLen ) &&
4011 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 {
4013 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4014 "WLAN TL:Chaining FC frame first on GetFrame"));
4015
4016 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4017
4018 vos_atomic_set_U32( (v_U32_t*)&pTLCb->vosTxFCBuf, (v_U32_t)NULL);
4019
4020 /*FC frames cannot be delayed*/
4021 pTLCb->bUrgent = TRUE;
4022
4023 /*Update remaining len from SSC */
4024 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4025
4026 /*Update resource count */
4027 pTLCb->uResCount -= uResLen;
4028 }
4029 else
4030 {
4031 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004032 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4034 break; /* Out of resources or reached max len */
4035 }
4036 }
4037 else
4038#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004040 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4041 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 {
4043 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4044 usPktLen, uResLen, uTotalPktLen);
4045
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004046 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4047 {
4048 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4049 VOS_ASSERT(0);
4050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004051
4052 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004053 ( uRemaining > uTotalPktLen ) &&
4054 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
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 management frame on GetFrame"));
4058
4059 vos_pkt_chain_packet( vosDataBuff,
4060 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4061 1 /*true*/ );
4062
4063 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlMgmtFrmClient.
4064 vosPendingDataBuff, (v_U32_t)NULL);
4065
4066 /*management frames cannot be delayed*/
4067 pTLCb->bUrgent = TRUE;
4068
4069 /*Update remaining len from SSC */
4070 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4071
4072 /*Update resource count */
4073 pTLCb->uResCount -= uResLen;
4074 }
4075 else
4076 {
4077 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4078 break; /* Out of resources or reached max len */
4079 }
4080 }
4081 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4082 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004083 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 {
4085 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4086 usPktLen, uResLen, uTotalPktLen);
4087
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004088 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4089 {
4090 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4091 VOS_ASSERT(0);
4092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4095 ( uRemaining > uTotalPktLen ))
4096 {
4097 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4098 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4099
4100 vos_pkt_chain_packet( vosDataBuff,
4101 pTLCb->tlBAPClient.vosPendingDataBuff,
4102 1 /*true*/ );
4103
4104 /*BAP frames cannot be delayed*/
4105 pTLCb->bUrgent = TRUE;
4106
4107 vos_atomic_set_U32( (v_U32_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4108 (v_U32_t)NULL);
4109
4110 /*Update remaining len from SSC */
4111 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4112
4113 /*Update resource count */
4114 pTLCb->uResCount -= uResLen;
4115 }
4116 else
4117 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 break; /* Out of resources or reached max len */
4120 }
4121 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004122 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4123 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4124 by default, EAPOL will be treated as higher priority, which means
4125 use mgmt_pool and DXE_TX_HI prority channel.
4126 this is introduced to address EAPOL failure under high background traffic
4127 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4128 see CR#387009 and WCNSOS-8
4129 */
4130 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4131 ( 0 == pTLCb->ucTxSuspended ) &&
4132 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4133 )
4134 {
4135 vosTempBuf = NULL;
4136 /*---------------------------------------------------------------------
4137 Check to see if there was any EAPOL packet is pending
4138 *--------------------------------------------------------------------*/
4139 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4140 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304141 if ((NULL != pTLCb->atlSTAClients[i]) &&
4142 (pTLCb->atlSTAClients[i]->ucExists) &&
4143 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004144 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4145 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004146 )
4147 break;
4148 }
4149
4150 if (i >= WLAN_MAX_STA_COUNT)
4151 {
4152 /* No More to Serve Exit Get Frames */
4153 break;
4154 }
4155 /* Serve EAPOL frame with HI_FLOW_MASK */
4156 ucSTAId = i;
4157
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004158 for (j = WLANTL_MAX_AC ; j > 0; j--)
4159 {
4160 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4161 {
4162 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4163 pTLCb->uCurServedAC = j-1;
4164 }
4165 }
4166
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304167 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4168
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004169 wSTAEvent = WLANTL_TX_EVENT;
4170
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304171 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004172 pfnSTATbl[wSTAEvent];
4173
4174 if ( NULL != pfnSTAFsm )
4175 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304176 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004177 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004178
4179 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4180 ( NULL != vosTempBuf ))
4181 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304182 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004183 vosTempBuf = NULL;
4184 break;
4185 }/* status success*/
4186 }
4187
4188 if (NULL != vosTempBuf)
4189 {
4190 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4191
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004192 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4193 {
4194 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4195 VOS_ASSERT(0);
4196 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004197
4198 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4199 "WLAN TL:Resources needed by frame: %d", uResLen));
4200
4201 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4202 ( uRemaining > uTotalPktLen )
4203 )
4204 {
4205 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4206 "WLAN TL:Chaining data frame on GetFrame"));
4207
4208 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4209
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004210 /*EAPOL frame cannot be delayed*/
4211 pTLCb->bUrgent = TRUE;
4212
4213 vosTempBuf = NULL;
4214
4215 /*Update remaining len from SSC */
4216 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4217
4218 /*Update resource count */
4219 pTLCb->uResCount -= uResLen;
4220
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004221 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304222 pClientSTA->uIngress_length += uResLen;
4223 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4224 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004225 pClientSTA->ucEapolPktPending = 0;
4226 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4227 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4228 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004229 }
4230 }
4231 else
4232 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004233 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4234 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4235 ucSTAId));
4236 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004237 }
4238 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004239
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004240 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4241 ( 0 == pTLCb->ucTxSuspended ) &&
4242 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4243 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4244 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4245 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 {
4247 /*---------------------------------------------------------------------
4248 Check to see if there was any packet left behind previously due to
4249 size constraints
4250 ---------------------------------------------------------------------*/
4251 vosTempBuf = NULL;
4252
4253 if ( NULL != pTLCb->vosTempBuf )
4254 {
4255 vosTempBuf = pTLCb->vosTempBuf;
4256 pTLCb->vosTempBuf = NULL;
4257 ucSTAId = pTLCb->ucCachedSTAId;
4258 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304259
4260 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4261 {
4262 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4263 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304264 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304265 }
4266
4267 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304268 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004269
4270 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4271 "WLAN TL:Chaining cached data frame on GetFrame"));
4272 }
4273 else
4274 {
4275 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4276 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4277 {
4278 /* Packets start coming in even after insmod Without *
4279 starting Hostapd or Interface being up *
4280 During which cases STAID is invaled and hence
4281 the check. HalMsg_ScnaComplete Triggers */
4282
4283 break;
4284 }
4285 /* ucCurrentAC should have correct AC to be served by calling
4286 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304287 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304288 if ( NULL == pClientSTA )
4289 {
4290 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4291 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304292 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304293 }
4294
4295 ucAC = pClientSTA->ucCurrentAC;
4296
4297 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004299 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 /*-------------------------------------------------------------------
4301 Check to see that STA is valid and tx is not suspended
4302 -------------------------------------------------------------------*/
4303 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304304 ( 0 == pClientSTA->ucTxSuspended ) &&
4305 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 {
4307 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004308 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 wSTAEvent = WLANTL_TX_EVENT;
4310
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304311 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 pfnSTATbl[wSTAEvent];
4313
4314 if ( NULL != pfnSTAFsm )
4315 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304316 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004317 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004318
4319 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4320 ( NULL != vosTempBuf ))
4321 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304322 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 vosTempBuf,
4324 vosStatus );
4325 vosTempBuf = NULL;
4326 }/* status success*/
4327 }/*NULL function state*/
4328 }/* valid STA id and ! suspended*/
4329 else
4330 {
4331 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4332 {
4333 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4334 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4335 ucSTAId));
4336 }
4337 }
4338 }/* data */
4339
4340 if ( NULL != vosTempBuf )
4341 {
4342 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4343
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004344 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4345 {
4346 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4347 VOS_ASSERT(0);
4348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004349
4350 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4351 "WLAN TL:Resources needed by frame: %d", uResLen));
4352
4353 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004354 ( uRemaining > uTotalPktLen ) &&
4355 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 {
4357 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4358 "WLAN TL:Chaining data frame on GetFrame"));
4359
4360 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4361 vosTempBuf = NULL;
4362
4363 /*Update remaining len from SSC */
4364 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4365
4366 /*Update resource count */
4367 pTLCb->uResCount -= uResLen;
4368
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304370 pClientSTA->uIngress_length += uResLen;
4371 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4372 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004373
4374 }
4375 else
4376 {
4377 /* Store this for later tx - already fetched from HDD */
4378 pTLCb->vosTempBuf = vosTempBuf;
4379 pTLCb->ucCachedSTAId = ucSTAId;
4380 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4382 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4383 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 break; /* Out of resources or reached max len */
4385 }
4386 }
4387 else
4388 {
4389 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4390 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304391 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4392 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 {
4394 /* There is station to be Served */
4395 break;
4396 }
4397 }
4398 if (i >= WLAN_MAX_STA_COUNT)
4399 {
4400 /* No More to Serve Exit Get Frames */
4401 break;
4402 }
4403 else
4404 {
4405 /* More to be Served */
4406 continue;
4407 }
4408 }
4409 }
4410 else
4411 {
4412 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4413 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4414 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 /* TL is starving even when DXE is not in low resource condition
4416 Return min resource number required and Let DXE deceide what to do */
4417 if(( 0 == pTLCb->ucTxSuspended ) &&
4418 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4419 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4420 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4421 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4422 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004423 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 "WLAN TL:Returning from GetFrame: resources = %d",
4425 pTLCb->uResCount));
4426 ucResult = WDA_TLI_MIN_RES_DATA;
4427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 break; /*out of min data resources*/
4429 }
4430
4431 pTLCb->usPendingTxCompleteCount++;
4432 /* Move data buffer up one packet */
4433 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4434 }
4435
4436 /*----------------------------------------------------------------------
4437 Packet chain starts at root + 1
4438 ----------------------------------------------------------------------*/
4439 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4440
4441 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004442 if (pbUrgent)
4443 {
4444 *pbUrgent = pTLCb->bUrgent;
4445 }
4446 else
4447 {
4448 VOS_ASSERT( pbUrgent );
4449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 return ucResult;
4451}/* WLANTL_GetFrames */
4452
4453
4454/*==========================================================================
4455
4456 FUNCTION WLANTL_TxComp
4457
4458 DESCRIPTION
4459 It is being called by BAL upon asynchronous notification of the packet
4460 or packets being sent over the bus.
4461
4462 DEPENDENCIES
4463 Tx complete cannot be called without a previous transmit.
4464
4465 PARAMETERS
4466
4467 IN
4468 pvosGCtx: pointer to the global vos context; a handle to TL's
4469 or BAL's control block can be extracted from its context
4470 vosDataBuff: it will contain a pointer to the first buffer for which
4471 the BAL report is being made, if there is more then one
4472 packet they will be chained using vOSS buffers.
4473 wTxStatus: the status of the transmitted packet, see above chapter
4474 on HDD interaction for a list of possible values
4475
4476 RETURN VALUE
4477 The result code associated with performing the operation
4478
4479 VOS_STATUS_E_INVAL: Input parameters are invalid
4480 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4481 page fault
4482 VOS_STATUS_E_EXISTS: Station was not registered
4483 VOS_STATUS_SUCCESS: Everything is good :)
4484
4485 SIDE EFFECTS
4486
4487============================================================================*/
4488VOS_STATUS
4489WLANTL_TxComp
4490(
4491 v_PVOID_t pvosGCtx,
4492 vos_pkt_t *pFrameDataBuff,
4493 VOS_STATUS wTxStatus
4494)
4495{
4496 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4497 WLANTL_CbType* pTLCb = NULL;
4498 WLANTL_TxCompCBType pfnTxComp = NULL;
4499 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 vos_pkt_t* vosTempTx = NULL;
4501
4502 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4503
4504 /*------------------------------------------------------------------------
4505 Sanity check
4506 ------------------------------------------------------------------------*/
4507 if ( NULL == vosDataBuff )
4508 {
4509 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4510 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4511 return VOS_STATUS_E_INVAL;
4512 }
4513
4514 /*------------------------------------------------------------------------
4515 Extract TL control block
4516 ------------------------------------------------------------------------*/
4517 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4518 if ( NULL == pTLCb )
4519 {
4520 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4521 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4522 return VOS_STATUS_E_FAULT;
4523 }
4524
4525 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4526 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4527 ( NULL != vosDataBuff))
4528 {
4529 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4530 (v_PVOID_t)&pfnTxComp);
4531
4532 /*it should never be NULL - default handler should be registered if none*/
4533 if ( NULL == pfnTxComp )
4534 {
4535 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4536 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4537 VOS_ASSERT(0);
4538 return VOS_STATUS_E_FAULT;
4539 }
4540
4541 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304542 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 vosDataBuff, pfnTxComp));
4544
4545 vosTempTx = vosDataBuff;
4546 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4547 &vosDataBuff, 1/*true*/);
4548
4549 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4550
4551 pTLCb->usPendingTxCompleteCount--;
4552 }
4553
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4556 "WLAN TL: current TL values are: resources = %d "
4557 "pTLCb->usPendingTxCompleteCount = %d",
4558 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4559
4560 return VOS_STATUS_SUCCESS;
4561}/* WLANTL_TxComp */
4562
4563/*==========================================================================
4564
4565 FUNCTION WLANTL_CacheSTAFrame
4566
4567 DESCRIPTION
4568 Internal utility function for for caching incoming data frames that do
4569 not have a registered station yet.
4570
4571 DEPENDENCIES
4572 TL must be initiailized before this function gets called.
4573 In order to benefit from thsi caching, the components must ensure that
4574 they will only register with TL at the moment when they are fully setup
4575 and ready to receive incoming data
4576
4577 PARAMETERS
4578
4579 IN
4580
4581 pTLCb: TL control block
4582 ucSTAId: station id
4583 vosTempBuff: the data packet
4584 uDPUSig: DPU signature of the incoming packet
4585 bBcast: true if packet had the MC/BC bit set
4586
4587 RETURN VALUE
4588 The result code associated with performing the operation
4589
4590 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4591 would cause a page fault
4592 VOS_STATUS_SUCCESS: Everything is good :)
4593
4594 SIDE EFFECTS
4595
4596============================================================================*/
4597static VOS_STATUS
4598WLANTL_CacheSTAFrame
4599(
4600 WLANTL_CbType* pTLCb,
4601 v_U8_t ucSTAId,
4602 vos_pkt_t* vosTempBuff,
4603 v_U32_t uDPUSig,
4604 v_U8_t bBcast,
4605 v_U8_t ucFrmType
4606)
4607{
4608 v_U8_t ucUcastSig;
4609 v_U8_t ucBcastSig;
4610 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304611 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4613
4614 /*-------------------------------------------------------------------------
4615 Sanity check
4616 -------------------------------------------------------------------------*/
4617 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4618 {
4619 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304620 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4621 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 return VOS_STATUS_E_FAULT;
4623 }
4624
4625 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4626 {
4627 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4628 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4629 return VOS_STATUS_E_FAULT;
4630 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304631 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4632
4633 if ( NULL == pClientSTA )
4634 {
4635 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4636 "WLAN TL:Client Memory was not allocated on %s", __func__));
4637 return VOS_STATUS_E_FAILURE;
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639
4640 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4641 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4642 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304643 pClientSTA->wSTADesc.ucUcastSig,
4644 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
4646 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4647 {
4648 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4649 "WLAN TL: No need to cache CTRL frame. Dropping"));
4650 vos_pkt_return_packet(vosTempBuff);
4651 return VOS_STATUS_SUCCESS;
4652 }
4653
4654 /*-------------------------------------------------------------------------
4655 Check if the packet that we are trying to cache belongs to the old
4656 registered station (if any) or the new (potentially)upcoming station
4657
4658 - If the STA with this Id was never registered with TL - the signature
4659 will be invalid;
4660 - If the STA was previously registered TL will have cached the former
4661 set of DPU signatures
4662 -------------------------------------------------------------------------*/
4663 if ( bBcast )
4664 {
4665 ucBcastSig = (v_U8_t)uDPUSig;
4666 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304667 pClientSTA->wSTADesc.ucBcastSig ) &&
4668 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 }
4670 else
4671 {
4672 ucUcastSig = (v_U8_t)uDPUSig;
4673 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304674 pClientSTA->wSTADesc.ucUcastSig ) &&
4675 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 }
4677
4678 /*------------------------------------------------------------------------
4679 If the value of the DPU SIG matches the old, this packet will not
4680 be cached as it belonged to the former association
4681 In case the SIG does not match - this is a packet for a potentially new
4682 associated station
4683 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004684 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 {
4686 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4687 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4688 "BC: %d - dropping",
4689 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304690 pClientSTA->wSTADesc.ucUcastSig,
4691 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 vos_pkt_return_packet(vosTempBuff);
4693 }
4694 else
4695 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304696 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 {
4698 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304699 pClientSTA->vosBegCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 }
4701 else
4702 {
4703 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304704 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 vosTempBuff, VOS_TRUE);
4706 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304707 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 }/*else new packet*/
4709
4710 return VOS_STATUS_SUCCESS;
4711}/*WLANTL_CacheSTAFrame*/
4712
4713/*==========================================================================
4714
4715 FUNCTION WLANTL_FlushCachedFrames
4716
4717 DESCRIPTION
4718 Internal utility function used by TL to flush the station cache
4719
4720 DEPENDENCIES
4721 TL must be initiailized before this function gets called.
4722
4723 PARAMETERS
4724
4725 IN
4726
4727 vosDataBuff: it will contain a pointer to the first cached buffer
4728 received,
4729
4730 RETURN VALUE
4731 The result code associated with performing the operation
4732
4733 VOS_STATUS_SUCCESS: Everything is good :)
4734
4735 SIDE EFFECTS
4736
4737 NOTE
4738 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4739 responsibility to do so, if required, after this function call.
4740 Because of this restriction, we decide to make this function to static
4741 so that upper layer doesn't need to be aware of this restriction.
4742
4743============================================================================*/
4744static VOS_STATUS
4745WLANTL_FlushCachedFrames
4746(
4747 vos_pkt_t* vosDataBuff
4748)
4749{
4750 /*----------------------------------------------------------------------
4751 Return the entire chain to vos if there are indeed cache frames
4752 ----------------------------------------------------------------------*/
4753 if ( NULL != vosDataBuff )
4754 {
4755 vos_pkt_return_packet(vosDataBuff);
4756 }
4757
4758 return VOS_STATUS_SUCCESS;
4759}/*WLANTL_FlushCachedFrames*/
4760
4761/*==========================================================================
4762
4763 FUNCTION WLANTL_ForwardSTAFrames
4764
4765 DESCRIPTION
4766 Internal utility function for either forwarding cached data to the station after
4767 the station has been registered, or flushing cached data if the station has not
4768 been registered.
4769
4770
4771 DEPENDENCIES
4772 TL must be initiailized before this function gets called.
4773
4774 PARAMETERS
4775
4776 IN
4777
4778 pTLCb: TL control block
4779 ucSTAId: station id
4780
4781 RETURN VALUE
4782 The result code associated with performing the operation
4783
4784 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4785 page fault
4786 VOS_STATUS_SUCCESS: Everything is good :)
4787
4788 SIDE EFFECTS
4789 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4790 responsibility to do so, if required, after this function call.
4791 Because of this restriction, we decide to make this function to static
4792 so that upper layer doesn't need to be aware of this restriction.
4793
4794============================================================================*/
4795static VOS_STATUS
4796WLANTL_ForwardSTAFrames
4797(
4798 void* pvosGCtx,
4799 v_U8_t ucSTAId,
4800 v_U8_t ucUcastSig,
4801 v_U8_t ucBcastSig
4802)
4803{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304804 WLANTL_CbType* pTLCb = NULL;
4805 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4807
4808 /*-------------------------------------------------------------------------
4809 Sanity check
4810 -------------------------------------------------------------------------*/
4811 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4812 if ( NULL == pTLCb )
4813 {
4814 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304815 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 pTLCb ));
4817 return VOS_STATUS_E_FAULT;
4818 }
4819
4820 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4821 {
4822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4823 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
4824 return VOS_STATUS_E_FAULT;
4825 }
4826
4827 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4828
4829 /*------------------------------------------------------------------------
4830 Check if station has not been registered in the mean while
4831 if not registered, flush cached frames.
4832 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304833 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4834
4835 if ( NULL == pClientSTA )
4836 {
4837 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4838 "WLAN TL:Client Memory was not allocated on %s", __func__));
4839 return VOS_STATUS_E_FAILURE;
4840 }
4841
4842 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 {
4844 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4845 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304846 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 goto done;
4848 }
4849
4850 /*------------------------------------------------------------------------
4851 Forwarding cache frames received while the station was in the process
4852 of being registered with the rest of the SW components
4853
4854 Access to the cache must be locked; similarly updating the signature and
4855 the existence flag must be synchronized because these values are checked
4856 during cached
4857 ------------------------------------------------------------------------*/
4858 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4859 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
4860
4861 /*-----------------------------------------------------------------------
4862 Save the new signature values
4863 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304864 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
4865 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004866
4867 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4868 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
4869 ucSTAId, ucUcastSig, ucBcastSig));
4870
4871 /*-------------------------------------------------------------------------
4872 Check to see if we have any cached data to forward
4873 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304874 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 {
4876 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4877 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
4878
4879 WLANTL_RxCachedFrames( pTLCb,
4880 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304881 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 }
4883 else
4884 {
4885 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4886 "WLAN TL: NO cached packets for station %d", ucSTAId ));
4887 }
4888
4889done:
4890 /*-------------------------------------------------------------------------
4891 Clear the station cache
4892 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304893 pClientSTA->vosBegCachedFrame = NULL;
4894 pClientSTA->vosEndCachedFrame = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004895
4896 /*-----------------------------------------------------------------------
4897 After all the init is complete we can mark the existance flag
4898 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304899 pClientSTA->ucRxBlocked = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004900
4901 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4902 return VOS_STATUS_SUCCESS;
4903
4904}/*WLANTL_ForwardSTAFrames*/
4905
4906
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004907#if defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004908/*==========================================================================
4909
4910 FUNCTION WLANTL_IsIAPPFrame
4911
4912 DESCRIPTION
4913 Internal utility function for detecting incoming CCX IAPP frames
4914
4915 DEPENDENCIES
4916
4917 PARAMETERS
4918
4919 IN
4920
4921 pvBDHeader: pointer to the BD header
4922 vosTempBuff: the data packet
4923
4924 IN/OUT
4925 pFirstDataPktArrived: static from caller function; used for rssi
4926 computation
4927 RETURN VALUE
4928 The result code associated with performing the operation
4929
4930 VOS_TRUE: It is a IAPP frame
4931 VOS_FALSE: It is NOT IAPP frame
4932
4933 SIDE EFFECTS
4934
4935============================================================================*/
4936v_BOOL_t
4937WLANTL_IsIAPPFrame
4938(
4939 v_PVOID_t pvBDHeader,
4940 vos_pkt_t* vosTempBuff
4941)
4942{
4943 v_U16_t usMPDUDOffset;
4944 v_U8_t ucOffset;
4945 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
4946 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
4947 VOS_STATUS vosStatus;
4948
4949 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4950
4951 /*------------------------------------------------------------------------
4952 Check if OUI field is present.
4953 -------------------------------------------------------------------------*/
4954 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
4955 {
4956 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4957 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
4958 "dropping pkt"));
4959 /* Drop packet */
4960 vos_pkt_return_packet(vosTempBuff);
4961 return VOS_TRUE;
4962 }
4963 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
4964 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
4965
4966 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
4967 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
4968
4969 if (( VOS_STATUS_SUCCESS != vosStatus))
4970 {
4971 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
4972 "Unable to extract Snap Hdr of data packet -"
4973 "dropping pkt"));
4974 return VOS_FALSE;
4975 }
4976
4977 /*------------------------------------------------------------------------
4978 Check if this is IAPP frame by matching Aironet Snap hdr.
4979 -------------------------------------------------------------------------*/
4980 // Compare returns 1 if values are same and 0
4981 // if not the same.
4982 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
4983 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
4984 WLANTL_LLC_SNAP_SIZE ) ))
4985 {
4986 return VOS_FALSE;
4987 }
4988
4989 return VOS_TRUE;
4990
4991}
4992#endif //FEATURE_WLAN_CCX
4993
4994/*==========================================================================
4995
4996 FUNCTION WLANTL_ProcessBAPFrame
4997
4998 DESCRIPTION
4999 Internal utility function for processing incoming BT-AMP frames
5000
5001 DEPENDENCIES
5002 TL must be initiailized before this function gets called.
5003 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5004 registered with TL.
5005
5006 PARAMETERS
5007
5008 IN
5009
5010 pvBDHeader: pointer to the BD header
5011 vosTempBuff: the data packet
5012 pTLCb: TL control block
5013 ucSTAId: station id
5014
5015 IN/OUT
5016 pFirstDataPktArrived: static from caller function; used for rssi
5017 computation
5018 RETURN VALUE
5019 The result code associated with performing the operation
5020
5021 VOS_STATUS_E_INVAL: Input parameters are invalid
5022 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5023 page fault
5024 VOS_STATUS_SUCCESS: Everything is good :)
5025
5026 SIDE EFFECTS
5027
5028============================================================================*/
5029v_BOOL_t
5030WLANTL_ProcessBAPFrame
5031(
5032 v_PVOID_t pvBDHeader,
5033 vos_pkt_t* vosTempBuff,
5034 WLANTL_CbType* pTLCb,
5035 v_U8_t* pFirstDataPktArrived,
5036 v_U8_t ucSTAId
5037)
5038{
5039 v_U16_t usMPDUDOffset;
5040 v_U8_t ucOffset;
5041 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5042 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5043 VOS_STATUS vosStatus;
5044 v_U16_t usType;
5045 v_SIZE_t usTypeLen = sizeof(usType);
5046 v_U8_t ucMPDUHOffset;
5047 v_U8_t ucMPDUHLen = 0;
5048 v_U16_t usActualHLen = 0;
5049
5050 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5051
5052 /*------------------------------------------------------------------------
5053 Extract OUI and type from LLC and validate; if non-data send to BAP
5054 -------------------------------------------------------------------------*/
5055 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5056 {
5057 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5058 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5059 "dropping pkt"));
5060 /* Drop packet */
5061 vos_pkt_return_packet(vosTempBuff);
5062 return VOS_TRUE;
5063 }
5064
5065 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5066 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5067 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5068 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5069
5070 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5071 (v_PVOID_t)ucOUI, &usOUISize);
5072
5073#if 0
5074 // Compare returns 1 if values are same and 0
5075 // if not the same.
5076 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5077 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5078 WLANTL_LLC_OUI_SIZE ) ))
5079 {
5080 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5081 "LLC header points to diff OUI in BT-AMP station -"
5082 "dropping pkt"));
5083 /* Drop packet */
5084 vos_pkt_return_packet(vosTempBuff);
5085 return VOS_TRUE;
5086 }
5087#endif
5088 /*------------------------------------------------------------------------
5089 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5090 ------------------------------------------------------------------------*/
5091 vosStatus = vos_pkt_extract_data( vosTempBuff,
5092 ucOffset + WLANTL_LLC_OUI_SIZE,
5093 (v_PVOID_t)&usType, &usTypeLen);
5094
5095 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5096 ( sizeof(usType) != usTypeLen ))
5097 {
5098 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5099 "Unable to extract type on incoming BAP packet -"
5100 "dropping pkt"));
5101 /* Drop packet */
5102 vos_pkt_return_packet(vosTempBuff);
5103 return VOS_TRUE;
5104 }
5105
5106 /*------------------------------------------------------------------------
5107 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5108 ------------------------------------------------------------------------*/
5109 usType = vos_be16_to_cpu(usType);
5110
5111 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5112 {
5113 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5114 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5115 usType));
5116
5117 /*Flatten packet as BAP expects to be able to peek*/
5118 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5119 {
5120 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5121 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5122 /* Drop packet */
5123 vos_pkt_return_packet(vosTempBuff);
5124 return VOS_TRUE;
5125 }
5126
5127 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5129 {
5130 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5131 "WLAN TL:BD header corrupted - dropping packet"));
5132 /* Drop packet */
5133 vos_pkt_return_packet(vosTempBuff);
5134 return VOS_TRUE;
5135 }
5136
5137 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5138 {
5139 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5140 "Non-data packet received over BT-AMP link: Sending it for "
5141 "frame Translation"));
5142
5143 if (usMPDUDOffset > ucMPDUHOffset)
5144 {
5145 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5146 }
5147
5148 /* software frame translation for BTAMP WDS.*/
5149 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005150 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005151
5152 }
5153 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5154 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5155 vosTempBuff,
5156 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005157 else
5158 {
5159 VOS_ASSERT(0);
5160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005161
5162 return VOS_TRUE;
5163 }
5164 else
5165 {
5166 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5167 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5168 usType));
5169 /*!!!FIX ME!!*/
5170 #if 0
5171 /*--------------------------------------------------------------------
5172 For data packet collect phy stats RSSI and Link Quality
5173 Calculate the RSSI average and save it. Continuous average is done.
5174 --------------------------------------------------------------------*/
5175 if ( *pFirstDataPktArrived == 0)
5176 {
5177 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5178 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5179 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5180 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5181
5182 // Rcvd 1st pkt, start average from next time
5183 *pFirstDataPktArrived = 1;
5184 }
5185 else
5186 {
5187 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5188 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5189 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5190 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5191 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5192 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5193 }/*Else, first data packet*/
5194 #endif
5195 }/*BT-AMP data packet*/
5196
5197 return VOS_FALSE;
5198}/*WLANTL_ProcessBAPFrame*/
5199
Jeff Johnson295189b2012-06-20 16:38:30 -07005200
5201/*==========================================================================
5202
5203 FUNCTION WLANTL_ProcessFCFrame
5204
5205 DESCRIPTION
5206 Internal utility function for processing incoming Flow Control frames. Enable
5207 or disable LWM mode based on the information.
5208
5209 DEPENDENCIES
5210 TL must be initiailized before this function gets called.
5211 FW sends up special flow control frame.
5212
5213 PARAMETERS
5214
5215 IN
5216 pvosGCtx pointer to vos global context
5217 pvBDHeader: pointer to the BD header
5218 pTLCb: TL control block
5219 pvBDHeader pointer to BD header.
5220
5221 IN/OUT
5222 pFirstDataPktArrived: static from caller function; used for rssi
5223 computation
5224 RETURN VALUE
5225 The result code associated with performing the operation
5226
5227 VOS_STATUS_E_INVAL: Input frame are invalid
5228 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5229 page fault
5230 VOS_STATUS_SUCCESS: Everything is good :)
5231
5232 SIDE EFFECTS
5233 The ingress and egress of each station will be updated. If needed, LWM mode will
5234 be enabled or disabled based on the flow control algorithm.
5235
5236============================================================================*/
5237v_BOOL_t
5238WLANTL_ProcessFCFrame
5239(
5240 v_PVOID_t pvosGCtx,
5241 vos_pkt_t* pvosDataBuff,
5242 v_PVOID_t pvBDHeader
5243)
5244{
5245#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5246 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005247 v_U8_t ucSTAId;
5248 v_U16_t ucStaValidBitmap;
5249 v_U16_t ucStaTxDisabledBitmap;
5250 WLANTL_CbType* pTLCb = NULL;
5251 #ifdef TL_DEBUG_FC
5252 v_U32_t rxTimeStamp;
5253 v_U32_t curTick;
5254 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005256 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 ------------------------------------------------------------------------*/
5258 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5259 if ( NULL == pTLCb )
5260 {
5261 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5262 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5263 return VOS_STATUS_E_FAULT;
5264 }
Hoonki Lee14621352013-04-16 17:51:19 -07005265 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5266 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5267#ifdef TL_DEBUG_FC
5268 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5269 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5270 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005271
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005273 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005274 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5275#endif
5276 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 {
Hoonki Lee14621352013-04-16 17:51:19 -07005278 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5279 continue;
5280
5281 if (ucStaTxDisabledBitmap & 0x1)
5282 {
5283 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5284 }
5285 else
5286 {
5287 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 }
5290
5291#else
5292 VOS_STATUS vosStatus;
5293 tpHalFcRxBd pvFcRxBd = NULL;
5294 v_U8_t ucBitCheck = 0x1;
5295 v_U8_t ucStaValid = 0;
5296 v_U8_t ucSTAId = 0;
5297
5298 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5299 "Received FC Response");
5300 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5301 {
5302 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005303 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 return VOS_STATUS_E_FAULT;
5305 }
5306 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5307 sizeof(tHalFcRxBd));
5308
5309 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5310 {
5311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5312 "WLAN TL:wrong FC Rx packet"));
5313 return VOS_STATUS_E_INVAL;
5314 }
5315
5316 // need to swap bytes in the FC contents.
5317 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5318
5319 //logic to enable/disable LWM mode for each station
5320 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5321 {
5322 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5323 {
5324 continue;
5325 }
5326
5327 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5328 {
5329 //LWM event is reported by FW. Able to fetch more packet
5330 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5331 {
5332 //Now memory usage is below LWM. Station can send more packets.
5333 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5334 }
5335 else
5336 {
5337 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005338 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 }
5340 }
5341
5342 //calculate uEgress_length/uIngress_length only after receiving enough packets
5343 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5344 {
5345 //check memory usage info to see whether LWM mode should be enabled for the station
5346 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5347 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5348
5349 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5350 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5351 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5352 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5353 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5354 )
5355 {
5356 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005357 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5359 }
5360 else
5361 {
5362 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5363 {
5364 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005365 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5367 }
5368
5369 }
5370
5371 //remember memory usage in FW starting from this round
5372 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5373 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5374 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5375
5376 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5377 {
5378 //always update current maximum allowed memeory usage
5379 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5380 pvFcRxBd->fcSTATxQLen[ucSTAId];
5381 }
5382
5383 }
5384#endif
5385
5386 return VOS_STATUS_SUCCESS;
5387}
Jeff Johnson295189b2012-06-20 16:38:30 -07005388
5389
5390/*==========================================================================
5391
5392 FUNCTION WLANTL_RxFrames
5393
5394 DESCRIPTION
5395 Callback registered by TL and called by BAL when a packet is received
5396 over the bus. Upon the call of this function TL will make the necessary
5397 decision with regards to the forwarding or queuing of this packet and
5398 the layer it needs to be delivered to.
5399
5400 DEPENDENCIES
5401 TL must be initiailized before this function gets called.
5402 If the frame carried is a data frame then the station for which it is
5403 destined to must have been previously registered with TL.
5404
5405 PARAMETERS
5406
5407 IN
5408 pvosGCtx: pointer to the global vos context; a handle to TL's
5409 or BAL's control block can be extracted from its context
5410
5411 vosDataBuff: it will contain a pointer to the first buffer received,
5412 if there is more then one packet they will be chained
5413 using vOSS buffers.
5414
5415 RETURN VALUE
5416 The result code associated with performing the operation
5417
5418 VOS_STATUS_E_INVAL: Input parameters are invalid
5419 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5420 page fault
5421 VOS_STATUS_SUCCESS: Everything is good :)
5422
5423 SIDE EFFECTS
5424
5425============================================================================*/
5426VOS_STATUS
5427WLANTL_RxFrames
5428(
5429 v_PVOID_t pvosGCtx,
5430 vos_pkt_t *pFrameDataBuff
5431)
5432{
5433 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5434 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305435 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 WLANTL_STAFuncType pfnSTAFsm;
5437 vos_pkt_t* vosTempBuff;
5438 v_U8_t ucSTAId;
5439 VOS_STATUS vosStatus;
5440 v_U8_t ucFrmType;
5441 v_PVOID_t pvBDHeader = NULL;
5442 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5443 v_U8_t ucTid = 0;
5444 v_BOOL_t broadcast = VOS_FALSE;
5445 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005446 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005449#ifdef FEATURE_WLAN_TDLS_INTERNAL
5450 v_U8_t ucMPDUHLen = 0 ;
5451 v_U16_t usEtherType = 0;
5452#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005453 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
5454
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5456
5457 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5458 "WLAN TL:TL Receive Frames called"));
5459
5460 /*------------------------------------------------------------------------
5461 Sanity check
5462 ------------------------------------------------------------------------*/
5463 if ( NULL == vosDataBuff )
5464 {
5465 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5466 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5467 return VOS_STATUS_E_INVAL;
5468 }
5469
Katya Nigam3802f202013-12-16 19:27:14 +05305470 /*------------------------------------------------------------------------
5471 Popolaute timestamp as the time when packet arrives
5472 ---------------------------------------------------------------------- */
5473 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5474
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 /*------------------------------------------------------------------------
5476 Extract TL control block
5477 ------------------------------------------------------------------------*/
5478 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5479 if ( NULL == pTLCb )
5480 {
5481 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5482 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5483 return VOS_STATUS_E_FAULT;
5484 }
5485
5486 /*---------------------------------------------------------------------
5487 Save the initial buffer - this is the first received buffer
5488 ---------------------------------------------------------------------*/
5489 vosTempBuff = vosDataBuff;
5490
5491 while ( NULL != vosTempBuff )
5492 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005493 broadcast = VOS_FALSE;
5494 selfBcastLoopback = VOS_FALSE;
5495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5497
5498 /*---------------------------------------------------------------------
5499 Peek at BD header - do not remove
5500 !!! Optimize me: only part of header is needed; not entire one
5501 ---------------------------------------------------------------------*/
5502 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5503
5504 if ( NULL == pvBDHeader )
5505 {
5506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5507 "WLAN TL:Cannot extract BD header"));
5508 /* Drop packet */
5509 vos_pkt_return_packet(vosTempBuff);
5510 vosTempBuff = vosDataBuff;
5511 continue;
5512 }
5513
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 /*---------------------------------------------------------------------
5515 Check if FC frame reported from FW
5516 ---------------------------------------------------------------------*/
5517 if(WDA_IS_RX_FC(pvBDHeader))
5518 {
5519 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5520 "WLAN TL:receive one FC frame"));
5521
5522 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5523 /* Drop packet */
5524 vos_pkt_return_packet(vosTempBuff);
5525 vosTempBuff = vosDataBuff;
5526 continue;
5527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005528
5529 /* AMSDU HW bug fix
5530 * After 2nd AMSDU subframe HW could not handle BD correctly
5531 * HAL workaround is needed */
5532 if(WDA_GET_RX_ASF(pvBDHeader))
5533 {
5534 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5535 }
5536
5537 /*---------------------------------------------------------------------
5538 Extract frame control field from 802.11 header if present
5539 (frame translation not done)
5540 ---------------------------------------------------------------------*/
5541
5542 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5543 pvBDHeader, &ucFrmType );
5544 if ( VOS_STATUS_SUCCESS != vosStatus )
5545 {
5546 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5547 "WLAN TL:Cannot extract Frame Control Field"));
5548 /* Drop packet */
5549 vos_pkt_return_packet(vosTempBuff);
5550 vosTempBuff = vosDataBuff;
5551 continue;
5552 }
5553
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005554#ifdef FEATURE_WLAN_TDLS_INTERNAL
5555 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5556 {
5557 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5558 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5559 }
5560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005562
5563 /*---------------------------------------------------------------------
5564 Check if management and send to PE
5565 ---------------------------------------------------------------------*/
5566
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005567 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5568#ifdef FEATURE_WLAN_TDLS_INTERNAL
5569 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5570#endif
5571 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 {
5573 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5574 "WLAN TL:Sending packet to management client"));
5575 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5576 {
5577 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5578 "WLAN TL:Cannot flatten packet - dropping"));
5579 /* Drop packet */
5580 vos_pkt_return_packet(vosTempBuff);
5581 vosTempBuff = vosDataBuff;
5582 continue;
5583 }
5584 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5585 /* Read RSSI and update */
5586 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5587 {
5588#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5589 /* Read RSSI and update */
5590 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5591 WLANTL_MGMT_FRAME_TYPE,
5592 pvBDHeader,
5593 ucSTAId,
5594 VOS_FALSE,
5595 NULL);
5596#else
5597 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5598#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305599 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5600 {
5601 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5602 "Handle RX Management Frame fail within Handoff "
5603 "support module"));
5604 /* Do Not Drop packet at here
5605 * Revisit why HO module return fail
5606 * vos_pkt_return_packet(vosTempBuff);
5607 * vosTempBuff = vosDataBuff;
5608 * continue;
5609 */
5610 }
5611 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5612
5613 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5614 {
5615 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5616 FL("Failed to Read SNR")));
5617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 }
5619
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5621 }
5622 else /* Data Frame */
5623 {
5624 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5625 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5626
5627 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5628 "WLAN TL:Data packet received for STA %d", ucSTAId));
5629
5630 /*------------------------------------------------------------------
5631 This should be corrected when multipe sta support is added !!!
5632 for now bcast frames will be sent to the last registered STA
5633 ------------------------------------------------------------------*/
5634 if ( WDA_IS_RX_BCAST(pvBDHeader))
5635 {
5636 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5637 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5638 broadcast = VOS_TRUE;
5639
5640 /*-------------------------------------------------------------------
5641 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5642 pkt we sent looping back to us. To be dropped if we are non BTAMP
5643 -------------------------------------------------------------------*/
5644 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5645 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5646 {
5647 selfBcastLoopback = VOS_TRUE;
5648 }
5649 }/*if bcast*/
5650
5651 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5652 {
5653 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5654 "WLAN TL:STA ID invalid - dropping pkt"));
5655 /* Drop packet */
5656 vos_pkt_return_packet(vosTempBuff);
5657 vosTempBuff = vosDataBuff;
5658 continue;
5659 }
5660
5661 /*----------------------------------------------------------------------
5662 No need to lock cache access because cache manipulation only happens
5663 in the transport thread/task context
5664 - These frames are to be forwarded to the station upon registration
5665 which happens in the main thread context
5666 The caching here can happen in either Tx or Rx thread depending
5667 on the current SSC scheduling
5668 - also we need to make sure that the frames in the cache are fwd-ed to
5669 the station before the new incoming ones
5670 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305671 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5672 if (NULL == pClientSTA)
5673 {
5674 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5675 "WLAN TL:STA not allocated memory. Dropping packet"));
5676 vos_pkt_return_packet(vosTempBuff);
5677 vosTempBuff = vosDataBuff;
5678 continue;
5679 }
5680
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005681#ifdef FEATURE_WLAN_TDLS
5682 if (( pClientSTA->ucExists ) &&
5683 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5684 (pClientSTA->ucTxSuspended))
5685 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5686 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5687 {
5688 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5689
5690 /* from the direct peer while it is not registered to TL yet */
5691 if ( (pMacHeader->fc.fromDS == 0) &&
5692 (pMacHeader->fc.toDS == 0) )
5693 {
5694 v_U8_t ucAddr3STAId;
5695
5696 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5697
5698 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5699 {
5700 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5701 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5702 /* Drop packet */
5703 vos_pkt_return_packet(vosTempBuff);
5704 vosTempBuff = vosDataBuff;
5705 continue;
5706 }
5707
5708 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5709 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5710 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5711 {
5712 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005713 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005714 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5715 vos_pkt_return_packet(vosTempBuff);
5716 vosTempBuff = vosDataBuff;
5717 continue;
5718 }
5719 else
5720 {
5721 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005722 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005723 ucSTAId, ucAddr3STAId));
5724 ucSTAId = ucAddr3STAId;
5725 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5726 }
5727 }
5728 }
5729#endif
5730
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305731 if ((( 0 == pClientSTA->ucExists ) ||
5732 ( (0 != pClientSTA->ucRxBlocked)
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 ///@@@: xg: no checking in SOFTAP for now, will revisit later
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305734 && (WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 ) ||
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305736 ( WLANTL_STA_DISCONNECTED == pClientSTA->tlState)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5738 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5739 * So it will lead to low resource condition in Rx Data Path.*/
5740 ((WDA_IS_RX_BCAST(pvBDHeader) == 0)))
5741 {
5742 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5743 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005744 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005745 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005746 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5748 vosTempBuff = vosDataBuff;
5749 continue;
5750 }
5751
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005752#ifdef FEATURE_WLAN_CCX_UPLOAD
5753 if ((pClientSTA->wSTADesc.ucIsCcxSta)|| broadcast)
5754 {
5755 /*--------------------------------------------------------------------
5756 Filter the IAPP frames for CCX connection;
5757 if data it will return false and it
5758 will be routed through the regular data path
5759 --------------------------------------------------------------------*/
5760 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5761 vosTempBuff))
5762 {
5763 bForwardIAPPwithLLC = VOS_TRUE;
5764 }
5765 }
5766#endif
5767
5768#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305769 if ((pClientSTA->wSTADesc.ucIsCcxSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 {
5771 /*--------------------------------------------------------------------
5772 Filter the IAPP frames for CCX connection;
5773 if data it will return false and it
5774 will be routed through the regular data path
5775 --------------------------------------------------------------------*/
5776 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5777 vosTempBuff))
5778 {
5779 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5780 {
5781 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5782 "WLAN TL:Cannot flatten packet - dropping"));
5783 /* Drop packet */
5784 vos_pkt_return_packet(vosTempBuff);
5785 } else {
5786
5787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5788 "WLAN TL: Received CCX IAPP Frame"));
5789
5790 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5791 }
5792 vosTempBuff = vosDataBuff;
5793 continue;
5794 }
5795 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005796#endif /* defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305798 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 {
5800 /*--------------------------------------------------------------------
5801 Process the ctrl BAP frame; if data it will return false and it
5802 will be routed through the regular data path
5803 --------------------------------------------------------------------*/
5804 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5805 vosTempBuff,
5806 pTLCb,
5807 &first_data_pkt_arrived,
5808 ucSTAId))
5809 {
5810 vosTempBuff = vosDataBuff;
5811 continue;
5812 }
5813 }/*if BT-AMP station*/
5814 else if(selfBcastLoopback == VOS_TRUE)
5815 {
5816 /* Drop packet */
5817 vos_pkt_return_packet(vosTempBuff);
5818 vosTempBuff = vosDataBuff;
5819 continue;
5820 }
5821
5822 /*---------------------------------------------------------------------
5823 Data packet received, send to state machine
5824 ---------------------------------------------------------------------*/
5825 wSTAEvent = WLANTL_RX_EVENT;
5826
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305827 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 pfnSTATbl[wSTAEvent];
5829
5830 if ( NULL != pfnSTAFsm )
5831 {
5832#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5833 /* Read RSSI and update */
5834 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5835 WLANTL_DATA_FRAME_TYPE,
5836 pvBDHeader,
5837 ucSTAId,
5838 broadcast,
5839 vosTempBuff);
5840 broadcast = VOS_FALSE;
5841#else
5842 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5843#endif /*FEATURE_WLAN_GEN6_ROAMING*/
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305844 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 {
5846 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5847 "Handle RX Data Frame fail within Handoff support module"));
5848 /* Do Not Drop packet at here
5849 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305850 * vos_pkt_return_packet(vosTempBuff);
5851 * vosTempBuff = vosDataBuff;
5852 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 */
5854 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305855 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5856
5857 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5858 {
5859 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5860 FL("Failed to Read SNR")));
5861 }
5862
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005863 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 }
5865 else
5866 {
5867 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5868 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305869 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 /* Drop packet */
5871 vos_pkt_return_packet(vosTempBuff);
5872 vosTempBuff = vosDataBuff;
5873 continue;
5874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 }/* else data frame*/
5876
5877 vosTempBuff = vosDataBuff;
5878 }/*while chain*/
5879
5880 return VOS_STATUS_SUCCESS;
5881}/* WLANTL_RxFrames */
5882
5883
5884/*==========================================================================
5885
5886 FUNCTION WLANTL_RxCachedFrames
5887
5888 DESCRIPTION
5889 Utility function used by TL to forward the cached frames to a particular
5890 station;
5891
5892 DEPENDENCIES
5893 TL must be initiailized before this function gets called.
5894 If the frame carried is a data frame then the station for which it is
5895 destined to must have been previously registered with TL.
5896
5897 PARAMETERS
5898
5899 IN
5900 pTLCb: pointer to TL handle
5901
5902 ucSTAId: station for which we need to forward the packets
5903
5904 vosDataBuff: it will contain a pointer to the first cached buffer
5905 received, if there is more then one packet they will be
5906 chained using vOSS buffers.
5907
5908 RETURN VALUE
5909 The result code associated with performing the operation
5910
5911 VOS_STATUS_E_INVAL: Input parameters are invalid
5912 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5913 page fault
5914 VOS_STATUS_SUCCESS: Everything is good :)
5915
5916 SIDE EFFECTS
5917
5918============================================================================*/
5919VOS_STATUS
5920WLANTL_RxCachedFrames
5921(
5922 WLANTL_CbType* pTLCb,
5923 v_U8_t ucSTAId,
5924 vos_pkt_t* vosDataBuff
5925)
5926{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305927 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 WLANTL_STAFuncType pfnSTAFsm;
5929 vos_pkt_t* vosTempBuff;
5930 VOS_STATUS vosStatus;
5931 v_PVOID_t pvBDHeader = NULL;
5932 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5933 v_U8_t ucTid = 0;
5934 v_BOOL_t broadcast = VOS_FALSE;
5935 v_BOOL_t bSigMatch = VOS_FALSE;
5936 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005937 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 v_U32_t uDPUSig;
5939 v_U8_t ucUcastSig;
5940 v_U8_t ucBcastSig;
5941 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5942
5943 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5944 "WLAN TL:TL Receive Cached Frames called"));
5945
5946 /*------------------------------------------------------------------------
5947 Sanity check
5948 ------------------------------------------------------------------------*/
5949 if ( NULL == vosDataBuff )
5950 {
5951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5952 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5953 return VOS_STATUS_E_INVAL;
5954 }
5955
5956 /*---------------------------------------------------------------------
5957 Save the initial buffer - this is the first received buffer
5958 ---------------------------------------------------------------------*/
5959 vosTempBuff = vosDataBuff;
5960
5961 while ( NULL != vosTempBuff )
5962 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005963 broadcast = VOS_FALSE;
5964 selfBcastLoopback = VOS_FALSE;
5965
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5967
5968 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5969 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
5970 /*---------------------------------------------------------------------
5971 Peek at BD header - do not remove
5972 !!! Optimize me: only part of header is needed; not entire one
5973 ---------------------------------------------------------------------*/
5974 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
5975
5976 if ( NULL == pvBDHeader )
5977 {
5978 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5979 "WLAN TL:Cannot extract BD header"));
5980 /* Drop packet */
5981 vos_pkt_return_packet(vosTempBuff);
5982 vosTempBuff = vosDataBuff;
5983 continue;
5984 }
5985
5986 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5987
5988 /* AMSDU HW bug fix
5989 * After 2nd AMSDU subframe HW could not handle BD correctly
5990 * HAL workaround is needed */
5991 if(WDA_GET_RX_ASF(pvBDHeader))
5992 {
5993 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5994 pvBDHeader);
5995 }
5996
5997 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5998
5999 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6000 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6001
6002 /*------------------------------------------------------------------
6003 This should be corrected when multipe sta support is added !!!
6004 for now bcast frames will be sent to the last registered STA
6005 ------------------------------------------------------------------*/
6006 if ( WDA_IS_RX_BCAST(pvBDHeader))
6007 {
6008 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6009 "WLAN TL:TL rx Bcast frame "));
6010 broadcast = VOS_TRUE;
6011
6012 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6013 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6014 */
6015 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6016 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6017 {
6018 selfBcastLoopback = VOS_TRUE;
6019 }
6020 }/*if bcast*/
6021
6022 /*-------------------------------------------------------------------------
6023 Check if the packet that we cached matches the DPU signature of the
6024 newly added station
6025 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306026 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6027
6028
6029 if ( NULL == pClientSTA )
6030 {
6031 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6032 "WLAN TL:Client Memory was not allocated on %s", __func__));
6033 return VOS_STATUS_E_FAILURE;
6034 }
6035
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 if ( broadcast )
6037 {
6038 ucBcastSig = (v_U8_t)uDPUSig;
6039 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306040 pClientSTA->wSTADesc.ucBcastSig ) &&
6041 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 }
6043 else
6044 {
6045 ucUcastSig = (v_U8_t)uDPUSig;
6046 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306047 pClientSTA->wSTADesc.ucUcastSig ) &&
6048 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 }
6050
6051 /*-------------------------------------------------------------------------
6052 If the packet doesn't match - drop it
6053 -------------------------------------------------------------------------*/
6054 if ( !bSigMatch )
6055 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006056 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6058 " DPU Sig %d UC %d BC %d B %d",
6059 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306060 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006061 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 broadcast));
6063
6064 /* Drop packet */
6065 vos_pkt_return_packet(vosTempBuff);
6066 vosTempBuff = vosDataBuff;
6067 continue;
6068
6069 }/*if signature mismatch*/
6070
6071 /*------------------------------------------------------------------------
6072 Check if BT-AMP frame:
6073 - additional processing needed in this case to separate BT-AMP date
6074 from BT-AMP Ctrl path
6075 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306076 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 {
6078 /*--------------------------------------------------------------------
6079 Process the ctrl BAP frame; if data it will return false and it
6080 will be routed through the regular data path
6081 --------------------------------------------------------------------*/
6082 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6083 vosTempBuff,
6084 pTLCb,
6085 &first_data_pkt_arrived,
6086 ucSTAId))
6087 {
6088 vosTempBuff = vosDataBuff;
6089 continue;
6090 }
6091 }/*if BT-AMP station*/
6092 else if(selfBcastLoopback == VOS_TRUE)
6093 {
6094 /* Drop packet */
6095 vos_pkt_return_packet(vosTempBuff);
6096 vosTempBuff = vosDataBuff;
6097 continue;
6098 }
6099
6100 /*---------------------------------------------------------------------
6101 Data packet received, send to state machine
6102 ---------------------------------------------------------------------*/
6103 wSTAEvent = WLANTL_RX_EVENT;
6104
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306105 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 pfnSTATbl[wSTAEvent];
6107
6108 if ( NULL != pfnSTAFsm )
6109 {
6110#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6111 /* Read RSSI and update */
6112 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6113 VOS_MODULE_ID_TL,pTLCb),
6114 WLANTL_DATA_FRAME_TYPE,
6115 pvBDHeader,
6116 ucSTAId,
6117 broadcast,
6118 vosTempBuff);
6119 broadcast = VOS_FALSE;
6120#else
6121 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
6122#endif /*FEATURE_WLAN_GEN6_ROAMING*/
6123 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6124 {
6125 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6126 "Handle RX Data Frame fail within Handoff support module"));
6127 /* Do Not Drop packet at here
6128 * Revisit why HO module return fail
6129 vos_pkt_return_packet(vosTempBuff);
6130 vosTempBuff = vosDataBuff;
6131 continue;
6132 */
6133 }
6134 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006135 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 }
6137 else
6138 {
6139 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6140 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306141 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 /* Drop packet */
6143 vos_pkt_return_packet(vosTempBuff);
6144 vosTempBuff = vosDataBuff;
6145 continue;
6146 }
6147
6148 vosTempBuff = vosDataBuff;
6149 }/*while chain*/
6150
6151 return VOS_STATUS_SUCCESS;
6152}/* WLANTL_RxCachedFrames */
6153
6154/*==========================================================================
6155 FUNCTION WLANTL_ResourceCB
6156
6157 DESCRIPTION
6158 Called by the TL when it has packets available for transmission.
6159
6160 DEPENDENCIES
6161 The TL must be registered with BAL before this function can be called.
6162
6163 PARAMETERS
6164
6165 IN
6166 pvosGCtx: pointer to the global vos context; a handle to TL's
6167 or BAL's control block can be extracted from its context
6168
6169 RETURN VALUE
6170 The result code associated with performing the operation
6171
6172 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6173 page fault
6174 VOS_STATUS_SUCCESS: Everything is good :)
6175
6176 SIDE EFFECTS
6177
6178============================================================================*/
6179VOS_STATUS
6180WLANTL_ResourceCB
6181(
6182 v_PVOID_t pvosGCtx,
6183 v_U32_t uCount
6184)
6185{
6186 WLANTL_CbType* pTLCb = NULL;
6187 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6188
6189 /*------------------------------------------------------------------------
6190 Sanity check
6191 Extract TL control block
6192 ------------------------------------------------------------------------*/
6193 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6194 if ( NULL == pTLCb )
6195 {
6196 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6197 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6198 return VOS_STATUS_E_FAULT;
6199 }
6200
6201 pTLCb->uResCount = uCount;
6202
6203
6204 /*-----------------------------------------------------------------------
6205 Resume Tx if enough res and not suspended
6206 -----------------------------------------------------------------------*/
6207 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6208 ( 0 == pTLCb->ucTxSuspended ))
6209 {
6210 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6211 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6212 return WDA_DS_StartXmit(pvosGCtx);
6213 }
6214
6215 return VOS_STATUS_SUCCESS;
6216}/* WLANTL_ResourceCB */
6217
6218
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006219/*==========================================================================
6220 FUNCTION WLANTL_IsTxXmitPending
6221
6222 DESCRIPTION
6223 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6224 is pending in TL msg queue
6225
6226 DEPENDENCIES
6227 The TL must be registered with WDA before this function can be called.
6228
6229 PARAMETERS
6230
6231 IN
6232 pvosGCtx: pointer to the global vos context; a handle to TL's
6233 or WDA's control block can be extracted from its context
6234
6235 RETURN VALUE
6236 The result code associated with performing the operation
6237
6238 0: No WDA_DS_TX_START_XMIT msg pending
6239 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6240
6241 SIDE EFFECTS
6242
6243============================================================================*/
6244v_BOOL_t
6245WLANTL_IsTxXmitPending
6246(
6247 v_PVOID_t pvosGCtx
6248)
6249{
6250
6251 WLANTL_CbType* pTLCb = NULL;
6252 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6253
6254 /*------------------------------------------------------------------------
6255 Sanity check
6256 Extract TL control block
6257 ------------------------------------------------------------------------*/
6258 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6259 if ( NULL == pTLCb )
6260 {
6261 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6262 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6263 return FALSE;
6264 }
6265
6266 return pTLCb->isTxTranmitMsgPending;
6267
6268}/*WLANTL_IsTxXmitPending */
6269
6270/*==========================================================================
6271 FUNCTION WLANTL_SetTxXmitPending
6272
6273 DESCRIPTION
6274 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6275 is pending in TL msg queue
6276
6277 DEPENDENCIES
6278 The TL must be registered with WDA before this function can be called.
6279
6280 PARAMETERS
6281
6282 IN
6283 pvosGCtx: pointer to the global vos context; a handle to TL's
6284 or WDA's control block can be extracted from its context
6285
6286 RETURN VALUE None
6287
6288 SIDE EFFECTS
6289
6290============================================================================*/
6291
6292v_VOID_t
6293WLANTL_SetTxXmitPending
6294(
6295 v_PVOID_t pvosGCtx
6296)
6297{
6298
6299 WLANTL_CbType* pTLCb = NULL;
6300 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6301
6302 /*------------------------------------------------------------------------
6303 Sanity check
6304 Extract TL control block
6305 ------------------------------------------------------------------------*/
6306 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6307 if ( NULL == pTLCb )
6308 {
6309 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6310 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6311 return;
6312 }
6313
6314 pTLCb->isTxTranmitMsgPending = 1;
6315 return;
6316
6317}/*WLANTL_SetTxXmitPending */
6318
6319/*==========================================================================
6320 FUNCTION WLANTL_ClearTxXmitPending
6321
6322 DESCRIPTION
6323 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6324 is pending in TL msg queue
6325
6326 DEPENDENCIES
6327 The TL must be registered with WDA before this function can be called.
6328
6329 PARAMETERS
6330
6331 IN
6332 pvosGCtx: pointer to the global vos context; a handle to TL's
6333 or WDA's control block can be extracted from its context
6334
6335 RETURN VALUE None
6336
6337 SIDE EFFECTS
6338
6339============================================================================*/
6340
6341v_VOID_t
6342WLANTL_ClearTxXmitPending
6343(
6344 v_PVOID_t pvosGCtx
6345)
6346{
6347
6348 WLANTL_CbType* pTLCb = NULL;
6349 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6350
6351 /*------------------------------------------------------------------------
6352 Sanity check
6353 Extract TL control block
6354 ------------------------------------------------------------------------*/
6355 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6356 if ( NULL == pTLCb )
6357 {
6358 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6359 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6360 return;
6361 }
6362
6363 pTLCb->isTxTranmitMsgPending = 0;
6364 return;
6365}/*WLANTL_ClearTxXmitPending */
6366
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306367/*==========================================================================
6368 FUNCTION WLANTL_TxThreadDebugHandler
6369
6370 DESCRIPTION
6371 Printing TL Snapshot dump, processed under TxThread context, currently
6372 information regarding the global TlCb struture. Dumps information related
6373 to per active STA connection currently in use by TL.
6374
6375 DEPENDENCIES
6376 The TL must be initialized before this gets called.
6377
6378 PARAMETERS
6379
6380 IN
6381 pvosGCtx: pointer to the global vos context; a handle to TL's
6382 or WDA's control block can be extracted from its context
6383
6384 RETURN VALUE None
6385
6386 SIDE EFFECTS
6387
6388============================================================================*/
6389
6390v_VOID_t
6391WLANTL_TxThreadDebugHandler
6392(
6393 v_PVOID_t *pVosContext
6394)
6395{
6396 WLANTL_CbType* pTLCb = NULL;
6397 WLANTL_STAClientType* pClientSTA = NULL;
6398 int i = 0;
6399 tWDA_CbContext *pWDA = NULL;
6400
6401 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6402 "WLAN TL: %s Enter ", __func__));
6403
6404 pTLCb = VOS_GET_TL_CB(pVosContext);
6405 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6406
6407 if ( NULL == pVosContext || NULL == pTLCb )
6408 {
6409 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6410 "Global VoS Context or TL Context are NULL"));
6411 return;
6412 }
6413
6414 if (NULL != pWDA)
6415 {
6416 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6417 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6418 }
6419 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6420 "************************TL DUMP INFORMATION**************"));
6421
6422 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6423 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6424 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6425 pTLCb->tlConfigInfo.uMinFramesProcThres));
6426
6427 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6428 "Management Frame Client exists: %d",
6429 pTLCb->tlMgmtFrmClient.ucExists));
6430 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6431 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6432 pTLCb->usPendingTxCompleteCount,
6433 pTLCb->ucTxSuspended));
6434
6435 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6436 "uResCount: %d", pTLCb->uResCount));
6437
6438 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6439 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6440 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6441
6442 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6443 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6444 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6445
6446 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6447 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6448 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6449
6450#ifdef FEATURE_WLAN_TDLS
6451 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6452 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6453#endif
6454
6455 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6456 "++++++++++++++++++++Registerd Client Information++++++++++"));
6457
6458 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6459 {
6460 pClientSTA = pTLCb->atlSTAClients[i];
6461 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6462 {
6463 continue;
6464 }
6465
6466 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6467 "######################STA Index: %d ############################",i));
6468 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6469 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6470 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6471 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6472 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6473 "STA Type: %d\tProtectedFrame: %d",
6474 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6475 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6476 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6477 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6478 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6479 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6480 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6481 pClientSTA->wSTADesc.ucBcastSig));
6482
6483 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6484 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6485 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6486 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6487 pClientSTA->tlPri));
6488 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6489 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6490 pClientSTA->ucPktPending));
6491 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6492 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6493 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6494 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6495 "ucRxBlocked: %d\t fcStaTxDisabled: %d", pClientSTA->ucRxBlocked,
6496 pClientSTA->fcStaTxDisabled));
6497 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6498 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6499 pClientSTA->ucServicedAC));
6500 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6501 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6502 pClientSTA->auRxCount[0]));
6503 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6504 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6505 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6506 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6507 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6508 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6509
6510 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6511 {
6512 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6513 "TrafficStatistics for SOFTAP Station:"));
6514 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6515 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6516 pClientSTA->trafficStatistics.rxMCFcnt,
6517 pClientSTA->trafficStatistics.rxBCFcnt));
6518 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6519 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6520 pClientSTA->trafficStatistics.rxMCBcnt,
6521 pClientSTA->trafficStatistics.rxBCBcnt));
6522 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6523 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6524 pClientSTA->trafficStatistics.txMCFcnt,
6525 pClientSTA->trafficStatistics.txBCFcnt));
6526 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6527 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6528 pClientSTA->trafficStatistics.txMCBcnt,
6529 pClientSTA->trafficStatistics.txBCBcnt));
6530 }
6531 }
6532 return;
6533}
6534
6535/*==========================================================================
6536 FUNCTION WLANTL_TLDebugMessage
6537
6538 DESCRIPTION
6539 Post a TL Snapshot request, posts message in TxThread.
6540
6541 DEPENDENCIES
6542 The TL must be initialized before this gets called.
6543
6544 PARAMETERS
6545
6546 IN
6547 displaySnapshot Boolean showing whether to dump the snapshot or not.
6548
6549 RETURN VALUE None
6550
6551 SIDE EFFECTS
6552
6553============================================================================*/
6554
6555v_VOID_t
6556WLANTL_TLDebugMessage
6557(
6558 v_BOOL_t displaySnapshot
6559)
6560{
6561 vos_msg_t vosMsg;
6562 VOS_STATUS status;
6563
6564 if(displaySnapshot)
6565 {
6566 vosMsg.reserved = 0;
6567 vosMsg.bodyptr = NULL;
6568 vosMsg.type = WLANTL_TX_SNAPSHOT;
6569
6570 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6571 if(status != VOS_STATUS_SUCCESS)
6572 {
6573 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
6574 return;
6575 }
6576 }
6577 return;
6578}
Jeff Johnson295189b2012-06-20 16:38:30 -07006579
6580/*============================================================================
6581 TL STATE MACHINE
6582============================================================================*/
6583
6584/*==========================================================================
6585 FUNCTION WLANTL_STATxConn
6586
6587 DESCRIPTION
6588 Transmit in connected state - only EAPOL and WAI packets allowed
6589
6590 DEPENDENCIES
6591 The STA must be registered with TL before this function can be called.
6592
6593 PARAMETERS
6594
6595 IN
6596 pvosGCtx: pointer to the global vos context; a handle to TL's
6597 control block can be extracted from its context
6598 ucSTAId: identifier of the station being processed
6599 vosDataBuff: pointer to the tx vos buffer
6600
6601 RETURN VALUE
6602 The result code associated with performing the operation
6603
6604 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6605 page fault
6606 VOS_STATUS_SUCCESS: Everything is good :)
6607
6608 Other return values are possible coming from the called functions.
6609 Please check API for additional info.
6610
6611 SIDE EFFECTS
6612
6613============================================================================*/
6614VOS_STATUS
6615WLANTL_STATxConn
6616(
6617 v_PVOID_t pvosGCtx,
6618 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006619 vos_pkt_t** pvosDataBuff,
6620 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07006621)
6622{
6623 v_U16_t usPktLen;
6624 VOS_STATUS vosStatus;
6625 v_MACADDR_t vDestMacAddr;
6626 vos_pkt_t* vosDataBuff = NULL;
6627 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306628 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 WLANTL_MetaInfoType tlMetaInfo;
6630 v_U8_t ucTypeSubtype = 0;
6631 v_U8_t ucTid;
6632 v_U8_t extraHeadSpace = 0;
6633 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006634 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306635 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6637
6638 /*------------------------------------------------------------------------
6639 Sanity check
6640 Extract TL control block
6641 ------------------------------------------------------------------------*/
6642 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6643 if ( NULL == pTLCb )
6644 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006645 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6646 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 *pvosDataBuff = NULL;
6648 return VOS_STATUS_E_FAULT;
6649 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306650 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6651
6652 if ( NULL == pClientSTA )
6653 {
6654 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6655 "WLAN TL:Client Memory was not allocated on %s", __func__));
6656 return VOS_STATUS_E_FAILURE;
6657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006658
6659 /*-------------------------------------------------------------------
6660 Disable AC temporary - if successfull retrieve re-enable
6661 The order is justified because of the possible scenario
6662 - TL tryes to fetch packet for AC and it returns NULL
6663 - TL analyzes the data it has received to see if there are
6664 any more pkts available for AC -> if not TL will disable AC
6665 - however it is possible that while analyzing results TL got
6666 preempted by a pending indication where the mask was again set
6667 TL will not check again and as a result when it resumes
6668 execution it will disable AC
6669 To prevent this the AC will be disabled here and if retrieve
6670 is successfull it will be re-enabled
6671 -------------------------------------------------------------------*/
6672
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006673
6674 //LTI:pTLCb->atlSTAClients[ucSTAId].
6675 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
6676
6677 /*------------------------------------------------------------------------
6678 Fetch packet from HDD
6679 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006680#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306681 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006682 (!vos_concurrent_sessions_running()) &&
6683 !pTLCb->ucTdlsPeerCount)
6684 {
6685#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306686 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006687 (!vos_concurrent_sessions_running()))
6688 {
Sunil Ravid5406f22013-01-22 00:18:31 -08006689#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306690 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006691
6692 /*-------------------------------------------------------------------
6693 Disable AC temporary - if successfull retrieve re-enable
6694 The order is justified because of the possible scenario
6695 - TL tryes to fetch packet for AC and it returns NULL
6696 - TL analyzes the data it has received to see if there are
6697 any more pkts available for AC -> if not TL will disable AC
6698 - however it is possible that while analyzing results TL got
6699 preempted by a pending indication where the mask was again set
6700 TL will not check again and as a result when it resumes
6701 execution it will disable AC
6702 To prevent this the AC will be disabled here and if retrieve
6703 is successfull it will be re-enabled
6704 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306705 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006706 }
6707 else
6708 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306709 //softap case
6710 ucAC = pTLCb->uCurServedAC;
6711 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006713
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306714 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306716 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306718 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6719 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
6720 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
6721 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306722 /*You make an initial assumption that HDD has no more data and if the
6723 assumption was wrong you reset the flags to their original state
6724 This will prevent from exposing a race condition between checking with HDD
6725 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006726 if ( 0 == ucACMask )
6727 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306728 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006729 }
6730 else
6731 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306732 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006733 }
6734
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006735
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006736 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006737 "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 +05306738 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07006739
6740 /*------------------------------------------------------------------------
6741 Fetch tx packet from HDD
6742 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006743//LTI
6744#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 if (WLAN_STA_SOFTAP != pTLCb->atlSTAClients[ucSTAId].wSTADesc.wSTAType &&
6746 (!vos_concurrent_sessions_running()))
6747 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 // don't set 0.
6749 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
6750 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6751 &ucSTAId,
6752 pTLCb->atlSTAClients[ucSTAId].ucCurrentAC,
6753 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 }
6755 else
6756 {
6757 //softap case
6758 WLANTL_ACEnumType ucAC = pTLCb->uCurServedAC;
6759 vosStatus = pTLCb->atlSTAClients[ucSTAId].pfnSTAFetchPkt( pvosGCtx,
6760 &ucSTAId,
6761 ucAC,
6762 &vosDataBuff, &tlMetaInfo );
6763 }
6764#endif
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006765
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306766 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006767 &ucSTAId,
6768 ucAC,
6769 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07006770
6771 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
6772 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006773 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 "WLAN TL:No more data at HDD status %d", vosStatus));
6775 *pvosDataBuff = NULL;
6776
6777 /*--------------------------------------------------------------------
6778 Reset AC for the serviced station to the highest priority AC
6779 -> due to no more data at the station
6780 Even if this AC is not supported by the station, correction will be
6781 made in the main TL loop
6782 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306783 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
6784 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006785
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08006786 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006787 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
6788 ucAC, ucACMask);
6789
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 return vosStatus;
6791 }
6792
6793 /*There are still packets in HDD - set back the pending packets and
6794 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306795 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
6796 pClientSTA->ucNoMoreData = 0;
6797 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006798
Jeff Johnson295189b2012-06-20 16:38:30 -07006799#ifdef WLAN_PERF
6800 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
6801 (v_PVOID_t)0);
6802
6803#endif /*WLAN_PERF*/
6804
6805
6806#ifdef FEATURE_WLAN_WAPI
6807 /*------------------------------------------------------------------------
6808 If the packet is neither an Eapol packet nor a WAI packet then drop it
6809 ------------------------------------------------------------------------*/
6810 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
6811 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07006812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
6814
6815 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306816 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 VOS_STATUS_E_BADMSG);
6818 vosDataBuff = NULL;
6819 *pvosDataBuff = NULL;
6820 return VOS_STATUS_SUCCESS;
6821 }
6822#else
6823 if ( 0 == tlMetaInfo.ucIsEapol )
6824 {
6825 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6826 "WLAN TL:Received non EAPOL packet before authentication"));
6827
6828 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306829 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 VOS_STATUS_E_BADMSG);
6831 vosDataBuff = NULL;
6832 *pvosDataBuff = NULL;
6833 return VOS_STATUS_SUCCESS;
6834 }
6835#endif /* FEATURE_WLAN_WAPI */
6836
6837 /*-------------------------------------------------------------------------
6838 Check TID
6839 -------------------------------------------------------------------------*/
6840 ucTid = tlMetaInfo.ucTID;
6841
6842 /*Make sure TID is valid*/
6843 if ( WLANTL_TID_INVALID(ucTid))
6844 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07006845 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
6847 ucTid));
6848 ucTid = 0;
6849 }
6850
6851 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6852 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
6853
6854#ifdef FEATURE_WLAN_WAPI
6855 /*------------------------------------------------------------------------
6856 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
6857 frame is a WAI frame.
6858 ------------------------------------------------------------------------*/
6859 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
6860 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
6861#else
6862 /*------------------------------------------------------------------------
6863 Translate 802.3 frame to 802.11 if Frame translation is enabled
6864 ------------------------------------------------------------------------*/
6865 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306866 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006867#endif //#ifdef FEATURE_WLAN_WAPI
6868 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08006869 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
6870 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07006871 &tlMetaInfo, &ucWDSEnabled,
6872 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 if ( VOS_STATUS_SUCCESS != vosStatus )
6874 {
6875 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6876 "WLAN TL:Error when translating header WLANTL_STATxConn"));
6877
6878 return vosStatus;
6879 }
6880
6881 tlMetaInfo.ucDisableFrmXtl = 1;
6882 }
6883
6884 /*-------------------------------------------------------------------------
6885 Call HAL to fill BD header
6886 -------------------------------------------------------------------------*/
6887 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
6888
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306889 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 {
6891 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
6892 }
6893
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306894#ifdef FEATURE_WLAN_WAPI
6895 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
6896 * case of WPA where GTK handshake is done after the 4 way handshake, the
6897 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
6898 * the TL is in authenticated state. Since the PTK has been installed
6899 * already (after the 4 way handshake) we make sure that all traffic
6900 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
6901 * we will only allow EAPOL data or WAI in case of WAPI)
6902 */
6903 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
6904 {
6905 txFlag = 0;
6906 }
6907#else
6908 if (pClientSTA->ptkInstalled)
6909 {
6910 txFlag = 0;
6911 }
6912#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006913
6914 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
6915 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306916 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306918 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05306919 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07006920 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07006921
6922 if ( VOS_STATUS_SUCCESS != vosStatus )
6923 {
6924 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6925 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
6926 *pvosDataBuff = NULL;
6927 return vosStatus;
6928 }
6929
6930 /*-----------------------------------------------------------------------
6931 Update tx counter for BA session query for tx side
6932 !1 - should this be done for EAPOL frames?
6933 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306934 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07006935
6936 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306937 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07006938
6939 /*------------------------------------------------------------------------
6940 Save data to input pointer for TL core
6941 ------------------------------------------------------------------------*/
6942 *pvosDataBuff = vosDataBuff;
6943 /*security frames cannot be delayed*/
6944 pTLCb->bUrgent = TRUE;
6945
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 /* TX Statistics */
6947 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
6948 {
6949 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306950 pClientSTA->trafficStatistics.txUCFcnt++;
6951 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006953
6954 return VOS_STATUS_SUCCESS;
6955}/* WLANTL_STATxConn */
6956
6957
6958/*==========================================================================
6959 FUNCTION WLANTL_STATxAuth
6960
6961 DESCRIPTION
6962 Transmit in authenticated state - all data allowed
6963
6964 DEPENDENCIES
6965 The STA must be registered with TL before this function can be called.
6966
6967 PARAMETERS
6968
6969 IN
6970 pvosGCtx: pointer to the global vos context; a handle to TL's
6971 control block can be extracted from its context
6972 ucSTAId: identifier of the station being processed
6973 vosDataBuff: pointer to the tx vos buffer
6974
6975 RETURN VALUE
6976 The result code associated with performing the operation
6977
6978 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6979 page fault
6980 VOS_STATUS_SUCCESS: Everything is good :)
6981
6982 Other return values are possible coming from the called functions.
6983 Please check API for additional info.
6984
6985 SIDE EFFECTS
6986
6987============================================================================*/
6988VOS_STATUS
6989WLANTL_STATxAuth
6990(
6991 v_PVOID_t pvosGCtx,
6992 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006993 vos_pkt_t** pvosDataBuff,
6994 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07006995)
6996{
6997 v_U16_t usPktLen;
6998 VOS_STATUS vosStatus;
6999 v_MACADDR_t vDestMacAddr;
7000 vos_pkt_t* vosDataBuff = NULL;
7001 WLANTL_CbType* pTLCb = NULL;
7002 WLANTL_MetaInfoType tlMetaInfo;
7003 v_U8_t ucTypeSubtype = 0;
7004 WLANTL_ACEnumType ucAC;
7005 WLANTL_ACEnumType ucNextAC;
7006 v_U8_t ucTid;
7007 v_U8_t ucSwFrmXtl = 0;
7008 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307009 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307011 v_U32_t ucTxFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 v_U8_t ucACMask, i;
7013 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7014
7015 /*------------------------------------------------------------------------
7016 Sanity check
7017 Extract TL control block
7018 ------------------------------------------------------------------------*/
7019 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7020 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7021 {
7022 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007023 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 pTLCb, pvosDataBuff));
7025 if (NULL != pvosDataBuff)
7026 {
7027 *pvosDataBuff = NULL;
7028 }
7029 if(NULL != pTLCb)
7030 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307031 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7032 {
7033 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7034 "WLAN TL:Client Memory was not allocated on %s", __func__));
7035 return VOS_STATUS_E_FAILURE;
7036 }
7037 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 }
7039 return VOS_STATUS_E_FAULT;
7040 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307041 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007042
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307043 if ( NULL == pStaClient )
7044 {
7045 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7046 "WLAN TL:Client Memory was not allocated on %s", __func__));
7047 return VOS_STATUS_E_FAILURE;
7048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007049
7050 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7051 /*------------------------------------------------------------------------
7052 Fetch packet from HDD
7053 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007054#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307055 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007056 (!vos_concurrent_sessions_running()) &&
7057 !pTLCb->ucTdlsPeerCount)
7058 {
7059#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
7061 (!vos_concurrent_sessions_running()))
7062 {
7063#endif
7064 ucAC = pStaClient->ucCurrentAC;
7065
7066 /*-------------------------------------------------------------------
7067 Disable AC temporary - if successfull retrieve re-enable
7068 The order is justified because of the possible scenario
7069 - TL tryes to fetch packet for AC and it returns NULL
7070 - TL analyzes the data it has received to see if there are
7071 any more pkts available for AC -> if not TL will disable AC
7072 - however it is possible that while analyzing results TL got
7073 preempted by a pending indication where the mask was again set
7074 TL will not check again and as a result when it resumes
7075 execution it will disable AC
7076 To prevent this the AC will be disabled here and if retrieve
7077 is successfull it will be re-enabled
7078 -------------------------------------------------------------------*/
7079 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7080
7081 // don't reset it, as other AC queues in HDD may have packets
7082 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 }
7084 else
7085 {
7086 //softap case
7087 ucAC = pTLCb->uCurServedAC;
7088 pStaClient->aucACMask[ucAC] = 0;
7089
7090 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007092
7093 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 /*You make an initial assumption that HDD has no more data and if the
7095 assumption was wrong you reset the flags to their original state
7096 This will prevent from exposing a race condition between checking with HDD
7097 for packets and setting the flags to false*/
7098 if ( 0 == ucACMask )
7099 {
7100 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7101 pStaClient->ucNoMoreData = 1;
7102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007103
7104 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7105 &ucSTAId,
7106 ucAC,
7107 &vosDataBuff, &tlMetaInfo );
7108
7109
7110 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7111 {
7112
7113 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
7114 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
7115 vosStatus);
7116 *pvosDataBuff = NULL;
7117 /*--------------------------------------------------------------------
7118 Reset AC for the serviced station to the highest priority AC
7119 -> due to no more data at the station
7120 Even if this AC is not supported by the station, correction will be
7121 made in the main TL loop
7122 --------------------------------------------------------------------*/
7123 pStaClient->ucCurrentAC = WLANTL_AC_VO;
7124 pStaClient->ucCurrentWeight = 0;
7125
7126 return vosStatus;
7127 }
7128
Jeff Johnsone7245742012-09-05 17:12:55 -07007129 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007130
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 /*There are still packets in HDD - set back the pending packets and
7132 the no more data assumption*/
7133 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7134 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007135
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7137 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 // don't need to set it, as we don't reset it in this function.
7139 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007141
7142#ifdef WLAN_PERF
7143 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7144 (v_PVOID_t)0);
7145#endif /*WLAN_PERF*/
7146
7147 /*-------------------------------------------------------------------------
7148 Check TID
7149 -------------------------------------------------------------------------*/
7150 ucTid = tlMetaInfo.ucTID;
7151
7152 /*Make sure TID is valid*/
7153 if ( WLANTL_TID_INVALID(ucTid))
7154 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007155 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7157 ucTid));
7158 ucTid = 0;
7159 }
7160
7161 /*Save for UAPSD timer consideration*/
7162 pStaClient->ucServicedAC = ucAC;
7163
7164 if ( ucAC == pStaClient->ucCurrentAC )
7165 {
7166 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7167 pStaClient->ucCurrentWeight--;
7168 }
7169 else
7170 {
7171 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307172 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007173
7174 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7175
7176 }
7177
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7179 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 if ( 0 == pStaClient->ucCurrentWeight )
7181 {
7182 WLANTL_ACEnumType tempAC = ucAC;
7183 /*-----------------------------------------------------------------------
7184 Choose next AC - !!! optimize me
7185 -----------------------------------------------------------------------*/
7186 while ( 0 != ucACMask )
7187 {
7188 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7189 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7190 {
7191 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307192 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007193
7194 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7195 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7196 pStaClient->ucCurrentAC ,
7197 pStaClient->ucCurrentWeight));
7198 break;
7199 }
7200 tempAC = ucNextAC;
7201 }
7202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007204
7205 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7206 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7207
7208 /*------------------------------------------------------------------------
7209 Translate 802.3 frame to 802.11
7210 ------------------------------------------------------------------------*/
7211 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7212 {
7213 /* Needs frame translation */
7214 // if the client has not enabled SW-only frame translation
7215 // and if the frame is a unicast frame
7216 // (HW frame translation does not support multiple broadcast domains
7217 // so we use SW frame translation for broadcast/multicast frames)
7218#ifdef FEATURE_WLAN_WAPI
7219 // and if the frame is not a WAPI frame
7220#endif
7221 // then use HW_based frame translation
7222
7223 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7224 ( 0 == tlMetaInfo.ucBcast ) &&
7225 ( 0 == tlMetaInfo.ucMcast )
7226#ifdef FEATURE_WLAN_WAPI
7227 && ( tlMetaInfo.ucIsWai != 1 )
7228#endif
7229 )
7230 {
7231#ifdef WLAN_PERF
7232 v_U32_t uFastFwdOK = 0;
7233
7234 /* HW based translation. See if the frame could be fast forwarded */
7235 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7236 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7237
7238 if( VOS_STATUS_SUCCESS == vosStatus )
7239 {
7240 if(uFastFwdOK)
7241 {
7242 /* Packet could be fast forwarded now */
7243 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7244 (v_PVOID_t)pStaClient->pfnSTATxComp );
7245
7246 *pvosDataBuff = vosDataBuff;
7247
7248 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7249 stats for every pkt? */
7250 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7251 return vosStatus;
7252 }
7253 /* can't be fast forwarded, fall through normal (slow) path. */
7254 }
7255 else
7256 {
7257
7258 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7259 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7260 *pvosDataBuff = NULL;
7261 return vosStatus;
7262 }
7263#endif /*WLAN_PERF*/
7264 }
7265 else
7266 {
7267 /* SW based translation */
7268
7269#ifdef FEATURE_WLAN_WAPI
7270 gUcIsWai = tlMetaInfo.ucIsWai,
7271#endif
7272
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007273 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7274 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007275 &tlMetaInfo, &ucWDSEnabled,
7276 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 if ( VOS_STATUS_SUCCESS != vosStatus )
7278 {
7279 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7280 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7281 return vosStatus;
7282 }
7283
7284 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007285 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 ucSwFrmXtl = 1;
7287 tlMetaInfo.ucDisableFrmXtl = 1;
7288 }
7289 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307290#ifdef FEATURE_WLAN_TDLS
7291 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7292 change. so update the pStaClient accordingly */
7293 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007294
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307295 if ( NULL == pStaClient )
7296 {
7297 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7298 "pStaClient is NULL %s", __func__));
7299 return VOS_STATUS_E_FAILURE;
7300 }
7301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 /*-------------------------------------------------------------------------
7303 Call HAL to fill BD header
7304 -------------------------------------------------------------------------*/
7305 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7306
7307 if ( pStaClient->wSTADesc.ucQosEnabled )
7308 {
7309 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7310 }
7311
7312 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7313 HAL_TRIGGER_ENABLED_AC_MASK:0;
7314
7315#ifdef FEATURE_WLAN_WAPI
7316 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7317 {
7318#ifdef LIBRA_WAPI_SUPPORT
7319 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7320#endif //LIBRA_WAPI_SUPPORT
7321 if ( tlMetaInfo.ucIsWai == 1 )
7322 {
7323 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7324 }
7325 }
7326#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007327#ifdef FEATURE_WLAN_TDLS
7328 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7329 {
7330 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7331 }
7332#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07007333
7334 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7335 vosDataBuff , &vDestMacAddr,
7336 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7337 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7338 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307339 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7341 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7342
7343 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7344 {
7345 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7346 "Fill TX BD Error status %d", vosStatus));
7347
7348 return vosStatus;
7349 }
7350
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 /* TX Statistics */
7352 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7353 {
7354 /* This is TX UC frame */
7355 pStaClient->trafficStatistics.txUCFcnt++;
7356 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007358
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007359#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 /*-----------------------------------------------------------------------
7361 Update tx counter for BA session query for tx side
7362 -----------------------------------------------------------------------*/
7363 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007364#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307365 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007366#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007367
7368 /* This code is to send traffic with lower priority AC when we does not
7369 get admitted to send it. Today HAL does not downgrade AC so this code
7370 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7371 statement is always false.)
7372 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7373 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7374 then there will be no need for any AC downgrade logic in TL/WDI. */
7375#if 0
7376 if (( ucTid != tlMetaInfo.ucTID ) &&
7377 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7378 ( 0 != ucSwFrmXtl ))
7379 {
7380 /*---------------------------------------------------------------------
7381 !! FIX me: Once downgrading is clear put in the proper change
7382 ---------------------------------------------------------------------*/
7383 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7384
7385 //!!!Fix this replace peek with extract
7386 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7387 sizeof(*pucQosCtrl));
7388 *pucQosCtrl = ucTid; //? proper byte order
7389 }
7390#endif
7391
7392 if ( VOS_STATUS_SUCCESS != vosStatus )
7393 {
7394 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7395 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7396 *pvosDataBuff = NULL;
7397 return vosStatus;
7398 }
7399
7400 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7401 (v_PVOID_t)pStaClient->pfnSTATxComp );
7402
7403 *pvosDataBuff = vosDataBuff;
7404
7405 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7406 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7407 {
7408 pTLCb->bUrgent= TRUE;
7409 }
7410
7411 return VOS_STATUS_SUCCESS;
7412}/* WLANTL_STATxAuth */
7413
7414/*==========================================================================
7415 FUNCTION WLANTL_STATxDisc
7416
7417 DESCRIPTION
7418 Transmit in disconnected state - no data allowed
7419
7420 DEPENDENCIES
7421 The STA must be registered with TL before this function can be called.
7422
7423 PARAMETERS
7424
7425 IN
7426 pvosGCtx: pointer to the global vos context; a handle to TL's
7427 control block can be extracted from its context
7428 ucSTAId: identifier of the station being processed
7429 vosDataBuff: pointer to the tx vos buffer
7430
7431 RETURN VALUE
7432 The result code associated with performing the operation
7433
7434 VOS_STATUS_SUCCESS: Everything is good :)
7435
7436 SIDE EFFECTS
7437
7438============================================================================*/
7439VOS_STATUS
7440WLANTL_STATxDisc
7441(
7442 v_PVOID_t pvosGCtx,
7443 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007444 vos_pkt_t** pvosDataBuff,
7445 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007446)
7447{
7448 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307449 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 /*------------------------------------------------------------------------
7453 Sanity check
7454 Extract TL control block
7455 ------------------------------------------------------------------------*/
7456 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7457 if ( NULL == pTLCb )
7458 {
7459 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7460 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7461 *pvosDataBuff = NULL;
7462 return VOS_STATUS_E_FAULT;
7463 }
7464
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307465 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7466
7467 if ( NULL == pClientSTA )
7468 {
7469 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7470 "WLAN TL:Client Memory was not allocated on %s", __func__));
7471 return VOS_STATUS_E_FAILURE;
7472 }
7473
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 /*------------------------------------------------------------------------
7475 Error
7476 ------------------------------------------------------------------------*/
7477 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7478 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7479 " request"));
7480
7481 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307482 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007483
7484 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307485 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007486
7487 return VOS_STATUS_SUCCESS;
7488}/* WLANTL_STATxDisc */
7489
7490/*==========================================================================
7491 FUNCTION WLANTL_STARxConn
7492
7493 DESCRIPTION
7494 Receive in connected state - only EAPOL
7495
7496 DEPENDENCIES
7497 The STA must be registered with TL before this function can be called.
7498
7499 PARAMETERS
7500
7501 IN
7502 pvosGCtx: pointer to the global vos context; a handle to TL's
7503 control block can be extracted from its context
7504 ucSTAId: identifier of the station being processed
7505 vosDataBuff: pointer to the tx/rx vos buffer
7506
7507 RETURN VALUE
7508 The result code associated with performing the operation
7509
7510 VOS_STATUS_E_INVAL: invalid input parameters
7511 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7512 page fault
7513 VOS_STATUS_SUCCESS: Everything is good :)
7514
7515 SIDE EFFECTS
7516
7517============================================================================*/
7518VOS_STATUS
7519WLANTL_STARxConn
7520(
7521 v_PVOID_t pvosGCtx,
7522 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007523 vos_pkt_t** pvosDataBuff,
7524 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007525)
7526{
7527 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307528 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 v_U16_t usEtherType = 0;
7530 v_U16_t usPktLen;
7531 v_U8_t ucMPDUHOffset;
7532 v_U16_t usMPDUDOffset;
7533 v_U16_t usMPDULen;
7534 v_U8_t ucMPDUHLen;
7535 v_U16_t usActualHLen = 0;
7536 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7537 vos_pkt_t* vosDataBuff;
7538 v_PVOID_t aucBDHeader;
7539 v_U8_t ucTid;
7540 WLANTL_RxMetaInfoType wRxMetaInfo;
7541 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7542
7543 /*------------------------------------------------------------------------
7544 Sanity check
7545 ------------------------------------------------------------------------*/
7546 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7547 {
7548 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7549 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
7550 return VOS_STATUS_E_INVAL;
7551 }
7552
7553 /*------------------------------------------------------------------------
7554 Extract TL control block
7555 ------------------------------------------------------------------------*/
7556 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7557 if ( NULL == pTLCb )
7558 {
7559 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7560 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7561 return VOS_STATUS_E_FAULT;
7562 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307563 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7564
7565 if ( NULL == pClientSTA )
7566 {
7567 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7568 "WLAN TL:Client Memory was not allocated on %s", __func__));
7569 return VOS_STATUS_E_FAILURE;
7570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007571
7572 /*------------------------------------------------------------------------
7573 Extract BD header and check if valid
7574 ------------------------------------------------------------------------*/
7575 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
7576
7577 if ( NULL == aucBDHeader )
7578 {
7579 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7580 "WLAN TL:Cannot extract BD header"));
7581 VOS_ASSERT( 0 );
7582 return VOS_STATUS_E_FAULT;
7583 }
7584
7585
7586 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7587 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7588 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7589 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7590 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7591
7592 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7593
7594 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7595 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
7596 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
7597
7598 /*It will cut out the 802.11 header if not used*/
7599 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7600 {
7601 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7602 "WLAN TL:BD header corrupted - dropping packet"));
7603 /* Drop packet */
7604 vos_pkt_return_packet(vosDataBuff);
7605 return VOS_STATUS_SUCCESS;
7606 }
7607
7608 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
7609
7610 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7611 {
7612#ifdef FEATURE_WLAN_WAPI
7613 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
7614 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
7615 /* that we get an EAPOL packet in WAPI mode or vice versa? */
7616 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
7617 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007618 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007619 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 /* Drop packet */
7621 vos_pkt_return_packet(vosDataBuff);
7622 }
7623#else
7624 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
7625 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007626 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7627 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 /* Drop packet */
7629 vos_pkt_return_packet(vosDataBuff);
7630 }
7631#endif /* FEATURE_WLAN_WAPI */
7632 else /* Frame is an EAPOL frame or a WAI frame*/
7633 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007634
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007635 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007636 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
7637
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307639 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 {
7641 if (usMPDUDOffset > ucMPDUHOffset)
7642 {
7643 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7644 }
7645
7646 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007647 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07007648
7649 if ( VOS_STATUS_SUCCESS != vosStatus )
7650 {
7651 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7652 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7653 /* Drop packet */
7654 vos_pkt_return_packet(vosDataBuff);
7655 return vosStatus;
7656 }
7657 }
7658 /*-------------------------------------------------------------------
7659 Increment receive counter
7660 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007661 if ( !WLANTL_TID_INVALID( ucTid) )
7662 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307663 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007664 }
7665 else
7666 {
7667 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7668 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7669 ucTid, ucSTAId, __func__));
7670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007671
7672 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7673 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
7674
7675 /*-------------------------------------------------------------------
7676 !!!Assuming TID = UP mapping
7677 -------------------------------------------------------------------*/
7678 wRxMetaInfo.ucUP = ucTid;
7679
Jeff Johnson295189b2012-06-20 16:38:30 -07007680 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007681 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307682 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 {
7684 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307685 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 &wRxMetaInfo );
7687 }
7688 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307689 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 &wRxMetaInfo );
7691 }/*EAPOL frame or WAI frame*/
7692 }/*vos status success*/
7693
7694 return VOS_STATUS_SUCCESS;
7695}/* WLANTL_STARxConn */
7696
Jeff Johnson295189b2012-06-20 16:38:30 -07007697/*==========================================================================
7698 FUNCTION WLANTL_FwdPktToHDD
7699
7700 DESCRIPTION
7701 Determine the Destation Station ID and route the Frame to Upper Layer
7702
7703 DEPENDENCIES
7704
7705 PARAMETERS
7706
7707 IN
7708 pvosGCtx: pointer to the global vos context; a handle to TL's
7709 control block can be extracted from its context
7710 ucSTAId: identifier of the station being processed
7711 vosDataBuff: pointer to the rx vos buffer
7712
7713 RETURN VALUE
7714 The result code associated with performing the operation
7715
7716 VOS_STATUS_E_INVAL: invalid input parameters
7717 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7718 page fault
7719 VOS_STATUS_SUCCESS: Everything is good :)
7720
7721 SIDE EFFECTS
7722
7723============================================================================*/
7724
7725VOS_STATUS
7726WLANTL_FwdPktToHDD
7727(
7728 v_PVOID_t pvosGCtx,
7729 vos_pkt_t* pvosDataBuff,
7730 v_U8_t ucSTAId
7731)
7732{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307733 v_MACADDR_t DestMacAddress;
7734 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
7735 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307737 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 vos_pkt_t* vosDataBuff ;
7739 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307740 v_U32_t STAMetaInfo;
7741 vos_pkt_t* vosNextDataBuff ;
7742 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 WLANTL_RxMetaInfoType wRxMetaInfo;
7744
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 /*------------------------------------------------------------------------
7746 Sanity check
7747 ------------------------------------------------------------------------*/
7748 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
7749 {
7750 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7751 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
7752 return VOS_STATUS_E_INVAL;
7753 }
7754
7755 /*------------------------------------------------------------------------
7756 Extract TL control block
7757 ------------------------------------------------------------------------*/
7758 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7759 if ( NULL == pTLCb )
7760 {
7761 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7762 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
7763 return VOS_STATUS_E_FAULT;
7764 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307765
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07007766 if(WLANTL_STA_ID_INVALID(ucSTAId))
7767 {
7768 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
7769 ucSTAId));
7770 return VOS_STATUS_E_INVAL;
7771 }
7772
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307773 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7774
7775 if ( NULL == pClientSTA )
7776 {
7777 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7778 "WLAN TL:Client Memory was not allocated on %s", __func__));
7779 return VOS_STATUS_E_FAILURE;
7780 }
7781
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
7783 may have packets destined to multiple destinations we have to process each packet
7784 at a time and determine its Destination. So the Voschain provided by Reorder code
7785 is unchain and forwarded to Upper Layer after Determining the Destination */
7786
7787 vosDataBuff = pvosDataBuff;
7788 while (vosDataBuff != NULL)
7789 {
7790 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
7791 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7792 (v_PVOID_t *)&STAMetaInfo );
7793 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007794 ucDesSTAId = (v_U8_t)((STAMetaInfo) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07007795
7796 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
7797 if ( VOS_STATUS_SUCCESS != vosStatus )
7798 {
7799 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08007800 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 vos_pkt_return_packet(vosDataBuff);
7802 return vosStatus;
7803 }
7804
Arif Hussaina7c8e412013-11-20 11:06:42 -08007805 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
7806 "station mac "MAC_ADDRESS_STR,
7807 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07007808
7809 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
7810 {
7811 // destination is mc/bc station
7812 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
7813 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007814 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 }
7816 else
7817 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307818 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 {
7820 // destination is AP itself
7821 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7822 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007823 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05307825 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 {
7827 // destination station is something else
7828 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007829 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
7831 }
7832
7833
7834 //loopback unicast station comes here
7835 }
7836
7837 wRxMetaInfo.ucUP = (v_U8_t)(STAMetaInfo & WLANTL_AC_MASK);
7838 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
7839
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307840 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307842 if ( VOS_STATUS_SUCCESS != vosStatus )
7843 {
7844 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08007845 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05307846 vos_pkt_return_packet(vosDataBuff);
7847
7848 return vosStatus;
7849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 vosDataBuff = vosNextDataBuff;
7851 }
7852 return VOS_STATUS_SUCCESS;
7853}
Jeff Johnson295189b2012-06-20 16:38:30 -07007854
7855/*==========================================================================
7856 FUNCTION WLANTL_STARxAuth
7857
7858 DESCRIPTION
7859 Receive in authenticated state - all data allowed
7860
7861 DEPENDENCIES
7862 The STA must be registered with TL before this function can be called.
7863
7864 PARAMETERS
7865
7866 IN
7867 pvosGCtx: pointer to the global vos context; a handle to TL's
7868 control block can be extracted from its context
7869 ucSTAId: identifier of the station being processed
7870 vosDataBuff: pointer to the rx vos buffer
7871
7872 RETURN VALUE
7873 The result code associated with performing the operation
7874
7875 VOS_STATUS_E_INVAL: invalid input parameters
7876 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7877 page fault
7878 VOS_STATUS_SUCCESS: Everything is good :)
7879
7880 SIDE EFFECTS
7881
7882============================================================================*/
7883VOS_STATUS
7884WLANTL_STARxAuth
7885(
7886 v_PVOID_t pvosGCtx,
7887 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007888 vos_pkt_t** pvosDataBuff,
7889 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007890)
7891{
7892 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307893 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 v_U8_t ucAsf; /* AMSDU sub frame */
7895 v_U16_t usMPDUDOffset;
7896 v_U8_t ucMPDUHOffset;
7897 v_U16_t usMPDULen;
7898 v_U8_t ucMPDUHLen;
7899 v_U16_t usActualHLen = 0;
7900 v_U8_t ucTid;
7901#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07007902 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007903#endif
7904 v_U16_t usPktLen;
7905 vos_pkt_t* vosDataBuff ;
7906 v_PVOID_t aucBDHeader;
7907 VOS_STATUS vosStatus;
7908 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07007909 static v_U8_t ucPMPDUHLen;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08007910 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
7912 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
7913 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
7914 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007915 struct _BARFrmStruct *pBarFrame = NULL;
7916
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7918
7919 /*------------------------------------------------------------------------
7920 Sanity check
7921 ------------------------------------------------------------------------*/
7922 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7923 {
7924 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7925 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
7926 return VOS_STATUS_E_INVAL;
7927 }
7928
7929 /*------------------------------------------------------------------------
7930 Extract TL control block
7931 ------------------------------------------------------------------------*/
7932 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7933 if ( NULL == pTLCb )
7934 {
7935 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7936 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
7937 return VOS_STATUS_E_FAULT;
7938 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307939 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7940
7941 if ( NULL == pClientSTA )
7942 {
7943 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7944 "WLAN TL:Client Memory was not allocated on %s", __func__));
7945 return VOS_STATUS_E_FAILURE;
7946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007947
7948 /*------------------------------------------------------------------------
7949 Extract BD header and check if valid
7950 ------------------------------------------------------------------------*/
7951 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
7952
7953 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7954 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7955 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7956 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7957 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7958
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07007959 /* Fix for a hardware bug.
7960 * H/W does not update the tid field in BD header for BAR frames.
7961 * Fix is to read the tid field from MAC header of BAR frame */
7962 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
7963 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
7964 {
7965 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
7966 ucTid = pBarFrame->barControl.numTID;
7967 }
7968
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 /*Host based replay check is needed for unicast data frames*/
7970 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 if(0 != ucMPDUHLen)
7972 {
7973 ucPMPDUHLen = ucMPDUHLen;
7974 }
7975
7976 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7977 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
7978 " Tid %d BD %d",
7979 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
7980 WLANHAL_RX_BD_HEADER_SIZE));
7981
7982 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7983
7984 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7985 {
7986 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
7987 {
7988 /* AMSDU case, ucMPDUHOffset = 0
7989 * it should be hancdled seperatly */
7990 if(( usMPDUDOffset > ucMPDUHOffset ) &&
7991 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
7992 ( !WLANTL_TID_INVALID(ucTid) ))
7993 {
7994 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
7995 }
7996 else
7997 {
7998 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7999 "WLAN TL:BD header corrupted - dropping packet"));
8000 /* Drop packet */
8001 vos_pkt_return_packet(vosDataBuff);
8002 return VOS_STATUS_SUCCESS;
8003 }
8004 }
8005 else
8006 {
8007 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8008 "WLAN TL:BD header corrupted - dropping packet"));
8009 /* Drop packet */
8010 vos_pkt_return_packet(vosDataBuff);
8011 return VOS_STATUS_SUCCESS;
8012 }
8013 }
8014
8015#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308016 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 {
8018 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8019 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8020 {
8021 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8022 {
8023 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8024 {
8025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8026 "WLAN TL:WAI frame was received encrypted - dropping"));
8027 /* Drop packet */
8028 /*Temporary fix added to fix wapi rekey issue*/
8029 //vos_pkt_return_packet(vosDataBuff);
8030 //return vosStatus; //returning success
8031 }
8032 }
8033 else
8034 {
8035 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8036 {
8037 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8038 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8039 /* Drop packet */
8040 vos_pkt_return_packet(vosDataBuff);
8041 return vosStatus; //returning success
8042 }
8043 }
8044 }
8045 else //could not extract EtherType - this should not happen
8046 {
8047 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008048 "WLAN TL:Could not extract EtherType"));
8049 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 }
8052 }
8053#endif /* FEATURE_WLAN_WAPI */
8054
8055 /*----------------------------------------------------------------------
8056 Increment receive counter
8057 !! not sure this is the best place to increase this - pkt might be
8058 dropped below or delayed in TL's queues
8059 - will leave it here for now
8060 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008061 if ( !WLANTL_TID_INVALID( ucTid) )
8062 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308063 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008064 }
8065 else
8066 {
8067 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8068 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8069 ucTid, ucSTAId, __func__));
8070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008071
8072 /*------------------------------------------------------------------------
8073 Check if AMSDU and send for processing if so
8074 ------------------------------------------------------------------------*/
8075 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8076
8077 if ( 0 != ucAsf )
8078 {
8079 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8080 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8081 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8082 ucMPDUHLen, usMPDULen );
8083 if(NULL == vosDataBuff)
8084 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008085 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 return VOS_STATUS_SUCCESS;
8087 }
8088 }
8089 /* After AMSDU header handled
8090 * AMSDU frame just same with normal frames */
8091 /*-------------------------------------------------------------------
8092 Translating header if necesary
8093 !! Fix me: rmv comments below
8094 ----------------------------------------------------------------------*/
8095 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308096 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8098 {
8099 if(0 == ucMPDUHLen)
8100 {
8101 ucMPDUHLen = ucPMPDUHLen;
8102 }
8103 if (usMPDUDOffset > ucMPDUHOffset)
8104 {
8105 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8106 }
8107 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008108 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008109
8110 if ( VOS_STATUS_SUCCESS != vosStatus )
8111 {
8112 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8113 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8114 /* Drop packet */
8115 vos_pkt_return_packet(vosDataBuff);
8116 return vosStatus;
8117 }
8118 }
8119 /* Softap requires additional Info such as Destination STAID and Access
8120 Category. Voschain or Buffer returned by BA would be unchain and this
8121 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308122 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308124 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8126 (v_PVOID_t)STAMetaInfoPtr);
8127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008128
8129 /*------------------------------------------------------------------------
8130 Check to see if re-ordering session is in place
8131 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308132 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 {
8134 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8135 }
8136
Jeff Johnson295189b2012-06-20 16:38:30 -07008137if(0 == ucUnicastBroadcastType
8138#ifdef FEATURE_ON_CHIP_REORDERING
8139 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8140#endif
8141)
8142{
8143 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308144 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 {
8146 /* replay check is needed for the station */
8147
8148 /* check whether frame is AMSDU frame */
8149 if ( 0 != ucAsf )
8150 {
8151 /* Since virgo can't send AMSDU frames this leg of the code
8152 was not tested properly, it needs to be tested properly*/
8153 /* Frame is AMSDU frame. As per 802.11n only first
8154 subframe will have replay counter */
8155 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8156 if( 0 != ucEsf )
8157 {
8158 v_BOOL_t status;
8159 /* Getting 48-bit replay counter from the RX BD */
8160 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8161
8162 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008163 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008164
8165 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308166 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008167
8168 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008169 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008170
8171 /* It is first subframe of AMSDU thus it
8172 conatains replay counter perform the
8173 replay check for this first subframe*/
8174 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8175 if(VOS_FALSE == status)
8176 {
8177 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308178 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 }
8180 else
8181 {
8182 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008183 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008184
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308185 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008187 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308188 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008189
8190 /* Drop the packet */
8191 vos_pkt_return_packet(vosDataBuff);
8192 return VOS_STATUS_SUCCESS;
8193 }
8194 }
8195 }
8196 else
8197 {
8198 v_BOOL_t status;
8199
8200 /* Getting 48-bit replay counter from the RX BD */
8201 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8202
8203 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008204 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008205
8206 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308207 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008208
8209 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008210 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008211
8212 /* It is not AMSDU frame so perform
8213 reaply check for each packet, as
8214 each packet contains valid replay counter*/
8215 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8216 if(VOS_FALSE == status)
8217 {
8218 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308219 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 }
8221 else
8222 {
8223 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008224 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008225
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308226 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008228 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308229 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008230
8231 /* Repaly packet, drop the packet */
8232 vos_pkt_return_packet(vosDataBuff);
8233 return VOS_STATUS_SUCCESS;
8234 }
8235 }
8236 }
8237}
8238/*It is a broadast packet DPU has already done replay check for
8239 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008240
8241 if ( NULL != vosDataBuff )
8242 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308243 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 {
8245 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8246 }
8247 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 {
8249 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008250 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308251#ifdef FEATURE_WLAN_TDLS
8252 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8253 {
8254 wRxMetaInfo.isStaTdls = TRUE;
8255 }
8256 else
8257 {
8258 wRxMetaInfo.isStaTdls = FALSE;
8259 }
8260#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308261 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 &wRxMetaInfo );
8263 }
8264 }/* if not NULL */
8265
8266 return VOS_STATUS_SUCCESS;
8267}/* WLANTL_STARxAuth */
8268
8269
8270/*==========================================================================
8271 FUNCTION WLANTL_STARxDisc
8272
8273 DESCRIPTION
8274 Receive in disconnected state - no data allowed
8275
8276 DEPENDENCIES
8277 The STA must be registered with TL before this function can be called.
8278
8279 PARAMETERS
8280
8281 IN
8282 pvosGCtx: pointer to the global vos context; a handle to TL's
8283 control block can be extracted from its context
8284 ucSTAId: identifier of the station being processed
8285 vosDataBuff: pointer to the rx vos buffer
8286
8287 RETURN VALUE
8288 The result code associated with performing the operation
8289
8290 VOS_STATUS_SUCCESS: Everything is good :)
8291
8292 SIDE EFFECTS
8293
8294============================================================================*/
8295VOS_STATUS
8296WLANTL_STARxDisc
8297(
8298 v_PVOID_t pvosGCtx,
8299 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008300 vos_pkt_t** pvosDataBuff,
8301 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008302)
8303{
8304 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8305
8306 /*------------------------------------------------------------------------
8307 Sanity check
8308 ------------------------------------------------------------------------*/
8309 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8310 {
8311 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8312 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8313 return VOS_STATUS_E_INVAL;
8314 }
8315
8316 /*------------------------------------------------------------------------
8317 Error - drop packet
8318 ------------------------------------------------------------------------*/
8319 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8320 "WLAN TL:Packet should not be received in state disconnected"
8321 " - dropping"));
8322 vos_pkt_return_packet(*pvosDataBuff);
8323 *pvosDataBuff = NULL;
8324
8325 return VOS_STATUS_SUCCESS;
8326}/* WLANTL_STARxDisc */
8327
8328/*==========================================================================
8329 Processing main loops for MAIN and TX threads
8330 ==========================================================================*/
8331
8332/*==========================================================================
8333 FUNCTION WLANTL_McProcessMsg
8334
8335 DESCRIPTION
8336 Called by VOSS when a message was serialized for TL through the
8337 main thread/task.
8338
8339 DEPENDENCIES
8340 The TL must be initialized before this function can be called.
8341
8342 PARAMETERS
8343
8344 IN
8345 pvosGCtx: pointer to the global vos context; a handle to TL's
8346 control block can be extracted from its context
8347 message: type and content of the message
8348
8349
8350 RETURN VALUE
8351 The result code associated with performing the operation
8352
8353 VOS_STATUS_E_INVAL: invalid input parameters
8354 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8355 page fault
8356 VOS_STATUS_SUCCESS: Everything is good :)
8357
8358 SIDE EFFECTS
8359
8360============================================================================*/
8361VOS_STATUS
8362WLANTL_McProcessMsg
8363(
8364 v_PVOID_t pvosGCtx,
8365 vos_msg_t* message
8366)
8367{
8368 WLANTL_CbType* pTLCb = NULL;
8369 tAddBAInd* ptAddBaInd = NULL;
8370 tDelBAInd* ptDelBaInd = NULL;
8371 tAddBARsp* ptAddBaRsp = NULL;
8372 vos_msg_t vosMessage;
8373 VOS_STATUS vosStatus;
8374 tpFlushACRsp FlushACRspPtr;
8375 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8376
8377 /*------------------------------------------------------------------------
8378 Sanity check
8379 ------------------------------------------------------------------------*/
8380 if ( NULL == message )
8381 {
8382 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8383 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8384 return VOS_STATUS_E_INVAL;
8385 }
8386
8387 /*------------------------------------------------------------------------
8388 Extract TL control block
8389 ------------------------------------------------------------------------*/
8390 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8391 if ( NULL == pTLCb )
8392 {
8393 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8394 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8395 return VOS_STATUS_E_FAULT;
8396 }
8397
8398 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8399 "WLAN TL:Received message: %d through main flow", message->type));
8400
8401 switch( message->type )
8402 {
8403 case WDA_TL_FLUSH_AC_RSP:
8404 // Extract the message from the message body
8405 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8406 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008407 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8408 {
8409 VOS_ASSERT(0);
8410 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8411 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8412 return VOS_STATUS_E_FAULT;
8413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008414
8415 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8416 "Received message: Flush complete received by TL"));
8417
8418 // Since we have the response back from HAL, just call the BAP client
8419 // registered call back from TL. There is only 1 possible
8420 // BAP client. So directly reference tlBAPClient
8421 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8422 FlushACRspPtr->ucSTAId,
8423 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8424
8425 // Free the PAL memory, we are done with it.
8426 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8427 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8428 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8429 break;
8430
8431 case WDA_HDD_ADDBA_REQ:
8432 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8433 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8434 ptAddBaInd->baSession.baSessionID,
8435 ptAddBaInd->baSession.STAID,
8436 ptAddBaInd->baSession.baTID,
8437 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8438 ptAddBaInd->baSession.winSize,
8439 ptAddBaInd->baSession.SSN);
8440 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8441
8442 if ( NULL == ptAddBaRsp )
8443 {
8444 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8445 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8446 VOS_ASSERT(0);
8447 return VOS_STATUS_E_NOMEM;
8448 }
8449
8450 if ( VOS_STATUS_SUCCESS == vosStatus )
8451 {
8452 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8453 "WLAN TL: Sending success indication to HAL for ADD BA"));
8454 /*Send success*/
8455 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8456 vosMessage.type = WDA_HDD_ADDBA_RSP;
8457 }
8458 else
8459 {
8460 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8461 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8462
8463 /*Send failure*/
8464 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8465 vosMessage.type = WDA_BA_FAIL_IND;
8466 }
8467
8468 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8469 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8470 /* This is default, reply win size has to be handled BA module, FIX THIS */
8471 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8472 vosMessage.bodyptr = ptAddBaRsp;
8473
8474 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8475 WLANTL_McFreeMsg (pvosGCtx, message);
8476 break;
8477 case WDA_DELETEBA_IND:
8478 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8479 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8480 ptDelBaInd->staIdx,
8481 ptDelBaInd->baTID);
8482
8483 if ( VOS_STATUS_SUCCESS != vosStatus )
8484 {
8485 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8486 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8487 ptDelBaInd->staIdx,
8488 ptDelBaInd->baTID,
8489 vosStatus));
8490 }
8491 WLANTL_McFreeMsg (pvosGCtx, message);
8492 break;
8493 default:
8494 /*no processing for now*/
8495 break;
8496 }
8497
8498 return VOS_STATUS_SUCCESS;
8499}/* WLANTL_ProcessMainMessage */
8500
8501/*==========================================================================
8502 FUNCTION WLANTL_McFreeMsg
8503
8504 DESCRIPTION
8505 Called by VOSS to free a given TL message on the Main thread when there
8506 are messages pending in the queue when the whole system is been reset.
8507 For now, TL does not allocate any body so this function shout translate
8508 into a NOOP
8509
8510 DEPENDENCIES
8511 The TL must be initialized before this function can be called.
8512
8513 PARAMETERS
8514
8515 IN
8516 pvosGCtx: pointer to the global vos context; a handle to TL's
8517 control block can be extracted from its context
8518 message: type and content of the message
8519
8520
8521 RETURN VALUE
8522 The result code associated with performing the operation
8523
8524 VOS_STATUS_SUCCESS: Everything is good :)
8525
8526 SIDE EFFECTS
8527
8528============================================================================*/
8529VOS_STATUS
8530WLANTL_McFreeMsg
8531(
8532 v_PVOID_t pvosGCtx,
8533 vos_msg_t* message
8534)
8535{
8536 WLANTL_CbType* pTLCb = NULL;
8537 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8538
8539 /*------------------------------------------------------------------------
8540 Sanity check
8541 ------------------------------------------------------------------------*/
8542 if ( NULL == message )
8543 {
8544 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8545 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
8546 return VOS_STATUS_E_INVAL;
8547 }
8548
8549 /*------------------------------------------------------------------------
8550 Extract TL control block
8551 ------------------------------------------------------------------------*/
8552 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8553 if ( NULL == pTLCb )
8554 {
8555 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8556 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
8557 return VOS_STATUS_E_FAULT;
8558 }
8559
8560 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8561 "WLAN TL:Received message: %d through main free", message->type));
8562
8563 switch( message->type )
8564 {
8565 case WDA_HDD_ADDBA_REQ:
8566 case WDA_DELETEBA_IND:
8567 /*vos free body pointer*/
8568 vos_mem_free(message->bodyptr);
8569 message->bodyptr = NULL;
8570 break;
8571 default:
8572 /*no processing for now*/
8573 break;
8574 }
8575
8576 return VOS_STATUS_SUCCESS;
8577}/*WLANTL_McFreeMsg*/
8578
8579/*==========================================================================
8580 FUNCTION WLANTL_TxProcessMsg
8581
8582 DESCRIPTION
8583 Called by VOSS when a message was serialized for TL through the
8584 tx thread/task.
8585
8586 DEPENDENCIES
8587 The TL must be initialized before this function can be called.
8588
8589 PARAMETERS
8590
8591 IN
8592 pvosGCtx: pointer to the global vos context; a handle to TL's
8593 control block can be extracted from its context
8594 message: type and content of the message
8595
8596
8597 RETURN VALUE
8598 The result code associated with performing the operation
8599
8600 VOS_STATUS_E_INVAL: invalid input parameters
8601 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8602 page fault
8603 VOS_STATUS_SUCCESS: Everything is good :)
8604
8605 Other values can be returned as a result of a function call, please check
8606 corresponding API for more info.
8607 SIDE EFFECTS
8608
8609============================================================================*/
8610VOS_STATUS
8611WLANTL_TxProcessMsg
8612(
8613 v_PVOID_t pvosGCtx,
8614 vos_msg_t* message
8615)
8616{
8617 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8618 v_U32_t uData;
8619 v_U8_t ucSTAId;
8620 v_U8_t ucUcastSig;
8621 v_U8_t ucBcastSig;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308622 WLANTL_CbType* pTLCb = NULL;
8623 WLANTL_STAClientType* pClientSTA = NULL;
8624 WLANTL_ACEnumType ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 void (*callbackRoutine) (void *callbackContext);
8626 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8628
8629 /*------------------------------------------------------------------------
8630 Sanity check
8631 ------------------------------------------------------------------------*/
8632 if ( NULL == message )
8633 {
8634 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8635 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
8636 return VOS_STATUS_E_INVAL;
8637 }
8638
8639 /*------------------------------------------------------------------------
8640 Process message
8641 ------------------------------------------------------------------------*/
8642 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8643 "WLAN TL:Received message: %d through tx flow", message->type));
8644
8645 switch( message->type )
8646 {
8647 case WLANTL_TX_SIG_SUSPEND:
8648 vosStatus = WLANTL_SuspendCB( pvosGCtx,
8649 (WLANTL_SuspendCBType)message->bodyptr,
8650 message->reserved);
8651 break;
8652 case WLANTL_TX_RES_NEEDED:
8653 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
8654 break;
8655
8656 case WLANTL_TX_FWD_CACHED:
8657 /*---------------------------------------------------------------------
8658 The data sent with the message has the following structure:
8659 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
8660 each field above is one byte
8661 ---------------------------------------------------------------------*/
Jeff Johnsond86c05a2013-11-10 18:50:34 -08008662 uData = message->bodyval;
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 ucSTAId = ( uData & 0x000000FF);
8664 ucUcastSig = ( uData & 0x0000FF00)>>8;
8665 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
8666 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
8667 ucUcastSig, ucBcastSig);
8668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 case WLANTL_TX_STAID_AC_IND:
8670 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8671 if ( NULL == pTLCb )
8672 {
8673 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8674 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
8675 return VOS_STATUS_E_FAULT;
8676 }
8677
8678 ucAC = message->bodyval & WLANTL_AC_MASK;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08008679 ucSTAId = (v_U8_t)(message->bodyval >> WLANTL_STAID_OFFSET);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308680 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07008681
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308682 if ( NULL == pClientSTA )
8683 {
8684 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8685 "WLAN TL:Client Memory was not allocated on %s", __func__));
8686 return VOS_STATUS_E_FAILURE;
8687 }
8688
8689 pClientSTA->aucACMask[ucAC] = 1;
8690
8691 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07008692 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8693 break;
Jeff Johnson017fdc32013-02-27 09:22:30 -08008694
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308696 WLANTL_ClearTxXmitPending(pvosGCtx);
8697 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 break;
8699
8700 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05308701 callbackContext = message->bodyptr;
8702 callbackRoutine = message->callback;
8703 if ( NULL != callbackRoutine )
8704 {
8705 callbackRoutine(callbackContext);
8706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008708
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308709 case WLANTL_TX_SNAPSHOT:
8710 /*Dumping TL State and then continuing to print
8711 the DXE Dump*/
8712 WLANTL_TxThreadDebugHandler(pvosGCtx);
8713 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
8714 break;
8715
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 default:
8717 /*no processing for now*/
8718 break;
8719 }
8720
8721 return vosStatus;
8722}/* WLANTL_TxProcessMsg */
8723
8724/*==========================================================================
8725 FUNCTION WLANTL_McFreeMsg
8726
8727 DESCRIPTION
8728 Called by VOSS to free a given TL message on the Main thread when there
8729 are messages pending in the queue when the whole system is been reset.
8730 For now, TL does not allocate any body so this function shout translate
8731 into a NOOP
8732
8733 DEPENDENCIES
8734 The TL must be initialized before this function can be called.
8735
8736 PARAMETERS
8737
8738 IN
8739 pvosGCtx: pointer to the global vos context; a handle to TL's
8740 control block can be extracted from its context
8741 message: type and content of the message
8742
8743
8744 RETURN VALUE
8745 The result code associated with performing the operation
8746
8747 VOS_STATUS_SUCCESS: Everything is good :)
8748
8749 SIDE EFFECTS
8750
8751============================================================================*/
8752VOS_STATUS
8753WLANTL_TxFreeMsg
8754(
8755 v_PVOID_t pvosGCtx,
8756 vos_msg_t* message
8757)
8758{
8759 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8760
8761 /*Nothing to do for now!!!*/
8762 return VOS_STATUS_SUCCESS;
8763}/*WLANTL_TxFreeMsg*/
8764
Jeff Johnson295189b2012-06-20 16:38:30 -07008765/*==========================================================================
8766
8767 FUNCTION WLANTL_TxFCFrame
8768
8769 DESCRIPTION
8770 Internal utility function to send FC frame. Enable
8771 or disable LWM mode based on the information.
8772
8773 DEPENDENCIES
8774 TL must be initiailized before this function gets called.
8775 FW sends up special flow control frame.
8776
8777 PARAMETERS
8778
8779 IN
8780 pvosGCtx: pointer to the global vos context; a handle to TL's
8781 control block can be extracted from its context
8782
8783 RETURN VALUE
8784 The result code associated with performing the operation
8785
8786 VOS_STATUS_E_INVAL: Input pointers are NULL.
8787 VOS_STATUS_E_FAULT: Something is wrong.
8788 VOS_STATUS_SUCCESS: Everything is good.
8789
8790 SIDE EFFECTS
8791 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
8792 be released.
8793
8794============================================================================*/
8795VOS_STATUS
8796WLANTL_TxFCFrame
8797(
8798 v_PVOID_t pvosGCtx
8799)
8800{
8801#if 0
8802 WLANTL_CbType* pTLCb = NULL;
8803 VOS_STATUS vosStatus;
8804 tpHalFcTxBd pvFcTxBd = NULL;
8805 vos_pkt_t * pPacket = NULL;
8806 v_U8_t ucSTAId = 0;
8807 v_U8_t ucBitCheck = 1;
8808
8809 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008810 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008811
8812 /*------------------------------------------------------------------------
8813 Sanity check
8814 ------------------------------------------------------------------------*/
8815 if ( NULL == pvosGCtx )
8816 {
8817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008818 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 return VOS_STATUS_E_INVAL;
8820 }
8821 /*------------------------------------------------------------------------
8822 Extract TL control block
8823 ------------------------------------------------------------------------*/
8824 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8825
8826 if (NULL == pTLCb)
8827 {
8828 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008829 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 return VOS_STATUS_E_INVAL;
8831 }
8832
8833 //Get one voss packet
8834 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
8835 VOS_FALSE, NULL, NULL );
8836
8837 if ( VOS_STATUS_SUCCESS != vosStatus )
8838 {
8839 return VOS_STATUS_E_INVAL;
8840 }
8841
8842 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
8843
8844 if( VOS_STATUS_SUCCESS != vosStatus )
8845 {
8846 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008847 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008848 vos_pkt_return_packet( pPacket );
8849 return VOS_STATUS_E_FAULT;
8850 }
8851
8852 //Generate most recent tlFCInfo. Most fields are correct.
8853 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
8854 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
8855 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
8856 {
8857 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
8858 {
8859 continue;
8860 }
8861
8862 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
8863 {
8864 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
8865 }
8866
8867 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
8868 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
8869 {
8870 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
8871
8872 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
8873
8874 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
8875 }
8876
8877 }
8878
8879 //request immediate feedback
8880 pTLCb->tlFCInfo.fcConfig |= 0x4;
8881
8882 //fill in BD to sent
8883 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
8884
8885 if( VOS_STATUS_SUCCESS != vosStatus )
8886 {
8887 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008888 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 vos_pkt_return_packet( pPacket );
8890 return VOS_STATUS_E_FAULT;
8891 }
8892
8893 if (NULL != pTLCb->vosTxFCBuf)
8894 {
8895 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008896 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
8898 }
8899
8900 pTLCb->vosTxFCBuf = pPacket;
8901
8902 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
8903 (v_PVOID_t)WLANTL_TxCompDefaultCb);
8904 vosStatus = WDA_DS_StartXmit(pvosGCtx);
8905
8906 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008907 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07008908#endif
8909 return VOS_STATUS_SUCCESS;
8910}
8911
Jeff Johnson295189b2012-06-20 16:38:30 -07008912
8913/*==========================================================================
8914 FUNCTION WLANTL_GetTxResourcesCB
8915
8916 DESCRIPTION
8917 Processing function for Resource needed signal. A request will be issued
8918 to BAL to get more tx resources.
8919
8920 DEPENDENCIES
8921 The TL must be initialized before this function can be called.
8922
8923 PARAMETERS
8924
8925 IN
8926 pvosGCtx: pointer to the global vos context; a handle to TL's
8927 control block can be extracted from its context
8928
8929
8930 RETURN VALUE
8931 The result code associated with performing the operation
8932
8933 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8934 page fault
8935 VOS_STATUS_SUCCESS: Everything is good :)
8936
8937 Other values can be returned as a result of a function call, please check
8938 corresponding API for more info.
8939 SIDE EFFECTS
8940
8941============================================================================*/
8942VOS_STATUS
8943WLANTL_GetTxResourcesCB
8944(
8945 v_PVOID_t pvosGCtx
8946)
8947{
8948 WLANTL_CbType* pTLCb = NULL;
8949 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
8950 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8951 v_U8_t ucMgmt = 0;
8952 v_U8_t ucBAP = 0;
8953 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008954#ifdef WLAN_SOFTAP_FLOWCTRL_EN
8955 tBssSystemRole systemRole;
8956 tpAniSirGlobal pMac;
8957#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008958 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8959 /*------------------------------------------------------------------------
8960 Extract TL control block
8961 ------------------------------------------------------------------------*/
8962 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8963 if ( NULL == pTLCb )
8964 {
8965 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8966 "WLAN TL:Invalid TL pointer from pvosGCtx on"
8967 " WLANTL_ProcessTxMessage"));
8968 return VOS_STATUS_E_FAULT;
8969 }
8970
8971 /*------------------------------------------------------------------------
8972 Get tx resources from BAL
8973 ------------------------------------------------------------------------*/
8974 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
8975
8976 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
8977 {
8978 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8979 "WLAN TL:TL failed to get resources from BAL, Err: %d",
8980 vosStatus));
8981 return vosStatus;
8982 }
8983
8984 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
8985 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
8986 changes should be done in BAL code of AMSS and WM */
8987 if (VOS_STATUS_E_RESOURCES == vosStatus)
8988 {
8989#ifdef VOLANS_PERF
8990 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
8991 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8992 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
8993#else
8994 return VOS_STATUS_E_FAILURE;
8995#endif
8996 }
8997
8998 pTLCb->uResCount = uResCount;
8999
9000
Jeff Johnson295189b2012-06-20 16:38:30 -07009001#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9002 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9003 pTLCb->sendFCFrame ++;
9004 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9005 systemRole = wdaGetGlobalSystemRole(pMac);
9006 if (eSYSTEM_AP_ROLE == systemRole)
9007 {
9008 if (pTLCb->sendFCFrame % 16 == 0)
9009 {
9010 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9011 "Transmit FC"));
9012 WLANTL_TxFCFrame (pvosGCtx);
9013 }
9014 }
9015#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009016
9017 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9018 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9019 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9020 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9021 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9022
9023 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9024 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9025 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9026
9027 if (( 0 == pTLCb->ucTxSuspended ) &&
9028 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9029 {
9030 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9031 "Issuing Xmit start request to BAL for avail res SYNC"));
9032 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9033 }
9034 return vosStatus;
9035}/*WLANTL_GetTxResourcesCB*/
9036
9037/*==========================================================================
9038 Utility functions
9039 ==========================================================================*/
9040
9041/*==========================================================================
9042 FUNCTION WLANTL_Translate8023To80211Header
9043
9044 DESCRIPTION
9045 Inline function for translating and 802.11 header into an 802.3 header.
9046
9047 DEPENDENCIES
9048
9049
9050 PARAMETERS
9051
9052 IN
9053 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009054 IN/OUT
9055 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9056 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009057
9058 IN/OUT
9059 vosDataBuff: vos data buffer, will contain the new header on output
9060
9061 OUT
9062 pvosStatus: status of the operation
9063
9064 RETURN VALUE
9065
9066 VOS_STATUS_SUCCESS: Everything is good :)
9067
9068 Other error codes might be returned from the vos api used in the function
9069 please check those return values.
9070
9071 SIDE EFFECTS
9072
9073============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009074VOS_STATUS
9075WLANTL_Translate8023To80211Header
9076(
9077 vos_pkt_t* vosDataBuff,
9078 VOS_STATUS* pvosStatus,
9079 WLANTL_CbType* pTLCb,
9080 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009081 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009082 v_U8_t *ucWDSEnabled,
9083 v_U8_t *extraHeadSpace
9084)
Jeff Johnson295189b2012-06-20 16:38:30 -07009085{
9086 WLANTL_8023HeaderType w8023Header;
9087 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9088 VOS_STATUS vosStatus;
9089 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9090 v_U8_t ucHeaderSize = 0;
9091 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309092 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009094 v_U8_t ucStaId;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009095#ifdef FEATURE_WLAN_CCX_UPLOAD
9096 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9097 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9098 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9099#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 *ucWDSEnabled = 0; // default WDS off.
9101 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9102 sizeof(w8023Header));
9103
9104 if ( VOS_STATUS_SUCCESS != vosStatus )
9105 {
9106 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9107 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9108 return vosStatus;
9109 }
9110
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009111 if( NULL == pucStaId )
9112 {
9113 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9114 "WLAN TL: Invalid pointer for StaId"));
9115 return VOS_STATUS_E_INVAL;
9116 }
9117 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309118 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9119
9120 if ( NULL == pClientSTA )
9121 {
9122 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9123 "WLAN TL:Client Memory was not allocated on %s", __func__));
9124 return VOS_STATUS_E_FAILURE;
9125 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009126
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009127#ifdef FEATURE_WLAN_TDLS
9128
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309129 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9130 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009131 {
9132 v_U8_t ucIndex = 0;
9133 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9134 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309135 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309136 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9137 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309138 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009139 (void*)w8023Header.vDA, 6) )
9140 {
9141 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9142 "WLAN TL: Got a TDLS station. Using that index"));
9143 ucStaId = ucIndex;
9144 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309145 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9146 if ( NULL == pClientSTA )
9147 {
9148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9149 "WLAN TL:Client Memory was not allocated on %s", __func__));
9150 return VOS_STATUS_E_FAILURE;
9151 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009152 break;
9153 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009154 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009155 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009156#endif
9157
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009158#ifdef FEATURE_WLAN_CCX_UPLOAD
9159if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsCcxSta))
9160{
9161 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9162 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9163 {
9164 /*The SNAP and the protocol type are already in the data buffer.
9165 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9166 bIAPPTxwithLLC = VOS_TRUE;
9167 }
9168 else
9169 {
9170 bIAPPTxwithLLC = VOS_FALSE;
9171 }
9172}
9173#endif /* FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009174
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009175 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
9176#ifdef FEATURE_WLAN_CCX_UPLOAD
9177 && (!bIAPPTxwithLLC)
9178#endif /* FEATURE_WLAN_CCX_UPLOAD */
9179 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009180 {
9181 /* Push the length */
9182 vosStatus = vos_pkt_push_head(vosDataBuff,
9183 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9184
9185 if ( VOS_STATUS_SUCCESS != vosStatus )
9186 {
9187 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9188 "WLAN TL: Packet push ether type fails on"
9189 " WLANTL_Translate8023To80211Header"));
9190 return vosStatus;
9191 }
9192
9193#ifdef BTAMP_TEST
9194 // The STA side will execute this, a hack to test BTAMP by using the
9195 // infra setup. On real BTAMP this will come from BAP itself.
9196 {
9197 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9198 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9199 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9200
9201 if ( VOS_STATUS_SUCCESS != vosStatus )
9202 {
9203 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9204 "WLAN TL: Packet push LLC header fails on"
9205 " WLANTL_Translate8023To80211Header"));
9206 return vosStatus;
9207 }
9208 }
9209#else
9210 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9211 sizeof(WLANTL_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#endif
9221 }/*If add LLC is enabled*/
9222 else
9223 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009224#ifdef FEATURE_WLAN_CCX_UPLOAD
9225 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
9226#endif /* FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9228 "WLAN TL: STA Client registered to not remove LLC"
9229 " WLANTL_Translate8023To80211Header"));
9230 }
9231
9232#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309233 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009234#endif
9235
9236 // Find the space required for the 802.11 header format
9237 // based on the frame control fields.
9238 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309239 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 {
9241 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9242 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309243 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 {
9245 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 }
9248
9249 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9250 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9251
9252 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9253 if ( NULL == ppvBDHeader )
9254 {
9255 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9256 "WLAN TL:VOSS packet corrupted "));
9257 *pvosStatus = VOS_STATUS_E_INVAL;
9258 return *pvosStatus;
9259 }
9260
Jeff Johnson295189b2012-06-20 16:38:30 -07009261
9262 // OK now we have the space. Fill the 80211 header
9263 /* Fill A2 */
9264 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9265 // only clear the required space.
9266 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9267 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9268
9269
9270#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309271 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9272 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009273#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309274 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9275 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009276#endif
9277 {
9278 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309279 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 }
9281
9282 pw80211Header->usDurationId = 0;
9283 pw80211Header->usSeqCtrl = 0;
9284
9285 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9286
9287
9288
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309289 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 {
9291 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9292
Ravi Joshid0699502013-07-08 15:48:47 -07009293 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009294
9295 }
9296 else
9297 {
9298 pw80211Header->wFrmCtrl.subType = 0;
9299
9300 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9301 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9302 // pw80211Header->usQosCtrl = 0;
9303 }
9304
9305
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309306 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 {
Ravi Joshid0699502013-07-08 15:48:47 -07009308 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 pw80211Header->wFrmCtrl.toDS = 0;
9310 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009311
9312 /*
9313 * If the frame is a multicast frame, then, the Address1
9314 * should be the destination address filled in the packet. Which is
9315 * the multicast address. Otherwise, set it to BSSID
9316 */
9317 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9318 {
9319 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9320 (v_MACADDR_t*)&w8023Header.vDA);
9321 }
9322 else
9323 {
9324 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9325 &pClientSTA->wSTADesc.vSTAMACAddress);
9326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309328 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 VOS_MAC_ADDR_SIZE);
9330 break;
9331
Ravi Joshid0699502013-07-08 15:48:47 -07009332 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 *ucWDSEnabled = 1; // WDS on.
9334 pw80211Header->wFrmCtrl.toDS = 1;
9335 pw80211Header->wFrmCtrl.fromDS = 1;
9336 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309337 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009339 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309341 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 /* fill the optional A4 header */
9343 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009344 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009346 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009347 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 break;
9349
Ravi Joshid0699502013-07-08 15:48:47 -07009350 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 *ucWDSEnabled = 0; // WDS off.
9352 pw80211Header->wFrmCtrl.toDS = 0;
9353 pw80211Header->wFrmCtrl.fromDS = 1;
9354 /*Copy the DA to A1*/
9355 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9356 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309357 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009358 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009359 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009361 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009362 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009364#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009365 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009366 pw80211Header->wFrmCtrl.toDS = 0;
9367 pw80211Header->wFrmCtrl.fromDS = 0;
9368 /*Fix me*/
9369 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309370 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009371 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309372 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009373 VOS_MAC_ADDR_SIZE);
9374 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009375 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009376 break;
9377#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009378 case WLAN_STA_INFRA:
9379 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 pw80211Header->wFrmCtrl.toDS = 1;
9381 pw80211Header->wFrmCtrl.fromDS = 0;
9382 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309383 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9385 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009386 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009387 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009388 break;
9389 }
9390 // OK now we have the space. Fill the 80211 header
9391 /* Fill A2 */
9392 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9393 return VOS_STATUS_SUCCESS;
9394}/*WLANTL_Translate8023To80211Header*/
9395
9396
9397/*=============================================================================
9398 BEGIN LOG FUNCTION !!! Remove me or clean me
9399=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009400#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009401
9402#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9403#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9404
9405static v_VOID_t WLANTL_DebugFrame
9406(
9407 v_PVOID_t dataPointer,
9408 v_U32_t dataSize
9409)
9410{
9411 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9412 v_U32_t numLines;
9413 v_U32_t numBytes;
9414 v_U32_t idx;
9415 v_U8_t *linePointer;
9416
9417 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9418 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9419 linePointer = (v_U8_t *)dataPointer;
9420
9421 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9422 for(idx = 0; idx < numLines; idx++)
9423 {
9424 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9425 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9426 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9427 "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",
9428 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9429 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9430 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9431 }
9432
9433 if(0 == numBytes)
9434 return;
9435
9436 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9437 memcpy(lineBuffer, linePointer, numBytes);
9438 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9439 {
9440 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9441 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9442 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9443 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9444 break;
9445 }
9446
9447 return;
9448}
9449#endif
9450
9451/*=============================================================================
9452 END LOG FUNCTION
9453=============================================================================*/
9454
9455/*==========================================================================
9456 FUNCTION WLANTL_Translate80211To8023Header
9457
9458 DESCRIPTION
9459 Inline function for translating and 802.11 header into an 802.3 header.
9460
9461 DEPENDENCIES
9462
9463
9464 PARAMETERS
9465
9466 IN
9467 pTLCb: TL control block
9468 ucStaId: station ID
9469 ucHeaderLen: Length of the header from BD
9470 ucActualHLen: Length of header including padding or any other trailers
9471
9472 IN/OUT
9473 vosDataBuff: vos data buffer, will contain the new header on output
9474
9475 OUT
9476 pvosStatus: status of the operation
9477
9478 RETURN VALUE
9479
9480 The result code associated with performing the operation
9481 VOS_STATUS_SUCCESS: Everything is good :)
9482
9483 SIDE EFFECTS
9484
9485============================================================================*/
9486VOS_STATUS
9487WLANTL_Translate80211To8023Header
9488(
9489 vos_pkt_t* vosDataBuff,
9490 VOS_STATUS* pvosStatus,
9491 v_U16_t usActualHLen,
9492 v_U8_t ucHeaderLen,
9493 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009494 v_U8_t ucSTAId,
9495 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009496)
9497{
9498 WLANTL_8023HeaderType w8023Header;
9499 WLANTL_80211HeaderType w80211Header;
9500 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9501 VOS_STATUS vosStatus;
9502 v_U16_t usDataStartOffset = 0;
9503 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9504
9505 if ( sizeof(w80211Header) < ucHeaderLen )
9506 {
9507 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9508 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9509 sizeof(w80211Header), ucHeaderLen));
9510 ucHeaderLen = sizeof(w80211Header);
9511 }
9512
9513 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9514 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9515 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9516
9517 if ( VOS_STATUS_SUCCESS != vosStatus )
9518 {
9519 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9520 "WLAN TL: Failed to pop 80211 header from packet %d",
9521 vosStatus));
9522
9523 return vosStatus;
9524 }
9525
9526 switch ( w80211Header.wFrmCtrl.fromDS )
9527 {
9528 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 if ( w80211Header.wFrmCtrl.toDS )
9530 {
9531 //SoftAP AP mode
9532 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9533 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9534 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009535 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 w8023Header.vDA, w8023Header.vSA));
9537 }
9538 else
9539 {
9540 /* IBSS */
9541 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9542 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 break;
9545 case 1:
9546 if ( w80211Header.wFrmCtrl.toDS )
9547 {
9548 /* BT-AMP case */
9549 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9550 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9551 }
9552 else
9553 { /* Infra */
9554 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9555 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9556 }
9557 break;
9558 }
9559
9560 if( usActualHLen > ucHeaderLen )
9561 {
9562 usDataStartOffset = usActualHLen - ucHeaderLen;
9563 }
9564
9565 if ( 0 < usDataStartOffset )
9566 {
9567 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
9568
9569 if ( VOS_STATUS_SUCCESS != vosStatus )
9570 {
9571 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9572 "WLAN TL: Failed to trim header from packet %d",
9573 vosStatus));
9574 return vosStatus;
9575 }
9576 }
9577
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309578 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9579 {
9580 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9581 "WLAN TL:Client Memory was not allocated on %s", __func__));
9582 return VOS_STATUS_E_FAILURE;
9583 }
9584
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009585 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
9586#ifdef FEATURE_WLAN_CCX_UPLOAD
9587 && (!bForwardIAPPwithLLC)
9588#endif /* FEATURE_WLAN_CCX_UPLOAD */
9589 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 {
9591 // Extract the LLC header
9592 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
9593 WLANTL_LLC_HEADER_LEN);
9594
9595 if ( VOS_STATUS_SUCCESS != vosStatus )
9596 {
9597 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9598 "WLAN TL: Failed to pop LLC header from packet %d",
9599 vosStatus));
9600
9601 return vosStatus;
9602 }
9603
9604 //Extract the length
9605 vos_mem_copy(&w8023Header.usLenType,
9606 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
9607 sizeof(w8023Header.usLenType) );
9608 }
9609 else
9610 {
9611 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
9612 &w8023Header.usLenType);
9613
9614 if ( VOS_STATUS_SUCCESS != vosStatus )
9615 {
9616 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9617 "WLAN TL: Failed to get packet length %d",
9618 vosStatus));
9619
9620 return vosStatus;
9621 }
9622
9623 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9624 "WLAN TL: BTAMP len (ethertype) fld = %d",
9625 w8023Header.usLenType));
9626 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
9627 }
9628
9629 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
9630
9631#ifdef BTAMP_TEST
9632 {
9633 // AP side will execute this.
9634 v_U8_t *temp_w8023Header = NULL;
9635 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
9636 &temp_w8023Header, sizeof(w8023Header) );
9637 }
9638#endif
9639#if 0 /*TL_DEBUG*/
9640 vos_pkt_get_packet_length(vosDataBuff, &usLen);
9641 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
9642
9643 WLANTL_DebugFrame(aucData, usLen);
9644
9645 vos_pkt_push_head(vosDataBuff, aucData, usLen);
9646
9647#endif
9648
9649 *pvosStatus = VOS_STATUS_SUCCESS;
9650
9651 return VOS_STATUS_SUCCESS;
9652}/*WLANTL_Translate80211To8023Header*/
9653
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009654/*==========================================================================
9655 FUNCTION WLANTL_FindFrameTypeBcMcUc
9656
9657 DESCRIPTION
9658 Utility function to find whether received frame is broadcast, multicast
9659 or unicast.
9660
9661 DEPENDENCIES
9662 The STA must be registered with TL before this function can be called.
9663
9664 PARAMETERS
9665
9666 IN
9667 pTLCb: pointer to the TL's control block
9668 ucSTAId: identifier of the station being processed
9669 vosDataBuff: pointer to the vos buffer
9670
9671 IN/OUT
9672 pucBcMcUc: pointer to buffer, will contain frame type on return
9673
9674 RETURN VALUE
9675 The result code associated with performing the operation
9676
9677 VOS_STATUS_E_INVAL: invalid input parameters
9678 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
9679 VOS_STATUS_SUCCESS: success
9680
9681 SIDE EFFECTS
9682 None.
9683============================================================================*/
9684VOS_STATUS
9685WLANTL_FindFrameTypeBcMcUc
9686(
9687 WLANTL_CbType *pTLCb,
9688 v_U8_t ucSTAId,
9689 vos_pkt_t *vosDataBuff,
9690 v_U8_t *pucBcMcUc
9691)
9692{
9693 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9694 v_PVOID_t aucBDHeader;
9695 v_PVOID_t pvPeekData;
9696 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9697
9698 /*------------------------------------------------------------------------
9699 Sanity check
9700 ------------------------------------------------------------------------*/
9701 if ((NULL == pTLCb) ||
9702 (NULL == vosDataBuff) ||
9703 (NULL == pucBcMcUc))
9704 {
9705 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9706 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
9707 return VOS_STATUS_E_INVAL;
9708 }
9709
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309710 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9711 {
9712 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9713 "WLAN TL:Client Memory was not allocated on %s", __func__));
9714 return VOS_STATUS_E_FAILURE;
9715 }
9716
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009717 /*------------------------------------------------------------------------
9718 Extract BD header and check if valid
9719 ------------------------------------------------------------------------*/
9720 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
9721
9722 if (NULL == aucBDHeader)
9723 {
9724 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9725 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
9726 VOS_ASSERT(0);
9727 return VOS_STATUS_E_BADMSG;
9728 }
9729
9730 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309731 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009732 {
9733 /* Its an 802.11 frame, extract MAC address 1 */
9734 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9735 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
9736 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
9737 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9738 }
9739 else
9740 {
9741 /* Its an 802.3 frame, extract Destination MAC address */
9742 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9743 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
9744 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
9745 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9746 }
9747
9748 if (VOS_STATUS_SUCCESS != vosStatus)
9749 {
9750 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9751 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
9752 return vosStatus;
9753 }
9754
9755 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
9756 {
9757 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
9758 }
9759 else
9760 {
9761 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
9762 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
9763 else
9764 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
9765 }
9766
9767 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9768 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
9769 ((tANI_U8 *)pvPeekData)[0]));
9770
9771 return VOS_STATUS_SUCCESS;
9772}
9773
Jeff Johnson295189b2012-06-20 16:38:30 -07009774#if 0
9775#ifdef WLAN_PERF
9776/*==========================================================================
9777 FUNCTION WLANTL_FastHwFwdDataFrame
9778
9779 DESCRIPTION
9780 Fast path function to quickly forward a data frame if HAL determines BD
9781 signature computed here matches the signature inside current VOSS packet.
9782 If there is a match, HAL and TL fills in the swapped packet length into
9783 BD header and DxE header, respectively. Otherwise, packet goes back to
9784 normal (slow) path and a new BD signature would be tagged into BD in this
9785 VOSS packet later by the WLANHAL_FillTxBd() function.
9786
9787 DEPENDENCIES
9788
9789 PARAMETERS
9790
9791 IN
9792 pvosGCtx VOS context
9793 vosDataBuff Ptr to VOSS packet
9794 pMetaInfo For getting frame's TID
9795 pStaInfo For checking STA type
9796
9797 OUT
9798 pvosStatus returned status
9799 puFastFwdOK Flag to indicate whether frame could be fast forwarded
9800
9801 RETURN VALUE
9802 No return.
9803
9804 SIDE EFFECTS
9805
9806============================================================================*/
9807static void
9808WLANTL_FastHwFwdDataFrame
9809(
9810 v_PVOID_t pvosGCtx,
9811 vos_pkt_t* vosDataBuff,
9812 VOS_STATUS* pvosStatus,
9813 v_U32_t* puFastFwdOK,
9814 WLANTL_MetaInfoType* pMetaInfo,
9815 WLAN_STADescType* pStaInfo
9816
9817)
9818{
9819 v_PVOID_t pvPeekData;
9820 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
9821 v_U8_t ucIsUnicast;
9822 WLANBAL_sDXEHeaderType *pDxEHeader;
9823 v_PVOID_t pvBDHeader;
9824 v_PVOID_t pucBuffPtr;
9825 v_U16_t usPktLen;
9826
9827 /*-----------------------------------------------------------------------
9828 Extract packet length
9829 -----------------------------------------------------------------------*/
9830
9831 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
9832
9833 /*-----------------------------------------------------------------------
9834 Extract MAC address
9835 -----------------------------------------------------------------------*/
9836 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
9837 WLANTL_MAC_ADDR_ALIGN(0),
9838 (v_PVOID_t)&pvPeekData,
9839 VOS_MAC_ADDR_SIZE );
9840
9841 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9842 {
9843 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9844 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9845 *pvosStatus));
9846 *pvosStatus = VOS_STATUS_E_INVAL;
9847 return;
9848 }
9849
9850 /*-----------------------------------------------------------------------
9851 Reserve head room for DxE header, BD, and WLAN header
9852 -----------------------------------------------------------------------*/
9853
9854 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
9855 ucDxEBDWLANHeaderLen );
9856 if ( NULL == pucBuffPtr )
9857 {
9858 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9859 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
9860 *pvosStatus = VOS_STATUS_E_INVAL;
9861 return;
9862 }
9863 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
9864 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
9865
9866 /* UMA Tx acceleration is enabled.
9867 * UMA would help convert frames to 802.11, fill partial BD fields and
9868 * construct LLC header. To further accelerate this kind of frames,
9869 * HAL would attempt to reuse the BD descriptor if the BD signature
9870 * matches to the saved BD descriptor.
9871 */
9872 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
9873 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
9874 else
9875 ucIsUnicast = 1;
9876
9877 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
9878
9879 /* Can't be fast forwarded. Trim the VOS head back to original location. */
9880 if(! *puFastFwdOK){
9881 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
9882 }else{
9883 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
9884 */
9885 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
9886 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
9887 (v_PVOID_t)uPacketSize);
9888 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
9889 }
9890 *pvosStatus = VOS_STATUS_SUCCESS;
9891 return;
9892}
9893#endif /*WLAN_PERF*/
9894#endif
9895
9896#if 0
9897/*==========================================================================
9898 FUNCTION WLANTL_PrepareBDHeader
9899
9900 DESCRIPTION
9901 Inline function for preparing BD header before HAL processing.
9902
9903 DEPENDENCIES
9904 Just notify HAL that suspend in TL is complete.
9905
9906 PARAMETERS
9907
9908 IN
9909 vosDataBuff: vos data buffer
9910 ucDisableFrmXtl: is frame xtl disabled
9911
9912 OUT
9913 ppvBDHeader: it will contain the BD header
9914 pvDestMacAdddr: it will contain the destination MAC address
9915 pvosStatus: status of the combined processing
9916 pusPktLen: packet len.
9917
9918 RETURN VALUE
9919 No return.
9920
9921 SIDE EFFECTS
9922
9923============================================================================*/
9924void
9925WLANTL_PrepareBDHeader
9926(
9927 vos_pkt_t* vosDataBuff,
9928 v_PVOID_t* ppvBDHeader,
9929 v_MACADDR_t* pvDestMacAdddr,
9930 v_U8_t ucDisableFrmXtl,
9931 VOS_STATUS* pvosStatus,
9932 v_U16_t* pusPktLen,
9933 v_U8_t ucQosEnabled,
9934 v_U8_t ucWDSEnabled,
9935 v_U8_t extraHeadSpace
9936)
9937{
9938 v_U8_t ucHeaderOffset;
9939 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
9941
9942 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9943 /*-------------------------------------------------------------------------
9944 Get header pointer from VOSS
9945 !!! make sure reserve head zeros out the memory
9946 -------------------------------------------------------------------------*/
9947 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
9948
9949 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
9950 {
9951 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9952 "WLAN TL: Length of the packet smaller than expected network"
9953 " header %d", *pusPktLen ));
9954
9955 *pvosStatus = VOS_STATUS_E_INVAL;
9956 return;
9957 }
9958
9959 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
9960 ucBDHeaderLen );
9961 if ( NULL == *ppvBDHeader )
9962 {
9963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9964 "WLAN TL:VOSS packet corrupted on Attach BD header"));
9965 *pvosStatus = VOS_STATUS_E_INVAL;
9966 return;
9967 }
9968
9969 /*-----------------------------------------------------------------------
9970 Extract MAC address
9971 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 {
9973 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
9974 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
9975 ucBDHeaderLen +
9976 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
9977 (v_PVOID_t)pvDestMacAdddr,
9978 &usMacAddrSize );
9979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 if ( VOS_STATUS_SUCCESS != *pvosStatus )
9981 {
9982 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9983 "WLAN TL:Failed while attempting to extract MAC Addr %d",
9984 *pvosStatus));
9985 }
9986 else
9987 {
9988 /*---------------------------------------------------------------------
9989 Fill MPDU info fields:
9990 - MPDU data start offset
9991 - MPDU header start offset
9992 - MPDU header length
9993 - MPDU length - this is a 16b field - needs swapping
9994 --------------------------------------------------------------------*/
9995 ucHeaderOffset = ucBDHeaderLen;
9996 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
9997
9998 if ( 0 != ucDisableFrmXtl )
9999 {
10000 if ( 0 != ucQosEnabled )
10001 {
10002 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10003 }
10004
10005 // Similar to Qos we need something for WDS format !
10006 if ( ucWDSEnabled != 0 )
10007 {
10008 // If we have frame translation enabled
10009 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10010 }
10011 if ( extraHeadSpace != 0 )
10012 {
10013 // Decrease the packet length with the extra padding after the header
10014 *pusPktLen = *pusPktLen - extraHeadSpace;
10015 }
10016 }
10017
10018 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10019 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10020 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10021 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10022 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10023
10024 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10025 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10026 ucHeaderLen, ucHeaderOffset,
10027 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10028 *pusPktLen, extraHeadSpace));
10029 }/* if peek MAC success*/
10030
10031}/* WLANTL_PrepareBDHeader */
10032#endif
10033
Jeff Johnson295189b2012-06-20 16:38:30 -070010034//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10035/*==========================================================================
10036 FUNCTION WLAN_TLGetNextTxIds
10037
10038 DESCRIPTION
10039 Gets the next station and next AC in the list that should be served by the TL.
10040
10041 Multiple Station Scheduling and TL queue management.
10042
10043 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10044 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10045 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10046 or not.
10047
10048 Stations are served in a round-robin fashion from highest priority to lowest priority.
10049 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10050 the traffic of different prioirty. As such, stations can not provide low priority packets if
10051 high priority packets are all served.
10052
10053 DEPENDENCIES
10054
10055 PARAMETERS
10056
10057 IN
10058 pvosGCtx: pointer to the global vos context; a handle to TL's
10059 control block can be extracted from its context
10060
10061 OUT
10062 pucSTAId: Station ID
10063
10064 RETURN VALUE
10065 The result code associated with performing the operation
10066
10067 VOS_STATUS_SUCCESS: Everything is good
10068
10069 SIDE EFFECTS
10070
10071 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10072 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10073 When existing from the function, these three fields are changed accordingly.
10074
10075============================================================================*/
10076VOS_STATUS
10077WLAN_TLAPGetNextTxIds
10078(
10079 v_PVOID_t pvosGCtx,
10080 v_U8_t* pucSTAId
10081)
10082{
10083 WLANTL_CbType* pTLCb;
10084 v_U8_t ucACFilter = 1;
10085 v_U8_t ucNextSTA ;
10086 v_BOOL_t isServed = TRUE; //current round has find a packet or not
10087 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
10088 v_U8_t uFlowMask; // TX FlowMask from WDA
10089 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010090 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010091 /*------------------------------------------------------------------------
10092 Extract TL control block
10093 ------------------------------------------------------------------------*/
10094 //ENTER();
10095
10096 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10097 if ( NULL == pTLCb )
10098 {
10099 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10100 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10101 return VOS_STATUS_E_FAULT;
10102 }
10103
10104 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10105 {
10106 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10107 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10108 return VOS_STATUS_E_FAULT;
10109 }
10110
10111 ucNextSTA = pTLCb->ucCurrentSTA;
10112
10113 ++ucNextSTA;
10114
10115 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10116 {
10117 //one round is done.
10118 ucNextSTA = 0;
10119 pTLCb->ucCurLeftWeight--;
10120 isServed = FALSE;
10121 if ( 0 == pTLCb->ucCurLeftWeight )
10122 {
10123 //current prioirty is done
10124 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10125 {
10126 //end of current VO, VI, BE, BK loop. Reset priority.
10127 pTLCb->uCurServedAC = WLANTL_AC_VO;
10128 }
10129 else
10130 {
10131 pTLCb->uCurServedAC --;
10132 }
10133
10134 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10135
10136 } // (0 == pTLCb->ucCurLeftWeight)
10137 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10138
10139 //decide how many loops to go. if current loop is partial, do one extra to make sure
10140 //we cover every station
10141 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10142 {
10143 ucACLoopNum ++; // now is 5 loops
10144 }
10145
10146 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10147 all have previous values.*/
10148 for (; ucACLoopNum > 0; ucACLoopNum--)
10149 {
10150
10151 ucACFilter = 1 << pTLCb->uCurServedAC;
10152
10153 // pTLCb->ucCurLeftWeight keeps previous results.
10154 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
10155 {
10156
10157 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10158 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010159 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10160 {
10161 continue;
10162 }
10163 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010164
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010165 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10166 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 (0 == (ucACMask & ucACFilter)) )
10168
10169 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010170 //current station does not exist or have any packet to serve.
10171 continue;
10172 }
10173
10174 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10175 {
10176 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10177 "%s Sta %d not in auth state so skipping it.",
10178 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 continue;
10180 }
10181
10182 //go to next station if current station can't send due to flow control
10183 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10184 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10185 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010186 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10187 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10188 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010189 )
10190 {
10191 continue;
10192 }
10193
10194
10195 // Find a station. Weight is updated already.
10196 *pucSTAId = ucNextSTA;
10197 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010198 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010199
10200 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10201 " TL serve one station AC: %d W: %d StaId: %d",
10202 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10203
10204 return VOS_STATUS_SUCCESS;
10205 } //STA loop
10206
10207 ucNextSTA = 0;
10208 if ( FALSE == isServed )
10209 {
10210 //current loop finds no packet.no need to repeat for the same priority
10211 break;
10212 }
10213 //current loop is partial loop. go for one more loop.
10214 isServed = FALSE;
10215
10216 } //Weight loop
10217
10218 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10219 {
10220 pTLCb->uCurServedAC = WLANTL_AC_VO;
10221 }
10222 else
10223 {
10224 pTLCb->uCurServedAC--;
10225 }
10226 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10227
10228 }// AC loop
10229
10230 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010231 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010232
10233 pTLCb->uCurServedAC = WLANTL_AC_BK;
10234 pTLCb->ucCurLeftWeight = 1;
10235 //invalid number will be captured by caller
10236 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10237
10238 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 return VOS_STATUS_E_FAULT;
10240}
10241
10242
10243/*==========================================================================
10244 FUNCTION WLAN_TLGetNextTxIds
10245
10246 DESCRIPTION
10247 Gets the next station and next AC in the list
10248
10249 DEPENDENCIES
10250
10251 PARAMETERS
10252
10253 IN
10254 pvosGCtx: pointer to the global vos context; a handle to TL's
10255 control block can be extracted from its context
10256
10257 OUT
10258 pucSTAId: Station ID
10259
10260
10261 RETURN VALUE
10262 The result code associated with performing the operation
10263
10264 VOS_STATUS_SUCCESS: Everything is good :)
10265
10266 SIDE EFFECTS
10267
10268============================================================================*/
10269VOS_STATUS
10270WLAN_TLGetNextTxIds
10271(
10272 v_PVOID_t pvosGCtx,
10273 v_U8_t* pucSTAId
10274)
10275{
10276 WLANTL_CbType* pTLCb;
10277 v_U8_t ucNextAC;
10278 v_U8_t ucNextSTA;
10279 v_U8_t ucCount;
10280 v_U8_t uFlowMask; // TX FlowMask from WDA
10281 v_U8_t ucACMask = 0;
10282 v_U8_t i = 0;
10283
10284 tBssSystemRole systemRole; //RG HACK to be removed
10285 tpAniSirGlobal pMac;
10286
10287 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10288 if ( NULL == pMac )
10289 {
10290 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010291 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 return VOS_STATUS_E_FAULT;
10293 }
10294
10295 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010296
Jeff Johnson295189b2012-06-20 16:38:30 -070010297 /*------------------------------------------------------------------------
10298 Extract TL control block
10299 ------------------------------------------------------------------------*/
10300 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10301 if ( NULL == pTLCb )
10302 {
10303 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10304 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10305 return VOS_STATUS_E_FAULT;
10306 }
10307
Sunil Ravid5406f22013-01-22 00:18:31 -080010308#ifdef FEATURE_WLAN_TDLS
10309 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()) || pTLCb->ucTdlsPeerCount)
10310#else
10311 if ((eSYSTEM_AP_ROLE == systemRole) || (vos_concurrent_sessions_running()))
10312#endif
10313 {
10314 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10315 }
10316
10317
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10319 {
10320 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10321 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10322 return VOS_STATUS_E_FAULT;
10323 }
10324
10325 /*STA id - no priority yet implemented */
10326 /*-----------------------------------------------------------------------
10327 Choose the next STA for tx - for now go in a round robin fashion
10328 through all the stations that have pending packets
10329 -------------------------------------------------------------------------*/
10330 ucNextSTA = pTLCb->ucCurrentSTA;
10331
10332 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10333 for ( ucCount = 0;
10334 ucCount < WLAN_MAX_STA_COUNT;
10335 ucCount++ )
10336 {
10337 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010338 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10339 {
10340 continue;
10341 }
10342 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10343 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010345 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10346 {
10347 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10348 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10349 pTLCb->ucCurrentSTA = ucNextSTA;
10350 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010351 }
10352 else
10353 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010354 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10355 "%s Sta %d is not in auth state, skipping this sta.",
10356 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 }
10359 }
10360
10361 *pucSTAId = pTLCb->ucCurrentSTA;
10362
10363 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10364 {
10365 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10366 "WLAN TL:No station registered with TL at this point"));
10367
10368 return VOS_STATUS_E_FAULT;
10369
10370 }
10371
10372 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010373 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010374
10375 if ( 0 == ucACMask )
10376 {
10377 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10378 "WLAN TL: Mask 0 "
10379 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10380
10381 /*setting STA id to invalid if mask is 0*/
10382 *pucSTAId = WLAN_MAX_STA_COUNT;
10383
10384 return VOS_STATUS_E_FAULT;
10385 }
10386
10387 /*-----------------------------------------------------------------------
10388 AC is updated whenever a packet is fetched from HDD -> the current
10389 weight of such an AC cannot be 0 -> in this case TL is expected to
10390 exit this function at this point during the main Tx loop
10391 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010392 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010393 {
10394 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10395 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010396 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10397 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 return VOS_STATUS_SUCCESS;
10399 }
10400
10401 /*-----------------------------------------------------------------------
10402 Choose highest priority AC - !!! optimize me
10403 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010404 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10406 "Next AC: %d", ucNextAC));
10407
10408 while ( 0 != ucACMask )
10409 {
10410 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10411 " AC Mask: %d Next: %d Res : %d",
10412 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10413
10414 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10415 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010416 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010418 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10420
10421 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10422 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010423 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10424 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010425 break;
10426 }
10427
10428 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10429
10430 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10431 "Next AC %d", ucNextAC));
10432
10433 }
10434
10435 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10436 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010437 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10438 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010439
10440 return VOS_STATUS_SUCCESS;
10441}/* WLAN_TLGetNextTxIds */
10442
Jeff Johnson295189b2012-06-20 16:38:30 -070010443
10444
10445/*==========================================================================
10446 DEFAULT HANDLERS: Registered at initialization with TL
10447 ==========================================================================*/
10448
10449/*==========================================================================
10450
10451 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10452
10453 DESCRIPTION
10454 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10455 called it means there is no registered rx cb pointer for Mgmt Frm.
10456
10457 DEPENDENCIES
10458
10459 PARAMETERS
10460 Not used.
10461
10462 RETURN VALUE
10463
10464 VOS_STATUS_E_FAILURE: Always FAILURE.
10465
10466============================================================================*/
10467VOS_STATUS
10468WLANTL_MgmtFrmRxDefaultCb
10469(
10470 v_PVOID_t pvosGCtx,
10471 v_PVOID_t vosBuff
10472)
10473{
10474 if ( NULL != vosBuff )
10475 {
10476 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10477 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10478 /* Drop packet */
10479 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10480 }
10481
Jeff Johnson295189b2012-06-20 16:38:30 -070010482 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10483 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010484
10485 return VOS_STATUS_E_FAILURE;
10486}/*WLANTL_MgmtFrmRxDefaultCb*/
10487
10488/*==========================================================================
10489
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010490 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070010491
10492 DESCRIPTION
10493 Default BAP rx callback: asserts all the time. If this function gets
10494 called it means there is no registered rx cb pointer for BAP.
10495
10496 DEPENDENCIES
10497
10498 PARAMETERS
10499 Not used.
10500
10501 RETURN VALUE
10502
10503 VOS_STATUS_E_FAILURE: Always FAILURE.
10504
10505============================================================================*/
10506VOS_STATUS
10507WLANTL_BAPRxDefaultCb
10508(
10509 v_PVOID_t pvosGCtx,
10510 vos_pkt_t* vosDataBuff,
10511 WLANTL_BAPFrameEnumType frameType
10512)
10513{
10514 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10515 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10516#ifndef BTAMP_TEST
10517 VOS_ASSERT(0);
10518#endif
10519 return VOS_STATUS_E_FAILURE;
10520}/*WLANTL_MgmtFrmRxDefaultCb*/
10521
10522/*==========================================================================
10523
10524 FUNCTION WLANTL_STARxDefaultCb
10525
10526 DESCRIPTION
10527 Default STA rx callback: asserts all the time. If this function gets
10528 called it means there is no registered rx cb pointer for station.
10529 (Mem corruption most likely, it should never happen)
10530
10531 DEPENDENCIES
10532
10533 PARAMETERS
10534 Not used.
10535
10536 RETURN VALUE
10537
10538 VOS_STATUS_E_FAILURE: Always FAILURE.
10539
10540============================================================================*/
10541VOS_STATUS
10542WLANTL_STARxDefaultCb
10543(
10544 v_PVOID_t pvosGCtx,
10545 vos_pkt_t* vosDataBuff,
10546 v_U8_t ucSTAId,
10547 WLANTL_RxMetaInfoType* pRxMetaInfo
10548)
10549{
10550 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10551 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10552 ucSTAId));
10553 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010554 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010555}/*WLANTL_MgmtFrmRxDefaultCb*/
10556
10557
10558/*==========================================================================
10559
10560 FUNCTION WLANTL_STAFetchPktDefaultCb
10561
10562 DESCRIPTION
10563 Default fetch callback: asserts all the time. If this function gets
10564 called it means there is no registered fetch cb pointer for station.
10565 (Mem corruption most likely, it should never happen)
10566
10567 DEPENDENCIES
10568
10569 PARAMETERS
10570 Not used.
10571
10572 RETURN VALUE
10573
10574 VOS_STATUS_E_FAILURE: Always FAILURE.
10575
10576============================================================================*/
10577VOS_STATUS
10578WLANTL_STAFetchPktDefaultCb
10579(
10580 v_PVOID_t pvosGCtx,
10581 v_U8_t* pucSTAId,
10582 WLANTL_ACEnumType ucAC,
10583 vos_pkt_t** vosDataBuff,
10584 WLANTL_MetaInfoType* tlMetaInfo
10585)
10586{
10587 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10588 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
10589 VOS_ASSERT(0);
10590 return VOS_STATUS_E_FAILURE;
10591}/*WLANTL_MgmtFrmRxDefaultCb*/
10592
10593/*==========================================================================
10594
10595 FUNCTION WLANTL_TxCompDefaultCb
10596
10597 DESCRIPTION
10598 Default tx complete handler. It will release the completed pkt to
10599 prevent memory leaks.
10600
10601 PARAMETERS
10602
10603 IN
10604 pvosGCtx: pointer to the global vos context; a handle to
10605 TL/HAL/PE/BAP/HDD control block can be extracted from
10606 its context
10607 vosDataBuff: pointer to the VOSS data buffer that was transmitted
10608 wTxSTAtus: status of the transmission
10609
10610
10611 RETURN VALUE
10612 The result code associated with performing the operation; please
10613 check vos_pkt_return_packet for possible error codes.
10614
10615 Please check vos_pkt_return_packet API for possible return values.
10616
10617============================================================================*/
10618VOS_STATUS
10619WLANTL_TxCompDefaultCb
10620(
10621 v_PVOID_t pvosGCtx,
10622 vos_pkt_t* vosDataBuff,
10623 VOS_STATUS wTxSTAtus
10624)
10625{
10626 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10627 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
10628 return vos_pkt_return_packet(vosDataBuff);
10629}/*WLANTL_TxCompDefaultCb*/
10630
10631
10632/*==========================================================================
10633 Cleanup functions
10634 ==========================================================================*/
10635
10636/*==========================================================================
10637
10638 FUNCTION WLANTL_CleanCB
10639
10640 DESCRIPTION
10641 Cleans TL control block
10642
10643 DEPENDENCIES
10644
10645 PARAMETERS
10646
10647 IN
10648 pTLCb: pointer to TL's control block
10649 ucEmpty: set if TL has to clean up the queues and release pedning pkts
10650
10651 RETURN VALUE
10652 The result code associated with performing the operation
10653
10654 VOS_STATUS_E_INVAL: invalid input parameters
10655 VOS_STATUS_SUCCESS: Everything is good :)
10656
10657 SIDE EFFECTS
10658
10659============================================================================*/
10660VOS_STATUS
10661WLANTL_CleanCB
10662(
10663 WLANTL_CbType* pTLCb,
10664 v_U8_t ucEmpty
10665)
10666{
10667 v_U8_t ucIndex;
10668 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10669
10670 /*-------------------------------------------------------------------------
10671 Sanity check
10672 -------------------------------------------------------------------------*/
10673 if ( NULL == pTLCb )
10674 {
10675 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10676 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
10677 return VOS_STATUS_E_INVAL;
10678 }
10679
10680 /* number of packets sent to BAL waiting for tx complete confirmation */
10681 pTLCb->usPendingTxCompleteCount = 0;
10682
10683 /* global suspend flag */
10684 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
10685
10686 /* resource flag */
10687 pTLCb->uResCount = 0;
10688
10689
10690 /*-------------------------------------------------------------------------
10691 Client stations
10692 -------------------------------------------------------------------------*/
10693 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10694 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010695 if(NULL != pTLCb->atlSTAClients[ucIndex])
10696 {
10697 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
10698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 }
10700
10701 /*-------------------------------------------------------------------------
10702 Management Frame client
10703 -------------------------------------------------------------------------*/
10704 pTLCb->tlMgmtFrmClient.ucExists = 0;
10705
10706 if ( ( 0 != ucEmpty) &&
10707 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
10708 {
10709 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
10710 }
10711
10712 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
10713
10714 /* set to a default cb in order to prevent constant checking for NULL */
10715 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
10716
10717 /*-------------------------------------------------------------------------
10718 BT AMP client
10719 -------------------------------------------------------------------------*/
10720 pTLCb->tlBAPClient.ucExists = 0;
10721
10722 if (( 0 != ucEmpty) &&
10723 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
10724 {
10725 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
10726 }
10727
10728 if (( 0 != ucEmpty) &&
10729 ( NULL != pTLCb->vosDummyBuf ))
10730 {
10731 vos_pkt_return_packet(pTLCb->vosDummyBuf);
10732 }
10733
10734 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
10735
10736 pTLCb->vosDummyBuf = NULL;
10737 pTLCb->vosTempBuf = NULL;
10738 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
10739
10740 /* set to a default cb in order to prevent constant checking for NULL */
10741 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
10742
10743 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
10744
10745 return VOS_STATUS_SUCCESS;
10746
10747}/* WLANTL_CleanCB*/
10748
10749/*==========================================================================
10750
10751 FUNCTION WLANTL_CleanSTA
10752
10753 DESCRIPTION
10754 Cleans a station control block.
10755
10756 DEPENDENCIES
10757
10758 PARAMETERS
10759
10760 IN
10761 pvosGCtx: pointer to the global vos context; a handle to TL's
10762 control block can be extracted from its context
10763 ucEmpty: if set the queues and pending pkts will be emptyed
10764
10765 RETURN VALUE
10766 The result code associated with performing the operation
10767
10768 VOS_STATUS_E_INVAL: invalid input parameters
10769 VOS_STATUS_SUCCESS: Everything is good :)
10770
10771 SIDE EFFECTS
10772
10773============================================================================*/
10774VOS_STATUS
10775WLANTL_CleanSTA
10776(
10777 WLANTL_STAClientType* ptlSTAClient,
10778 v_U8_t ucEmpty
10779)
10780{
10781 v_U8_t ucIndex;
10782 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10783
10784 /*-------------------------------------------------------------------------
10785 Sanity check
10786 -------------------------------------------------------------------------*/
10787 if ( NULL == ptlSTAClient )
10788 {
10789 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10790 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
10791 return VOS_STATUS_E_INVAL;
10792 }
10793
10794 /*------------------------------------------------------------------------
10795 Clear station from TL
10796 ------------------------------------------------------------------------*/
10797 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10798 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
10799 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
10800
10801 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
10802 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
10803 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
10804
10805 ptlSTAClient->tlState = WLANTL_STA_INIT;
10806 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
10807
10808 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
10809 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
10810 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
10811
10812 ptlSTAClient->wSTADesc.ucSTAId = 0;
10813 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
10814
10815 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
10816 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
10817 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
10818 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
10819 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
10820
10821 /*-------------------------------------------------------------------------
10822 AMSDU information for the STA
10823 -------------------------------------------------------------------------*/
10824 if ( ( 0 != ucEmpty ) &&
10825 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
10826 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010827 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080010828 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070010829 "suspecting a memory corruption"));
10830
Jeff Johnson295189b2012-06-20 16:38:30 -070010831 }
10832
10833 ptlSTAClient->vosAMSDUChain = NULL;
10834 ptlSTAClient->vosAMSDUChainRoot = NULL;
10835
10836 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
10837 WLANTL_MPDU_HEADER_LEN);
10838 ptlSTAClient->ucMPDUHeaderLen = 0;
10839
10840 /*-------------------------------------------------------------------------
10841 Reordering information for the STA
10842 -------------------------------------------------------------------------*/
10843 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
10844 {
10845 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
10846 {
10847 continue;
10848 }
10849 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
10850 {
10851 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
10852 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
10853 }
10854 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
10855 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
10856 }
10857
10858 /*-------------------------------------------------------------------------
10859 QOS information for the STA
10860 -------------------------------------------------------------------------*/
10861 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
10862 ptlSTAClient->ucCurrentWeight = 0;
10863 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
10864
10865 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
10866 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
10867
10868
10869 /*--------------------------------------------------------------------
10870 Stats info
10871 --------------------------------------------------------------------*/
10872 vos_mem_zero( ptlSTAClient->auRxCount,
10873 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
10874 vos_mem_zero( ptlSTAClient->auTxCount,
10875 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
10876 ptlSTAClient->rssiAvg = 0;
10877
10878 /*Tx not suspended and station fully registered*/
10879 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
10880 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
10881
10882 if ( 0 == ucEmpty )
10883 {
10884 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
10885 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
10886 }
10887
10888 ptlSTAClient->ucExists = 0;
10889
10890 /*--------------------------------------------------------------------
10891 Statistics info
10892 --------------------------------------------------------------------*/
10893 memset(&ptlSTAClient->trafficStatistics,
10894 0,
10895 sizeof(WLANTL_TRANSFER_STA_TYPE));
10896
10897 /*fix me!!: add new values from the TL Cb for cleanup */
10898 return VOS_STATUS_SUCCESS;
10899}/* WLANTL_CleanSTA */
10900
10901
10902/*==========================================================================
10903 FUNCTION WLANTL_EnableUAPSDForAC
10904
10905 DESCRIPTION
10906 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
10907 logic in FW/SLM to start sending trigger frames. Previously TL had the
10908 trigger frame logic which later moved down to FW. Hence
10909 HDD -> TL -> WDA -> FW call flow.
10910
10911 DEPENDENCIES
10912 The TL must be initialized before this function can be called.
10913
10914 PARAMETERS
10915
10916 IN
10917 pvosGCtx: pointer to the global vos context; a handle to TL's
10918 control block can be extracted from its context
10919 ucSTAId: station Id
10920 ucAC: AC for which U-APSD is being enabled
10921 ucTid: TID for which U-APSD is setup
10922 ucUP: used to place in the trigger frame generation
10923 ucServiceInt: service interval used by TL to send trigger frames
10924 ucSuspendInt: suspend interval used by TL to determine that an
10925 app is idle and should start sending trigg frms less often
10926 wTSDir: direction of TSpec
10927
10928 RETURN VALUE
10929 The result code associated with performing the operation
10930
10931 VOS_STATUS_SUCCESS: Everything is good :)
10932
10933 SIDE EFFECTS
10934
10935============================================================================*/
10936VOS_STATUS
10937WLANTL_EnableUAPSDForAC
10938(
10939 v_PVOID_t pvosGCtx,
10940 v_U8_t ucSTAId,
10941 WLANTL_ACEnumType ucAC,
10942 v_U8_t ucTid,
10943 v_U8_t ucUP,
10944 v_U32_t uServiceInt,
10945 v_U32_t uSuspendInt,
10946 WLANTL_TSDirType wTSDir
10947)
10948{
10949
10950 WLANTL_CbType* pTLCb = NULL;
10951 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10952 tUapsdInfo halUAPSDInfo;
10953 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10954
10955 /*------------------------------------------------------------------------
10956 Sanity check
10957 Extract TL control block
10958 ------------------------------------------------------------------------*/
10959 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10960 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010961 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 {
10963 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10964 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010965 " TL: %p STA: %d AC: %d",
10966 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070010967 return VOS_STATUS_E_FAULT;
10968 }
10969
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010970 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10971 {
10972 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10973 "WLAN TL:Client Memory was not allocated on %s", __func__));
10974 return VOS_STATUS_E_FAILURE;
10975 }
10976
Jeff Johnson295189b2012-06-20 16:38:30 -070010977 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010978 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010979
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010980#ifdef FEATURE_WLAN_TDLS
10981 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
10982#endif
10983 {
10984 if( 0 == uServiceInt )
10985 {
10986 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053010987 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010988 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010990
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010991 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10992 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
10993 "DI: %d",
10994 ucSTAId, ucAC, uServiceInt, uSuspendInt,
10995 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070010996
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010997 /*Save all info for HAL*/
10998 halUAPSDInfo.staidx = ucSTAId;
10999 halUAPSDInfo.ac = ucAC;
11000 halUAPSDInfo.up = ucUP;
11001 halUAPSDInfo.srvInterval = uServiceInt;
11002 halUAPSDInfo.susInterval = uSuspendInt;
11003 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11004
11005 /*Notify HAL*/
11006 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 return vosStatus;
11009
11010}/*WLANTL_EnableUAPSDForAC*/
11011
11012
11013/*==========================================================================
11014 FUNCTION WLANTL_DisableUAPSDForAC
11015
11016 DESCRIPTION
11017 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11018 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11019 trigger frame logic which later moved down to FW. Hence
11020 HDD -> TL -> WDA -> FW call flow.
11021
11022 DEPENDENCIES
11023 The TL must be initialized before this function can be called.
11024
11025 PARAMETERS
11026
11027 IN
11028 pvosGCtx: pointer to the global vos context; a handle to TL's
11029 control block can be extracted from its context
11030 ucSTAId: station Id
11031 ucAC: AC for which U-APSD is being enabled
11032
11033
11034 RETURN VALUE
11035 The result code associated with performing the operation
11036
11037 VOS_STATUS_SUCCESS: Everything is good :)
11038
11039 SIDE EFFECTS
11040
11041============================================================================*/
11042VOS_STATUS
11043WLANTL_DisableUAPSDForAC
11044(
11045 v_PVOID_t pvosGCtx,
11046 v_U8_t ucSTAId,
11047 WLANTL_ACEnumType ucAC
11048)
11049{
11050 WLANTL_CbType* pTLCb;
11051 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11052
11053 /*------------------------------------------------------------------------
11054 Sanity check
11055 Extract TL control block
11056 ------------------------------------------------------------------------*/
11057 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11058 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11059 || WLANTL_AC_INVALID(ucAC) )
11060 {
11061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11062 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011063 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011064 return VOS_STATUS_E_FAULT;
11065 }
11066
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011067 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11068 {
11069 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11070 "WLAN TL:Client Memory was not allocated on %s", __func__));
11071 return VOS_STATUS_E_FAILURE;
11072 }
11073
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011075 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011076
11077 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11078 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11079 ucSTAId, ucAC));
11080
11081 /*Notify HAL*/
11082 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11083
11084 return VOS_STATUS_SUCCESS;
11085}/* WLANTL_DisableUAPSDForAC */
11086
11087#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11088/*==========================================================================
11089 FUNCTION WLANTL_RegRSSIIndicationCB
11090
11091 DESCRIPTION Registration function to get notification if RSSI cross
11092 threshold.
11093 Client should register threshold, direction, and notification
11094 callback function pointer
11095
11096 DEPENDENCIES NONE
11097
11098 PARAMETERS in pAdapter - Global handle
11099 in rssiValue - RSSI threshold value
11100 in triggerEvent - Cross direction should be notified
11101 UP, DOWN, and CROSS
11102 in crossCBFunction - Notification CB Function
11103 in usrCtxt - user context
11104
11105 RETURN VALUE VOS_STATUS
11106
11107 SIDE EFFECTS NONE
11108
11109============================================================================*/
11110VOS_STATUS WLANTL_RegRSSIIndicationCB
11111(
11112 v_PVOID_t pAdapter,
11113 v_S7_t rssiValue,
11114 v_U8_t triggerEvent,
11115 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11116 VOS_MODULE_ID moduleID,
11117 v_PVOID_t usrCtxt
11118)
11119{
11120 VOS_STATUS status = VOS_STATUS_SUCCESS;
11121
11122 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11123 rssiValue,
11124 triggerEvent,
11125 crossCBFunction,
11126 moduleID,
11127 usrCtxt);
11128
11129 return status;
11130}
11131
11132/*==========================================================================
11133 FUNCTION WLANTL_DeregRSSIIndicationCB
11134
11135 DESCRIPTION Remove specific threshold from list
11136
11137 DEPENDENCIES NONE
11138
11139 PARAMETERS in pAdapter - Global handle
11140 in rssiValue - RSSI threshold value
11141 in triggerEvent - Cross direction should be notified
11142 UP, DOWN, and CROSS
11143
11144 RETURN VALUE VOS_STATUS
11145
11146 SIDE EFFECTS NONE
11147
11148============================================================================*/
11149VOS_STATUS WLANTL_DeregRSSIIndicationCB
11150(
11151 v_PVOID_t pAdapter,
11152 v_S7_t rssiValue,
11153 v_U8_t triggerEvent,
11154 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11155 VOS_MODULE_ID moduleID
11156)
11157{
11158 VOS_STATUS status = VOS_STATUS_SUCCESS;
11159
11160 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11161 rssiValue,
11162 triggerEvent,
11163 crossCBFunction,
11164 moduleID);
11165 return status;
11166}
11167
11168/*==========================================================================
11169 FUNCTION WLANTL_SetAlpha
11170
11171 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11172 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11173 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11174 (10 - ALPHA)% of newRSSI weight
11175 This portion is dynamically configurable.
11176 Default is ?
11177
11178 DEPENDENCIES NONE
11179
11180 PARAMETERS in pAdapter - Global handle
11181 in valueAlpah - ALPHA
11182
11183 RETURN VALUE VOS_STATUS
11184
11185 SIDE EFFECTS NONE
11186
11187============================================================================*/
11188VOS_STATUS WLANTL_SetAlpha
11189(
11190 v_PVOID_t pAdapter,
11191 v_U8_t valueAlpha
11192)
11193{
11194 VOS_STATUS status = VOS_STATUS_SUCCESS;
11195
11196 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11197 return status;
11198}
11199
11200/*==========================================================================
11201
11202 FUNCTION
11203
11204 DESCRIPTION
11205
11206 PARAMETERS
11207
11208 RETURN VALUE
11209
11210============================================================================*/
11211VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11212(
11213 v_PVOID_t pAdapter,
11214 tpSirRSSINotification pRSSINotification
11215)
11216{
11217 VOS_STATUS status = VOS_STATUS_SUCCESS;
11218
11219 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11220 return status;
11221}
11222
11223/*==========================================================================
11224 FUNCTION WLANTL_RegGetTrafficStatus
11225
11226 DESCRIPTION Registration function for traffic status monitoring
11227 During measure period count data frames.
11228 If frame count is larger then IDLE threshold set as traffic ON
11229 or OFF.
11230 And traffic status is changed send report to client with
11231 registered callback function
11232
11233 DEPENDENCIES NONE
11234
11235 PARAMETERS in pAdapter - Global handle
11236 in idleThreshold - Traffic on or off threshold
11237 in measurePeriod - Traffic state check period
11238 in trfficStatusCB - traffic status changed notification
11239 CB function
11240 in usrCtxt - user context
11241
11242 RETURN VALUE VOS_STATUS
11243
11244 SIDE EFFECTS NONE
11245
11246============================================================================*/
11247VOS_STATUS WLANTL_RegGetTrafficStatus
11248(
11249 v_PVOID_t pAdapter,
11250 v_U32_t idleThreshold,
11251 v_U32_t measurePeriod,
11252 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11253 v_PVOID_t usrCtxt
11254)
11255{
11256 VOS_STATUS status = VOS_STATUS_SUCCESS;
11257
11258 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11259 idleThreshold,
11260 measurePeriod,
11261 trfficStatusCB,
11262 usrCtxt);
11263 return status;
11264}
11265#endif
11266/*==========================================================================
11267 FUNCTION WLANTL_GetStatistics
11268
11269 DESCRIPTION Get traffic statistics for identified station
11270
11271 DEPENDENCIES NONE
11272
11273 PARAMETERS in pAdapter - Global handle
11274 in statType - specific statistics field to reset
11275 out statBuffer - traffic statistics buffer
11276
11277 RETURN VALUE VOS_STATUS
11278
11279 SIDE EFFECTS NONE
11280
11281============================================================================*/
11282VOS_STATUS WLANTL_GetStatistics
11283(
11284 v_PVOID_t pAdapter,
11285 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11286 v_U8_t STAid
11287)
11288{
11289 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011290 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011291 VOS_STATUS status = VOS_STATUS_SUCCESS;
11292 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11293
11294 /*------------------------------------------------------------------------
11295 Sanity check
11296 Extract TL control block
11297 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011298 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011299 {
11300 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11301 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11302 return VOS_STATUS_E_FAULT;
11303 }
11304
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011305 pClientSTA = pTLCb->atlSTAClients[STAid];
11306
11307 if ( NULL == pClientSTA )
11308 {
11309 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11310 "WLAN TL:Client Memory was not allocated on %s", __func__));
11311 return VOS_STATUS_E_FAILURE;
11312 }
11313
11314 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 {
11316 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11317 "WLAN TL: %d STA ID does not exist", STAid));
11318 return VOS_STATUS_E_INVAL;
11319 }
11320
11321 if(NULL == statBuffer)
11322 {
11323 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11324 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11325 return VOS_STATUS_E_INVAL;
11326 }
11327
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011328 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011329 memcpy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11330
11331 return status;
11332}
11333
11334/*==========================================================================
11335 FUNCTION WLANTL_ResetStatistics
11336
11337 DESCRIPTION Reset statistics structure for identified station ID
11338 Reset means set values as 0
11339
11340 DEPENDENCIES NONE
11341
11342 PARAMETERS in pAdapter - Global handle
11343 in statType - specific statistics field to reset
11344
11345 RETURN VALUE VOS_STATUS
11346
11347 SIDE EFFECTS NONE
11348
11349============================================================================*/
11350VOS_STATUS WLANTL_ResetStatistics
11351(
11352 v_PVOID_t pAdapter,
11353 v_U8_t STAid
11354)
11355{
11356 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011357 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 VOS_STATUS status = VOS_STATUS_SUCCESS;
11359 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11360
11361 /*------------------------------------------------------------------------
11362 Sanity check
11363 Extract TL control block
11364 ------------------------------------------------------------------------*/
11365 if (NULL == pTLCb)
11366 {
11367 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11368 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11369 return VOS_STATUS_E_FAULT;
11370 }
11371
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011372 pClientSTA = pTLCb->atlSTAClients[STAid];
11373
11374 if ( NULL == pClientSTA )
11375 {
11376 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11377 "WLAN TL:Client Memory was not allocated on %s", __func__));
11378 return VOS_STATUS_E_FAILURE;
11379 }
11380
11381 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 {
11383 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11384 "WLAN TL: %d STA ID does not exist", STAid));
11385 return VOS_STATUS_E_INVAL;
11386 }
11387
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011388 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11390
11391 return status;
11392}
11393
11394/*==========================================================================
11395 FUNCTION WLANTL_GetSpecStatistic
11396
11397 DESCRIPTION Get specific field within statistics structure for
11398 identified station ID
11399
11400 DEPENDENCIES NONE
11401
11402 PARAMETERS in pAdapter - Global handle
11403 in statType - specific statistics field to reset
11404 in STAid - Station ID
11405 out buffer - Statistic value
11406
11407 RETURN VALUE VOS_STATUS
11408
11409 SIDE EFFECTS NONE
11410
11411============================================================================*/
11412VOS_STATUS WLANTL_GetSpecStatistic
11413(
11414 v_PVOID_t pAdapter,
11415 WLANTL_TRANSFER_STATIC_TYPE statType,
11416 v_U32_t *buffer,
11417 v_U8_t STAid
11418)
11419{
11420 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011421 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 VOS_STATUS status = VOS_STATUS_SUCCESS;
11423 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11424
11425 /*------------------------------------------------------------------------
11426 Sanity check
11427 Extract TL control block
11428 ------------------------------------------------------------------------*/
11429 if (NULL == pTLCb)
11430 {
11431 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11432 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11433 return VOS_STATUS_E_FAULT;
11434 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011435 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011436
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011437 if ( NULL == pClientSTA )
11438 {
11439 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11440 "WLAN TL:Client Memory was not allocated on %s", __func__));
11441 return VOS_STATUS_E_FAILURE;
11442 }
11443
11444 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 {
11446 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11447 "WLAN TL: %d STA ID does not exist", STAid));
11448 return VOS_STATUS_E_INVAL;
11449 }
11450
11451 if(NULL == buffer)
11452 {
11453 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11454 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11455 return VOS_STATUS_E_INVAL;
11456 }
11457
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011458 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 switch(statType)
11460 {
11461 case WLANTL_STATIC_TX_UC_FCNT:
11462 *buffer = statistics->txUCFcnt;
11463 break;
11464
11465 case WLANTL_STATIC_TX_MC_FCNT:
11466 *buffer = statistics->txMCFcnt;
11467 break;
11468
11469 case WLANTL_STATIC_TX_BC_FCNT:
11470 *buffer = statistics->txBCFcnt;
11471 break;
11472
11473 case WLANTL_STATIC_TX_UC_BCNT:
11474 *buffer = statistics->txUCBcnt;
11475 break;
11476
11477 case WLANTL_STATIC_TX_MC_BCNT:
11478 *buffer = statistics->txMCBcnt;
11479 break;
11480
11481 case WLANTL_STATIC_TX_BC_BCNT:
11482 *buffer = statistics->txBCBcnt;
11483 break;
11484
11485 case WLANTL_STATIC_RX_UC_FCNT:
11486 *buffer = statistics->rxUCFcnt;
11487 break;
11488
11489 case WLANTL_STATIC_RX_MC_FCNT:
11490 *buffer = statistics->rxMCFcnt;
11491 break;
11492
11493 case WLANTL_STATIC_RX_BC_FCNT:
11494 *buffer = statistics->rxBCFcnt;
11495 break;
11496
11497 case WLANTL_STATIC_RX_UC_BCNT:
11498 *buffer = statistics->rxUCBcnt;
11499 break;
11500
11501 case WLANTL_STATIC_RX_MC_BCNT:
11502 *buffer = statistics->rxMCBcnt;
11503 break;
11504
11505 case WLANTL_STATIC_RX_BC_BCNT:
11506 *buffer = statistics->rxBCBcnt;
11507 break;
11508
11509 case WLANTL_STATIC_RX_BCNT:
11510 *buffer = statistics->rxBcnt;
11511 break;
11512
11513 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11514 *buffer = statistics->rxBcntCRCok;
11515 break;
11516
11517 case WLANTL_STATIC_RX_RATE:
11518 *buffer = statistics->rxRate;
11519 break;
11520
11521 default:
11522 *buffer = 0;
11523 status = VOS_STATUS_E_INVAL;
11524 break;
11525 }
11526
11527
11528 return status;
11529}
11530
11531/*==========================================================================
11532 FUNCTION WLANTL_ResetSpecStatistic
11533
11534 DESCRIPTION Reset specific field within statistics structure for
11535 identified station ID
11536 Reset means set as 0
11537
11538 DEPENDENCIES NONE
11539
11540 PARAMETERS in pAdapter - Global handle
11541 in statType - specific statistics field to reset
11542 in STAid - Station ID
11543
11544 RETURN VALUE VOS_STATUS
11545
11546 SIDE EFFECTS NONE
11547
11548============================================================================*/
11549VOS_STATUS WLANTL_ResetSpecStatistic
11550(
11551 v_PVOID_t pAdapter,
11552 WLANTL_TRANSFER_STATIC_TYPE statType,
11553 v_U8_t STAid
11554)
11555{
11556 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011557 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 VOS_STATUS status = VOS_STATUS_SUCCESS;
11559 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11560
11561 /*------------------------------------------------------------------------
11562 Sanity check
11563 Extract TL control block
11564 ------------------------------------------------------------------------*/
11565 if (NULL == pTLCb)
11566 {
11567 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11568 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11569 return VOS_STATUS_E_FAULT;
11570 }
11571
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011572 pClientSTA = pTLCb->atlSTAClients[STAid];
11573
11574 if ( NULL == pClientSTA )
11575 {
11576 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11577 "WLAN TL:Client Memory was not allocated on %s", __func__));
11578 return VOS_STATUS_E_FAILURE;
11579 }
11580
11581 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 {
11583 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11584 "WLAN TL: %d STA ID does not exist", STAid));
11585 return VOS_STATUS_E_INVAL;
11586 }
11587
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011588 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 switch(statType)
11590 {
11591 case WLANTL_STATIC_TX_UC_FCNT:
11592 statistics->txUCFcnt = 0;
11593 break;
11594
11595 case WLANTL_STATIC_TX_MC_FCNT:
11596 statistics->txMCFcnt = 0;
11597 break;
11598
11599 case WLANTL_STATIC_TX_BC_FCNT:
11600 statistics->txBCFcnt = 0;
11601 break;
11602
11603 case WLANTL_STATIC_TX_UC_BCNT:
11604 statistics->txUCBcnt = 0;
11605 break;
11606
11607 case WLANTL_STATIC_TX_MC_BCNT:
11608 statistics->txMCBcnt = 0;
11609 break;
11610
11611 case WLANTL_STATIC_TX_BC_BCNT:
11612 statistics->txBCBcnt = 0;
11613 break;
11614
11615 case WLANTL_STATIC_RX_UC_FCNT:
11616 statistics->rxUCFcnt = 0;
11617 break;
11618
11619 case WLANTL_STATIC_RX_MC_FCNT:
11620 statistics->rxMCFcnt = 0;
11621 break;
11622
11623 case WLANTL_STATIC_RX_BC_FCNT:
11624 statistics->rxBCFcnt = 0;
11625 break;
11626
11627 case WLANTL_STATIC_RX_UC_BCNT:
11628 statistics->rxUCBcnt = 0;
11629 break;
11630
11631 case WLANTL_STATIC_RX_MC_BCNT:
11632 statistics->rxMCBcnt = 0;
11633 break;
11634
11635 case WLANTL_STATIC_RX_BC_BCNT:
11636 statistics->rxBCBcnt = 0;
11637 break;
11638
11639 case WLANTL_STATIC_RX_BCNT:
11640 statistics->rxBcnt = 0;
11641 break;
11642
11643 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11644 statistics->rxBcntCRCok = 0;
11645 break;
11646
11647 case WLANTL_STATIC_RX_RATE:
11648 statistics->rxRate = 0;
11649 break;
11650
11651 default:
11652 status = VOS_STATUS_E_INVAL;
11653 break;
11654 }
11655
11656 return status;
11657}
11658
11659
11660/*==========================================================================
11661
11662 FUNCTION
11663
11664 DESCRIPTION Read RSSI value out of a RX BD
11665
11666 PARAMETERS: Caller must validate all parameters
11667
11668 RETURN VALUE
11669
11670============================================================================*/
11671VOS_STATUS WLANTL_ReadRSSI
11672(
11673 v_PVOID_t pAdapter,
11674 v_PVOID_t pBDHeader,
11675 v_U8_t STAid
11676)
11677{
11678 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11679 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
11680
11681
11682 if(NULL == tlCtxt)
11683 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011684 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011685 return VOS_STATUS_E_INVAL;
11686 }
11687
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011688 if ( NULL == tlCtxt->atlSTAClients[STAid] )
11689 {
11690 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11691 "WLAN TL:Client Memory was not allocated on %s", __func__));
11692 return VOS_STATUS_E_FAILURE;
11693 }
11694
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
11696 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
11697 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
11698
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011699 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070011700
11701 return VOS_STATUS_SUCCESS;
11702}
11703
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011704/*==========================================================================
11705
11706 FUNCTION
11707
11708 DESCRIPTION Read SNR value out of a RX BD
11709
11710 PARAMETERS: Caller must validate all parameters
11711
11712 RETURN VALUE
11713
11714============================================================================*/
11715VOS_STATUS WLANTL_ReadSNR
11716(
11717 v_PVOID_t pAdapter,
11718 v_PVOID_t pBDHeader,
11719 v_U8_t STAid
11720)
11721{
11722 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11723 v_S7_t currentSNR;
11724
11725
11726 if (NULL == tlCtxt)
11727 {
11728 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11729 "%s Invalid TL handle", __func__));
11730 return VOS_STATUS_E_INVAL;
11731 }
11732
11733 if (NULL == tlCtxt->atlSTAClients[STAid])
11734 {
11735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11736 "WLAN TL:Client Memory was not allocated on %s", __func__));
11737 return VOS_STATUS_E_FAILURE;
11738 }
11739
11740 currentSNR = WLANTL_GETSNR(pBDHeader);
11741
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053011742 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
11743 * Get the correct SNR value
11744 */
11745 currentSNR = currentSNR >> 1;
11746
11747 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
11748 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
11749 WLANTL_MAX_HW_SNR);
11750
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011751 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11752 "%s: snrsum: %d snridx: %d prevsnravg: %d",
11753 __func__,
11754 tlCtxt->atlSTAClients[STAid]->snrSum,
11755 tlCtxt->atlSTAClients[STAid]->snrIdx,
11756 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
11757
11758 /* The SNR returned for all purposes is the average SNR over
11759 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
11760 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
11761 * store the average of the samples in prevSnrAvg
11762 * and start a new averaging window. The prevSnrAvg is used when
11763 * enough data samples are not available when applications
11764 * actually query for SNR.
11765 *
11766 * SEE: WLANTL_GetSnr()
11767 */
11768 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
11769 {
11770 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
11771 tlCtxt->atlSTAClients[STAid]->snrSum /
11772 tlCtxt->atlSTAClients[STAid]->snrIdx;
11773 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
11774 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
11775 }
11776 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
11777 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
11778
11779 return VOS_STATUS_SUCCESS;
11780}
Jeff Johnson295189b2012-06-20 16:38:30 -070011781
11782/*
11783 DESCRIPTION
11784 TL returns the weight currently maintained in TL.
11785 IN
11786 pvosGCtx: pointer to the global vos context; a handle to TL's
11787 or SME's control block can be extracted from its context
11788
11789 OUT
11790 pACWeights: Caller allocated memory for filling in weights
11791
11792 RETURN VALUE VOS_STATUS
11793*/
11794VOS_STATUS
11795WLANTL_GetACWeights
11796(
11797 v_PVOID_t pvosGCtx,
11798 v_U8_t* pACWeights
11799)
11800{
11801 WLANTL_CbType* pTLCb = NULL;
11802 v_U8_t ucIndex;
11803 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11804
11805 /*------------------------------------------------------------------------
11806 Sanity check
11807 ------------------------------------------------------------------------*/
11808 if ( NULL == pACWeights )
11809 {
11810 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11811 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11812 return VOS_STATUS_E_INVAL;
11813 }
11814
11815 /*------------------------------------------------------------------------
11816 Extract TL control block and check existance
11817 ------------------------------------------------------------------------*/
11818 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11819 if ( NULL == pTLCb )
11820 {
11821 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11822 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11823 return VOS_STATUS_E_FAULT;
11824 }
11825 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11826 {
11827 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
11828 }
11829
11830 return VOS_STATUS_SUCCESS;
11831}
11832
11833
11834
11835/*
11836 DESCRIPTION
11837 Change the weight currently maintained by TL.
11838 IN
11839 pvosGCtx: pointer to the global vos context; a handle to TL's
11840 or SME's control block can be extracted from its context
11841 pACWeights: Caller allocated memory contain the weights to use
11842
11843
11844 RETURN VALUE VOS_STATUS
11845*/
11846VOS_STATUS
11847WLANTL_SetACWeights
11848(
11849 v_PVOID_t pvosGCtx,
11850 v_U8_t* pACWeights
11851)
11852{
11853 WLANTL_CbType* pTLCb = NULL;
11854 v_U8_t ucIndex;
11855 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11856
11857 /*------------------------------------------------------------------------
11858 Sanity check
11859 ------------------------------------------------------------------------*/
11860 if ( NULL == pACWeights )
11861 {
11862 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11863 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
11864 return VOS_STATUS_E_INVAL;
11865 }
11866
11867 /*------------------------------------------------------------------------
11868 Extract TL control block and check existance
11869 ------------------------------------------------------------------------*/
11870 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11871 if ( NULL == pTLCb )
11872 {
11873 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11874 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
11875 return VOS_STATUS_E_FAULT;
11876 }
11877 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
11878 {
11879 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
11880 }
11881
11882 return VOS_STATUS_SUCCESS;
11883}
11884
11885
11886/*==========================================================================
11887
11888 FUNCTION
11889
11890 DESCRIPTION
11891
11892 PARAMETERS
11893
11894 RETURN VALUE
11895
11896============================================================================*/
11897void WLANTL_PowerStateChangedCB
11898(
11899 v_PVOID_t pAdapter,
11900 tPmcState newState
11901)
11902{
11903 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11904
11905 if (NULL == tlCtxt)
11906 {
11907 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011908 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070011909 return;
11910 }
11911
11912 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
11913 switch(newState)
11914 {
11915 case FULL_POWER:
11916 tlCtxt->isBMPS = VOS_FALSE;
11917 break;
11918
11919 case BMPS:
11920#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11921 WLANTL_SetFWRSSIThresholds(pAdapter);
11922#endif
11923
11924 tlCtxt->isBMPS = VOS_TRUE;
11925 break;
11926
11927 case IMPS:
11928 case LOW_POWER:
11929 case REQUEST_BMPS:
11930 case REQUEST_FULL_POWER:
11931 case REQUEST_IMPS:
11932 case STOPPED:
11933 case REQUEST_START_UAPSD:
11934 case REQUEST_STOP_UAPSD:
11935 case UAPSD:
11936 case REQUEST_STANDBY:
11937 case STANDBY:
11938 case REQUEST_ENTER_WOWL:
11939 case REQUEST_EXIT_WOWL:
11940 case WOWL:
11941 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
11942 break;
11943
11944 default:
11945 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
11946 break;
11947 }
11948
11949 return;
11950}
11951/*==========================================================================
11952 FUNCTION WLANTL_GetEtherType
11953
11954 DESCRIPTION Extract Ether type information from the BD
11955
11956 DEPENDENCIES NONE
11957
11958 PARAMETERS in aucBDHeader - BD header
11959 in vosDataBuff - data buffer
11960 in ucMPDUHLen - MPDU header length
11961 out pUsEtherType - pointer to Ethertype
11962
11963 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
11964 VOS_STATUS_FAILURE : if the EtherType extraction failed and
11965 the packet was dropped
11966
11967 SIDE EFFECTS NONE
11968
11969============================================================================*/
11970static VOS_STATUS WLANTL_GetEtherType
11971(
11972 v_U8_t * aucBDHeader,
11973 vos_pkt_t * vosDataBuff,
11974 v_U8_t ucMPDUHLen,
11975 v_U16_t * pUsEtherType
11976)
11977{
11978 v_U8_t ucOffset;
11979 v_U16_t usEtherType = *pUsEtherType;
11980 v_SIZE_t usLLCSize = sizeof(usEtherType);
11981 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11982
11983 /*------------------------------------------------------------------------
11984 Check if LLC is present - if not, TL is unable to determine type
11985 ------------------------------------------------------------------------*/
11986 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
11987 {
11988 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
11989 }
11990 else
11991 {
11992 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
11993 }
11994
11995 /*------------------------------------------------------------------------
11996 Extract LLC type
11997 ------------------------------------------------------------------------*/
11998 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
11999 (v_PVOID_t)&usEtherType, &usLLCSize);
12000
12001 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12002 ( sizeof(usEtherType) != usLLCSize ))
12003
12004 {
12005 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12006 "WLAN TL:Error extracting Ether type from data packet"));
12007 /* Drop packet */
12008 vos_pkt_return_packet(vosDataBuff);
12009 vosStatus = VOS_STATUS_E_FAILURE;
12010 }
12011 else
12012 {
12013 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12014 "WLAN TL:Ether type retrieved before endianess conv: %d",
12015 usEtherType));
12016
12017 usEtherType = vos_be16_to_cpu(usEtherType);
12018 *pUsEtherType = usEtherType;
12019
12020 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12021 "WLAN TL:Ether type retrieved: %d", usEtherType));
12022 }
12023
12024 return vosStatus;
12025}
12026
Jeff Johnson295189b2012-06-20 16:38:30 -070012027/*==========================================================================
12028 FUNCTION WLANTL_GetSoftAPStatistics
12029
12030 DESCRIPTION Collect the cumulative statistics for all Softap stations
12031
12032 DEPENDENCIES NONE
12033
12034 PARAMETERS in pvosGCtx - Pointer to the global vos context
12035 bReset - If set TL statistics will be cleared after reading
12036 out statsSum - pointer to collected statistics
12037
12038 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12039
12040 SIDE EFFECTS NONE
12041
12042============================================================================*/
12043VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12044{
12045 v_U8_t i = 0;
12046 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12047 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12048 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12049 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12050 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12051
12052
12053 if ( NULL == pTLCb )
12054 {
12055 return VOS_STATUS_E_FAULT;
12056 }
12057
12058 // Sum up all the statistics for stations of Soft AP from TL
12059 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12060 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012061 if ( NULL == pTLCb->atlSTAClients[i])
12062 {
12063 continue;
12064 }
12065 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 {
12067 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12068
12069 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12070 return VOS_STATUS_E_FAULT;
12071
12072 // Add to the counters
12073 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12074 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12075 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12076 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12077 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12078 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12079 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12080 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12081 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12082 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12083 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12084 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12085
12086 if (bReset)
12087 {
12088 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12089 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12090 return VOS_STATUS_E_FAULT;
12091 }
12092 }
12093 }
12094
12095 return vosStatus;
12096}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012097#ifdef FEATURE_WLAN_TDLS_INTERNAL
12098/*==========================================================================
12099 FUNCTION WLANTL_GetEtherType_2
12100
12101 DESCRIPTION Extract Ether type information from the BD
12102
12103 DEPENDENCIES NONE
12104
12105 PARAMETERS in aucBDHeader - BD header
12106 in vosDataBuff - data buffer
12107 in ucMPDUHLen - MPDU header length
12108 out pUsEtherType - pointer to Ethertype
12109
12110 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12111 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12112 the packet was dropped
12113
12114 SIDE EFFECTS NONE
12115
12116============================================================================*/
12117static VOS_STATUS WLANTL_GetEtherType_2
12118(
12119 v_U8_t * aucBDHeader,
12120 vos_pkt_t * vosDataBuff,
12121 v_U8_t ucMPDUHLen,
12122 v_U16_t * pUsEtherType
12123)
12124{
12125 v_U8_t ucOffset;
12126 v_U16_t usEtherType = *pUsEtherType;
12127 v_SIZE_t usLLCSize = sizeof(usEtherType);
12128 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12129 //v_U8_t ucLLCHeader;
12130 v_U8_t ucMPDUHOffset ;
12131 /*------------------------------------------------------------------------
12132 Check if LLC is present - if not, TL is unable to determine type
12133 ------------------------------------------------------------------------*/
12134 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12135 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12136 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12137
12138 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12139 {
12140 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12141 }
12142 else
12143 {
12144 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12145 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12146 }
12147
12148 /*------------------------------------------------------------------------
12149 Extract LLC type
12150 ------------------------------------------------------------------------*/
12151 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12152 (v_PVOID_t)&usEtherType, &usLLCSize);
12153
12154 /* TODO: Do it in better way */
12155 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12156 {
12157 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -080012158 ("TDLS frame llc %x"), vos_be16_to_cpu(usEtherType)) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012159 }
12160
12161 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12162 "WLAN TL:Ether type retrieved before endianess conv: %d",
12163 usEtherType);
12164
12165 usEtherType = vos_be16_to_cpu(usEtherType);
12166 *pUsEtherType = usEtherType;
12167
12168 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12169 "WLAN TL:Ether type retrieved: %d", usEtherType);
12170
12171 return vosStatus;
12172}
12173#endif /* FEATURE_WLAN_TDLS */
12174
Jeff Johnson295189b2012-06-20 16:38:30 -070012175/*===============================================================================
12176 FUNCTION WLANTL_IsReplayPacket
12177
12178 DESCRIPTION This function does replay check for valid stations
12179
12180 DEPENDENCIES Validity of replay check must be done before the function
12181 is called
12182
12183 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12184 previousReplayCounter previous replay counter taken from TL CB
12185
12186 RETRUN VOS_TRUE packet is a replay packet
12187 VOS_FALSE packet is not a replay packet
12188
12189 SIDE EFFECTS none
12190 ===============================================================================*/
12191v_BOOL_t
12192WLANTL_IsReplayPacket
12193(
12194 v_U64_t ullcurrentReplayCounter,
12195 v_U64_t ullpreviousReplayCounter
12196)
12197{
12198 /* Do the replay check by comparing previous received replay counter with
12199 current received replay counter*/
12200 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12201 {
12202 /* Valid packet not replay */
12203 return VOS_FALSE;
12204 }
12205 else
12206 {
12207
12208 /* Current packet number is less than or equal to previuos received
12209 packet no, this means current packet is replay packet */
12210 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12211 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12212
12213 return VOS_TRUE;
12214 }
12215}
12216
12217#if 0
12218/*===============================================================================
12219 FUNCTION WLANTL_GetReplayCounterFromRxBD
12220
12221 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12222
12223 DEPENDENCIES Validity of replay check must be done before the function
12224 is called
12225
12226 PARAMETERS pucRxHeader pointer to RX BD header
12227
12228 RETRUN v_U64_t Packet number extarcted from RX BD
12229
12230 SIDE EFFECTS none
12231 ===============================================================================*/
12232v_U64_t
12233WLANTL_GetReplayCounterFromRxBD
12234(
12235 v_U8_t *pucRxBDHeader
12236)
12237{
12238/* 48-bit replay counter is created as follows
12239 from RX BD 6 byte PMI command:
12240 Addr : AES/TKIP
12241 0x38 : pn3/tsc3
12242 0x39 : pn2/tsc2
12243 0x3a : pn1/tsc1
12244 0x3b : pn0/tsc0
12245
12246 0x3c : pn5/tsc5
12247 0x3d : pn4/tsc4 */
12248
12249#ifdef ANI_BIG_BYTE_ENDIAN
12250 v_U64_t ullcurrentReplayCounter = 0;
12251 /* Getting 48-bit replay counter from the RX BD */
12252 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12253 ullcurrentReplayCounter <<= 16;
12254 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12255 return ullcurrentReplayCounter;
12256#else
12257 v_U64_t ullcurrentReplayCounter = 0;
12258 /* Getting 48-bit replay counter from the RX BD */
12259 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12260 ullcurrentReplayCounter <<= 32;
12261 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12262 return ullcurrentReplayCounter;
12263#endif
12264}
12265#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012266
12267/*===============================================================================
12268 FUNCTION WLANTL_PostResNeeded
12269
12270 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12271
12272 DEPENDENCIES None
12273
12274 PARAMETERS pvosGCtx
12275
12276 RETURN None
12277
12278 SIDE EFFECTS none
12279 ===============================================================================*/
12280
12281void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12282{
12283 vos_msg_t vosMsg;
12284
12285 vosMsg.reserved = 0;
12286 vosMsg.bodyptr = NULL;
12287 vosMsg.type = WLANTL_TX_RES_NEEDED;
12288 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12289 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12290 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12291 {
12292 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012293 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 }
12295}
12296
12297/*===============================================================================
12298 FUNCTION WLANTL_UpdateRssiBmps
12299
12300 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12301
12302 DEPENDENCIES None
12303
12304 PARAMETERS
12305
12306 pvosGCtx VOS context VOS Global context
12307 staId Station ID Station ID
12308 rssi RSSI (BMPS mode) RSSI in BMPS mode
12309
12310 RETURN None
12311
12312 SIDE EFFECTS none
12313 ===============================================================================*/
12314
12315void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12316{
12317 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12318
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012319 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012321 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 }
12323}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012324
12325/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012326 FUNCTION WLANTL_UpdateSnrBmps
12327
12328 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
12329
12330 DEPENDENCIES None
12331
12332 PARAMETERS
12333
12334 pvosGCtx VOS context VOS Global context
12335 staId Station ID Station ID
12336 snr SNR (BMPS mode) SNR in BMPS mode
12337
12338 RETURN None
12339
12340 SIDE EFFECTS none
12341 ===============================================================================*/
12342
12343void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
12344{
12345 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12346
12347 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12348 {
12349 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
12350 }
12351}
12352
12353/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012354 FUNCTION WLANTL_UpdateLinkCapacity
12355
12356 DESCRIPTION This function updates the STA's Link Capacity in TL
12357
12358 DEPENDENCIES None
12359
12360 PARAMETERS
12361
12362 pvosGCtx VOS context VOS Global context
12363 staId Station ID Station ID
12364 linkCapacity linkCapacity Link Capacity
12365
12366 RETURN None
12367
12368 SIDE EFFECTS none
12369 ===============================================================================*/
12370
12371void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12372{
12373 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12374
12375 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12376 {
12377 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12378 }
12379}
12380
12381
12382/*===========================================================================
12383
12384 FUNCTION WLANTL_GetSTALinkCapacity
12385
12386 DESCRIPTION
12387
12388 Returns Link Capacity of a particular STA.
12389
12390 DEPENDENCIES
12391
12392 A station must have been registered before its state can be retrieved.
12393
12394
12395 PARAMETERS
12396
12397 IN
12398 pvosGCtx: pointer to the global vos context; a handle to TL's
12399 control block can be extracted from its context
12400 ucSTAId: identifier of the station
12401
12402 OUT
12403 plinkCapacity: the current link capacity the connection to
12404 the given station
12405
12406
12407 RETURN VALUE
12408
12409 The result code associated with performing the operation
12410
12411 VOS_STATUS_E_INVAL: Input parameters are invalid
12412 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12413 TL cb is NULL ; access would cause a page fault
12414 VOS_STATUS_E_EXISTS: Station was not registered
12415 VOS_STATUS_SUCCESS: Everything is good :)
12416
12417 SIDE EFFECTS
12418
12419============================================================================*/
12420VOS_STATUS
12421WLANTL_GetSTALinkCapacity
12422(
12423 v_PVOID_t pvosGCtx,
12424 v_U8_t ucSTAId,
12425 v_U32_t *plinkCapacity
12426)
12427{
12428 WLANTL_CbType* pTLCb = NULL;
12429 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12430
12431 /*------------------------------------------------------------------------
12432 Sanity check
12433 ------------------------------------------------------------------------*/
12434 if ( NULL == plinkCapacity )
12435 {
12436 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12437 FL("WLAN TL:Invalid parameter")));
12438 return VOS_STATUS_E_INVAL;
12439 }
12440
12441 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12442 {
12443 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12444 FL("WLAN TL:Invalid station id")));
12445 return VOS_STATUS_E_FAULT;
12446 }
12447
12448 /*------------------------------------------------------------------------
12449 Extract TL control block and check existance
12450 ------------------------------------------------------------------------*/
12451 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12452 if ( NULL == pTLCb )
12453 {
12454 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12455 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12456 return VOS_STATUS_E_FAULT;
12457 }
12458
12459 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12460 {
12461 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12462 FL("WLAN TL:Client Memory was not allocated")));
12463 return VOS_STATUS_E_FAILURE;
12464 }
12465
12466 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12467 {
12468 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12469 FL("WLAN TL:Station was not previously registered")));
12470 return VOS_STATUS_E_EXISTS;
12471 }
12472
12473 /*------------------------------------------------------------------------
12474 Get STA state
12475 ------------------------------------------------------------------------*/
12476 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12477
12478 return VOS_STATUS_SUCCESS;
12479}/* WLANTL_GetSTALinkCapacity */