blob: a8e8d4f8e168714e47de3abf33bdc4fbc4f1d303 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam1ed83fc2014-02-19 01:15:45 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/*===========================================================================
32
33
34 W L A N _ Q C T _ T L . C
35
36 OVERVIEW:
37
38 This software unit holds the implementation of the WLAN Transport Layer.
39
40 The functions externalized by this module are to be called ONLY by other
41 WLAN modules that properly register with the Transport Layer initially.
42
43 DEPENDENCIES:
44
45 Are listed for each API below.
46
47
Kiet Lamaa8e15a2014-02-11 23:30:06 -080048 Copyright (c) 2008 QUALCOMM Incorporated.
49 All Rights Reserved.
50 Qualcomm Confidential and Proprietary
Jeff Johnson295189b2012-06-20 16:38:30 -070051===========================================================================*/
52
53/*===========================================================================
54
55 EDIT HISTORY FOR FILE
56
57
58 This section contains comments describing changes made to the module.
59 Notice that changes are listed in reverse chronological order.
60
61
62 $Header$$DateTime$$Author$
63
64
65 when who what, where, why
66---------- --- --------------------------------------------------------
672010-07-13 c_shinde Fixed an issue where WAPI rekeying was failing because
68 WAI frame sent out during rekeying had the protected bit
69 set to 1.
702010-05-06 rnair Changed name of variable from usLlcType to usEtherType
71 Changed function name from GetLLCType to GetEtherType
72 Fixed 802.3 to 802.11 frame translation issue where two
73 bytes of the LLC header was getting overwritten in the
74 non-Qos path
752010-05-06 rnair RxAuth path fix for modifying the header before ether
76 type is retreived (Detected while testing rekeying
77 in WAPI Volans)
782010-02-19 bad Fixed 802.11 to 802.3 ft issues with WAPI
792010-02-19 rnair WAPI: If frame is a WAI frame in TxConn and TxAuth, TL
80 does frame translation.
812010-02-01 rnair WAPI: Fixed a bug where the value of ucIsWapiSta was not
82 being set in the TL control block in the RegisterSTA func.
832010-01-08 lti Added TL Data Caching
842009-11-04 rnair WAPI: Moving common functionality to a seperate function
85 called WLANTL_GetLLCType
862009-10-15 rnair WAPI: Featurizing WAPI code
872009-10-09 rnair WAPI: Modifications to authenticated state handling of Rx data
882009-10-06 rnair Adding support for WAPI
892009-09-22 lti Add deregistration API for management client
902009-07-16 rnair Temporary fix to let TL fetch packets when multiple
91 peers exist in an IBSS
922009-06-10 lti Fix for checking TID value of meta info on TX - prevent
93 memory overwrite
94 Fix for properly checking the sta id for resuming trigger
95 frame generation
962009-05-14 lti Fix for sending out trigger frames
972009-05-15 lti Addr3 filtering
982009-04-13 lti Assert if packet larger then allowed
99 Drop packet that fails flatten
1002009-04-02 lti Performance fixes for TL
1012009-02-19 lti Added fix for LLC management on Rx Connect
1022009-01-16 lti Replaced peek data with extract data for non BD opertions
103 Extracted frame control in Tl and pass to HAL for frame
104 type evaluation
1052009-02-02 sch Add handoff support
1062008-12-09 lti Fixes for AMSS compilation
107 Removed assert on receive when there is no station
1082008-12-02 lti Fix fo trigger frame generation
1092008-10-31 lti Fix fo TL tx suspend
1102008-10-01 lti Merged in fixes from reordering
111 Disabled part of UAPSD functionality in TL
112 (will be re-enabled once UAPSD is tested)
113 Fix for UAPSD multiple enable
1142008-08-10 lti Fixes following UAPSD testing
115 Fixed infinite loop on mask computation when STA no reg
1162008-08-06 lti Fixes after QOS unit testing
1172008-08-06 lti Added QOS support
1182008-07-23 lti Fix for vos packet draining
1192008-07-17 lti Fix for data type value
120 Added frame translation code in TL
121 Avoid returning failure to PE in case previous frame is
122 still pending; fail previous and cache new one for tx
123 Get frames returning boolean true if more frames are pending
1242008-07-03 lti Fixes following pre-integration testing
1252008-06-26 lti Fixes following unit testing
126 Added alloc and free for TL context
127 Using atomic set u8 instead of u32
1282008-05-16 lti Created module
129
130===========================================================================*/
131
132/*----------------------------------------------------------------------------
133 * Include Files
134 * -------------------------------------------------------------------------*/
135#include "wlan_qct_tl.h"
136#include "wlan_qct_wda.h"
137#include "wlan_qct_tli.h"
138#include "wlan_qct_tli_ba.h"
139#include "wlan_qct_tl_hosupport.h"
Katya Nigam42e16e82014-02-04 16:28:55 +0530140#include "vos_types.h"
141#include "vos_trace.h"
142#include "wlan_qct_tl_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700143#include "tlDebug.h"
144#ifdef FEATURE_WLAN_WAPI
145/*Included to access WDI_RxBdType */
146#include "wlan_qct_wdi_bd.h"
147#endif
148/*Enables debugging behavior in TL*/
149#define TL_DEBUG
Hoonki Lee14621352013-04-16 17:51:19 -0700150/*Enables debugging FC control frame in TL*/
151//#define TL_DEBUG_FC
Jeff Johnson295189b2012-06-20 16:38:30 -0700152//#define WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -0700153//#define BTAMP_TEST
Hoonki Lee14621352013-04-16 17:51:19 -0700154#ifdef TL_DEBUG_FC
155#include <wlan_qct_pal_status.h>
156#include <wlan_qct_pal_device.h> // wpalReadRegister
157#endif
158
Jeff Johnson295189b2012-06-20 16:38:30 -0700159/*----------------------------------------------------------------------------
160 * Preprocessor Definitions and Constants
161 * -------------------------------------------------------------------------*/
162/*LLC header value*/
163static v_U8_t WLANTL_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
164
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800165#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700166/*Aironet SNAP header value*/
167static v_U8_t WLANTL_AIRONET_SNAP_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800168#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700169
170/*BT-AMP packet LLC OUI value*/
171const v_U8_t WLANTL_BT_AMP_OUI[] = {0x00, 0x19, 0x58 };
172
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530173#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700174
175#ifdef VOLANS_PERF
176#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
177#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
178
179/* TL BD/PDU threshold to enable interrupt */
180int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
181int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
182#endif /* VOLANS_PERF */
183
184/*-----------------------------------*
185 | Type(2b) | Sub-type(4b) |
186 *-----------------------------------*/
187#define WLANTL_IS_DATA_FRAME(_type_sub) \
188 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
189
190#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
191 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
192 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
193
194#define WLANTL_IS_MGMT_FRAME(_type_sub) \
195 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
196
197#define WLANTL_IS_CTRL_FRAME(_type_sub) \
198 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
199
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800200#ifdef FEATURE_WLAN_TDLS
201#define WLANTL_IS_TDLS_FRAME(_eth_type) \
202 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
203#endif
204
Jeff Johnson295189b2012-06-20 16:38:30 -0700205/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800206#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208#define WLANTL_MASK_AC 0x03
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210//some flow_control define
211//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
212#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
213
214//Get enough sample to do the LWM related calculation
215#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
216
217//Maximal on-fly packet per station in LWM mode
218#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
219
220#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800221#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222
223/* UINT32 type endian swap */
224#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
225 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
226
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530227/* Maximum value of SNR that can be calculated by the HW */
228#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700229
Jeff Johnson295189b2012-06-20 16:38:30 -0700230/*----------------------------------------------------------------------------
231 * Type Declarations
232 * -------------------------------------------------------------------------*/
233#define TL_LITTLE_BIT_ENDIAN
234
235typedef struct
236{
237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239 v_U8_t protVer :2;
240 v_U8_t type :2;
241 v_U8_t subType :4;
242
243 v_U8_t toDS :1;
244 v_U8_t fromDS :1;
245 v_U8_t moreFrag :1;
246 v_U8_t retry :1;
247 v_U8_t powerMgmt :1;
248 v_U8_t moreData :1;
249 v_U8_t wep :1;
250 v_U8_t order :1;
251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253} WLANTL_MACFCType;
254
255/* 802.11 header */
256typedef struct
257{
258 /* Frame control field */
259 WLANTL_MACFCType wFrmCtrl;
260
261 /* Duration ID */
262 v_U16_t usDurationId;
263
264 /* Address 1 field */
265 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
266
267 /* Address 2 field */
268 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
269
270 /* Address 3 field */
271 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
272
273 /* Sequence control field */
274 v_U16_t usSeqCtrl;
275
276 // Find the size of the mandatory header size.
277#define WLAN80211_MANDATORY_HEADER_SIZE \
278 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
279 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
280 sizeof(v_U16_t))
281
282 /* Optional A4 address */
283 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
284
285 /* Optional QOS control field */
286 v_U16_t usQosCtrl;
287}WLANTL_80211HeaderType;
288
289/* 802.3 header */
290typedef struct
291{
292 /* Destination address field */
293 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
294
295 /* Source address field */
296 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
297
298 /* Length field */
299 v_U16_t usLenType;
300}WLANTL_8023HeaderType;
301
302/*----------------------------------------------------------------------------
303 * Global Data Definitions
304 * -------------------------------------------------------------------------*/
305#define WLAN_TL_INVALID_U_SIG 255
306#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530307#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
310 do\
311 {\
312 _ucACMask = 0; \
313 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
314 { \
315 if ( 0 != (_pSTA)->aucACMask[i] ) \
316 { \
317 _ucACMask |= ( 1 << i ); \
318 } \
319 } \
320 } while (0);
321
322/*----------------------------------------------------------------------------
323 * Static Variable Definitions
324 * -------------------------------------------------------------------------*/
325
326/*----------------------------------------------------------------------------
327 * Static Function Declarations and Definitions
328 * -------------------------------------------------------------------------*/
329
330static VOS_STATUS
331WLANTL_GetEtherType
332(
333 v_U8_t * aucBDHeader,
334 vos_pkt_t * vosDataBuff,
335 v_U8_t ucMPDUHLen,
336 v_U16_t * usEtherType
337);
338
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800339#ifdef FEATURE_WLAN_TDLS_INTERNAL
340/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
341But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
342wherease TDLS expect vosDataBuff->offset should still points to RxBd.
343So far, data frmae stripped RxBD and passed to data frame handler.
344(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
345handler, where RX BD should be preserved)
346To avoid breaking existing functionality, for now, I temporarily rename to
347WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
348*/
349static VOS_STATUS
350WLANTL_GetEtherType_2
351(
352 v_U8_t * aucBDHeader,
353 vos_pkt_t * vosDataBuff,
354 v_U8_t ucMPDUHLen,
355 v_U16_t * usEtherType
356);
357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700358#ifdef FEATURE_WLAN_WAPI
359/*---------------------------------------------------------------------------
360 * Adding a global variable to be used when doing frame translation in TxAuth
361 * state so as to not set the protected bit to 1 in the case of WAI frames
362 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700363v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700364#endif
365
366/*----------------------------------------------------------------------------
367 * Externalized Function Definitions
368* -------------------------------------------------------------------------*/
369
370/*----------------------------------------------------------------------------
371 * Function Declarations and Documentation
372 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530373/*==========================================================================
374
375 FUNCTION WLANTL_FreeClientMemory
376
377 DESCRIPTION
378 It frees up the memory allocated to all the STA clients in TLCB block
379 Can be called inside Close, Stop or when some FAULT occurs
380
381 DEPENDENCIES
382
383 PARAMETERS
384
385 IN
386 pClientSTA: Pointer to the global client pointer array
387
388 RETURN VALUE
389
390 SIDE EFFECTS
391
392============================================================================*/
393void WLANTL_FreeClientMemory
394(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
395{
396 v_U32_t i = 0;
397 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
398 {
399 if( NULL != pClientSTA[i] )
400 {
401 vos_mem_free(pClientSTA[i]);
402 }
403 pClientSTA[i] = NULL;
404 }
405 return;
406}
Jeff Johnson295189b2012-06-20 16:38:30 -0700407
408/*==========================================================================
409
410 FUNCTION WLANTL_Open
411
412 DESCRIPTION
413 Called by HDD at driver initialization. TL will initialize all its
414 internal resources and will wait for the call to start to register
415 with the other modules.
416
417 DEPENDENCIES
418
419 PARAMETERS
420
421 IN
422 pvosGCtx: pointer to the global vos context; a handle to TL's
423 control block can be extracted from its context
424 pTLConfig: TL Configuration
425
426 RETURN VALUE
427 The result code associated with performing the operation
428
429 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
430 fault
431 VOS_STATUS_SUCCESS: Everything is good :)
432
433 SIDE EFFECTS
434
435============================================================================*/
436VOS_STATUS
437WLANTL_Open
438(
439 v_PVOID_t pvosGCtx,
440 WLANTL_ConfigInfoType* pTLConfig
441)
442{
443 WLANTL_CbType* pTLCb = NULL;
444 v_U8_t ucIndex;
445 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530446 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700447#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
448 VOS_STATUS status = VOS_STATUS_SUCCESS;
449#endif
450 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
451
452 /*------------------------------------------------------------------------
453 Sanity check
454 Extract TL control block
455 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530456 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
458 (void*)&pTLCb, sizeof(WLANTL_CbType));
459
460 pTLCb = VOS_GET_TL_CB(pvosGCtx);
461 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
462 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700463 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530464 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 return VOS_STATUS_E_FAULT;
466 }
467
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700468 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
469 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
470
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
472 if ( NULL == smeContext )
473 {
474 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700475 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 return VOS_STATUS_E_FAULT;
477 }
478
479 /* Zero out the memory so we are OK, when CleanCB is called.*/
480 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
481
482 /*------------------------------------------------------------------------
483 Clean up TL control block, initialize all values
484 ------------------------------------------------------------------------*/
485 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
486 "WLAN TL:WLANTL_Open"));
487
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530488 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530490 if ( i < WLAN_NON32_STA_COUNT )
491 {
492 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
493 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
494 if ( NULL == pTLCb->atlSTAClients[i] )
495 {
496 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
497 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
498 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
499 return VOS_STATUS_E_FAULT;
500 }
501 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
502 }
503 else
504 {
505 pTLCb->atlSTAClients[i] = NULL;
506 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 }
508
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
510 if (NULL == pTLCb->reorderBufferPool)
511 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800512 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 +0530513 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
515 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 }
517
518 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
519
520 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
521
522 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
523 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530524 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 }
526
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800527 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
528 {
529 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
530 }
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 // scheduling init to be the last one of previous round
533 pTLCb->uCurServedAC = WLANTL_AC_BK;
534 pTLCb->ucCurLeftWeight = 1;
535 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
536
537#if 0
538 //flow control field init
539 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
540 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
541 pTLCb->tlFCInfo.fcConfig = 0x1;
542#endif
543
544 pTLCb->vosTxFCBuf = NULL;
545 pTLCb->tlConfigInfo.uMinFramesProcThres =
546 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
Sunil Ravid5406f22013-01-22 00:18:31 -0800548#ifdef FEATURE_WLAN_TDLS
549 pTLCb->ucTdlsPeerCount = 0;
550#endif
551
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
553 pTLConfig->uDelayedTriggerFrmInt;
554
555 /*------------------------------------------------------------------------
556 Allocate internal resources
557 ------------------------------------------------------------------------*/
558 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
559 1/*true*/,NULL, NULL);
560
561 WLANTL_InitBAReorderBuffer(pvosGCtx);
562#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
563 /* Initialize Handoff support modue
564 * RSSI measure and Traffic state monitoring */
565 status = WLANTL_HSInit(pvosGCtx);
566 if(!VOS_IS_STATUS_SUCCESS(status))
567 {
568 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
569 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530570 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 vos_mem_free(pTLCb->reorderBufferPool);
572 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
573 return status;
574 }
575#endif
576
577 pTLCb->isBMPS = VOS_FALSE;
578 pmcRegisterDeviceStateUpdateInd( smeContext,
579 WLANTL_PowerStateChangedCB, pvosGCtx );
580
581 return VOS_STATUS_SUCCESS;
582}/* WLANTL_Open */
583
584/*==========================================================================
585
586 FUNCTION WLANTL_Start
587
588 DESCRIPTION
589 Called by HDD as part of the overall start procedure. TL will use this
590 call to register with BAL as a transport layer entity.
591
592 DEPENDENCIES
593
594 PARAMETERS
595
596 IN
597 pvosGCtx: pointer to the global vos context; a handle to TL's
598 control block can be extracted from its context
599
600 RETURN VALUE
601 The result code associated with performing the operation
602
603 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
604 fault
605 VOS_STATUS_SUCCESS: Everything is good :)
606
607 Other codes can be returned as a result of a BAL failure; see BAL API
608 for more info
609
610 SIDE EFFECTS
611
612============================================================================*/
613VOS_STATUS
614WLANTL_Start
615(
616 v_PVOID_t pvosGCtx
617)
618{
619 WLANTL_CbType* pTLCb = NULL;
620 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
621 VOS_STATUS vosStatus;
622 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
623
624 /*------------------------------------------------------------------------
625 Sanity check
626 Extract TL control block
627 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530628 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 pTLCb = VOS_GET_TL_CB(pvosGCtx);
630 if ( NULL == pTLCb )
631 {
632 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
633 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
634 return VOS_STATUS_E_FAULT;
635 }
636
637 /*------------------------------------------------------------------------
638 Register with WDA as transport layer client
639 Request resources for tx from bus
640 ------------------------------------------------------------------------*/
641 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
642 "WLAN TL:WLAN TL:WLANTL_Start"));
643
Katya Nigam42e16e82014-02-04 16:28:55 +0530644 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 vosStatus = WDA_DS_Register( pvosGCtx,
646 WLANTL_TxComp,
647 WLANTL_RxFrames,
648 WLANTL_GetFrames,
649 WLANTL_ResourceCB,
650 WDA_TLI_MIN_RES_DATA,
651 pvosGCtx,
652 &uResCount );
653
654 if ( VOS_STATUS_SUCCESS != vosStatus )
655 {
656 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
657 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
658 vosStatus));
659 return vosStatus;
660 }
661
662 /* Enable transmission */
663 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
664
665 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 return VOS_STATUS_SUCCESS;
667}/* WLANTL_Start */
668
669/*==========================================================================
670
671 FUNCTION WLANTL_Stop
672
673 DESCRIPTION
674 Called by HDD to stop operation in TL, before close. TL will suspend all
675 frame transfer operation and will wait for the close request to clean up
676 its resources.
677
678 DEPENDENCIES
679
680 PARAMETERS
681
682 IN
683 pvosGCtx: pointer to the global vos context; a handle to TL's
684 control block can be extracted from its context
685
686 RETURN VALUE
687 The result code associated with performing the operation
688
689 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
690 fault
691 VOS_STATUS_SUCCESS: Everything is good :)
692
693 SIDE EFFECTS
694
695============================================================================*/
696VOS_STATUS
697WLANTL_Stop
698(
699 v_PVOID_t pvosGCtx
700)
701{
702 WLANTL_CbType* pTLCb = NULL;
703 v_U8_t ucIndex;
704 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
705
706 /*------------------------------------------------------------------------
707 Sanity check
708 Extract TL control block
709 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530710 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 pTLCb = VOS_GET_TL_CB(pvosGCtx);
712 if ( NULL == pTLCb )
713 {
714 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
715 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
716 return VOS_STATUS_E_FAULT;
717 }
718
719 /*------------------------------------------------------------------------
720 Stop TL and empty Station list
721 ------------------------------------------------------------------------*/
722 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
723 "WLAN TL:WLANTL_Stop"));
724
725 /* Disable transmission */
726 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
727
728 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
729 {
730 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
731 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
732 }
733
734 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
735 {
736 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
737 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
738 }
739
740#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
741 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
742 {
743 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
744 "Handoff Support module stop fail"));
745 }
746#endif
747
748 /*-------------------------------------------------------------------------
749 Clean client stations
750 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530751 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530753 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
754 {
755 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 }
758
759
760 return VOS_STATUS_SUCCESS;
761}/* WLANTL_Stop */
762
763/*==========================================================================
764
765 FUNCTION WLANTL_Close
766
767 DESCRIPTION
768 Called by HDD during general driver close procedure. TL will clean up
769 all the internal resources.
770
771 DEPENDENCIES
772
773 PARAMETERS
774
775 IN
776 pvosGCtx: pointer to the global vos context; a handle to TL's
777 control block can be extracted from its context
778
779 RETURN VALUE
780 The result code associated with performing the operation
781
782 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
783 fault
784 VOS_STATUS_SUCCESS: Everything is good :)
785
786 SIDE EFFECTS
787
788============================================================================*/
789VOS_STATUS
790WLANTL_Close
791(
792 v_PVOID_t pvosGCtx
793)
794{
795 WLANTL_CbType* pTLCb = NULL;
796 tHalHandle smeContext;
797 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
798
799 /*------------------------------------------------------------------------
800 Sanity check
801 Extract TL control block
802 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530803 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 pTLCb = VOS_GET_TL_CB(pvosGCtx);
805 if ( NULL == pTLCb )
806 {
807 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
808 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
809 return VOS_STATUS_E_FAULT;
810 }
811 /*------------------------------------------------------------------------
812 Deregister from PMC
813 ------------------------------------------------------------------------*/
814 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
815 if ( NULL == smeContext )
816 {
817 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700818 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 // continue so that we can cleanup as much as possible
820 }
821 else
822 {
823 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
824 }
825
826#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
827 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
828 {
829 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
830 "Handoff Support module DeInit fail"));
831 }
832#endif
833
834 /*------------------------------------------------------------------------
835 Cleanup TL control block.
836 ------------------------------------------------------------------------*/
837 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
838 "WLAN TL: WLANTL_Close"));
839 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
840
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530841 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 vos_mem_free(pTLCb->reorderBufferPool);
844
845 /*------------------------------------------------------------------------
846 Free TL context from VOSS global
847 ------------------------------------------------------------------------*/
848 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
849 return VOS_STATUS_SUCCESS;
850}/* WLANTL_Close */
851
852/*----------------------------------------------------------------------------
853 INTERACTION WITH HDD
854 ---------------------------------------------------------------------------*/
855/*==========================================================================
856
857 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
858
859 DESCRIPTION
860 Function to disable/enable frame translation for all association stations.
861
862 DEPENDENCIES
863
864 PARAMETERS
865 IN
866 pvosGCtx: VOS context
867 EnableFrameXlation TRUE means enable SW translation for all stations.
868 .
869
870 RETURN VALUE
871
872 void.
873
874============================================================================*/
875void
876WLANTL_ConfigureSwFrameTXXlationForAll
877(
878 v_PVOID_t pvosGCtx,
879 v_BOOL_t enableFrameXlation
880)
881{
882 v_U8_t ucIndex;
883 /*------------------------------------------------------------------------
884 Extract TL control block
885 ------------------------------------------------------------------------*/
886 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530887 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 if ( NULL == pTLCb )
889 {
890 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
891 "WLAN TL:Invalid TL pointer from pvosGCtx on "
892 "WLANTL_ConfigureSwFrameTXXlationForAll"));
893 return;
894 }
895
896 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
897 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
898 enableFrameXlation));
899
900 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
901 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530902 pClientSTA = pTLCb->atlSTAClients[ucIndex];
903 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 {
905#ifdef WLAN_SOFTAP_VSTA_FEATURE
906 // if this station was not allocated resources to perform HW-based
907 // TX frame translation then force SW-based TX frame translation
908 // otherwise use the frame translation supplied by the client
909 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
910 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530911 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 }
913 else
914#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530915 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
917 }
918}
919
920/*===========================================================================
921
922 FUNCTION WLANTL_StartForwarding
923
924 DESCRIPTION
925
926 This function is used to ask serialization through TX thread of the
927 cached frame forwarding (if statation has been registered in the mean while)
928 or flushing (if station has not been registered by the time)
929
930 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
931 and doesn't need to call this function explicitly. TL will handle this inside
932 WLANTL_RegisterSTAClient().
933
934 In case of flushing, upper layer is required to call this function explicitly
935
936 DEPENDENCIES
937
938 TL must have been initialized before this gets called.
939
940
941 PARAMETERS
942
943 ucSTAId: station id
944
945 RETURN VALUE
946
947 The result code associated with performing the operation
948 Please check return values of vos_tx_mq_serialize.
949
950 SIDE EFFECTS
951 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
952 either WLANTL_RegisterSTAClient() or this function must be called
953 within reasonable time. Otherwise, TL will keep cached vos buffer until
954 one of this function is called, and may end up with system buffer exhasution.
955
956 It's an upper layer's responsibility to call this function in case of
957 flushing
958
959============================================================================*/
960
961VOS_STATUS
962WLANTL_StartForwarding
963(
964 v_U8_t ucSTAId,
965 v_U8_t ucUcastSig,
966 v_U8_t ucBcastSig
967)
968{
969 vos_msg_t sMessage;
970 v_U32_t uData;
971 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
972
973 /* Signal the OS to serialize our event */
974 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
975 "Serializing TL Start Forwarding Cached for control STA %d",
976 ucSTAId );
977
978 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
979
980 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -0800981 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +0530982 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700983
Katya Nigam664f5032014-05-05 12:24:32 +0530984 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986} /* WLANTL_StartForwarding() */
987
988/*===========================================================================
989
Katya Nigam63902932014-06-26 19:04:23 +0530990 FUNCTION WLANTL_EnableCaching
991
992 DESCRIPTION
993
994 This function is used to enable caching only when assoc/reassoc req is send.
995 that is cache packets only for such STA ID.
996
997
998 DEPENDENCIES
999
1000 TL must have been initialized before this gets called.
1001
1002
1003 PARAMETERS
1004
1005 staId: station id
1006
1007 RETURN VALUE
1008
1009 none
1010
1011============================================================================*/
1012void WLANTL_EnableCaching(v_U8_t staId)
1013{
1014 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1015 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1016 if ( NULL == pTLCb )
1017 {
1018 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1019 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1020 "WLANTL_EnableCaching"));
1021 return;
1022 }
1023 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1024}
1025
1026/*===========================================================================
1027
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 FUNCTION WLANTL_AssocFailed
1029
1030 DESCRIPTION
1031
1032 This function is used by PE to notify TL that cache needs to flushed'
1033 when association is not successfully completed
1034
1035 Internally, TL post a message to TX_Thread to serialize the request to
1036 keep lock-free mechanism.
1037
1038
1039 DEPENDENCIES
1040
1041 TL must have been initialized before this gets called.
1042
1043
1044 PARAMETERS
1045
1046 ucSTAId: station id
1047
1048 RETURN VALUE
1049
1050 none
1051
1052 SIDE EFFECTS
1053 There may be race condition that PE call this API and send another association
1054 request immediately with same staId before TX_thread can process the message.
1055
1056 To avoid this, we might need PE to wait for TX_thread process the message,
1057 but this is not currently implemented.
1058
1059============================================================================*/
1060void WLANTL_AssocFailed(v_U8_t staId)
1061{
1062 // flushing frames and forwarding frames uses the same message
1063 // the only difference is what happens when the message is processed
1064 // if the STA exist, the frames will be forwarded
1065 // and if it doesn't exist, the frames will be flushed
1066 // in this case we know it won't exist so the DPU index signature values don't matter
Mihir Sheteae6f02b2014-04-11 19:49:21 +05301067 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1068 staId, 0));
1069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1071 {
1072 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301073 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 }
1075}
1076
1077 /*===========================================================================
1078
1079 FUNCTION WLANTL_Finish_ULA
1080
1081 DESCRIPTION
1082 This function is used by HDD to notify TL to finish Upper layer authentication
1083 incase the last EAPOL packet is pending in the TL queue.
1084 To avoid the race condition between sme set key and the last EAPOL packet
1085 the HDD module calls this function just before calling the sme_RoamSetKey.
1086
1087 DEPENDENCIES
1088
1089 TL must have been initialized before this gets called.
1090
1091 PARAMETERS
1092
1093 callbackRoutine: HDD Callback function.
1094 callbackContext : HDD userdata context.
1095
1096 RETURN VALUE
1097
1098 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1099
1100 SIDE EFFECTS
1101
1102============================================================================*/
1103
1104VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001105 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001106{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001107 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108}
1109
1110
1111/*===========================================================================
1112
1113 FUNCTION WLANTL_RegisterSTAClient
1114
1115 DESCRIPTION
1116
1117 This function is used by HDD to register as a client for data services
1118 with TL. HDD will call this API for each new station that it adds,
1119 thus having the flexibility of registering different callback for each
1120 STA it services.
1121
1122 DEPENDENCIES
1123
1124 TL must have been initialized before this gets called.
1125
1126 Restriction:
1127 Main thread will have higher priority that Tx and Rx threads thus
1128 guaranteeing that a station will be added before any data can be
1129 received for it. (This enables TL to be lock free)
1130
1131 PARAMETERS
1132
1133 pvosGCtx: pointer to the global vos context; a handle to TL's
1134 control block can be extracted from its context
1135 pfnStARx: function pointer to the receive packet handler from HDD
1136 pfnSTATxComp: function pointer to the transmit complete confirmation
1137 handler from HDD
1138 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1139 wSTADescType: STA Descriptor, contains information related to the
1140 new added STA
1141
1142 RETURN VALUE
1143
1144 The result code associated with performing the operation
1145
1146 VOS_STATUS_E_INVAL: Input parameters are invalid
1147 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1148 TL cb is NULL ; access would cause a page fault
1149 VOS_STATUS_E_EXISTS: Station was already registered
1150 VOS_STATUS_SUCCESS: Everything is good :)
1151
1152 SIDE EFFECTS
1153
1154============================================================================*/
1155VOS_STATUS
1156WLANTL_RegisterSTAClient
1157(
1158 v_PVOID_t pvosGCtx,
1159 WLANTL_STARxCBType pfnSTARx,
1160 WLANTL_TxCompCBType pfnSTATxComp,
1161 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1162 WLAN_STADescType* pwSTADescType,
1163 v_S7_t rssi
1164)
1165{
1166 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301167 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1170
1171 /*------------------------------------------------------------------------
1172 Sanity check
1173 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301174 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1176 ( NULL == pfnSTAFetchPkt ))
1177 {
1178 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1179 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1180 return VOS_STATUS_E_INVAL;
1181 }
1182
1183 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1184 {
1185 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1186 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1187 return VOS_STATUS_E_FAULT;
1188 }
1189
1190 /*------------------------------------------------------------------------
1191 Extract TL control block
1192 ------------------------------------------------------------------------*/
1193 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1194 if ( NULL == pTLCb )
1195 {
1196 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1197 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1198 return VOS_STATUS_E_FAULT;
1199 }
1200
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301201 //Code for checking and allocating memory for new STA
1202 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1203 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1204 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1205 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1206 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1207 return VOS_STATUS_E_FAILURE;
1208 }
1209 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1210 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1211 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1212 }
1213
1214 //Assigning the pointer to local variable for easy access in future
1215 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1216 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301218 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1220 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1221 return VOS_STATUS_E_EXISTS;
1222 }
1223
1224 /*------------------------------------------------------------------------
1225 Register station with TL
1226 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301227 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1228 pwSTADescType->ucSTAId, (unsigned )
1229 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1230 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1231 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1232 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1233
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1235 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1236
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301237 pClientSTA->pfnSTARx = pfnSTARx;
1238 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001239
1240 /* Only register if different from NULL - TL default Tx Comp Cb will
1241 release the vos packet */
1242 if ( NULL != pfnSTATxComp )
1243 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301244 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 }
1246
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301247 pClientSTA->tlState = WLANTL_STA_INIT;
1248 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1249 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301250 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001251
1252 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1253 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1254 pwSTADescType->ucSTAId,
1255 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1256
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301257 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301259 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001260
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301261 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001262
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301263 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001264
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001265#ifdef FEATURE_WLAN_ESE
1266 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001267
1268 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001269 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 pwSTADescType->ucSTAId,
1271 pwSTADescType->ucQosEnabled,
1272 pwSTADescType->ucAddRmvLLC,
1273 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001274 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001275#else
1276
1277 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1278 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1279 pwSTADescType->ucSTAId,
1280 pwSTADescType->ucQosEnabled,
1281 pwSTADescType->ucAddRmvLLC,
1282 pwSTADescType->ucProtectedFrame));
1283
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001284#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001285#ifdef WLAN_SOFTAP_VSTA_FEATURE
1286 // if this station was not allocated resources to perform HW-based
1287 // TX frame translation then force SW-based TX frame translation
1288 // otherwise use the frame translation supplied by the client
1289
1290 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1291 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1292 {
1293 pwSTADescType->ucSwFrameTXXlation = 1;
1294 }
1295#endif
1296
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301297 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1298 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001299
1300#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301301 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302#endif /* FEATURE_WLAN_WAPI */
1303
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301304 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301306 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001307
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301308 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301311 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1312 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001313/*Clear replay counters of the STA on all TIDs*/
1314 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1315 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301316 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001318
1319 /*--------------------------------------------------------------------
1320 Set the AC for the registered station to the highest priority AC
1321 Even if this AC is not supported by the station, correction will be
1322 made in the main TL loop after the supported mask is properly
1323 updated in the pending packets call
1324 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301325 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1326 pClientSTA->ucCurrentWeight = 0;
1327 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1328 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001329
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301330 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001331
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301332 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001333
1334 /*--------------------------------------------------------------------
1335 Reordering info and AMSDU de-aggregation
1336 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301337 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1338 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 WLAN_MAX_TID);
1340
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301341 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 WLANTL_MPDU_HEADER_LEN);
1343
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301344 pClientSTA->ucMPDUHeaderLen = 0;
1345 pClientSTA->vosAMSDUChain = NULL;
1346 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001347
1348
Leo Chang6b6faaf2014-01-24 21:21:26 -08001349 /* Reorder LOCK
1350 * During handle normal RX frame within RX thread,
1351 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1352 * Context should be protected from race */
1353 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1354 {
1355 if (!VOS_IS_STATUS_SUCCESS(
1356 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1357 {
1358 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1359 "Lock Init Fail"));
1360 return VOS_STATUS_E_FAILURE;
1361 }
1362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 /*--------------------------------------------------------------------
1364 Stats info
1365 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301366 vos_mem_zero( pClientSTA->auRxCount,
1367 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 WLAN_MAX_TID);
1369
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301370 vos_mem_zero( pClientSTA->auTxCount,
1371 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 WLAN_MAX_TID);
1373 /* Initial RSSI is always reported as zero because TL doesnt have enough
1374 data to calculate RSSI. So to avoid reporting zero, we are initializing
1375 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301376 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001377#ifdef FEATURE_WLAN_TDLS
1378 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1379 {
1380 /* If client is TDLS, use TDLS specific alpha */
1381 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1382 }
1383 else
1384 {
1385 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1386 }
1387#else
1388 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1389#endif /* FEATURE_WLAN_TDLS */
Jeff Johnson295189b2012-06-20 16:38:30 -07001390
1391 /*Tx not suspended and station fully registered*/
1392 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301393 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001394
1395 /* Used until multiple station support will be added*/
1396 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1397
1398 /* Save the BAP station ID for future usage */
1399 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1400 {
1401 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1402 }
1403
1404 /*------------------------------------------------------------------------
1405 Statistics info
1406 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301407 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1409
1410
1411 /*------------------------------------------------------------------------
1412 Start with the state suggested by client caller
1413 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301414 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 /*-----------------------------------------------------------------------
1416 After all the init is complete we can mark the existance flag
1417 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301418 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001419
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301421 pClientSTA->ucLwmModeEnabled = FALSE;
1422 pClientSTA->ucLwmEventReported = FALSE;
1423 pClientSTA->bmuMemConsumed = 0;
1424 pClientSTA->uIngress_length = 0;
1425 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301427 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428
1429 //@@@ HDDSOFTAP does not queue unregistered packet for now
1430 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1431 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 /*------------------------------------------------------------------------
1433 Forward received frames while STA was not yet registered
1434 - ----------------------------------------------------------------------*/
1435 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1436 pwSTADescType->ucUcastSig,
1437 pwSTADescType->ucBcastSig)))
1438 {
1439 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001440 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001442#ifdef FEATURE_WLAN_TDLS
1443 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1444 pTLCb->ucTdlsPeerCount++;
1445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 return VOS_STATUS_SUCCESS;
1448}/* WLANTL_RegisterSTAClient */
1449
1450/*===========================================================================
1451
1452 FUNCTION WLANTL_ClearSTAClient
1453
1454 DESCRIPTION
1455
1456 HDD will call this API when it no longer needs data services for the
1457 particular station.
1458
1459 DEPENDENCIES
1460
1461 A station must have been registered before the clear registration is
1462 called.
1463
1464 PARAMETERS
1465
1466 pvosGCtx: pointer to the global vos context; a handle to TL's
1467 control block can be extracted from its context
1468 ucSTAId: identifier for the STA to be cleared
1469
1470 RETURN VALUE
1471
1472 The result code associated with performing the operation
1473
1474 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1475 TL cb is NULL ; access would cause a page fault
1476 VOS_STATUS_E_EXISTS: Station was not registered
1477 VOS_STATUS_SUCCESS: Everything is good :)
1478
1479 SIDE EFFECTS
1480
1481============================================================================*/
1482VOS_STATUS
1483WLANTL_ClearSTAClient
1484(
1485 v_PVOID_t pvosGCtx,
1486 v_U8_t ucSTAId
1487)
1488{
1489 WLANTL_CbType* pTLCb = NULL;
1490 v_U8_t ucIndex;
1491 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1492
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301493 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 /*------------------------------------------------------------------------
1495 Sanity check
1496 ------------------------------------------------------------------------*/
1497 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1498 {
1499 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1500 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1501 return VOS_STATUS_E_FAULT;
1502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 /*------------------------------------------------------------------------
1504 Extract TL control block
1505 ------------------------------------------------------------------------*/
1506 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1507 if ( NULL == pTLCb )
1508 {
1509 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1510 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1511 return VOS_STATUS_E_FAULT;
1512 }
1513
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301514 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1515 {
1516 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1517 "WLAN TL:Client Memory was not allocated on %s", __func__));
1518 return VOS_STATUS_E_FAILURE;
1519 }
1520
1521 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 {
1523 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1524 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301525 /* Clean packets cached for the STA */
1526 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 return VOS_STATUS_E_EXISTS;
1528 }
1529
1530 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001531 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001533 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1534 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 }
1536
Sunil Ravid5406f22013-01-22 00:18:31 -08001537#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301538 /* decrement ucTdlsPeerCount only if it is non-zero */
1539 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001540 && pTLCb->ucTdlsPeerCount)
1541 pTLCb->ucTdlsPeerCount--;
1542#endif
1543
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 /*------------------------------------------------------------------------
1545 Clear station
1546 ------------------------------------------------------------------------*/
1547 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1548 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301549 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
1551 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1552 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1553 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1554 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1555
1556 return VOS_STATUS_SUCCESS;
1557}/* WLANTL_ClearSTAClient */
1558
1559/*===========================================================================
1560
1561 FUNCTION WLANTL_ChangeSTAState
1562
1563 DESCRIPTION
1564
1565 HDD will make this notification whenever a change occurs in the
1566 connectivity state of a particular STA.
1567
1568 DEPENDENCIES
1569
1570 A station must have been registered before the change state can be
1571 called.
1572
1573 RESTRICTION: A station is being notified as authenticated before the
1574 keys are installed in HW. This way if a frame is received
1575 before the keys are installed DPU will drop that frame.
1576
1577 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1578 the following:
1579 - a station will be in assoc state in TL before TL receives any data
1580 for it
1581
1582 PARAMETERS
1583
1584 pvosGCtx: pointer to the global vos context; a handle to TL's
1585 control block can be extracted from its context
1586 ucSTAId: identifier for the STA that is pending transmission
1587 tlSTAState: the new state of the connection to the given station
1588
1589
1590 RETURN VALUE
1591
1592 The result code associated with performing the operation
1593
1594 VOS_STATUS_E_INVAL: Input parameters are invalid
1595 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1596 TL cb is NULL ; access would cause a page fault
1597 VOS_STATUS_E_EXISTS: Station was not registered
1598 VOS_STATUS_SUCCESS: Everything is good :)
1599
1600 SIDE EFFECTS
1601
1602============================================================================*/
1603VOS_STATUS
1604WLANTL_ChangeSTAState
1605(
1606 v_PVOID_t pvosGCtx,
1607 v_U8_t ucSTAId,
1608 WLANTL_STAStateType tlSTAState
1609)
1610{
1611 WLANTL_CbType* pTLCb = NULL;
1612 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1613
1614 /*------------------------------------------------------------------------
1615 Sanity check
1616 ------------------------------------------------------------------------*/
1617 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1618 {
1619 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1620 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1621 return VOS_STATUS_E_INVAL;
1622 }
1623
1624 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1625 {
1626 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1627 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1628 return VOS_STATUS_E_FAULT;
1629 }
1630
1631 /*------------------------------------------------------------------------
1632 Extract TL control block and check existance
1633 ------------------------------------------------------------------------*/
1634 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1635 if ( NULL == pTLCb )
1636 {
1637 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1638 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1639 return VOS_STATUS_E_FAULT;
1640 }
1641
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301642 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1643 {
1644 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1645 "WLAN TL:Client Memory was not allocated on %s", __func__));
1646 return VOS_STATUS_E_FAILURE;
1647 }
1648
1649 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 {
1651 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1652 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1653 return VOS_STATUS_E_EXISTS;
1654 }
1655
1656 /*------------------------------------------------------------------------
1657 Change STA state
1658 No need to lock this operation, see restrictions above
1659 ------------------------------------------------------------------------*/
1660 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1661 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301662 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001663
Katya Nigam42e16e82014-02-04 16:28:55 +05301664 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1665 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1666
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301667 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668
1669 return VOS_STATUS_SUCCESS;
1670}/* WLANTL_ChangeSTAState */
1671
1672/*===========================================================================
1673
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301674 FUNCTION WLANTL_STAPtkInstalled
1675
1676 DESCRIPTION
1677
1678 HDD will make this notification whenever PTK is installed for the STA
1679
1680 DEPENDENCIES
1681
1682 A station must have been registered before the change state can be
1683 called.
1684
1685 PARAMETERS
1686
1687 pvosGCtx: pointer to the global vos context; a handle to TL's
1688 control block can be extracted from its context
1689 ucSTAId: identifier for the STA for which Pairwise key is
1690 installed
1691
1692 RETURN VALUE
1693
1694 The result code associated with performing the operation
1695
1696 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1697 TL cb is NULL ; access would cause a page fault
1698 VOS_STATUS_E_EXISTS: Station was not registered
1699 VOS_STATUS_SUCCESS: Everything is good :)
1700
1701 SIDE EFFECTS
1702
1703============================================================================*/
1704VOS_STATUS
1705WLANTL_STAPtkInstalled
1706(
1707 v_PVOID_t pvosGCtx,
1708 v_U8_t ucSTAId
1709)
1710{
1711 WLANTL_CbType* pTLCb = NULL;
1712 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1713
1714 /*------------------------------------------------------------------------
1715 Sanity check
1716 ------------------------------------------------------------------------*/
1717
1718 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1719 {
1720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1721 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1722 return VOS_STATUS_E_FAULT;
1723 }
1724
1725 /*------------------------------------------------------------------------
1726 Extract TL control block and check existance
1727 ------------------------------------------------------------------------*/
1728 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1729 if ( NULL == pTLCb )
1730 {
1731 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1732 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1733 return VOS_STATUS_E_FAULT;
1734 }
1735
1736 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1737 {
1738 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1739 FL("WLAN TL:Client Memory was not allocated")));
1740 return VOS_STATUS_E_FAILURE;
1741 }
1742
1743 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1744 {
1745 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1746 FL("WLAN TL:Station was not previously registered")));
1747 return VOS_STATUS_E_EXISTS;
1748 }
1749
1750 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1751
1752 return VOS_STATUS_SUCCESS;
1753}/* WLANTL_STAPtkInstalled */
1754
1755/*===========================================================================
1756
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001757 FUNCTION WLANTL_GetSTAState
1758
1759 DESCRIPTION
1760
1761 Returns connectivity state of a particular STA.
1762
1763 DEPENDENCIES
1764
1765 A station must have been registered before its state can be retrieved.
1766
1767
1768 PARAMETERS
1769
1770 IN
1771 pvosGCtx: pointer to the global vos context; a handle to TL's
1772 control block can be extracted from its context
1773 ucSTAId: identifier of the station
1774
1775 OUT
1776 ptlSTAState: the current state of the connection to the given station
1777
1778
1779 RETURN VALUE
1780
1781 The result code associated with performing the operation
1782
1783 VOS_STATUS_E_INVAL: Input parameters are invalid
1784 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1785 TL cb is NULL ; access would cause a page fault
1786 VOS_STATUS_E_EXISTS: Station was not registered
1787 VOS_STATUS_SUCCESS: Everything is good :)
1788
1789 SIDE EFFECTS
1790
1791============================================================================*/
1792VOS_STATUS
1793WLANTL_GetSTAState
1794(
1795 v_PVOID_t pvosGCtx,
1796 v_U8_t ucSTAId,
1797 WLANTL_STAStateType *ptlSTAState
1798)
1799{
1800 WLANTL_CbType* pTLCb = NULL;
1801 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1802
1803 /*------------------------------------------------------------------------
1804 Sanity check
1805 ------------------------------------------------------------------------*/
1806 if ( NULL == ptlSTAState )
1807 {
1808 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1809 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1810 return VOS_STATUS_E_INVAL;
1811 }
1812
1813 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1814 {
1815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1816 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1817 return VOS_STATUS_E_FAULT;
1818 }
1819
1820 /*------------------------------------------------------------------------
1821 Extract TL control block and check existance
1822 ------------------------------------------------------------------------*/
1823 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1824 if ( NULL == pTLCb )
1825 {
1826 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1827 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1828 return VOS_STATUS_E_FAULT;
1829 }
1830
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301831 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1832 {
1833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1834 "WLAN TL:Client Memory was not allocated on %s", __func__));
1835 return VOS_STATUS_E_FAILURE;
1836 }
1837
1838 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001839 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001840 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001841 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1842 return VOS_STATUS_E_EXISTS;
1843 }
1844
1845 /*------------------------------------------------------------------------
1846 Get STA state
1847 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301848 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001849
1850 return VOS_STATUS_SUCCESS;
1851}/* WLANTL_GetSTAState */
1852
Shailender Karmuchia734f332013-04-19 14:02:48 -07001853/*==========================================================================
1854 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1855
1856 DESCRIPTION
1857 HDD will call this API to update the BSSID for this Station.
1858
1859 DEPENDENCIES
1860 The HDD Should registered the staID with TL before calling this function.
1861
1862 PARAMETERS
1863
1864 IN
1865 pvosGCtx: Pointer to the global vos context; a handle to TL's
1866 or WDA's control block can be extracted from its context
1867 IN
1868 ucSTAId The Station ID for Bssid to be updated
1869 IN
1870 pBssid BSSID to be updated
1871
1872 RETURN VALUE
1873 The result code associated with performing the operation
1874
1875 VOS_STATUS_E_INVAL: Input parameters are invalid
1876 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1877 TL cb is NULL ; access would cause a page fault
1878 VOS_STATUS_E_EXISTS: Station was not registered
1879 VOS_STATUS_SUCCESS: Everything is good :)
1880
1881 SIDE EFFECTS
1882============================================================================*/
1883
1884
1885VOS_STATUS
1886WLANTL_UpdateSTABssIdforIBSS
1887(
1888 v_PVOID_t pvosGCtx,
1889 v_U8_t ucSTAId,
1890 v_U8_t *pBssid
1891)
1892{
1893 WLANTL_CbType* pTLCb = NULL;
1894 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1895
1896 /*------------------------------------------------------------------------
1897 Sanity check
1898 ------------------------------------------------------------------------*/
1899 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1900 {
1901 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1902 "WLAN TL:Invalid station id requested %s", __func__));
1903 return VOS_STATUS_E_FAULT;
1904 }
1905
1906 /*------------------------------------------------------------------------
1907 Extract TL control block and check existance
1908 ------------------------------------------------------------------------*/
1909 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1910 if ( NULL == pTLCb )
1911 {
1912 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1913 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1914 return VOS_STATUS_E_FAULT;
1915 }
1916
1917 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1918 {
1919 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1920 "WLAN TL:Client Memory was not allocated on %s", __func__));
1921 return VOS_STATUS_E_FAILURE;
1922 }
1923
1924 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1925 {
1926 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1927 "WLAN TL:Station was not previously registered %s", __func__));
1928 return VOS_STATUS_E_EXISTS;
1929 }
1930
1931 /*------------------------------------------------------------------------
1932 Update the IBSS BSSID
1933 ------------------------------------------------------------------------*/
1934 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1935 pBssid, sizeof(v_MACADDR_t));
1936
1937 return VOS_STATUS_SUCCESS;
1938}
1939
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001940/*===========================================================================
1941
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 FUNCTION WLANTL_STAPktPending
1943
1944 DESCRIPTION
1945
1946 HDD will call this API when a packet is pending transmission in its
1947 queues.
1948
1949 DEPENDENCIES
1950
1951 A station must have been registered before the packet pending
1952 notification can be sent.
1953
1954 RESTRICTION: TL will not count packets for pending notification.
1955 HDD is expected to send the notification only when
1956 non-empty event gets triggered. Worst case scenario
1957 is that TL might end up making a call when Hdds
1958 queues are actually empty.
1959
1960 PARAMETERS
1961
1962 pvosGCtx: pointer to the global vos context; a handle to TL's
1963 control block can be extracted from its context
1964 ucSTAId: identifier for the STA that is pending transmission
1965
1966 RETURN VALUE
1967
1968 The result code associated with performing the operation
1969
1970 VOS_STATUS_E_INVAL: Input parameters are invalid
1971 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1972 to TL cb is NULL ; access would cause a page fault
1973 VOS_STATUS_E_EXISTS: Station was not registered
1974 VOS_STATUS_SUCCESS: Everything is good :)
1975
1976 SIDE EFFECTS
1977
1978============================================================================*/
1979VOS_STATUS
1980WLANTL_STAPktPending
1981(
1982 v_PVOID_t pvosGCtx,
1983 v_U8_t ucSTAId,
1984 WLANTL_ACEnumType ucAc
1985)
1986{
1987 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301988 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1990
1991 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1992 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
1993
1994 /*------------------------------------------------------------------------
1995 Sanity check
1996 ------------------------------------------------------------------------*/
1997 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1998 {
1999 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2000 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2001 return VOS_STATUS_E_FAULT;
2002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 /*------------------------------------------------------------------------
2004 Extract TL control block and check existance
2005 ------------------------------------------------------------------------*/
2006 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2007 if ( NULL == pTLCb )
2008 {
2009 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2010 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2011 return VOS_STATUS_E_FAULT;
2012 }
2013
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302014 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2015
2016 if ( NULL == pClientSTA )
2017 {
2018 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2019 "WLAN TL:Client Memory was not allocated on %s", __func__));
2020 return VOS_STATUS_E_FAILURE;
2021 }
2022
2023 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 {
2025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2026 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2027 return VOS_STATUS_E_EXISTS;
2028 }
2029
2030 /*---------------------------------------------------------------------
2031 Temporary fix to enable TL to fetch packets when multiple peers join
2032 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2033 going through all STA's in round robin fashion gets merged in from
2034 BT AMP branch.
2035 --------------------------------------------------------------------*/
2036 pTLCb->ucRegisteredStaId = ucSTAId;
2037
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302038 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002039 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2040 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2041 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2042 to make sure TL is indeed waiting for EAPOL.
2043 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302044 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002045
Katya Nigam42e16e82014-02-04 16:28:55 +05302046 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2047 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2048
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002049 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002050 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302051 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002052 }
2053
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 /*-----------------------------------------------------------------------
2055 Enable this AC in the AC mask in order for TL to start servicing it
2056 Set packet pending flag
2057 To avoid race condition, serialize the updation of AC and AC mask
2058 through WLANTL_TX_STAID_AC_IND message.
2059 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002060
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302061 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302063 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002064
2065 /*------------------------------------------------------------------------
2066 Check if there are enough resources for transmission and tx is not
2067 suspended.
2068 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07002069 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2070 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302072 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_STA_PKT_PENDING,
2073 ucSTAId, pClientSTA->tlState ));
2074
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2076 "Issuing Xmit start request to BAL"));
2077 WDA_DS_StartXmit(pvosGCtx);
2078 }
2079 else
2080 {
2081 /*---------------------------------------------------------------------
2082 No error code is sent because TL will resume tx autonomously if
2083 resources become available or tx gets resumed
2084 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002085 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002087 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 return VOS_STATUS_SUCCESS;
2090}/* WLANTL_STAPktPending */
2091
2092/*==========================================================================
2093
2094 FUNCTION WLANTL_SetSTAPriority
2095
2096 DESCRIPTION
2097
2098 TL exposes this API to allow upper layers a rough control over the
2099 priority of transmission for a given station when supporting multiple
2100 connections.
2101
2102 DEPENDENCIES
2103
2104 A station must have been registered before the change in priority can be
2105 called.
2106
2107 PARAMETERS
2108
2109 pvosGCtx: pointer to the global vos context; a handle to TL's
2110 control block can be extracted from its context
2111 ucSTAId: identifier for the STA that has to change priority
2112
2113 RETURN VALUE
2114
2115 The result code associated with performing the operation
2116
2117 VOS_STATUS_E_INVAL: Input parameters are invalid
2118 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2119 to TL cb is NULL ; access would cause a page fault
2120 VOS_STATUS_E_EXISTS: Station was not registered
2121 VOS_STATUS_SUCCESS: Everything is good :)
2122
2123 SIDE EFFECTS
2124
2125============================================================================*/
2126VOS_STATUS
2127WLANTL_SetSTAPriority
2128(
2129 v_PVOID_t pvosGCtx,
2130 v_U8_t ucSTAId,
2131 WLANTL_STAPriorityType tlSTAPri
2132)
2133{
2134 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302135 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2137
2138 /*------------------------------------------------------------------------
2139 Sanity check
2140 ------------------------------------------------------------------------*/
2141 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2142 {
2143 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2144 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2145 return VOS_STATUS_E_FAULT;
2146 }
2147
2148 /*------------------------------------------------------------------------
2149 Extract TL control block
2150 ------------------------------------------------------------------------*/
2151 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2152 if ( NULL == pTLCb )
2153 {
2154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2155 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2156 return VOS_STATUS_E_FAULT;
2157 }
2158
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302159 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2160
2161 if ( NULL == pClientSTA )
2162 {
2163 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2164 "WLAN TL:Client Memory was not allocated on %s", __func__));
2165 return VOS_STATUS_E_FAILURE;
2166 }
2167
2168 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 {
2170 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2171 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2172 return VOS_STATUS_E_EXISTS;
2173 }
2174
2175 /*------------------------------------------------------------------------
2176 Re-analize if lock is needed when adding multiple stations
2177 ------------------------------------------------------------------------*/
2178 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2179 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302180 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2181 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002182
2183 return VOS_STATUS_SUCCESS;
2184}/* WLANTL_SetSTAPriority */
2185
2186
2187/*----------------------------------------------------------------------------
2188 INTERACTION WITH BAP
2189 ---------------------------------------------------------------------------*/
2190
2191/*==========================================================================
2192
2193 FUNCTION WLANTL_RegisterBAPClient
2194
2195 DESCRIPTION
2196 Called by SME to register itself as client for non-data BT-AMP packets.
2197
2198 DEPENDENCIES
2199 TL must be initialized before this function can be called.
2200
2201 PARAMETERS
2202
2203 IN
2204 pvosGCtx: pointer to the global vos context; a handle to TL's
2205 or SME's control block can be extracted from its context
2206 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2207 BT-AMP packets
2208 pfnFlushOpCompleteCb:
2209 pointer to the call back function, for the Flush operation
2210 completion.
2211
2212
2213 RETURN VALUE
2214
2215 The result code associated with performing the operation
2216
2217 VOS_STATUS_E_INVAL: Input parameters are invalid
2218 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2219 to TL cb is NULL ; access would cause a page fault
2220 VOS_STATUS_E_EXISTS: BAL client was already registered
2221 VOS_STATUS_SUCCESS: Everything is good :)
2222
2223 SIDE EFFECTS
2224
2225============================================================================*/
2226VOS_STATUS
2227WLANTL_RegisterBAPClient
2228(
2229 v_PVOID_t pvosGCtx,
2230 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2231 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2232)
2233{
2234 WLANTL_CbType* pTLCb = NULL;
2235 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2236
2237 /*------------------------------------------------------------------------
2238 Sanity check
2239 ------------------------------------------------------------------------*/
2240 if ( NULL == pfnTlBAPRxFrm )
2241 {
2242 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2243 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2244 return VOS_STATUS_E_INVAL;
2245 }
2246
2247 if ( NULL == pfnFlushOpCompleteCb )
2248 {
2249 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2250 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2251 return VOS_STATUS_E_INVAL;
2252 }
2253
2254 /*------------------------------------------------------------------------
2255 Extract TL control block
2256 ------------------------------------------------------------------------*/
2257 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2258 if ( NULL == pTLCb )
2259 {
2260 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2261 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2262 return VOS_STATUS_E_FAULT;
2263 }
2264
2265 /*------------------------------------------------------------------------
2266 Make sure this is the first registration attempt
2267 ------------------------------------------------------------------------*/
2268 if ( 0 != pTLCb->tlBAPClient.ucExists )
2269 {
2270 pTLCb->tlBAPClient.ucExists++;
2271 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2272 "WLAN TL:BAP client was already registered"));
2273 return VOS_STATUS_E_EXISTS;
2274 }
2275
2276 /*------------------------------------------------------------------------
2277 Register station with TL
2278 ------------------------------------------------------------------------*/
2279 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2280 "WLAN TL:Registering BAP Client" ));
2281
2282 pTLCb->tlBAPClient.ucExists++;
2283
2284 if ( NULL != pfnTlBAPRxFrm )
2285 {
2286 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2287 }
2288
2289 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2290
2291 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2292
2293 return VOS_STATUS_SUCCESS;
2294}/* WLANTL_RegisterBAPClient */
2295
2296
2297/*==========================================================================
2298
2299 FUNCTION WLANTL_TxBAPFrm
2300
2301 DESCRIPTION
2302 BAP calls this when it wants to send a frame to the module
2303
2304 DEPENDENCIES
2305 BAP must be registered with TL before this function can be called.
2306
2307 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2308 a tx complete from the previous packet, that means BAP
2309 sends one packet, wait for tx complete and then
2310 sends another one
2311
2312 If BAP sends another packet before TL manages to process the
2313 previously sent packet call will end in failure
2314
2315 PARAMETERS
2316
2317 IN
2318 pvosGCtx: pointer to the global vos context; a handle to TL's
2319 or BAP's control block can be extracted from its context
2320 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2321 transmitted
2322 pMetaInfo: meta information about the packet
2323 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2324 the result of the operation over the bus
2325
2326 RETURN VALUE
2327 The result code associated with performing the operation
2328
2329 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2330 page fault
2331 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2332 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2333 VOS_STATUS_SUCCESS: Everything is good :)
2334
2335 Other failure messages may be returned from the BD header handling
2336 routines, please check apropriate API for more info.
2337
2338 SIDE EFFECTS
2339
2340============================================================================*/
2341VOS_STATUS
2342WLANTL_TxBAPFrm
2343(
2344 v_PVOID_t pvosGCtx,
2345 vos_pkt_t* vosDataBuff,
2346 WLANTL_MetaInfoType* pMetaInfo,
2347 WLANTL_TxCompCBType pfnTlBAPTxComp
2348)
2349{
2350 WLANTL_CbType* pTLCb = NULL;
2351 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2352 v_MACADDR_t vDestMacAddr;
2353 v_U16_t usPktLen;
2354 v_U8_t ucStaId = 0;
2355 v_U8_t extraHeadSpace = 0;
2356 v_U8_t ucWDSEnabled = 0;
2357 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2358
2359 /*------------------------------------------------------------------------
2360 Sanity check
2361 Extract TL control block
2362 ------------------------------------------------------------------------*/
2363 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2364 if ( NULL == pTLCb )
2365 {
2366 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2367 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2368 return VOS_STATUS_E_FAULT;
2369 }
2370
2371 /*------------------------------------------------------------------------
2372 Ensure that BAP client was registered previously
2373 ------------------------------------------------------------------------*/
2374 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2375 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2376 {
2377 pTLCb->tlBAPClient.ucExists++;
2378 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2379 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2380 return VOS_STATUS_E_EXISTS;
2381 }
2382
2383 /*------------------------------------------------------------------------
2384 Check if any BT-AMP Frm is pending
2385 ------------------------------------------------------------------------*/
2386 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2387 {
2388 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2389 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2390 return VOS_STATUS_E_BUSY;
2391 }
2392
2393 /*------------------------------------------------------------------------
2394 Save buffer and notify BAL; no lock is needed if the above restriction
2395 is met
2396 Save the tx complete fnct pointer as tl specific data in the vos buffer
2397 ------------------------------------------------------------------------*/
2398
2399 /*------------------------------------------------------------------------
2400 Translate 802.3 frame to 802.11
2401 ------------------------------------------------------------------------*/
2402 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302403 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2404 {
2405 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2406 "WLAN TL:Client Memory was not allocated on %s", __func__));
2407 return VOS_STATUS_E_FAILURE;
2408 }
2409 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2410 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002412 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2413 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002414 pMetaInfo, &ucWDSEnabled,
2415 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002416
2417 if ( VOS_STATUS_SUCCESS != vosStatus )
2418 {
2419 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2420 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2421
2422 return vosStatus;
2423 }
2424
2425 pMetaInfo->ucDisableFrmXtl = 1;
2426 }
2427
2428 /*-------------------------------------------------------------------------
2429 Call HAL to fill BD header
2430 -------------------------------------------------------------------------*/
2431
2432 /* Adding Type, SubType which was missing for EAPOL from BAP */
2433 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2434 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2435
2436 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2437 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302438 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302440 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002442 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002443
2444 if ( VOS_STATUS_SUCCESS != vosStatus )
2445 {
2446 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2447 "WLAN TL:Failed while building TX header %d", vosStatus));
2448 return vosStatus;
2449 }
2450
2451 if ( NULL != pfnTlBAPTxComp )
2452 {
2453 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2454 (v_PVOID_t)pfnTlBAPTxComp);
2455 }
2456 else
2457 {
2458 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2459 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2460
2461 }
2462
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302463 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2464 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465
2466 /*------------------------------------------------------------------------
2467 Check if thre are enough resources for transmission and tx is not
2468 suspended.
2469 ------------------------------------------------------------------------*/
2470 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2471 ( 0 == pTLCb->ucTxSuspended ))
2472 {
2473 WDA_DS_StartXmit(pvosGCtx);
2474 }
2475 else
2476 {
2477 /*---------------------------------------------------------------------
2478 No error code is sent because TL will resume tx autonomously if
2479 resources become available or tx gets resumed
2480 ---------------------------------------------------------------------*/
2481 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2482 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2483 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2484 }
2485
2486 return VOS_STATUS_SUCCESS;
2487}/* WLANTL_TxBAPFrm */
2488
2489
2490/*----------------------------------------------------------------------------
2491 INTERACTION WITH SME
2492 ---------------------------------------------------------------------------*/
2493
2494/*==========================================================================
2495
2496 FUNCTION WLANTL_GetRssi
2497
2498 DESCRIPTION
2499 TL will extract the RSSI information from every data packet from the
2500 ongoing traffic and will store it. It will provide the result to SME
2501 upon request.
2502
2503 DEPENDENCIES
2504
2505 WARNING: the read and write of this value will not be protected
2506 by locks, therefore the information obtained after a read
2507 might not always be consistent.
2508
2509 PARAMETERS
2510
2511 IN
2512 pvosGCtx: pointer to the global vos context; a handle to TL's
2513 or SME's control block can be extracted from its context
2514 ucSTAId: station identifier for the requested value
2515
2516 OUT
2517 puRssi: the average value of the RSSI
2518
2519
2520 RETURN VALUE
2521 The result code associated with performing the operation
2522
2523 VOS_STATUS_E_INVAL: Input parameters are invalid
2524 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2525 to TL cb is NULL ; access would cause a page fault
2526 VOS_STATUS_E_EXISTS: STA was not yet registered
2527 VOS_STATUS_SUCCESS: Everything is good :)
2528
2529 SIDE EFFECTS
2530
2531============================================================================*/
2532VOS_STATUS
2533WLANTL_GetRssi
2534(
2535 v_PVOID_t pvosGCtx,
2536 v_U8_t ucSTAId,
2537 v_S7_t* pRssi
2538)
2539{
2540 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302541 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2543
2544 /*------------------------------------------------------------------------
2545 Sanity check
2546 ------------------------------------------------------------------------*/
2547 if ( NULL == pRssi )
2548 {
2549 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2550 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2551 return VOS_STATUS_E_INVAL;
2552 }
2553
2554 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2555 {
2556 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2557 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2558 return VOS_STATUS_E_FAULT;
2559 }
2560
2561 /*------------------------------------------------------------------------
2562 Extract TL control block and check existance
2563 ------------------------------------------------------------------------*/
2564 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2565 if ( NULL == pTLCb )
2566 {
2567 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2568 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2569 return VOS_STATUS_E_FAULT;
2570 }
2571
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302572 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2573
2574 if ( NULL == pClientSTA )
2575 {
2576 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2577 "WLAN TL:Client Memory was not allocated on %s", __func__));
2578 return VOS_STATUS_E_FAILURE;
2579 }
2580
2581 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 {
2583 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2584 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2585 return VOS_STATUS_E_EXISTS;
2586 }
2587
2588 /*------------------------------------------------------------------------
2589 Copy will not be locked; please read restriction
2590 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302591 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302593 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2595 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2596 might not have happend by that time. Hence reading the most recent Rssi
2597 calcluated by TL*/
2598 if(0 == *pRssi)
2599 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302600 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 }
2603 else
2604 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302605 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 }
2607
2608 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002609 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2610 ucSTAId, *pRssi,
2611 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002612
2613 return VOS_STATUS_SUCCESS;
2614}/* WLANTL_GetRssi */
2615
2616/*==========================================================================
2617
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302618 FUNCTION WLANTL_GetSnr
2619
2620 DESCRIPTION
2621 TL will extract the SNR information from every data packet from the
2622 ongoing traffic and will store it. It will provide the result to SME
2623 upon request.
2624
2625 DEPENDENCIES
2626
2627 WARNING: the read and write of this value will not be protected
2628 by locks, therefore the information obtained after a read
2629 might not always be consistent.
2630
2631 PARAMETERS
2632
2633 IN
2634 pvosGCtx: pointer to the global vos context; a handle to TL's
2635 or SME's control block can be extracted from its context
2636 ucSTAId: station identifier for the requested value
2637
2638 OUT
2639 pSnr: the average value of the SNR
2640
2641
2642 RETURN VALUE
2643 The result code associated with performing the operation
2644
2645 VOS_STATUS_E_INVAL: Input parameters are invalid
2646 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2647 to TL cb is NULL ; access would cause a page fault
2648 VOS_STATUS_E_EXISTS: STA was not yet registered
2649 VOS_STATUS_SUCCESS: Everything is good :)
2650
2651 SIDE EFFECTS
2652
2653============================================================================*/
2654VOS_STATUS
2655WLANTL_GetSnr
2656(
2657 tANI_U8 ucSTAId,
2658 tANI_S8* pSnr
2659)
2660{
2661 WLANTL_CbType* pTLCb = NULL;
2662 WLANTL_STAClientType* pClientSTA = NULL;
2663 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2664
2665 /*------------------------------------------------------------------------
2666 Sanity check
2667 ------------------------------------------------------------------------*/
2668 if (NULL == pSnr)
2669 {
2670 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2671 "WLAN TL:Invalid parameter sent on %s", __func__));
2672 return VOS_STATUS_E_INVAL;
2673 }
2674
2675 if (WLANTL_STA_ID_INVALID(ucSTAId))
2676 {
2677 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2678 "WLAN TL:Invalid station id requested on %s", __func__));
2679 return VOS_STATUS_E_FAULT;
2680 }
2681
2682 /*------------------------------------------------------------------------
2683 Extract TL control block and check existance
2684 ------------------------------------------------------------------------*/
2685 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2686 if (NULL == pTLCb)
2687 {
2688 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2689 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2690 return VOS_STATUS_E_FAULT;
2691 }
2692
2693 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2694
2695 if (NULL == pClientSTA)
2696 {
2697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2698 "WLAN TL:Client Memory was not allocated on %s", __func__));
2699 return VOS_STATUS_E_FAILURE;
2700 }
2701
2702 if (0 == pClientSTA->ucExists)
2703 {
2704 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2705 "WLAN TL:Station was not previously registered on %s", __func__));
2706 return VOS_STATUS_E_EXISTS;
2707 }
2708
2709 /*------------------------------------------------------------------------
2710 Copy will not be locked; please read restriction
2711 ------------------------------------------------------------------------*/
2712 if (pTLCb->isBMPS)
2713 {
2714 *pSnr = pClientSTA->snrAvgBmps;
2715 }
2716 else
2717 {
2718 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2719 * data samples (snridx) to calculate the average then return the
2720 * average for the window of prevoius 20 packets. And if there aren't
2721 * enough samples and the average for previous window of 20 packets is
2722 * not available then return a predefined value
2723 *
2724 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2725 * team reveal that the SNR value has a ceiling well below 127 dBm,
2726 * so if SNR has value of 127 the userspace applications can know that
2727 * the SNR has not been computed yet because enough data was not
2728 * available for SNR calculation
2729 */
2730 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2731 || !(pClientSTA->prevSnrAvg))
2732 {
2733 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2734 }
2735 else if (pClientSTA->prevSnrAvg)
2736 {
2737 *pSnr = pClientSTA->prevSnrAvg;
2738 }
2739 else
2740 {
2741 *pSnr = SNR_HACK_BMPS;
2742 }
2743 }
2744
2745 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2746 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2747 ucSTAId, *pSnr,
2748 pTLCb->isBMPS ? " in BMPS" : "");
2749
2750 return VOS_STATUS_SUCCESS;
2751}/* WLANTL_GetSnr */
2752/*==========================================================================
2753
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 FUNCTION WLANTL_GetLinkQuality
2755
2756 DESCRIPTION
2757 TL will extract the SNR information from every data packet from the
2758 ongoing traffic and will store it. It will provide the result to SME
2759 upon request.
2760
2761 DEPENDENCIES
2762
2763 WARNING: the read and write of this value will not be protected
2764 by locks, therefore the information obtained after a read
2765 might not always be consistent.
2766
2767 PARAMETERS
2768
2769 IN
2770 pvosGCtx: pointer to the global vos context; a handle to TL's
2771 or SME's control block can be extracted from its context
2772 ucSTAId: station identifier for the requested value
2773
2774 OUT
2775 puLinkQuality: the average value of the SNR
2776
2777
2778 RETURN VALUE
2779 The result code associated with performing the operation
2780
2781 VOS_STATUS_E_INVAL: Input parameters are invalid
2782 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2783 to TL cb is NULL ; access would cause a page fault
2784 VOS_STATUS_E_EXISTS: STA was not yet registered
2785 VOS_STATUS_SUCCESS: Everything is good :)
2786
2787 SIDE EFFECTS
2788
2789============================================================================*/
2790VOS_STATUS
2791WLANTL_GetLinkQuality
2792(
2793 v_PVOID_t pvosGCtx,
2794 v_U8_t ucSTAId,
2795 v_U32_t* puLinkQuality
2796)
2797{
2798 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302799 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800
2801 /*------------------------------------------------------------------------
2802 Sanity check
2803 ------------------------------------------------------------------------*/
2804 if ( NULL == puLinkQuality )
2805 {
2806 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2807 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2808 return VOS_STATUS_E_INVAL;
2809 }
2810
2811 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2812 {
2813 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2814 "Invalid station id requested on WLANTL_GetLinkQuality"));
2815 return VOS_STATUS_E_FAULT;
2816 }
2817
2818 /*------------------------------------------------------------------------
2819 Extract TL control block and check existance
2820 ------------------------------------------------------------------------*/
2821 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2822 if ( NULL == pTLCb )
2823 {
2824 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2825 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2826 return VOS_STATUS_E_FAULT;
2827 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302828 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002829
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302830 if ( NULL == pClientSTA )
2831 {
2832 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2833 "WLAN TL:Client Memory was not allocated on %s", __func__));
2834 return VOS_STATUS_E_FAILURE;
2835 }
2836
2837 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 {
2839 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2840 "Station was not previously registered on WLANTL_GetLinkQuality"));
2841 return VOS_STATUS_E_EXISTS;
2842 }
2843
2844 /*------------------------------------------------------------------------
2845 Copy will not be locked; please read restriction
2846 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302847 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002848
2849 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2850 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2851
2852 return VOS_STATUS_SUCCESS;
2853}/* WLANTL_GetLinkQuality */
2854
2855/*==========================================================================
2856
2857 FUNCTION WLANTL_FlushStaTID
2858
2859 DESCRIPTION
2860 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2861 message to HAL. This API is called by the SME inorder to perform a flush
2862 operation.
2863
2864 DEPENDENCIES
2865
2866 PARAMETERS
2867
2868 IN
2869 pvosGCtx: pointer to the global vos context; a handle to TL's
2870 or SME's control block can be extracted from its context
2871 ucSTAId: station identifier for the requested value
2872 ucTid: Tspec ID for the new BA session
2873
2874 OUT
2875 The response for this post is received in the main thread, via a response
2876 message from HAL to TL.
2877
2878 RETURN VALUE
2879 VOS_STATUS_SUCCESS: Everything is good :)
2880
2881 SIDE EFFECTS
2882============================================================================*/
2883VOS_STATUS
2884WLANTL_FlushStaTID
2885(
2886 v_PVOID_t pvosGCtx,
2887 v_U8_t ucSTAId,
2888 v_U8_t ucTid
2889)
2890{
2891 WLANTL_CbType* pTLCb = NULL;
2892 tpFlushACReq FlushACReqPtr = NULL;
2893 vos_msg_t vosMessage;
2894
2895
2896 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2897 {
2898 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2899 "Invalid station id requested on WLANTL_FlushStaTID"));
2900 return VOS_STATUS_E_FAULT;
2901 }
2902
2903 /*------------------------------------------------------------------------
2904 Extract TL control block and check existance
2905 ------------------------------------------------------------------------*/
2906 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2907 if ( NULL == pTLCb )
2908 {
2909 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2910 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2911 return VOS_STATUS_E_FAULT;
2912 }
2913
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302914 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2915 {
2916 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2917 "WLAN TL:Client Memory was not allocated on %s", __func__));
2918 return VOS_STATUS_E_FAILURE;
2919 }
2920
2921 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 {
2923 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2924 "Station was not previously registered on WLANTL_FlushStaTID"));
2925 return VOS_STATUS_E_EXISTS;
2926 }
2927
2928 /*------------------------------------------------------------------------
2929 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2930 ------------------------------------------------------------------------*/
2931 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2932
2933 if ( NULL == FlushACReqPtr )
2934 {
2935 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2936 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2937 VOS_ASSERT(0);
2938 return VOS_STATUS_E_NOMEM;
2939 }
2940
2941 // Start constructing the message for HAL
2942 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2943 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2944 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2945 FlushACReqPtr->ucSTAId = ucSTAId;
2946 FlushACReqPtr->ucTid = ucTid;
2947
2948 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2949 vosMessage.bodyptr = (void *)FlushACReqPtr;
2950
2951 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2952 return VOS_STATUS_SUCCESS;
2953}
2954
2955
2956/*----------------------------------------------------------------------------
2957 INTERACTION WITH PE
2958 ---------------------------------------------------------------------------*/
2959
2960/*==========================================================================
2961
2962 FUNCTION WLANTL_RegisterMgmtFrmClient
2963
2964 DESCRIPTION
2965 Called by PE to register as a client for management frames delivery.
2966
2967 DEPENDENCIES
2968 TL must be initialized before this API can be called.
2969
2970 PARAMETERS
2971
2972 IN
2973 pvosGCtx: pointer to the global vos context; a handle to
2974 TL's control block can be extracted from its context
2975 pfnTlMgmtFrmRx: pointer to the receive processing routine for
2976 management frames
2977
2978 RETURN VALUE
2979 The result code associated with performing the operation
2980
2981 VOS_STATUS_E_INVAL: Input parameters are invalid
2982 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2983 page fault
2984 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
2985 VOS_STATUS_SUCCESS: Everything is good :)
2986
2987 SIDE EFFECTS
2988
2989============================================================================*/
2990VOS_STATUS
2991WLANTL_RegisterMgmtFrmClient
2992(
2993 v_PVOID_t pvosGCtx,
2994 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
2995)
2996{
2997 WLANTL_CbType* pTLCb = NULL;
2998 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2999
3000 /*------------------------------------------------------------------------
3001 Sanity check
3002 ------------------------------------------------------------------------*/
3003 if ( NULL == pfnTlMgmtFrmRx )
3004 {
3005 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3006 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3007 return VOS_STATUS_E_INVAL;
3008 }
3009
3010 /*------------------------------------------------------------------------
3011 Extract TL control block
3012 ------------------------------------------------------------------------*/
3013 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3014 if ( NULL == pTLCb )
3015 {
3016 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3017 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3018 return VOS_STATUS_E_FAULT;
3019 }
3020
3021 /*------------------------------------------------------------------------
3022 Make sure this is the first registration attempt
3023 ------------------------------------------------------------------------*/
3024 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3025 {
3026 pTLCb->tlMgmtFrmClient.ucExists++;
3027 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3028 "WLAN TL:Management frame client was already registered"));
3029 return VOS_STATUS_E_EXISTS;
3030 }
3031
3032 /*------------------------------------------------------------------------
3033 Register station with TL
3034 ------------------------------------------------------------------------*/
3035 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3036 "WLAN TL:Registering Management Frame Client" ));
3037
3038 pTLCb->tlMgmtFrmClient.ucExists++;
3039
3040 if ( NULL != pfnTlMgmtFrmRx )
3041 {
3042 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3043 }
3044
3045 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3046
3047 return VOS_STATUS_SUCCESS;
3048}/* WLANTL_RegisterMgmtFrmClient */
3049
3050/*==========================================================================
3051
3052 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3053
3054 DESCRIPTION
3055 Called by PE to deregister as a client for management frames delivery.
3056
3057 DEPENDENCIES
3058 TL must be initialized before this API can be called.
3059
3060 PARAMETERS
3061
3062 IN
3063 pvosGCtx: pointer to the global vos context; a handle to
3064 TL's control block can be extracted from its context
3065 RETURN VALUE
3066 The result code associated with performing the operation
3067
3068 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3069 page fault
3070 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3071 VOS_STATUS_SUCCESS: Everything is good :)
3072
3073 SIDE EFFECTS
3074
3075============================================================================*/
3076VOS_STATUS
3077WLANTL_DeRegisterMgmtFrmClient
3078(
3079 v_PVOID_t pvosGCtx
3080)
3081{
3082 WLANTL_CbType* pTLCb = NULL;
3083 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3084
3085 /*------------------------------------------------------------------------
3086 Extract TL control block
3087 ------------------------------------------------------------------------*/
3088 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3089 if ( NULL == pTLCb )
3090 {
3091 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3092 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3093 return VOS_STATUS_E_FAULT;
3094 }
3095
3096 /*------------------------------------------------------------------------
3097 Make sure this is the first registration attempt
3098 ------------------------------------------------------------------------*/
3099 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3100 {
3101 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3102 "WLAN TL:Management frame client was never registered"));
3103 return VOS_STATUS_E_EXISTS;
3104 }
3105
3106 /*------------------------------------------------------------------------
3107 Clear registration with TL
3108 ------------------------------------------------------------------------*/
3109 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3110 "WLAN TL:Deregistering Management Frame Client" ));
3111
3112 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3113 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3114 {
3115 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3116 "WLAN TL:Management cache buffer not empty on deregistering"
3117 " - dropping packet" ));
3118 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3119
3120 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3121 }
3122
3123 pTLCb->tlMgmtFrmClient.ucExists = 0;
3124
3125 return VOS_STATUS_SUCCESS;
3126}/* WLANTL_RegisterMgmtFrmClient */
3127
3128/*==========================================================================
3129
3130 FUNCTION WLANTL_TxMgmtFrm
3131
3132 DESCRIPTION
3133 Called by PE when it want to send out a management frame.
3134 HAL will also use this API for the few frames it sends out, they are not
3135 management frames howevere it is accepted that an exception will be
3136 allowed ONLY for the usage of HAL.
3137 Generic data frames SHOULD NOT travel through this function.
3138
3139 DEPENDENCIES
3140 TL must be initialized before this API can be called.
3141
3142 RESTRICTION: If PE sends another packet before TL manages to process the
3143 previously sent packet call will end in failure
3144
3145 Frames comming through here must be 802.11 frames, frame
3146 translation in UMA will be automatically disabled.
3147
3148 PARAMETERS
3149
3150 IN
3151 pvosGCtx: pointer to the global vos context;a handle to TL's
3152 control block can be extracted from its context
3153 vosFrmBuf: pointer to a vOSS buffer containing the management
3154 frame to be transmitted
3155 usFrmLen: the length of the frame to be transmitted; information
3156 is already included in the vOSS buffer
3157 wFrmType: the type of the frame being transmitted
3158 tid: tid used to transmit this frame
3159 pfnCompTxFunc: function pointer to the transmit complete routine
3160 pvBDHeader: pointer to the BD header, if NULL it means it was not
3161 yet constructed and it lies within TL's responsibility
3162 to do so; if not NULL it is expected that it was
3163 already packed inside the vos packet
3164 ucAckResponse: flag notifying it an interrupt is needed for the
3165 acknowledgement received when the frame is sent out
3166 the air and ; the interrupt will be processed by HAL,
3167 only one such frame can be pending in the system at
3168 one time.
3169
3170
3171 RETURN VALUE
3172 The result code associated with performing the operation
3173
3174 VOS_STATUS_E_INVAL: Input parameters are invalid
3175 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3176 page fault
3177 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3178 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3179 VOS_STATUS_SUCCESS: Everything is good :)
3180
3181 Other failure messages may be returned from the BD header handling
3182 routines, please check apropriate API for more info.
3183
3184 SIDE EFFECTS
3185
3186============================================================================*/
3187VOS_STATUS
3188WLANTL_TxMgmtFrm
3189(
3190 v_PVOID_t pvosGCtx,
3191 vos_pkt_t* vosFrmBuf,
3192 v_U16_t usFrmLen,
3193 v_U8_t wFrmType,
3194 v_U8_t ucTid,
3195 WLANTL_TxCompCBType pfnCompTxFunc,
3196 v_PVOID_t pvBDHeader,
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303197 v_U32_t ucAckResponse
Jeff Johnson295189b2012-06-20 16:38:30 -07003198)
3199{
3200 WLANTL_CbType* pTLCb = NULL;
3201 v_MACADDR_t vDestMacAddr;
3202 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3203 v_U16_t usPktLen;
3204 v_U32_t usTimeStamp = 0;
3205 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3206
3207 /*------------------------------------------------------------------------
3208 Sanity check
3209 ------------------------------------------------------------------------*/
3210 if ( NULL == vosFrmBuf )
3211 {
3212 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3213 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3214 return VOS_STATUS_E_INVAL;
3215 }
3216
3217 /*------------------------------------------------------------------------
3218 Extract TL control block
3219 ------------------------------------------------------------------------*/
3220 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3221 if ( NULL == pTLCb )
3222 {
3223 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3224 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3225 return VOS_STATUS_E_FAULT;
3226 }
3227
3228 /*------------------------------------------------------------------------
3229 Ensure that management frame client was previously registered
3230 ------------------------------------------------------------------------*/
3231 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3232 {
3233 pTLCb->tlMgmtFrmClient.ucExists++;
3234 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3235 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3236 return VOS_STATUS_E_EXISTS;
3237 }
3238
3239 /*------------------------------------------------------------------------
3240 Check if any Mgmt Frm is pending
3241 ------------------------------------------------------------------------*/
3242 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3243 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3244 {
3245
3246 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3247 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3248
3249
3250 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303251 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3252 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003253
3254 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3255 // (v_PVOID_t)&pfnTxComp);
3256
3257 /*it should never be NULL - default handler should be registered if none*/
3258 //if ( NULL == pfnTxComp )
3259 //{
3260 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3261 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3262 // VOS_ASSERT(0);
3263 // return VOS_STATUS_E_FAULT;
3264 //}
3265
3266 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3267 //return VOS_STATUS_E_BUSY;
3268
3269
3270 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3271 return VOS_STATUS_E_RESOURCES;
3272 }
3273
3274
3275 /*------------------------------------------------------------------------
3276 Check if BD header was build, if not construct
3277 ------------------------------------------------------------------------*/
3278 if ( NULL == pvBDHeader )
3279 {
3280 v_MACADDR_t* pvAddr2MacAddr;
3281 v_U8_t uQosHdr = VOS_FALSE;
3282
3283 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3284 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3285 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3286 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3287
3288 if ( VOS_STATUS_SUCCESS != vosStatus )
3289 {
3290 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3291 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3292 return vosStatus;
3293 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303294
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003295 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 * for management functionality comes through route.
3297 */
3298 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3299 {
3300 uQosHdr = VOS_TRUE;
3301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 /*----------------------------------------------------------------------
3303 Call WDA to build TX header
3304 ----------------------------------------------------------------------*/
3305 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3306 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
3307 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
3308 ucAckResponse, usTimeStamp, 0, 0 );
3309
3310
3311 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3312 {
3313 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3314 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3315 return vosStatus;
3316 }
3317 }/* if BD header not present */
3318
3319 /*------------------------------------------------------------------------
3320 Save buffer and notify BAL; no lock is needed if the above restriction
3321 is met
3322 Save the tx complete fnct pointer as tl specific data in the vos buffer
3323 ------------------------------------------------------------------------*/
3324 if ( NULL != pfnCompTxFunc )
3325 {
3326 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3327 (v_PVOID_t)pfnCompTxFunc);
3328 }
3329 else
3330 {
3331 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3332 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3333
3334 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303335 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3336 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003337
3338 /*------------------------------------------------------------------------
3339 Check if thre are enough resources for transmission and tx is not
3340 suspended.
3341 ------------------------------------------------------------------------*/
3342 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3343 {
3344 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3345 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3346 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3347 if(VOS_STATUS_SUCCESS != vosStatus)
3348 {
3349 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3350 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303351 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 }
3353 return vosStatus;
3354
3355 }
3356 else
3357 {
3358 /*---------------------------------------------------------------------
3359 No error code is sent because TL will resume tx autonomously if
3360 resources become available or tx gets resumed
3361 ---------------------------------------------------------------------*/
3362 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3363 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3364 pTLCb->uResCount));
3365 }
3366
3367 return VOS_STATUS_SUCCESS;
3368}/* WLANTL_TxMgmtFrm */
3369
3370/*----------------------------------------------------------------------------
3371 INTERACTION WITH HAL
3372 ---------------------------------------------------------------------------*/
3373
3374/*==========================================================================
3375
3376 FUNCTION WLANTL_ResetNotification
3377
3378 DESCRIPTION
3379 HAL notifies TL when the module is being reset.
3380 Currently not used.
3381
3382 DEPENDENCIES
3383
3384 PARAMETERS
3385
3386 IN
3387 pvosGCtx: pointer to the global vos context; a handle to TL's
3388 control block can be extracted from its context
3389
3390
3391 RETURN VALUE
3392 The result code associated with performing the operation
3393
3394 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3395 page fault
3396 VOS_STATUS_SUCCESS: Everything is good :)
3397
3398 SIDE EFFECTS
3399
3400============================================================================*/
3401VOS_STATUS
3402WLANTL_ResetNotification
3403(
3404 v_PVOID_t pvosGCtx
3405)
3406{
3407 WLANTL_CbType* pTLCb = NULL;
3408 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3409
3410 /*------------------------------------------------------------------------
3411 Sanity check
3412 Extract TL control block
3413 ------------------------------------------------------------------------*/
3414 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3415 if ( NULL == pTLCb )
3416 {
3417 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3418 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3419 return VOS_STATUS_E_FAULT;
3420 }
3421
3422 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3423 return VOS_STATUS_SUCCESS;
3424}/* WLANTL_ResetNotification */
3425
3426/*==========================================================================
3427
3428 FUNCTION WLANTL_SuspendDataTx
3429
3430 DESCRIPTION
3431 HAL calls this API when it wishes to suspend transmission for a
3432 particular STA.
3433
3434 DEPENDENCIES
3435 The STA for which the request is made must be first registered with
3436 TL by HDD.
3437
3438 RESTRICTION: In case of a suspend, the flag write and read will not be
3439 locked: worst case scenario one more packet can get
3440 through before the flag gets updated (we can make this
3441 write atomic as well to guarantee consistency)
3442
3443 PARAMETERS
3444
3445 IN
3446 pvosGCtx: pointer to the global vos context; a handle to TL's
3447 control block can be extracted from its context
3448 pucSTAId: identifier of the station for which the request is made;
3449 a value of NULL assumes suspend on all active station
3450 pfnSuspendTxCB: pointer to the suspend result notification in case the
3451 call is asynchronous
3452
3453
3454 RETURN VALUE
3455 The result code associated with performing the operation
3456
3457 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3458 to TL cb is NULL ; access would cause a page fault
3459 VOS_STATUS_E_EXISTS: Station was not registered
3460 VOS_STATUS_SUCCESS: Everything is good :)
3461
3462 SIDE EFFECTS
3463
3464============================================================================*/
3465
3466VOS_STATUS
3467WLANTL_SuspendDataTx
3468(
3469 v_PVOID_t pvosGCtx,
3470 v_U8_t* pucSTAId,
3471 WLANTL_SuspendCBType pfnSuspendTx
3472)
3473{
3474 WLANTL_CbType* pTLCb = NULL;
3475 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003476
3477 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3478
3479 /*------------------------------------------------------------------------
3480 Sanity check
3481 Extract TL control block
3482 ------------------------------------------------------------------------*/
3483 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003484 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 {
3486 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3487 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3488 return VOS_STATUS_E_FAULT;
3489 }
3490
3491 /*------------------------------------------------------------------------
3492 Check the type of request: generic suspend, or per station suspend
3493 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003494 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 {
3496 /* General Suspend Request received */
3497 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3498 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003499 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3501 }
3502 else
3503 {
Hoonki Lee14621352013-04-16 17:51:19 -07003504 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 {
Hoonki Lee14621352013-04-16 17:51:19 -07003506 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3507 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3508 return VOS_STATUS_E_FAULT;
3509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003510
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303511 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3512 {
3513 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3514 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3515 "WLANTL_SuspendDataTx", *pucSTAId));
3516 return VOS_STATUS_E_FAULT;
3517 }
3518
3519 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003520 {
3521 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3522 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3523 return VOS_STATUS_E_EXISTS;
3524 }
3525
3526 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3527 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3528 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 vosMsg.reserved = *pucSTAId;
3530 }
3531
3532 /*------------------------------------------------------------------------
3533 Serialize request through TX thread
3534 ------------------------------------------------------------------------*/
3535 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3536 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3537
Katya Nigam42e16e82014-02-04 16:28:55 +05303538 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3539 vosMsg.reserved , 0 ));
3540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3542 {
3543 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003544 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 }
3546
3547 return VOS_STATUS_SUCCESS;
3548}/* WLANTL_SuspendDataTx */
3549
3550/*==========================================================================
3551
3552 FUNCTION WLANTL_ResumeDataTx
3553
3554 DESCRIPTION
3555 Called by HAL to resume data transmission for a given STA.
3556
3557 WARNING: If a station was individually suspended a global resume will
3558 not resume that station
3559
3560 DEPENDENCIES
3561
3562 PARAMETERS
3563
3564 IN
3565 pvosGCtx: pointer to the global vos context; a handle to TL's
3566 control block can be extracted from its context
3567 pucSTAId: identifier of the station which is being resumed; NULL
3568 translates into global resume
3569
3570 RETURN VALUE
3571 The result code associated with performing the operation
3572
3573 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3574 to TL cb is NULL ; access would cause a page fault
3575 VOS_STATUS_E_EXISTS: Station was not registered
3576 VOS_STATUS_SUCCESS: Everything is good :)
3577
3578 SIDE EFFECTS
3579
3580============================================================================*/
3581
3582VOS_STATUS
3583WLANTL_ResumeDataTx
3584(
3585 v_PVOID_t pvosGCtx,
3586 v_U8_t* pucSTAId
3587)
3588{
3589 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3591
3592 /*------------------------------------------------------------------------
3593 Sanity check
3594 Extract TL control block
3595 ------------------------------------------------------------------------*/
3596 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003597 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 {
3599 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3600 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3601 return VOS_STATUS_E_FAULT;
3602 }
3603
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 /*------------------------------------------------------------------------
3605 Check to see the type of resume
3606 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003607 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303609 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3610 41 , 0 ));
3611
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3613 "WLAN TL:General resume requested"));
3614 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 }
3616 else
3617 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303618 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3619 *pucSTAId , 0 ));
3620
Hoonki Lee14621352013-04-16 17:51:19 -07003621 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 {
Hoonki Lee14621352013-04-16 17:51:19 -07003623 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3624 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3625 return VOS_STATUS_E_FAULT;
3626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003627
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303628 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3629 {
3630 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3631 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3632 "WLANTL_ResumeDataTx", *pucSTAId));
3633 return VOS_STATUS_E_FAULT;
3634 }
3635
3636 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003637 {
3638 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3639 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3640 return VOS_STATUS_E_EXISTS;
3641 }
3642
3643 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3644 "WLAN TL:Resume request for station: %d", *pucSTAId));
3645 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 }
3647
3648 /*------------------------------------------------------------------------
3649 Resuming transmission
3650 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003651 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3652 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 {
3654 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3655 "WLAN TL:Resuming transmission"));
3656 return WDA_DS_StartXmit(pvosGCtx);
3657 }
3658
3659 return VOS_STATUS_SUCCESS;
3660}/* WLANTL_ResumeDataTx */
3661
3662/*==========================================================================
3663 FUNCTION WLANTL_SuspendCB
3664
3665 DESCRIPTION
3666 Callback function for serializing Suspend signal through Tx thread
3667
3668 DEPENDENCIES
3669 Just notify HAL that suspend in TL is complete.
3670
3671 PARAMETERS
3672
3673 IN
3674 pvosGCtx: pointer to the global vos context; a handle to TL's
3675 control block can be extracted from its context
3676 pUserData: user data sent with the callback
3677
3678 RETURN VALUE
3679 The result code associated with performing the operation
3680
3681 VOS_STATUS_E_INVAL: invalid input parameters
3682 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3683 page fault
3684 VOS_STATUS_SUCCESS: Everything is good :)
3685
3686
3687 SIDE EFFECTS
3688
3689============================================================================*/
3690VOS_STATUS
3691WLANTL_SuspendCB
3692(
3693 v_PVOID_t pvosGCtx,
3694 WLANTL_SuspendCBType pfnSuspendCB,
3695 v_U16_t usReserved
3696)
3697{
3698 WLANTL_CbType* pTLCb = NULL;
3699 v_U8_t ucSTAId = (v_U8_t)usReserved;
3700 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3701
3702 /*------------------------------------------------------------------------
3703 Sanity check
3704 ------------------------------------------------------------------------*/
3705 if ( NULL == pfnSuspendCB )
3706 {
3707 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3708 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3709 return VOS_STATUS_SUCCESS;
3710 }
3711
3712 /*------------------------------------------------------------------------
3713 Extract TL control block
3714 ------------------------------------------------------------------------*/
3715 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3716 if ( NULL == pTLCb )
3717 {
3718 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3719 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3720 return VOS_STATUS_E_FAULT;
3721 }
3722
3723 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3724 {
3725 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3726 }
3727 else
3728 {
3729 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3730 }
3731
3732 return VOS_STATUS_SUCCESS;
3733}/*WLANTL_SuspendCB*/
3734
3735
3736/*----------------------------------------------------------------------------
3737 CLIENT INDEPENDENT INTERFACE
3738 ---------------------------------------------------------------------------*/
3739
3740/*==========================================================================
3741
3742 FUNCTION WLANTL_GetTxPktCount
3743
3744 DESCRIPTION
3745 TL will provide the number of transmitted packets counted per
3746 STA per TID.
3747
3748 DEPENDENCIES
3749
3750 PARAMETERS
3751
3752 IN
3753 pvosGCtx: pointer to the global vos context; a handle to TL's
3754 control block can be extracted from its context
3755 ucSTAId: identifier of the station
3756 ucTid: identifier of the tspec
3757
3758 OUT
3759 puTxPktCount: the number of packets tx packet for this STA and TID
3760
3761 RETURN VALUE
3762 The result code associated with performing the operation
3763
3764 VOS_STATUS_E_INVAL: Input parameters are invalid
3765 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3766 to TL cb is NULL ; access would cause a page fault
3767 VOS_STATUS_E_EXISTS: Station was not registered
3768 VOS_STATUS_SUCCESS: Everything is good :)
3769
3770 SIDE EFFECTS
3771
3772============================================================================*/
3773VOS_STATUS
3774WLANTL_GetTxPktCount
3775(
3776 v_PVOID_t pvosGCtx,
3777 v_U8_t ucSTAId,
3778 v_U8_t ucTid,
3779 v_U32_t* puTxPktCount
3780)
3781{
3782 WLANTL_CbType* pTLCb = NULL;
3783 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3784
3785 /*------------------------------------------------------------------------
3786 Sanity check
3787 ------------------------------------------------------------------------*/
3788 if ( NULL == puTxPktCount )
3789 {
3790 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3791 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3792 return VOS_STATUS_E_INVAL;
3793 }
3794
3795 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3796 {
3797 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3798 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3799 ucSTAId, ucTid));
3800 return VOS_STATUS_E_FAULT;
3801 }
3802
3803 /*------------------------------------------------------------------------
3804 Extract TL control block and check if station exists
3805 ------------------------------------------------------------------------*/
3806 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3807 if ( NULL == pTLCb )
3808 {
3809 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3810 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3811 return VOS_STATUS_E_FAULT;
3812 }
3813
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303814 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3815 {
3816 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3817 "WLAN TL:Client Memory was not allocated on %s", __func__));
3818 return VOS_STATUS_E_FAILURE;
3819 }
3820
3821 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 {
3823 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3824 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3825 ucSTAId));
3826 return VOS_STATUS_E_EXISTS;
3827 }
3828
3829 /*------------------------------------------------------------------------
3830 Return data
3831 ------------------------------------------------------------------------*/
3832 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3833 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3834 // ucSTAId, ucTid);
3835
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303836 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003837
3838 return VOS_STATUS_SUCCESS;
3839}/* WLANTL_GetTxPktCount */
3840
3841/*==========================================================================
3842
3843 FUNCTION WLANTL_GetRxPktCount
3844
3845 DESCRIPTION
3846 TL will provide the number of received packets counted per
3847 STA per TID.
3848
3849 DEPENDENCIES
3850
3851 PARAMETERS
3852
3853 IN
3854 pvosGCtx: pointer to the global vos context; a handle to TL's
3855 control block can be extracted from its context
3856 ucSTAId: identifier of the station
3857 ucTid: identifier of the tspec
3858
3859 OUT
3860 puTxPktCount: the number of packets rx packet for this STA and TID
3861
3862 RETURN VALUE
3863 The result code associated with performing the operation
3864
3865 VOS_STATUS_E_INVAL: Input parameters are invalid
3866 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3867 to TL cb is NULL ; access would cause a page fault
3868 VOS_STATUS_E_EXISTS: Station was not registered
3869 VOS_STATUS_SUCCESS: Everything is good :)
3870
3871 SIDE EFFECTS
3872
3873============================================================================*/
3874VOS_STATUS
3875WLANTL_GetRxPktCount
3876(
3877 v_PVOID_t pvosGCtx,
3878 v_U8_t ucSTAId,
3879 v_U8_t ucTid,
3880 v_U32_t* puRxPktCount
3881)
3882{
3883 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303884 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3886
3887 /*------------------------------------------------------------------------
3888 Sanity check
3889 ------------------------------------------------------------------------*/
3890 if ( NULL == puRxPktCount )
3891 {
3892 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3893 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3894 return VOS_STATUS_E_INVAL;
3895 }
3896
3897 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3898 {
3899 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3900 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
3901 ucSTAId, ucTid));
3902 return VOS_STATUS_E_FAULT;
3903 }
3904
3905 /*------------------------------------------------------------------------
3906 Extract TL control block and existance
3907 ------------------------------------------------------------------------*/
3908 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3909 if ( NULL == pTLCb )
3910 {
3911 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3912 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
3913 return VOS_STATUS_E_FAULT;
3914 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303915 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07003916
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303917 if ( NULL == pClientSTA )
3918 {
3919 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3920 "WLAN TL:Client Memory was not allocated on %s", __func__));
3921 return VOS_STATUS_E_FAILURE;
3922 }
3923
3924 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 {
3926 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3927 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
3928 return VOS_STATUS_E_EXISTS;
3929 }
3930
3931 /*------------------------------------------------------------------------
3932 Return data
3933 ------------------------------------------------------------------------*/
3934 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3935 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
3936 ucSTAId, ucTid));
3937
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303938 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003939
3940 return VOS_STATUS_SUCCESS;
3941}/* WLANTL_GetRxPktCount */
3942
Jeff Johnson295189b2012-06-20 16:38:30 -07003943VOS_STATUS
3944WLANTL_TxFCFrame
3945(
3946 v_PVOID_t pvosGCtx
3947);
Jeff Johnson295189b2012-06-20 16:38:30 -07003948/*============================================================================
3949 TL INTERNAL API DEFINITION
3950============================================================================*/
3951
3952/*==========================================================================
3953
3954 FUNCTION WLANTL_GetFrames
3955
3956 DESCRIPTION
3957
3958 BAL calls this function at the request of the lower bus interface.
3959 When this request is being received TL will retrieve packets from HDD
3960 in accordance with the priority rules and the count supplied by BAL.
3961
3962 DEPENDENCIES
3963
3964 HDD must have registered with TL at least one STA before this function
3965 can be called.
3966
3967 PARAMETERS
3968
3969 IN
3970 pvosGCtx: pointer to the global vos context; a handle to TL's
3971 or BAL's control block can be extracted from its context
3972 uSize: maximum size accepted by the lower layer
3973 uFlowMask TX flow control mask for Prima. Each bit is defined as
3974 WDA_TXFlowEnumType
3975
3976 OUT
3977 vosDataBuff: it will contain a pointer to the first buffer supplied
3978 by TL, if there is more than one packet supplied, TL
3979 will chain them through vOSS buffers
3980
3981 RETURN VALUE
3982
3983 The result code associated with performing the operation
3984
3985 1 or more: number of required resources if there are still frames to fetch
3986 0 : error or HDD queues are drained
3987
3988 SIDE EFFECTS
3989
3990 NOTE
3991
3992 Featurized uFlowMask. If we want to remove featurization, we need to change
3993 BAL on Volans.
3994
3995============================================================================*/
3996v_U32_t
3997WLANTL_GetFrames
3998(
3999 v_PVOID_t pvosGCtx,
4000 vos_pkt_t **ppFrameDataBuff,
4001 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 v_BOOL_t* pbUrgent
4004)
4005{
4006 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4007 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304008 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 v_U32_t uRemaining = uSize;
4010 vos_pkt_t* vosRoot;
4011 vos_pkt_t* vosTempBuf;
4012 WLANTL_STAFuncType pfnSTAFsm;
4013 v_U16_t usPktLen;
4014 v_U32_t uResLen;
4015 v_U8_t ucSTAId;
4016 v_U8_t ucAC;
4017 vos_pkt_t* vosDataBuff;
4018 v_U32_t uTotalPktLen;
4019 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004020 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 v_U32_t ucResult = 0;
4022 VOS_STATUS vosStatus;
4023 WLANTL_STAEventType wSTAEvent;
4024 tBssSystemRole systemRole;
4025 tpAniSirGlobal pMac;
4026 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4027
4028 /*------------------------------------------------------------------------
4029 Sanity check
4030 Extract TL control block
4031 ------------------------------------------------------------------------*/
4032 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4033 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4034 {
4035 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4036 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4037 return ucResult;
4038 }
4039
4040 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4041 if ( NULL == pMac )
4042 {
4043 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004044 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 return ucResult;
4046 }
4047
4048 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4049 each iteration */
4050
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004052
4053 /*-----------------------------------------------------------------------
4054 Save the root as we will walk this chain as we fill it
4055 -----------------------------------------------------------------------*/
4056 vosRoot = vosDataBuff;
4057
4058 /*-----------------------------------------------------------------------
4059 There is still data - until FSM function says otherwise
4060 -----------------------------------------------------------------------*/
4061 pTLCb->bUrgent = FALSE;
4062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4064 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
4066 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004067#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4068/* FIXME: The code has been disabled since it is creating issues in power save */
4069 if (eSYSTEM_AP_ROLE == systemRole)
4070 {
4071 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4072 {
4073 WLANTL_TxFCFrame (pvosGCtx);
4074 pTLCb->done_once ++;
4075 }
4076 }
4077 if ( NULL != pTLCb->vosTxFCBuf )
4078 {
4079 //there is flow control packet waiting to be sent
4080 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4081
4082 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004083 ( uRemaining > uTotalPktLen ) &&
4084 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 {
4086 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4087 "WLAN TL:Chaining FC frame first on GetFrame"));
4088
4089 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4090
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304091 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004092
4093 /*FC frames cannot be delayed*/
4094 pTLCb->bUrgent = TRUE;
4095
4096 /*Update remaining len from SSC */
4097 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4098
4099 /*Update resource count */
4100 pTLCb->uResCount -= uResLen;
4101 }
4102 else
4103 {
4104 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004105 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4107 break; /* Out of resources or reached max len */
4108 }
4109 }
4110 else
4111#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004112
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004113 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4114 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 {
4116 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4117 usPktLen, uResLen, uTotalPktLen);
4118
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004119 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4120 {
4121 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4122 VOS_ASSERT(0);
4123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004124
4125 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004126 ( uRemaining > uTotalPktLen ) &&
4127 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 {
4129 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4130 "WLAN TL:Chaining management frame on GetFrame"));
4131
4132 vos_pkt_chain_packet( vosDataBuff,
4133 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4134 1 /*true*/ );
4135
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304136 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4137 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004138
4139 /*management frames cannot be delayed*/
4140 pTLCb->bUrgent = TRUE;
4141
4142 /*Update remaining len from SSC */
4143 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4144
4145 /*Update resource count */
4146 pTLCb->uResCount -= uResLen;
4147 }
4148 else
4149 {
4150 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4151 break; /* Out of resources or reached max len */
4152 }
4153 }
4154 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4155 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004156 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 {
4158 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4159 usPktLen, uResLen, uTotalPktLen);
4160
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004161 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4162 {
4163 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4164 VOS_ASSERT(0);
4165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004166
4167 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4168 ( uRemaining > uTotalPktLen ))
4169 {
4170 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4171 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4172
4173 vos_pkt_chain_packet( vosDataBuff,
4174 pTLCb->tlBAPClient.vosPendingDataBuff,
4175 1 /*true*/ );
4176
4177 /*BAP frames cannot be delayed*/
4178 pTLCb->bUrgent = TRUE;
4179
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304180 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4181 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182
4183 /*Update remaining len from SSC */
4184 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4185
4186 /*Update resource count */
4187 pTLCb->uResCount -= uResLen;
4188 }
4189 else
4190 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 break; /* Out of resources or reached max len */
4193 }
4194 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004195 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4196 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4197 by default, EAPOL will be treated as higher priority, which means
4198 use mgmt_pool and DXE_TX_HI prority channel.
4199 this is introduced to address EAPOL failure under high background traffic
4200 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4201 see CR#387009 and WCNSOS-8
4202 */
4203 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4204 ( 0 == pTLCb->ucTxSuspended ) &&
4205 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4206 )
4207 {
4208 vosTempBuf = NULL;
4209 /*---------------------------------------------------------------------
4210 Check to see if there was any EAPOL packet is pending
4211 *--------------------------------------------------------------------*/
4212 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4213 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304214 if ((NULL != pTLCb->atlSTAClients[i]) &&
4215 (pTLCb->atlSTAClients[i]->ucExists) &&
4216 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004217 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4218 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004219 )
4220 break;
4221 }
4222
4223 if (i >= WLAN_MAX_STA_COUNT)
4224 {
4225 /* No More to Serve Exit Get Frames */
4226 break;
4227 }
4228 /* Serve EAPOL frame with HI_FLOW_MASK */
4229 ucSTAId = i;
4230
Katya Nigam42e16e82014-02-04 16:28:55 +05304231 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4232 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pTLCb->atlSTAClients[i]->tlState));
4233
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004234 for (j = WLANTL_MAX_AC ; j > 0; j--)
4235 {
4236 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4237 {
4238 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4239 pTLCb->uCurServedAC = j-1;
4240 }
4241 }
4242
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304243 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4244
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004245 wSTAEvent = WLANTL_TX_EVENT;
4246
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304247 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004248 pfnSTATbl[wSTAEvent];
4249
4250 if ( NULL != pfnSTAFsm )
4251 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304252 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004253 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004254
4255 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4256 ( NULL != vosTempBuf ))
4257 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304258 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004259 vosTempBuf = NULL;
4260 break;
4261 }/* status success*/
4262 }
4263
4264 if (NULL != vosTempBuf)
4265 {
4266 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4267
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004268 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4269 {
4270 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4271 VOS_ASSERT(0);
4272 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004273
4274 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4275 "WLAN TL:Resources needed by frame: %d", uResLen));
4276
4277 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4278 ( uRemaining > uTotalPktLen )
4279 )
4280 {
4281 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4282 "WLAN TL:Chaining data frame on GetFrame"));
4283
4284 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4285
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004286 /*EAPOL frame cannot be delayed*/
4287 pTLCb->bUrgent = TRUE;
4288
4289 vosTempBuf = NULL;
4290
4291 /*Update remaining len from SSC */
4292 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4293
4294 /*Update resource count */
4295 pTLCb->uResCount -= uResLen;
4296
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004297 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304298 pClientSTA->uIngress_length += uResLen;
4299 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4300 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004301 pClientSTA->ucEapolPktPending = 0;
4302 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4303 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4304 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004305 }
4306 }
4307 else
4308 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004309 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4310 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4311 ucSTAId));
4312 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004313 }
4314 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004315
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004316 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4317 ( 0 == pTLCb->ucTxSuspended ) &&
4318 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4319 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4320 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4321 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 {
4323 /*---------------------------------------------------------------------
4324 Check to see if there was any packet left behind previously due to
4325 size constraints
4326 ---------------------------------------------------------------------*/
4327 vosTempBuf = NULL;
4328
4329 if ( NULL != pTLCb->vosTempBuf )
4330 {
4331 vosTempBuf = pTLCb->vosTempBuf;
4332 pTLCb->vosTempBuf = NULL;
4333 ucSTAId = pTLCb->ucCachedSTAId;
4334 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304335
4336 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4337 {
4338 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4339 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304340 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304341 }
4342
4343 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304344 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004345
4346 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4347 "WLAN TL:Chaining cached data frame on GetFrame"));
4348 }
4349 else
4350 {
4351 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4352 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4353 {
4354 /* Packets start coming in even after insmod Without *
4355 starting Hostapd or Interface being up *
4356 During which cases STAID is invaled and hence
4357 the check. HalMsg_ScnaComplete Triggers */
4358
4359 break;
4360 }
4361 /* ucCurrentAC should have correct AC to be served by calling
4362 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304363 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304364 if ( NULL == pClientSTA )
4365 {
4366 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4367 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304368 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304369 }
4370
4371 ucAC = pClientSTA->ucCurrentAC;
4372
4373 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004375 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 /*-------------------------------------------------------------------
4377 Check to see that STA is valid and tx is not suspended
4378 -------------------------------------------------------------------*/
4379 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304380 ( 0 == pClientSTA->ucTxSuspended ) &&
4381 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 {
4383 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004384 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 wSTAEvent = WLANTL_TX_EVENT;
4386
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304387 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 pfnSTATbl[wSTAEvent];
4389
4390 if ( NULL != pfnSTAFsm )
4391 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304392 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004393 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004394
4395 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4396 ( NULL != vosTempBuf ))
4397 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304398 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 vosTempBuf,
4400 vosStatus );
4401 vosTempBuf = NULL;
4402 }/* status success*/
4403 }/*NULL function state*/
4404 }/* valid STA id and ! suspended*/
4405 else
4406 {
4407 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4408 {
4409 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4410 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4411 ucSTAId));
4412 }
4413 }
4414 }/* data */
4415
4416 if ( NULL != vosTempBuf )
4417 {
4418 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4419
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004420 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4421 {
4422 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4423 VOS_ASSERT(0);
4424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004425
4426 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4427 "WLAN TL:Resources needed by frame: %d", uResLen));
4428
4429 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004430 ( uRemaining > uTotalPktLen ) &&
4431 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 {
4433 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4434 "WLAN TL:Chaining data frame on GetFrame"));
4435
4436 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4437 vosTempBuf = NULL;
4438
4439 /*Update remaining len from SSC */
4440 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4441
4442 /*Update resource count */
4443 pTLCb->uResCount -= uResLen;
4444
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304446 pClientSTA->uIngress_length += uResLen;
4447 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4448 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004449
4450 }
4451 else
4452 {
4453 /* Store this for later tx - already fetched from HDD */
4454 pTLCb->vosTempBuf = vosTempBuf;
4455 pTLCb->ucCachedSTAId = ucSTAId;
4456 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4458 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4459 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 break; /* Out of resources or reached max len */
4461 }
4462 }
4463 else
4464 {
4465 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4466 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304467 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4468 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 {
4470 /* There is station to be Served */
4471 break;
4472 }
4473 }
4474 if (i >= WLAN_MAX_STA_COUNT)
4475 {
4476 /* No More to Serve Exit Get Frames */
4477 break;
4478 }
4479 else
4480 {
4481 /* More to be Served */
4482 continue;
4483 }
4484 }
4485 }
4486 else
4487 {
4488 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4489 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4490 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 /* TL is starving even when DXE is not in low resource condition
4492 Return min resource number required and Let DXE deceide what to do */
4493 if(( 0 == pTLCb->ucTxSuspended ) &&
4494 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4495 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4496 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4497 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4498 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004499 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 "WLAN TL:Returning from GetFrame: resources = %d",
4501 pTLCb->uResCount));
4502 ucResult = WDA_TLI_MIN_RES_DATA;
4503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 break; /*out of min data resources*/
4505 }
4506
4507 pTLCb->usPendingTxCompleteCount++;
4508 /* Move data buffer up one packet */
4509 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4510 }
4511
4512 /*----------------------------------------------------------------------
4513 Packet chain starts at root + 1
4514 ----------------------------------------------------------------------*/
4515 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4516
4517 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004518 if (pbUrgent)
4519 {
4520 *pbUrgent = pTLCb->bUrgent;
4521 }
4522 else
4523 {
4524 VOS_ASSERT( pbUrgent );
4525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 return ucResult;
4527}/* WLANTL_GetFrames */
4528
4529
4530/*==========================================================================
4531
4532 FUNCTION WLANTL_TxComp
4533
4534 DESCRIPTION
4535 It is being called by BAL upon asynchronous notification of the packet
4536 or packets being sent over the bus.
4537
4538 DEPENDENCIES
4539 Tx complete cannot be called without a previous transmit.
4540
4541 PARAMETERS
4542
4543 IN
4544 pvosGCtx: pointer to the global vos context; a handle to TL's
4545 or BAL's control block can be extracted from its context
4546 vosDataBuff: it will contain a pointer to the first buffer for which
4547 the BAL report is being made, if there is more then one
4548 packet they will be chained using vOSS buffers.
4549 wTxStatus: the status of the transmitted packet, see above chapter
4550 on HDD interaction for a list of possible values
4551
4552 RETURN VALUE
4553 The result code associated with performing the operation
4554
4555 VOS_STATUS_E_INVAL: Input parameters are invalid
4556 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4557 page fault
4558 VOS_STATUS_E_EXISTS: Station was not registered
4559 VOS_STATUS_SUCCESS: Everything is good :)
4560
4561 SIDE EFFECTS
4562
4563============================================================================*/
4564VOS_STATUS
4565WLANTL_TxComp
4566(
4567 v_PVOID_t pvosGCtx,
4568 vos_pkt_t *pFrameDataBuff,
4569 VOS_STATUS wTxStatus
4570)
4571{
4572 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4573 WLANTL_CbType* pTLCb = NULL;
4574 WLANTL_TxCompCBType pfnTxComp = NULL;
4575 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 vos_pkt_t* vosTempTx = NULL;
4577
4578 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4579
4580 /*------------------------------------------------------------------------
4581 Sanity check
4582 ------------------------------------------------------------------------*/
4583 if ( NULL == vosDataBuff )
4584 {
4585 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4586 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4587 return VOS_STATUS_E_INVAL;
4588 }
4589
4590 /*------------------------------------------------------------------------
4591 Extract TL control block
4592 ------------------------------------------------------------------------*/
4593 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4594 if ( NULL == pTLCb )
4595 {
4596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4597 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4598 return VOS_STATUS_E_FAULT;
4599 }
4600
4601 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4602 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4603 ( NULL != vosDataBuff))
4604 {
4605 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4606 (v_PVOID_t)&pfnTxComp);
4607
4608 /*it should never be NULL - default handler should be registered if none*/
4609 if ( NULL == pfnTxComp )
4610 {
4611 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4612 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4613 VOS_ASSERT(0);
4614 return VOS_STATUS_E_FAULT;
4615 }
4616
4617 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304618 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 vosDataBuff, pfnTxComp));
4620
4621 vosTempTx = vosDataBuff;
4622 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4623 &vosDataBuff, 1/*true*/);
4624
4625 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4626
4627 pTLCb->usPendingTxCompleteCount--;
4628 }
4629
Jeff Johnson295189b2012-06-20 16:38:30 -07004630
4631 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4632 "WLAN TL: current TL values are: resources = %d "
4633 "pTLCb->usPendingTxCompleteCount = %d",
4634 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4635
4636 return VOS_STATUS_SUCCESS;
4637}/* WLANTL_TxComp */
4638
4639/*==========================================================================
4640
4641 FUNCTION WLANTL_CacheSTAFrame
4642
4643 DESCRIPTION
4644 Internal utility function for for caching incoming data frames that do
4645 not have a registered station yet.
4646
4647 DEPENDENCIES
4648 TL must be initiailized before this function gets called.
4649 In order to benefit from thsi caching, the components must ensure that
4650 they will only register with TL at the moment when they are fully setup
4651 and ready to receive incoming data
4652
4653 PARAMETERS
4654
4655 IN
4656
4657 pTLCb: TL control block
4658 ucSTAId: station id
4659 vosTempBuff: the data packet
4660 uDPUSig: DPU signature of the incoming packet
4661 bBcast: true if packet had the MC/BC bit set
4662
4663 RETURN VALUE
4664 The result code associated with performing the operation
4665
4666 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4667 would cause a page fault
4668 VOS_STATUS_SUCCESS: Everything is good :)
4669
4670 SIDE EFFECTS
4671
4672============================================================================*/
4673static VOS_STATUS
4674WLANTL_CacheSTAFrame
4675(
4676 WLANTL_CbType* pTLCb,
4677 v_U8_t ucSTAId,
4678 vos_pkt_t* vosTempBuff,
4679 v_U32_t uDPUSig,
4680 v_U8_t bBcast,
4681 v_U8_t ucFrmType
4682)
4683{
4684 v_U8_t ucUcastSig;
4685 v_U8_t ucBcastSig;
4686 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304687 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4689
4690 /*-------------------------------------------------------------------------
4691 Sanity check
4692 -------------------------------------------------------------------------*/
4693 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4694 {
4695 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304696 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4697 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 return VOS_STATUS_E_FAULT;
4699 }
4700
4701 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4702 {
4703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4704 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4705 return VOS_STATUS_E_FAULT;
4706 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304707 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4708
4709 if ( NULL == pClientSTA )
4710 {
4711 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4712 "WLAN TL:Client Memory was not allocated on %s", __func__));
4713 return VOS_STATUS_E_FAILURE;
4714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004715
4716 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4717 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4718 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304719 pClientSTA->wSTADesc.ucUcastSig,
4720 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004721
4722 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4723 {
4724 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4725 "WLAN TL: No need to cache CTRL frame. Dropping"));
4726 vos_pkt_return_packet(vosTempBuff);
4727 return VOS_STATUS_SUCCESS;
4728 }
4729
4730 /*-------------------------------------------------------------------------
4731 Check if the packet that we are trying to cache belongs to the old
4732 registered station (if any) or the new (potentially)upcoming station
4733
4734 - If the STA with this Id was never registered with TL - the signature
4735 will be invalid;
4736 - If the STA was previously registered TL will have cached the former
4737 set of DPU signatures
4738 -------------------------------------------------------------------------*/
4739 if ( bBcast )
4740 {
4741 ucBcastSig = (v_U8_t)uDPUSig;
4742 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304743 pClientSTA->wSTADesc.ucBcastSig ) &&
4744 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 }
4746 else
4747 {
4748 ucUcastSig = (v_U8_t)uDPUSig;
4749 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304750 pClientSTA->wSTADesc.ucUcastSig ) &&
4751 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 }
4753
4754 /*------------------------------------------------------------------------
4755 If the value of the DPU SIG matches the old, this packet will not
4756 be cached as it belonged to the former association
4757 In case the SIG does not match - this is a packet for a potentially new
4758 associated station
4759 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004760 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 {
4762 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4763 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4764 "BC: %d - dropping",
4765 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304766 pClientSTA->wSTADesc.ucUcastSig,
4767 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 vos_pkt_return_packet(vosTempBuff);
4769 }
4770 else
4771 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304772 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 {
4774 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304775 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05304776
4777 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
4778 pClientSTA->tlCacheInfo.cacheDoneTime =
4779 pClientSTA->tlCacheInfo.cacheInitTime;
4780 pClientSTA->tlCacheInfo.cacheSize = 1;
4781
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304782 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
4783 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
4784
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 }
4786 else
4787 {
4788 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304789 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05304791
4792 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
4793 pClientSTA->tlCacheInfo.cacheSize ++;
4794
4795 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
4796 {
4797 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4798 "%s: Cache High watermark for staid:%d (%d)",
4799 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304800 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
4801 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05304802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304804 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 }/*else new packet*/
4806
4807 return VOS_STATUS_SUCCESS;
4808}/*WLANTL_CacheSTAFrame*/
4809
4810/*==========================================================================
4811
4812 FUNCTION WLANTL_FlushCachedFrames
4813
4814 DESCRIPTION
4815 Internal utility function used by TL to flush the station cache
4816
4817 DEPENDENCIES
4818 TL must be initiailized before this function gets called.
4819
4820 PARAMETERS
4821
4822 IN
4823
4824 vosDataBuff: it will contain a pointer to the first cached buffer
4825 received,
4826
4827 RETURN VALUE
4828 The result code associated with performing the operation
4829
4830 VOS_STATUS_SUCCESS: Everything is good :)
4831
4832 SIDE EFFECTS
4833
4834 NOTE
4835 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4836 responsibility to do so, if required, after this function call.
4837 Because of this restriction, we decide to make this function to static
4838 so that upper layer doesn't need to be aware of this restriction.
4839
4840============================================================================*/
4841static VOS_STATUS
4842WLANTL_FlushCachedFrames
4843(
4844 vos_pkt_t* vosDataBuff
4845)
4846{
4847 /*----------------------------------------------------------------------
4848 Return the entire chain to vos if there are indeed cache frames
4849 ----------------------------------------------------------------------*/
4850 if ( NULL != vosDataBuff )
4851 {
4852 vos_pkt_return_packet(vosDataBuff);
4853 }
4854
4855 return VOS_STATUS_SUCCESS;
4856}/*WLANTL_FlushCachedFrames*/
4857
4858/*==========================================================================
4859
4860 FUNCTION WLANTL_ForwardSTAFrames
4861
4862 DESCRIPTION
4863 Internal utility function for either forwarding cached data to the station after
4864 the station has been registered, or flushing cached data if the station has not
4865 been registered.
4866
4867
4868 DEPENDENCIES
4869 TL must be initiailized before this function gets called.
4870
4871 PARAMETERS
4872
4873 IN
4874
4875 pTLCb: TL control block
4876 ucSTAId: station id
4877
4878 RETURN VALUE
4879 The result code associated with performing the operation
4880
4881 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4882 page fault
4883 VOS_STATUS_SUCCESS: Everything is good :)
4884
4885 SIDE EFFECTS
4886 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4887 responsibility to do so, if required, after this function call.
4888 Because of this restriction, we decide to make this function to static
4889 so that upper layer doesn't need to be aware of this restriction.
4890
4891============================================================================*/
4892static VOS_STATUS
4893WLANTL_ForwardSTAFrames
4894(
4895 void* pvosGCtx,
4896 v_U8_t ucSTAId,
4897 v_U8_t ucUcastSig,
4898 v_U8_t ucBcastSig
4899)
4900{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304901 WLANTL_CbType* pTLCb = NULL;
4902 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4904
4905 /*-------------------------------------------------------------------------
4906 Sanity check
4907 -------------------------------------------------------------------------*/
4908 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4909 if ( NULL == pTLCb )
4910 {
4911 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304912 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 pTLCb ));
4914 return VOS_STATUS_E_FAULT;
4915 }
4916
4917 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4918 {
4919 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4920 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
4921 return VOS_STATUS_E_FAULT;
4922 }
4923
4924 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
4925
4926 /*------------------------------------------------------------------------
4927 Check if station has not been registered in the mean while
4928 if not registered, flush cached frames.
4929 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304930 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4931
4932 if ( NULL == pClientSTA )
4933 {
4934 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4935 "WLAN TL:Client Memory was not allocated on %s", __func__));
4936 return VOS_STATUS_E_FAILURE;
4937 }
4938
4939 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 {
4941 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4942 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304943 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
4944 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304945 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 goto done;
4947 }
4948
4949 /*------------------------------------------------------------------------
4950 Forwarding cache frames received while the station was in the process
4951 of being registered with the rest of the SW components
4952
4953 Access to the cache must be locked; similarly updating the signature and
4954 the existence flag must be synchronized because these values are checked
4955 during cached
4956 ------------------------------------------------------------------------*/
4957 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4958 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
4959
4960 /*-----------------------------------------------------------------------
4961 Save the new signature values
4962 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304963 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
4964 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004965
4966 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4967 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
4968 ucSTAId, ucUcastSig, ucBcastSig));
4969
4970 /*-------------------------------------------------------------------------
4971 Check to see if we have any cached data to forward
4972 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304973 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 {
4975 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4976 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
4977
4978 WLANTL_RxCachedFrames( pTLCb,
4979 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304980 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 }
4982 else
4983 {
4984 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4985 "WLAN TL: NO cached packets for station %d", ucSTAId ));
4986 }
4987
4988done:
4989 /*-------------------------------------------------------------------------
4990 Clear the station cache
4991 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304992 pClientSTA->vosBegCachedFrame = NULL;
4993 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05304994 pClientSTA->tlCacheInfo.cacheSize = 0;
4995 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07004996
4997 /*-----------------------------------------------------------------------
4998 After all the init is complete we can mark the existance flag
4999 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305000 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005001
5002 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5003 return VOS_STATUS_SUCCESS;
5004
5005}/*WLANTL_ForwardSTAFrames*/
5006
5007
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005008#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005009/*==========================================================================
5010
5011 FUNCTION WLANTL_IsIAPPFrame
5012
5013 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005014 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005015
5016 DEPENDENCIES
5017
5018 PARAMETERS
5019
5020 IN
5021
5022 pvBDHeader: pointer to the BD header
5023 vosTempBuff: the data packet
5024
5025 IN/OUT
5026 pFirstDataPktArrived: static from caller function; used for rssi
5027 computation
5028 RETURN VALUE
5029 The result code associated with performing the operation
5030
5031 VOS_TRUE: It is a IAPP frame
5032 VOS_FALSE: It is NOT IAPP frame
5033
5034 SIDE EFFECTS
5035
5036============================================================================*/
5037v_BOOL_t
5038WLANTL_IsIAPPFrame
5039(
5040 v_PVOID_t pvBDHeader,
5041 vos_pkt_t* vosTempBuff
5042)
5043{
5044 v_U16_t usMPDUDOffset;
5045 v_U8_t ucOffset;
5046 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5047 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5048 VOS_STATUS vosStatus;
5049
5050 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5051
5052 /*------------------------------------------------------------------------
5053 Check if OUI field is present.
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 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5065 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5066
5067 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5068 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5069
5070 if (( VOS_STATUS_SUCCESS != vosStatus))
5071 {
5072 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5073 "Unable to extract Snap Hdr of data packet -"
5074 "dropping pkt"));
5075 return VOS_FALSE;
5076 }
5077
5078 /*------------------------------------------------------------------------
5079 Check if this is IAPP frame by matching Aironet Snap hdr.
5080 -------------------------------------------------------------------------*/
5081 // Compare returns 1 if values are same and 0
5082 // if not the same.
5083 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5084 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5085 WLANTL_LLC_SNAP_SIZE ) ))
5086 {
5087 return VOS_FALSE;
5088 }
5089
5090 return VOS_TRUE;
5091
5092}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005093#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005094
5095/*==========================================================================
5096
5097 FUNCTION WLANTL_ProcessBAPFrame
5098
5099 DESCRIPTION
5100 Internal utility function for processing incoming BT-AMP frames
5101
5102 DEPENDENCIES
5103 TL must be initiailized before this function gets called.
5104 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5105 registered with TL.
5106
5107 PARAMETERS
5108
5109 IN
5110
5111 pvBDHeader: pointer to the BD header
5112 vosTempBuff: the data packet
5113 pTLCb: TL control block
5114 ucSTAId: station id
5115
5116 IN/OUT
5117 pFirstDataPktArrived: static from caller function; used for rssi
5118 computation
5119 RETURN VALUE
5120 The result code associated with performing the operation
5121
5122 VOS_STATUS_E_INVAL: Input parameters are invalid
5123 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5124 page fault
5125 VOS_STATUS_SUCCESS: Everything is good :)
5126
5127 SIDE EFFECTS
5128
5129============================================================================*/
5130v_BOOL_t
5131WLANTL_ProcessBAPFrame
5132(
5133 v_PVOID_t pvBDHeader,
5134 vos_pkt_t* vosTempBuff,
5135 WLANTL_CbType* pTLCb,
5136 v_U8_t* pFirstDataPktArrived,
5137 v_U8_t ucSTAId
5138)
5139{
5140 v_U16_t usMPDUDOffset;
5141 v_U8_t ucOffset;
5142 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5143 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5144 VOS_STATUS vosStatus;
5145 v_U16_t usType;
5146 v_SIZE_t usTypeLen = sizeof(usType);
5147 v_U8_t ucMPDUHOffset;
5148 v_U8_t ucMPDUHLen = 0;
5149 v_U16_t usActualHLen = 0;
5150
5151 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5152
5153 /*------------------------------------------------------------------------
5154 Extract OUI and type from LLC and validate; if non-data send to BAP
5155 -------------------------------------------------------------------------*/
5156 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5157 {
5158 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5159 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5160 "dropping pkt"));
5161 /* Drop packet */
5162 vos_pkt_return_packet(vosTempBuff);
5163 return VOS_TRUE;
5164 }
5165
5166 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5167 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5168 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5169 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5170
5171 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5172 (v_PVOID_t)ucOUI, &usOUISize);
5173
5174#if 0
5175 // Compare returns 1 if values are same and 0
5176 // if not the same.
5177 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5178 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5179 WLANTL_LLC_OUI_SIZE ) ))
5180 {
5181 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5182 "LLC header points to diff OUI in BT-AMP station -"
5183 "dropping pkt"));
5184 /* Drop packet */
5185 vos_pkt_return_packet(vosTempBuff);
5186 return VOS_TRUE;
5187 }
5188#endif
5189 /*------------------------------------------------------------------------
5190 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5191 ------------------------------------------------------------------------*/
5192 vosStatus = vos_pkt_extract_data( vosTempBuff,
5193 ucOffset + WLANTL_LLC_OUI_SIZE,
5194 (v_PVOID_t)&usType, &usTypeLen);
5195
5196 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5197 ( sizeof(usType) != usTypeLen ))
5198 {
5199 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5200 "Unable to extract type on incoming BAP packet -"
5201 "dropping pkt"));
5202 /* Drop packet */
5203 vos_pkt_return_packet(vosTempBuff);
5204 return VOS_TRUE;
5205 }
5206
5207 /*------------------------------------------------------------------------
5208 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5209 ------------------------------------------------------------------------*/
5210 usType = vos_be16_to_cpu(usType);
5211
5212 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5213 {
5214 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5215 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5216 usType));
5217
5218 /*Flatten packet as BAP expects to be able to peek*/
5219 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5220 {
5221 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5222 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5223 /* Drop packet */
5224 vos_pkt_return_packet(vosTempBuff);
5225 return VOS_TRUE;
5226 }
5227
5228 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5230 {
5231 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5232 "WLAN TL:BD header corrupted - dropping packet"));
5233 /* Drop packet */
5234 vos_pkt_return_packet(vosTempBuff);
5235 return VOS_TRUE;
5236 }
5237
5238 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5239 {
5240 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5241 "Non-data packet received over BT-AMP link: Sending it for "
5242 "frame Translation"));
5243
5244 if (usMPDUDOffset > ucMPDUHOffset)
5245 {
5246 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5247 }
5248
5249 /* software frame translation for BTAMP WDS.*/
5250 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005251 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005252
5253 }
5254 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5255 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5256 vosTempBuff,
5257 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005258 else
5259 {
5260 VOS_ASSERT(0);
5261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005262
5263 return VOS_TRUE;
5264 }
5265 else
5266 {
5267 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5268 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5269 usType));
5270 /*!!!FIX ME!!*/
5271 #if 0
5272 /*--------------------------------------------------------------------
5273 For data packet collect phy stats RSSI and Link Quality
5274 Calculate the RSSI average and save it. Continuous average is done.
5275 --------------------------------------------------------------------*/
5276 if ( *pFirstDataPktArrived == 0)
5277 {
5278 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5279 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5280 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5281 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5282
5283 // Rcvd 1st pkt, start average from next time
5284 *pFirstDataPktArrived = 1;
5285 }
5286 else
5287 {
5288 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5289 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5290 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5291 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5292 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5293 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5294 }/*Else, first data packet*/
5295 #endif
5296 }/*BT-AMP data packet*/
5297
5298 return VOS_FALSE;
5299}/*WLANTL_ProcessBAPFrame*/
5300
Jeff Johnson295189b2012-06-20 16:38:30 -07005301
5302/*==========================================================================
5303
5304 FUNCTION WLANTL_ProcessFCFrame
5305
5306 DESCRIPTION
5307 Internal utility function for processing incoming Flow Control frames. Enable
5308 or disable LWM mode based on the information.
5309
5310 DEPENDENCIES
5311 TL must be initiailized before this function gets called.
5312 FW sends up special flow control frame.
5313
5314 PARAMETERS
5315
5316 IN
5317 pvosGCtx pointer to vos global context
5318 pvBDHeader: pointer to the BD header
5319 pTLCb: TL control block
5320 pvBDHeader pointer to BD header.
5321
5322 IN/OUT
5323 pFirstDataPktArrived: static from caller function; used for rssi
5324 computation
5325 RETURN VALUE
5326 The result code associated with performing the operation
5327
5328 VOS_STATUS_E_INVAL: Input frame are invalid
5329 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5330 page fault
5331 VOS_STATUS_SUCCESS: Everything is good :)
5332
5333 SIDE EFFECTS
5334 The ingress and egress of each station will be updated. If needed, LWM mode will
5335 be enabled or disabled based on the flow control algorithm.
5336
5337============================================================================*/
5338v_BOOL_t
5339WLANTL_ProcessFCFrame
5340(
5341 v_PVOID_t pvosGCtx,
5342 vos_pkt_t* pvosDataBuff,
5343 v_PVOID_t pvBDHeader
5344)
5345{
5346#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5347 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005348 v_U8_t ucSTAId;
5349 v_U16_t ucStaValidBitmap;
5350 v_U16_t ucStaTxDisabledBitmap;
5351 WLANTL_CbType* pTLCb = NULL;
5352 #ifdef TL_DEBUG_FC
5353 v_U32_t rxTimeStamp;
5354 v_U32_t curTick;
5355 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005357 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 ------------------------------------------------------------------------*/
5359 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5360 if ( NULL == pTLCb )
5361 {
5362 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5363 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5364 return VOS_STATUS_E_FAULT;
5365 }
Hoonki Lee14621352013-04-16 17:51:19 -07005366 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5367 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5368#ifdef TL_DEBUG_FC
5369 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5370 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5371 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005372
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005374 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005375 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5376#endif
5377 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 {
Hoonki Lee14621352013-04-16 17:51:19 -07005379 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5380 continue;
5381
5382 if (ucStaTxDisabledBitmap & 0x1)
5383 {
5384 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5385 }
5386 else
5387 {
5388 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 }
5391
5392#else
5393 VOS_STATUS vosStatus;
5394 tpHalFcRxBd pvFcRxBd = NULL;
5395 v_U8_t ucBitCheck = 0x1;
5396 v_U8_t ucStaValid = 0;
5397 v_U8_t ucSTAId = 0;
5398
5399 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5400 "Received FC Response");
5401 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5402 {
5403 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005404 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 return VOS_STATUS_E_FAULT;
5406 }
5407 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5408 sizeof(tHalFcRxBd));
5409
5410 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5411 {
5412 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5413 "WLAN TL:wrong FC Rx packet"));
5414 return VOS_STATUS_E_INVAL;
5415 }
5416
5417 // need to swap bytes in the FC contents.
5418 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5419
5420 //logic to enable/disable LWM mode for each station
5421 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5422 {
5423 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5424 {
5425 continue;
5426 }
5427
5428 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5429 {
5430 //LWM event is reported by FW. Able to fetch more packet
5431 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5432 {
5433 //Now memory usage is below LWM. Station can send more packets.
5434 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5435 }
5436 else
5437 {
5438 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005439 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 }
5441 }
5442
5443 //calculate uEgress_length/uIngress_length only after receiving enough packets
5444 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5445 {
5446 //check memory usage info to see whether LWM mode should be enabled for the station
5447 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5448 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5449
5450 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5451 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5452 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5453 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5454 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5455 )
5456 {
5457 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005458 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5460 }
5461 else
5462 {
5463 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5464 {
5465 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005466 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5468 }
5469
5470 }
5471
5472 //remember memory usage in FW starting from this round
5473 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5474 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5475 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5476
5477 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5478 {
5479 //always update current maximum allowed memeory usage
5480 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5481 pvFcRxBd->fcSTATxQLen[ucSTAId];
5482 }
5483
5484 }
5485#endif
5486
5487 return VOS_STATUS_SUCCESS;
5488}
Jeff Johnson295189b2012-06-20 16:38:30 -07005489
5490
5491/*==========================================================================
5492
5493 FUNCTION WLANTL_RxFrames
5494
5495 DESCRIPTION
5496 Callback registered by TL and called by BAL when a packet is received
5497 over the bus. Upon the call of this function TL will make the necessary
5498 decision with regards to the forwarding or queuing of this packet and
5499 the layer it needs to be delivered to.
5500
5501 DEPENDENCIES
5502 TL must be initiailized before this function gets called.
5503 If the frame carried is a data frame then the station for which it is
5504 destined to must have been previously registered with TL.
5505
5506 PARAMETERS
5507
5508 IN
5509 pvosGCtx: pointer to the global vos context; a handle to TL's
5510 or BAL's control block can be extracted from its context
5511
5512 vosDataBuff: it will contain a pointer to the first buffer received,
5513 if there is more then one packet they will be chained
5514 using vOSS buffers.
5515
5516 RETURN VALUE
5517 The result code associated with performing the operation
5518
5519 VOS_STATUS_E_INVAL: Input parameters are invalid
5520 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5521 page fault
5522 VOS_STATUS_SUCCESS: Everything is good :)
5523
5524 SIDE EFFECTS
5525
5526============================================================================*/
5527VOS_STATUS
5528WLANTL_RxFrames
5529(
5530 v_PVOID_t pvosGCtx,
5531 vos_pkt_t *pFrameDataBuff
5532)
5533{
5534 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5535 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305536 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 WLANTL_STAFuncType pfnSTAFsm;
5538 vos_pkt_t* vosTempBuff;
5539 v_U8_t ucSTAId;
5540 VOS_STATUS vosStatus;
5541 v_U8_t ucFrmType;
5542 v_PVOID_t pvBDHeader = NULL;
5543 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5544 v_U8_t ucTid = 0;
5545 v_BOOL_t broadcast = VOS_FALSE;
5546 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005547 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005550#ifdef FEATURE_WLAN_TDLS_INTERNAL
5551 v_U8_t ucMPDUHLen = 0 ;
5552 v_U16_t usEtherType = 0;
5553#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005554 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
5555
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5557
5558 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5559 "WLAN TL:TL Receive Frames called"));
5560
5561 /*------------------------------------------------------------------------
5562 Sanity check
5563 ------------------------------------------------------------------------*/
5564 if ( NULL == vosDataBuff )
5565 {
5566 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5567 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5568 return VOS_STATUS_E_INVAL;
5569 }
5570
Katya Nigam3802f202013-12-16 19:27:14 +05305571 /*------------------------------------------------------------------------
5572 Popolaute timestamp as the time when packet arrives
5573 ---------------------------------------------------------------------- */
5574 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5575
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 /*------------------------------------------------------------------------
5577 Extract TL control block
5578 ------------------------------------------------------------------------*/
5579 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5580 if ( NULL == pTLCb )
5581 {
5582 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5583 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5584 return VOS_STATUS_E_FAULT;
5585 }
5586
5587 /*---------------------------------------------------------------------
5588 Save the initial buffer - this is the first received buffer
5589 ---------------------------------------------------------------------*/
5590 vosTempBuff = vosDataBuff;
5591
5592 while ( NULL != vosTempBuff )
5593 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005594 broadcast = VOS_FALSE;
5595 selfBcastLoopback = VOS_FALSE;
5596
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5598
5599 /*---------------------------------------------------------------------
5600 Peek at BD header - do not remove
5601 !!! Optimize me: only part of header is needed; not entire one
5602 ---------------------------------------------------------------------*/
5603 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5604
5605 if ( NULL == pvBDHeader )
5606 {
5607 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5608 "WLAN TL:Cannot extract BD header"));
5609 /* Drop packet */
5610 vos_pkt_return_packet(vosTempBuff);
5611 vosTempBuff = vosDataBuff;
5612 continue;
5613 }
5614
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 /*---------------------------------------------------------------------
5616 Check if FC frame reported from FW
5617 ---------------------------------------------------------------------*/
5618 if(WDA_IS_RX_FC(pvBDHeader))
5619 {
5620 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5621 "WLAN TL:receive one FC frame"));
5622
5623 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5624 /* Drop packet */
5625 vos_pkt_return_packet(vosTempBuff);
5626 vosTempBuff = vosDataBuff;
5627 continue;
5628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005629
5630 /* AMSDU HW bug fix
5631 * After 2nd AMSDU subframe HW could not handle BD correctly
5632 * HAL workaround is needed */
5633 if(WDA_GET_RX_ASF(pvBDHeader))
5634 {
5635 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5636 }
5637
5638 /*---------------------------------------------------------------------
5639 Extract frame control field from 802.11 header if present
5640 (frame translation not done)
5641 ---------------------------------------------------------------------*/
5642
5643 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5644 pvBDHeader, &ucFrmType );
5645 if ( VOS_STATUS_SUCCESS != vosStatus )
5646 {
5647 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5648 "WLAN TL:Cannot extract Frame Control Field"));
5649 /* Drop packet */
5650 vos_pkt_return_packet(vosTempBuff);
5651 vosTempBuff = vosDataBuff;
5652 continue;
5653 }
5654
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005655#ifdef FEATURE_WLAN_TDLS_INTERNAL
5656 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5657 {
5658 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5659 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5660 }
5661#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005663
5664 /*---------------------------------------------------------------------
5665 Check if management and send to PE
5666 ---------------------------------------------------------------------*/
5667
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005668 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5669#ifdef FEATURE_WLAN_TDLS_INTERNAL
5670 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5671#endif
5672 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 {
5674 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5675 "WLAN TL:Sending packet to management client"));
5676 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5677 {
5678 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5679 "WLAN TL:Cannot flatten packet - dropping"));
5680 /* Drop packet */
5681 vos_pkt_return_packet(vosTempBuff);
5682 vosTempBuff = vosDataBuff;
5683 continue;
5684 }
5685 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5686 /* Read RSSI and update */
5687 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5688 {
5689#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5690 /* Read RSSI and update */
5691 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5692 WLANTL_MGMT_FRAME_TYPE,
5693 pvBDHeader,
5694 ucSTAId,
5695 VOS_FALSE,
5696 NULL);
5697#else
5698 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5699#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305700 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5701 {
5702 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5703 "Handle RX Management Frame fail within Handoff "
5704 "support module"));
5705 /* Do Not Drop packet at here
5706 * Revisit why HO module return fail
5707 * vos_pkt_return_packet(vosTempBuff);
5708 * vosTempBuff = vosDataBuff;
5709 * continue;
5710 */
5711 }
5712 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5713
5714 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5715 {
5716 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5717 FL("Failed to Read SNR")));
5718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 }
5720
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5722 }
5723 else /* Data Frame */
5724 {
5725 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5726 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
5727
5728 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5729 "WLAN TL:Data packet received for STA %d", ucSTAId));
5730
5731 /*------------------------------------------------------------------
5732 This should be corrected when multipe sta support is added !!!
5733 for now bcast frames will be sent to the last registered STA
5734 ------------------------------------------------------------------*/
5735 if ( WDA_IS_RX_BCAST(pvBDHeader))
5736 {
5737 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5738 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5739 broadcast = VOS_TRUE;
5740
5741 /*-------------------------------------------------------------------
5742 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5743 pkt we sent looping back to us. To be dropped if we are non BTAMP
5744 -------------------------------------------------------------------*/
5745 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5746 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5747 {
5748 selfBcastLoopback = VOS_TRUE;
5749 }
5750 }/*if bcast*/
5751
5752 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5753 {
5754 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5755 "WLAN TL:STA ID invalid - dropping pkt"));
5756 /* Drop packet */
5757 vos_pkt_return_packet(vosTempBuff);
5758 vosTempBuff = vosDataBuff;
5759 continue;
5760 }
5761
5762 /*----------------------------------------------------------------------
5763 No need to lock cache access because cache manipulation only happens
5764 in the transport thread/task context
5765 - These frames are to be forwarded to the station upon registration
5766 which happens in the main thread context
5767 The caching here can happen in either Tx or Rx thread depending
5768 on the current SSC scheduling
5769 - also we need to make sure that the frames in the cache are fwd-ed to
5770 the station before the new incoming ones
5771 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305772 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5773 if (NULL == pClientSTA)
5774 {
5775 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5776 "WLAN TL:STA not allocated memory. Dropping packet"));
5777 vos_pkt_return_packet(vosTempBuff);
5778 vosTempBuff = vosDataBuff;
5779 continue;
5780 }
5781
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005782#ifdef FEATURE_WLAN_TDLS
5783 if (( pClientSTA->ucExists ) &&
5784 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5785 (pClientSTA->ucTxSuspended))
5786 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5787 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5788 {
5789 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5790
5791 /* from the direct peer while it is not registered to TL yet */
5792 if ( (pMacHeader->fc.fromDS == 0) &&
5793 (pMacHeader->fc.toDS == 0) )
5794 {
5795 v_U8_t ucAddr3STAId;
5796
5797 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5798
5799 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5800 {
5801 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5802 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5803 /* Drop packet */
5804 vos_pkt_return_packet(vosTempBuff);
5805 vosTempBuff = vosDataBuff;
5806 continue;
5807 }
5808
5809 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5810 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5811 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5812 {
5813 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005814 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005815 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5816 vos_pkt_return_packet(vosTempBuff);
5817 vosTempBuff = vosDataBuff;
5818 continue;
5819 }
5820 else
5821 {
5822 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005823 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005824 ucSTAId, ucAddr3STAId));
5825 ucSTAId = ucAddr3STAId;
5826 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5827 }
5828 }
5829 }
5830#endif
5831
Katya Nigam63902932014-06-26 19:04:23 +05305832 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5834 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5835 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05305836 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05305838 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
5839 {
5840 //drop packet for Self STA index
5841 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5842 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
5843
5844 vos_pkt_return_packet(vosTempBuff);
5845 vosTempBuff = vosDataBuff;
5846 continue;
5847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5849 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005850 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005851 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005852 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5854 vosTempBuff = vosDataBuff;
5855 continue;
5856 }
5857
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005858#ifdef FEATURE_WLAN_ESE_UPLOAD
5859 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005860 {
5861 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005862 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005863 if data it will return false and it
5864 will be routed through the regular data path
5865 --------------------------------------------------------------------*/
5866 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5867 vosTempBuff))
5868 {
5869 bForwardIAPPwithLLC = VOS_TRUE;
5870 }
5871 }
5872#endif
5873
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005874#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
5875 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 {
5877 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005878 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 if data it will return false and it
5880 will be routed through the regular data path
5881 --------------------------------------------------------------------*/
5882 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5883 vosTempBuff))
5884 {
5885 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5886 {
5887 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5888 "WLAN TL:Cannot flatten packet - dropping"));
5889 /* Drop packet */
5890 vos_pkt_return_packet(vosTempBuff);
5891 } else {
5892
5893 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005894 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005895
5896 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5897 }
5898 vosTempBuff = vosDataBuff;
5899 continue;
5900 }
5901 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005902#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005903
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305904 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 {
5906 /*--------------------------------------------------------------------
5907 Process the ctrl BAP frame; if data it will return false and it
5908 will be routed through the regular data path
5909 --------------------------------------------------------------------*/
5910 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
5911 vosTempBuff,
5912 pTLCb,
5913 &first_data_pkt_arrived,
5914 ucSTAId))
5915 {
5916 vosTempBuff = vosDataBuff;
5917 continue;
5918 }
5919 }/*if BT-AMP station*/
5920 else if(selfBcastLoopback == VOS_TRUE)
5921 {
5922 /* Drop packet */
5923 vos_pkt_return_packet(vosTempBuff);
5924 vosTempBuff = vosDataBuff;
5925 continue;
5926 }
5927
5928 /*---------------------------------------------------------------------
5929 Data packet received, send to state machine
5930 ---------------------------------------------------------------------*/
5931 wSTAEvent = WLANTL_RX_EVENT;
5932
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305933 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 pfnSTATbl[wSTAEvent];
5935
5936 if ( NULL != pfnSTAFsm )
5937 {
5938#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5939 /* Read RSSI and update */
5940 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5941 WLANTL_DATA_FRAME_TYPE,
5942 pvBDHeader,
5943 ucSTAId,
5944 broadcast,
5945 vosTempBuff);
5946 broadcast = VOS_FALSE;
5947#else
5948 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07005949#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305950 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 {
5952 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5953 "Handle RX Data Frame fail within Handoff support module"));
5954 /* Do Not Drop packet at here
5955 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305956 * vos_pkt_return_packet(vosTempBuff);
5957 * vosTempBuff = vosDataBuff;
5958 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 */
5960 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305961 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5962
5963 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5964 {
5965 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5966 FL("Failed to Read SNR")));
5967 }
5968
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005969 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 }
5971 else
5972 {
5973 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5974 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305975 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 /* Drop packet */
5977 vos_pkt_return_packet(vosTempBuff);
5978 vosTempBuff = vosDataBuff;
5979 continue;
5980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 }/* else data frame*/
5982
5983 vosTempBuff = vosDataBuff;
5984 }/*while chain*/
5985
5986 return VOS_STATUS_SUCCESS;
5987}/* WLANTL_RxFrames */
5988
5989
5990/*==========================================================================
5991
5992 FUNCTION WLANTL_RxCachedFrames
5993
5994 DESCRIPTION
5995 Utility function used by TL to forward the cached frames to a particular
5996 station;
5997
5998 DEPENDENCIES
5999 TL must be initiailized before this function gets called.
6000 If the frame carried is a data frame then the station for which it is
6001 destined to must have been previously registered with TL.
6002
6003 PARAMETERS
6004
6005 IN
6006 pTLCb: pointer to TL handle
6007
6008 ucSTAId: station for which we need to forward the packets
6009
6010 vosDataBuff: it will contain a pointer to the first cached buffer
6011 received, if there is more then one packet they will be
6012 chained using vOSS buffers.
6013
6014 RETURN VALUE
6015 The result code associated with performing the operation
6016
6017 VOS_STATUS_E_INVAL: Input parameters are invalid
6018 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6019 page fault
6020 VOS_STATUS_SUCCESS: Everything is good :)
6021
6022 SIDE EFFECTS
6023
6024============================================================================*/
6025VOS_STATUS
6026WLANTL_RxCachedFrames
6027(
6028 WLANTL_CbType* pTLCb,
6029 v_U8_t ucSTAId,
6030 vos_pkt_t* vosDataBuff
6031)
6032{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306033 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 WLANTL_STAFuncType pfnSTAFsm;
6035 vos_pkt_t* vosTempBuff;
6036 VOS_STATUS vosStatus;
6037 v_PVOID_t pvBDHeader = NULL;
6038 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6039 v_U8_t ucTid = 0;
6040 v_BOOL_t broadcast = VOS_FALSE;
6041 v_BOOL_t bSigMatch = VOS_FALSE;
6042 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006043 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 v_U32_t uDPUSig;
6045 v_U8_t ucUcastSig;
6046 v_U8_t ucBcastSig;
6047 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6048
6049 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6050 "WLAN TL:TL Receive Cached Frames called"));
6051
6052 /*------------------------------------------------------------------------
6053 Sanity check
6054 ------------------------------------------------------------------------*/
6055 if ( NULL == vosDataBuff )
6056 {
6057 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6058 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6059 return VOS_STATUS_E_INVAL;
6060 }
6061
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306062 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6063
6064 if ( NULL == pClientSTA )
6065 {
6066 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6067 "WLAN TL:Client Memory was not allocated on %s", __func__));
6068 return VOS_STATUS_E_FAILURE;
6069 }
6070
6071 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6072 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6073
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 /*---------------------------------------------------------------------
6075 Save the initial buffer - this is the first received buffer
6076 ---------------------------------------------------------------------*/
6077 vosTempBuff = vosDataBuff;
6078
6079 while ( NULL != vosTempBuff )
6080 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006081 broadcast = VOS_FALSE;
6082 selfBcastLoopback = VOS_FALSE;
6083
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6085
6086 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6087 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6088 /*---------------------------------------------------------------------
6089 Peek at BD header - do not remove
6090 !!! Optimize me: only part of header is needed; not entire one
6091 ---------------------------------------------------------------------*/
6092 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6093
6094 if ( NULL == pvBDHeader )
6095 {
6096 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6097 "WLAN TL:Cannot extract BD header"));
6098 /* Drop packet */
6099 vos_pkt_return_packet(vosTempBuff);
6100 vosTempBuff = vosDataBuff;
6101 continue;
6102 }
6103
6104 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6105
6106 /* AMSDU HW bug fix
6107 * After 2nd AMSDU subframe HW could not handle BD correctly
6108 * HAL workaround is needed */
6109 if(WDA_GET_RX_ASF(pvBDHeader))
6110 {
6111 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6112 pvBDHeader);
6113 }
6114
6115 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6116
6117 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6118 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6119
6120 /*------------------------------------------------------------------
6121 This should be corrected when multipe sta support is added !!!
6122 for now bcast frames will be sent to the last registered STA
6123 ------------------------------------------------------------------*/
6124 if ( WDA_IS_RX_BCAST(pvBDHeader))
6125 {
6126 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6127 "WLAN TL:TL rx Bcast frame "));
6128 broadcast = VOS_TRUE;
6129
6130 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6131 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6132 */
6133 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6134 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6135 {
6136 selfBcastLoopback = VOS_TRUE;
6137 }
6138 }/*if bcast*/
6139
6140 /*-------------------------------------------------------------------------
6141 Check if the packet that we cached matches the DPU signature of the
6142 newly added station
6143 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306144 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6145
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306146 if ( NULL == pClientSTA )
6147 {
6148 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6149 "WLAN TL:Client Memory was not allocated on %s", __func__));
6150 return VOS_STATUS_E_FAILURE;
6151 }
6152
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 if ( broadcast )
6154 {
6155 ucBcastSig = (v_U8_t)uDPUSig;
6156 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306157 pClientSTA->wSTADesc.ucBcastSig ) &&
6158 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 }
6160 else
6161 {
6162 ucUcastSig = (v_U8_t)uDPUSig;
6163 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306164 pClientSTA->wSTADesc.ucUcastSig ) &&
6165 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 }
6167
6168 /*-------------------------------------------------------------------------
6169 If the packet doesn't match - drop it
6170 -------------------------------------------------------------------------*/
6171 if ( !bSigMatch )
6172 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006173 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6175 " DPU Sig %d UC %d BC %d B %d",
6176 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306177 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006178 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 broadcast));
6180
6181 /* Drop packet */
6182 vos_pkt_return_packet(vosTempBuff);
6183 vosTempBuff = vosDataBuff;
6184 continue;
6185
6186 }/*if signature mismatch*/
6187
6188 /*------------------------------------------------------------------------
6189 Check if BT-AMP frame:
6190 - additional processing needed in this case to separate BT-AMP date
6191 from BT-AMP Ctrl path
6192 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306193 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 {
6195 /*--------------------------------------------------------------------
6196 Process the ctrl BAP frame; if data it will return false and it
6197 will be routed through the regular data path
6198 --------------------------------------------------------------------*/
6199 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6200 vosTempBuff,
6201 pTLCb,
6202 &first_data_pkt_arrived,
6203 ucSTAId))
6204 {
6205 vosTempBuff = vosDataBuff;
6206 continue;
6207 }
6208 }/*if BT-AMP station*/
6209 else if(selfBcastLoopback == VOS_TRUE)
6210 {
6211 /* Drop packet */
6212 vos_pkt_return_packet(vosTempBuff);
6213 vosTempBuff = vosDataBuff;
6214 continue;
6215 }
6216
6217 /*---------------------------------------------------------------------
6218 Data packet received, send to state machine
6219 ---------------------------------------------------------------------*/
6220 wSTAEvent = WLANTL_RX_EVENT;
6221
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306222 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 pfnSTATbl[wSTAEvent];
6224
6225 if ( NULL != pfnSTAFsm )
6226 {
6227#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6228 /* Read RSSI and update */
6229 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6230 VOS_MODULE_ID_TL,pTLCb),
6231 WLANTL_DATA_FRAME_TYPE,
6232 pvBDHeader,
6233 ucSTAId,
6234 broadcast,
6235 vosTempBuff);
6236 broadcast = VOS_FALSE;
6237#else
6238 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006239#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6241 {
6242 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6243 "Handle RX Data Frame fail within Handoff support module"));
6244 /* Do Not Drop packet at here
6245 * Revisit why HO module return fail
6246 vos_pkt_return_packet(vosTempBuff);
6247 vosTempBuff = vosDataBuff;
6248 continue;
6249 */
6250 }
6251 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006252 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 }
6254 else
6255 {
6256 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6257 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306258 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 /* Drop packet */
6260 vos_pkt_return_packet(vosTempBuff);
6261 vosTempBuff = vosDataBuff;
6262 continue;
6263 }
6264
6265 vosTempBuff = vosDataBuff;
6266 }/*while chain*/
6267
6268 return VOS_STATUS_SUCCESS;
6269}/* WLANTL_RxCachedFrames */
6270
6271/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05306272 FUNCTION WLANTL_RxProcessMsg
6273
6274 DESCRIPTION
6275 Called by VOSS when a message was serialized for TL through the
6276 rx thread/task.
6277
6278 DEPENDENCIES
6279 The TL must be initialized before this function can be called.
6280
6281 PARAMETERS
6282
6283 IN
6284 pvosGCtx: pointer to the global vos context; a handle to TL's
6285 control block can be extracted from its context
6286 message: type and content of the message
6287
6288
6289 RETURN VALUE
6290 The result code associated with performing the operation
6291
6292 VOS_STATUS_E_INVAL: invalid input parameters
6293 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6294 page fault
6295 VOS_STATUS_SUCCESS: Everything is good :)
6296
6297 Other values can be returned as a result of a function call, please check
6298 corresponding API for more info.
6299 SIDE EFFECTS
6300
6301============================================================================*/
6302VOS_STATUS
6303WLANTL_RxProcessMsg
6304(
6305 v_PVOID_t pvosGCtx,
6306 vos_msg_t* message
6307)
6308{
6309 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6310 v_U32_t uData;
6311 v_U8_t ucSTAId;
6312 v_U8_t ucUcastSig;
6313 v_U8_t ucBcastSig;
6314
6315 /*------------------------------------------------------------------------
6316 Sanity check
6317 ------------------------------------------------------------------------*/
6318 if ( NULL == message )
6319 {
6320 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6321 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
6322 return VOS_STATUS_E_INVAL;
6323 }
6324
6325 /*------------------------------------------------------------------------
6326 Process message
6327 ------------------------------------------------------------------------*/
6328 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6329 "WLAN TL:Received message: %d through rx flow", message->type));
6330
6331 switch( message->type )
6332 {
6333
6334 case WLANTL_RX_FWD_CACHED:
6335 /*---------------------------------------------------------------------
6336 The data sent with the message has the following structure:
6337 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
6338 each field above is one byte
6339 ---------------------------------------------------------------------*/
6340 uData = message->bodyval;
6341 ucSTAId = ( uData & 0x000000FF);
6342 ucUcastSig = ( uData & 0x0000FF00)>>8;
6343 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
6344 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
6345 ucUcastSig, ucBcastSig);
6346 break;
6347
6348 default:
6349 /*no processing for now*/
6350 break;
6351 }
6352
6353 return VOS_STATUS_SUCCESS;
6354}
6355
6356
6357/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 FUNCTION WLANTL_ResourceCB
6359
6360 DESCRIPTION
6361 Called by the TL when it has packets available for transmission.
6362
6363 DEPENDENCIES
6364 The TL must be registered with BAL before this function can be called.
6365
6366 PARAMETERS
6367
6368 IN
6369 pvosGCtx: pointer to the global vos context; a handle to TL's
6370 or BAL's control block can be extracted from its context
6371
6372 RETURN VALUE
6373 The result code associated with performing the operation
6374
6375 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6376 page fault
6377 VOS_STATUS_SUCCESS: Everything is good :)
6378
6379 SIDE EFFECTS
6380
6381============================================================================*/
6382VOS_STATUS
6383WLANTL_ResourceCB
6384(
6385 v_PVOID_t pvosGCtx,
6386 v_U32_t uCount
6387)
6388{
6389 WLANTL_CbType* pTLCb = NULL;
6390 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6391
6392 /*------------------------------------------------------------------------
6393 Sanity check
6394 Extract TL control block
6395 ------------------------------------------------------------------------*/
6396 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6397 if ( NULL == pTLCb )
6398 {
6399 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6400 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6401 return VOS_STATUS_E_FAULT;
6402 }
6403
6404 pTLCb->uResCount = uCount;
6405
6406
6407 /*-----------------------------------------------------------------------
6408 Resume Tx if enough res and not suspended
6409 -----------------------------------------------------------------------*/
6410 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6411 ( 0 == pTLCb->ucTxSuspended ))
6412 {
6413 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6414 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6415 return WDA_DS_StartXmit(pvosGCtx);
6416 }
6417
6418 return VOS_STATUS_SUCCESS;
6419}/* WLANTL_ResourceCB */
6420
6421
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006422/*==========================================================================
6423 FUNCTION WLANTL_IsTxXmitPending
6424
6425 DESCRIPTION
6426 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6427 is pending in TL msg queue
6428
6429 DEPENDENCIES
6430 The TL must be registered with WDA before this function can be called.
6431
6432 PARAMETERS
6433
6434 IN
6435 pvosGCtx: pointer to the global vos context; a handle to TL's
6436 or WDA's control block can be extracted from its context
6437
6438 RETURN VALUE
6439 The result code associated with performing the operation
6440
6441 0: No WDA_DS_TX_START_XMIT msg pending
6442 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6443
6444 SIDE EFFECTS
6445
6446============================================================================*/
6447v_BOOL_t
6448WLANTL_IsTxXmitPending
6449(
6450 v_PVOID_t pvosGCtx
6451)
6452{
6453
6454 WLANTL_CbType* pTLCb = NULL;
6455 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6456
6457 /*------------------------------------------------------------------------
6458 Sanity check
6459 Extract TL control block
6460 ------------------------------------------------------------------------*/
6461 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6462 if ( NULL == pTLCb )
6463 {
6464 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6465 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6466 return FALSE;
6467 }
6468
6469 return pTLCb->isTxTranmitMsgPending;
6470
6471}/*WLANTL_IsTxXmitPending */
6472
6473/*==========================================================================
6474 FUNCTION WLANTL_SetTxXmitPending
6475
6476 DESCRIPTION
6477 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6478 is pending in TL msg queue
6479
6480 DEPENDENCIES
6481 The TL must be registered with WDA before this function can be called.
6482
6483 PARAMETERS
6484
6485 IN
6486 pvosGCtx: pointer to the global vos context; a handle to TL's
6487 or WDA's control block can be extracted from its context
6488
6489 RETURN VALUE None
6490
6491 SIDE EFFECTS
6492
6493============================================================================*/
6494
6495v_VOID_t
6496WLANTL_SetTxXmitPending
6497(
6498 v_PVOID_t pvosGCtx
6499)
6500{
6501
6502 WLANTL_CbType* pTLCb = NULL;
6503 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6504
6505 /*------------------------------------------------------------------------
6506 Sanity check
6507 Extract TL control block
6508 ------------------------------------------------------------------------*/
6509 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6510 if ( NULL == pTLCb )
6511 {
6512 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6513 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6514 return;
6515 }
6516
6517 pTLCb->isTxTranmitMsgPending = 1;
6518 return;
6519
6520}/*WLANTL_SetTxXmitPending */
6521
6522/*==========================================================================
6523 FUNCTION WLANTL_ClearTxXmitPending
6524
6525 DESCRIPTION
6526 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6527 is pending in TL msg queue
6528
6529 DEPENDENCIES
6530 The TL must be registered with WDA before this function can be called.
6531
6532 PARAMETERS
6533
6534 IN
6535 pvosGCtx: pointer to the global vos context; a handle to TL's
6536 or WDA's control block can be extracted from its context
6537
6538 RETURN VALUE None
6539
6540 SIDE EFFECTS
6541
6542============================================================================*/
6543
6544v_VOID_t
6545WLANTL_ClearTxXmitPending
6546(
6547 v_PVOID_t pvosGCtx
6548)
6549{
6550
6551 WLANTL_CbType* pTLCb = NULL;
6552 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6553
6554 /*------------------------------------------------------------------------
6555 Sanity check
6556 Extract TL control block
6557 ------------------------------------------------------------------------*/
6558 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6559 if ( NULL == pTLCb )
6560 {
6561 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6562 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6563 return;
6564 }
6565
6566 pTLCb->isTxTranmitMsgPending = 0;
6567 return;
6568}/*WLANTL_ClearTxXmitPending */
6569
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306570/*==========================================================================
6571 FUNCTION WLANTL_TxThreadDebugHandler
6572
6573 DESCRIPTION
6574 Printing TL Snapshot dump, processed under TxThread context, currently
6575 information regarding the global TlCb struture. Dumps information related
6576 to per active STA connection currently in use by TL.
6577
6578 DEPENDENCIES
6579 The TL must be initialized before this gets called.
6580
6581 PARAMETERS
6582
6583 IN
6584 pvosGCtx: pointer to the global vos context; a handle to TL's
6585 or WDA's control block can be extracted from its context
6586
6587 RETURN VALUE None
6588
6589 SIDE EFFECTS
6590
6591============================================================================*/
6592
6593v_VOID_t
6594WLANTL_TxThreadDebugHandler
6595(
6596 v_PVOID_t *pVosContext
6597)
6598{
6599 WLANTL_CbType* pTLCb = NULL;
6600 WLANTL_STAClientType* pClientSTA = NULL;
6601 int i = 0;
6602 tWDA_CbContext *pWDA = NULL;
6603
6604 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6605 "WLAN TL: %s Enter ", __func__));
6606
6607 pTLCb = VOS_GET_TL_CB(pVosContext);
6608 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6609
6610 if ( NULL == pVosContext || NULL == pTLCb )
6611 {
6612 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6613 "Global VoS Context or TL Context are NULL"));
6614 return;
6615 }
6616
6617 if (NULL != pWDA)
6618 {
6619 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6620 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6621 }
6622 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6623 "************************TL DUMP INFORMATION**************"));
6624
6625 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6626 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6627 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6628 pTLCb->tlConfigInfo.uMinFramesProcThres));
6629
6630 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6631 "Management Frame Client exists: %d",
6632 pTLCb->tlMgmtFrmClient.ucExists));
6633 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6634 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6635 pTLCb->usPendingTxCompleteCount,
6636 pTLCb->ucTxSuspended));
6637
6638 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6639 "uResCount: %d", pTLCb->uResCount));
6640
6641 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6642 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6643 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6644
6645 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6646 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6647 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6648
6649 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6650 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6651 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6652
6653#ifdef FEATURE_WLAN_TDLS
6654 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6655 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6656#endif
6657
6658 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6659 "++++++++++++++++++++Registerd Client Information++++++++++"));
6660
6661 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6662 {
6663 pClientSTA = pTLCb->atlSTAClients[i];
6664 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6665 {
6666 continue;
6667 }
6668
6669 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6670 "######################STA Index: %d ############################",i));
6671 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6672 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6673 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6674 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6675 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6676 "STA Type: %d\tProtectedFrame: %d",
6677 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6678 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6679 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6680 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6681 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6682 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6683 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6684 pClientSTA->wSTADesc.ucBcastSig));
6685
6686 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6687 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6688 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6689 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6690 pClientSTA->tlPri));
6691 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6692 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6693 pClientSTA->ucPktPending));
6694 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6695 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6696 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6697 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Katya Nigam63902932014-06-26 19:04:23 +05306698 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306699 pClientSTA->fcStaTxDisabled));
6700 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6701 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6702 pClientSTA->ucServicedAC));
6703 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6704 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6705 pClientSTA->auRxCount[0]));
6706 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6707 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6708 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6709 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6710 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6711 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6712
6713 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6714 {
6715 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6716 "TrafficStatistics for SOFTAP Station:"));
6717 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6718 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6719 pClientSTA->trafficStatistics.rxMCFcnt,
6720 pClientSTA->trafficStatistics.rxBCFcnt));
6721 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6722 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6723 pClientSTA->trafficStatistics.rxMCBcnt,
6724 pClientSTA->trafficStatistics.rxBCBcnt));
6725 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6726 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6727 pClientSTA->trafficStatistics.txMCFcnt,
6728 pClientSTA->trafficStatistics.txBCFcnt));
6729 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6730 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6731 pClientSTA->trafficStatistics.txMCBcnt,
6732 pClientSTA->trafficStatistics.txBCBcnt));
6733 }
6734 }
6735 return;
6736}
6737
6738/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05306739 FUNCTION WLANTL_FatalErrorHandler
6740
6741 DESCRIPTION
6742 Handle Fatal errors detected on the TX path.
6743 Currently issues SSR to recover from the error.
6744
6745 DEPENDENCIES
6746 The TL must be initialized before this gets called.
6747
6748 PARAMETERS
6749
6750 IN
6751 pvosGCtx: pointer to the global vos context; a handle to TL's
6752 or WDA's control block can be extracted from its context
6753
6754 RETURN VALUE None
6755
6756 SIDE EFFECTS
6757
6758============================================================================*/
6759v_VOID_t
6760WLANTL_FatalErrorHandler
6761(
6762 v_PVOID_t *pVosContext
6763)
6764{
6765
6766 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6767 "WLAN TL: %s Enter ", __func__));
6768
6769 if ( NULL == pVosContext )
6770 {
6771 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6772 "%s: Global VoS Context or TL Context are NULL",
6773 __func__));
6774 return;
6775 }
6776
6777 /*
6778 * Issue SSR. vos_wlanRestart has tight checks to make sure that
6779 * we do not send an FIQ if previous FIQ is not processed
6780 */
6781 vos_wlanRestart();
6782}
6783
6784/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306785 FUNCTION WLANTL_TLDebugMessage
6786
6787 DESCRIPTION
6788 Post a TL Snapshot request, posts message in TxThread.
6789
6790 DEPENDENCIES
6791 The TL must be initialized before this gets called.
6792
6793 PARAMETERS
6794
6795 IN
6796 displaySnapshot Boolean showing whether to dump the snapshot or not.
6797
6798 RETURN VALUE None
6799
6800 SIDE EFFECTS
6801
6802============================================================================*/
6803
6804v_VOID_t
6805WLANTL_TLDebugMessage
6806(
6807 v_BOOL_t displaySnapshot
6808)
6809{
6810 vos_msg_t vosMsg;
6811 VOS_STATUS status;
6812
6813 if(displaySnapshot)
6814 {
6815 vosMsg.reserved = 0;
6816 vosMsg.bodyptr = NULL;
6817 vosMsg.type = WLANTL_TX_SNAPSHOT;
6818
6819 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6820 if(status != VOS_STATUS_SUCCESS)
6821 {
6822 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
6823 return;
6824 }
6825 }
6826 return;
6827}
Jeff Johnson295189b2012-06-20 16:38:30 -07006828
Mihir Shetefd62d9d2014-08-06 15:08:21 +05306829/*==========================================================================
6830 FUNCTION WLANTL_FatalError
6831
6832 DESCRIPTION
6833 Fatal error reported in TX path, post an event to TX Thread for further
6834 handling
6835
6836 DEPENDENCIES
6837 The TL must be initialized before this gets called.
6838
6839 PARAMETERS
6840
6841 VOID
6842
6843 RETURN VALUE None
6844
6845 SIDE EFFECTS
6846
6847============================================================================*/
6848
6849v_VOID_t
6850WLANTL_FatalError
6851(
6852 v_VOID_t
6853)
6854{
6855 vos_msg_t vosMsg;
6856 VOS_STATUS status;
6857
6858 vosMsg.reserved = 0;
6859 vosMsg.bodyptr = NULL;
6860 vosMsg.type = WLANTL_TX_FATAL_ERROR;
6861
6862 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
6863 if(status != VOS_STATUS_SUCCESS)
6864 {
6865 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6866 "%s: TX Msg Posting Failed with status: %d",
6867 __func__,status));
6868 }
6869 return;
6870}
Jeff Johnson295189b2012-06-20 16:38:30 -07006871/*============================================================================
6872 TL STATE MACHINE
6873============================================================================*/
6874
6875/*==========================================================================
6876 FUNCTION WLANTL_STATxConn
6877
6878 DESCRIPTION
6879 Transmit in connected state - only EAPOL and WAI packets allowed
6880
6881 DEPENDENCIES
6882 The STA must be registered with TL before this function can be called.
6883
6884 PARAMETERS
6885
6886 IN
6887 pvosGCtx: pointer to the global vos context; a handle to TL's
6888 control block can be extracted from its context
6889 ucSTAId: identifier of the station being processed
6890 vosDataBuff: pointer to the tx vos buffer
6891
6892 RETURN VALUE
6893 The result code associated with performing the operation
6894
6895 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6896 page fault
6897 VOS_STATUS_SUCCESS: Everything is good :)
6898
6899 Other return values are possible coming from the called functions.
6900 Please check API for additional info.
6901
6902 SIDE EFFECTS
6903
6904============================================================================*/
6905VOS_STATUS
6906WLANTL_STATxConn
6907(
6908 v_PVOID_t pvosGCtx,
6909 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006910 vos_pkt_t** pvosDataBuff,
6911 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07006912)
6913{
6914 v_U16_t usPktLen;
6915 VOS_STATUS vosStatus;
6916 v_MACADDR_t vDestMacAddr;
6917 vos_pkt_t* vosDataBuff = NULL;
6918 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306919 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 WLANTL_MetaInfoType tlMetaInfo;
6921 v_U8_t ucTypeSubtype = 0;
6922 v_U8_t ucTid;
6923 v_U8_t extraHeadSpace = 0;
6924 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006925 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306926 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6928
6929 /*------------------------------------------------------------------------
6930 Sanity check
6931 Extract TL control block
6932 ------------------------------------------------------------------------*/
6933 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6934 if ( NULL == pTLCb )
6935 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006936 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6937 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 *pvosDataBuff = NULL;
6939 return VOS_STATUS_E_FAULT;
6940 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306941 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6942
6943 if ( NULL == pClientSTA )
6944 {
6945 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6946 "WLAN TL:Client Memory was not allocated on %s", __func__));
6947 return VOS_STATUS_E_FAILURE;
6948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006949
6950 /*-------------------------------------------------------------------
6951 Disable AC temporary - if successfull retrieve re-enable
6952 The order is justified because of the possible scenario
6953 - TL tryes to fetch packet for AC and it returns NULL
6954 - TL analyzes the data it has received to see if there are
6955 any more pkts available for AC -> if not TL will disable AC
6956 - however it is possible that while analyzing results TL got
6957 preempted by a pending indication where the mask was again set
6958 TL will not check again and as a result when it resumes
6959 execution it will disable AC
6960 To prevent this the AC will be disabled here and if retrieve
6961 is successfull it will be re-enabled
6962 -------------------------------------------------------------------*/
6963
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006964
6965 //LTI:pTLCb->atlSTAClients[ucSTAId].
6966 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
6967
6968 /*------------------------------------------------------------------------
6969 Fetch packet from HDD
6970 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08006971#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306972 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05306973 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08006974 !pTLCb->ucTdlsPeerCount)
6975 {
6976#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306977 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05306978 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006979 {
Sunil Ravid5406f22013-01-22 00:18:31 -08006980#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306981 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006982
6983 /*-------------------------------------------------------------------
6984 Disable AC temporary - if successfull retrieve re-enable
6985 The order is justified because of the possible scenario
6986 - TL tryes to fetch packet for AC and it returns NULL
6987 - TL analyzes the data it has received to see if there are
6988 any more pkts available for AC -> if not TL will disable AC
6989 - however it is possible that while analyzing results TL got
6990 preempted by a pending indication where the mask was again set
6991 TL will not check again and as a result when it resumes
6992 execution it will disable AC
6993 To prevent this the AC will be disabled here and if retrieve
6994 is successfull it will be re-enabled
6995 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306996 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07006997 }
6998 else
6999 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307000 //softap case
7001 ucAC = pTLCb->uCurServedAC;
7002 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007004
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307005 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307007 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307009 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7010 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7011 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7012 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307013 /*You make an initial assumption that HDD has no more data and if the
7014 assumption was wrong you reset the flags to their original state
7015 This will prevent from exposing a race condition between checking with HDD
7016 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007017 if ( 0 == ucACMask )
7018 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307019 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007020 }
7021 else
7022 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307023 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007024 }
7025
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007026
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007027 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007028 "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 +05307029 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07007030
7031 /*------------------------------------------------------------------------
7032 Fetch tx packet from HDD
7033 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007034
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307035 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007036 &ucSTAId,
7037 ucAC,
7038 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07007039
7040 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7041 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007042 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 "WLAN TL:No more data at HDD status %d", vosStatus));
7044 *pvosDataBuff = NULL;
7045
7046 /*--------------------------------------------------------------------
7047 Reset AC for the serviced station to the highest priority AC
7048 -> due to no more data at the station
7049 Even if this AC is not supported by the station, correction will be
7050 made in the main TL loop
7051 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307052 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
7053 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007054
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007055 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007056 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
7057 ucAC, ucACMask);
7058
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 return vosStatus;
7060 }
7061
7062 /*There are still packets in HDD - set back the pending packets and
7063 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307064 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
7065 pClientSTA->ucNoMoreData = 0;
7066 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007067
Jeff Johnson295189b2012-06-20 16:38:30 -07007068#ifdef WLAN_PERF
7069 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7070 (v_PVOID_t)0);
7071
7072#endif /*WLAN_PERF*/
7073
7074
7075#ifdef FEATURE_WLAN_WAPI
7076 /*------------------------------------------------------------------------
7077 If the packet is neither an Eapol packet nor a WAI packet then drop it
7078 ------------------------------------------------------------------------*/
7079 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
7080 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007081 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
7083
7084 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307085 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 VOS_STATUS_E_BADMSG);
7087 vosDataBuff = NULL;
7088 *pvosDataBuff = NULL;
7089 return VOS_STATUS_SUCCESS;
7090 }
7091#else
7092 if ( 0 == tlMetaInfo.ucIsEapol )
7093 {
7094 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7095 "WLAN TL:Received non EAPOL packet before authentication"));
7096
7097 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307098 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 VOS_STATUS_E_BADMSG);
7100 vosDataBuff = NULL;
7101 *pvosDataBuff = NULL;
7102 return VOS_STATUS_SUCCESS;
7103 }
7104#endif /* FEATURE_WLAN_WAPI */
7105
7106 /*-------------------------------------------------------------------------
7107 Check TID
7108 -------------------------------------------------------------------------*/
7109 ucTid = tlMetaInfo.ucTID;
7110
7111 /*Make sure TID is valid*/
7112 if ( WLANTL_TID_INVALID(ucTid))
7113 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007114 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7116 ucTid));
7117 ucTid = 0;
7118 }
7119
7120 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7121 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
7122
7123#ifdef FEATURE_WLAN_WAPI
7124 /*------------------------------------------------------------------------
7125 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
7126 frame is a WAI frame.
7127 ------------------------------------------------------------------------*/
7128 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
7129 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
7130#else
7131 /*------------------------------------------------------------------------
7132 Translate 802.3 frame to 802.11 if Frame translation is enabled
7133 ------------------------------------------------------------------------*/
7134 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307135 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007136#endif //#ifdef FEATURE_WLAN_WAPI
7137 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007138 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7139 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007140 &tlMetaInfo, &ucWDSEnabled,
7141 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 if ( VOS_STATUS_SUCCESS != vosStatus )
7143 {
7144 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7145 "WLAN TL:Error when translating header WLANTL_STATxConn"));
7146
7147 return vosStatus;
7148 }
7149
7150 tlMetaInfo.ucDisableFrmXtl = 1;
7151 }
7152
7153 /*-------------------------------------------------------------------------
7154 Call HAL to fill BD header
7155 -------------------------------------------------------------------------*/
7156 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7157
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307158 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 {
7160 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7161 }
7162
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307163#ifdef FEATURE_WLAN_WAPI
7164 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
7165 * case of WPA where GTK handshake is done after the 4 way handshake, the
7166 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
7167 * the TL is in authenticated state. Since the PTK has been installed
7168 * already (after the 4 way handshake) we make sure that all traffic
7169 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
7170 * we will only allow EAPOL data or WAI in case of WAPI)
7171 */
7172 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
7173 {
7174 txFlag = 0;
7175 }
7176#else
7177 if (pClientSTA->ptkInstalled)
7178 {
7179 txFlag = 0;
7180 }
7181#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007182
7183 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
7184 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307185 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307187 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307188 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07007189 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07007190
7191 if ( VOS_STATUS_SUCCESS != vosStatus )
7192 {
7193 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7194 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7195 *pvosDataBuff = NULL;
7196 return vosStatus;
7197 }
7198
7199 /*-----------------------------------------------------------------------
7200 Update tx counter for BA session query for tx side
7201 !1 - should this be done for EAPOL frames?
7202 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307203 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07007204
7205 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307206 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07007207
7208 /*------------------------------------------------------------------------
7209 Save data to input pointer for TL core
7210 ------------------------------------------------------------------------*/
7211 *pvosDataBuff = vosDataBuff;
7212 /*security frames cannot be delayed*/
7213 pTLCb->bUrgent = TRUE;
7214
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 /* TX Statistics */
7216 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7217 {
7218 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307219 pClientSTA->trafficStatistics.txUCFcnt++;
7220 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007222
7223 return VOS_STATUS_SUCCESS;
7224}/* WLANTL_STATxConn */
7225
7226
7227/*==========================================================================
7228 FUNCTION WLANTL_STATxAuth
7229
7230 DESCRIPTION
7231 Transmit in authenticated state - all data allowed
7232
7233 DEPENDENCIES
7234 The STA must be registered with TL before this function can be called.
7235
7236 PARAMETERS
7237
7238 IN
7239 pvosGCtx: pointer to the global vos context; a handle to TL's
7240 control block can be extracted from its context
7241 ucSTAId: identifier of the station being processed
7242 vosDataBuff: pointer to the tx vos buffer
7243
7244 RETURN VALUE
7245 The result code associated with performing the operation
7246
7247 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7248 page fault
7249 VOS_STATUS_SUCCESS: Everything is good :)
7250
7251 Other return values are possible coming from the called functions.
7252 Please check API for additional info.
7253
7254 SIDE EFFECTS
7255
7256============================================================================*/
7257VOS_STATUS
7258WLANTL_STATxAuth
7259(
7260 v_PVOID_t pvosGCtx,
7261 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007262 vos_pkt_t** pvosDataBuff,
7263 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007264)
7265{
7266 v_U16_t usPktLen;
7267 VOS_STATUS vosStatus;
7268 v_MACADDR_t vDestMacAddr;
7269 vos_pkt_t* vosDataBuff = NULL;
7270 WLANTL_CbType* pTLCb = NULL;
7271 WLANTL_MetaInfoType tlMetaInfo;
7272 v_U8_t ucTypeSubtype = 0;
7273 WLANTL_ACEnumType ucAC;
7274 WLANTL_ACEnumType ucNextAC;
7275 v_U8_t ucTid;
7276 v_U8_t ucSwFrmXtl = 0;
7277 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307278 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307280 v_U32_t ucTxFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 v_U8_t ucACMask, i;
7282 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7283
7284 /*------------------------------------------------------------------------
7285 Sanity check
7286 Extract TL control block
7287 ------------------------------------------------------------------------*/
7288 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7289 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7290 {
7291 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007292 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 pTLCb, pvosDataBuff));
7294 if (NULL != pvosDataBuff)
7295 {
7296 *pvosDataBuff = NULL;
7297 }
7298 if(NULL != pTLCb)
7299 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307300 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7301 {
7302 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7303 "WLAN TL:Client Memory was not allocated on %s", __func__));
7304 return VOS_STATUS_E_FAILURE;
7305 }
7306 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 }
7308 return VOS_STATUS_E_FAULT;
7309 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307310 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007311
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307312 if ( NULL == pStaClient )
7313 {
7314 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7315 "WLAN TL:Client Memory was not allocated on %s", __func__));
7316 return VOS_STATUS_E_FAILURE;
7317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007318
7319 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7320 /*------------------------------------------------------------------------
7321 Fetch packet from HDD
7322 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007323#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307324 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307325 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007326 !pTLCb->ucTdlsPeerCount)
7327 {
7328#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307330 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 {
7332#endif
7333 ucAC = pStaClient->ucCurrentAC;
7334
7335 /*-------------------------------------------------------------------
7336 Disable AC temporary - if successfull retrieve re-enable
7337 The order is justified because of the possible scenario
7338 - TL tryes to fetch packet for AC and it returns NULL
7339 - TL analyzes the data it has received to see if there are
7340 any more pkts available for AC -> if not TL will disable AC
7341 - however it is possible that while analyzing results TL got
7342 preempted by a pending indication where the mask was again set
7343 TL will not check again and as a result when it resumes
7344 execution it will disable AC
7345 To prevent this the AC will be disabled here and if retrieve
7346 is successfull it will be re-enabled
7347 -------------------------------------------------------------------*/
7348 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7349
7350 // don't reset it, as other AC queues in HDD may have packets
7351 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 }
7353 else
7354 {
7355 //softap case
7356 ucAC = pTLCb->uCurServedAC;
7357 pStaClient->aucACMask[ucAC] = 0;
7358
7359 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007361
7362 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 /*You make an initial assumption that HDD has no more data and if the
7364 assumption was wrong you reset the flags to their original state
7365 This will prevent from exposing a race condition between checking with HDD
7366 for packets and setting the flags to false*/
7367 if ( 0 == ucACMask )
7368 {
7369 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7370 pStaClient->ucNoMoreData = 1;
7371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007372
7373 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7374 &ucSTAId,
7375 ucAC,
7376 &vosDataBuff, &tlMetaInfo );
7377
7378
7379 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7380 {
7381
7382 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
7383 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
7384 vosStatus);
7385 *pvosDataBuff = NULL;
7386 /*--------------------------------------------------------------------
7387 Reset AC for the serviced station to the highest priority AC
7388 -> due to no more data at the station
7389 Even if this AC is not supported by the station, correction will be
7390 made in the main TL loop
7391 --------------------------------------------------------------------*/
7392 pStaClient->ucCurrentAC = WLANTL_AC_VO;
7393 pStaClient->ucCurrentWeight = 0;
7394
7395 return vosStatus;
7396 }
7397
Jeff Johnsone7245742012-09-05 17:12:55 -07007398 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007399
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 /*There are still packets in HDD - set back the pending packets and
7401 the no more data assumption*/
7402 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7403 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007404
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7406 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 // don't need to set it, as we don't reset it in this function.
7408 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007410
7411#ifdef WLAN_PERF
7412 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7413 (v_PVOID_t)0);
7414#endif /*WLAN_PERF*/
7415
7416 /*-------------------------------------------------------------------------
7417 Check TID
7418 -------------------------------------------------------------------------*/
7419 ucTid = tlMetaInfo.ucTID;
7420
7421 /*Make sure TID is valid*/
7422 if ( WLANTL_TID_INVALID(ucTid))
7423 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007424 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7426 ucTid));
7427 ucTid = 0;
7428 }
7429
7430 /*Save for UAPSD timer consideration*/
7431 pStaClient->ucServicedAC = ucAC;
7432
7433 if ( ucAC == pStaClient->ucCurrentAC )
7434 {
7435 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7436 pStaClient->ucCurrentWeight--;
7437 }
7438 else
7439 {
7440 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307441 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007442
7443 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7444
7445 }
7446
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7448 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 if ( 0 == pStaClient->ucCurrentWeight )
7450 {
7451 WLANTL_ACEnumType tempAC = ucAC;
7452 /*-----------------------------------------------------------------------
7453 Choose next AC - !!! optimize me
7454 -----------------------------------------------------------------------*/
7455 while ( 0 != ucACMask )
7456 {
7457 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7458 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7459 {
7460 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307461 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007462
7463 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7464 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7465 pStaClient->ucCurrentAC ,
7466 pStaClient->ucCurrentWeight));
7467 break;
7468 }
7469 tempAC = ucNextAC;
7470 }
7471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007473
7474 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7475 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7476
7477 /*------------------------------------------------------------------------
7478 Translate 802.3 frame to 802.11
7479 ------------------------------------------------------------------------*/
7480 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7481 {
7482 /* Needs frame translation */
7483 // if the client has not enabled SW-only frame translation
7484 // and if the frame is a unicast frame
7485 // (HW frame translation does not support multiple broadcast domains
7486 // so we use SW frame translation for broadcast/multicast frames)
7487#ifdef FEATURE_WLAN_WAPI
7488 // and if the frame is not a WAPI frame
7489#endif
7490 // then use HW_based frame translation
7491
7492 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7493 ( 0 == tlMetaInfo.ucBcast ) &&
7494 ( 0 == tlMetaInfo.ucMcast )
7495#ifdef FEATURE_WLAN_WAPI
7496 && ( tlMetaInfo.ucIsWai != 1 )
7497#endif
7498 )
7499 {
7500#ifdef WLAN_PERF
7501 v_U32_t uFastFwdOK = 0;
7502
7503 /* HW based translation. See if the frame could be fast forwarded */
7504 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7505 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7506
7507 if( VOS_STATUS_SUCCESS == vosStatus )
7508 {
7509 if(uFastFwdOK)
7510 {
7511 /* Packet could be fast forwarded now */
7512 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7513 (v_PVOID_t)pStaClient->pfnSTATxComp );
7514
7515 *pvosDataBuff = vosDataBuff;
7516
7517 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7518 stats for every pkt? */
7519 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7520 return vosStatus;
7521 }
7522 /* can't be fast forwarded, fall through normal (slow) path. */
7523 }
7524 else
7525 {
7526
7527 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7528 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7529 *pvosDataBuff = NULL;
7530 return vosStatus;
7531 }
7532#endif /*WLAN_PERF*/
7533 }
7534 else
7535 {
7536 /* SW based translation */
7537
7538#ifdef FEATURE_WLAN_WAPI
7539 gUcIsWai = tlMetaInfo.ucIsWai,
7540#endif
7541
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007542 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7543 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007544 &tlMetaInfo, &ucWDSEnabled,
7545 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 if ( VOS_STATUS_SUCCESS != vosStatus )
7547 {
7548 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7549 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7550 return vosStatus;
7551 }
7552
7553 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007554 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 ucSwFrmXtl = 1;
7556 tlMetaInfo.ucDisableFrmXtl = 1;
7557 }
7558 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307559#ifdef FEATURE_WLAN_TDLS
7560 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7561 change. so update the pStaClient accordingly */
7562 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007563
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307564 if ( NULL == pStaClient )
7565 {
7566 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7567 "pStaClient is NULL %s", __func__));
7568 return VOS_STATUS_E_FAILURE;
7569 }
7570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 /*-------------------------------------------------------------------------
7572 Call HAL to fill BD header
7573 -------------------------------------------------------------------------*/
7574 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7575
7576 if ( pStaClient->wSTADesc.ucQosEnabled )
7577 {
7578 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7579 }
7580
7581 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7582 HAL_TRIGGER_ENABLED_AC_MASK:0;
7583
7584#ifdef FEATURE_WLAN_WAPI
7585 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7586 {
7587#ifdef LIBRA_WAPI_SUPPORT
7588 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7589#endif //LIBRA_WAPI_SUPPORT
7590 if ( tlMetaInfo.ucIsWai == 1 )
7591 {
7592 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7593 }
7594 }
7595#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007596#ifdef FEATURE_WLAN_TDLS
7597 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7598 {
7599 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7600 }
7601#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05307602 if( tlMetaInfo.ucIsArp )
7603 {
7604 /*Send ARP at lowest Phy rate and through WQ5 */
7605 ucTxFlag |= HAL_USE_BD_RATE_MASK;
Abhishek Singhfa011222014-04-14 10:57:08 +05307606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007607
7608 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7609 vosDataBuff , &vDestMacAddr,
7610 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7611 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7612 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307613 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7615 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7616
7617 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7618 {
7619 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7620 "Fill TX BD Error status %d", vosStatus));
7621
7622 return vosStatus;
7623 }
7624
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 /* TX Statistics */
7626 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7627 {
7628 /* This is TX UC frame */
7629 pStaClient->trafficStatistics.txUCFcnt++;
7630 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007632
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007633#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 /*-----------------------------------------------------------------------
7635 Update tx counter for BA session query for tx side
7636 -----------------------------------------------------------------------*/
7637 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007638#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307639 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007640#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007641
7642 /* This code is to send traffic with lower priority AC when we does not
7643 get admitted to send it. Today HAL does not downgrade AC so this code
7644 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7645 statement is always false.)
7646 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7647 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7648 then there will be no need for any AC downgrade logic in TL/WDI. */
7649#if 0
7650 if (( ucTid != tlMetaInfo.ucTID ) &&
7651 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7652 ( 0 != ucSwFrmXtl ))
7653 {
7654 /*---------------------------------------------------------------------
7655 !! FIX me: Once downgrading is clear put in the proper change
7656 ---------------------------------------------------------------------*/
7657 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7658
7659 //!!!Fix this replace peek with extract
7660 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7661 sizeof(*pucQosCtrl));
7662 *pucQosCtrl = ucTid; //? proper byte order
7663 }
7664#endif
7665
7666 if ( VOS_STATUS_SUCCESS != vosStatus )
7667 {
7668 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7669 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7670 *pvosDataBuff = NULL;
7671 return vosStatus;
7672 }
7673
7674 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7675 (v_PVOID_t)pStaClient->pfnSTATxComp );
7676
7677 *pvosDataBuff = vosDataBuff;
7678
7679 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7680 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7681 {
7682 pTLCb->bUrgent= TRUE;
7683 }
7684
7685 return VOS_STATUS_SUCCESS;
7686}/* WLANTL_STATxAuth */
7687
7688/*==========================================================================
7689 FUNCTION WLANTL_STATxDisc
7690
7691 DESCRIPTION
7692 Transmit in disconnected state - no data allowed
7693
7694 DEPENDENCIES
7695 The STA must be registered with TL before this function can be called.
7696
7697 PARAMETERS
7698
7699 IN
7700 pvosGCtx: pointer to the global vos context; a handle to TL's
7701 control block can be extracted from its context
7702 ucSTAId: identifier of the station being processed
7703 vosDataBuff: pointer to the tx vos buffer
7704
7705 RETURN VALUE
7706 The result code associated with performing the operation
7707
7708 VOS_STATUS_SUCCESS: Everything is good :)
7709
7710 SIDE EFFECTS
7711
7712============================================================================*/
7713VOS_STATUS
7714WLANTL_STATxDisc
7715(
7716 v_PVOID_t pvosGCtx,
7717 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007718 vos_pkt_t** pvosDataBuff,
7719 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007720)
7721{
7722 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307723 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007724 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7725
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 /*------------------------------------------------------------------------
7727 Sanity check
7728 Extract TL control block
7729 ------------------------------------------------------------------------*/
7730 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7731 if ( NULL == pTLCb )
7732 {
7733 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7734 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7735 *pvosDataBuff = NULL;
7736 return VOS_STATUS_E_FAULT;
7737 }
7738
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307739 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7740
7741 if ( NULL == pClientSTA )
7742 {
7743 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7744 "WLAN TL:Client Memory was not allocated on %s", __func__));
7745 return VOS_STATUS_E_FAILURE;
7746 }
7747
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 /*------------------------------------------------------------------------
7749 Error
7750 ------------------------------------------------------------------------*/
7751 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7752 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7753 " request"));
7754
7755 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307756 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007757
7758 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307759 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007760
7761 return VOS_STATUS_SUCCESS;
7762}/* WLANTL_STATxDisc */
7763
7764/*==========================================================================
7765 FUNCTION WLANTL_STARxConn
7766
7767 DESCRIPTION
7768 Receive in connected state - only EAPOL
7769
7770 DEPENDENCIES
7771 The STA must be registered with TL before this function can be called.
7772
7773 PARAMETERS
7774
7775 IN
7776 pvosGCtx: pointer to the global vos context; a handle to TL's
7777 control block can be extracted from its context
7778 ucSTAId: identifier of the station being processed
7779 vosDataBuff: pointer to the tx/rx vos buffer
7780
7781 RETURN VALUE
7782 The result code associated with performing the operation
7783
7784 VOS_STATUS_E_INVAL: invalid input parameters
7785 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7786 page fault
7787 VOS_STATUS_SUCCESS: Everything is good :)
7788
7789 SIDE EFFECTS
7790
7791============================================================================*/
7792VOS_STATUS
7793WLANTL_STARxConn
7794(
7795 v_PVOID_t pvosGCtx,
7796 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007797 vos_pkt_t** pvosDataBuff,
7798 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007799)
7800{
7801 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307802 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 v_U16_t usEtherType = 0;
7804 v_U16_t usPktLen;
7805 v_U8_t ucMPDUHOffset;
7806 v_U16_t usMPDUDOffset;
7807 v_U16_t usMPDULen;
7808 v_U8_t ucMPDUHLen;
7809 v_U16_t usActualHLen = 0;
7810 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7811 vos_pkt_t* vosDataBuff;
7812 v_PVOID_t aucBDHeader;
7813 v_U8_t ucTid;
7814 WLANTL_RxMetaInfoType wRxMetaInfo;
7815 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7816
7817 /*------------------------------------------------------------------------
7818 Sanity check
7819 ------------------------------------------------------------------------*/
7820 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
7821 {
7822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7823 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
7824 return VOS_STATUS_E_INVAL;
7825 }
7826
7827 /*------------------------------------------------------------------------
7828 Extract TL control block
7829 ------------------------------------------------------------------------*/
7830 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7831 if ( NULL == pTLCb )
7832 {
7833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7834 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
7835 return VOS_STATUS_E_FAULT;
7836 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307837 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7838
7839 if ( NULL == pClientSTA )
7840 {
7841 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7842 "WLAN TL:Client Memory was not allocated on %s", __func__));
7843 return VOS_STATUS_E_FAILURE;
7844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007845
7846 /*------------------------------------------------------------------------
7847 Extract BD header and check if valid
7848 ------------------------------------------------------------------------*/
7849 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
7850
7851 if ( NULL == aucBDHeader )
7852 {
7853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7854 "WLAN TL:Cannot extract BD header"));
7855 VOS_ASSERT( 0 );
7856 return VOS_STATUS_E_FAULT;
7857 }
7858
7859
7860 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
7861 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
7862 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
7863 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
7864 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
7865
7866 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
7867
7868 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7869 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
7870 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
7871
7872 /*It will cut out the 802.11 header if not used*/
7873 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
7874 {
7875 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7876 "WLAN TL:BD header corrupted - dropping packet"));
7877 /* Drop packet */
7878 vos_pkt_return_packet(vosDataBuff);
7879 return VOS_STATUS_SUCCESS;
7880 }
7881
7882 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
7883
7884 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
7885 {
7886#ifdef FEATURE_WLAN_WAPI
7887 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
7888 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
7889 /* that we get an EAPOL packet in WAPI mode or vice versa? */
7890 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
7891 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007892 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007893 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 /* Drop packet */
7895 vos_pkt_return_packet(vosDataBuff);
7896 }
7897#else
7898 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
7899 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007900 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7901 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07007902 /* Drop packet */
7903 vos_pkt_return_packet(vosDataBuff);
7904 }
7905#endif /* FEATURE_WLAN_WAPI */
7906 else /* Frame is an EAPOL frame or a WAI frame*/
7907 {
Katya Nigam42e16e82014-02-04 16:28:55 +05307908 MTRACE(vos_trace(VOS_MODULE_ID_TL,
7909 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007910
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007911 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007912 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
7913
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307915 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 {
7917 if (usMPDUDOffset > ucMPDUHOffset)
7918 {
7919 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
7920 }
7921
7922 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007923 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07007924
7925 if ( VOS_STATUS_SUCCESS != vosStatus )
7926 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05307927 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
7929 /* Drop packet */
7930 vos_pkt_return_packet(vosDataBuff);
7931 return vosStatus;
7932 }
7933 }
7934 /*-------------------------------------------------------------------
7935 Increment receive counter
7936 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007937 if ( !WLANTL_TID_INVALID( ucTid) )
7938 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307939 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07007940 }
7941 else
7942 {
7943 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7944 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
7945 ucTid, ucSTAId, __func__));
7946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007947
7948 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7949 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
7950
7951 /*-------------------------------------------------------------------
7952 !!!Assuming TID = UP mapping
7953 -------------------------------------------------------------------*/
7954 wRxMetaInfo.ucUP = ucTid;
7955
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007957 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307958 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 {
7960 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307961 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 &wRxMetaInfo );
7963 }
7964 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307965 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 &wRxMetaInfo );
7967 }/*EAPOL frame or WAI frame*/
7968 }/*vos status success*/
7969
7970 return VOS_STATUS_SUCCESS;
7971}/* WLANTL_STARxConn */
7972
Jeff Johnson295189b2012-06-20 16:38:30 -07007973/*==========================================================================
7974 FUNCTION WLANTL_FwdPktToHDD
7975
7976 DESCRIPTION
7977 Determine the Destation Station ID and route the Frame to Upper Layer
7978
7979 DEPENDENCIES
7980
7981 PARAMETERS
7982
7983 IN
7984 pvosGCtx: pointer to the global vos context; a handle to TL's
7985 control block can be extracted from its context
7986 ucSTAId: identifier of the station being processed
7987 vosDataBuff: pointer to the rx vos buffer
7988
7989 RETURN VALUE
7990 The result code associated with performing the operation
7991
7992 VOS_STATUS_E_INVAL: invalid input parameters
7993 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7994 page fault
7995 VOS_STATUS_SUCCESS: Everything is good :)
7996
7997 SIDE EFFECTS
7998
7999============================================================================*/
8000
8001VOS_STATUS
8002WLANTL_FwdPktToHDD
8003(
8004 v_PVOID_t pvosGCtx,
8005 vos_pkt_t* pvosDataBuff,
8006 v_U8_t ucSTAId
8007)
8008{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308009 v_MACADDR_t DestMacAddress;
8010 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
8011 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308013 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 vos_pkt_t* vosDataBuff ;
8015 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308016 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308017 vos_pkt_t* vosNextDataBuff ;
8018 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 WLANTL_RxMetaInfoType wRxMetaInfo;
8020
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 /*------------------------------------------------------------------------
8022 Sanity check
8023 ------------------------------------------------------------------------*/
8024 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
8025 {
8026 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8027 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
8028 return VOS_STATUS_E_INVAL;
8029 }
8030
8031 /*------------------------------------------------------------------------
8032 Extract TL control block
8033 ------------------------------------------------------------------------*/
8034 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8035 if ( NULL == pTLCb )
8036 {
8037 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8038 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
8039 return VOS_STATUS_E_FAULT;
8040 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308041
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008042 if(WLANTL_STA_ID_INVALID(ucSTAId))
8043 {
8044 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
8045 ucSTAId));
8046 return VOS_STATUS_E_INVAL;
8047 }
8048
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308049 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8050
8051 if ( NULL == pClientSTA )
8052 {
8053 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8054 "WLAN TL:Client Memory was not allocated on %s", __func__));
8055 return VOS_STATUS_E_FAILURE;
8056 }
8057
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
8059 may have packets destined to multiple destinations we have to process each packet
8060 at a time and determine its Destination. So the Voschain provided by Reorder code
8061 is unchain and forwarded to Upper Layer after Determining the Destination */
8062
8063 vosDataBuff = pvosDataBuff;
8064 while (vosDataBuff != NULL)
8065 {
8066 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
8067 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05308068 (v_PVOID_t *)&STAMetaInfoPtr );
8069 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
8070 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07008071
8072 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
8073 if ( VOS_STATUS_SUCCESS != vosStatus )
8074 {
8075 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008076 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 vos_pkt_return_packet(vosDataBuff);
8078 return vosStatus;
8079 }
8080
Arif Hussaina7c8e412013-11-20 11:06:42 -08008081 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
8082 "station mac "MAC_ADDRESS_STR,
8083 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008084
8085 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
8086 {
8087 // destination is mc/bc station
8088 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
8089 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008090 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 }
8092 else
8093 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308094 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 {
8096 // destination is AP itself
8097 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8098 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008099 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308101 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 {
8103 // destination station is something else
8104 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008105 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8107 }
8108
8109
8110 //loopback unicast station comes here
8111 }
8112
Girish Gowli93e3edd2014-05-01 15:42:31 +05308113 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
8115
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308116 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308118 if ( VOS_STATUS_SUCCESS != vosStatus )
8119 {
8120 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008121 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308122 vos_pkt_return_packet(vosDataBuff);
8123
8124 return vosStatus;
8125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 vosDataBuff = vosNextDataBuff;
8127 }
8128 return VOS_STATUS_SUCCESS;
8129}
Jeff Johnson295189b2012-06-20 16:38:30 -07008130
8131/*==========================================================================
8132 FUNCTION WLANTL_STARxAuth
8133
8134 DESCRIPTION
8135 Receive in authenticated state - all data allowed
8136
8137 DEPENDENCIES
8138 The STA must be registered with TL before this function can be called.
8139
8140 PARAMETERS
8141
8142 IN
8143 pvosGCtx: pointer to the global vos context; a handle to TL's
8144 control block can be extracted from its context
8145 ucSTAId: identifier of the station being processed
8146 vosDataBuff: pointer to the rx vos buffer
8147
8148 RETURN VALUE
8149 The result code associated with performing the operation
8150
8151 VOS_STATUS_E_INVAL: invalid input parameters
8152 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8153 page fault
8154 VOS_STATUS_SUCCESS: Everything is good :)
8155
8156 SIDE EFFECTS
8157
8158============================================================================*/
8159VOS_STATUS
8160WLANTL_STARxAuth
8161(
8162 v_PVOID_t pvosGCtx,
8163 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008164 vos_pkt_t** pvosDataBuff,
8165 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008166)
8167{
8168 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308169 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 v_U8_t ucAsf; /* AMSDU sub frame */
8171 v_U16_t usMPDUDOffset;
8172 v_U8_t ucMPDUHOffset;
8173 v_U16_t usMPDULen;
8174 v_U8_t ucMPDUHLen;
8175 v_U16_t usActualHLen = 0;
8176 v_U8_t ucTid;
8177#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07008178 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008179#endif
8180 v_U16_t usPktLen;
8181 vos_pkt_t* vosDataBuff ;
8182 v_PVOID_t aucBDHeader;
8183 VOS_STATUS vosStatus;
8184 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07008185 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308186 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
8188 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
8189 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
8190 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008191 struct _BARFrmStruct *pBarFrame = NULL;
8192
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8194
8195 /*------------------------------------------------------------------------
8196 Sanity check
8197 ------------------------------------------------------------------------*/
8198 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8199 {
8200 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8201 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
8202 return VOS_STATUS_E_INVAL;
8203 }
8204
8205 /*------------------------------------------------------------------------
8206 Extract TL control block
8207 ------------------------------------------------------------------------*/
8208 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8209 if ( NULL == pTLCb )
8210 {
8211 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8212 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
8213 return VOS_STATUS_E_FAULT;
8214 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308215 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8216
8217 if ( NULL == pClientSTA )
8218 {
8219 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8220 "WLAN TL:Client Memory was not allocated on %s", __func__));
8221 return VOS_STATUS_E_FAILURE;
8222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008223
8224 /*------------------------------------------------------------------------
8225 Extract BD header and check if valid
8226 ------------------------------------------------------------------------*/
8227 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
8228
8229 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8230 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8231 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8232 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8233 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8234
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008235 /* Fix for a hardware bug.
8236 * H/W does not update the tid field in BD header for BAR frames.
8237 * Fix is to read the tid field from MAC header of BAR frame */
8238 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
8239 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
8240 {
8241 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
8242 ucTid = pBarFrame->barControl.numTID;
8243 }
8244
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 /*Host based replay check is needed for unicast data frames*/
8246 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008247 if(0 != ucMPDUHLen)
8248 {
8249 ucPMPDUHLen = ucMPDUHLen;
8250 }
8251
8252 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8253 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
8254 " Tid %d BD %d",
8255 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
8256 WLANHAL_RX_BD_HEADER_SIZE));
8257
8258 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8259
8260 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8261 {
8262 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8263 {
8264 /* AMSDU case, ucMPDUHOffset = 0
8265 * it should be hancdled seperatly */
8266 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8267 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8268 ( !WLANTL_TID_INVALID(ucTid) ))
8269 {
8270 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8271 }
8272 else
8273 {
8274 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8275 "WLAN TL:BD header corrupted - dropping packet"));
8276 /* Drop packet */
8277 vos_pkt_return_packet(vosDataBuff);
8278 return VOS_STATUS_SUCCESS;
8279 }
8280 }
8281 else
8282 {
8283 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8284 "WLAN TL:BD header corrupted - dropping packet"));
8285 /* Drop packet */
8286 vos_pkt_return_packet(vosDataBuff);
8287 return VOS_STATUS_SUCCESS;
8288 }
8289 }
8290
8291#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308292 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 {
8294 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8295 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8296 {
8297 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8298 {
8299 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8300 {
8301 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8302 "WLAN TL:WAI frame was received encrypted - dropping"));
8303 /* Drop packet */
8304 /*Temporary fix added to fix wapi rekey issue*/
8305 //vos_pkt_return_packet(vosDataBuff);
8306 //return vosStatus; //returning success
8307 }
8308 }
8309 else
8310 {
8311 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8312 {
8313 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8314 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8315 /* Drop packet */
8316 vos_pkt_return_packet(vosDataBuff);
8317 return vosStatus; //returning success
8318 }
8319 }
8320 }
8321 else //could not extract EtherType - this should not happen
8322 {
8323 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008324 "WLAN TL:Could not extract EtherType"));
8325 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 }
8328 }
8329#endif /* FEATURE_WLAN_WAPI */
8330
8331 /*----------------------------------------------------------------------
8332 Increment receive counter
8333 !! not sure this is the best place to increase this - pkt might be
8334 dropped below or delayed in TL's queues
8335 - will leave it here for now
8336 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008337 if ( !WLANTL_TID_INVALID( ucTid) )
8338 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308339 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008340 }
8341 else
8342 {
8343 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8344 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8345 ucTid, ucSTAId, __func__));
8346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008347
8348 /*------------------------------------------------------------------------
8349 Check if AMSDU and send for processing if so
8350 ------------------------------------------------------------------------*/
8351 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8352
8353 if ( 0 != ucAsf )
8354 {
8355 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8356 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8357 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8358 ucMPDUHLen, usMPDULen );
8359 if(NULL == vosDataBuff)
8360 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008361 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 return VOS_STATUS_SUCCESS;
8363 }
8364 }
8365 /* After AMSDU header handled
8366 * AMSDU frame just same with normal frames */
8367 /*-------------------------------------------------------------------
8368 Translating header if necesary
8369 !! Fix me: rmv comments below
8370 ----------------------------------------------------------------------*/
8371 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308372 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8374 {
8375 if(0 == ucMPDUHLen)
8376 {
8377 ucMPDUHLen = ucPMPDUHLen;
8378 }
8379 if (usMPDUDOffset > ucMPDUHOffset)
8380 {
8381 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8382 }
8383 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008384 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008385
8386 if ( VOS_STATUS_SUCCESS != vosStatus )
8387 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308388 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8390 /* Drop packet */
8391 vos_pkt_return_packet(vosDataBuff);
8392 return vosStatus;
8393 }
8394 }
8395 /* Softap requires additional Info such as Destination STAID and Access
8396 Category. Voschain or Buffer returned by BA would be unchain and this
8397 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308398 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308400 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8402 (v_PVOID_t)STAMetaInfoPtr);
8403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008404
8405 /*------------------------------------------------------------------------
8406 Check to see if re-ordering session is in place
8407 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308408 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 {
8410 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8411 }
8412
Jeff Johnson295189b2012-06-20 16:38:30 -07008413if(0 == ucUnicastBroadcastType
8414#ifdef FEATURE_ON_CHIP_REORDERING
8415 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8416#endif
8417)
8418{
8419 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308420 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 {
8422 /* replay check is needed for the station */
8423
8424 /* check whether frame is AMSDU frame */
8425 if ( 0 != ucAsf )
8426 {
8427 /* Since virgo can't send AMSDU frames this leg of the code
8428 was not tested properly, it needs to be tested properly*/
8429 /* Frame is AMSDU frame. As per 802.11n only first
8430 subframe will have replay counter */
8431 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8432 if( 0 != ucEsf )
8433 {
8434 v_BOOL_t status;
8435 /* Getting 48-bit replay counter from the RX BD */
8436 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8437
8438 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008439 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008440
8441 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308442 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008443
8444 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008445 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008446
8447 /* It is first subframe of AMSDU thus it
8448 conatains replay counter perform the
8449 replay check for this first subframe*/
8450 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8451 if(VOS_FALSE == status)
8452 {
8453 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308454 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 }
8456 else
8457 {
8458 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008459 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008460
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308461 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008463 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308464 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008465
8466 /* Drop the packet */
8467 vos_pkt_return_packet(vosDataBuff);
8468 return VOS_STATUS_SUCCESS;
8469 }
8470 }
8471 }
8472 else
8473 {
8474 v_BOOL_t status;
8475
8476 /* Getting 48-bit replay counter from the RX BD */
8477 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8478
8479 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008480 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008481
8482 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308483 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008484
8485 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008486 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008487
8488 /* It is not AMSDU frame so perform
8489 reaply check for each packet, as
8490 each packet contains valid replay counter*/
8491 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8492 if(VOS_FALSE == status)
8493 {
8494 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308495 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 }
8497 else
8498 {
8499 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008500 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008501
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308502 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008504 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308505 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008506
8507 /* Repaly packet, drop the packet */
8508 vos_pkt_return_packet(vosDataBuff);
8509 return VOS_STATUS_SUCCESS;
8510 }
8511 }
8512 }
8513}
8514/*It is a broadast packet DPU has already done replay check for
8515 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008516
8517 if ( NULL != vosDataBuff )
8518 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308519 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 {
8521 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8522 }
8523 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 {
8525 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008526 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308527#ifdef FEATURE_WLAN_TDLS
8528 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8529 {
8530 wRxMetaInfo.isStaTdls = TRUE;
8531 }
8532 else
8533 {
8534 wRxMetaInfo.isStaTdls = FALSE;
8535 }
8536#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308537 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 &wRxMetaInfo );
8539 }
8540 }/* if not NULL */
8541
8542 return VOS_STATUS_SUCCESS;
8543}/* WLANTL_STARxAuth */
8544
8545
8546/*==========================================================================
8547 FUNCTION WLANTL_STARxDisc
8548
8549 DESCRIPTION
8550 Receive in disconnected state - no data allowed
8551
8552 DEPENDENCIES
8553 The STA must be registered with TL before this function can be called.
8554
8555 PARAMETERS
8556
8557 IN
8558 pvosGCtx: pointer to the global vos context; a handle to TL's
8559 control block can be extracted from its context
8560 ucSTAId: identifier of the station being processed
8561 vosDataBuff: pointer to the rx vos buffer
8562
8563 RETURN VALUE
8564 The result code associated with performing the operation
8565
8566 VOS_STATUS_SUCCESS: Everything is good :)
8567
8568 SIDE EFFECTS
8569
8570============================================================================*/
8571VOS_STATUS
8572WLANTL_STARxDisc
8573(
8574 v_PVOID_t pvosGCtx,
8575 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008576 vos_pkt_t** pvosDataBuff,
8577 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008578)
8579{
8580 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8581
8582 /*------------------------------------------------------------------------
8583 Sanity check
8584 ------------------------------------------------------------------------*/
8585 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8586 {
8587 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8588 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8589 return VOS_STATUS_E_INVAL;
8590 }
8591
8592 /*------------------------------------------------------------------------
8593 Error - drop packet
8594 ------------------------------------------------------------------------*/
8595 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8596 "WLAN TL:Packet should not be received in state disconnected"
8597 " - dropping"));
8598 vos_pkt_return_packet(*pvosDataBuff);
8599 *pvosDataBuff = NULL;
8600
8601 return VOS_STATUS_SUCCESS;
8602}/* WLANTL_STARxDisc */
8603
8604/*==========================================================================
8605 Processing main loops for MAIN and TX threads
8606 ==========================================================================*/
8607
8608/*==========================================================================
8609 FUNCTION WLANTL_McProcessMsg
8610
8611 DESCRIPTION
8612 Called by VOSS when a message was serialized for TL through the
8613 main thread/task.
8614
8615 DEPENDENCIES
8616 The TL must be initialized before this function can be called.
8617
8618 PARAMETERS
8619
8620 IN
8621 pvosGCtx: pointer to the global vos context; a handle to TL's
8622 control block can be extracted from its context
8623 message: type and content of the message
8624
8625
8626 RETURN VALUE
8627 The result code associated with performing the operation
8628
8629 VOS_STATUS_E_INVAL: invalid input parameters
8630 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8631 page fault
8632 VOS_STATUS_SUCCESS: Everything is good :)
8633
8634 SIDE EFFECTS
8635
8636============================================================================*/
8637VOS_STATUS
8638WLANTL_McProcessMsg
8639(
8640 v_PVOID_t pvosGCtx,
8641 vos_msg_t* message
8642)
8643{
8644 WLANTL_CbType* pTLCb = NULL;
8645 tAddBAInd* ptAddBaInd = NULL;
8646 tDelBAInd* ptDelBaInd = NULL;
8647 tAddBARsp* ptAddBaRsp = NULL;
8648 vos_msg_t vosMessage;
8649 VOS_STATUS vosStatus;
8650 tpFlushACRsp FlushACRspPtr;
8651 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8652
8653 /*------------------------------------------------------------------------
8654 Sanity check
8655 ------------------------------------------------------------------------*/
8656 if ( NULL == message )
8657 {
8658 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8659 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8660 return VOS_STATUS_E_INVAL;
8661 }
8662
8663 /*------------------------------------------------------------------------
8664 Extract TL control block
8665 ------------------------------------------------------------------------*/
8666 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8667 if ( NULL == pTLCb )
8668 {
8669 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8670 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8671 return VOS_STATUS_E_FAULT;
8672 }
8673
8674 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8675 "WLAN TL:Received message: %d through main flow", message->type));
8676
8677 switch( message->type )
8678 {
8679 case WDA_TL_FLUSH_AC_RSP:
8680 // Extract the message from the message body
8681 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8682 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008683 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8684 {
8685 VOS_ASSERT(0);
8686 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8687 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8688 return VOS_STATUS_E_FAULT;
8689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008690
8691 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8692 "Received message: Flush complete received by TL"));
8693
8694 // Since we have the response back from HAL, just call the BAP client
8695 // registered call back from TL. There is only 1 possible
8696 // BAP client. So directly reference tlBAPClient
8697 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8698 FlushACRspPtr->ucSTAId,
8699 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8700
8701 // Free the PAL memory, we are done with it.
8702 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8703 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8704 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8705 break;
8706
8707 case WDA_HDD_ADDBA_REQ:
8708 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8709 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8710 ptAddBaInd->baSession.baSessionID,
8711 ptAddBaInd->baSession.STAID,
8712 ptAddBaInd->baSession.baTID,
8713 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8714 ptAddBaInd->baSession.winSize,
8715 ptAddBaInd->baSession.SSN);
8716 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8717
8718 if ( NULL == ptAddBaRsp )
8719 {
8720 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8721 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8722 VOS_ASSERT(0);
8723 return VOS_STATUS_E_NOMEM;
8724 }
8725
8726 if ( VOS_STATUS_SUCCESS == vosStatus )
8727 {
8728 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8729 "WLAN TL: Sending success indication to HAL for ADD BA"));
8730 /*Send success*/
8731 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8732 vosMessage.type = WDA_HDD_ADDBA_RSP;
8733 }
8734 else
8735 {
8736 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8737 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8738
8739 /*Send failure*/
8740 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8741 vosMessage.type = WDA_BA_FAIL_IND;
8742 }
8743
8744 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8745 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8746 /* This is default, reply win size has to be handled BA module, FIX THIS */
8747 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8748 vosMessage.bodyptr = ptAddBaRsp;
8749
8750 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8751 WLANTL_McFreeMsg (pvosGCtx, message);
8752 break;
8753 case WDA_DELETEBA_IND:
8754 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8755 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8756 ptDelBaInd->staIdx,
8757 ptDelBaInd->baTID);
8758
8759 if ( VOS_STATUS_SUCCESS != vosStatus )
8760 {
8761 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8762 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8763 ptDelBaInd->staIdx,
8764 ptDelBaInd->baTID,
8765 vosStatus));
8766 }
8767 WLANTL_McFreeMsg (pvosGCtx, message);
8768 break;
8769 default:
8770 /*no processing for now*/
8771 break;
8772 }
8773
8774 return VOS_STATUS_SUCCESS;
8775}/* WLANTL_ProcessMainMessage */
8776
8777/*==========================================================================
8778 FUNCTION WLANTL_McFreeMsg
8779
8780 DESCRIPTION
8781 Called by VOSS to free a given TL message on the Main thread when there
8782 are messages pending in the queue when the whole system is been reset.
8783 For now, TL does not allocate any body so this function shout translate
8784 into a NOOP
8785
8786 DEPENDENCIES
8787 The TL must be initialized before this function can be called.
8788
8789 PARAMETERS
8790
8791 IN
8792 pvosGCtx: pointer to the global vos context; a handle to TL's
8793 control block can be extracted from its context
8794 message: type and content of the message
8795
8796
8797 RETURN VALUE
8798 The result code associated with performing the operation
8799
8800 VOS_STATUS_SUCCESS: Everything is good :)
8801
8802 SIDE EFFECTS
8803
8804============================================================================*/
8805VOS_STATUS
8806WLANTL_McFreeMsg
8807(
8808 v_PVOID_t pvosGCtx,
8809 vos_msg_t* message
8810)
8811{
8812 WLANTL_CbType* pTLCb = NULL;
8813 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8814
8815 /*------------------------------------------------------------------------
8816 Sanity check
8817 ------------------------------------------------------------------------*/
8818 if ( NULL == message )
8819 {
8820 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8821 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
8822 return VOS_STATUS_E_INVAL;
8823 }
8824
8825 /*------------------------------------------------------------------------
8826 Extract TL control block
8827 ------------------------------------------------------------------------*/
8828 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8829 if ( NULL == pTLCb )
8830 {
8831 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8832 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
8833 return VOS_STATUS_E_FAULT;
8834 }
8835
8836 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8837 "WLAN TL:Received message: %d through main free", message->type));
8838
8839 switch( message->type )
8840 {
8841 case WDA_HDD_ADDBA_REQ:
8842 case WDA_DELETEBA_IND:
8843 /*vos free body pointer*/
8844 vos_mem_free(message->bodyptr);
8845 message->bodyptr = NULL;
8846 break;
8847 default:
8848 /*no processing for now*/
8849 break;
8850 }
8851
8852 return VOS_STATUS_SUCCESS;
8853}/*WLANTL_McFreeMsg*/
8854
8855/*==========================================================================
8856 FUNCTION WLANTL_TxProcessMsg
8857
8858 DESCRIPTION
8859 Called by VOSS when a message was serialized for TL through the
8860 tx thread/task.
8861
8862 DEPENDENCIES
8863 The TL must be initialized before this function can be called.
8864
8865 PARAMETERS
8866
8867 IN
8868 pvosGCtx: pointer to the global vos context; a handle to TL's
8869 control block can be extracted from its context
8870 message: type and content of the message
8871
8872
8873 RETURN VALUE
8874 The result code associated with performing the operation
8875
8876 VOS_STATUS_E_INVAL: invalid input parameters
8877 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8878 page fault
8879 VOS_STATUS_SUCCESS: Everything is good :)
8880
8881 Other values can be returned as a result of a function call, please check
8882 corresponding API for more info.
8883 SIDE EFFECTS
8884
8885============================================================================*/
8886VOS_STATUS
8887WLANTL_TxProcessMsg
8888(
8889 v_PVOID_t pvosGCtx,
8890 vos_msg_t* message
8891)
8892{
8893 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 void (*callbackRoutine) (void *callbackContext);
8895 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8897
8898 /*------------------------------------------------------------------------
8899 Sanity check
8900 ------------------------------------------------------------------------*/
8901 if ( NULL == message )
8902 {
8903 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8904 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
8905 return VOS_STATUS_E_INVAL;
8906 }
8907
8908 /*------------------------------------------------------------------------
8909 Process message
8910 ------------------------------------------------------------------------*/
8911 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8912 "WLAN TL:Received message: %d through tx flow", message->type));
8913
8914 switch( message->type )
8915 {
8916 case WLANTL_TX_SIG_SUSPEND:
8917 vosStatus = WLANTL_SuspendCB( pvosGCtx,
8918 (WLANTL_SuspendCBType)message->bodyptr,
8919 message->reserved);
8920 break;
8921 case WLANTL_TX_RES_NEEDED:
8922 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
8923 break;
Katya Nigam664f5032014-05-05 12:24:32 +05308924
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308926 WLANTL_ClearTxXmitPending(pvosGCtx);
8927 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 break;
8929
8930 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05308931 callbackContext = message->bodyptr;
8932 callbackRoutine = message->callback;
8933 if ( NULL != callbackRoutine )
8934 {
8935 callbackRoutine(callbackContext);
8936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008938
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308939 case WLANTL_TX_SNAPSHOT:
8940 /*Dumping TL State and then continuing to print
8941 the DXE Dump*/
8942 WLANTL_TxThreadDebugHandler(pvosGCtx);
8943 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
8944 break;
8945
Mihir Shetefd62d9d2014-08-06 15:08:21 +05308946 case WLANTL_TX_FATAL_ERROR:
8947 WLANTL_FatalErrorHandler(pvosGCtx);
8948 break;
8949
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 default:
8951 /*no processing for now*/
8952 break;
8953 }
8954
8955 return vosStatus;
8956}/* WLANTL_TxProcessMsg */
8957
8958/*==========================================================================
8959 FUNCTION WLANTL_McFreeMsg
8960
8961 DESCRIPTION
8962 Called by VOSS to free a given TL message on the Main thread when there
8963 are messages pending in the queue when the whole system is been reset.
8964 For now, TL does not allocate any body so this function shout translate
8965 into a NOOP
8966
8967 DEPENDENCIES
8968 The TL must be initialized before this function can be called.
8969
8970 PARAMETERS
8971
8972 IN
8973 pvosGCtx: pointer to the global vos context; a handle to TL's
8974 control block can be extracted from its context
8975 message: type and content of the message
8976
8977
8978 RETURN VALUE
8979 The result code associated with performing the operation
8980
8981 VOS_STATUS_SUCCESS: Everything is good :)
8982
8983 SIDE EFFECTS
8984
8985============================================================================*/
8986VOS_STATUS
8987WLANTL_TxFreeMsg
8988(
8989 v_PVOID_t pvosGCtx,
8990 vos_msg_t* message
8991)
8992{
8993 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8994
8995 /*Nothing to do for now!!!*/
8996 return VOS_STATUS_SUCCESS;
8997}/*WLANTL_TxFreeMsg*/
8998
Jeff Johnson295189b2012-06-20 16:38:30 -07008999/*==========================================================================
9000
9001 FUNCTION WLANTL_TxFCFrame
9002
9003 DESCRIPTION
9004 Internal utility function to send FC frame. Enable
9005 or disable LWM mode based on the information.
9006
9007 DEPENDENCIES
9008 TL must be initiailized before this function gets called.
9009 FW sends up special flow control frame.
9010
9011 PARAMETERS
9012
9013 IN
9014 pvosGCtx: pointer to the global vos context; a handle to TL's
9015 control block can be extracted from its context
9016
9017 RETURN VALUE
9018 The result code associated with performing the operation
9019
9020 VOS_STATUS_E_INVAL: Input pointers are NULL.
9021 VOS_STATUS_E_FAULT: Something is wrong.
9022 VOS_STATUS_SUCCESS: Everything is good.
9023
9024 SIDE EFFECTS
9025 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
9026 be released.
9027
9028============================================================================*/
9029VOS_STATUS
9030WLANTL_TxFCFrame
9031(
9032 v_PVOID_t pvosGCtx
9033)
9034{
9035#if 0
9036 WLANTL_CbType* pTLCb = NULL;
9037 VOS_STATUS vosStatus;
9038 tpHalFcTxBd pvFcTxBd = NULL;
9039 vos_pkt_t * pPacket = NULL;
9040 v_U8_t ucSTAId = 0;
9041 v_U8_t ucBitCheck = 1;
9042
9043 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009044 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009045
9046 /*------------------------------------------------------------------------
9047 Sanity check
9048 ------------------------------------------------------------------------*/
9049 if ( NULL == pvosGCtx )
9050 {
9051 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009052 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 return VOS_STATUS_E_INVAL;
9054 }
9055 /*------------------------------------------------------------------------
9056 Extract TL control block
9057 ------------------------------------------------------------------------*/
9058 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9059
9060 if (NULL == pTLCb)
9061 {
9062 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009063 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009064 return VOS_STATUS_E_INVAL;
9065 }
9066
9067 //Get one voss packet
9068 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
9069 VOS_FALSE, NULL, NULL );
9070
9071 if ( VOS_STATUS_SUCCESS != vosStatus )
9072 {
9073 return VOS_STATUS_E_INVAL;
9074 }
9075
9076 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
9077
9078 if( VOS_STATUS_SUCCESS != vosStatus )
9079 {
9080 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009081 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 vos_pkt_return_packet( pPacket );
9083 return VOS_STATUS_E_FAULT;
9084 }
9085
9086 //Generate most recent tlFCInfo. Most fields are correct.
9087 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
9088 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
9089 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
9090 {
9091 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
9092 {
9093 continue;
9094 }
9095
9096 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
9097 {
9098 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
9099 }
9100
9101 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
9102 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
9103 {
9104 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
9105
9106 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
9107
9108 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
9109 }
9110
9111 }
9112
9113 //request immediate feedback
9114 pTLCb->tlFCInfo.fcConfig |= 0x4;
9115
9116 //fill in BD to sent
9117 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
9118
9119 if( VOS_STATUS_SUCCESS != vosStatus )
9120 {
9121 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009122 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 vos_pkt_return_packet( pPacket );
9124 return VOS_STATUS_E_FAULT;
9125 }
9126
9127 if (NULL != pTLCb->vosTxFCBuf)
9128 {
9129 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009130 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
9132 }
9133
9134 pTLCb->vosTxFCBuf = pPacket;
9135
9136 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
9137 (v_PVOID_t)WLANTL_TxCompDefaultCb);
9138 vosStatus = WDA_DS_StartXmit(pvosGCtx);
9139
9140 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009141 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009142#endif
9143 return VOS_STATUS_SUCCESS;
9144}
9145
Jeff Johnson295189b2012-06-20 16:38:30 -07009146
9147/*==========================================================================
9148 FUNCTION WLANTL_GetTxResourcesCB
9149
9150 DESCRIPTION
9151 Processing function for Resource needed signal. A request will be issued
9152 to BAL to get more tx resources.
9153
9154 DEPENDENCIES
9155 The TL must be initialized before this function can be called.
9156
9157 PARAMETERS
9158
9159 IN
9160 pvosGCtx: pointer to the global vos context; a handle to TL's
9161 control block can be extracted from its context
9162
9163
9164 RETURN VALUE
9165 The result code associated with performing the operation
9166
9167 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9168 page fault
9169 VOS_STATUS_SUCCESS: Everything is good :)
9170
9171 Other values can be returned as a result of a function call, please check
9172 corresponding API for more info.
9173 SIDE EFFECTS
9174
9175============================================================================*/
9176VOS_STATUS
9177WLANTL_GetTxResourcesCB
9178(
9179 v_PVOID_t pvosGCtx
9180)
9181{
9182 WLANTL_CbType* pTLCb = NULL;
9183 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
9184 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9185 v_U8_t ucMgmt = 0;
9186 v_U8_t ucBAP = 0;
9187 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009188#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9189 tBssSystemRole systemRole;
9190 tpAniSirGlobal pMac;
9191#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9193 /*------------------------------------------------------------------------
9194 Extract TL control block
9195 ------------------------------------------------------------------------*/
9196 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9197 if ( NULL == pTLCb )
9198 {
9199 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9200 "WLAN TL:Invalid TL pointer from pvosGCtx on"
9201 " WLANTL_ProcessTxMessage"));
9202 return VOS_STATUS_E_FAULT;
9203 }
9204
9205 /*------------------------------------------------------------------------
9206 Get tx resources from BAL
9207 ------------------------------------------------------------------------*/
9208 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
9209
9210 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
9211 {
9212 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9213 "WLAN TL:TL failed to get resources from BAL, Err: %d",
9214 vosStatus));
9215 return vosStatus;
9216 }
9217
9218 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
9219 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
9220 changes should be done in BAL code of AMSS and WM */
9221 if (VOS_STATUS_E_RESOURCES == vosStatus)
9222 {
9223#ifdef VOLANS_PERF
9224 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
9225 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9226 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9227#else
9228 return VOS_STATUS_E_FAILURE;
9229#endif
9230 }
9231
9232 pTLCb->uResCount = uResCount;
9233
9234
Jeff Johnson295189b2012-06-20 16:38:30 -07009235#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9236 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9237 pTLCb->sendFCFrame ++;
9238 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9239 systemRole = wdaGetGlobalSystemRole(pMac);
9240 if (eSYSTEM_AP_ROLE == systemRole)
9241 {
9242 if (pTLCb->sendFCFrame % 16 == 0)
9243 {
9244 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9245 "Transmit FC"));
9246 WLANTL_TxFCFrame (pvosGCtx);
9247 }
9248 }
9249#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009250
9251 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9252 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9253 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9254 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9255 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9256
9257 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9258 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9259 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9260
9261 if (( 0 == pTLCb->ucTxSuspended ) &&
9262 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9263 {
9264 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9265 "Issuing Xmit start request to BAL for avail res SYNC"));
9266 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9267 }
9268 return vosStatus;
9269}/*WLANTL_GetTxResourcesCB*/
9270
9271/*==========================================================================
9272 Utility functions
9273 ==========================================================================*/
9274
9275/*==========================================================================
9276 FUNCTION WLANTL_Translate8023To80211Header
9277
9278 DESCRIPTION
9279 Inline function for translating and 802.11 header into an 802.3 header.
9280
9281 DEPENDENCIES
9282
9283
9284 PARAMETERS
9285
9286 IN
9287 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009288 IN/OUT
9289 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9290 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009291
9292 IN/OUT
9293 vosDataBuff: vos data buffer, will contain the new header on output
9294
9295 OUT
9296 pvosStatus: status of the operation
9297
9298 RETURN VALUE
9299
9300 VOS_STATUS_SUCCESS: Everything is good :)
9301
9302 Other error codes might be returned from the vos api used in the function
9303 please check those return values.
9304
9305 SIDE EFFECTS
9306
9307============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009308VOS_STATUS
9309WLANTL_Translate8023To80211Header
9310(
9311 vos_pkt_t* vosDataBuff,
9312 VOS_STATUS* pvosStatus,
9313 WLANTL_CbType* pTLCb,
9314 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009315 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009316 v_U8_t *ucWDSEnabled,
9317 v_U8_t *extraHeadSpace
9318)
Jeff Johnson295189b2012-06-20 16:38:30 -07009319{
9320 WLANTL_8023HeaderType w8023Header;
9321 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9322 VOS_STATUS vosStatus;
9323 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9324 v_U8_t ucHeaderSize = 0;
9325 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309326 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009328 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009329#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009330 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9331 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9332 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9333#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 *ucWDSEnabled = 0; // default WDS off.
9335 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9336 sizeof(w8023Header));
9337
9338 if ( VOS_STATUS_SUCCESS != vosStatus )
9339 {
9340 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9341 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9342 return vosStatus;
9343 }
9344
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009345 if( NULL == pucStaId )
9346 {
9347 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9348 "WLAN TL: Invalid pointer for StaId"));
9349 return VOS_STATUS_E_INVAL;
9350 }
9351 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309352 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9353
9354 if ( NULL == pClientSTA )
9355 {
9356 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9357 "WLAN TL:Client Memory was not allocated on %s", __func__));
9358 return VOS_STATUS_E_FAILURE;
9359 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009360
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009361#ifdef FEATURE_WLAN_TDLS
9362
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309363 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9364 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009365 {
9366 v_U8_t ucIndex = 0;
9367 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9368 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309369 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309370 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9371 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309372 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009373 (void*)w8023Header.vDA, 6) )
9374 {
9375 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9376 "WLAN TL: Got a TDLS station. Using that index"));
9377 ucStaId = ucIndex;
9378 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309379 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9380 if ( NULL == pClientSTA )
9381 {
9382 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9383 "WLAN TL:Client Memory was not allocated on %s", __func__));
9384 return VOS_STATUS_E_FAILURE;
9385 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009386 break;
9387 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009388 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009389 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009390#endif
9391
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009392#ifdef FEATURE_WLAN_ESE_UPLOAD
9393if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009394{
9395 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9396 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9397 {
9398 /*The SNAP and the protocol type are already in the data buffer.
9399 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9400 bIAPPTxwithLLC = VOS_TRUE;
9401 }
9402 else
9403 {
9404 bIAPPTxwithLLC = VOS_FALSE;
9405 }
9406}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009407#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009408
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009409 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009410#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009411 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009412#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009413 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 {
9415 /* Push the length */
9416 vosStatus = vos_pkt_push_head(vosDataBuff,
9417 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9418
9419 if ( VOS_STATUS_SUCCESS != vosStatus )
9420 {
9421 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9422 "WLAN TL: Packet push ether type fails on"
9423 " WLANTL_Translate8023To80211Header"));
9424 return vosStatus;
9425 }
9426
9427#ifdef BTAMP_TEST
9428 // The STA side will execute this, a hack to test BTAMP by using the
9429 // infra setup. On real BTAMP this will come from BAP itself.
9430 {
9431 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9432 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9433 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9434
9435 if ( VOS_STATUS_SUCCESS != vosStatus )
9436 {
9437 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9438 "WLAN TL: Packet push LLC header fails on"
9439 " WLANTL_Translate8023To80211Header"));
9440 return vosStatus;
9441 }
9442 }
9443#else
9444 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9445 sizeof(WLANTL_LLC_HEADER));
9446
9447 if ( VOS_STATUS_SUCCESS != vosStatus )
9448 {
9449 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9450 "WLAN TL: Packet push LLC header fails on"
9451 " WLANTL_Translate8023To80211Header"));
9452 return vosStatus;
9453 }
9454#endif
9455 }/*If add LLC is enabled*/
9456 else
9457 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009458#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009459 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009460#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9462 "WLAN TL: STA Client registered to not remove LLC"
9463 " WLANTL_Translate8023To80211Header"));
9464 }
9465
9466#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309467 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009468#endif
9469
9470 // Find the space required for the 802.11 header format
9471 // based on the frame control fields.
9472 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309473 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 {
9475 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9476 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309477 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 {
9479 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 }
9482
9483 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9484 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9485
9486 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9487 if ( NULL == ppvBDHeader )
9488 {
9489 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9490 "WLAN TL:VOSS packet corrupted "));
9491 *pvosStatus = VOS_STATUS_E_INVAL;
9492 return *pvosStatus;
9493 }
9494
Jeff Johnson295189b2012-06-20 16:38:30 -07009495
9496 // OK now we have the space. Fill the 80211 header
9497 /* Fill A2 */
9498 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9499 // only clear the required space.
9500 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9501 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9502
9503
9504#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309505 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9506 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009507#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309508 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9509 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009510#endif
9511 {
9512 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309513 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 }
9515
9516 pw80211Header->usDurationId = 0;
9517 pw80211Header->usSeqCtrl = 0;
9518
9519 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9520
9521
9522
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309523 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 {
9525 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9526
Ravi Joshid0699502013-07-08 15:48:47 -07009527 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
9529 }
9530 else
9531 {
9532 pw80211Header->wFrmCtrl.subType = 0;
9533
9534 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9535 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9536 // pw80211Header->usQosCtrl = 0;
9537 }
9538
9539
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309540 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 {
Ravi Joshid0699502013-07-08 15:48:47 -07009542 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 pw80211Header->wFrmCtrl.toDS = 0;
9544 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009545
9546 /*
9547 * If the frame is a multicast frame, then, the Address1
9548 * should be the destination address filled in the packet. Which is
9549 * the multicast address. Otherwise, set it to BSSID
9550 */
9551 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9552 {
9553 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9554 (v_MACADDR_t*)&w8023Header.vDA);
9555 }
9556 else
9557 {
9558 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9559 &pClientSTA->wSTADesc.vSTAMACAddress);
9560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309562 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 VOS_MAC_ADDR_SIZE);
9564 break;
9565
Ravi Joshid0699502013-07-08 15:48:47 -07009566 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 *ucWDSEnabled = 1; // WDS on.
9568 pw80211Header->wFrmCtrl.toDS = 1;
9569 pw80211Header->wFrmCtrl.fromDS = 1;
9570 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309571 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009573 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309575 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 /* fill the optional A4 header */
9577 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009578 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009580 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009581 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 break;
9583
Ravi Joshid0699502013-07-08 15:48:47 -07009584 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 *ucWDSEnabled = 0; // WDS off.
9586 pw80211Header->wFrmCtrl.toDS = 0;
9587 pw80211Header->wFrmCtrl.fromDS = 1;
9588 /*Copy the DA to A1*/
9589 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9590 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309591 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009593 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009594 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009595 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009596 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009598#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009599 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009600 pw80211Header->wFrmCtrl.toDS = 0;
9601 pw80211Header->wFrmCtrl.fromDS = 0;
9602 /*Fix me*/
9603 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309604 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009605 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309606 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009607 VOS_MAC_ADDR_SIZE);
9608 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009609 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009610 break;
9611#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009612 case WLAN_STA_INFRA:
9613 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 pw80211Header->wFrmCtrl.toDS = 1;
9615 pw80211Header->wFrmCtrl.fromDS = 0;
9616 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309617 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9619 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009620 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009621 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 break;
9623 }
9624 // OK now we have the space. Fill the 80211 header
9625 /* Fill A2 */
9626 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9627 return VOS_STATUS_SUCCESS;
9628}/*WLANTL_Translate8023To80211Header*/
9629
9630
9631/*=============================================================================
9632 BEGIN LOG FUNCTION !!! Remove me or clean me
9633=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009634#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009635
9636#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9637#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9638
9639static v_VOID_t WLANTL_DebugFrame
9640(
9641 v_PVOID_t dataPointer,
9642 v_U32_t dataSize
9643)
9644{
9645 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9646 v_U32_t numLines;
9647 v_U32_t numBytes;
9648 v_U32_t idx;
9649 v_U8_t *linePointer;
9650
9651 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9652 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9653 linePointer = (v_U8_t *)dataPointer;
9654
9655 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9656 for(idx = 0; idx < numLines; idx++)
9657 {
9658 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9659 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9660 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9661 "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",
9662 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9663 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9664 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9665 }
9666
9667 if(0 == numBytes)
9668 return;
9669
9670 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9671 memcpy(lineBuffer, linePointer, numBytes);
9672 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9673 {
9674 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9675 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9676 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9677 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9678 break;
9679 }
9680
9681 return;
9682}
9683#endif
9684
9685/*=============================================================================
9686 END LOG FUNCTION
9687=============================================================================*/
9688
9689/*==========================================================================
9690 FUNCTION WLANTL_Translate80211To8023Header
9691
9692 DESCRIPTION
9693 Inline function for translating and 802.11 header into an 802.3 header.
9694
9695 DEPENDENCIES
9696
9697
9698 PARAMETERS
9699
9700 IN
9701 pTLCb: TL control block
9702 ucStaId: station ID
9703 ucHeaderLen: Length of the header from BD
9704 ucActualHLen: Length of header including padding or any other trailers
9705
9706 IN/OUT
9707 vosDataBuff: vos data buffer, will contain the new header on output
9708
9709 OUT
9710 pvosStatus: status of the operation
9711
9712 RETURN VALUE
9713
9714 The result code associated with performing the operation
9715 VOS_STATUS_SUCCESS: Everything is good :)
9716
9717 SIDE EFFECTS
9718
9719============================================================================*/
9720VOS_STATUS
9721WLANTL_Translate80211To8023Header
9722(
9723 vos_pkt_t* vosDataBuff,
9724 VOS_STATUS* pvosStatus,
9725 v_U16_t usActualHLen,
9726 v_U8_t ucHeaderLen,
9727 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009728 v_U8_t ucSTAId,
9729 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009730)
9731{
9732 WLANTL_8023HeaderType w8023Header;
9733 WLANTL_80211HeaderType w80211Header;
9734 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9735 VOS_STATUS vosStatus;
9736 v_U16_t usDataStartOffset = 0;
9737 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9738
9739 if ( sizeof(w80211Header) < ucHeaderLen )
9740 {
9741 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9742 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9743 sizeof(w80211Header), ucHeaderLen));
9744 ucHeaderLen = sizeof(w80211Header);
9745 }
9746
9747 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9748 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9749 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9750
9751 if ( VOS_STATUS_SUCCESS != vosStatus )
9752 {
9753 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9754 "WLAN TL: Failed to pop 80211 header from packet %d",
9755 vosStatus));
9756
9757 return vosStatus;
9758 }
9759
9760 switch ( w80211Header.wFrmCtrl.fromDS )
9761 {
9762 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 if ( w80211Header.wFrmCtrl.toDS )
9764 {
9765 //SoftAP AP mode
9766 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9767 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9768 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009769 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 w8023Header.vDA, w8023Header.vSA));
9771 }
9772 else
9773 {
9774 /* IBSS */
9775 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9776 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 break;
9779 case 1:
9780 if ( w80211Header.wFrmCtrl.toDS )
9781 {
9782 /* BT-AMP case */
9783 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9784 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9785 }
9786 else
9787 { /* Infra */
9788 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9789 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9790 }
9791 break;
9792 }
9793
9794 if( usActualHLen > ucHeaderLen )
9795 {
9796 usDataStartOffset = usActualHLen - ucHeaderLen;
9797 }
9798
9799 if ( 0 < usDataStartOffset )
9800 {
9801 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
9802
9803 if ( VOS_STATUS_SUCCESS != vosStatus )
9804 {
9805 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9806 "WLAN TL: Failed to trim header from packet %d",
9807 vosStatus));
9808 return vosStatus;
9809 }
9810 }
9811
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309812 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9813 {
9814 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9815 "WLAN TL:Client Memory was not allocated on %s", __func__));
9816 return VOS_STATUS_E_FAILURE;
9817 }
9818
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009819 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009820#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009821 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009822#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009823 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 {
9825 // Extract the LLC header
9826 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
9827 WLANTL_LLC_HEADER_LEN);
9828
9829 if ( VOS_STATUS_SUCCESS != vosStatus )
9830 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05309831 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 "WLAN TL: Failed to pop LLC header from packet %d",
9833 vosStatus));
9834
9835 return vosStatus;
9836 }
9837
9838 //Extract the length
9839 vos_mem_copy(&w8023Header.usLenType,
9840 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
9841 sizeof(w8023Header.usLenType) );
9842 }
9843 else
9844 {
9845 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
9846 &w8023Header.usLenType);
9847
9848 if ( VOS_STATUS_SUCCESS != vosStatus )
9849 {
9850 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9851 "WLAN TL: Failed to get packet length %d",
9852 vosStatus));
9853
9854 return vosStatus;
9855 }
9856
9857 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9858 "WLAN TL: BTAMP len (ethertype) fld = %d",
9859 w8023Header.usLenType));
9860 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
9861 }
9862
9863 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
9864
9865#ifdef BTAMP_TEST
9866 {
9867 // AP side will execute this.
9868 v_U8_t *temp_w8023Header = NULL;
9869 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
9870 &temp_w8023Header, sizeof(w8023Header) );
9871 }
9872#endif
9873#if 0 /*TL_DEBUG*/
9874 vos_pkt_get_packet_length(vosDataBuff, &usLen);
9875 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
9876
9877 WLANTL_DebugFrame(aucData, usLen);
9878
9879 vos_pkt_push_head(vosDataBuff, aucData, usLen);
9880
9881#endif
9882
9883 *pvosStatus = VOS_STATUS_SUCCESS;
9884
9885 return VOS_STATUS_SUCCESS;
9886}/*WLANTL_Translate80211To8023Header*/
9887
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009888/*==========================================================================
9889 FUNCTION WLANTL_FindFrameTypeBcMcUc
9890
9891 DESCRIPTION
9892 Utility function to find whether received frame is broadcast, multicast
9893 or unicast.
9894
9895 DEPENDENCIES
9896 The STA must be registered with TL before this function can be called.
9897
9898 PARAMETERS
9899
9900 IN
9901 pTLCb: pointer to the TL's control block
9902 ucSTAId: identifier of the station being processed
9903 vosDataBuff: pointer to the vos buffer
9904
9905 IN/OUT
9906 pucBcMcUc: pointer to buffer, will contain frame type on return
9907
9908 RETURN VALUE
9909 The result code associated with performing the operation
9910
9911 VOS_STATUS_E_INVAL: invalid input parameters
9912 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
9913 VOS_STATUS_SUCCESS: success
9914
9915 SIDE EFFECTS
9916 None.
9917============================================================================*/
9918VOS_STATUS
9919WLANTL_FindFrameTypeBcMcUc
9920(
9921 WLANTL_CbType *pTLCb,
9922 v_U8_t ucSTAId,
9923 vos_pkt_t *vosDataBuff,
9924 v_U8_t *pucBcMcUc
9925)
9926{
9927 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9928 v_PVOID_t aucBDHeader;
9929 v_PVOID_t pvPeekData;
9930 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9931
9932 /*------------------------------------------------------------------------
9933 Sanity check
9934 ------------------------------------------------------------------------*/
9935 if ((NULL == pTLCb) ||
9936 (NULL == vosDataBuff) ||
9937 (NULL == pucBcMcUc))
9938 {
9939 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9940 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
9941 return VOS_STATUS_E_INVAL;
9942 }
9943
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309944 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
9945 {
9946 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9947 "WLAN TL:Client Memory was not allocated on %s", __func__));
9948 return VOS_STATUS_E_FAILURE;
9949 }
9950
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009951 /*------------------------------------------------------------------------
9952 Extract BD header and check if valid
9953 ------------------------------------------------------------------------*/
9954 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
9955
9956 if (NULL == aucBDHeader)
9957 {
9958 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9959 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
9960 VOS_ASSERT(0);
9961 return VOS_STATUS_E_BADMSG;
9962 }
9963
9964 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309965 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08009966 {
9967 /* Its an 802.11 frame, extract MAC address 1 */
9968 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9969 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
9970 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
9971 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9972 }
9973 else
9974 {
9975 /* Its an 802.3 frame, extract Destination MAC address */
9976 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9977 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
9978 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
9979 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
9980 }
9981
9982 if (VOS_STATUS_SUCCESS != vosStatus)
9983 {
9984 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9985 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
9986 return vosStatus;
9987 }
9988
9989 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
9990 {
9991 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
9992 }
9993 else
9994 {
9995 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
9996 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
9997 else
9998 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
9999 }
10000
10001 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10002 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
10003 ((tANI_U8 *)pvPeekData)[0]));
10004
10005 return VOS_STATUS_SUCCESS;
10006}
10007
Jeff Johnson295189b2012-06-20 16:38:30 -070010008#if 0
10009#ifdef WLAN_PERF
10010/*==========================================================================
10011 FUNCTION WLANTL_FastHwFwdDataFrame
10012
10013 DESCRIPTION
10014 Fast path function to quickly forward a data frame if HAL determines BD
10015 signature computed here matches the signature inside current VOSS packet.
10016 If there is a match, HAL and TL fills in the swapped packet length into
10017 BD header and DxE header, respectively. Otherwise, packet goes back to
10018 normal (slow) path and a new BD signature would be tagged into BD in this
10019 VOSS packet later by the WLANHAL_FillTxBd() function.
10020
10021 DEPENDENCIES
10022
10023 PARAMETERS
10024
10025 IN
10026 pvosGCtx VOS context
10027 vosDataBuff Ptr to VOSS packet
10028 pMetaInfo For getting frame's TID
10029 pStaInfo For checking STA type
10030
10031 OUT
10032 pvosStatus returned status
10033 puFastFwdOK Flag to indicate whether frame could be fast forwarded
10034
10035 RETURN VALUE
10036 No return.
10037
10038 SIDE EFFECTS
10039
10040============================================================================*/
10041static void
10042WLANTL_FastHwFwdDataFrame
10043(
10044 v_PVOID_t pvosGCtx,
10045 vos_pkt_t* vosDataBuff,
10046 VOS_STATUS* pvosStatus,
10047 v_U32_t* puFastFwdOK,
10048 WLANTL_MetaInfoType* pMetaInfo,
10049 WLAN_STADescType* pStaInfo
10050
10051)
10052{
10053 v_PVOID_t pvPeekData;
10054 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
10055 v_U8_t ucIsUnicast;
10056 WLANBAL_sDXEHeaderType *pDxEHeader;
10057 v_PVOID_t pvBDHeader;
10058 v_PVOID_t pucBuffPtr;
10059 v_U16_t usPktLen;
10060
10061 /*-----------------------------------------------------------------------
10062 Extract packet length
10063 -----------------------------------------------------------------------*/
10064
10065 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
10066
10067 /*-----------------------------------------------------------------------
10068 Extract MAC address
10069 -----------------------------------------------------------------------*/
10070 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
10071 WLANTL_MAC_ADDR_ALIGN(0),
10072 (v_PVOID_t)&pvPeekData,
10073 VOS_MAC_ADDR_SIZE );
10074
10075 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10076 {
10077 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10078 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10079 *pvosStatus));
10080 *pvosStatus = VOS_STATUS_E_INVAL;
10081 return;
10082 }
10083
10084 /*-----------------------------------------------------------------------
10085 Reserve head room for DxE header, BD, and WLAN header
10086 -----------------------------------------------------------------------*/
10087
10088 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
10089 ucDxEBDWLANHeaderLen );
10090 if ( NULL == pucBuffPtr )
10091 {
10092 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10093 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
10094 *pvosStatus = VOS_STATUS_E_INVAL;
10095 return;
10096 }
10097 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
10098 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
10099
10100 /* UMA Tx acceleration is enabled.
10101 * UMA would help convert frames to 802.11, fill partial BD fields and
10102 * construct LLC header. To further accelerate this kind of frames,
10103 * HAL would attempt to reuse the BD descriptor if the BD signature
10104 * matches to the saved BD descriptor.
10105 */
10106 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
10107 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
10108 else
10109 ucIsUnicast = 1;
10110
10111 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
10112
10113 /* Can't be fast forwarded. Trim the VOS head back to original location. */
10114 if(! *puFastFwdOK){
10115 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
10116 }else{
10117 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
10118 */
10119 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
10120 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
10121 (v_PVOID_t)uPacketSize);
10122 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
10123 }
10124 *pvosStatus = VOS_STATUS_SUCCESS;
10125 return;
10126}
10127#endif /*WLAN_PERF*/
10128#endif
10129
10130#if 0
10131/*==========================================================================
10132 FUNCTION WLANTL_PrepareBDHeader
10133
10134 DESCRIPTION
10135 Inline function for preparing BD header before HAL processing.
10136
10137 DEPENDENCIES
10138 Just notify HAL that suspend in TL is complete.
10139
10140 PARAMETERS
10141
10142 IN
10143 vosDataBuff: vos data buffer
10144 ucDisableFrmXtl: is frame xtl disabled
10145
10146 OUT
10147 ppvBDHeader: it will contain the BD header
10148 pvDestMacAdddr: it will contain the destination MAC address
10149 pvosStatus: status of the combined processing
10150 pusPktLen: packet len.
10151
10152 RETURN VALUE
10153 No return.
10154
10155 SIDE EFFECTS
10156
10157============================================================================*/
10158void
10159WLANTL_PrepareBDHeader
10160(
10161 vos_pkt_t* vosDataBuff,
10162 v_PVOID_t* ppvBDHeader,
10163 v_MACADDR_t* pvDestMacAdddr,
10164 v_U8_t ucDisableFrmXtl,
10165 VOS_STATUS* pvosStatus,
10166 v_U16_t* pusPktLen,
10167 v_U8_t ucQosEnabled,
10168 v_U8_t ucWDSEnabled,
10169 v_U8_t extraHeadSpace
10170)
10171{
10172 v_U8_t ucHeaderOffset;
10173 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
10175
10176 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10177 /*-------------------------------------------------------------------------
10178 Get header pointer from VOSS
10179 !!! make sure reserve head zeros out the memory
10180 -------------------------------------------------------------------------*/
10181 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
10182
10183 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
10184 {
10185 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10186 "WLAN TL: Length of the packet smaller than expected network"
10187 " header %d", *pusPktLen ));
10188
10189 *pvosStatus = VOS_STATUS_E_INVAL;
10190 return;
10191 }
10192
10193 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
10194 ucBDHeaderLen );
10195 if ( NULL == *ppvBDHeader )
10196 {
10197 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10198 "WLAN TL:VOSS packet corrupted on Attach BD header"));
10199 *pvosStatus = VOS_STATUS_E_INVAL;
10200 return;
10201 }
10202
10203 /*-----------------------------------------------------------------------
10204 Extract MAC address
10205 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 {
10207 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
10208 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
10209 ucBDHeaderLen +
10210 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
10211 (v_PVOID_t)pvDestMacAdddr,
10212 &usMacAddrSize );
10213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10215 {
10216 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10217 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10218 *pvosStatus));
10219 }
10220 else
10221 {
10222 /*---------------------------------------------------------------------
10223 Fill MPDU info fields:
10224 - MPDU data start offset
10225 - MPDU header start offset
10226 - MPDU header length
10227 - MPDU length - this is a 16b field - needs swapping
10228 --------------------------------------------------------------------*/
10229 ucHeaderOffset = ucBDHeaderLen;
10230 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10231
10232 if ( 0 != ucDisableFrmXtl )
10233 {
10234 if ( 0 != ucQosEnabled )
10235 {
10236 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10237 }
10238
10239 // Similar to Qos we need something for WDS format !
10240 if ( ucWDSEnabled != 0 )
10241 {
10242 // If we have frame translation enabled
10243 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10244 }
10245 if ( extraHeadSpace != 0 )
10246 {
10247 // Decrease the packet length with the extra padding after the header
10248 *pusPktLen = *pusPktLen - extraHeadSpace;
10249 }
10250 }
10251
10252 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10253 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10254 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10255 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10256 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10257
10258 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10259 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10260 ucHeaderLen, ucHeaderOffset,
10261 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10262 *pusPktLen, extraHeadSpace));
10263 }/* if peek MAC success*/
10264
10265}/* WLANTL_PrepareBDHeader */
10266#endif
10267
Jeff Johnson295189b2012-06-20 16:38:30 -070010268//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10269/*==========================================================================
10270 FUNCTION WLAN_TLGetNextTxIds
10271
10272 DESCRIPTION
10273 Gets the next station and next AC in the list that should be served by the TL.
10274
10275 Multiple Station Scheduling and TL queue management.
10276
10277 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10278 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10279 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10280 or not.
10281
10282 Stations are served in a round-robin fashion from highest priority to lowest priority.
10283 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10284 the traffic of different prioirty. As such, stations can not provide low priority packets if
10285 high priority packets are all served.
10286
10287 DEPENDENCIES
10288
10289 PARAMETERS
10290
10291 IN
10292 pvosGCtx: pointer to the global vos context; a handle to TL's
10293 control block can be extracted from its context
10294
10295 OUT
10296 pucSTAId: Station ID
10297
10298 RETURN VALUE
10299 The result code associated with performing the operation
10300
10301 VOS_STATUS_SUCCESS: Everything is good
10302
10303 SIDE EFFECTS
10304
10305 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10306 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10307 When existing from the function, these three fields are changed accordingly.
10308
10309============================================================================*/
10310VOS_STATUS
10311WLAN_TLAPGetNextTxIds
10312(
10313 v_PVOID_t pvosGCtx,
10314 v_U8_t* pucSTAId
10315)
10316{
10317 WLANTL_CbType* pTLCb;
10318 v_U8_t ucACFilter = 1;
10319 v_U8_t ucNextSTA ;
10320 v_BOOL_t isServed = TRUE; //current round has find a packet or not
10321 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
10322 v_U8_t uFlowMask; // TX FlowMask from WDA
10323 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010324 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 /*------------------------------------------------------------------------
10326 Extract TL control block
10327 ------------------------------------------------------------------------*/
10328 //ENTER();
10329
10330 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10331 if ( NULL == pTLCb )
10332 {
10333 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10334 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10335 return VOS_STATUS_E_FAULT;
10336 }
10337
10338 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10339 {
10340 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10341 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10342 return VOS_STATUS_E_FAULT;
10343 }
10344
10345 ucNextSTA = pTLCb->ucCurrentSTA;
10346
10347 ++ucNextSTA;
10348
10349 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10350 {
10351 //one round is done.
10352 ucNextSTA = 0;
10353 pTLCb->ucCurLeftWeight--;
10354 isServed = FALSE;
10355 if ( 0 == pTLCb->ucCurLeftWeight )
10356 {
10357 //current prioirty is done
10358 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10359 {
10360 //end of current VO, VI, BE, BK loop. Reset priority.
10361 pTLCb->uCurServedAC = WLANTL_AC_VO;
10362 }
10363 else
10364 {
10365 pTLCb->uCurServedAC --;
10366 }
10367
10368 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10369
10370 } // (0 == pTLCb->ucCurLeftWeight)
10371 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10372
10373 //decide how many loops to go. if current loop is partial, do one extra to make sure
10374 //we cover every station
10375 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10376 {
10377 ucACLoopNum ++; // now is 5 loops
10378 }
10379
10380 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10381 all have previous values.*/
10382 for (; ucACLoopNum > 0; ucACLoopNum--)
10383 {
10384
10385 ucACFilter = 1 << pTLCb->uCurServedAC;
10386
10387 // pTLCb->ucCurLeftWeight keeps previous results.
10388 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
10389 {
10390
10391 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10392 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010393 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10394 {
10395 continue;
10396 }
10397 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010398
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010399 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10400 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010401 (0 == (ucACMask & ucACFilter)) )
10402
10403 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010404 //current station does not exist or have any packet to serve.
10405 continue;
10406 }
10407
10408 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10409 {
10410 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10411 "%s Sta %d not in auth state so skipping it.",
10412 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 continue;
10414 }
10415
10416 //go to next station if current station can't send due to flow control
10417 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10418 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10419 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010420 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10421 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10422 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010423 )
10424 {
10425 continue;
10426 }
10427
10428
10429 // Find a station. Weight is updated already.
10430 *pucSTAId = ucNextSTA;
10431 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010432 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010433
10434 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10435 " TL serve one station AC: %d W: %d StaId: %d",
10436 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10437
10438 return VOS_STATUS_SUCCESS;
10439 } //STA loop
10440
10441 ucNextSTA = 0;
10442 if ( FALSE == isServed )
10443 {
10444 //current loop finds no packet.no need to repeat for the same priority
10445 break;
10446 }
10447 //current loop is partial loop. go for one more loop.
10448 isServed = FALSE;
10449
10450 } //Weight loop
10451
10452 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10453 {
10454 pTLCb->uCurServedAC = WLANTL_AC_VO;
10455 }
10456 else
10457 {
10458 pTLCb->uCurServedAC--;
10459 }
10460 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10461
10462 }// AC loop
10463
10464 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010465 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010466
10467 pTLCb->uCurServedAC = WLANTL_AC_BK;
10468 pTLCb->ucCurLeftWeight = 1;
10469 //invalid number will be captured by caller
10470 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10471
10472 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 return VOS_STATUS_E_FAULT;
10474}
10475
10476
10477/*==========================================================================
10478 FUNCTION WLAN_TLGetNextTxIds
10479
10480 DESCRIPTION
10481 Gets the next station and next AC in the list
10482
10483 DEPENDENCIES
10484
10485 PARAMETERS
10486
10487 IN
10488 pvosGCtx: pointer to the global vos context; a handle to TL's
10489 control block can be extracted from its context
10490
10491 OUT
10492 pucSTAId: Station ID
10493
10494
10495 RETURN VALUE
10496 The result code associated with performing the operation
10497
10498 VOS_STATUS_SUCCESS: Everything is good :)
10499
10500 SIDE EFFECTS
10501
10502============================================================================*/
10503VOS_STATUS
10504WLAN_TLGetNextTxIds
10505(
10506 v_PVOID_t pvosGCtx,
10507 v_U8_t* pucSTAId
10508)
10509{
10510 WLANTL_CbType* pTLCb;
10511 v_U8_t ucNextAC;
10512 v_U8_t ucNextSTA;
10513 v_U8_t ucCount;
10514 v_U8_t uFlowMask; // TX FlowMask from WDA
10515 v_U8_t ucACMask = 0;
10516 v_U8_t i = 0;
10517
10518 tBssSystemRole systemRole; //RG HACK to be removed
10519 tpAniSirGlobal pMac;
10520
10521 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10522 if ( NULL == pMac )
10523 {
10524 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010525 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 return VOS_STATUS_E_FAULT;
10527 }
10528
10529 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010530
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 /*------------------------------------------------------------------------
10532 Extract TL control block
10533 ------------------------------------------------------------------------*/
10534 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10535 if ( NULL == pTLCb )
10536 {
10537 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10538 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10539 return VOS_STATUS_E_FAULT;
10540 }
10541
Sunil Ravid5406f22013-01-22 00:18:31 -080010542#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053010543 if ((eSYSTEM_AP_ROLE == systemRole) ||
10544 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080010545#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053010546 if ((eSYSTEM_AP_ROLE == systemRole) ||
10547 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080010548#endif
10549 {
10550 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10551 }
10552
10553
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10555 {
10556 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10557 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10558 return VOS_STATUS_E_FAULT;
10559 }
10560
10561 /*STA id - no priority yet implemented */
10562 /*-----------------------------------------------------------------------
10563 Choose the next STA for tx - for now go in a round robin fashion
10564 through all the stations that have pending packets
10565 -------------------------------------------------------------------------*/
10566 ucNextSTA = pTLCb->ucCurrentSTA;
10567
10568 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10569 for ( ucCount = 0;
10570 ucCount < WLAN_MAX_STA_COUNT;
10571 ucCount++ )
10572 {
10573 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010574 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10575 {
10576 continue;
10577 }
10578 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10579 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010581 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10582 {
10583 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10584 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10585 pTLCb->ucCurrentSTA = ucNextSTA;
10586 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010587 }
10588 else
10589 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010590 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10591 "%s Sta %d is not in auth state, skipping this sta.",
10592 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010593 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 }
10595 }
10596
10597 *pucSTAId = pTLCb->ucCurrentSTA;
10598
10599 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10600 {
10601 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10602 "WLAN TL:No station registered with TL at this point"));
10603
10604 return VOS_STATUS_E_FAULT;
10605
10606 }
10607
10608 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010609 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010610
10611 if ( 0 == ucACMask )
10612 {
10613 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10614 "WLAN TL: Mask 0 "
10615 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10616
10617 /*setting STA id to invalid if mask is 0*/
10618 *pucSTAId = WLAN_MAX_STA_COUNT;
10619
10620 return VOS_STATUS_E_FAULT;
10621 }
10622
10623 /*-----------------------------------------------------------------------
10624 AC is updated whenever a packet is fetched from HDD -> the current
10625 weight of such an AC cannot be 0 -> in this case TL is expected to
10626 exit this function at this point during the main Tx loop
10627 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010628 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 {
10630 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10631 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010632 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10633 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 return VOS_STATUS_SUCCESS;
10635 }
10636
10637 /*-----------------------------------------------------------------------
10638 Choose highest priority AC - !!! optimize me
10639 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010640 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10642 "Next AC: %d", ucNextAC));
10643
10644 while ( 0 != ucACMask )
10645 {
10646 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10647 " AC Mask: %d Next: %d Res : %d",
10648 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10649
10650 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10651 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010652 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010654 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010655 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10656
10657 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10658 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010659 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10660 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 break;
10662 }
10663
10664 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10665
10666 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10667 "Next AC %d", ucNextAC));
10668
10669 }
10670
10671 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10672 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010673 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10674 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010675
10676 return VOS_STATUS_SUCCESS;
10677}/* WLAN_TLGetNextTxIds */
10678
Jeff Johnson295189b2012-06-20 16:38:30 -070010679
10680
10681/*==========================================================================
10682 DEFAULT HANDLERS: Registered at initialization with TL
10683 ==========================================================================*/
10684
10685/*==========================================================================
10686
10687 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10688
10689 DESCRIPTION
10690 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10691 called it means there is no registered rx cb pointer for Mgmt Frm.
10692
10693 DEPENDENCIES
10694
10695 PARAMETERS
10696 Not used.
10697
10698 RETURN VALUE
10699
10700 VOS_STATUS_E_FAILURE: Always FAILURE.
10701
10702============================================================================*/
10703VOS_STATUS
10704WLANTL_MgmtFrmRxDefaultCb
10705(
10706 v_PVOID_t pvosGCtx,
10707 v_PVOID_t vosBuff
10708)
10709{
10710 if ( NULL != vosBuff )
10711 {
10712 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10713 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10714 /* Drop packet */
10715 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10716 }
10717
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10719 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010720
10721 return VOS_STATUS_E_FAILURE;
10722}/*WLANTL_MgmtFrmRxDefaultCb*/
10723
10724/*==========================================================================
10725
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010726 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070010727
10728 DESCRIPTION
10729 Default BAP rx callback: asserts all the time. If this function gets
10730 called it means there is no registered rx cb pointer for BAP.
10731
10732 DEPENDENCIES
10733
10734 PARAMETERS
10735 Not used.
10736
10737 RETURN VALUE
10738
10739 VOS_STATUS_E_FAILURE: Always FAILURE.
10740
10741============================================================================*/
10742VOS_STATUS
10743WLANTL_BAPRxDefaultCb
10744(
10745 v_PVOID_t pvosGCtx,
10746 vos_pkt_t* vosDataBuff,
10747 WLANTL_BAPFrameEnumType frameType
10748)
10749{
10750 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10751 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10752#ifndef BTAMP_TEST
10753 VOS_ASSERT(0);
10754#endif
10755 return VOS_STATUS_E_FAILURE;
10756}/*WLANTL_MgmtFrmRxDefaultCb*/
10757
10758/*==========================================================================
10759
10760 FUNCTION WLANTL_STARxDefaultCb
10761
10762 DESCRIPTION
10763 Default STA rx callback: asserts all the time. If this function gets
10764 called it means there is no registered rx cb pointer for station.
10765 (Mem corruption most likely, it should never happen)
10766
10767 DEPENDENCIES
10768
10769 PARAMETERS
10770 Not used.
10771
10772 RETURN VALUE
10773
10774 VOS_STATUS_E_FAILURE: Always FAILURE.
10775
10776============================================================================*/
10777VOS_STATUS
10778WLANTL_STARxDefaultCb
10779(
10780 v_PVOID_t pvosGCtx,
10781 vos_pkt_t* vosDataBuff,
10782 v_U8_t ucSTAId,
10783 WLANTL_RxMetaInfoType* pRxMetaInfo
10784)
10785{
10786 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10787 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10788 ucSTAId));
10789 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010790 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010791}/*WLANTL_MgmtFrmRxDefaultCb*/
10792
10793
10794/*==========================================================================
10795
10796 FUNCTION WLANTL_STAFetchPktDefaultCb
10797
10798 DESCRIPTION
10799 Default fetch callback: asserts all the time. If this function gets
10800 called it means there is no registered fetch cb pointer for station.
10801 (Mem corruption most likely, it should never happen)
10802
10803 DEPENDENCIES
10804
10805 PARAMETERS
10806 Not used.
10807
10808 RETURN VALUE
10809
10810 VOS_STATUS_E_FAILURE: Always FAILURE.
10811
10812============================================================================*/
10813VOS_STATUS
10814WLANTL_STAFetchPktDefaultCb
10815(
10816 v_PVOID_t pvosGCtx,
10817 v_U8_t* pucSTAId,
10818 WLANTL_ACEnumType ucAC,
10819 vos_pkt_t** vosDataBuff,
10820 WLANTL_MetaInfoType* tlMetaInfo
10821)
10822{
10823 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10824 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
10825 VOS_ASSERT(0);
10826 return VOS_STATUS_E_FAILURE;
10827}/*WLANTL_MgmtFrmRxDefaultCb*/
10828
10829/*==========================================================================
10830
10831 FUNCTION WLANTL_TxCompDefaultCb
10832
10833 DESCRIPTION
10834 Default tx complete handler. It will release the completed pkt to
10835 prevent memory leaks.
10836
10837 PARAMETERS
10838
10839 IN
10840 pvosGCtx: pointer to the global vos context; a handle to
10841 TL/HAL/PE/BAP/HDD control block can be extracted from
10842 its context
10843 vosDataBuff: pointer to the VOSS data buffer that was transmitted
10844 wTxSTAtus: status of the transmission
10845
10846
10847 RETURN VALUE
10848 The result code associated with performing the operation; please
10849 check vos_pkt_return_packet for possible error codes.
10850
10851 Please check vos_pkt_return_packet API for possible return values.
10852
10853============================================================================*/
10854VOS_STATUS
10855WLANTL_TxCompDefaultCb
10856(
10857 v_PVOID_t pvosGCtx,
10858 vos_pkt_t* vosDataBuff,
10859 VOS_STATUS wTxSTAtus
10860)
10861{
10862 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10863 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
10864 return vos_pkt_return_packet(vosDataBuff);
10865}/*WLANTL_TxCompDefaultCb*/
10866
10867
10868/*==========================================================================
10869 Cleanup functions
10870 ==========================================================================*/
10871
10872/*==========================================================================
10873
10874 FUNCTION WLANTL_CleanCB
10875
10876 DESCRIPTION
10877 Cleans TL control block
10878
10879 DEPENDENCIES
10880
10881 PARAMETERS
10882
10883 IN
10884 pTLCb: pointer to TL's control block
10885 ucEmpty: set if TL has to clean up the queues and release pedning pkts
10886
10887 RETURN VALUE
10888 The result code associated with performing the operation
10889
10890 VOS_STATUS_E_INVAL: invalid input parameters
10891 VOS_STATUS_SUCCESS: Everything is good :)
10892
10893 SIDE EFFECTS
10894
10895============================================================================*/
10896VOS_STATUS
10897WLANTL_CleanCB
10898(
10899 WLANTL_CbType* pTLCb,
10900 v_U8_t ucEmpty
10901)
10902{
10903 v_U8_t ucIndex;
10904 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10905
10906 /*-------------------------------------------------------------------------
10907 Sanity check
10908 -------------------------------------------------------------------------*/
10909 if ( NULL == pTLCb )
10910 {
10911 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10912 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
10913 return VOS_STATUS_E_INVAL;
10914 }
10915
10916 /* number of packets sent to BAL waiting for tx complete confirmation */
10917 pTLCb->usPendingTxCompleteCount = 0;
10918
10919 /* global suspend flag */
10920 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
10921
10922 /* resource flag */
10923 pTLCb->uResCount = 0;
10924
10925
10926 /*-------------------------------------------------------------------------
10927 Client stations
10928 -------------------------------------------------------------------------*/
10929 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
10930 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010931 if(NULL != pTLCb->atlSTAClients[ucIndex])
10932 {
10933 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
10934 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 }
10936
10937 /*-------------------------------------------------------------------------
10938 Management Frame client
10939 -------------------------------------------------------------------------*/
10940 pTLCb->tlMgmtFrmClient.ucExists = 0;
10941
10942 if ( ( 0 != ucEmpty) &&
10943 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
10944 {
10945 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
10946 }
10947
10948 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
10949
10950 /* set to a default cb in order to prevent constant checking for NULL */
10951 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
10952
10953 /*-------------------------------------------------------------------------
10954 BT AMP client
10955 -------------------------------------------------------------------------*/
10956 pTLCb->tlBAPClient.ucExists = 0;
10957
10958 if (( 0 != ucEmpty) &&
10959 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
10960 {
10961 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
10962 }
10963
10964 if (( 0 != ucEmpty) &&
10965 ( NULL != pTLCb->vosDummyBuf ))
10966 {
10967 vos_pkt_return_packet(pTLCb->vosDummyBuf);
10968 }
10969
10970 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
10971
10972 pTLCb->vosDummyBuf = NULL;
10973 pTLCb->vosTempBuf = NULL;
10974 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
10975
10976 /* set to a default cb in order to prevent constant checking for NULL */
10977 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
10978
10979 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
10980
10981 return VOS_STATUS_SUCCESS;
10982
10983}/* WLANTL_CleanCB*/
10984
10985/*==========================================================================
10986
10987 FUNCTION WLANTL_CleanSTA
10988
10989 DESCRIPTION
10990 Cleans a station control block.
10991
10992 DEPENDENCIES
10993
10994 PARAMETERS
10995
10996 IN
10997 pvosGCtx: pointer to the global vos context; a handle to TL's
10998 control block can be extracted from its context
10999 ucEmpty: if set the queues and pending pkts will be emptyed
11000
11001 RETURN VALUE
11002 The result code associated with performing the operation
11003
11004 VOS_STATUS_E_INVAL: invalid input parameters
11005 VOS_STATUS_SUCCESS: Everything is good :)
11006
11007 SIDE EFFECTS
11008
11009============================================================================*/
11010VOS_STATUS
11011WLANTL_CleanSTA
11012(
11013 WLANTL_STAClientType* ptlSTAClient,
11014 v_U8_t ucEmpty
11015)
11016{
11017 v_U8_t ucIndex;
11018 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11019
11020 /*-------------------------------------------------------------------------
11021 Sanity check
11022 -------------------------------------------------------------------------*/
11023 if ( NULL == ptlSTAClient )
11024 {
11025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11026 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
11027 return VOS_STATUS_E_INVAL;
11028 }
11029
11030 /*------------------------------------------------------------------------
11031 Clear station from TL
11032 ------------------------------------------------------------------------*/
11033 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11034 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
11035 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
11036
11037 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
11038 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
11039 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
11040
11041 ptlSTAClient->tlState = WLANTL_STA_INIT;
11042 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
11043
11044 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
11045 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
11046 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
11047
11048 ptlSTAClient->wSTADesc.ucSTAId = 0;
11049 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
11050
11051 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
11052 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
11053 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
11054 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
11055 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
11056
11057 /*-------------------------------------------------------------------------
11058 AMSDU information for the STA
11059 -------------------------------------------------------------------------*/
11060 if ( ( 0 != ucEmpty ) &&
11061 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
11062 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011063 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080011064 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011065 "suspecting a memory corruption"));
11066
Jeff Johnson295189b2012-06-20 16:38:30 -070011067 }
11068
11069 ptlSTAClient->vosAMSDUChain = NULL;
11070 ptlSTAClient->vosAMSDUChainRoot = NULL;
11071
11072 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
11073 WLANTL_MPDU_HEADER_LEN);
11074 ptlSTAClient->ucMPDUHeaderLen = 0;
11075
11076 /*-------------------------------------------------------------------------
11077 Reordering information for the STA
11078 -------------------------------------------------------------------------*/
11079 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
11080 {
11081 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
11082 {
11083 continue;
11084 }
11085 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
11086 {
11087 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
11088 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
11089 }
11090 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
11091 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
11092 }
11093
11094 /*-------------------------------------------------------------------------
11095 QOS information for the STA
11096 -------------------------------------------------------------------------*/
11097 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
11098 ptlSTAClient->ucCurrentWeight = 0;
11099 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
11100
11101 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
11102 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
11103
11104
11105 /*--------------------------------------------------------------------
11106 Stats info
11107 --------------------------------------------------------------------*/
11108 vos_mem_zero( ptlSTAClient->auRxCount,
11109 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
11110 vos_mem_zero( ptlSTAClient->auTxCount,
11111 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
11112 ptlSTAClient->rssiAvg = 0;
11113
11114 /*Tx not suspended and station fully registered*/
11115 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
11116 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
11117
11118 if ( 0 == ucEmpty )
11119 {
11120 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
11121 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
11122 }
11123
11124 ptlSTAClient->ucExists = 0;
11125
11126 /*--------------------------------------------------------------------
11127 Statistics info
11128 --------------------------------------------------------------------*/
11129 memset(&ptlSTAClient->trafficStatistics,
11130 0,
11131 sizeof(WLANTL_TRANSFER_STA_TYPE));
11132
11133 /*fix me!!: add new values from the TL Cb for cleanup */
11134 return VOS_STATUS_SUCCESS;
11135}/* WLANTL_CleanSTA */
11136
11137
11138/*==========================================================================
11139 FUNCTION WLANTL_EnableUAPSDForAC
11140
11141 DESCRIPTION
11142 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
11143 logic in FW/SLM to start sending trigger frames. Previously TL had the
11144 trigger frame logic which later moved down to FW. Hence
11145 HDD -> TL -> WDA -> FW call flow.
11146
11147 DEPENDENCIES
11148 The TL must be initialized before this function can be called.
11149
11150 PARAMETERS
11151
11152 IN
11153 pvosGCtx: pointer to the global vos context; a handle to TL's
11154 control block can be extracted from its context
11155 ucSTAId: station Id
11156 ucAC: AC for which U-APSD is being enabled
11157 ucTid: TID for which U-APSD is setup
11158 ucUP: used to place in the trigger frame generation
11159 ucServiceInt: service interval used by TL to send trigger frames
11160 ucSuspendInt: suspend interval used by TL to determine that an
11161 app is idle and should start sending trigg frms less often
11162 wTSDir: direction of TSpec
11163
11164 RETURN VALUE
11165 The result code associated with performing the operation
11166
11167 VOS_STATUS_SUCCESS: Everything is good :)
11168
11169 SIDE EFFECTS
11170
11171============================================================================*/
11172VOS_STATUS
11173WLANTL_EnableUAPSDForAC
11174(
11175 v_PVOID_t pvosGCtx,
11176 v_U8_t ucSTAId,
11177 WLANTL_ACEnumType ucAC,
11178 v_U8_t ucTid,
11179 v_U8_t ucUP,
11180 v_U32_t uServiceInt,
11181 v_U32_t uSuspendInt,
11182 WLANTL_TSDirType wTSDir
11183)
11184{
11185
11186 WLANTL_CbType* pTLCb = NULL;
11187 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11188 tUapsdInfo halUAPSDInfo;
11189 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11190
11191 /*------------------------------------------------------------------------
11192 Sanity check
11193 Extract TL control block
11194 ------------------------------------------------------------------------*/
11195 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11196 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011197 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070011198 {
11199 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11200 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011201 " TL: %p STA: %d AC: %d",
11202 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011203 return VOS_STATUS_E_FAULT;
11204 }
11205
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011206 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11207 {
11208 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11209 "WLAN TL:Client Memory was not allocated on %s", __func__));
11210 return VOS_STATUS_E_FAILURE;
11211 }
11212
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011214 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011215
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011216#ifdef FEATURE_WLAN_TDLS
11217 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
11218#endif
11219 {
11220 if( 0 == uServiceInt )
11221 {
11222 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053011223 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011224 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011226
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011227 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11228 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11229 "DI: %d",
11230 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11231 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011232
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011233 /*Save all info for HAL*/
11234 halUAPSDInfo.staidx = ucSTAId;
11235 halUAPSDInfo.ac = ucAC;
11236 halUAPSDInfo.up = ucUP;
11237 halUAPSDInfo.srvInterval = uServiceInt;
11238 halUAPSDInfo.susInterval = uSuspendInt;
11239 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11240
11241 /*Notify HAL*/
11242 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 return vosStatus;
11245
11246}/*WLANTL_EnableUAPSDForAC*/
11247
11248
11249/*==========================================================================
11250 FUNCTION WLANTL_DisableUAPSDForAC
11251
11252 DESCRIPTION
11253 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11254 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11255 trigger frame logic which later moved down to FW. Hence
11256 HDD -> TL -> WDA -> FW call flow.
11257
11258 DEPENDENCIES
11259 The TL must be initialized before this function can be called.
11260
11261 PARAMETERS
11262
11263 IN
11264 pvosGCtx: pointer to the global vos context; a handle to TL's
11265 control block can be extracted from its context
11266 ucSTAId: station Id
11267 ucAC: AC for which U-APSD is being enabled
11268
11269
11270 RETURN VALUE
11271 The result code associated with performing the operation
11272
11273 VOS_STATUS_SUCCESS: Everything is good :)
11274
11275 SIDE EFFECTS
11276
11277============================================================================*/
11278VOS_STATUS
11279WLANTL_DisableUAPSDForAC
11280(
11281 v_PVOID_t pvosGCtx,
11282 v_U8_t ucSTAId,
11283 WLANTL_ACEnumType ucAC
11284)
11285{
11286 WLANTL_CbType* pTLCb;
11287 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11288
11289 /*------------------------------------------------------------------------
11290 Sanity check
11291 Extract TL control block
11292 ------------------------------------------------------------------------*/
11293 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11294 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11295 || WLANTL_AC_INVALID(ucAC) )
11296 {
11297 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11298 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011299 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 return VOS_STATUS_E_FAULT;
11301 }
11302
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011303 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11304 {
11305 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11306 "WLAN TL:Client Memory was not allocated on %s", __func__));
11307 return VOS_STATUS_E_FAILURE;
11308 }
11309
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011311 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011312
11313 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11314 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11315 ucSTAId, ucAC));
11316
11317 /*Notify HAL*/
11318 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11319
11320 return VOS_STATUS_SUCCESS;
11321}/* WLANTL_DisableUAPSDForAC */
11322
11323#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11324/*==========================================================================
11325 FUNCTION WLANTL_RegRSSIIndicationCB
11326
11327 DESCRIPTION Registration function to get notification if RSSI cross
11328 threshold.
11329 Client should register threshold, direction, and notification
11330 callback function pointer
11331
11332 DEPENDENCIES NONE
11333
11334 PARAMETERS in pAdapter - Global handle
11335 in rssiValue - RSSI threshold value
11336 in triggerEvent - Cross direction should be notified
11337 UP, DOWN, and CROSS
11338 in crossCBFunction - Notification CB Function
11339 in usrCtxt - user context
11340
11341 RETURN VALUE VOS_STATUS
11342
11343 SIDE EFFECTS NONE
11344
11345============================================================================*/
11346VOS_STATUS WLANTL_RegRSSIIndicationCB
11347(
11348 v_PVOID_t pAdapter,
11349 v_S7_t rssiValue,
11350 v_U8_t triggerEvent,
11351 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11352 VOS_MODULE_ID moduleID,
11353 v_PVOID_t usrCtxt
11354)
11355{
11356 VOS_STATUS status = VOS_STATUS_SUCCESS;
11357
11358 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11359 rssiValue,
11360 triggerEvent,
11361 crossCBFunction,
11362 moduleID,
11363 usrCtxt);
11364
11365 return status;
11366}
11367
11368/*==========================================================================
11369 FUNCTION WLANTL_DeregRSSIIndicationCB
11370
11371 DESCRIPTION Remove specific threshold from list
11372
11373 DEPENDENCIES NONE
11374
11375 PARAMETERS in pAdapter - Global handle
11376 in rssiValue - RSSI threshold value
11377 in triggerEvent - Cross direction should be notified
11378 UP, DOWN, and CROSS
11379
11380 RETURN VALUE VOS_STATUS
11381
11382 SIDE EFFECTS NONE
11383
11384============================================================================*/
11385VOS_STATUS WLANTL_DeregRSSIIndicationCB
11386(
11387 v_PVOID_t pAdapter,
11388 v_S7_t rssiValue,
11389 v_U8_t triggerEvent,
11390 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11391 VOS_MODULE_ID moduleID
11392)
11393{
11394 VOS_STATUS status = VOS_STATUS_SUCCESS;
11395
11396 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11397 rssiValue,
11398 triggerEvent,
11399 crossCBFunction,
11400 moduleID);
11401 return status;
11402}
11403
11404/*==========================================================================
11405 FUNCTION WLANTL_SetAlpha
11406
11407 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11408 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11409 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11410 (10 - ALPHA)% of newRSSI weight
11411 This portion is dynamically configurable.
11412 Default is ?
11413
11414 DEPENDENCIES NONE
11415
11416 PARAMETERS in pAdapter - Global handle
11417 in valueAlpah - ALPHA
11418
11419 RETURN VALUE VOS_STATUS
11420
11421 SIDE EFFECTS NONE
11422
11423============================================================================*/
11424VOS_STATUS WLANTL_SetAlpha
11425(
11426 v_PVOID_t pAdapter,
11427 v_U8_t valueAlpha
11428)
11429{
11430 VOS_STATUS status = VOS_STATUS_SUCCESS;
11431
11432 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11433 return status;
11434}
11435
11436/*==========================================================================
11437
11438 FUNCTION
11439
11440 DESCRIPTION
11441
11442 PARAMETERS
11443
11444 RETURN VALUE
11445
11446============================================================================*/
11447VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11448(
11449 v_PVOID_t pAdapter,
11450 tpSirRSSINotification pRSSINotification
11451)
11452{
11453 VOS_STATUS status = VOS_STATUS_SUCCESS;
11454
11455 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11456 return status;
11457}
11458
11459/*==========================================================================
11460 FUNCTION WLANTL_RegGetTrafficStatus
11461
11462 DESCRIPTION Registration function for traffic status monitoring
11463 During measure period count data frames.
11464 If frame count is larger then IDLE threshold set as traffic ON
11465 or OFF.
11466 And traffic status is changed send report to client with
11467 registered callback function
11468
11469 DEPENDENCIES NONE
11470
11471 PARAMETERS in pAdapter - Global handle
11472 in idleThreshold - Traffic on or off threshold
11473 in measurePeriod - Traffic state check period
11474 in trfficStatusCB - traffic status changed notification
11475 CB function
11476 in usrCtxt - user context
11477
11478 RETURN VALUE VOS_STATUS
11479
11480 SIDE EFFECTS NONE
11481
11482============================================================================*/
11483VOS_STATUS WLANTL_RegGetTrafficStatus
11484(
11485 v_PVOID_t pAdapter,
11486 v_U32_t idleThreshold,
11487 v_U32_t measurePeriod,
11488 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11489 v_PVOID_t usrCtxt
11490)
11491{
11492 VOS_STATUS status = VOS_STATUS_SUCCESS;
11493
11494 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11495 idleThreshold,
11496 measurePeriod,
11497 trfficStatusCB,
11498 usrCtxt);
11499 return status;
11500}
11501#endif
11502/*==========================================================================
11503 FUNCTION WLANTL_GetStatistics
11504
11505 DESCRIPTION Get traffic statistics for identified station
11506
11507 DEPENDENCIES NONE
11508
11509 PARAMETERS in pAdapter - Global handle
11510 in statType - specific statistics field to reset
11511 out statBuffer - traffic statistics buffer
11512
11513 RETURN VALUE VOS_STATUS
11514
11515 SIDE EFFECTS NONE
11516
11517============================================================================*/
11518VOS_STATUS WLANTL_GetStatistics
11519(
11520 v_PVOID_t pAdapter,
11521 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11522 v_U8_t STAid
11523)
11524{
11525 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011526 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 VOS_STATUS status = VOS_STATUS_SUCCESS;
11528 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11529
11530 /*------------------------------------------------------------------------
11531 Sanity check
11532 Extract TL control block
11533 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011534 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 {
11536 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11537 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11538 return VOS_STATUS_E_FAULT;
11539 }
11540
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011541 pClientSTA = pTLCb->atlSTAClients[STAid];
11542
11543 if ( NULL == pClientSTA )
11544 {
11545 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11546 "WLAN TL:Client Memory was not allocated on %s", __func__));
11547 return VOS_STATUS_E_FAILURE;
11548 }
11549
11550 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 {
11552 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11553 "WLAN TL: %d STA ID does not exist", STAid));
11554 return VOS_STATUS_E_INVAL;
11555 }
11556
11557 if(NULL == statBuffer)
11558 {
11559 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11560 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11561 return VOS_STATUS_E_INVAL;
11562 }
11563
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011564 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053011565 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070011566
11567 return status;
11568}
11569
11570/*==========================================================================
11571 FUNCTION WLANTL_ResetStatistics
11572
11573 DESCRIPTION Reset statistics structure for identified station ID
11574 Reset means set values as 0
11575
11576 DEPENDENCIES NONE
11577
11578 PARAMETERS in pAdapter - Global handle
11579 in statType - specific statistics field to reset
11580
11581 RETURN VALUE VOS_STATUS
11582
11583 SIDE EFFECTS NONE
11584
11585============================================================================*/
11586VOS_STATUS WLANTL_ResetStatistics
11587(
11588 v_PVOID_t pAdapter,
11589 v_U8_t STAid
11590)
11591{
11592 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011593 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 VOS_STATUS status = VOS_STATUS_SUCCESS;
11595 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11596
11597 /*------------------------------------------------------------------------
11598 Sanity check
11599 Extract TL control block
11600 ------------------------------------------------------------------------*/
11601 if (NULL == pTLCb)
11602 {
11603 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11604 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11605 return VOS_STATUS_E_FAULT;
11606 }
11607
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011608 pClientSTA = pTLCb->atlSTAClients[STAid];
11609
11610 if ( NULL == pClientSTA )
11611 {
11612 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11613 "WLAN TL:Client Memory was not allocated on %s", __func__));
11614 return VOS_STATUS_E_FAILURE;
11615 }
11616
11617 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 {
11619 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11620 "WLAN TL: %d STA ID does not exist", STAid));
11621 return VOS_STATUS_E_INVAL;
11622 }
11623
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011624 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011625 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11626
11627 return status;
11628}
11629
11630/*==========================================================================
11631 FUNCTION WLANTL_GetSpecStatistic
11632
11633 DESCRIPTION Get specific field within statistics structure for
11634 identified station ID
11635
11636 DEPENDENCIES NONE
11637
11638 PARAMETERS in pAdapter - Global handle
11639 in statType - specific statistics field to reset
11640 in STAid - Station ID
11641 out buffer - Statistic value
11642
11643 RETURN VALUE VOS_STATUS
11644
11645 SIDE EFFECTS NONE
11646
11647============================================================================*/
11648VOS_STATUS WLANTL_GetSpecStatistic
11649(
11650 v_PVOID_t pAdapter,
11651 WLANTL_TRANSFER_STATIC_TYPE statType,
11652 v_U32_t *buffer,
11653 v_U8_t STAid
11654)
11655{
11656 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011657 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 VOS_STATUS status = VOS_STATUS_SUCCESS;
11659 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11660
11661 /*------------------------------------------------------------------------
11662 Sanity check
11663 Extract TL control block
11664 ------------------------------------------------------------------------*/
11665 if (NULL == pTLCb)
11666 {
11667 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11668 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11669 return VOS_STATUS_E_FAULT;
11670 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011671 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011672
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011673 if ( NULL == pClientSTA )
11674 {
11675 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11676 "WLAN TL:Client Memory was not allocated on %s", __func__));
11677 return VOS_STATUS_E_FAILURE;
11678 }
11679
11680 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 {
11682 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11683 "WLAN TL: %d STA ID does not exist", STAid));
11684 return VOS_STATUS_E_INVAL;
11685 }
11686
11687 if(NULL == buffer)
11688 {
11689 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11690 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11691 return VOS_STATUS_E_INVAL;
11692 }
11693
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011694 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 switch(statType)
11696 {
11697 case WLANTL_STATIC_TX_UC_FCNT:
11698 *buffer = statistics->txUCFcnt;
11699 break;
11700
11701 case WLANTL_STATIC_TX_MC_FCNT:
11702 *buffer = statistics->txMCFcnt;
11703 break;
11704
11705 case WLANTL_STATIC_TX_BC_FCNT:
11706 *buffer = statistics->txBCFcnt;
11707 break;
11708
11709 case WLANTL_STATIC_TX_UC_BCNT:
11710 *buffer = statistics->txUCBcnt;
11711 break;
11712
11713 case WLANTL_STATIC_TX_MC_BCNT:
11714 *buffer = statistics->txMCBcnt;
11715 break;
11716
11717 case WLANTL_STATIC_TX_BC_BCNT:
11718 *buffer = statistics->txBCBcnt;
11719 break;
11720
11721 case WLANTL_STATIC_RX_UC_FCNT:
11722 *buffer = statistics->rxUCFcnt;
11723 break;
11724
11725 case WLANTL_STATIC_RX_MC_FCNT:
11726 *buffer = statistics->rxMCFcnt;
11727 break;
11728
11729 case WLANTL_STATIC_RX_BC_FCNT:
11730 *buffer = statistics->rxBCFcnt;
11731 break;
11732
11733 case WLANTL_STATIC_RX_UC_BCNT:
11734 *buffer = statistics->rxUCBcnt;
11735 break;
11736
11737 case WLANTL_STATIC_RX_MC_BCNT:
11738 *buffer = statistics->rxMCBcnt;
11739 break;
11740
11741 case WLANTL_STATIC_RX_BC_BCNT:
11742 *buffer = statistics->rxBCBcnt;
11743 break;
11744
11745 case WLANTL_STATIC_RX_BCNT:
11746 *buffer = statistics->rxBcnt;
11747 break;
11748
11749 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11750 *buffer = statistics->rxBcntCRCok;
11751 break;
11752
11753 case WLANTL_STATIC_RX_RATE:
11754 *buffer = statistics->rxRate;
11755 break;
11756
11757 default:
11758 *buffer = 0;
11759 status = VOS_STATUS_E_INVAL;
11760 break;
11761 }
11762
11763
11764 return status;
11765}
11766
11767/*==========================================================================
11768 FUNCTION WLANTL_ResetSpecStatistic
11769
11770 DESCRIPTION Reset specific field within statistics structure for
11771 identified station ID
11772 Reset means set as 0
11773
11774 DEPENDENCIES NONE
11775
11776 PARAMETERS in pAdapter - Global handle
11777 in statType - specific statistics field to reset
11778 in STAid - Station ID
11779
11780 RETURN VALUE VOS_STATUS
11781
11782 SIDE EFFECTS NONE
11783
11784============================================================================*/
11785VOS_STATUS WLANTL_ResetSpecStatistic
11786(
11787 v_PVOID_t pAdapter,
11788 WLANTL_TRANSFER_STATIC_TYPE statType,
11789 v_U8_t STAid
11790)
11791{
11792 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011793 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 VOS_STATUS status = VOS_STATUS_SUCCESS;
11795 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11796
11797 /*------------------------------------------------------------------------
11798 Sanity check
11799 Extract TL control block
11800 ------------------------------------------------------------------------*/
11801 if (NULL == pTLCb)
11802 {
11803 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11804 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11805 return VOS_STATUS_E_FAULT;
11806 }
11807
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011808 pClientSTA = pTLCb->atlSTAClients[STAid];
11809
11810 if ( NULL == pClientSTA )
11811 {
11812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11813 "WLAN TL:Client Memory was not allocated on %s", __func__));
11814 return VOS_STATUS_E_FAILURE;
11815 }
11816
11817 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 {
11819 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11820 "WLAN TL: %d STA ID does not exist", STAid));
11821 return VOS_STATUS_E_INVAL;
11822 }
11823
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011824 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 switch(statType)
11826 {
11827 case WLANTL_STATIC_TX_UC_FCNT:
11828 statistics->txUCFcnt = 0;
11829 break;
11830
11831 case WLANTL_STATIC_TX_MC_FCNT:
11832 statistics->txMCFcnt = 0;
11833 break;
11834
11835 case WLANTL_STATIC_TX_BC_FCNT:
11836 statistics->txBCFcnt = 0;
11837 break;
11838
11839 case WLANTL_STATIC_TX_UC_BCNT:
11840 statistics->txUCBcnt = 0;
11841 break;
11842
11843 case WLANTL_STATIC_TX_MC_BCNT:
11844 statistics->txMCBcnt = 0;
11845 break;
11846
11847 case WLANTL_STATIC_TX_BC_BCNT:
11848 statistics->txBCBcnt = 0;
11849 break;
11850
11851 case WLANTL_STATIC_RX_UC_FCNT:
11852 statistics->rxUCFcnt = 0;
11853 break;
11854
11855 case WLANTL_STATIC_RX_MC_FCNT:
11856 statistics->rxMCFcnt = 0;
11857 break;
11858
11859 case WLANTL_STATIC_RX_BC_FCNT:
11860 statistics->rxBCFcnt = 0;
11861 break;
11862
11863 case WLANTL_STATIC_RX_UC_BCNT:
11864 statistics->rxUCBcnt = 0;
11865 break;
11866
11867 case WLANTL_STATIC_RX_MC_BCNT:
11868 statistics->rxMCBcnt = 0;
11869 break;
11870
11871 case WLANTL_STATIC_RX_BC_BCNT:
11872 statistics->rxBCBcnt = 0;
11873 break;
11874
11875 case WLANTL_STATIC_RX_BCNT:
11876 statistics->rxBcnt = 0;
11877 break;
11878
11879 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11880 statistics->rxBcntCRCok = 0;
11881 break;
11882
11883 case WLANTL_STATIC_RX_RATE:
11884 statistics->rxRate = 0;
11885 break;
11886
11887 default:
11888 status = VOS_STATUS_E_INVAL;
11889 break;
11890 }
11891
11892 return status;
11893}
11894
11895
11896/*==========================================================================
11897
11898 FUNCTION
11899
11900 DESCRIPTION Read RSSI value out of a RX BD
11901
11902 PARAMETERS: Caller must validate all parameters
11903
11904 RETURN VALUE
11905
11906============================================================================*/
11907VOS_STATUS WLANTL_ReadRSSI
11908(
11909 v_PVOID_t pAdapter,
11910 v_PVOID_t pBDHeader,
11911 v_U8_t STAid
11912)
11913{
11914 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11915 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
11916
11917
11918 if(NULL == tlCtxt)
11919 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011920 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 return VOS_STATUS_E_INVAL;
11922 }
11923
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011924 if ( NULL == tlCtxt->atlSTAClients[STAid] )
11925 {
11926 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11927 "WLAN TL:Client Memory was not allocated on %s", __func__));
11928 return VOS_STATUS_E_FAILURE;
11929 }
11930
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
11932 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
11933 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
11934
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011935 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070011936
11937 return VOS_STATUS_SUCCESS;
11938}
11939
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011940/*==========================================================================
11941
11942 FUNCTION
11943
11944 DESCRIPTION Read SNR value out of a RX BD
11945
11946 PARAMETERS: Caller must validate all parameters
11947
11948 RETURN VALUE
11949
11950============================================================================*/
11951VOS_STATUS WLANTL_ReadSNR
11952(
11953 v_PVOID_t pAdapter,
11954 v_PVOID_t pBDHeader,
11955 v_U8_t STAid
11956)
11957{
11958 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
11959 v_S7_t currentSNR;
11960
11961
11962 if (NULL == tlCtxt)
11963 {
11964 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11965 "%s Invalid TL handle", __func__));
11966 return VOS_STATUS_E_INVAL;
11967 }
11968
11969 if (NULL == tlCtxt->atlSTAClients[STAid])
11970 {
11971 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11972 "WLAN TL:Client Memory was not allocated on %s", __func__));
11973 return VOS_STATUS_E_FAILURE;
11974 }
11975
11976 currentSNR = WLANTL_GETSNR(pBDHeader);
11977
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053011978 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
11979 * Get the correct SNR value
11980 */
11981 currentSNR = currentSNR >> 1;
11982
11983 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
11984 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
11985 WLANTL_MAX_HW_SNR);
11986
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011987 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11988 "%s: snrsum: %d snridx: %d prevsnravg: %d",
11989 __func__,
11990 tlCtxt->atlSTAClients[STAid]->snrSum,
11991 tlCtxt->atlSTAClients[STAid]->snrIdx,
11992 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
11993
11994 /* The SNR returned for all purposes is the average SNR over
11995 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
11996 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
11997 * store the average of the samples in prevSnrAvg
11998 * and start a new averaging window. The prevSnrAvg is used when
11999 * enough data samples are not available when applications
12000 * actually query for SNR.
12001 *
12002 * SEE: WLANTL_GetSnr()
12003 */
12004 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
12005 {
12006 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
12007 tlCtxt->atlSTAClients[STAid]->snrSum /
12008 tlCtxt->atlSTAClients[STAid]->snrIdx;
12009 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
12010 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
12011 }
12012 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
12013 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
12014
12015 return VOS_STATUS_SUCCESS;
12016}
Jeff Johnson295189b2012-06-20 16:38:30 -070012017
12018/*
12019 DESCRIPTION
12020 TL returns the weight currently maintained in TL.
12021 IN
12022 pvosGCtx: pointer to the global vos context; a handle to TL's
12023 or SME's control block can be extracted from its context
12024
12025 OUT
12026 pACWeights: Caller allocated memory for filling in weights
12027
12028 RETURN VALUE VOS_STATUS
12029*/
12030VOS_STATUS
12031WLANTL_GetACWeights
12032(
12033 v_PVOID_t pvosGCtx,
12034 v_U8_t* pACWeights
12035)
12036{
12037 WLANTL_CbType* pTLCb = NULL;
12038 v_U8_t ucIndex;
12039 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12040
12041 /*------------------------------------------------------------------------
12042 Sanity check
12043 ------------------------------------------------------------------------*/
12044 if ( NULL == pACWeights )
12045 {
12046 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12047 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12048 return VOS_STATUS_E_INVAL;
12049 }
12050
12051 /*------------------------------------------------------------------------
12052 Extract TL control block and check existance
12053 ------------------------------------------------------------------------*/
12054 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12055 if ( NULL == pTLCb )
12056 {
12057 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12058 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12059 return VOS_STATUS_E_FAULT;
12060 }
12061 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12062 {
12063 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
12064 }
12065
12066 return VOS_STATUS_SUCCESS;
12067}
12068
12069
12070
12071/*
12072 DESCRIPTION
12073 Change the weight currently maintained by TL.
12074 IN
12075 pvosGCtx: pointer to the global vos context; a handle to TL's
12076 or SME's control block can be extracted from its context
12077 pACWeights: Caller allocated memory contain the weights to use
12078
12079
12080 RETURN VALUE VOS_STATUS
12081*/
12082VOS_STATUS
12083WLANTL_SetACWeights
12084(
12085 v_PVOID_t pvosGCtx,
12086 v_U8_t* pACWeights
12087)
12088{
12089 WLANTL_CbType* pTLCb = NULL;
12090 v_U8_t ucIndex;
12091 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12092
12093 /*------------------------------------------------------------------------
12094 Sanity check
12095 ------------------------------------------------------------------------*/
12096 if ( NULL == pACWeights )
12097 {
12098 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12099 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12100 return VOS_STATUS_E_INVAL;
12101 }
12102
12103 /*------------------------------------------------------------------------
12104 Extract TL control block and check existance
12105 ------------------------------------------------------------------------*/
12106 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12107 if ( NULL == pTLCb )
12108 {
12109 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12110 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12111 return VOS_STATUS_E_FAULT;
12112 }
12113 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12114 {
12115 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
12116 }
12117
12118 return VOS_STATUS_SUCCESS;
12119}
12120
12121
12122/*==========================================================================
12123
12124 FUNCTION
12125
12126 DESCRIPTION
12127
12128 PARAMETERS
12129
12130 RETURN VALUE
12131
12132============================================================================*/
12133void WLANTL_PowerStateChangedCB
12134(
12135 v_PVOID_t pAdapter,
12136 tPmcState newState
12137)
12138{
12139 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12140
12141 if (NULL == tlCtxt)
12142 {
12143 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053012144 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 return;
12146 }
12147
12148 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
12149 switch(newState)
12150 {
12151 case FULL_POWER:
12152 tlCtxt->isBMPS = VOS_FALSE;
12153 break;
12154
12155 case BMPS:
12156#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12157 WLANTL_SetFWRSSIThresholds(pAdapter);
12158#endif
12159
12160 tlCtxt->isBMPS = VOS_TRUE;
12161 break;
12162
12163 case IMPS:
12164 case LOW_POWER:
12165 case REQUEST_BMPS:
12166 case REQUEST_FULL_POWER:
12167 case REQUEST_IMPS:
12168 case STOPPED:
12169 case REQUEST_START_UAPSD:
12170 case REQUEST_STOP_UAPSD:
12171 case UAPSD:
12172 case REQUEST_STANDBY:
12173 case STANDBY:
12174 case REQUEST_ENTER_WOWL:
12175 case REQUEST_EXIT_WOWL:
12176 case WOWL:
12177 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
12178 break;
12179
12180 default:
12181 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
12182 break;
12183 }
12184
12185 return;
12186}
12187/*==========================================================================
12188 FUNCTION WLANTL_GetEtherType
12189
12190 DESCRIPTION Extract Ether type information from the BD
12191
12192 DEPENDENCIES NONE
12193
12194 PARAMETERS in aucBDHeader - BD header
12195 in vosDataBuff - data buffer
12196 in ucMPDUHLen - MPDU header length
12197 out pUsEtherType - pointer to Ethertype
12198
12199 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12200 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12201 the packet was dropped
12202
12203 SIDE EFFECTS NONE
12204
12205============================================================================*/
12206static VOS_STATUS WLANTL_GetEtherType
12207(
12208 v_U8_t * aucBDHeader,
12209 vos_pkt_t * vosDataBuff,
12210 v_U8_t ucMPDUHLen,
12211 v_U16_t * pUsEtherType
12212)
12213{
12214 v_U8_t ucOffset;
12215 v_U16_t usEtherType = *pUsEtherType;
12216 v_SIZE_t usLLCSize = sizeof(usEtherType);
12217 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12218
12219 /*------------------------------------------------------------------------
12220 Check if LLC is present - if not, TL is unable to determine type
12221 ------------------------------------------------------------------------*/
12222 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
12223 {
12224 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12225 }
12226 else
12227 {
12228 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12229 }
12230
12231 /*------------------------------------------------------------------------
12232 Extract LLC type
12233 ------------------------------------------------------------------------*/
12234 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12235 (v_PVOID_t)&usEtherType, &usLLCSize);
12236
12237 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12238 ( sizeof(usEtherType) != usLLCSize ))
12239
12240 {
12241 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12242 "WLAN TL:Error extracting Ether type from data packet"));
12243 /* Drop packet */
12244 vos_pkt_return_packet(vosDataBuff);
12245 vosStatus = VOS_STATUS_E_FAILURE;
12246 }
12247 else
12248 {
12249 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12250 "WLAN TL:Ether type retrieved before endianess conv: %d",
12251 usEtherType));
12252
12253 usEtherType = vos_be16_to_cpu(usEtherType);
12254 *pUsEtherType = usEtherType;
12255
12256 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12257 "WLAN TL:Ether type retrieved: %d", usEtherType));
12258 }
12259
12260 return vosStatus;
12261}
12262
Jeff Johnson295189b2012-06-20 16:38:30 -070012263/*==========================================================================
12264 FUNCTION WLANTL_GetSoftAPStatistics
12265
12266 DESCRIPTION Collect the cumulative statistics for all Softap stations
12267
12268 DEPENDENCIES NONE
12269
12270 PARAMETERS in pvosGCtx - Pointer to the global vos context
12271 bReset - If set TL statistics will be cleared after reading
12272 out statsSum - pointer to collected statistics
12273
12274 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12275
12276 SIDE EFFECTS NONE
12277
12278============================================================================*/
12279VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12280{
12281 v_U8_t i = 0;
12282 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12283 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12284 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12285 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12286 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12287
12288
12289 if ( NULL == pTLCb )
12290 {
12291 return VOS_STATUS_E_FAULT;
12292 }
12293
12294 // Sum up all the statistics for stations of Soft AP from TL
12295 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12296 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012297 if ( NULL == pTLCb->atlSTAClients[i])
12298 {
12299 continue;
12300 }
12301 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 {
12303 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12304
12305 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12306 return VOS_STATUS_E_FAULT;
12307
12308 // Add to the counters
12309 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12310 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12311 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12312 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12313 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12314 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12315 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12316 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12317 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12318 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12319 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12320 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12321
12322 if (bReset)
12323 {
12324 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12325 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12326 return VOS_STATUS_E_FAULT;
12327 }
12328 }
12329 }
12330
12331 return vosStatus;
12332}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012333#ifdef FEATURE_WLAN_TDLS_INTERNAL
12334/*==========================================================================
12335 FUNCTION WLANTL_GetEtherType_2
12336
12337 DESCRIPTION Extract Ether type information from the BD
12338
12339 DEPENDENCIES NONE
12340
12341 PARAMETERS in aucBDHeader - BD header
12342 in vosDataBuff - data buffer
12343 in ucMPDUHLen - MPDU header length
12344 out pUsEtherType - pointer to Ethertype
12345
12346 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12347 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12348 the packet was dropped
12349
12350 SIDE EFFECTS NONE
12351
12352============================================================================*/
12353static VOS_STATUS WLANTL_GetEtherType_2
12354(
12355 v_U8_t * aucBDHeader,
12356 vos_pkt_t * vosDataBuff,
12357 v_U8_t ucMPDUHLen,
12358 v_U16_t * pUsEtherType
12359)
12360{
12361 v_U8_t ucOffset;
12362 v_U16_t usEtherType = *pUsEtherType;
12363 v_SIZE_t usLLCSize = sizeof(usEtherType);
12364 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12365 //v_U8_t ucLLCHeader;
12366 v_U8_t ucMPDUHOffset ;
12367 /*------------------------------------------------------------------------
12368 Check if LLC is present - if not, TL is unable to determine type
12369 ------------------------------------------------------------------------*/
12370 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12371 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12372 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12373
12374 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12375 {
12376 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12377 }
12378 else
12379 {
12380 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12381 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12382 }
12383
12384 /*------------------------------------------------------------------------
12385 Extract LLC type
12386 ------------------------------------------------------------------------*/
12387 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12388 (v_PVOID_t)&usEtherType, &usLLCSize);
12389
12390 /* TODO: Do it in better way */
12391 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12392 {
12393 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -080012394 ("TDLS frame llc %x"), vos_be16_to_cpu(usEtherType)) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012395 }
12396
12397 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12398 "WLAN TL:Ether type retrieved before endianess conv: %d",
12399 usEtherType);
12400
12401 usEtherType = vos_be16_to_cpu(usEtherType);
12402 *pUsEtherType = usEtherType;
12403
12404 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12405 "WLAN TL:Ether type retrieved: %d", usEtherType);
12406
12407 return vosStatus;
12408}
12409#endif /* FEATURE_WLAN_TDLS */
12410
Jeff Johnson295189b2012-06-20 16:38:30 -070012411/*===============================================================================
12412 FUNCTION WLANTL_IsReplayPacket
12413
12414 DESCRIPTION This function does replay check for valid stations
12415
12416 DEPENDENCIES Validity of replay check must be done before the function
12417 is called
12418
12419 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12420 previousReplayCounter previous replay counter taken from TL CB
12421
12422 RETRUN VOS_TRUE packet is a replay packet
12423 VOS_FALSE packet is not a replay packet
12424
12425 SIDE EFFECTS none
12426 ===============================================================================*/
12427v_BOOL_t
12428WLANTL_IsReplayPacket
12429(
12430 v_U64_t ullcurrentReplayCounter,
12431 v_U64_t ullpreviousReplayCounter
12432)
12433{
12434 /* Do the replay check by comparing previous received replay counter with
12435 current received replay counter*/
12436 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12437 {
12438 /* Valid packet not replay */
12439 return VOS_FALSE;
12440 }
12441 else
12442 {
12443
12444 /* Current packet number is less than or equal to previuos received
12445 packet no, this means current packet is replay packet */
12446 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12447 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12448
12449 return VOS_TRUE;
12450 }
12451}
12452
12453#if 0
12454/*===============================================================================
12455 FUNCTION WLANTL_GetReplayCounterFromRxBD
12456
12457 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12458
12459 DEPENDENCIES Validity of replay check must be done before the function
12460 is called
12461
12462 PARAMETERS pucRxHeader pointer to RX BD header
12463
12464 RETRUN v_U64_t Packet number extarcted from RX BD
12465
12466 SIDE EFFECTS none
12467 ===============================================================================*/
12468v_U64_t
12469WLANTL_GetReplayCounterFromRxBD
12470(
12471 v_U8_t *pucRxBDHeader
12472)
12473{
12474/* 48-bit replay counter is created as follows
12475 from RX BD 6 byte PMI command:
12476 Addr : AES/TKIP
12477 0x38 : pn3/tsc3
12478 0x39 : pn2/tsc2
12479 0x3a : pn1/tsc1
12480 0x3b : pn0/tsc0
12481
12482 0x3c : pn5/tsc5
12483 0x3d : pn4/tsc4 */
12484
12485#ifdef ANI_BIG_BYTE_ENDIAN
12486 v_U64_t ullcurrentReplayCounter = 0;
12487 /* Getting 48-bit replay counter from the RX BD */
12488 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12489 ullcurrentReplayCounter <<= 16;
12490 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12491 return ullcurrentReplayCounter;
12492#else
12493 v_U64_t ullcurrentReplayCounter = 0;
12494 /* Getting 48-bit replay counter from the RX BD */
12495 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12496 ullcurrentReplayCounter <<= 32;
12497 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12498 return ullcurrentReplayCounter;
12499#endif
12500}
12501#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012502
12503/*===============================================================================
12504 FUNCTION WLANTL_PostResNeeded
12505
12506 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12507
12508 DEPENDENCIES None
12509
12510 PARAMETERS pvosGCtx
12511
12512 RETURN None
12513
12514 SIDE EFFECTS none
12515 ===============================================================================*/
12516
12517void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12518{
12519 vos_msg_t vosMsg;
12520
12521 vosMsg.reserved = 0;
12522 vosMsg.bodyptr = NULL;
12523 vosMsg.type = WLANTL_TX_RES_NEEDED;
12524 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12525 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12526 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12527 {
12528 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012529 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 }
12531}
12532
12533/*===============================================================================
12534 FUNCTION WLANTL_UpdateRssiBmps
12535
12536 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12537
12538 DEPENDENCIES None
12539
12540 PARAMETERS
12541
12542 pvosGCtx VOS context VOS Global context
12543 staId Station ID Station ID
12544 rssi RSSI (BMPS mode) RSSI in BMPS mode
12545
12546 RETURN None
12547
12548 SIDE EFFECTS none
12549 ===============================================================================*/
12550
12551void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12552{
12553 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12554
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012555 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012557 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012558 }
12559}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012560
12561/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012562 FUNCTION WLANTL_UpdateSnrBmps
12563
12564 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
12565
12566 DEPENDENCIES None
12567
12568 PARAMETERS
12569
12570 pvosGCtx VOS context VOS Global context
12571 staId Station ID Station ID
12572 snr SNR (BMPS mode) SNR in BMPS mode
12573
12574 RETURN None
12575
12576 SIDE EFFECTS none
12577 ===============================================================================*/
12578
12579void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
12580{
12581 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12582
12583 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12584 {
12585 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
12586 }
12587}
12588
12589/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012590 FUNCTION WLANTL_UpdateLinkCapacity
12591
12592 DESCRIPTION This function updates the STA's Link Capacity in TL
12593
12594 DEPENDENCIES None
12595
12596 PARAMETERS
12597
12598 pvosGCtx VOS context VOS Global context
12599 staId Station ID Station ID
12600 linkCapacity linkCapacity Link Capacity
12601
12602 RETURN None
12603
12604 SIDE EFFECTS none
12605 ===============================================================================*/
12606
12607void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12608{
12609 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12610
12611 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12612 {
12613 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12614 }
12615}
12616
12617
12618/*===========================================================================
12619
12620 FUNCTION WLANTL_GetSTALinkCapacity
12621
12622 DESCRIPTION
12623
12624 Returns Link Capacity of a particular STA.
12625
12626 DEPENDENCIES
12627
12628 A station must have been registered before its state can be retrieved.
12629
12630
12631 PARAMETERS
12632
12633 IN
12634 pvosGCtx: pointer to the global vos context; a handle to TL's
12635 control block can be extracted from its context
12636 ucSTAId: identifier of the station
12637
12638 OUT
12639 plinkCapacity: the current link capacity the connection to
12640 the given station
12641
12642
12643 RETURN VALUE
12644
12645 The result code associated with performing the operation
12646
12647 VOS_STATUS_E_INVAL: Input parameters are invalid
12648 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12649 TL cb is NULL ; access would cause a page fault
12650 VOS_STATUS_E_EXISTS: Station was not registered
12651 VOS_STATUS_SUCCESS: Everything is good :)
12652
12653 SIDE EFFECTS
12654
12655============================================================================*/
12656VOS_STATUS
12657WLANTL_GetSTALinkCapacity
12658(
12659 v_PVOID_t pvosGCtx,
12660 v_U8_t ucSTAId,
12661 v_U32_t *plinkCapacity
12662)
12663{
12664 WLANTL_CbType* pTLCb = NULL;
12665 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12666
12667 /*------------------------------------------------------------------------
12668 Sanity check
12669 ------------------------------------------------------------------------*/
12670 if ( NULL == plinkCapacity )
12671 {
12672 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12673 FL("WLAN TL:Invalid parameter")));
12674 return VOS_STATUS_E_INVAL;
12675 }
12676
12677 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12678 {
12679 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12680 FL("WLAN TL:Invalid station id")));
12681 return VOS_STATUS_E_FAULT;
12682 }
12683
12684 /*------------------------------------------------------------------------
12685 Extract TL control block and check existance
12686 ------------------------------------------------------------------------*/
12687 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12688 if ( NULL == pTLCb )
12689 {
12690 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12691 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12692 return VOS_STATUS_E_FAULT;
12693 }
12694
12695 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12696 {
12697 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12698 FL("WLAN TL:Client Memory was not allocated")));
12699 return VOS_STATUS_E_FAILURE;
12700 }
12701
12702 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12703 {
12704 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12705 FL("WLAN TL:Station was not previously registered")));
12706 return VOS_STATUS_E_EXISTS;
12707 }
12708
12709 /*------------------------------------------------------------------------
12710 Get STA state
12711 ------------------------------------------------------------------------*/
12712 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12713
12714 return VOS_STATUS_SUCCESS;
12715}/* WLANTL_GetSTALinkCapacity */