blob: 2f8a09af32828a6e22b3036892ff660897f8d110 [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
Dino Mycle3b9536d2014-07-09 22:05:24 +0530173#ifdef WLAN_FEATURE_LINK_LAYER_STATS
174extern const v_U8_t WLANTL_TID_2_AC[WLAN_MAX_TID];
175
176#endif
177
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530178#define WLANTL_MAX_SNR_DATA_SAMPLES 20
Jeff Johnson295189b2012-06-20 16:38:30 -0700179
180#ifdef VOLANS_PERF
181#define WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD 120
182#define WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD 120
183
184/* TL BD/PDU threshold to enable interrupt */
185int bdPduInterruptEnableThreshold = WLANTL_BD_PDU_INTERRUPT_ENABLE_THRESHOLD;
186int bdPduInterruptGetThreshold = WLANTL_BD_PDU_INTERRUPT_GET_THRESHOLD;
187#endif /* VOLANS_PERF */
188
189/*-----------------------------------*
190 | Type(2b) | Sub-type(4b) |
191 *-----------------------------------*/
192#define WLANTL_IS_DATA_FRAME(_type_sub) \
193 ( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 ))
194
195#define WLANTL_IS_QOS_DATA_FRAME(_type_sub) \
196 (( WLANTL_DATA_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
197 ( WLANTL_80211_DATA_QOS_SUBTYPE == ( (_type_sub) & 0xF )))
198
199#define WLANTL_IS_MGMT_FRAME(_type_sub) \
200 ( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 ))
201
Dino Mycle3b9536d2014-07-09 22:05:24 +0530202#define WLANTL_IS_MGMT_ACTION_FRAME(_type_sub) \
203 (( WLANTL_MGMT_FRAME_TYPE == ( (_type_sub) & 0x30 )) && \
204 ( ( WLANTL_80211_MGMT_ACTION_SUBTYPE == ( (_type_sub) & 0xF )) || \
205 ( WLANTL_80211_MGMT_ACTION_NO_ACK_SUBTYPE == ( (_type_sub) & 0xF ))))
206
Siddharth Bhal4551b102014-10-09 21:36:36 +0530207#define WLANTL_IS_PROBE_REQ(_type_sub) \
208 ( WLANTL_MGMT_PROBE_REQ_FRAME_TYPE == ( (_type_sub) & 0x3F ))
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210#define WLANTL_IS_CTRL_FRAME(_type_sub) \
211 ( WLANTL_CTRL_FRAME_TYPE == ( (_type_sub) & 0x30 ))
212
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800213#ifdef FEATURE_WLAN_TDLS
214#define WLANTL_IS_TDLS_FRAME(_eth_type) \
215 ( WLANTL_LLC_TDLS_TYPE == ( _eth_type))
216#endif
217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218/*MAX Allowed len processed by TL - MAx MTU + 802.3 header + BD+DXE+XTL*/
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800219#define WLANTL_MAX_ALLOWED_LEN (1514 + 100)
Jeff Johnson295189b2012-06-20 16:38:30 -0700220
221#define WLANTL_MASK_AC 0x03
222
Jeff Johnson295189b2012-06-20 16:38:30 -0700223//some flow_control define
224//LWM mode will be enabled for this station if the egress/ingress falls below this ratio
225#define WLANTL_LWM_EGRESS_INGRESS_THRESHOLD (0.75)
226
227//Get enough sample to do the LWM related calculation
228#define WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD (64)
229
230//Maximal on-fly packet per station in LWM mode
231#define WLANTL_STA_BMU_THRESHOLD_MAX (256)
232
233#define WLANTL_AC_MASK (0x7)
Gopichand Nakkala976e3252013-01-03 15:45:56 -0800234#define WLANTL_STAID_OFFSET (0x6)
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
236/* UINT32 type endian swap */
237#define SWAP_ENDIAN_UINT32(a) ((a) = ((a) >> 0x18 ) |(((a) & 0xFF0000) >> 0x08) | \
238 (((a) & 0xFF00) << 0x08) | (((a) & 0xFF) << 0x18))
239
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +0530240/* Maximum value of SNR that can be calculated by the HW */
241#define WLANTL_MAX_HW_SNR 35
Jeff Johnson295189b2012-06-20 16:38:30 -0700242
Jeff Johnson295189b2012-06-20 16:38:30 -0700243/*----------------------------------------------------------------------------
244 * Type Declarations
245 * -------------------------------------------------------------------------*/
246#define TL_LITTLE_BIT_ENDIAN
247
248typedef struct
249{
250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251
252 v_U8_t protVer :2;
253 v_U8_t type :2;
254 v_U8_t subType :4;
255
256 v_U8_t toDS :1;
257 v_U8_t fromDS :1;
258 v_U8_t moreFrag :1;
259 v_U8_t retry :1;
260 v_U8_t powerMgmt :1;
261 v_U8_t moreData :1;
262 v_U8_t wep :1;
263 v_U8_t order :1;
264
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266} WLANTL_MACFCType;
267
268/* 802.11 header */
269typedef struct
270{
271 /* Frame control field */
272 WLANTL_MACFCType wFrmCtrl;
273
274 /* Duration ID */
275 v_U16_t usDurationId;
276
277 /* Address 1 field */
278 v_U8_t vA1[VOS_MAC_ADDR_SIZE];
279
280 /* Address 2 field */
281 v_U8_t vA2[VOS_MAC_ADDR_SIZE];
282
283 /* Address 3 field */
284 v_U8_t vA3[VOS_MAC_ADDR_SIZE];
285
286 /* Sequence control field */
287 v_U16_t usSeqCtrl;
288
289 // Find the size of the mandatory header size.
290#define WLAN80211_MANDATORY_HEADER_SIZE \
291 (sizeof(WLANTL_MACFCType) + sizeof(v_U16_t) + \
292 (3 * (sizeof(v_U8_t) * VOS_MAC_ADDR_SIZE)) + \
293 sizeof(v_U16_t))
294
295 /* Optional A4 address */
296 v_U8_t optvA4[VOS_MAC_ADDR_SIZE];
297
298 /* Optional QOS control field */
299 v_U16_t usQosCtrl;
300}WLANTL_80211HeaderType;
301
302/* 802.3 header */
303typedef struct
304{
305 /* Destination address field */
306 v_U8_t vDA[VOS_MAC_ADDR_SIZE];
307
308 /* Source address field */
309 v_U8_t vSA[VOS_MAC_ADDR_SIZE];
310
311 /* Length field */
312 v_U16_t usLenType;
313}WLANTL_8023HeaderType;
314
315/*----------------------------------------------------------------------------
316 * Global Data Definitions
317 * -------------------------------------------------------------------------*/
318#define WLAN_TL_INVALID_U_SIG 255
319#define WLAN_TL_INVALID_B_SIG 255
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530320#define ENTER() VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Enter:%s", __func__)
321
Jeff Johnson295189b2012-06-20 16:38:30 -0700322#define WLAN_TL_AC_ARRAY_2_MASK( _pSTA, _ucACMask, i ) \
323 do\
324 {\
325 _ucACMask = 0; \
326 for ( i = 0; i < WLANTL_MAX_AC; i++ ) \
327 { \
328 if ( 0 != (_pSTA)->aucACMask[i] ) \
329 { \
330 _ucACMask |= ( 1 << i ); \
331 } \
332 } \
333 } while (0);
334
335/*----------------------------------------------------------------------------
336 * Static Variable Definitions
337 * -------------------------------------------------------------------------*/
338
339/*----------------------------------------------------------------------------
340 * Static Function Declarations and Definitions
341 * -------------------------------------------------------------------------*/
342
343static VOS_STATUS
344WLANTL_GetEtherType
345(
346 v_U8_t * aucBDHeader,
347 vos_pkt_t * vosDataBuff,
348 v_U8_t ucMPDUHLen,
349 v_U16_t * usEtherType
350);
351
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800352#ifdef FEATURE_WLAN_TDLS_INTERNAL
353/* FIXME_MUST: during TDLS integration to main/latest, WLANTL_GetEtherType() conflicts.
354But there is difference. existing WLANTL_GetEtherType() expects vosDataBuff->offset points to MPDU Header,
355wherease TDLS expect vosDataBuff->offset should still points to RxBd.
356So far, data frmae stripped RxBD and passed to data frame handler.
357(RxBd should not be stripped in case TDLS, because it will be eventually routed to mgmt packet
358handler, where RX BD should be preserved)
359To avoid breaking existing functionality, for now, I temporarily rename to
360WLANTL_GetEtherType_2(). Eventually this function should be removed and merged to WLANTL_GetEtherType()
361*/
362static VOS_STATUS
363WLANTL_GetEtherType_2
364(
365 v_U8_t * aucBDHeader,
366 vos_pkt_t * vosDataBuff,
367 v_U8_t ucMPDUHLen,
368 v_U16_t * usEtherType
369);
370#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700371#ifdef FEATURE_WLAN_WAPI
372/*---------------------------------------------------------------------------
373 * Adding a global variable to be used when doing frame translation in TxAuth
374 * state so as to not set the protected bit to 1 in the case of WAI frames
375 *---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700376v_U8_t gUcIsWai;
Jeff Johnson295189b2012-06-20 16:38:30 -0700377#endif
378
379/*----------------------------------------------------------------------------
380 * Externalized Function Definitions
381* -------------------------------------------------------------------------*/
382
383/*----------------------------------------------------------------------------
384 * Function Declarations and Documentation
385 * -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530386/*==========================================================================
387
388 FUNCTION WLANTL_FreeClientMemory
389
390 DESCRIPTION
391 It frees up the memory allocated to all the STA clients in TLCB block
392 Can be called inside Close, Stop or when some FAULT occurs
393
394 DEPENDENCIES
395
396 PARAMETERS
397
398 IN
399 pClientSTA: Pointer to the global client pointer array
400
401 RETURN VALUE
402
403 SIDE EFFECTS
404
405============================================================================*/
406void WLANTL_FreeClientMemory
407(WLANTL_STAClientType* pClientSTA[WLAN_MAX_STA_COUNT])
408{
409 v_U32_t i = 0;
410 for(i =0; i < WLAN_MAX_STA_COUNT; i++)
411 {
412 if( NULL != pClientSTA[i] )
413 {
414 vos_mem_free(pClientSTA[i]);
415 }
416 pClientSTA[i] = NULL;
417 }
418 return;
419}
Jeff Johnson295189b2012-06-20 16:38:30 -0700420
421/*==========================================================================
422
423 FUNCTION WLANTL_Open
424
425 DESCRIPTION
426 Called by HDD at driver initialization. TL will initialize all its
427 internal resources and will wait for the call to start to register
428 with the other modules.
429
430 DEPENDENCIES
431
432 PARAMETERS
433
434 IN
435 pvosGCtx: pointer to the global vos context; a handle to TL's
436 control block can be extracted from its context
437 pTLConfig: TL Configuration
438
439 RETURN VALUE
440 The result code associated with performing the operation
441
442 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
443 fault
444 VOS_STATUS_SUCCESS: Everything is good :)
445
446 SIDE EFFECTS
447
448============================================================================*/
449VOS_STATUS
450WLANTL_Open
451(
452 v_PVOID_t pvosGCtx,
453 WLANTL_ConfigInfoType* pTLConfig
454)
455{
456 WLANTL_CbType* pTLCb = NULL;
457 v_U8_t ucIndex;
458 tHalHandle smeContext;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530459 v_U32_t i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700460#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
461 VOS_STATUS status = VOS_STATUS_SUCCESS;
462#endif
463 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
464
465 /*------------------------------------------------------------------------
466 Sanity check
467 Extract TL control block
468 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530469 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 vos_alloc_context( pvosGCtx, VOS_MODULE_ID_TL,
471 (void*)&pTLCb, sizeof(WLANTL_CbType));
472
473 pTLCb = VOS_GET_TL_CB(pvosGCtx);
474 if (( NULL == pTLCb ) || ( NULL == pTLConfig ) )
475 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700476 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530477 "WLAN TL: Invalid input pointer on WLANTL_Open TL %p Config %p", pTLCb, pTLConfig ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 return VOS_STATUS_E_FAULT;
479 }
480
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -0700481 /* Set the default log level to VOS_TRACE_LEVEL_ERROR */
482 vos_trace_setLevel(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR);
483
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
485 if ( NULL == smeContext )
486 {
487 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700488 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 return VOS_STATUS_E_FAULT;
490 }
491
492 /* Zero out the memory so we are OK, when CleanCB is called.*/
493 vos_mem_zero((v_VOID_t *)pTLCb, sizeof(WLANTL_CbType));
494
495 /*------------------------------------------------------------------------
496 Clean up TL control block, initialize all values
497 ------------------------------------------------------------------------*/
498 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
499 "WLAN TL:WLANTL_Open"));
500
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530501 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530503 if ( i < WLAN_NON32_STA_COUNT )
504 {
505 pTLCb->atlSTAClients[i] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
506 /* Allocating memory for LEGACY STA COUNT so as to avoid regression issues. */
507 if ( NULL == pTLCb->atlSTAClients[i] )
508 {
509 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN TL: StaClient allocation failed"));
510 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
511 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
512 return VOS_STATUS_E_FAULT;
513 }
514 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[i], sizeof(WLANTL_STAClientType));
515 }
516 else
517 {
518 pTLCb->atlSTAClients[i] = NULL;
519 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 }
521
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 pTLCb->reorderBufferPool = vos_mem_malloc(sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
523 if (NULL == pTLCb->reorderBufferPool)
524 {
Arif Hussainf2b00992013-11-17 21:46:15 -0800525 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 +0530526 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
528 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 }
530
531 vos_mem_zero((v_VOID_t *)pTLCb->reorderBufferPool, sizeof(WLANTL_REORDER_BUFFER_T) * WLANTL_MAX_BA_SESSION);
532
533 WLANTL_CleanCB(pTLCb, 0 /*do not empty*/);
534
535 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
536 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530537 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pTLConfig->ucAcWeights[ucIndex];
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 }
539
Dhanashri Atred8c20a32014-01-03 17:20:55 -0800540 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
541 {
542 pTLCb->tlConfigInfo.ucReorderAgingTime[ucIndex] = pTLConfig->ucReorderAgingTime[ucIndex];
543 }
544
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 // scheduling init to be the last one of previous round
546 pTLCb->uCurServedAC = WLANTL_AC_BK;
547 pTLCb->ucCurLeftWeight = 1;
548 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT-1;
549
550#if 0
551 //flow control field init
552 vos_mem_zero(&pTLCb->tlFCInfo, sizeof(tFcTxParams_type));
553 //bit 0: set (Bd/pdu count) bit 1: set (request station PS change notification)
554 pTLCb->tlFCInfo.fcConfig = 0x1;
555#endif
556
557 pTLCb->vosTxFCBuf = NULL;
558 pTLCb->tlConfigInfo.uMinFramesProcThres =
559 pTLConfig->uMinFramesProcThres;
Jeff Johnson295189b2012-06-20 16:38:30 -0700560
Sunil Ravid5406f22013-01-22 00:18:31 -0800561#ifdef FEATURE_WLAN_TDLS
562 pTLCb->ucTdlsPeerCount = 0;
563#endif
564
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt =
566 pTLConfig->uDelayedTriggerFrmInt;
567
568 /*------------------------------------------------------------------------
569 Allocate internal resources
570 ------------------------------------------------------------------------*/
571 vos_pkt_get_packet(&pTLCb->vosDummyBuf, VOS_PKT_TYPE_RX_RAW, 1, 1,
572 1/*true*/,NULL, NULL);
573
574 WLANTL_InitBAReorderBuffer(pvosGCtx);
575#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
576 /* Initialize Handoff support modue
577 * RSSI measure and Traffic state monitoring */
578 status = WLANTL_HSInit(pvosGCtx);
579 if(!VOS_IS_STATUS_SUCCESS(status))
580 {
581 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
582 "Handoff support module init fail"));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530583 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 vos_mem_free(pTLCb->reorderBufferPool);
585 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
586 return status;
587 }
588#endif
589
590 pTLCb->isBMPS = VOS_FALSE;
591 pmcRegisterDeviceStateUpdateInd( smeContext,
592 WLANTL_PowerStateChangedCB, pvosGCtx );
593
594 return VOS_STATUS_SUCCESS;
595}/* WLANTL_Open */
596
597/*==========================================================================
598
599 FUNCTION WLANTL_Start
600
601 DESCRIPTION
602 Called by HDD as part of the overall start procedure. TL will use this
603 call to register with BAL as a transport layer entity.
604
605 DEPENDENCIES
606
607 PARAMETERS
608
609 IN
610 pvosGCtx: pointer to the global vos context; a handle to TL's
611 control block can be extracted from its context
612
613 RETURN VALUE
614 The result code associated with performing the operation
615
616 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
617 fault
618 VOS_STATUS_SUCCESS: Everything is good :)
619
620 Other codes can be returned as a result of a BAL failure; see BAL API
621 for more info
622
623 SIDE EFFECTS
624
625============================================================================*/
626VOS_STATUS
627WLANTL_Start
628(
629 v_PVOID_t pvosGCtx
630)
631{
632 WLANTL_CbType* pTLCb = NULL;
633 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
634 VOS_STATUS vosStatus;
635 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
636
637 /*------------------------------------------------------------------------
638 Sanity check
639 Extract TL control block
640 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530641 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 pTLCb = VOS_GET_TL_CB(pvosGCtx);
643 if ( NULL == pTLCb )
644 {
645 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
646 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_Start"));
647 return VOS_STATUS_E_FAULT;
648 }
649
650 /*------------------------------------------------------------------------
651 Register with WDA as transport layer client
652 Request resources for tx from bus
653 ------------------------------------------------------------------------*/
654 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
655 "WLAN TL:WLAN TL:WLANTL_Start"));
656
Katya Nigam42e16e82014-02-04 16:28:55 +0530657 tlTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 vosStatus = WDA_DS_Register( pvosGCtx,
659 WLANTL_TxComp,
660 WLANTL_RxFrames,
661 WLANTL_GetFrames,
662 WLANTL_ResourceCB,
663 WDA_TLI_MIN_RES_DATA,
664 pvosGCtx,
665 &uResCount );
666
667 if ( VOS_STATUS_SUCCESS != vosStatus )
668 {
669 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
670 "WLAN TL:TL failed to register with BAL/WDA, Err: %d",
671 vosStatus));
672 return vosStatus;
673 }
674
675 /* Enable transmission */
676 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
677
678 pTLCb->uResCount = uResCount;
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 return VOS_STATUS_SUCCESS;
680}/* WLANTL_Start */
681
682/*==========================================================================
683
684 FUNCTION WLANTL_Stop
685
686 DESCRIPTION
687 Called by HDD to stop operation in TL, before close. TL will suspend all
688 frame transfer operation and will wait for the close request to clean up
689 its resources.
690
691 DEPENDENCIES
692
693 PARAMETERS
694
695 IN
696 pvosGCtx: pointer to the global vos context; a handle to TL's
697 control block can be extracted from its context
698
699 RETURN VALUE
700 The result code associated with performing the operation
701
702 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
703 fault
704 VOS_STATUS_SUCCESS: Everything is good :)
705
706 SIDE EFFECTS
707
708============================================================================*/
709VOS_STATUS
710WLANTL_Stop
711(
712 v_PVOID_t pvosGCtx
713)
714{
715 WLANTL_CbType* pTLCb = NULL;
716 v_U8_t ucIndex;
717 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
718
719 /*------------------------------------------------------------------------
720 Sanity check
721 Extract TL control block
722 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530723 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 pTLCb = VOS_GET_TL_CB(pvosGCtx);
725 if ( NULL == pTLCb )
726 {
727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
728 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
729 return VOS_STATUS_E_FAULT;
730 }
731
732 /*------------------------------------------------------------------------
733 Stop TL and empty Station list
734 ------------------------------------------------------------------------*/
735 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
736 "WLAN TL:WLANTL_Stop"));
737
738 /* Disable transmission */
739 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
740
741 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
742 {
743 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
744 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
745 }
746
747 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
748 {
749 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
750 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
751 }
752
753#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
754 if(VOS_STATUS_SUCCESS != WLANTL_HSStop(pvosGCtx))
755 {
756 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
757 "Handoff Support module stop fail"));
758 }
759#endif
760
761 /*-------------------------------------------------------------------------
762 Clean client stations
763 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530764 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530766 if ( NULL != pTLCb->atlSTAClients[ucIndex] )
767 {
768 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucIndex], 1 /*empty all queues*/);
769 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 }
771
772
773 return VOS_STATUS_SUCCESS;
774}/* WLANTL_Stop */
775
776/*==========================================================================
777
778 FUNCTION WLANTL_Close
779
780 DESCRIPTION
781 Called by HDD during general driver close procedure. TL will clean up
782 all the internal resources.
783
784 DEPENDENCIES
785
786 PARAMETERS
787
788 IN
789 pvosGCtx: pointer to the global vos context; a handle to TL's
790 control block can be extracted from its context
791
792 RETURN VALUE
793 The result code associated with performing the operation
794
795 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a page
796 fault
797 VOS_STATUS_SUCCESS: Everything is good :)
798
799 SIDE EFFECTS
800
801============================================================================*/
802VOS_STATUS
803WLANTL_Close
804(
805 v_PVOID_t pvosGCtx
806)
807{
808 WLANTL_CbType* pTLCb = NULL;
809 tHalHandle smeContext;
810 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
811
812 /*------------------------------------------------------------------------
813 Sanity check
814 Extract TL control block
815 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530816 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 pTLCb = VOS_GET_TL_CB(pvosGCtx);
818 if ( NULL == pTLCb )
819 {
820 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
821 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
822 return VOS_STATUS_E_FAULT;
823 }
824 /*------------------------------------------------------------------------
825 Deregister from PMC
826 ------------------------------------------------------------------------*/
827 smeContext = vos_get_context(VOS_MODULE_ID_SME, pvosGCtx);
828 if ( NULL == smeContext )
829 {
830 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700831 "%s: Invalid smeContext", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 // continue so that we can cleanup as much as possible
833 }
834 else
835 {
836 pmcDeregisterDeviceStateUpdateInd( smeContext, WLANTL_PowerStateChangedCB );
837 }
838
839#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
840 if(VOS_STATUS_SUCCESS != WLANTL_HSDeInit(pvosGCtx))
841 {
842 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
843 "Handoff Support module DeInit fail"));
844 }
845#endif
846
847 /*------------------------------------------------------------------------
848 Cleanup TL control block.
849 ------------------------------------------------------------------------*/
850 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
851 "WLAN TL: WLANTL_Close"));
852 WLANTL_CleanCB(pTLCb, 1 /* empty queues/lists/pkts if any*/);
853
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530854 WLANTL_FreeClientMemory(pTLCb->atlSTAClients);
855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 vos_mem_free(pTLCb->reorderBufferPool);
857
858 /*------------------------------------------------------------------------
859 Free TL context from VOSS global
860 ------------------------------------------------------------------------*/
861 vos_free_context(pvosGCtx, VOS_MODULE_ID_TL, pTLCb);
862 return VOS_STATUS_SUCCESS;
863}/* WLANTL_Close */
864
865/*----------------------------------------------------------------------------
866 INTERACTION WITH HDD
867 ---------------------------------------------------------------------------*/
868/*==========================================================================
869
870 FUNCTION WLANTL_ConfigureSwFrameTXXlationForAll
871
872 DESCRIPTION
873 Function to disable/enable frame translation for all association stations.
874
875 DEPENDENCIES
876
877 PARAMETERS
878 IN
879 pvosGCtx: VOS context
880 EnableFrameXlation TRUE means enable SW translation for all stations.
881 .
882
883 RETURN VALUE
884
885 void.
886
887============================================================================*/
888void
889WLANTL_ConfigureSwFrameTXXlationForAll
890(
891 v_PVOID_t pvosGCtx,
892 v_BOOL_t enableFrameXlation
893)
894{
895 v_U8_t ucIndex;
896 /*------------------------------------------------------------------------
897 Extract TL control block
898 ------------------------------------------------------------------------*/
899 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530900 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if ( NULL == pTLCb )
902 {
903 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
904 "WLAN TL:Invalid TL pointer from pvosGCtx on "
905 "WLANTL_ConfigureSwFrameTXXlationForAll"));
906 return;
907 }
908
909 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
910 "WLANTL_ConfigureSwFrameTXXlationForAll: Configure SW frameXlation %d",
911 enableFrameXlation));
912
913 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID; ucIndex++)
914 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530915 pClientSTA = pTLCb->atlSTAClients[ucIndex];
916 if ( NULL != pClientSTA && 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 {
918#ifdef WLAN_SOFTAP_VSTA_FEATURE
919 // if this station was not allocated resources to perform HW-based
920 // TX frame translation then force SW-based TX frame translation
921 // otherwise use the frame translation supplied by the client
922 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, ucIndex))
923 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530924 pClientSTA->wSTADesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 }
926 else
927#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +0530928 pClientSTA->wSTADesc.ucSwFrameTXXlation = enableFrameXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 }
930 }
931}
932
933/*===========================================================================
934
935 FUNCTION WLANTL_StartForwarding
936
937 DESCRIPTION
938
939 This function is used to ask serialization through TX thread of the
940 cached frame forwarding (if statation has been registered in the mean while)
941 or flushing (if station has not been registered by the time)
942
943 In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
944 and doesn't need to call this function explicitly. TL will handle this inside
945 WLANTL_RegisterSTAClient().
946
947 In case of flushing, upper layer is required to call this function explicitly
948
949 DEPENDENCIES
950
951 TL must have been initialized before this gets called.
952
953
954 PARAMETERS
955
956 ucSTAId: station id
957
958 RETURN VALUE
959
960 The result code associated with performing the operation
961 Please check return values of vos_tx_mq_serialize.
962
963 SIDE EFFECTS
964 If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
965 either WLANTL_RegisterSTAClient() or this function must be called
966 within reasonable time. Otherwise, TL will keep cached vos buffer until
967 one of this function is called, and may end up with system buffer exhasution.
968
969 It's an upper layer's responsibility to call this function in case of
970 flushing
971
972============================================================================*/
973
974VOS_STATUS
975WLANTL_StartForwarding
976(
977 v_U8_t ucSTAId,
978 v_U8_t ucUcastSig,
979 v_U8_t ucBcastSig
980)
981{
982 vos_msg_t sMessage;
983 v_U32_t uData;
984 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
985
986 /* Signal the OS to serialize our event */
987 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
988 "Serializing TL Start Forwarding Cached for control STA %d",
989 ucSTAId );
990
991 vos_mem_zero( &sMessage, sizeof(vos_msg_t) );
992
993 uData = ucSTAId | (ucUcastSig << 8 ) | (ucBcastSig << 16);
Jeff Johnsond86c05a2013-11-10 18:50:34 -0800994 sMessage.bodyval = uData;
Katya Nigam664f5032014-05-05 12:24:32 +0530995 sMessage.type = WLANTL_RX_FWD_CACHED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
Katya Nigam664f5032014-05-05 12:24:32 +0530997 return vos_rx_mq_serialize(VOS_MQ_ID_TL, &sMessage);
Jeff Johnson295189b2012-06-20 16:38:30 -0700998
999} /* WLANTL_StartForwarding() */
1000
1001/*===========================================================================
1002
Katya Nigam63902932014-06-26 19:04:23 +05301003 FUNCTION WLANTL_EnableCaching
1004
1005 DESCRIPTION
1006
1007 This function is used to enable caching only when assoc/reassoc req is send.
1008 that is cache packets only for such STA ID.
1009
1010
1011 DEPENDENCIES
1012
1013 TL must have been initialized before this gets called.
1014
1015
1016 PARAMETERS
1017
1018 staId: station id
1019
1020 RETURN VALUE
1021
1022 none
1023
1024============================================================================*/
1025void WLANTL_EnableCaching(v_U8_t staId)
1026{
1027 v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
1028 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
1029 if ( NULL == pTLCb )
1030 {
1031 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1032 "WLAN TL:Invalid TL pointer from pvosGCtx on "
1033 "WLANTL_EnableCaching"));
1034 return;
1035 }
1036 pTLCb->atlSTAClients[staId]->enableCaching = 1;
1037}
1038
1039/*===========================================================================
1040
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 FUNCTION WLANTL_AssocFailed
1042
1043 DESCRIPTION
1044
1045 This function is used by PE to notify TL that cache needs to flushed'
1046 when association is not successfully completed
1047
1048 Internally, TL post a message to TX_Thread to serialize the request to
1049 keep lock-free mechanism.
1050
1051
1052 DEPENDENCIES
1053
1054 TL must have been initialized before this gets called.
1055
1056
1057 PARAMETERS
1058
1059 ucSTAId: station id
1060
1061 RETURN VALUE
1062
1063 none
1064
1065 SIDE EFFECTS
1066 There may be race condition that PE call this API and send another association
1067 request immediately with same staId before TX_thread can process the message.
1068
1069 To avoid this, we might need PE to wait for TX_thread process the message,
1070 but this is not currently implemented.
1071
1072============================================================================*/
1073void WLANTL_AssocFailed(v_U8_t staId)
1074{
1075 // flushing frames and forwarding frames uses the same message
1076 // the only difference is what happens when the message is processed
1077 // if the STA exist, the frames will be forwarded
1078 // and if it doesn't exist, the frames will be flushed
1079 // 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 +05301080 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_ASSOC_FAILED,
1081 staId, 0));
1082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding(staId,0,0)))
1084 {
1085 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mihir Sheteb7337272014-04-11 15:53:08 +05301086 " %s fails to start forwarding (staId %d)", __func__, staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 }
1088}
1089
1090 /*===========================================================================
1091
1092 FUNCTION WLANTL_Finish_ULA
1093
1094 DESCRIPTION
1095 This function is used by HDD to notify TL to finish Upper layer authentication
1096 incase the last EAPOL packet is pending in the TL queue.
1097 To avoid the race condition between sme set key and the last EAPOL packet
1098 the HDD module calls this function just before calling the sme_RoamSetKey.
1099
1100 DEPENDENCIES
1101
1102 TL must have been initialized before this gets called.
1103
1104 PARAMETERS
1105
1106 callbackRoutine: HDD Callback function.
1107 callbackContext : HDD userdata context.
1108
1109 RETURN VALUE
1110
1111 VOS_STATUS_SUCCESS/VOS_STATUS_FAILURE
1112
1113 SIDE EFFECTS
1114
1115============================================================================*/
1116
1117VOS_STATUS WLANTL_Finish_ULA( void (*callbackRoutine) (void *callbackContext),
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001118 void *callbackContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07001119{
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001120 return WDA_DS_FinishULA( callbackRoutine, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001121}
1122
1123
1124/*===========================================================================
1125
1126 FUNCTION WLANTL_RegisterSTAClient
1127
1128 DESCRIPTION
1129
1130 This function is used by HDD to register as a client for data services
1131 with TL. HDD will call this API for each new station that it adds,
1132 thus having the flexibility of registering different callback for each
1133 STA it services.
1134
1135 DEPENDENCIES
1136
1137 TL must have been initialized before this gets called.
1138
1139 Restriction:
1140 Main thread will have higher priority that Tx and Rx threads thus
1141 guaranteeing that a station will be added before any data can be
1142 received for it. (This enables TL to be lock free)
1143
1144 PARAMETERS
1145
1146 pvosGCtx: pointer to the global vos context; a handle to TL's
1147 control block can be extracted from its context
1148 pfnStARx: function pointer to the receive packet handler from HDD
1149 pfnSTATxComp: function pointer to the transmit complete confirmation
1150 handler from HDD
1151 pfnSTAFetchPkt: function pointer to the packet retrieval routine in HDD
1152 wSTADescType: STA Descriptor, contains information related to the
1153 new added STA
1154
1155 RETURN VALUE
1156
1157 The result code associated with performing the operation
1158
1159 VOS_STATUS_E_INVAL: Input parameters are invalid
1160 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1161 TL cb is NULL ; access would cause a page fault
1162 VOS_STATUS_E_EXISTS: Station was already registered
1163 VOS_STATUS_SUCCESS: Everything is good :)
1164
1165 SIDE EFFECTS
1166
1167============================================================================*/
1168VOS_STATUS
1169WLANTL_RegisterSTAClient
1170(
1171 v_PVOID_t pvosGCtx,
1172 WLANTL_STARxCBType pfnSTARx,
1173 WLANTL_TxCompCBType pfnSTATxComp,
1174 WLANTL_STAFetchPktCBType pfnSTAFetchPkt,
1175 WLAN_STADescType* pwSTADescType,
1176 v_S7_t rssi
1177)
1178{
1179 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301180 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 v_U8_t ucTid = 0;/*Local variable to clear previous replay counters of STA on all TIDs*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1183
1184 /*------------------------------------------------------------------------
1185 Sanity check
1186 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301187 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 if (( NULL == pwSTADescType ) || ( NULL == pfnSTARx ) ||
1189 ( NULL == pfnSTAFetchPkt ))
1190 {
1191 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1192 "WLAN TL:Invalid parameter sent on WLANTL_RegisterSTAClient"));
1193 return VOS_STATUS_E_INVAL;
1194 }
1195
1196 if ( WLANTL_STA_ID_INVALID( pwSTADescType->ucSTAId ) )
1197 {
1198 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1199 "WLAN TL:Invalid station id requested on WLANTL_RegisterSTAClient"));
1200 return VOS_STATUS_E_FAULT;
1201 }
1202
1203 /*------------------------------------------------------------------------
1204 Extract TL control block
1205 ------------------------------------------------------------------------*/
1206 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1207 if ( NULL == pTLCb )
1208 {
1209 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1210 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterSTAClient"));
1211 return VOS_STATUS_E_FAULT;
1212 }
1213
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301214 //Code for checking and allocating memory for new STA
1215 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1216 pTLCb->atlSTAClients[pwSTADescType->ucSTAId] = vos_mem_malloc(sizeof(WLANTL_STAClientType));
1217 if ( NULL == pTLCb->atlSTAClients[pwSTADescType->ucSTAId] ){
1218 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1219 "WLAN TL: STA Client memory allocation failed in WLANTL_RegisterSTAClient"));
1220 return VOS_STATUS_E_FAILURE;
1221 }
1222 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
1223 "WLAN TL: STA Client memory allocation in WLANTL_RegisterSTAClient"));
1224 vos_mem_zero((v_VOID_t *) pTLCb->atlSTAClients[pwSTADescType->ucSTAId],sizeof(WLANTL_STAClientType));
1225 }
1226
1227 //Assigning the pointer to local variable for easy access in future
1228 pClientSTA = pTLCb->atlSTAClients[pwSTADescType->ucSTAId];
1229 if ( 0 != pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301231 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1233 "WLAN TL:Station was already registered on WLANTL_RegisterSTAClient"));
1234 return VOS_STATUS_E_EXISTS;
1235 }
1236
1237 /*------------------------------------------------------------------------
1238 Register station with TL
1239 ------------------------------------------------------------------------*/
Katya Nigam42e16e82014-02-04 16:28:55 +05301240 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_REGISTER_STA_CLIENT,
1241 pwSTADescType->ucSTAId, (unsigned )
1242 (*(pwSTADescType->vSTAMACAddress.bytes+2)<<24 |
1243 *(pwSTADescType->vSTAMACAddress.bytes+3)<<16 |
1244 *(pwSTADescType->vSTAMACAddress.bytes+4)<<8 |
1245 *(pwSTADescType->vSTAMACAddress.bytes+5))));
1246
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1248 "WLAN TL:Registering STA Client ID: %d", pwSTADescType->ucSTAId ));
1249
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301250 pClientSTA->pfnSTARx = pfnSTARx;
1251 pClientSTA->pfnSTAFetchPkt = pfnSTAFetchPkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001252
1253 /* Only register if different from NULL - TL default Tx Comp Cb will
1254 release the vos packet */
1255 if ( NULL != pfnSTATxComp )
1256 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301257 pClientSTA->pfnSTATxComp = pfnSTATxComp;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 }
1259
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301260 pClientSTA->tlState = WLANTL_STA_INIT;
1261 pClientSTA->tlPri = WLANTL_STA_PRI_NORMAL;
1262 pClientSTA->wSTADesc.ucSTAId = pwSTADescType->ucSTAId;
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301263 pClientSTA->ptkInstalled = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001264
1265 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1266 "WLAN TL:Registering STA Client ID: %d with UC %d and BC %d",
1267 pwSTADescType->ucSTAId,
1268 pwSTADescType->ucUcastSig, pwSTADescType->ucBcastSig));
1269
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301270 pClientSTA->wSTADesc.wSTAType = pwSTADescType->wSTAType;
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301272 pClientSTA->wSTADesc.ucQosEnabled = pwSTADescType->ucQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001273
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301274 pClientSTA->wSTADesc.ucAddRmvLLC = pwSTADescType->ucAddRmvLLC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001275
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301276 pClientSTA->wSTADesc.ucProtectedFrame = pwSTADescType->ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07001277
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001278#ifdef FEATURE_WLAN_ESE
1279 pClientSTA->wSTADesc.ucIsEseSta = pwSTADescType->ucIsEseSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001280
1281 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001282 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d EseSta %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 pwSTADescType->ucSTAId,
1284 pwSTADescType->ucQosEnabled,
1285 pwSTADescType->ucAddRmvLLC,
1286 pwSTADescType->ucProtectedFrame,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001287 pwSTADescType->ucIsEseSta));
Jeff Johnson295189b2012-06-20 16:38:30 -07001288#else
1289
1290 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1291 "WLAN TL:Registering STA Client ID: %d QoS %d Add LLC %d ProtFrame %d",
1292 pwSTADescType->ucSTAId,
1293 pwSTADescType->ucQosEnabled,
1294 pwSTADescType->ucAddRmvLLC,
1295 pwSTADescType->ucProtectedFrame));
1296
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001297#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001298#ifdef WLAN_SOFTAP_VSTA_FEATURE
1299 // if this station was not allocated resources to perform HW-based
1300 // TX frame translation then force SW-based TX frame translation
1301 // otherwise use the frame translation supplied by the client
1302
1303 if (!WDA_IsHwFrameTxTranslationCapable(pvosGCtx, pwSTADescType->ucSTAId)
1304 || ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType))
1305 {
1306 pwSTADescType->ucSwFrameTXXlation = 1;
1307 }
1308#endif
1309
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301310 pClientSTA->wSTADesc.ucSwFrameTXXlation = pwSTADescType->ucSwFrameTXXlation;
1311 pClientSTA->wSTADesc.ucSwFrameRXXlation = pwSTADescType->ucSwFrameRXXlation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001312
1313#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301314 pClientSTA->wSTADesc.ucIsWapiSta = pwSTADescType->ucIsWapiSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07001315#endif /* FEATURE_WLAN_WAPI */
1316
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301317 vos_copy_macaddr( &pClientSTA->wSTADesc.vSTAMACAddress, &pwSTADescType->vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001318
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301319 vos_copy_macaddr( &pClientSTA->wSTADesc.vBSSIDforIBSS, &pwSTADescType->vBSSIDforIBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301321 vos_copy_macaddr( &pClientSTA->wSTADesc.vSelfMACAddress, &pwSTADescType->vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 /* In volans release L replay check is done at TL */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301324 pClientSTA->ucIsReplayCheckValid = pwSTADescType->ucIsReplayCheckValid;
1325 pClientSTA->ulTotalReplayPacketsDetected = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001326/*Clear replay counters of the STA on all TIDs*/
1327 for(ucTid = 0; ucTid < WLANTL_MAX_TID ; ucTid++)
1328 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301329 pClientSTA->ullReplayCounter[ucTid] = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001331
1332 /*--------------------------------------------------------------------
1333 Set the AC for the registered station to the highest priority AC
1334 Even if this AC is not supported by the station, correction will be
1335 made in the main TL loop after the supported mask is properly
1336 updated in the pending packets call
1337 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301338 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
1339 pClientSTA->ucCurrentWeight = 0;
1340 pClientSTA->ucServicedAC = WLANTL_AC_BK;
1341 pClientSTA->ucEapolPktPending = 0;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07001342
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301343 vos_mem_zero( pClientSTA->aucACMask, sizeof(pClientSTA->aucACMask));
Jeff Johnson295189b2012-06-20 16:38:30 -07001344
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301345 vos_mem_zero( &pClientSTA->wUAPSDInfo, sizeof(pClientSTA->wUAPSDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001346
1347 /*--------------------------------------------------------------------
1348 Reordering info and AMSDU de-aggregation
1349 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301350 vos_mem_zero( pClientSTA->atlBAReorderInfo,
1351 sizeof(pClientSTA->atlBAReorderInfo[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 WLAN_MAX_TID);
1353
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301354 vos_mem_zero( pClientSTA->aucMPDUHeader,
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 WLANTL_MPDU_HEADER_LEN);
1356
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301357 pClientSTA->ucMPDUHeaderLen = 0;
1358 pClientSTA->vosAMSDUChain = NULL;
1359 pClientSTA->vosAMSDUChainRoot = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360
1361
Leo Chang6b6faaf2014-01-24 21:21:26 -08001362 /* Reorder LOCK
1363 * During handle normal RX frame within RX thread,
1364 * if MC thread try to preempt, ADDBA, DELBA, TIMER
1365 * Context should be protected from race */
1366 for (ucTid = 0; ucTid < WLAN_MAX_TID ; ucTid++)
1367 {
1368 if (!VOS_IS_STATUS_SUCCESS(
1369 vos_lock_init(&pClientSTA->atlBAReorderInfo[ucTid].reorderLock)))
1370 {
1371 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1372 "Lock Init Fail"));
1373 return VOS_STATUS_E_FAILURE;
1374 }
1375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 /*--------------------------------------------------------------------
1377 Stats info
1378 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301379 vos_mem_zero( pClientSTA->auRxCount,
1380 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 WLAN_MAX_TID);
1382
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301383 vos_mem_zero( pClientSTA->auTxCount,
1384 sizeof(pClientSTA->auRxCount[0])*
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 WLAN_MAX_TID);
1386 /* Initial RSSI is always reported as zero because TL doesnt have enough
1387 data to calculate RSSI. So to avoid reporting zero, we are initializing
1388 RSSI with RSSI saved in BssDescription during scanning. */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301389 pClientSTA->rssiAvg = rssi;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001390#ifdef FEATURE_WLAN_TDLS
1391 if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
1392 {
1393 /* If client is TDLS, use TDLS specific alpha */
1394 pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
1395 }
1396 else
1397 {
1398 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1399 }
1400#else
1401 pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
1402#endif /* FEATURE_WLAN_TDLS */
Dino Mycle3b9536d2014-07-09 22:05:24 +05301403#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1404 pClientSTA->rssiDataAlpha = WLANTL_HO_DEFAULT_ALPHA;
1405 pClientSTA->interfaceStats.accessCategoryStats[0].ac = WLANTL_AC_BK;
1406 pClientSTA->interfaceStats.accessCategoryStats[1].ac = WLANTL_AC_BE;
1407 pClientSTA->interfaceStats.accessCategoryStats[2].ac = WLANTL_AC_VI;
1408 pClientSTA->interfaceStats.accessCategoryStats[3].ac = WLANTL_AC_VO;
1409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001410
1411 /*Tx not suspended and station fully registered*/
1412 vos_atomic_set_U8(
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301413 &pClientSTA->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001414
1415 /* Used until multiple station support will be added*/
1416 pTLCb->ucRegisteredStaId = pwSTADescType->ucSTAId;
1417
1418 /* Save the BAP station ID for future usage */
1419 if ( WLAN_STA_BT_AMP == pwSTADescType->wSTAType )
1420 {
1421 pTLCb->tlBAPClient.ucBAPSTAId = pwSTADescType->ucSTAId;
1422 }
1423
1424 /*------------------------------------------------------------------------
1425 Statistics info
1426 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301427 memset(&pClientSTA->trafficStatistics,
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 0, sizeof(WLANTL_TRANSFER_STA_TYPE));
1429
1430
1431 /*------------------------------------------------------------------------
1432 Start with the state suggested by client caller
1433 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05301434 pClientSTA->tlState = pwSTADescType->ucInitState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 /*-----------------------------------------------------------------------
1436 After all the init is complete we can mark the existance flag
1437 ----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301438 pClientSTA->ucExists++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001439
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 //flow control fields init
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301441 pClientSTA->ucLwmModeEnabled = FALSE;
1442 pClientSTA->ucLwmEventReported = FALSE;
1443 pClientSTA->bmuMemConsumed = 0;
1444 pClientSTA->uIngress_length = 0;
1445 pClientSTA->uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX;
Jeff Johnson295189b2012-06-20 16:38:30 -07001446
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301447 pClientSTA->uLwmThreshold = WLANTL_STA_BMU_THRESHOLD_MAX / 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07001448
1449 //@@@ HDDSOFTAP does not queue unregistered packet for now
1450 if ( WLAN_STA_SOFTAP != pwSTADescType->wSTAType )
1451 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 /*------------------------------------------------------------------------
1453 Forward received frames while STA was not yet registered
1454 - ----------------------------------------------------------------------*/
1455 if(!VOS_IS_STATUS_SUCCESS(WLANTL_StartForwarding( pwSTADescType->ucSTAId,
1456 pwSTADescType->ucUcastSig,
1457 pwSTADescType->ucBcastSig)))
1458 {
1459 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001460 " %s fails to start forwarding", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 }
Sunil Ravid5406f22013-01-22 00:18:31 -08001462#ifdef FEATURE_WLAN_TDLS
1463 if( WLAN_STA_TDLS == pwSTADescType->wSTAType )
1464 pTLCb->ucTdlsPeerCount++;
1465#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 return VOS_STATUS_SUCCESS;
1468}/* WLANTL_RegisterSTAClient */
1469
1470/*===========================================================================
1471
1472 FUNCTION WLANTL_ClearSTAClient
1473
1474 DESCRIPTION
1475
1476 HDD will call this API when it no longer needs data services for the
1477 particular station.
1478
1479 DEPENDENCIES
1480
1481 A station must have been registered before the clear registration is
1482 called.
1483
1484 PARAMETERS
1485
1486 pvosGCtx: pointer to the global vos context; a handle to TL's
1487 control block can be extracted from its context
1488 ucSTAId: identifier for the STA to be cleared
1489
1490 RETURN VALUE
1491
1492 The result code associated with performing the operation
1493
1494 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1495 TL cb is NULL ; access would cause a page fault
1496 VOS_STATUS_E_EXISTS: Station was not registered
1497 VOS_STATUS_SUCCESS: Everything is good :)
1498
1499 SIDE EFFECTS
1500
1501============================================================================*/
1502VOS_STATUS
1503WLANTL_ClearSTAClient
1504(
1505 v_PVOID_t pvosGCtx,
1506 v_U8_t ucSTAId
1507)
1508{
1509 WLANTL_CbType* pTLCb = NULL;
1510 v_U8_t ucIndex;
1511 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1512
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301513 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 /*------------------------------------------------------------------------
1515 Sanity check
1516 ------------------------------------------------------------------------*/
1517 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1518 {
1519 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1520 "WLAN TL:Invalid station id requested on WLANTL_ClearSTAClient"));
1521 return VOS_STATUS_E_FAULT;
1522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 /*------------------------------------------------------------------------
1524 Extract TL control block
1525 ------------------------------------------------------------------------*/
1526 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1527 if ( NULL == pTLCb )
1528 {
1529 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1530 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ClearSTAClient"));
1531 return VOS_STATUS_E_FAULT;
1532 }
1533
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301534 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1535 {
1536 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1537 "WLAN TL:Client Memory was not allocated on %s", __func__));
1538 return VOS_STATUS_E_FAILURE;
1539 }
1540
1541 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 {
1543 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1544 "WLAN TL:Station was not previously registered on WLANTL_ClearSTAClient"));
Siddharth Bhalaef8ee12014-04-02 00:09:45 +05301545 /* Clean packets cached for the STA */
1546 WLANTL_StartForwarding(ucSTAId,0,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 return VOS_STATUS_E_EXISTS;
1548 }
1549
1550 /* Delete BA sessions on all TID's */
Leo Chang6b6faaf2014-01-24 21:21:26 -08001551 for (ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 {
Leo Chang6b6faaf2014-01-24 21:21:26 -08001553 WLANTL_BaSessionDel(pvosGCtx, ucSTAId, ucIndex);
1554 vos_lock_destroy(&pTLCb->atlSTAClients[ucSTAId]->atlBAReorderInfo[ucIndex].reorderLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 }
1556
Sunil Ravid5406f22013-01-22 00:18:31 -08001557#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301558 /* decrement ucTdlsPeerCount only if it is non-zero */
1559 if(WLAN_STA_TDLS == pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType
Sunil Ravid5406f22013-01-22 00:18:31 -08001560 && pTLCb->ucTdlsPeerCount)
1561 pTLCb->ucTdlsPeerCount--;
1562#endif
1563
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 /*------------------------------------------------------------------------
1565 Clear station
1566 ------------------------------------------------------------------------*/
1567 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1568 "WLAN TL:Clearing STA Client ID: %d", ucSTAId ));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301569 WLANTL_CleanSTA(pTLCb->atlSTAClients[ucSTAId], 1 /*empty packets*/);
Jeff Johnson295189b2012-06-20 16:38:30 -07001570
1571 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1572 "WLAN TL:Clearing STA Reset History RSSI and Region number"));
1573 pTLCb->hoSupport.currentHOState.historyRSSI = 0;
1574 pTLCb->hoSupport.currentHOState.regionNumber = 0;
1575
1576 return VOS_STATUS_SUCCESS;
1577}/* WLANTL_ClearSTAClient */
1578
1579/*===========================================================================
1580
1581 FUNCTION WLANTL_ChangeSTAState
1582
1583 DESCRIPTION
1584
1585 HDD will make this notification whenever a change occurs in the
1586 connectivity state of a particular STA.
1587
1588 DEPENDENCIES
1589
1590 A station must have been registered before the change state can be
1591 called.
1592
1593 RESTRICTION: A station is being notified as authenticated before the
1594 keys are installed in HW. This way if a frame is received
1595 before the keys are installed DPU will drop that frame.
1596
1597 Main thread has higher priority that Tx and Rx threads thus guaranteeing
1598 the following:
1599 - a station will be in assoc state in TL before TL receives any data
1600 for it
1601
1602 PARAMETERS
1603
1604 pvosGCtx: pointer to the global vos context; a handle to TL's
1605 control block can be extracted from its context
1606 ucSTAId: identifier for the STA that is pending transmission
1607 tlSTAState: the new state of the connection to the given station
1608
1609
1610 RETURN VALUE
1611
1612 The result code associated with performing the operation
1613
1614 VOS_STATUS_E_INVAL: Input parameters are invalid
1615 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1616 TL cb is NULL ; access would cause a page fault
1617 VOS_STATUS_E_EXISTS: Station was not registered
1618 VOS_STATUS_SUCCESS: Everything is good :)
1619
1620 SIDE EFFECTS
1621
1622============================================================================*/
1623VOS_STATUS
1624WLANTL_ChangeSTAState
1625(
1626 v_PVOID_t pvosGCtx,
1627 v_U8_t ucSTAId,
1628 WLANTL_STAStateType tlSTAState
1629)
1630{
1631 WLANTL_CbType* pTLCb = NULL;
1632 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1633
1634 /*------------------------------------------------------------------------
1635 Sanity check
1636 ------------------------------------------------------------------------*/
1637 if ( tlSTAState >= WLANTL_STA_MAX_STATE )
1638 {
1639 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1640 "WLAN TL:Invalid parameter sent on WLANTL_ChangeSTAState"));
1641 return VOS_STATUS_E_INVAL;
1642 }
1643
1644 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1645 {
1646 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1647 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1648 return VOS_STATUS_E_FAULT;
1649 }
1650
1651 /*------------------------------------------------------------------------
1652 Extract TL control block and check existance
1653 ------------------------------------------------------------------------*/
1654 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1655 if ( NULL == pTLCb )
1656 {
1657 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1658 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
1659 return VOS_STATUS_E_FAULT;
1660 }
1661
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301662 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1663 {
1664 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1665 "WLAN TL:Client Memory was not allocated on %s", __func__));
1666 return VOS_STATUS_E_FAILURE;
1667 }
1668
1669 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 {
1671 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1672 "WLAN TL:Station was not previously registered on WLANTL_ChangeSTAState"));
1673 return VOS_STATUS_E_EXISTS;
1674 }
1675
1676 /*------------------------------------------------------------------------
1677 Change STA state
1678 No need to lock this operation, see restrictions above
1679 ------------------------------------------------------------------------*/
1680 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1681 "WLAN TL:Changing state for STA Client ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301682 ucSTAId, pTLCb->atlSTAClients[ucSTAId]->tlState, tlSTAState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001683
Katya Nigam42e16e82014-02-04 16:28:55 +05301684 MTRACE(vos_trace(VOS_MODULE_ID_TL,
1685 TRACE_CODE_TL_STA_STATE, ucSTAId,tlSTAState ));
1686
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301687 pTLCb->atlSTAClients[ucSTAId]->tlState = tlSTAState;
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
1689 return VOS_STATUS_SUCCESS;
1690}/* WLANTL_ChangeSTAState */
1691
1692/*===========================================================================
1693
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05301694 FUNCTION WLANTL_STAPtkInstalled
1695
1696 DESCRIPTION
1697
1698 HDD will make this notification whenever PTK is installed for the STA
1699
1700 DEPENDENCIES
1701
1702 A station must have been registered before the change state can be
1703 called.
1704
1705 PARAMETERS
1706
1707 pvosGCtx: pointer to the global vos context; a handle to TL's
1708 control block can be extracted from its context
1709 ucSTAId: identifier for the STA for which Pairwise key is
1710 installed
1711
1712 RETURN VALUE
1713
1714 The result code associated with performing the operation
1715
1716 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1717 TL cb is NULL ; access would cause a page fault
1718 VOS_STATUS_E_EXISTS: Station was not registered
1719 VOS_STATUS_SUCCESS: Everything is good :)
1720
1721 SIDE EFFECTS
1722
1723============================================================================*/
1724VOS_STATUS
1725WLANTL_STAPtkInstalled
1726(
1727 v_PVOID_t pvosGCtx,
1728 v_U8_t ucSTAId
1729)
1730{
1731 WLANTL_CbType* pTLCb = NULL;
1732 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1733
1734 /*------------------------------------------------------------------------
1735 Sanity check
1736 ------------------------------------------------------------------------*/
1737
1738 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1739 {
1740 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1741 "WLAN TL:Invalid station id requested on WLANTL_ChangeSTAState"));
1742 return VOS_STATUS_E_FAULT;
1743 }
1744
1745 /*------------------------------------------------------------------------
1746 Extract TL control block and check existance
1747 ------------------------------------------------------------------------*/
1748 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1749 if ( NULL == pTLCb )
1750 {
1751 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1752 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
1753 return VOS_STATUS_E_FAULT;
1754 }
1755
1756 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1757 {
1758 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1759 FL("WLAN TL:Client Memory was not allocated")));
1760 return VOS_STATUS_E_FAILURE;
1761 }
1762
1763 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1764 {
1765 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1766 FL("WLAN TL:Station was not previously registered")));
1767 return VOS_STATUS_E_EXISTS;
1768 }
1769
1770 pTLCb->atlSTAClients[ucSTAId]->ptkInstalled = 1;
1771
1772 return VOS_STATUS_SUCCESS;
1773}/* WLANTL_STAPtkInstalled */
1774
1775/*===========================================================================
1776
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001777 FUNCTION WLANTL_GetSTAState
1778
1779 DESCRIPTION
1780
1781 Returns connectivity state of a particular STA.
1782
1783 DEPENDENCIES
1784
1785 A station must have been registered before its state can be retrieved.
1786
1787
1788 PARAMETERS
1789
1790 IN
1791 pvosGCtx: pointer to the global vos context; a handle to TL's
1792 control block can be extracted from its context
1793 ucSTAId: identifier of the station
1794
1795 OUT
1796 ptlSTAState: the current state of the connection to the given station
1797
1798
1799 RETURN VALUE
1800
1801 The result code associated with performing the operation
1802
1803 VOS_STATUS_E_INVAL: Input parameters are invalid
1804 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1805 TL cb is NULL ; access would cause a page fault
1806 VOS_STATUS_E_EXISTS: Station was not registered
1807 VOS_STATUS_SUCCESS: Everything is good :)
1808
1809 SIDE EFFECTS
1810
1811============================================================================*/
1812VOS_STATUS
1813WLANTL_GetSTAState
1814(
1815 v_PVOID_t pvosGCtx,
1816 v_U8_t ucSTAId,
1817 WLANTL_STAStateType *ptlSTAState
1818)
1819{
1820 WLANTL_CbType* pTLCb = NULL;
1821 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1822
1823 /*------------------------------------------------------------------------
1824 Sanity check
1825 ------------------------------------------------------------------------*/
1826 if ( NULL == ptlSTAState )
1827 {
1828 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1829 "WLAN TL:Invalid parameter sent on WLANTL_GetSTAState"));
1830 return VOS_STATUS_E_INVAL;
1831 }
1832
1833 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1834 {
1835 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1836 "WLAN TL:Invalid station id requested on WLANTL_GetSTAState"));
1837 return VOS_STATUS_E_FAULT;
1838 }
1839
1840 /*------------------------------------------------------------------------
1841 Extract TL control block and check existance
1842 ------------------------------------------------------------------------*/
1843 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1844 if ( NULL == pTLCb )
1845 {
1846 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1847 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetSTAState"));
1848 return VOS_STATUS_E_FAULT;
1849 }
1850
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301851 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1852 {
1853 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1854 "WLAN TL:Client Memory was not allocated on %s", __func__));
1855 return VOS_STATUS_E_FAILURE;
1856 }
1857
1858 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001859 {
Sunil Ravid5406f22013-01-22 00:18:31 -08001860 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001861 "WLAN TL:Station was not previously registered on WLANTL_GetSTAState"));
1862 return VOS_STATUS_E_EXISTS;
1863 }
1864
1865 /*------------------------------------------------------------------------
1866 Get STA state
1867 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05301868 *ptlSTAState = pTLCb->atlSTAClients[ucSTAId]->tlState;
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001869
1870 return VOS_STATUS_SUCCESS;
1871}/* WLANTL_GetSTAState */
1872
Shailender Karmuchia734f332013-04-19 14:02:48 -07001873/*==========================================================================
1874 FUNCTION WLANTL_UpdateSTABssIdforIBSS
1875
1876 DESCRIPTION
1877 HDD will call this API to update the BSSID for this Station.
1878
1879 DEPENDENCIES
1880 The HDD Should registered the staID with TL before calling this function.
1881
1882 PARAMETERS
1883
1884 IN
1885 pvosGCtx: Pointer to the global vos context; a handle to TL's
1886 or WDA's control block can be extracted from its context
1887 IN
1888 ucSTAId The Station ID for Bssid to be updated
1889 IN
1890 pBssid BSSID to be updated
1891
1892 RETURN VALUE
1893 The result code associated with performing the operation
1894
1895 VOS_STATUS_E_INVAL: Input parameters are invalid
1896 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
1897 TL cb is NULL ; access would cause a page fault
1898 VOS_STATUS_E_EXISTS: Station was not registered
1899 VOS_STATUS_SUCCESS: Everything is good :)
1900
1901 SIDE EFFECTS
1902============================================================================*/
1903
1904
1905VOS_STATUS
1906WLANTL_UpdateSTABssIdforIBSS
1907(
1908 v_PVOID_t pvosGCtx,
1909 v_U8_t ucSTAId,
1910 v_U8_t *pBssid
1911)
1912{
1913 WLANTL_CbType* pTLCb = NULL;
1914 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
1915
1916 /*------------------------------------------------------------------------
1917 Sanity check
1918 ------------------------------------------------------------------------*/
1919 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
1920 {
1921 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1922 "WLAN TL:Invalid station id requested %s", __func__));
1923 return VOS_STATUS_E_FAULT;
1924 }
1925
1926 /*------------------------------------------------------------------------
1927 Extract TL control block and check existance
1928 ------------------------------------------------------------------------*/
1929 pTLCb = VOS_GET_TL_CB(pvosGCtx);
1930 if ( NULL == pTLCb )
1931 {
1932 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1933 "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
1934 return VOS_STATUS_E_FAULT;
1935 }
1936
1937 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
1938 {
1939 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
1940 "WLAN TL:Client Memory was not allocated on %s", __func__));
1941 return VOS_STATUS_E_FAILURE;
1942 }
1943
1944 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
1945 {
1946 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
1947 "WLAN TL:Station was not previously registered %s", __func__));
1948 return VOS_STATUS_E_EXISTS;
1949 }
1950
1951 /*------------------------------------------------------------------------
1952 Update the IBSS BSSID
1953 ------------------------------------------------------------------------*/
1954 vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
1955 pBssid, sizeof(v_MACADDR_t));
1956
1957 return VOS_STATUS_SUCCESS;
1958}
1959
Madan Mohan Koyyalamudifc1d1fe2012-10-18 15:07:12 -07001960/*===========================================================================
1961
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 FUNCTION WLANTL_STAPktPending
1963
1964 DESCRIPTION
1965
1966 HDD will call this API when a packet is pending transmission in its
1967 queues.
1968
1969 DEPENDENCIES
1970
1971 A station must have been registered before the packet pending
1972 notification can be sent.
1973
1974 RESTRICTION: TL will not count packets for pending notification.
1975 HDD is expected to send the notification only when
1976 non-empty event gets triggered. Worst case scenario
1977 is that TL might end up making a call when Hdds
1978 queues are actually empty.
1979
1980 PARAMETERS
1981
1982 pvosGCtx: pointer to the global vos context; a handle to TL's
1983 control block can be extracted from its context
1984 ucSTAId: identifier for the STA that is pending transmission
1985
1986 RETURN VALUE
1987
1988 The result code associated with performing the operation
1989
1990 VOS_STATUS_E_INVAL: Input parameters are invalid
1991 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
1992 to TL cb is NULL ; access would cause a page fault
1993 VOS_STATUS_E_EXISTS: Station was not registered
1994 VOS_STATUS_SUCCESS: Everything is good :)
1995
1996 SIDE EFFECTS
1997
1998============================================================================*/
1999VOS_STATUS
2000WLANTL_STAPktPending
2001(
2002 v_PVOID_t pvosGCtx,
2003 v_U8_t ucSTAId,
2004 WLANTL_ACEnumType ucAc
2005)
2006{
2007 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302008 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2010
2011 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
2012 "WLAN TL:Packet pending indication for STA: %d AC: %d", ucSTAId, ucAc);
2013
2014 /*------------------------------------------------------------------------
2015 Sanity check
2016 ------------------------------------------------------------------------*/
2017 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2018 {
2019 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2020 "WLAN TL:Invalid station id requested on WLANTL_STAPktPending"));
2021 return VOS_STATUS_E_FAULT;
2022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 /*------------------------------------------------------------------------
2024 Extract TL control block and check existance
2025 ------------------------------------------------------------------------*/
2026 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2027 if ( NULL == pTLCb )
2028 {
2029 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2030 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STAPktPending"));
2031 return VOS_STATUS_E_FAULT;
2032 }
2033
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302034 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2035
2036 if ( NULL == pClientSTA )
2037 {
2038 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2039 "WLAN TL:Client Memory was not allocated on %s", __func__));
2040 return VOS_STATUS_E_FAILURE;
2041 }
2042
2043 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 {
Mahesh A Saptasagara3d89912014-10-16 14:55:54 +05302045 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 "WLAN TL:Station was not previously registered on WLANTL_STAPktPending"));
2047 return VOS_STATUS_E_EXISTS;
2048 }
2049
2050 /*---------------------------------------------------------------------
2051 Temporary fix to enable TL to fetch packets when multiple peers join
2052 an IBSS. To fix CR177301. Needs to go away when the actual fix of
2053 going through all STA's in round robin fashion gets merged in from
2054 BT AMP branch.
2055 --------------------------------------------------------------------*/
2056 pTLCb->ucRegisteredStaId = ucSTAId;
2057
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302058 if( WLANTL_STA_CONNECTED == pClientSTA->tlState )
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002059 { /* EAPOL_HI_PRIORITY : need to find out whether EAPOL is pending before
2060 WLANTL_FetchPacket()/WLANTL_TxConn() is called.
2061 change STA_AUTHENTICATED != tlState to CONNECTED == tlState
2062 to make sure TL is indeed waiting for EAPOL.
2063 Just in the case when STA got disconnected shortly after connectection */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302064 pClientSTA->ucEapolPktPending = 1;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002065
Katya Nigam42e16e82014-02-04 16:28:55 +05302066 MTRACE(vos_trace(VOS_MODULE_ID_TL,
2067 TRACE_CODE_TL_EAPOL_PKT_PENDING, ucSTAId, ucAc));
2068
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002069 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002070 "WLAN TL:Packet pending indication for STA: %d AC: %d State: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302071 ucSTAId, ucAc, pClientSTA->tlState);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07002072 }
2073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 /*-----------------------------------------------------------------------
2075 Enable this AC in the AC mask in order for TL to start servicing it
2076 Set packet pending flag
2077 To avoid race condition, serialize the updation of AC and AC mask
2078 through WLANTL_TX_STAID_AC_IND message.
2079 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002080
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302081 pClientSTA->aucACMask[ucAc] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302083 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002084
2085 /*------------------------------------------------------------------------
2086 Check if there are enough resources for transmission and tx is not
2087 suspended.
2088 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi24a00f92012-10-22 15:21:02 -07002089 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA ) &&
2090 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 {
Katya Nigam42e16e82014-02-04 16:28:55 +05302092 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_STA_PKT_PENDING,
2093 ucSTAId, pClientSTA->tlState ));
2094
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2096 "Issuing Xmit start request to BAL"));
2097 WDA_DS_StartXmit(pvosGCtx);
2098 }
2099 else
2100 {
2101 /*---------------------------------------------------------------------
2102 No error code is sent because TL will resume tx autonomously if
2103 resources become available or tx gets resumed
2104 ---------------------------------------------------------------------*/
Madan Mohan Koyyalamudi179e6fe2012-10-15 15:31:08 -07002105 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 "WLAN TL:Request to send but condition not met. Res: %d,Suspend: %d",
Madan Mohan Koyyalamudi48139e32012-10-11 14:43:56 -07002107 pTLCb->uResCount, pTLCb->ucTxSuspended );
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 return VOS_STATUS_SUCCESS;
2110}/* WLANTL_STAPktPending */
2111
2112/*==========================================================================
2113
2114 FUNCTION WLANTL_SetSTAPriority
2115
2116 DESCRIPTION
2117
2118 TL exposes this API to allow upper layers a rough control over the
2119 priority of transmission for a given station when supporting multiple
2120 connections.
2121
2122 DEPENDENCIES
2123
2124 A station must have been registered before the change in priority can be
2125 called.
2126
2127 PARAMETERS
2128
2129 pvosGCtx: pointer to the global vos context; a handle to TL's
2130 control block can be extracted from its context
2131 ucSTAId: identifier for the STA that has to change priority
2132
2133 RETURN VALUE
2134
2135 The result code associated with performing the operation
2136
2137 VOS_STATUS_E_INVAL: Input parameters are invalid
2138 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2139 to TL cb is NULL ; access would cause a page fault
2140 VOS_STATUS_E_EXISTS: Station was not registered
2141 VOS_STATUS_SUCCESS: Everything is good :)
2142
2143 SIDE EFFECTS
2144
2145============================================================================*/
2146VOS_STATUS
2147WLANTL_SetSTAPriority
2148(
2149 v_PVOID_t pvosGCtx,
2150 v_U8_t ucSTAId,
2151 WLANTL_STAPriorityType tlSTAPri
2152)
2153{
2154 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302155 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2157
2158 /*------------------------------------------------------------------------
2159 Sanity check
2160 ------------------------------------------------------------------------*/
2161 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2162 {
2163 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2164 "WLAN TL:Invalid station id requested on WLANTL_SetSTAPriority"));
2165 return VOS_STATUS_E_FAULT;
2166 }
2167
2168 /*------------------------------------------------------------------------
2169 Extract TL control block
2170 ------------------------------------------------------------------------*/
2171 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2172 if ( NULL == pTLCb )
2173 {
2174 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2175 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SetSTAPriority"));
2176 return VOS_STATUS_E_FAULT;
2177 }
2178
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302179 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2180
2181 if ( NULL == pClientSTA )
2182 {
2183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2184 "WLAN TL:Client Memory was not allocated on %s", __func__));
2185 return VOS_STATUS_E_FAILURE;
2186 }
2187
2188 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 {
2190 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2191 "WLAN TL:Station was not previously registered on WLANTL_SetSTAPriority"));
2192 return VOS_STATUS_E_EXISTS;
2193 }
2194
2195 /*------------------------------------------------------------------------
2196 Re-analize if lock is needed when adding multiple stations
2197 ------------------------------------------------------------------------*/
2198 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2199 "WLAN TL:Changing state for STA Pri ID: %d from %d to %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302200 ucSTAId, pClientSTA->tlPri, tlSTAPri));
2201 pClientSTA->tlPri = tlSTAPri;
Jeff Johnson295189b2012-06-20 16:38:30 -07002202
2203 return VOS_STATUS_SUCCESS;
2204}/* WLANTL_SetSTAPriority */
2205
2206
2207/*----------------------------------------------------------------------------
2208 INTERACTION WITH BAP
2209 ---------------------------------------------------------------------------*/
2210
2211/*==========================================================================
2212
2213 FUNCTION WLANTL_RegisterBAPClient
2214
2215 DESCRIPTION
2216 Called by SME to register itself as client for non-data BT-AMP packets.
2217
2218 DEPENDENCIES
2219 TL must be initialized before this function can be called.
2220
2221 PARAMETERS
2222
2223 IN
2224 pvosGCtx: pointer to the global vos context; a handle to TL's
2225 or SME's control block can be extracted from its context
2226 pfnTlBAPRxFrm: pointer to the receive processing routine for non-data
2227 BT-AMP packets
2228 pfnFlushOpCompleteCb:
2229 pointer to the call back function, for the Flush operation
2230 completion.
2231
2232
2233 RETURN VALUE
2234
2235 The result code associated with performing the operation
2236
2237 VOS_STATUS_E_INVAL: Input parameters are invalid
2238 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2239 to TL cb is NULL ; access would cause a page fault
2240 VOS_STATUS_E_EXISTS: BAL client was already registered
2241 VOS_STATUS_SUCCESS: Everything is good :)
2242
2243 SIDE EFFECTS
2244
2245============================================================================*/
2246VOS_STATUS
2247WLANTL_RegisterBAPClient
2248(
2249 v_PVOID_t pvosGCtx,
2250 WLANTL_BAPRxCBType pfnTlBAPRxFrm,
2251 WLANTL_FlushOpCompCBType pfnFlushOpCompleteCb
2252)
2253{
2254 WLANTL_CbType* pTLCb = NULL;
2255 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2256
2257 /*------------------------------------------------------------------------
2258 Sanity check
2259 ------------------------------------------------------------------------*/
2260 if ( NULL == pfnTlBAPRxFrm )
2261 {
2262 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2263 "WLAN TL:Invalid parameter sent on WLANTL_RegisterBAPClient"));
2264 return VOS_STATUS_E_INVAL;
2265 }
2266
2267 if ( NULL == pfnFlushOpCompleteCb )
2268 {
2269 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2270 "Invalid Flush Complete Cb parameter sent on WLANTL_RegisterBAPClient"));
2271 return VOS_STATUS_E_INVAL;
2272 }
2273
2274 /*------------------------------------------------------------------------
2275 Extract TL control block
2276 ------------------------------------------------------------------------*/
2277 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2278 if ( NULL == pTLCb )
2279 {
2280 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2281 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_RegisterBAPClient"));
2282 return VOS_STATUS_E_FAULT;
2283 }
2284
2285 /*------------------------------------------------------------------------
2286 Make sure this is the first registration attempt
2287 ------------------------------------------------------------------------*/
2288 if ( 0 != pTLCb->tlBAPClient.ucExists )
2289 {
2290 pTLCb->tlBAPClient.ucExists++;
2291 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2292 "WLAN TL:BAP client was already registered"));
2293 return VOS_STATUS_E_EXISTS;
2294 }
2295
2296 /*------------------------------------------------------------------------
2297 Register station with TL
2298 ------------------------------------------------------------------------*/
2299 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2300 "WLAN TL:Registering BAP Client" ));
2301
2302 pTLCb->tlBAPClient.ucExists++;
2303
2304 if ( NULL != pfnTlBAPRxFrm )
2305 {
2306 pTLCb->tlBAPClient.pfnTlBAPRx = pfnTlBAPRxFrm;
2307 }
2308
2309 pTLCb->tlBAPClient.pfnFlushOpCompleteCb = pfnFlushOpCompleteCb;
2310
2311 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
2312
2313 return VOS_STATUS_SUCCESS;
2314}/* WLANTL_RegisterBAPClient */
2315
2316
2317/*==========================================================================
2318
2319 FUNCTION WLANTL_TxBAPFrm
2320
2321 DESCRIPTION
2322 BAP calls this when it wants to send a frame to the module
2323
2324 DEPENDENCIES
2325 BAP must be registered with TL before this function can be called.
2326
2327 RESTRICTION: BAP CANNOT push any packets to TL until it did not receive
2328 a tx complete from the previous packet, that means BAP
2329 sends one packet, wait for tx complete and then
2330 sends another one
2331
2332 If BAP sends another packet before TL manages to process the
2333 previously sent packet call will end in failure
2334
2335 PARAMETERS
2336
2337 IN
2338 pvosGCtx: pointer to the global vos context; a handle to TL's
2339 or BAP's control block can be extracted from its context
2340 vosDataBuff: pointer to the vOSS buffer containing the packet to be
2341 transmitted
2342 pMetaInfo: meta information about the packet
2343 pfnTlBAPTxComp: pointer to a transmit complete routine for notifying
2344 the result of the operation over the bus
2345
2346 RETURN VALUE
2347 The result code associated with performing the operation
2348
2349 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
2350 page fault
2351 VOS_STATUS_E_EXISTS: BAL client was not yet registered
2352 VOS_STATUS_E_BUSY: The previous BT-AMP packet was not yet transmitted
2353 VOS_STATUS_SUCCESS: Everything is good :)
2354
2355 Other failure messages may be returned from the BD header handling
2356 routines, please check apropriate API for more info.
2357
2358 SIDE EFFECTS
2359
2360============================================================================*/
2361VOS_STATUS
2362WLANTL_TxBAPFrm
2363(
2364 v_PVOID_t pvosGCtx,
2365 vos_pkt_t* vosDataBuff,
2366 WLANTL_MetaInfoType* pMetaInfo,
2367 WLANTL_TxCompCBType pfnTlBAPTxComp
2368)
2369{
2370 WLANTL_CbType* pTLCb = NULL;
2371 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2372 v_MACADDR_t vDestMacAddr;
2373 v_U16_t usPktLen;
2374 v_U8_t ucStaId = 0;
2375 v_U8_t extraHeadSpace = 0;
2376 v_U8_t ucWDSEnabled = 0;
2377 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2378
2379 /*------------------------------------------------------------------------
2380 Sanity check
2381 Extract TL control block
2382 ------------------------------------------------------------------------*/
2383 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2384 if ( NULL == pTLCb )
2385 {
2386 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2387 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxBAPFrm"));
2388 return VOS_STATUS_E_FAULT;
2389 }
2390
2391 /*------------------------------------------------------------------------
2392 Ensure that BAP client was registered previously
2393 ------------------------------------------------------------------------*/
2394 if (( 0 == pTLCb->tlBAPClient.ucExists ) ||
2395 ( WLANTL_STA_ID_INVALID(pTLCb->tlBAPClient.ucBAPSTAId) ))
2396 {
2397 pTLCb->tlBAPClient.ucExists++;
2398 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2399 "WLAN TL:BAP client not register on WLANTL_TxBAPFrm"));
2400 return VOS_STATUS_E_EXISTS;
2401 }
2402
2403 /*------------------------------------------------------------------------
2404 Check if any BT-AMP Frm is pending
2405 ------------------------------------------------------------------------*/
2406 if ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff )
2407 {
2408 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2409 "WLAN TL:BT-AMP Frame already pending tx in TL on WLANTL_TxBAPFrm"));
2410 return VOS_STATUS_E_BUSY;
2411 }
2412
2413 /*------------------------------------------------------------------------
2414 Save buffer and notify BAL; no lock is needed if the above restriction
2415 is met
2416 Save the tx complete fnct pointer as tl specific data in the vos buffer
2417 ------------------------------------------------------------------------*/
2418
2419 /*------------------------------------------------------------------------
2420 Translate 802.3 frame to 802.11
2421 ------------------------------------------------------------------------*/
2422 ucStaId = pTLCb->tlBAPClient.ucBAPSTAId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302423 if ( NULL == pTLCb->atlSTAClients[ucStaId] )
2424 {
2425 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2426 "WLAN TL:Client Memory was not allocated on %s", __func__));
2427 return VOS_STATUS_E_FAILURE;
2428 }
2429 if (( 0 == pMetaInfo->ucDisableFrmXtl ) &&
2430 ( 0 != pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucSwFrameTXXlation ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08002432 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
2433 pTLCb, &ucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07002434 pMetaInfo, &ucWDSEnabled,
2435 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07002436
2437 if ( VOS_STATUS_SUCCESS != vosStatus )
2438 {
2439 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2440 "WLAN TL:Error when translating header WLANTL_TxBAPFrm"));
2441
2442 return vosStatus;
2443 }
2444
2445 pMetaInfo->ucDisableFrmXtl = 1;
2446 }
2447
2448 /*-------------------------------------------------------------------------
2449 Call HAL to fill BD header
2450 -------------------------------------------------------------------------*/
2451
2452 /* Adding Type, SubType which was missing for EAPOL from BAP */
2453 pMetaInfo->ucType |= (WLANTL_80211_DATA_TYPE << 4);
2454 pMetaInfo->ucType |= (WLANTL_80211_DATA_QOS_SUBTYPE);
2455
2456 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff ,
2457 &vDestMacAddr, pMetaInfo->ucDisableFrmXtl,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302458 &usPktLen, pTLCb->atlSTAClients[ucStaId]->wSTADesc.ucQosEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 ucWDSEnabled, extraHeadSpace, pMetaInfo->ucType,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302460 &pTLCb->atlSTAClients[ucStaId]->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 pMetaInfo->ucTID, 0 /* No ACK */, pMetaInfo->usTimeStamp,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07002462 pMetaInfo->ucIsEapol || pMetaInfo->ucIsWai, pMetaInfo->ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07002463
2464 if ( VOS_STATUS_SUCCESS != vosStatus )
2465 {
2466 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2467 "WLAN TL:Failed while building TX header %d", vosStatus));
2468 return vosStatus;
2469 }
2470
2471 if ( NULL != pfnTlBAPTxComp )
2472 {
2473 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2474 (v_PVOID_t)pfnTlBAPTxComp);
2475 }
2476 else
2477 {
2478 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
2479 (v_PVOID_t)WLANTL_TxCompDefaultCb);
2480
2481 }
2482
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05302483 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
2484 (uintptr_t)vosDataBuff);
Jeff Johnson295189b2012-06-20 16:38:30 -07002485
2486 /*------------------------------------------------------------------------
2487 Check if thre are enough resources for transmission and tx is not
2488 suspended.
2489 ------------------------------------------------------------------------*/
2490 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
2491 ( 0 == pTLCb->ucTxSuspended ))
2492 {
2493 WDA_DS_StartXmit(pvosGCtx);
2494 }
2495 else
2496 {
2497 /*---------------------------------------------------------------------
2498 No error code is sent because TL will resume tx autonomously if
2499 resources become available or tx gets resumed
2500 ---------------------------------------------------------------------*/
2501 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2502 "WLAN TL:Request to send from BAP but condition not met.Res: %d,"
2503 "Suspend: %d", pTLCb->uResCount, pTLCb->ucTxSuspended ));
2504 }
2505
2506 return VOS_STATUS_SUCCESS;
2507}/* WLANTL_TxBAPFrm */
2508
2509
2510/*----------------------------------------------------------------------------
2511 INTERACTION WITH SME
2512 ---------------------------------------------------------------------------*/
2513
2514/*==========================================================================
2515
2516 FUNCTION WLANTL_GetRssi
2517
2518 DESCRIPTION
2519 TL will extract the RSSI information from every data packet from the
2520 ongoing traffic and will store it. It will provide the result to SME
2521 upon request.
2522
2523 DEPENDENCIES
2524
2525 WARNING: the read and write of this value will not be protected
2526 by locks, therefore the information obtained after a read
2527 might not always be consistent.
2528
2529 PARAMETERS
2530
2531 IN
2532 pvosGCtx: pointer to the global vos context; a handle to TL's
2533 or SME's control block can be extracted from its context
2534 ucSTAId: station identifier for the requested value
2535
2536 OUT
2537 puRssi: the average value of the RSSI
2538
2539
2540 RETURN VALUE
2541 The result code associated with performing the operation
2542
2543 VOS_STATUS_E_INVAL: Input parameters are invalid
2544 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2545 to TL cb is NULL ; access would cause a page fault
2546 VOS_STATUS_E_EXISTS: STA was not yet registered
2547 VOS_STATUS_SUCCESS: Everything is good :)
2548
2549 SIDE EFFECTS
2550
2551============================================================================*/
2552VOS_STATUS
2553WLANTL_GetRssi
2554(
2555 v_PVOID_t pvosGCtx,
2556 v_U8_t ucSTAId,
2557 v_S7_t* pRssi
2558)
2559{
2560 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302561 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2563
2564 /*------------------------------------------------------------------------
2565 Sanity check
2566 ------------------------------------------------------------------------*/
2567 if ( NULL == pRssi )
2568 {
2569 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2570 "WLAN TL:Invalid parameter sent on WLANTL_GetRssi"));
2571 return VOS_STATUS_E_INVAL;
2572 }
2573
2574 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2575 {
2576 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2577 "WLAN TL:Invalid station id requested on WLANTL_GetRssi"));
2578 return VOS_STATUS_E_FAULT;
2579 }
2580
2581 /*------------------------------------------------------------------------
2582 Extract TL control block and check existance
2583 ------------------------------------------------------------------------*/
2584 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2585 if ( NULL == pTLCb )
2586 {
2587 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2588 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRssi"));
2589 return VOS_STATUS_E_FAULT;
2590 }
2591
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302592 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2593
2594 if ( NULL == pClientSTA )
2595 {
2596 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2597 "WLAN TL:Client Memory was not allocated on %s", __func__));
2598 return VOS_STATUS_E_FAILURE;
2599 }
2600
2601 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 {
2603 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2604 "WLAN TL:Station was not previously registered on WLANTL_GetRssi"));
2605 return VOS_STATUS_E_EXISTS;
2606 }
2607
2608 /*------------------------------------------------------------------------
2609 Copy will not be locked; please read restriction
2610 ------------------------------------------------------------------------*/
Katya Nigam5c2e5f62013-11-15 19:19:11 +05302611 if(pTLCb->isBMPS || IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302613 *pRssi = pClientSTA->rssiAvgBmps;
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 /* Check If RSSI is zero because we are reading rssAvgBmps updated by HAL in
2615 previous GetStatsRequest. It may be updated as zero by Hal because EnterBmps
2616 might not have happend by that time. Hence reading the most recent Rssi
2617 calcluated by TL*/
2618 if(0 == *pRssi)
2619 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302620 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 }
2623 else
2624 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302625 *pRssi = pClientSTA->rssiAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 }
2627
2628 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson32d95a32012-09-10 13:15:23 -07002629 "WLAN TL:WLANTL_GetRssi for STA: %d RSSI: %d%s",
2630 ucSTAId, *pRssi,
2631 pTLCb->isBMPS ? " in BMPS" : ""));
Jeff Johnson295189b2012-06-20 16:38:30 -07002632
2633 return VOS_STATUS_SUCCESS;
2634}/* WLANTL_GetRssi */
2635
2636/*==========================================================================
2637
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05302638 FUNCTION WLANTL_GetSnr
2639
2640 DESCRIPTION
2641 TL will extract the SNR information from every data packet from the
2642 ongoing traffic and will store it. It will provide the result to SME
2643 upon request.
2644
2645 DEPENDENCIES
2646
2647 WARNING: the read and write of this value will not be protected
2648 by locks, therefore the information obtained after a read
2649 might not always be consistent.
2650
2651 PARAMETERS
2652
2653 IN
2654 pvosGCtx: pointer to the global vos context; a handle to TL's
2655 or SME's control block can be extracted from its context
2656 ucSTAId: station identifier for the requested value
2657
2658 OUT
2659 pSnr: the average value of the SNR
2660
2661
2662 RETURN VALUE
2663 The result code associated with performing the operation
2664
2665 VOS_STATUS_E_INVAL: Input parameters are invalid
2666 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2667 to TL cb is NULL ; access would cause a page fault
2668 VOS_STATUS_E_EXISTS: STA was not yet registered
2669 VOS_STATUS_SUCCESS: Everything is good :)
2670
2671 SIDE EFFECTS
2672
2673============================================================================*/
2674VOS_STATUS
2675WLANTL_GetSnr
2676(
2677 tANI_U8 ucSTAId,
2678 tANI_S8* pSnr
2679)
2680{
2681 WLANTL_CbType* pTLCb = NULL;
2682 WLANTL_STAClientType* pClientSTA = NULL;
2683 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
2684
2685 /*------------------------------------------------------------------------
2686 Sanity check
2687 ------------------------------------------------------------------------*/
2688 if (NULL == pSnr)
2689 {
2690 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2691 "WLAN TL:Invalid parameter sent on %s", __func__));
2692 return VOS_STATUS_E_INVAL;
2693 }
2694
2695 if (WLANTL_STA_ID_INVALID(ucSTAId))
2696 {
2697 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2698 "WLAN TL:Invalid station id requested on %s", __func__));
2699 return VOS_STATUS_E_FAULT;
2700 }
2701
2702 /*------------------------------------------------------------------------
2703 Extract TL control block and check existance
2704 ------------------------------------------------------------------------*/
2705 pTLCb = VOS_GET_TL_CB(vos_get_global_context(VOS_MODULE_ID_TL, NULL));
2706 if (NULL == pTLCb)
2707 {
2708 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2709 "WLAN TL:Invalid TL pointer from pvosGCtx on %s", __func__));
2710 return VOS_STATUS_E_FAULT;
2711 }
2712
2713 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
2714
2715 if (NULL == pClientSTA)
2716 {
2717 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2718 "WLAN TL:Client Memory was not allocated on %s", __func__));
2719 return VOS_STATUS_E_FAILURE;
2720 }
2721
2722 if (0 == pClientSTA->ucExists)
2723 {
2724 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2725 "WLAN TL:Station was not previously registered on %s", __func__));
2726 return VOS_STATUS_E_EXISTS;
2727 }
2728
2729 /*------------------------------------------------------------------------
2730 Copy will not be locked; please read restriction
2731 ------------------------------------------------------------------------*/
2732 if (pTLCb->isBMPS)
2733 {
2734 *pSnr = pClientSTA->snrAvgBmps;
2735 }
2736 else
2737 {
2738 /* SNR is averaged over WLANTL_MAX_SNR_DATA_SAMPLES, if there are not enough
2739 * data samples (snridx) to calculate the average then return the
2740 * average for the window of prevoius 20 packets. And if there aren't
2741 * enough samples and the average for previous window of 20 packets is
2742 * not available then return a predefined value
2743 *
2744 * NOTE: the SNR_HACK_BMPS value is defined to 127, documents from HW
2745 * team reveal that the SNR value has a ceiling well below 127 dBm,
2746 * so if SNR has value of 127 the userspace applications can know that
2747 * the SNR has not been computed yet because enough data was not
2748 * available for SNR calculation
2749 */
2750 if (pClientSTA->snrIdx > (WLANTL_MAX_SNR_DATA_SAMPLES/2)
2751 || !(pClientSTA->prevSnrAvg))
2752 {
2753 *pSnr = pClientSTA->snrSum / pClientSTA->snrIdx;
2754 }
2755 else if (pClientSTA->prevSnrAvg)
2756 {
2757 *pSnr = pClientSTA->prevSnrAvg;
2758 }
2759 else
2760 {
2761 *pSnr = SNR_HACK_BMPS;
2762 }
2763 }
2764
2765 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2766 "WLAN TL:WLANTL_GetSnr for STA: %d SNR: %d%s",
2767 ucSTAId, *pSnr,
2768 pTLCb->isBMPS ? " in BMPS" : "");
2769
2770 return VOS_STATUS_SUCCESS;
2771}/* WLANTL_GetSnr */
2772/*==========================================================================
2773
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 FUNCTION WLANTL_GetLinkQuality
2775
2776 DESCRIPTION
2777 TL will extract the SNR information from every data packet from the
2778 ongoing traffic and will store it. It will provide the result to SME
2779 upon request.
2780
2781 DEPENDENCIES
2782
2783 WARNING: the read and write of this value will not be protected
2784 by locks, therefore the information obtained after a read
2785 might not always be consistent.
2786
2787 PARAMETERS
2788
2789 IN
2790 pvosGCtx: pointer to the global vos context; a handle to TL's
2791 or SME's control block can be extracted from its context
2792 ucSTAId: station identifier for the requested value
2793
2794 OUT
2795 puLinkQuality: the average value of the SNR
2796
2797
2798 RETURN VALUE
2799 The result code associated with performing the operation
2800
2801 VOS_STATUS_E_INVAL: Input parameters are invalid
2802 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
2803 to TL cb is NULL ; access would cause a page fault
2804 VOS_STATUS_E_EXISTS: STA was not yet registered
2805 VOS_STATUS_SUCCESS: Everything is good :)
2806
2807 SIDE EFFECTS
2808
2809============================================================================*/
2810VOS_STATUS
2811WLANTL_GetLinkQuality
2812(
2813 v_PVOID_t pvosGCtx,
2814 v_U8_t ucSTAId,
2815 v_U32_t* puLinkQuality
2816)
2817{
2818 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302819 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002820
2821 /*------------------------------------------------------------------------
2822 Sanity check
2823 ------------------------------------------------------------------------*/
2824 if ( NULL == puLinkQuality )
2825 {
2826 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2827 "Invalid parameter sent on WLANTL_GetLinkQuality"));
2828 return VOS_STATUS_E_INVAL;
2829 }
2830
2831 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2832 {
2833 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2834 "Invalid station id requested on WLANTL_GetLinkQuality"));
2835 return VOS_STATUS_E_FAULT;
2836 }
2837
2838 /*------------------------------------------------------------------------
2839 Extract TL control block and check existance
2840 ------------------------------------------------------------------------*/
2841 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2842 if ( NULL == pTLCb )
2843 {
2844 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2845 "Invalid TL pointer from pvosGCtx on WLANTL_GetLinkQuality"));
2846 return VOS_STATUS_E_FAULT;
2847 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302848 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07002849
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302850 if ( NULL == pClientSTA )
2851 {
2852 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2853 "WLAN TL:Client Memory was not allocated on %s", __func__));
2854 return VOS_STATUS_E_FAILURE;
2855 }
2856
2857 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 {
2859 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2860 "Station was not previously registered on WLANTL_GetLinkQuality"));
2861 return VOS_STATUS_E_EXISTS;
2862 }
2863
2864 /*------------------------------------------------------------------------
2865 Copy will not be locked; please read restriction
2866 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302867 *puLinkQuality = pClientSTA->uLinkQualityAvg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002868
2869 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2870 "WLANTL_GetLinkQuality for STA: %d LinkQuality: %d", ucSTAId, *puLinkQuality));
2871
2872 return VOS_STATUS_SUCCESS;
2873}/* WLANTL_GetLinkQuality */
2874
2875/*==========================================================================
2876
2877 FUNCTION WLANTL_FlushStaTID
2878
2879 DESCRIPTION
2880 TL provides this API as an interface to SME (BAP) layer. TL inturn posts a
2881 message to HAL. This API is called by the SME inorder to perform a flush
2882 operation.
2883
2884 DEPENDENCIES
2885
2886 PARAMETERS
2887
2888 IN
2889 pvosGCtx: pointer to the global vos context; a handle to TL's
2890 or SME's control block can be extracted from its context
2891 ucSTAId: station identifier for the requested value
2892 ucTid: Tspec ID for the new BA session
2893
2894 OUT
2895 The response for this post is received in the main thread, via a response
2896 message from HAL to TL.
2897
2898 RETURN VALUE
2899 VOS_STATUS_SUCCESS: Everything is good :)
2900
2901 SIDE EFFECTS
2902============================================================================*/
2903VOS_STATUS
2904WLANTL_FlushStaTID
2905(
2906 v_PVOID_t pvosGCtx,
2907 v_U8_t ucSTAId,
2908 v_U8_t ucTid
2909)
2910{
2911 WLANTL_CbType* pTLCb = NULL;
2912 tpFlushACReq FlushACReqPtr = NULL;
2913 vos_msg_t vosMessage;
2914
2915
2916 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
2917 {
2918 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2919 "Invalid station id requested on WLANTL_FlushStaTID"));
2920 return VOS_STATUS_E_FAULT;
2921 }
2922
2923 /*------------------------------------------------------------------------
2924 Extract TL control block and check existance
2925 ------------------------------------------------------------------------*/
2926 pTLCb = VOS_GET_TL_CB(pvosGCtx);
2927 if ( NULL == pTLCb )
2928 {
2929 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2930 "Invalid TL pointer from pvosGCtx on WLANTL_FlushStaTID"));
2931 return VOS_STATUS_E_FAULT;
2932 }
2933
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05302934 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
2935 {
2936 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2937 "WLAN TL:Client Memory was not allocated on %s", __func__));
2938 return VOS_STATUS_E_FAILURE;
2939 }
2940
2941 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 {
2943 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2944 "Station was not previously registered on WLANTL_FlushStaTID"));
2945 return VOS_STATUS_E_EXISTS;
2946 }
2947
2948 /*------------------------------------------------------------------------
2949 We need to post a message with the STA, TID value to HAL. HAL performs the flush
2950 ------------------------------------------------------------------------*/
2951 FlushACReqPtr = vos_mem_malloc(sizeof(tFlushACReq));
2952
2953 if ( NULL == FlushACReqPtr )
2954 {
2955 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
2956 "WLAN TL: fatal failure, cannot allocate Flush Req structure"));
2957 VOS_ASSERT(0);
2958 return VOS_STATUS_E_NOMEM;
2959 }
2960
2961 // Start constructing the message for HAL
2962 FlushACReqPtr->mesgType = SIR_TL_HAL_FLUSH_AC_REQ;
2963 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2964 FlushACReqPtr->mesgLen = sizeof(tFlushACReq);
2965 FlushACReqPtr->ucSTAId = ucSTAId;
2966 FlushACReqPtr->ucTid = ucTid;
2967
2968 vosMessage.type = WDA_TL_FLUSH_AC_REQ;
2969 vosMessage.bodyptr = (void *)FlushACReqPtr;
2970
2971 vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
2972 return VOS_STATUS_SUCCESS;
2973}
2974
2975
2976/*----------------------------------------------------------------------------
2977 INTERACTION WITH PE
2978 ---------------------------------------------------------------------------*/
Siddharth Bhal4551b102014-10-09 21:36:36 +05302979/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07002980
Siddharth Bhal4551b102014-10-09 21:36:36 +05302981 FUNCTION WLANTL_updateSpoofMacAddr
2982
2983 DESCRIPTION
2984 Called by HDD to update macaddr
2985
2986 DEPENDENCIES
2987 TL must be initialized before this API can be called.
2988
2989 PARAMETERS
2990
2991 IN
2992 pvosGCtx: pointer to the global vos context; a handle to
2993 TL's control block can be extracted from its context
2994 spoofMacAddr: spoofed mac adderess
2995 selfMacAddr: self Mac Address
2996
2997 RETURN VALUE
2998 The result code associated with performing the operation
2999
3000 VOS_STATUS_E_INVAL: Input parameters are invalid
3001 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3002 page fault
3003 VOS_STATUS_SUCCESS: Everything is good :)
3004
3005 SIDE EFFECTS
3006
3007============================================================================*/
3008VOS_STATUS
3009WLANTL_updateSpoofMacAddr
3010(
3011 v_PVOID_t pvosGCtx,
3012 v_MACADDR_t* spoofMacAddr,
3013 v_MACADDR_t* selfMacAddr
3014)
3015{
3016 WLANTL_CbType* pTLCb = NULL;
3017 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3018
3019 /*------------------------------------------------------------------------
3020 Sanity check
3021 ------------------------------------------------------------------------*/
3022 if ( NULL == spoofMacAddr || NULL == selfMacAddr)
3023 {
3024 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3025 "WLAN TL:Invalid parameter sent on WLANTL_updateSpoofMacAddr");
3026 return VOS_STATUS_E_INVAL;
3027 }
3028
3029 /*------------------------------------------------------------------------
3030 Extract TL control block
3031 ------------------------------------------------------------------------*/
3032 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3033 if ( NULL == pTLCb )
3034 {
3035 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3036 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState");
3037 return VOS_STATUS_E_FAULT;
3038 }
3039
3040 vos_mem_copy(pTLCb->spoofMacAddr.selfMac.bytes, selfMacAddr,
3041 VOS_MAC_ADDRESS_LEN);
3042 vos_mem_copy(pTLCb->spoofMacAddr.spoofMac.bytes, spoofMacAddr,
3043 VOS_MAC_ADDRESS_LEN);
3044
3045 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
3046 "TL: SelfSTA mac Addr for current Scan "MAC_ADDRESS_STR,
3047 MAC_ADDR_ARRAY(pTLCb->spoofMacAddr.selfMac.bytes));
3048
3049 return VOS_STATUS_SUCCESS;
3050}/* WLANTL_updateSpoofMacAddr */
Jeff Johnson295189b2012-06-20 16:38:30 -07003051/*==========================================================================
3052
3053 FUNCTION WLANTL_RegisterMgmtFrmClient
3054
3055 DESCRIPTION
3056 Called by PE to register as a client for management frames delivery.
3057
3058 DEPENDENCIES
3059 TL must be initialized before this API can be called.
3060
3061 PARAMETERS
3062
3063 IN
3064 pvosGCtx: pointer to the global vos context; a handle to
3065 TL's control block can be extracted from its context
3066 pfnTlMgmtFrmRx: pointer to the receive processing routine for
3067 management frames
3068
3069 RETURN VALUE
3070 The result code associated with performing the operation
3071
3072 VOS_STATUS_E_INVAL: Input parameters are invalid
3073 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3074 page fault
3075 VOS_STATUS_E_EXISTS: Mgmt Frame client was already registered
3076 VOS_STATUS_SUCCESS: Everything is good :)
3077
3078 SIDE EFFECTS
3079
3080============================================================================*/
3081VOS_STATUS
3082WLANTL_RegisterMgmtFrmClient
3083(
3084 v_PVOID_t pvosGCtx,
3085 WLANTL_MgmtFrmRxCBType pfnTlMgmtFrmRx
3086)
3087{
3088 WLANTL_CbType* pTLCb = NULL;
3089 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3090
3091 /*------------------------------------------------------------------------
3092 Sanity check
3093 ------------------------------------------------------------------------*/
3094 if ( NULL == pfnTlMgmtFrmRx )
3095 {
3096 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3097 "WLAN TL:Invalid parameter sent on WLANTL_RegisterMgmtFrmClient"));
3098 return VOS_STATUS_E_INVAL;
3099 }
3100
3101 /*------------------------------------------------------------------------
3102 Extract TL control block
3103 ------------------------------------------------------------------------*/
3104 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3105 if ( NULL == pTLCb )
3106 {
3107 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3108 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3109 return VOS_STATUS_E_FAULT;
3110 }
3111
3112 /*------------------------------------------------------------------------
3113 Make sure this is the first registration attempt
3114 ------------------------------------------------------------------------*/
3115 if ( 0 != pTLCb->tlMgmtFrmClient.ucExists )
3116 {
3117 pTLCb->tlMgmtFrmClient.ucExists++;
3118 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3119 "WLAN TL:Management frame client was already registered"));
3120 return VOS_STATUS_E_EXISTS;
3121 }
3122
3123 /*------------------------------------------------------------------------
3124 Register station with TL
3125 ------------------------------------------------------------------------*/
3126 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3127 "WLAN TL:Registering Management Frame Client" ));
3128
3129 pTLCb->tlMgmtFrmClient.ucExists++;
3130
3131 if ( NULL != pfnTlMgmtFrmRx )
3132 {
3133 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = pfnTlMgmtFrmRx;
3134 }
3135
3136 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3137
3138 return VOS_STATUS_SUCCESS;
3139}/* WLANTL_RegisterMgmtFrmClient */
3140
3141/*==========================================================================
3142
3143 FUNCTION WLANTL_DeRegisterMgmtFrmClient
3144
3145 DESCRIPTION
3146 Called by PE to deregister as a client for management frames delivery.
3147
3148 DEPENDENCIES
3149 TL must be initialized before this API can be called.
3150
3151 PARAMETERS
3152
3153 IN
3154 pvosGCtx: pointer to the global vos context; a handle to
3155 TL's control block can be extracted from its context
3156 RETURN VALUE
3157 The result code associated with performing the operation
3158
3159 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3160 page fault
3161 VOS_STATUS_E_EXISTS: Mgmt Frame client was never registered
3162 VOS_STATUS_SUCCESS: Everything is good :)
3163
3164 SIDE EFFECTS
3165
3166============================================================================*/
3167VOS_STATUS
3168WLANTL_DeRegisterMgmtFrmClient
3169(
3170 v_PVOID_t pvosGCtx
3171)
3172{
3173 WLANTL_CbType* pTLCb = NULL;
3174 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3175
3176 /*------------------------------------------------------------------------
3177 Extract TL control block
3178 ------------------------------------------------------------------------*/
3179 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3180 if ( NULL == pTLCb )
3181 {
3182 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3183 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
3184 return VOS_STATUS_E_FAULT;
3185 }
3186
3187 /*------------------------------------------------------------------------
3188 Make sure this is the first registration attempt
3189 ------------------------------------------------------------------------*/
3190 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3191 {
3192 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3193 "WLAN TL:Management frame client was never registered"));
3194 return VOS_STATUS_E_EXISTS;
3195 }
3196
3197 /*------------------------------------------------------------------------
3198 Clear registration with TL
3199 ------------------------------------------------------------------------*/
3200 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3201 "WLAN TL:Deregistering Management Frame Client" ));
3202
3203 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
3204 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff)
3205 {
3206 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3207 "WLAN TL:Management cache buffer not empty on deregistering"
3208 " - dropping packet" ));
3209 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
3210
3211 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
3212 }
3213
3214 pTLCb->tlMgmtFrmClient.ucExists = 0;
3215
3216 return VOS_STATUS_SUCCESS;
3217}/* WLANTL_RegisterMgmtFrmClient */
3218
3219/*==========================================================================
3220
3221 FUNCTION WLANTL_TxMgmtFrm
3222
3223 DESCRIPTION
3224 Called by PE when it want to send out a management frame.
3225 HAL will also use this API for the few frames it sends out, they are not
3226 management frames howevere it is accepted that an exception will be
3227 allowed ONLY for the usage of HAL.
3228 Generic data frames SHOULD NOT travel through this function.
3229
3230 DEPENDENCIES
3231 TL must be initialized before this API can be called.
3232
3233 RESTRICTION: If PE sends another packet before TL manages to process the
3234 previously sent packet call will end in failure
3235
3236 Frames comming through here must be 802.11 frames, frame
3237 translation in UMA will be automatically disabled.
3238
3239 PARAMETERS
3240
3241 IN
3242 pvosGCtx: pointer to the global vos context;a handle to TL's
3243 control block can be extracted from its context
3244 vosFrmBuf: pointer to a vOSS buffer containing the management
3245 frame to be transmitted
3246 usFrmLen: the length of the frame to be transmitted; information
3247 is already included in the vOSS buffer
3248 wFrmType: the type of the frame being transmitted
3249 tid: tid used to transmit this frame
3250 pfnCompTxFunc: function pointer to the transmit complete routine
3251 pvBDHeader: pointer to the BD header, if NULL it means it was not
3252 yet constructed and it lies within TL's responsibility
3253 to do so; if not NULL it is expected that it was
3254 already packed inside the vos packet
3255 ucAckResponse: flag notifying it an interrupt is needed for the
3256 acknowledgement received when the frame is sent out
3257 the air and ; the interrupt will be processed by HAL,
3258 only one such frame can be pending in the system at
3259 one time.
3260
3261
3262 RETURN VALUE
3263 The result code associated with performing the operation
3264
3265 VOS_STATUS_E_INVAL: Input parameters are invalid
3266 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3267 page fault
3268 VOS_STATUS_E_EXISTS: Mgmt Frame client was not yet registered
3269 VOS_STATUS_E_BUSY: The previous Mgmt packet was not yet transmitted
3270 VOS_STATUS_SUCCESS: Everything is good :)
3271
3272 Other failure messages may be returned from the BD header handling
3273 routines, please check apropriate API for more info.
3274
3275 SIDE EFFECTS
3276
3277============================================================================*/
3278VOS_STATUS
3279WLANTL_TxMgmtFrm
3280(
3281 v_PVOID_t pvosGCtx,
3282 vos_pkt_t* vosFrmBuf,
3283 v_U16_t usFrmLen,
3284 v_U8_t wFrmType,
3285 v_U8_t ucTid,
3286 WLANTL_TxCompCBType pfnCompTxFunc,
3287 v_PVOID_t pvBDHeader,
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303288 v_U32_t ucAckResponse
Jeff Johnson295189b2012-06-20 16:38:30 -07003289)
3290{
3291 WLANTL_CbType* pTLCb = NULL;
3292 v_MACADDR_t vDestMacAddr;
3293 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3294 v_U16_t usPktLen;
3295 v_U32_t usTimeStamp = 0;
3296 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3297
3298 /*------------------------------------------------------------------------
3299 Sanity check
3300 ------------------------------------------------------------------------*/
3301 if ( NULL == vosFrmBuf )
3302 {
3303 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3304 "WLAN TL:Invalid parameter sent on WLANTL_TxMgmtFrm"));
3305 return VOS_STATUS_E_INVAL;
3306 }
3307
3308 /*------------------------------------------------------------------------
3309 Extract TL control block
3310 ------------------------------------------------------------------------*/
3311 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3312 if ( NULL == pTLCb )
3313 {
3314 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3315 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxMgmtFrm"));
3316 return VOS_STATUS_E_FAULT;
3317 }
3318
3319 /*------------------------------------------------------------------------
3320 Ensure that management frame client was previously registered
3321 ------------------------------------------------------------------------*/
3322 if ( 0 == pTLCb->tlMgmtFrmClient.ucExists )
3323 {
3324 pTLCb->tlMgmtFrmClient.ucExists++;
3325 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3326 "WLAN TL:Management Frame client not register on WLANTL_TxMgmtFrm"));
3327 return VOS_STATUS_E_EXISTS;
3328 }
3329
3330 /*------------------------------------------------------------------------
3331 Check if any Mgmt Frm is pending
3332 ------------------------------------------------------------------------*/
3333 //vosTempBuff = pTLCb->tlMgmtFrmClient.vosPendingDataBuff;
3334 if ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff )
3335 {
3336
3337 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3338 "WLAN TL:Management Frame already pending tx in TL: failing old one"));
3339
3340
3341 /*Failing the tx for the previous packet enqued by PE*/
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303342 //vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3343 // (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345 //vos_pkt_get_user_data_ptr( vosTempBuff, VOS_PKT_USER_DATA_ID_TL,
3346 // (v_PVOID_t)&pfnTxComp);
3347
3348 /*it should never be NULL - default handler should be registered if none*/
3349 //if ( NULL == pfnTxComp )
3350 //{
3351 // VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3352 // "NULL pointer to Tx Complete on WLANTL_TxMgmtFrm");
3353 // VOS_ASSERT(0);
3354 // return VOS_STATUS_E_FAULT;
3355 //}
3356
3357 //pfnTxComp( pvosGCtx, vosTempBuff, VOS_STATUS_E_RESOURCES );
3358 //return VOS_STATUS_E_BUSY;
3359
3360
3361 //pfnCompTxFunc( pvosGCtx, vosFrmBuf, VOS_STATUS_E_RESOURCES);
3362 return VOS_STATUS_E_RESOURCES;
3363 }
3364
3365
3366 /*------------------------------------------------------------------------
3367 Check if BD header was build, if not construct
3368 ------------------------------------------------------------------------*/
3369 if ( NULL == pvBDHeader )
3370 {
3371 v_MACADDR_t* pvAddr2MacAddr;
3372 v_U8_t uQosHdr = VOS_FALSE;
3373
3374 /* Get address 2 of Mangement Frame to give to WLANHAL_FillTxBd */
3375 vosStatus = vos_pkt_peek_data( vosFrmBuf,
3376 WLANTL_MAC_ADDR_ALIGN(1) + VOS_MAC_ADDR_SIZE,
3377 (v_PVOID_t)&pvAddr2MacAddr, VOS_MAC_ADDR_SIZE);
3378
3379 if ( VOS_STATUS_SUCCESS != vosStatus )
3380 {
3381 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3382 "WLAN TL:Failed while attempting to get addr2 %d", vosStatus));
3383 return vosStatus;
3384 }
Gopichand Nakkala0f3eb5c2013-05-07 16:48:38 +05303385
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003386 /* ESE IAPP/TDLS Frame which are data frames but technically used
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 * for management functionality comes through route.
3388 */
3389 if (WLANTL_IS_QOS_DATA_FRAME(wFrmType)) \
3390 {
3391 uQosHdr = VOS_TRUE;
3392 }
Siddharth Bhal4551b102014-10-09 21:36:36 +05303393
3394 if (WLANTL_IS_PROBE_REQ(wFrmType))
3395 {
3396 if (VOS_TRUE == vos_mem_compare((v_VOID_t*) pvAddr2MacAddr,
3397 (v_VOID_t*) &pTLCb->spoofMacAddr.spoofMac, VOS_MAC_ADDRESS_LEN))
3398 {
3399 pvAddr2MacAddr = (v_PVOID_t)pTLCb->spoofMacAddr.selfMac.bytes;
3400 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3401 "TL: using self sta addr to get staidx for spoofed probe req "
3402 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pvAddr2MacAddr->bytes));
3403 }
3404 }
3405
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 /*----------------------------------------------------------------------
3407 Call WDA to build TX header
3408 ----------------------------------------------------------------------*/
3409 vosStatus = WDA_DS_BuildTxPacketInfo( pvosGCtx, vosFrmBuf , &vDestMacAddr,
3410 1 /* always 802.11 frames*/, &usPktLen, uQosHdr /*qos not enabled !!!*/,
Siddharth Bhal4551b102014-10-09 21:36:36 +05303411 0 /* WDS off */, 0, wFrmType, pvAddr2MacAddr, ucTid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 ucAckResponse, usTimeStamp, 0, 0 );
3413
3414
3415 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
3416 {
3417 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3418 "WLAN TL:Failed while attempting to build TX header %d", vosStatus));
3419 return vosStatus;
3420 }
3421 }/* if BD header not present */
3422
3423 /*------------------------------------------------------------------------
3424 Save buffer and notify BAL; no lock is needed if the above restriction
3425 is met
3426 Save the tx complete fnct pointer as tl specific data in the vos buffer
3427 ------------------------------------------------------------------------*/
3428 if ( NULL != pfnCompTxFunc )
3429 {
3430 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3431 (v_PVOID_t)pfnCompTxFunc);
3432 }
3433 else
3434 {
3435 vos_pkt_set_user_data_ptr( vosFrmBuf, VOS_PKT_USER_DATA_ID_TL,
3436 (v_PVOID_t)WLANTL_TxCompDefaultCb);
3437
3438 }
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303439 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
3440 (uintptr_t)vosFrmBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003441
3442 /*------------------------------------------------------------------------
3443 Check if thre are enough resources for transmission and tx is not
3444 suspended.
3445 ------------------------------------------------------------------------*/
3446 if ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF )
3447 {
3448 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3449 "WLAN TL:Issuing Xmit start request to BAL for MGMT"));
3450 vosStatus = WDA_DS_StartXmit(pvosGCtx);
3451 if(VOS_STATUS_SUCCESS != vosStatus)
3452 {
3453 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
3454 "WLAN TL:WDA_DS_StartXmit fails. vosStatus %d", vosStatus));
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05303455 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.vosPendingDataBuff,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 }
3457 return vosStatus;
3458
3459 }
3460 else
3461 {
3462 /*---------------------------------------------------------------------
3463 No error code is sent because TL will resume tx autonomously if
3464 resources become available or tx gets resumed
3465 ---------------------------------------------------------------------*/
3466 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
3467 "WLAN TL:Request to send for Mgmt Frm but condition not met. Res: %d",
3468 pTLCb->uResCount));
3469 }
3470
3471 return VOS_STATUS_SUCCESS;
3472}/* WLANTL_TxMgmtFrm */
3473
3474/*----------------------------------------------------------------------------
3475 INTERACTION WITH HAL
3476 ---------------------------------------------------------------------------*/
3477
3478/*==========================================================================
3479
3480 FUNCTION WLANTL_ResetNotification
3481
3482 DESCRIPTION
3483 HAL notifies TL when the module is being reset.
3484 Currently not used.
3485
3486 DEPENDENCIES
3487
3488 PARAMETERS
3489
3490 IN
3491 pvosGCtx: pointer to the global vos context; a handle to TL's
3492 control block can be extracted from its context
3493
3494
3495 RETURN VALUE
3496 The result code associated with performing the operation
3497
3498 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3499 page fault
3500 VOS_STATUS_SUCCESS: Everything is good :)
3501
3502 SIDE EFFECTS
3503
3504============================================================================*/
3505VOS_STATUS
3506WLANTL_ResetNotification
3507(
3508 v_PVOID_t pvosGCtx
3509)
3510{
3511 WLANTL_CbType* pTLCb = NULL;
3512 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3513
3514 /*------------------------------------------------------------------------
3515 Sanity check
3516 Extract TL control block
3517 ------------------------------------------------------------------------*/
3518 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3519 if ( NULL == pTLCb )
3520 {
3521 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3522 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResetNotification"));
3523 return VOS_STATUS_E_FAULT;
3524 }
3525
3526 WLANTL_CleanCB(pTLCb, 1 /*empty all queues and pending packets*/);
3527 return VOS_STATUS_SUCCESS;
3528}/* WLANTL_ResetNotification */
3529
3530/*==========================================================================
3531
3532 FUNCTION WLANTL_SuspendDataTx
3533
3534 DESCRIPTION
3535 HAL calls this API when it wishes to suspend transmission for a
3536 particular STA.
3537
3538 DEPENDENCIES
3539 The STA for which the request is made must be first registered with
3540 TL by HDD.
3541
3542 RESTRICTION: In case of a suspend, the flag write and read will not be
3543 locked: worst case scenario one more packet can get
3544 through before the flag gets updated (we can make this
3545 write atomic as well to guarantee consistency)
3546
3547 PARAMETERS
3548
3549 IN
3550 pvosGCtx: pointer to the global vos context; a handle to TL's
3551 control block can be extracted from its context
3552 pucSTAId: identifier of the station for which the request is made;
3553 a value of NULL assumes suspend on all active station
3554 pfnSuspendTxCB: pointer to the suspend result notification in case the
3555 call is asynchronous
3556
3557
3558 RETURN VALUE
3559 The result code associated with performing the operation
3560
3561 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3562 to TL cb is NULL ; access would cause a page fault
3563 VOS_STATUS_E_EXISTS: Station was not registered
3564 VOS_STATUS_SUCCESS: Everything is good :)
3565
3566 SIDE EFFECTS
3567
3568============================================================================*/
3569
3570VOS_STATUS
3571WLANTL_SuspendDataTx
3572(
3573 v_PVOID_t pvosGCtx,
3574 v_U8_t* pucSTAId,
3575 WLANTL_SuspendCBType pfnSuspendTx
3576)
3577{
3578 WLANTL_CbType* pTLCb = NULL;
3579 vos_msg_t vosMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07003580
3581 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3582
3583 /*------------------------------------------------------------------------
3584 Sanity check
3585 Extract TL control block
3586 ------------------------------------------------------------------------*/
3587 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003588 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 {
3590 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3591 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
3592 return VOS_STATUS_E_FAULT;
3593 }
3594
3595 /*------------------------------------------------------------------------
3596 Check the type of request: generic suspend, or per station suspend
3597 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003598 if (NULL == pucSTAId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 {
3600 /* General Suspend Request received */
3601 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3602 "WLAN TL:General suspend requested"));
Hoonki Lee14621352013-04-16 17:51:19 -07003603 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 vosMsg.reserved = WLAN_MAX_STA_COUNT;
3605 }
3606 else
3607 {
Hoonki Lee14621352013-04-16 17:51:19 -07003608 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 {
Hoonki Lee14621352013-04-16 17:51:19 -07003610 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3611 "WLAN TL:Invalid station id %d requested on WLANTL_SuspendDataTx", *pucSTAId));
3612 return VOS_STATUS_E_FAULT;
3613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003614
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303615 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3616 {
3617 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3618 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3619 "WLANTL_SuspendDataTx", *pucSTAId));
3620 return VOS_STATUS_E_FAULT;
3621 }
3622
3623 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003624 {
3625 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3626 "WLAN TL:Station %d was not previously registered on WLANTL_SuspendDataTx", *pucSTAId));
3627 return VOS_STATUS_E_EXISTS;
3628 }
3629
3630 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3631 "WLAN TL:Suspend request for station: %d", *pucSTAId));
3632 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 vosMsg.reserved = *pucSTAId;
3634 }
3635
3636 /*------------------------------------------------------------------------
3637 Serialize request through TX thread
3638 ------------------------------------------------------------------------*/
3639 vosMsg.type = WLANTL_TX_SIG_SUSPEND;
3640 vosMsg.bodyptr = (v_PVOID_t)pfnSuspendTx;
3641
Katya Nigam42e16e82014-02-04 16:28:55 +05303642 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_SUSPEND_DATA_TX,
3643 vosMsg.reserved , 0 ));
3644
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
3646 {
3647 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003648 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 }
3650
3651 return VOS_STATUS_SUCCESS;
3652}/* WLANTL_SuspendDataTx */
3653
3654/*==========================================================================
3655
3656 FUNCTION WLANTL_ResumeDataTx
3657
3658 DESCRIPTION
3659 Called by HAL to resume data transmission for a given STA.
3660
3661 WARNING: If a station was individually suspended a global resume will
3662 not resume that station
3663
3664 DEPENDENCIES
3665
3666 PARAMETERS
3667
3668 IN
3669 pvosGCtx: pointer to the global vos context; a handle to TL's
3670 control block can be extracted from its context
3671 pucSTAId: identifier of the station which is being resumed; NULL
3672 translates into global resume
3673
3674 RETURN VALUE
3675 The result code associated with performing the operation
3676
3677 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3678 to TL cb is NULL ; access would cause a page fault
3679 VOS_STATUS_E_EXISTS: Station was not registered
3680 VOS_STATUS_SUCCESS: Everything is good :)
3681
3682 SIDE EFFECTS
3683
3684============================================================================*/
3685
3686VOS_STATUS
3687WLANTL_ResumeDataTx
3688(
3689 v_PVOID_t pvosGCtx,
3690 v_U8_t* pucSTAId
3691)
3692{
3693 WLANTL_CbType* pTLCb = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3695
3696 /*------------------------------------------------------------------------
3697 Sanity check
3698 Extract TL control block
3699 ------------------------------------------------------------------------*/
3700 pTLCb = VOS_GET_TL_CB(pvosGCtx);
Hoonki Lee14621352013-04-16 17:51:19 -07003701 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 {
3703 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3704 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ResumeDataTx"));
3705 return VOS_STATUS_E_FAULT;
3706 }
3707
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 /*------------------------------------------------------------------------
3709 Check to see the type of resume
3710 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003711 if ( NULL == pucSTAId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303713 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3714 41 , 0 ));
3715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3717 "WLAN TL:General resume requested"));
3718 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 }
3720 else
3721 {
Katya Nigam42e16e82014-02-04 16:28:55 +05303722 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_RESUME_DATA_TX,
3723 *pucSTAId , 0 ));
3724
Hoonki Lee14621352013-04-16 17:51:19 -07003725 if ( WLANTL_STA_ID_INVALID( *pucSTAId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 {
Hoonki Lee14621352013-04-16 17:51:19 -07003727 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3728 "WLAN TL:Invalid station id %d requested on WLANTL_ResumeDataTx", *pucSTAId));
3729 return VOS_STATUS_E_FAULT;
3730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003731
Gopichand Nakkalae5fef6c2013-06-19 18:04:23 +05303732 if ( NULL == pTLCb->atlSTAClients[*pucSTAId] )
3733 {
3734 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3735 "WLAN TL:Invalid pTLCb->atlSTAClients pointer for STA Id :%d on "
3736 "WLANTL_ResumeDataTx", *pucSTAId));
3737 return VOS_STATUS_E_FAULT;
3738 }
3739
3740 if ( 0 == pTLCb->atlSTAClients[*pucSTAId]->ucExists )
Hoonki Lee14621352013-04-16 17:51:19 -07003741 {
3742 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3743 "WLAN TL:Station %d was not previously registered on WLANTL_ResumeDataTx", *pucSTAId));
3744 return VOS_STATUS_E_EXISTS;
3745 }
3746
3747 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3748 "WLAN TL:Resume request for station: %d", *pucSTAId));
3749 vos_atomic_set_U8( &pTLCb->atlSTAClients[*pucSTAId]->ucTxSuspended, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 }
3751
3752 /*------------------------------------------------------------------------
3753 Resuming transmission
3754 ------------------------------------------------------------------------*/
Hoonki Lee14621352013-04-16 17:51:19 -07003755 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
3756 ( 0 == pTLCb->ucTxSuspended ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 {
3758 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
3759 "WLAN TL:Resuming transmission"));
3760 return WDA_DS_StartXmit(pvosGCtx);
3761 }
3762
3763 return VOS_STATUS_SUCCESS;
3764}/* WLANTL_ResumeDataTx */
3765
3766/*==========================================================================
3767 FUNCTION WLANTL_SuspendCB
3768
3769 DESCRIPTION
3770 Callback function for serializing Suspend signal through Tx thread
3771
3772 DEPENDENCIES
3773 Just notify HAL that suspend in TL is complete.
3774
3775 PARAMETERS
3776
3777 IN
3778 pvosGCtx: pointer to the global vos context; a handle to TL's
3779 control block can be extracted from its context
3780 pUserData: user data sent with the callback
3781
3782 RETURN VALUE
3783 The result code associated with performing the operation
3784
3785 VOS_STATUS_E_INVAL: invalid input parameters
3786 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
3787 page fault
3788 VOS_STATUS_SUCCESS: Everything is good :)
3789
3790
3791 SIDE EFFECTS
3792
3793============================================================================*/
3794VOS_STATUS
3795WLANTL_SuspendCB
3796(
3797 v_PVOID_t pvosGCtx,
3798 WLANTL_SuspendCBType pfnSuspendCB,
3799 v_U16_t usReserved
3800)
3801{
3802 WLANTL_CbType* pTLCb = NULL;
3803 v_U8_t ucSTAId = (v_U8_t)usReserved;
3804 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3805
3806 /*------------------------------------------------------------------------
3807 Sanity check
3808 ------------------------------------------------------------------------*/
3809 if ( NULL == pfnSuspendCB )
3810 {
3811 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
3812 "WLAN TL: No Call back processing requested WLANTL_SuspendCB"));
3813 return VOS_STATUS_SUCCESS;
3814 }
3815
3816 /*------------------------------------------------------------------------
3817 Extract TL control block
3818 ------------------------------------------------------------------------*/
3819 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3820 if ( NULL == pTLCb )
3821 {
3822 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3823 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendCB"));
3824 return VOS_STATUS_E_FAULT;
3825 }
3826
3827 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
3828 {
3829 pfnSuspendCB(pvosGCtx, NULL, VOS_STATUS_SUCCESS);
3830 }
3831 else
3832 {
3833 pfnSuspendCB(pvosGCtx, &ucSTAId, VOS_STATUS_SUCCESS);
3834 }
3835
3836 return VOS_STATUS_SUCCESS;
3837}/*WLANTL_SuspendCB*/
3838
3839
3840/*----------------------------------------------------------------------------
3841 CLIENT INDEPENDENT INTERFACE
3842 ---------------------------------------------------------------------------*/
3843
3844/*==========================================================================
3845
3846 FUNCTION WLANTL_GetTxPktCount
3847
3848 DESCRIPTION
3849 TL will provide the number of transmitted packets counted per
3850 STA per TID.
3851
3852 DEPENDENCIES
3853
3854 PARAMETERS
3855
3856 IN
3857 pvosGCtx: pointer to the global vos context; a handle to TL's
3858 control block can be extracted from its context
3859 ucSTAId: identifier of the station
3860 ucTid: identifier of the tspec
3861
3862 OUT
3863 puTxPktCount: the number of packets tx packet for this STA and TID
3864
3865 RETURN VALUE
3866 The result code associated with performing the operation
3867
3868 VOS_STATUS_E_INVAL: Input parameters are invalid
3869 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3870 to TL cb is NULL ; access would cause a page fault
3871 VOS_STATUS_E_EXISTS: Station was not registered
3872 VOS_STATUS_SUCCESS: Everything is good :)
3873
3874 SIDE EFFECTS
3875
3876============================================================================*/
3877VOS_STATUS
3878WLANTL_GetTxPktCount
3879(
3880 v_PVOID_t pvosGCtx,
3881 v_U8_t ucSTAId,
3882 v_U8_t ucTid,
3883 v_U32_t* puTxPktCount
3884)
3885{
3886 WLANTL_CbType* pTLCb = NULL;
3887 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3888
3889 /*------------------------------------------------------------------------
3890 Sanity check
3891 ------------------------------------------------------------------------*/
3892 if ( NULL == puTxPktCount )
3893 {
3894 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3895 "WLAN TL:Invalid parameter sent on WLANTL_GetTxPktCount"));
3896 return VOS_STATUS_E_INVAL;
3897 }
3898
3899 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
3900 {
3901 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3902 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetTxPktCount",
3903 ucSTAId, ucTid));
3904 return VOS_STATUS_E_FAULT;
3905 }
3906
3907 /*------------------------------------------------------------------------
3908 Extract TL control block and check if station exists
3909 ------------------------------------------------------------------------*/
3910 pTLCb = VOS_GET_TL_CB(pvosGCtx);
3911 if ( NULL == pTLCb )
3912 {
3913 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3914 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetTxPktCount"));
3915 return VOS_STATUS_E_FAULT;
3916 }
3917
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303918 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
3919 {
3920 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3921 "WLAN TL:Client Memory was not allocated on %s", __func__));
3922 return VOS_STATUS_E_FAILURE;
3923 }
3924
3925 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 {
3927 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3928 "WLAN TL:Station was not previously registered on WLANTL_GetTxPktCount %d",
3929 ucSTAId));
3930 return VOS_STATUS_E_EXISTS;
3931 }
3932
3933 /*------------------------------------------------------------------------
3934 Return data
3935 ------------------------------------------------------------------------*/
3936 //VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
3937 // "WLAN TL:Requested tx packet count for STA: %d, TID: %d",
3938 // ucSTAId, ucTid);
3939
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303940 *puTxPktCount = pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07003941
3942 return VOS_STATUS_SUCCESS;
3943}/* WLANTL_GetTxPktCount */
3944
3945/*==========================================================================
3946
3947 FUNCTION WLANTL_GetRxPktCount
3948
3949 DESCRIPTION
3950 TL will provide the number of received packets counted per
3951 STA per TID.
3952
3953 DEPENDENCIES
3954
3955 PARAMETERS
3956
3957 IN
3958 pvosGCtx: pointer to the global vos context; a handle to TL's
3959 control block can be extracted from its context
3960 ucSTAId: identifier of the station
3961 ucTid: identifier of the tspec
3962
3963 OUT
3964 puTxPktCount: the number of packets rx packet for this STA and TID
3965
3966 RETURN VALUE
3967 The result code associated with performing the operation
3968
3969 VOS_STATUS_E_INVAL: Input parameters are invalid
3970 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer
3971 to TL cb is NULL ; access would cause a page fault
3972 VOS_STATUS_E_EXISTS: Station was not registered
3973 VOS_STATUS_SUCCESS: Everything is good :)
3974
3975 SIDE EFFECTS
3976
3977============================================================================*/
3978VOS_STATUS
3979WLANTL_GetRxPktCount
3980(
3981 v_PVOID_t pvosGCtx,
3982 v_U8_t ucSTAId,
3983 v_U8_t ucTid,
3984 v_U32_t* puRxPktCount
3985)
3986{
3987 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05303988 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
3990
3991 /*------------------------------------------------------------------------
3992 Sanity check
3993 ------------------------------------------------------------------------*/
3994 if ( NULL == puRxPktCount )
3995 {
3996 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
3997 "WLAN TL:Invalid parameter sent on WLANTL_GetRxPktCount"));
3998 return VOS_STATUS_E_INVAL;
3999 }
4000
4001 if ( WLANTL_STA_ID_INVALID( ucSTAId ) || WLANTL_TID_INVALID( ucTid) )
4002 {
4003 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4004 "WLAN TL:Invalid station id %d/tid %d requested on WLANTL_GetRxPktCount",
4005 ucSTAId, ucTid));
4006 return VOS_STATUS_E_FAULT;
4007 }
4008
4009 /*------------------------------------------------------------------------
4010 Extract TL control block and existance
4011 ------------------------------------------------------------------------*/
4012 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4013 if ( NULL == pTLCb )
4014 {
4015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4016 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetRxPktCount"));
4017 return VOS_STATUS_E_FAULT;
4018 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304019 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004020
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304021 if ( NULL == pClientSTA )
4022 {
4023 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4024 "WLAN TL:Client Memory was not allocated on %s", __func__));
4025 return VOS_STATUS_E_FAILURE;
4026 }
4027
4028 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 {
4030 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4031 "WLAN TL:Station was not previously registered on WLANTL_GetRxPktCount"));
4032 return VOS_STATUS_E_EXISTS;
4033 }
4034
4035 /*------------------------------------------------------------------------
4036 Return data
4037 ------------------------------------------------------------------------*/
4038 TLLOG3(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
4039 "WLAN TL:Requested rx packet count for STA: %d, TID: %d",
4040 ucSTAId, ucTid));
4041
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304042 *puRxPktCount = pClientSTA->auRxCount[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07004043
4044 return VOS_STATUS_SUCCESS;
4045}/* WLANTL_GetRxPktCount */
4046
Jeff Johnson295189b2012-06-20 16:38:30 -07004047VOS_STATUS
4048WLANTL_TxFCFrame
4049(
4050 v_PVOID_t pvosGCtx
4051);
Jeff Johnson295189b2012-06-20 16:38:30 -07004052/*============================================================================
4053 TL INTERNAL API DEFINITION
4054============================================================================*/
4055
4056/*==========================================================================
4057
4058 FUNCTION WLANTL_GetFrames
4059
4060 DESCRIPTION
4061
4062 BAL calls this function at the request of the lower bus interface.
4063 When this request is being received TL will retrieve packets from HDD
4064 in accordance with the priority rules and the count supplied by BAL.
4065
4066 DEPENDENCIES
4067
4068 HDD must have registered with TL at least one STA before this function
4069 can be called.
4070
4071 PARAMETERS
4072
4073 IN
4074 pvosGCtx: pointer to the global vos context; a handle to TL's
4075 or BAL's control block can be extracted from its context
4076 uSize: maximum size accepted by the lower layer
4077 uFlowMask TX flow control mask for Prima. Each bit is defined as
4078 WDA_TXFlowEnumType
4079
4080 OUT
4081 vosDataBuff: it will contain a pointer to the first buffer supplied
4082 by TL, if there is more than one packet supplied, TL
4083 will chain them through vOSS buffers
4084
4085 RETURN VALUE
4086
4087 The result code associated with performing the operation
4088
4089 1 or more: number of required resources if there are still frames to fetch
4090 0 : error or HDD queues are drained
4091
4092 SIDE EFFECTS
4093
4094 NOTE
4095
4096 Featurized uFlowMask. If we want to remove featurization, we need to change
4097 BAL on Volans.
4098
4099============================================================================*/
4100v_U32_t
4101WLANTL_GetFrames
4102(
4103 v_PVOID_t pvosGCtx,
4104 vos_pkt_t **ppFrameDataBuff,
4105 v_U32_t uSize,
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 v_U8_t uFlowMask,
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 v_BOOL_t* pbUrgent
4108)
4109{
4110 vos_pkt_t** pvosDataBuff = (vos_pkt_t**)ppFrameDataBuff;
4111 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304112 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 v_U32_t uRemaining = uSize;
4114 vos_pkt_t* vosRoot;
4115 vos_pkt_t* vosTempBuf;
4116 WLANTL_STAFuncType pfnSTAFsm;
4117 v_U16_t usPktLen;
4118 v_U32_t uResLen;
4119 v_U8_t ucSTAId;
4120 v_U8_t ucAC;
4121 vos_pkt_t* vosDataBuff;
4122 v_U32_t uTotalPktLen;
4123 v_U32_t i=0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004124 v_U32_t j=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 v_U32_t ucResult = 0;
4126 VOS_STATUS vosStatus;
4127 WLANTL_STAEventType wSTAEvent;
4128 tBssSystemRole systemRole;
4129 tpAniSirGlobal pMac;
4130 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4131
4132 /*------------------------------------------------------------------------
4133 Sanity check
4134 Extract TL control block
4135 ------------------------------------------------------------------------*/
4136 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4137 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
4138 {
4139 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4140 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
4141 return ucResult;
4142 }
4143
4144 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
4145 if ( NULL == pMac )
4146 {
4147 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004148 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 return ucResult;
4150 }
4151
4152 vosDataBuff = pTLCb->vosDummyBuf; /* Just to avoid checking for NULL at
4153 each iteration */
4154
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 pTLCb->uResCount = uSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07004156
4157 /*-----------------------------------------------------------------------
4158 Save the root as we will walk this chain as we fill it
4159 -----------------------------------------------------------------------*/
4160 vosRoot = vosDataBuff;
4161
4162 /*-----------------------------------------------------------------------
4163 There is still data - until FSM function says otherwise
4164 -----------------------------------------------------------------------*/
4165 pTLCb->bUrgent = FALSE;
4166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 while (( pTLCb->tlConfigInfo.uMinFramesProcThres < pTLCb->uResCount ) &&
4168 ( 0 < uRemaining ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 {
4170 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07004171#ifdef WLAN_SOFTAP_FLOWCTRL_EN
4172/* FIXME: The code has been disabled since it is creating issues in power save */
4173 if (eSYSTEM_AP_ROLE == systemRole)
4174 {
4175 if (pTLCb->done_once == 0 && NULL == pTLCb->vosTxFCBuf)
4176 {
4177 WLANTL_TxFCFrame (pvosGCtx);
4178 pTLCb->done_once ++;
4179 }
4180 }
4181 if ( NULL != pTLCb->vosTxFCBuf )
4182 {
4183 //there is flow control packet waiting to be sent
4184 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->vosTxFCBuf, usPktLen, uResLen, uTotalPktLen);
4185
4186 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004187 ( uRemaining > uTotalPktLen ) &&
4188 ( uFlowMask & ( 1 << WDA_TXFLOW_FC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 {
4190 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4191 "WLAN TL:Chaining FC frame first on GetFrame"));
4192
4193 vos_pkt_chain_packet( vosDataBuff, pTLCb->vosTxFCBuf, 1 /*true*/ );
4194
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304195 vos_atomic_set( (uintptr_t*)&pTLCb->vosTxFCBuf, (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004196
4197 /*FC frames cannot be delayed*/
4198 pTLCb->bUrgent = TRUE;
4199
4200 /*Update remaining len from SSC */
4201 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4202
4203 /*Update resource count */
4204 pTLCb->uResCount -= uResLen;
4205 }
4206 else
4207 {
4208 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004209 "WLAN TL:send fc out of source %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4211 break; /* Out of resources or reached max len */
4212 }
4213 }
4214 else
4215#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07004216
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004217 if (( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ) &&
4218 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 {
4220 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4221 usPktLen, uResLen, uTotalPktLen);
4222
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004223 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4224 {
4225 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4226 VOS_ASSERT(0);
4227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004228
4229 if ( ( pTLCb->uResCount > uResLen ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004230 ( uRemaining > uTotalPktLen ) &&
4231 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 {
4233 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4234 "WLAN TL:Chaining management frame on GetFrame"));
4235
4236 vos_pkt_chain_packet( vosDataBuff,
4237 pTLCb->tlMgmtFrmClient.vosPendingDataBuff,
4238 1 /*true*/ );
4239
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304240 vos_atomic_set( (uintptr_t*)&pTLCb->tlMgmtFrmClient.
4241 vosPendingDataBuff, (uintptr_t)NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004242
4243 /*management frames cannot be delayed*/
4244 pTLCb->bUrgent = TRUE;
4245
4246 /*Update remaining len from SSC */
4247 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4248
4249 /*Update resource count */
4250 pTLCb->uResCount -= uResLen;
4251 }
4252 else
4253 {
4254 ucResult = ( pTLCb->uResCount > uResLen )?VOS_TRUE:VOS_FALSE;
4255 break; /* Out of resources or reached max len */
4256 }
4257 }
4258 else if (( pTLCb->tlBAPClient.vosPendingDataBuff ) &&
4259 ( WDA_TLI_MIN_RES_BAP <= pTLCb->uResCount ) &&
Gopichand Nakkala7e48ca72012-12-31 14:15:07 -08004260 ( 0 == pTLCb->ucTxSuspended ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 {
4262 WDA_TLI_PROCESS_FRAME_LEN( pTLCb->tlBAPClient.vosPendingDataBuff,
4263 usPktLen, uResLen, uTotalPktLen);
4264
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004265 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4266 {
4267 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4268 VOS_ASSERT(0);
4269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004270
4271 if ( ( pTLCb->uResCount > (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4272 ( uRemaining > uTotalPktLen ))
4273 {
4274 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4275 "WLAN TL:Chaining BT-AMP frame on GetFrame"));
4276
4277 vos_pkt_chain_packet( vosDataBuff,
4278 pTLCb->tlBAPClient.vosPendingDataBuff,
4279 1 /*true*/ );
4280
4281 /*BAP frames cannot be delayed*/
4282 pTLCb->bUrgent = TRUE;
4283
Arun Kumar Khandavalli0af8d3c2014-02-07 18:05:11 +05304284 vos_atomic_set( (uintptr_t*)&pTLCb->tlBAPClient.vosPendingDataBuff,
4285 (uintptr_t) NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004286
4287 /*Update remaining len from SSC */
4288 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4289
4290 /*Update resource count */
4291 pTLCb->uResCount -= uResLen;
4292 }
4293 else
4294 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 ucResult = uResLen + WDA_TLI_MIN_RES_MF;
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 break; /* Out of resources or reached max len */
4297 }
4298 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004299 /* note: this feature implemented only after WLAN_INGETRATED_SOC */
4300 /* search 'EAPOL_HI_PRIORITY' will show EAPOL HI_PRIORITY change in TL and WDI
4301 by default, EAPOL will be treated as higher priority, which means
4302 use mgmt_pool and DXE_TX_HI prority channel.
4303 this is introduced to address EAPOL failure under high background traffic
4304 with multi-channel concurrent mode. But this change works in SCC or standalone, too.
4305 see CR#387009 and WCNSOS-8
4306 */
4307 else if (( WDA_TLI_MIN_RES_MF <= pTLCb->uResCount )&&
4308 ( 0 == pTLCb->ucTxSuspended ) &&
4309 ( uFlowMask & ( 1 << WDA_TXFLOW_MGMT ) )
4310 )
4311 {
4312 vosTempBuf = NULL;
4313 /*---------------------------------------------------------------------
4314 Check to see if there was any EAPOL packet is pending
4315 *--------------------------------------------------------------------*/
4316 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4317 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304318 if ((NULL != pTLCb->atlSTAClients[i]) &&
4319 (pTLCb->atlSTAClients[i]->ucExists) &&
4320 (0 == pTLCb->atlSTAClients[i]->ucTxSuspended) &&
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004321 (WLANTL_STA_CONNECTED == pTLCb->atlSTAClients[i]->tlState) &&
4322 (pTLCb->atlSTAClients[i]->ucPktPending)
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004323 )
4324 break;
4325 }
4326
4327 if (i >= WLAN_MAX_STA_COUNT)
4328 {
4329 /* No More to Serve Exit Get Frames */
4330 break;
4331 }
4332 /* Serve EAPOL frame with HI_FLOW_MASK */
4333 ucSTAId = i;
4334
Katya Nigam42e16e82014-02-04 16:28:55 +05304335 MTRACE(vos_trace(VOS_MODULE_ID_TL,
4336 TRACE_CODE_TL_GET_FRAMES_EAPOL, ucSTAId, pTLCb->atlSTAClients[i]->tlState));
4337
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004338 for (j = WLANTL_MAX_AC ; j > 0; j--)
4339 {
4340 if (0 != pTLCb->atlSTAClients[ucSTAId]->aucACMask[j-1])
4341 {
4342 pTLCb->atlSTAClients[ucSTAId]->ucCurrentAC = j-1;
4343 pTLCb->uCurServedAC = j-1;
4344 }
4345 }
4346
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304347 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4348
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004349 wSTAEvent = WLANTL_TX_EVENT;
4350
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304351 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004352 pfnSTATbl[wSTAEvent];
4353
4354 if ( NULL != pfnSTAFsm )
4355 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304356 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004357 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004358
4359 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4360 ( NULL != vosTempBuf ))
4361 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304362 pClientSTA->pfnSTATxComp( pvosGCtx, vosTempBuf, vosStatus );
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004363 vosTempBuf = NULL;
4364 break;
4365 }/* status success*/
4366 }
4367
4368 if (NULL != vosTempBuf)
4369 {
4370 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4371
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004372 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4373 {
4374 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4375 VOS_ASSERT(0);
4376 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004377
4378 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4379 "WLAN TL:Resources needed by frame: %d", uResLen));
4380
4381 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_MF ) ) &&
4382 ( uRemaining > uTotalPktLen )
4383 )
4384 {
4385 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4386 "WLAN TL:Chaining data frame on GetFrame"));
4387
4388 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4389
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004390 /*EAPOL frame cannot be delayed*/
4391 pTLCb->bUrgent = TRUE;
4392
4393 vosTempBuf = NULL;
4394
4395 /*Update remaining len from SSC */
4396 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4397
4398 /*Update resource count */
4399 pTLCb->uResCount -= uResLen;
4400
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004401 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304402 pClientSTA->uIngress_length += uResLen;
4403 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4404 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004405 pClientSTA->ucEapolPktPending = 0;
4406 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4407 "WLAN TL:GetFrames STA: %d EAPOLPktPending %d",
4408 ucSTAId, pClientSTA->ucEapolPktPending);
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004409 }
4410 }
4411 else
4412 { // no EAPOL frames exit Get frames
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08004413 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4414 "WLAN TL:GetFrames STA: %d, no EAPOL frame, continue.",
4415 ucSTAId));
4416 continue;
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004417 }
4418 }
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07004419
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004420 else if (( WDA_TLI_MIN_RES_DATA <= pTLCb->uResCount ) &&
4421 ( 0 == pTLCb->ucTxSuspended ) &&
4422 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4423 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4424 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4425 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 {
4427 /*---------------------------------------------------------------------
4428 Check to see if there was any packet left behind previously due to
4429 size constraints
4430 ---------------------------------------------------------------------*/
4431 vosTempBuf = NULL;
4432
4433 if ( NULL != pTLCb->vosTempBuf )
4434 {
4435 vosTempBuf = pTLCb->vosTempBuf;
4436 pTLCb->vosTempBuf = NULL;
4437 ucSTAId = pTLCb->ucCachedSTAId;
4438 ucAC = pTLCb->ucCachedAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304439
4440 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
4441 {
4442 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4443 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304444 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304445 }
4446
4447 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 0;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304448 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07004449
4450 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4451 "WLAN TL:Chaining cached data frame on GetFrame"));
4452 }
4453 else
4454 {
4455 WLAN_TLGetNextTxIds( pvosGCtx, &ucSTAId);
4456 if (ucSTAId >= WLAN_MAX_STA_COUNT)
4457 {
4458 /* Packets start coming in even after insmod Without *
4459 starting Hostapd or Interface being up *
4460 During which cases STAID is invaled and hence
4461 the check. HalMsg_ScnaComplete Triggers */
4462
4463 break;
4464 }
4465 /* ucCurrentAC should have correct AC to be served by calling
4466 WLAN_TLGetNextTxIds */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304467 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304468 if ( NULL == pClientSTA )
4469 {
4470 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4471 "WLAN TL:Client Memory was not allocated on %s", __func__));
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05304472 continue;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304473 }
4474
4475 ucAC = pClientSTA->ucCurrentAC;
4476
4477 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004479 "WLAN TL: %s get one data frame, station ID %d ", __func__, ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 /*-------------------------------------------------------------------
4481 Check to see that STA is valid and tx is not suspended
4482 -------------------------------------------------------------------*/
4483 if ( ( ! WLANTL_STA_ID_INVALID( ucSTAId ) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304484 ( 0 == pClientSTA->ucTxSuspended ) &&
4485 ( 0 == pClientSTA->fcStaTxDisabled) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 {
4487 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004488 "WLAN TL: %s sta id valid and not suspended ",__func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 wSTAEvent = WLANTL_TX_EVENT;
4490
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304491 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 pfnSTATbl[wSTAEvent];
4493
4494 if ( NULL != pfnSTAFsm )
4495 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304496 pClientSTA->ucNoMoreData = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004497 vosStatus = pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuf, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004498
4499 if (( VOS_STATUS_SUCCESS != vosStatus ) &&
4500 ( NULL != vosTempBuf ))
4501 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304502 pClientSTA->pfnSTATxComp( pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 vosTempBuf,
4504 vosStatus );
4505 vosTempBuf = NULL;
4506 }/* status success*/
4507 }/*NULL function state*/
4508 }/* valid STA id and ! suspended*/
4509 else
4510 {
4511 if ( ! WLANTL_STA_ID_INVALID( ucSTAId ) )
4512 {
4513 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4514 "WLAN TL:Not fetching frame because suspended for sta ID %d",
4515 ucSTAId));
4516 }
4517 }
4518 }/* data */
4519
4520 if ( NULL != vosTempBuf )
4521 {
4522 WDA_TLI_PROCESS_FRAME_LEN( vosTempBuf, usPktLen, uResLen, uTotalPktLen);
4523
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004524 if (usPktLen > WLANTL_MAX_ALLOWED_LEN)
4525 {
4526 usPktLen = WLANTL_MAX_ALLOWED_LEN;
4527 VOS_ASSERT(0);
4528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
4530 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
4531 "WLAN TL:Resources needed by frame: %d", uResLen));
4532
4533 if ( ( pTLCb->uResCount >= (uResLen + WDA_TLI_MIN_RES_BAP ) ) &&
Jeff Johnson9b5dc4d2013-02-22 21:28:47 -08004534 ( uRemaining > uTotalPktLen ) &&
4535 ( uFlowMask & ( 1 << ucAC ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 {
4537 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4538 "WLAN TL:Chaining data frame on GetFrame"));
4539
4540 vos_pkt_chain_packet( vosDataBuff, vosTempBuf, 1 /*true*/ );
4541 vosTempBuf = NULL;
4542
4543 /*Update remaining len from SSC */
4544 uRemaining -= (usPktLen + WDA_DXE_HEADER_SIZE);
4545
4546 /*Update resource count */
4547 pTLCb->uResCount -= uResLen;
4548
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 //fow control update
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304550 pClientSTA->uIngress_length += uResLen;
4551 pClientSTA->uBuffThresholdMax = (pClientSTA->uBuffThresholdMax >= uResLen) ?
4552 (pClientSTA->uBuffThresholdMax - uResLen) : 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553
4554 }
4555 else
4556 {
4557 /* Store this for later tx - already fetched from HDD */
4558 pTLCb->vosTempBuf = vosTempBuf;
4559 pTLCb->ucCachedSTAId = ucSTAId;
4560 pTLCb->ucCachedAC = ucAC;
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 ucResult = uResLen + WDA_TLI_MIN_RES_BAP;
4562 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4563 "min %d res required by TL.", ucResult ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 break; /* Out of resources or reached max len */
4565 }
4566 }
4567 else
4568 {
4569 for ( i = 0; i < WLAN_MAX_STA_COUNT; i++)
4570 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304571 if (NULL != pTLCb->atlSTAClients[i] && (pTLCb->atlSTAClients[i]->ucExists) &&
4572 (pTLCb->atlSTAClients[i]->ucPktPending))
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 {
4574 /* There is station to be Served */
4575 break;
4576 }
4577 }
4578 if (i >= WLAN_MAX_STA_COUNT)
4579 {
4580 /* No More to Serve Exit Get Frames */
4581 break;
4582 }
4583 else
4584 {
4585 /* More to be Served */
4586 continue;
4587 }
4588 }
4589 }
4590 else
4591 {
4592 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4593 "WLAN TL:Returning from GetFrame: resources = %d suspended = %d",
4594 pTLCb->uResCount, pTLCb->ucTxSuspended));
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 /* TL is starving even when DXE is not in low resource condition
4596 Return min resource number required and Let DXE deceide what to do */
4597 if(( 0 == pTLCb->ucTxSuspended ) &&
4598 (( uFlowMask & ( 1 << WDA_TXFLOW_AC_BK ) ) ||
4599 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_BE ) ) ||
4600 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VI ) ) ||
4601 ( uFlowMask & ( 1 << WDA_TXFLOW_AC_VO ) )))
4602 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004603 TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 "WLAN TL:Returning from GetFrame: resources = %d",
4605 pTLCb->uResCount));
4606 ucResult = WDA_TLI_MIN_RES_DATA;
4607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 break; /*out of min data resources*/
4609 }
4610
4611 pTLCb->usPendingTxCompleteCount++;
4612 /* Move data buffer up one packet */
4613 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 0/*false*/ );
4614 }
4615
4616 /*----------------------------------------------------------------------
4617 Packet chain starts at root + 1
4618 ----------------------------------------------------------------------*/
4619 vos_pkt_walk_packet_chain( vosRoot, &vosDataBuff, 1/*true*/ );
4620
4621 *pvosDataBuff = vosDataBuff;
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08004622 if (pbUrgent)
4623 {
4624 *pbUrgent = pTLCb->bUrgent;
4625 }
4626 else
4627 {
4628 VOS_ASSERT( pbUrgent );
4629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 return ucResult;
4631}/* WLANTL_GetFrames */
4632
4633
4634/*==========================================================================
4635
4636 FUNCTION WLANTL_TxComp
4637
4638 DESCRIPTION
4639 It is being called by BAL upon asynchronous notification of the packet
4640 or packets being sent over the bus.
4641
4642 DEPENDENCIES
4643 Tx complete cannot be called without a previous transmit.
4644
4645 PARAMETERS
4646
4647 IN
4648 pvosGCtx: pointer to the global vos context; a handle to TL's
4649 or BAL's control block can be extracted from its context
4650 vosDataBuff: it will contain a pointer to the first buffer for which
4651 the BAL report is being made, if there is more then one
4652 packet they will be chained using vOSS buffers.
4653 wTxStatus: the status of the transmitted packet, see above chapter
4654 on HDD interaction for a list of possible values
4655
4656 RETURN VALUE
4657 The result code associated with performing the operation
4658
4659 VOS_STATUS_E_INVAL: Input parameters are invalid
4660 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4661 page fault
4662 VOS_STATUS_E_EXISTS: Station was not registered
4663 VOS_STATUS_SUCCESS: Everything is good :)
4664
4665 SIDE EFFECTS
4666
4667============================================================================*/
4668VOS_STATUS
4669WLANTL_TxComp
4670(
4671 v_PVOID_t pvosGCtx,
4672 vos_pkt_t *pFrameDataBuff,
4673 VOS_STATUS wTxStatus
4674)
4675{
4676 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
4677 WLANTL_CbType* pTLCb = NULL;
4678 WLANTL_TxCompCBType pfnTxComp = NULL;
4679 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 vos_pkt_t* vosTempTx = NULL;
4681
4682 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
4683
4684 /*------------------------------------------------------------------------
4685 Sanity check
4686 ------------------------------------------------------------------------*/
4687 if ( NULL == vosDataBuff )
4688 {
4689 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4690 "WLAN TL:Extraneous NULL data pointer on WLANTL_TxComp"));
4691 return VOS_STATUS_E_INVAL;
4692 }
4693
4694 /*------------------------------------------------------------------------
4695 Extract TL control block
4696 ------------------------------------------------------------------------*/
4697 pTLCb = VOS_GET_TL_CB(pvosGCtx);
4698 if ( NULL == pTLCb )
4699 {
4700 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4701 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_TxComp"));
4702 return VOS_STATUS_E_FAULT;
4703 }
4704
4705 while ((0 < pTLCb->usPendingTxCompleteCount) &&
4706 ( VOS_STATUS_SUCCESS == vosStatus ) &&
4707 ( NULL != vosDataBuff))
4708 {
4709 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
4710 (v_PVOID_t)&pfnTxComp);
4711
4712 /*it should never be NULL - default handler should be registered if none*/
4713 if ( NULL == pfnTxComp )
4714 {
4715 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4716 "WLAN TL:NULL pointer to Tx Complete on WLANTL_TxComp"));
4717 VOS_ASSERT(0);
4718 return VOS_STATUS_E_FAULT;
4719 }
4720
4721 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304722 "WLAN TL:Calling Tx complete for pkt %p in function %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 vosDataBuff, pfnTxComp));
4724
4725 vosTempTx = vosDataBuff;
4726 vosStatus = vos_pkt_walk_packet_chain( vosDataBuff,
4727 &vosDataBuff, 1/*true*/);
4728
4729 pfnTxComp( pvosGCtx, vosTempTx, wTxStatus );
4730
4731 pTLCb->usPendingTxCompleteCount--;
4732 }
4733
Jeff Johnson295189b2012-06-20 16:38:30 -07004734
4735 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4736 "WLAN TL: current TL values are: resources = %d "
4737 "pTLCb->usPendingTxCompleteCount = %d",
4738 pTLCb->uResCount, pTLCb->usPendingTxCompleteCount));
4739
4740 return VOS_STATUS_SUCCESS;
4741}/* WLANTL_TxComp */
4742
4743/*==========================================================================
4744
4745 FUNCTION WLANTL_CacheSTAFrame
4746
4747 DESCRIPTION
4748 Internal utility function for for caching incoming data frames that do
4749 not have a registered station yet.
4750
4751 DEPENDENCIES
4752 TL must be initiailized before this function gets called.
4753 In order to benefit from thsi caching, the components must ensure that
4754 they will only register with TL at the moment when they are fully setup
4755 and ready to receive incoming data
4756
4757 PARAMETERS
4758
4759 IN
4760
4761 pTLCb: TL control block
4762 ucSTAId: station id
4763 vosTempBuff: the data packet
4764 uDPUSig: DPU signature of the incoming packet
4765 bBcast: true if packet had the MC/BC bit set
4766
4767 RETURN VALUE
4768 The result code associated with performing the operation
4769
4770 VOS_STATUS_E_FAULT: pointer to TL cb is NULL or STA Id invalid ; access
4771 would cause a page fault
4772 VOS_STATUS_SUCCESS: Everything is good :)
4773
4774 SIDE EFFECTS
4775
4776============================================================================*/
4777static VOS_STATUS
4778WLANTL_CacheSTAFrame
4779(
4780 WLANTL_CbType* pTLCb,
4781 v_U8_t ucSTAId,
4782 vos_pkt_t* vosTempBuff,
4783 v_U32_t uDPUSig,
4784 v_U8_t bBcast,
4785 v_U8_t ucFrmType
4786)
4787{
4788 v_U8_t ucUcastSig;
4789 v_U8_t ucBcastSig;
4790 v_BOOL_t bOldSTAPkt;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304791 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4793
4794 /*-------------------------------------------------------------------------
4795 Sanity check
4796 -------------------------------------------------------------------------*/
4797 if (( NULL == pTLCb ) || ( NULL == vosTempBuff ) )
4798 {
4799 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304800 "WLAN TL: Invalid input pointer on WLANTL_CacheSTAFrame TL %p"
4801 " Packet %p", pTLCb, vosTempBuff ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 return VOS_STATUS_E_FAULT;
4803 }
4804
4805 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
4806 {
4807 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4808 "WLAN TL:Invalid station id requested on WLANTL_CacheSTAFrame"));
4809 return VOS_STATUS_E_FAULT;
4810 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304811 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
4812
4813 if ( NULL == pClientSTA )
4814 {
4815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4816 "WLAN TL:Client Memory was not allocated on %s", __func__));
4817 return VOS_STATUS_E_FAILURE;
4818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004819
4820 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4821 "WLAN TL:Attempting to cache pkt for STA %d, BD DPU Sig: %d with sig UC: %d, BC: %d",
4822 ucSTAId, uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304823 pClientSTA->wSTADesc.ucUcastSig,
4824 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004825
4826 if(WLANTL_IS_CTRL_FRAME(ucFrmType))
4827 {
4828 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4829 "WLAN TL: No need to cache CTRL frame. Dropping"));
4830 vos_pkt_return_packet(vosTempBuff);
4831 return VOS_STATUS_SUCCESS;
4832 }
4833
4834 /*-------------------------------------------------------------------------
4835 Check if the packet that we are trying to cache belongs to the old
4836 registered station (if any) or the new (potentially)upcoming station
4837
4838 - If the STA with this Id was never registered with TL - the signature
4839 will be invalid;
4840 - If the STA was previously registered TL will have cached the former
4841 set of DPU signatures
4842 -------------------------------------------------------------------------*/
4843 if ( bBcast )
4844 {
4845 ucBcastSig = (v_U8_t)uDPUSig;
4846 bOldSTAPkt = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304847 pClientSTA->wSTADesc.ucBcastSig ) &&
4848 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 }
4850 else
4851 {
4852 ucUcastSig = (v_U8_t)uDPUSig;
4853 bOldSTAPkt = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304854 pClientSTA->wSTADesc.ucUcastSig ) &&
4855 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 }
4857
4858 /*------------------------------------------------------------------------
4859 If the value of the DPU SIG matches the old, this packet will not
4860 be cached as it belonged to the former association
4861 In case the SIG does not match - this is a packet for a potentially new
4862 associated station
4863 -------------------------------------------------------------------------*/
Varun Reddy Yeturua39b9902013-01-18 15:48:32 -08004864 if ( bOldSTAPkt || bBcast )
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 {
4866 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
4867 "WLAN TL:Data packet matches old sig for sig DPU: %d UC: %d, "
4868 "BC: %d - dropping",
4869 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304870 pClientSTA->wSTADesc.ucUcastSig,
4871 pClientSTA->wSTADesc.ucBcastSig));
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 vos_pkt_return_packet(vosTempBuff);
4873 }
4874 else
4875 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304876 if ( NULL == pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 {
4878 /*this is the first frame that we are caching */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304879 pClientSTA->vosBegCachedFrame = vosTempBuff;
Mihir Sheteb7337272014-04-11 15:53:08 +05304880
4881 pClientSTA->tlCacheInfo.cacheInitTime = vos_timer_get_system_time();
4882 pClientSTA->tlCacheInfo.cacheDoneTime =
4883 pClientSTA->tlCacheInfo.cacheInitTime;
4884 pClientSTA->tlCacheInfo.cacheSize = 1;
4885
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304886 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
4887 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
4888
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 }
4890 else
4891 {
4892 /*this is a subsequent frame that we are caching: chain to the end */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304893 vos_pkt_chain_packet(pClientSTA->vosEndCachedFrame,
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 vosTempBuff, VOS_TRUE);
Mihir Sheteb7337272014-04-11 15:53:08 +05304895
4896 pClientSTA->tlCacheInfo.cacheDoneTime = vos_timer_get_system_time();
4897 pClientSTA->tlCacheInfo.cacheSize ++;
4898
4899 if (pClientSTA->tlCacheInfo.cacheSize % WLANTL_CACHE_TRACE_WATERMARK == 0)
4900 {
4901 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
4902 "%s: Cache High watermark for staid:%d (%d)",
4903 __func__,ucSTAId, pClientSTA->tlCacheInfo.cacheSize);
Mihir Sheteae6f02b2014-04-11 19:49:21 +05304904 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_CACHE_FRAME,
4905 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Mihir Sheteb7337272014-04-11 15:53:08 +05304906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05304908 pClientSTA->vosEndCachedFrame = vosTempBuff;
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 }/*else new packet*/
4910
4911 return VOS_STATUS_SUCCESS;
4912}/*WLANTL_CacheSTAFrame*/
4913
4914/*==========================================================================
4915
4916 FUNCTION WLANTL_FlushCachedFrames
4917
4918 DESCRIPTION
4919 Internal utility function used by TL to flush the station cache
4920
4921 DEPENDENCIES
4922 TL must be initiailized before this function gets called.
4923
4924 PARAMETERS
4925
4926 IN
4927
4928 vosDataBuff: it will contain a pointer to the first cached buffer
4929 received,
4930
4931 RETURN VALUE
4932 The result code associated with performing the operation
4933
4934 VOS_STATUS_SUCCESS: Everything is good :)
4935
4936 SIDE EFFECTS
4937
4938 NOTE
4939 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4940 responsibility to do so, if required, after this function call.
4941 Because of this restriction, we decide to make this function to static
4942 so that upper layer doesn't need to be aware of this restriction.
4943
4944============================================================================*/
4945static VOS_STATUS
4946WLANTL_FlushCachedFrames
4947(
4948 vos_pkt_t* vosDataBuff
4949)
4950{
4951 /*----------------------------------------------------------------------
4952 Return the entire chain to vos if there are indeed cache frames
4953 ----------------------------------------------------------------------*/
4954 if ( NULL != vosDataBuff )
4955 {
4956 vos_pkt_return_packet(vosDataBuff);
4957 }
4958
4959 return VOS_STATUS_SUCCESS;
4960}/*WLANTL_FlushCachedFrames*/
4961
4962/*==========================================================================
4963
4964 FUNCTION WLANTL_ForwardSTAFrames
4965
4966 DESCRIPTION
4967 Internal utility function for either forwarding cached data to the station after
4968 the station has been registered, or flushing cached data if the station has not
4969 been registered.
4970
4971
4972 DEPENDENCIES
4973 TL must be initiailized before this function gets called.
4974
4975 PARAMETERS
4976
4977 IN
4978
4979 pTLCb: TL control block
4980 ucSTAId: station id
4981
4982 RETURN VALUE
4983 The result code associated with performing the operation
4984
4985 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
4986 page fault
4987 VOS_STATUS_SUCCESS: Everything is good :)
4988
4989 SIDE EFFECTS
4990 This function doesn't re-initialize vosDataBuff to NULL. It's caller's
4991 responsibility to do so, if required, after this function call.
4992 Because of this restriction, we decide to make this function to static
4993 so that upper layer doesn't need to be aware of this restriction.
4994
4995============================================================================*/
4996static VOS_STATUS
4997WLANTL_ForwardSTAFrames
4998(
4999 void* pvosGCtx,
5000 v_U8_t ucSTAId,
5001 v_U8_t ucUcastSig,
5002 v_U8_t ucBcastSig
5003)
5004{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305005 WLANTL_CbType* pTLCb = NULL;
5006 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5008
5009 /*-------------------------------------------------------------------------
5010 Sanity check
5011 -------------------------------------------------------------------------*/
5012 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5013 if ( NULL == pTLCb )
5014 {
5015 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305016 "WLAN TL: Invalid input pointer on WLANTL_ForwardSTAFrames TL %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 pTLCb ));
5018 return VOS_STATUS_E_FAULT;
5019 }
5020
5021 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
5022 {
5023 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5024 "WLAN TL:Invalid station id requested on WLANTL_ForwardSTAFrames"));
5025 return VOS_STATUS_E_FAULT;
5026 }
5027
5028 //WLAN_TL_LOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5029
5030 /*------------------------------------------------------------------------
5031 Check if station has not been registered in the mean while
5032 if not registered, flush cached frames.
5033 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305034 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5035
5036 if ( NULL == pClientSTA )
5037 {
5038 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5039 "WLAN TL:Client Memory was not allocated on %s", __func__));
5040 return VOS_STATUS_E_FAILURE;
5041 }
5042
5043 if ( 0 == pClientSTA->ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 {
5045 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5046 "WLAN TL:Station has been deleted for STA %d - flushing cache", ucSTAId));
Mihir Sheteae6f02b2014-04-11 19:49:21 +05305047 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FLUSH_CACHED_FRAMES,
5048 ucSTAId, pClientSTA->tlCacheInfo.cacheSize));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305049 WLANTL_FlushCachedFrames(pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 goto done;
5051 }
5052
5053 /*------------------------------------------------------------------------
5054 Forwarding cache frames received while the station was in the process
5055 of being registered with the rest of the SW components
5056
5057 Access to the cache must be locked; similarly updating the signature and
5058 the existence flag must be synchronized because these values are checked
5059 during cached
5060 ------------------------------------------------------------------------*/
5061 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5062 "WLAN TL:Preparing to fwd packets for STA %d", ucSTAId));
5063
5064 /*-----------------------------------------------------------------------
5065 Save the new signature values
5066 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305067 pClientSTA->wSTADesc.ucUcastSig = ucUcastSig;
5068 pClientSTA->wSTADesc.ucBcastSig = ucBcastSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005069
5070 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5071 "WLAN TL:Fwd-ing packets for STA %d UC %d BC %d",
5072 ucSTAId, ucUcastSig, ucBcastSig));
5073
5074 /*-------------------------------------------------------------------------
5075 Check to see if we have any cached data to forward
5076 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305077 if ( NULL != pClientSTA->vosBegCachedFrame )
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 {
5079 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5080 "WLAN TL: Fwd-ing Cached packets for station %d", ucSTAId ));
5081
5082 WLANTL_RxCachedFrames( pTLCb,
5083 ucSTAId,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305084 pClientSTA->vosBegCachedFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 }
5086 else
5087 {
5088 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5089 "WLAN TL: NO cached packets for station %d", ucSTAId ));
5090 }
5091
5092done:
5093 /*-------------------------------------------------------------------------
5094 Clear the station cache
5095 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305096 pClientSTA->vosBegCachedFrame = NULL;
5097 pClientSTA->vosEndCachedFrame = NULL;
Mihir Sheteb7337272014-04-11 15:53:08 +05305098 pClientSTA->tlCacheInfo.cacheSize = 0;
5099 pClientSTA->tlCacheInfo.cacheClearTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -07005100
5101 /*-----------------------------------------------------------------------
5102 After all the init is complete we can mark the existance flag
5103 ----------------------------------------------------------------------*/
Katya Nigam63902932014-06-26 19:04:23 +05305104 pClientSTA->enableCaching = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005105
5106 //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]);
5107 return VOS_STATUS_SUCCESS;
5108
5109}/*WLANTL_ForwardSTAFrames*/
5110
5111
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005112#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005113/*==========================================================================
5114
5115 FUNCTION WLANTL_IsIAPPFrame
5116
5117 DESCRIPTION
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005118 Internal utility function for detecting incoming ESE IAPP frames
Jeff Johnson295189b2012-06-20 16:38:30 -07005119
5120 DEPENDENCIES
5121
5122 PARAMETERS
5123
5124 IN
5125
5126 pvBDHeader: pointer to the BD header
5127 vosTempBuff: the data packet
5128
5129 IN/OUT
5130 pFirstDataPktArrived: static from caller function; used for rssi
5131 computation
5132 RETURN VALUE
5133 The result code associated with performing the operation
5134
5135 VOS_TRUE: It is a IAPP frame
5136 VOS_FALSE: It is NOT IAPP frame
5137
5138 SIDE EFFECTS
5139
5140============================================================================*/
5141v_BOOL_t
5142WLANTL_IsIAPPFrame
5143(
5144 v_PVOID_t pvBDHeader,
5145 vos_pkt_t* vosTempBuff
5146)
5147{
5148 v_U16_t usMPDUDOffset;
5149 v_U8_t ucOffset;
5150 v_U8_t ucSnapHdr[WLANTL_LLC_SNAP_SIZE];
5151 v_SIZE_t usSnapHdrSize = WLANTL_LLC_SNAP_SIZE;
5152 VOS_STATUS vosStatus;
5153
5154 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5155
5156 /*------------------------------------------------------------------------
5157 Check if OUI field is present.
5158 -------------------------------------------------------------------------*/
5159 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5160 {
5161 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5162 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5163 "dropping pkt"));
5164 /* Drop packet */
5165 vos_pkt_return_packet(vosTempBuff);
5166 return VOS_TRUE;
5167 }
5168 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5169 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_SNAP_OFFSET;
5170
5171 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5172 (v_PVOID_t)ucSnapHdr, &usSnapHdrSize);
5173
5174 if (( VOS_STATUS_SUCCESS != vosStatus))
5175 {
5176 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5177 "Unable to extract Snap Hdr of data packet -"
5178 "dropping pkt"));
5179 return VOS_FALSE;
5180 }
5181
5182 /*------------------------------------------------------------------------
5183 Check if this is IAPP frame by matching Aironet Snap hdr.
5184 -------------------------------------------------------------------------*/
5185 // Compare returns 1 if values are same and 0
5186 // if not the same.
5187 if (( WLANTL_LLC_SNAP_SIZE != usSnapHdrSize ) ||
5188 ( 0 == vos_mem_compare(ucSnapHdr, (v_PVOID_t)WLANTL_AIRONET_SNAP_HEADER,
5189 WLANTL_LLC_SNAP_SIZE ) ))
5190 {
5191 return VOS_FALSE;
5192 }
5193
5194 return VOS_TRUE;
5195
5196}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005197#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005198
5199/*==========================================================================
5200
5201 FUNCTION WLANTL_ProcessBAPFrame
5202
5203 DESCRIPTION
5204 Internal utility function for processing incoming BT-AMP frames
5205
5206 DEPENDENCIES
5207 TL must be initiailized before this function gets called.
5208 Bothe the BT-AMP station and the BAP Ctrl path must have been previously
5209 registered with TL.
5210
5211 PARAMETERS
5212
5213 IN
5214
5215 pvBDHeader: pointer to the BD header
5216 vosTempBuff: the data packet
5217 pTLCb: TL control block
5218 ucSTAId: station id
5219
5220 IN/OUT
5221 pFirstDataPktArrived: static from caller function; used for rssi
5222 computation
5223 RETURN VALUE
5224 The result code associated with performing the operation
5225
5226 VOS_STATUS_E_INVAL: Input parameters are invalid
5227 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5228 page fault
5229 VOS_STATUS_SUCCESS: Everything is good :)
5230
5231 SIDE EFFECTS
5232
5233============================================================================*/
5234v_BOOL_t
5235WLANTL_ProcessBAPFrame
5236(
5237 v_PVOID_t pvBDHeader,
5238 vos_pkt_t* vosTempBuff,
5239 WLANTL_CbType* pTLCb,
5240 v_U8_t* pFirstDataPktArrived,
5241 v_U8_t ucSTAId
5242)
5243{
5244 v_U16_t usMPDUDOffset;
5245 v_U8_t ucOffset;
5246 v_U8_t ucOUI[WLANTL_LLC_OUI_SIZE];
5247 v_SIZE_t usOUISize = WLANTL_LLC_OUI_SIZE;
5248 VOS_STATUS vosStatus;
5249 v_U16_t usType;
5250 v_SIZE_t usTypeLen = sizeof(usType);
5251 v_U8_t ucMPDUHOffset;
5252 v_U8_t ucMPDUHLen = 0;
5253 v_U16_t usActualHLen = 0;
5254
5255 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5256
5257 /*------------------------------------------------------------------------
5258 Extract OUI and type from LLC and validate; if non-data send to BAP
5259 -------------------------------------------------------------------------*/
5260 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT(pvBDHeader) )
5261 {
5262 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5263 "WLAN TL:LLC header removed, cannot determine BT-AMP type -"
5264 "dropping pkt"));
5265 /* Drop packet */
5266 vos_pkt_return_packet(vosTempBuff);
5267 return VOS_TRUE;
5268 }
5269
5270 usMPDUDOffset = (v_U8_t)WDA_GET_RX_MPDU_DATA_OFFSET(pvBDHeader);
5271 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(pvBDHeader);
5272 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5273 ucOffset = (v_U8_t)usMPDUDOffset + WLANTL_LLC_OUI_OFFSET;
5274
5275 vosStatus = vos_pkt_extract_data( vosTempBuff, ucOffset,
5276 (v_PVOID_t)ucOUI, &usOUISize);
5277
5278#if 0
5279 // Compare returns 1 if values are same and 0
5280 // if not the same.
5281 if (( WLANTL_LLC_OUI_SIZE != usOUISize ) ||
5282 ( 0 == vos_mem_compare(ucOUI, (v_PVOID_t)WLANTL_BT_AMP_OUI,
5283 WLANTL_LLC_OUI_SIZE ) ))
5284 {
5285 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5286 "LLC header points to diff OUI in BT-AMP station -"
5287 "dropping pkt"));
5288 /* Drop packet */
5289 vos_pkt_return_packet(vosTempBuff);
5290 return VOS_TRUE;
5291 }
5292#endif
5293 /*------------------------------------------------------------------------
5294 Extract LLC OUI and ensure that this is indeed a BT-AMP frame
5295 ------------------------------------------------------------------------*/
5296 vosStatus = vos_pkt_extract_data( vosTempBuff,
5297 ucOffset + WLANTL_LLC_OUI_SIZE,
5298 (v_PVOID_t)&usType, &usTypeLen);
5299
5300 if (( VOS_STATUS_SUCCESS != vosStatus) ||
5301 ( sizeof(usType) != usTypeLen ))
5302 {
5303 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5304 "Unable to extract type on incoming BAP packet -"
5305 "dropping pkt"));
5306 /* Drop packet */
5307 vos_pkt_return_packet(vosTempBuff);
5308 return VOS_TRUE;
5309 }
5310
5311 /*------------------------------------------------------------------------
5312 Check if this is BT-AMP data or ctrl packet(RSN, LinkSvision, ActivityR)
5313 ------------------------------------------------------------------------*/
5314 usType = vos_be16_to_cpu(usType);
5315
5316 if (WLANTL_BAP_IS_NON_DATA_PKT_TYPE(usType))
5317 {
5318 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5319 "WLAN TL:Non-data packet received over BT-AMP link: %d, => BAP",
5320 usType));
5321
5322 /*Flatten packet as BAP expects to be able to peek*/
5323 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5324 {
5325 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5326 "WLAN TL:Cannot flatten BT-AMP packet - dropping"));
5327 /* Drop packet */
5328 vos_pkt_return_packet(vosTempBuff);
5329 return VOS_TRUE;
5330 }
5331
5332 /* Send packet to BAP client*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosTempBuff ) )
5334 {
5335 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5336 "WLAN TL:BD header corrupted - dropping packet"));
5337 /* Drop packet */
5338 vos_pkt_return_packet(vosTempBuff);
5339 return VOS_TRUE;
5340 }
5341
5342 if ( 0 == WDA_GET_RX_FT_DONE(pvBDHeader) )
5343 {
5344 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5345 "Non-data packet received over BT-AMP link: Sending it for "
5346 "frame Translation"));
5347
5348 if (usMPDUDOffset > ucMPDUHOffset)
5349 {
5350 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
5351 }
5352
5353 /* software frame translation for BTAMP WDS.*/
5354 WLANTL_Translate80211To8023Header( vosTempBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005355 ucMPDUHLen, pTLCb,ucSTAId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005356
5357 }
5358 if (pTLCb->tlBAPClient.pfnTlBAPRx)
5359 pTLCb->tlBAPClient.pfnTlBAPRx( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
5360 vosTempBuff,
5361 (WLANTL_BAPFrameEnumType)usType );
Manjunathappa Prakashfb585462013-12-23 19:07:07 -08005362 else
5363 {
5364 VOS_ASSERT(0);
5365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005366
5367 return VOS_TRUE;
5368 }
5369 else
5370 {
5371 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5372 "WLAN TL: BAP DATA packet received over BT-AMP link: %d, => BAP",
5373 usType));
5374 /*!!!FIX ME!!*/
5375 #if 0
5376 /*--------------------------------------------------------------------
5377 For data packet collect phy stats RSSI and Link Quality
5378 Calculate the RSSI average and save it. Continuous average is done.
5379 --------------------------------------------------------------------*/
5380 if ( *pFirstDataPktArrived == 0)
5381 {
5382 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5383 WLANHAL_GET_RSSI_AVERAGE( pvBDHeader );
5384 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5385 WLANHAL_RX_BD_GET_SNR( pvBDHeader );
5386
5387 // Rcvd 1st pkt, start average from next time
5388 *pFirstDataPktArrived = 1;
5389 }
5390 else
5391 {
5392 pTLCb->atlSTAClients[ucSTAId].rssiAvg =
5393 (WLANHAL_GET_RSSI_AVERAGE( pvBDHeader ) +
5394 pTLCb->atlSTAClients[ucSTAId].rssiAvg)/2;
5395 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg =
5396 (WLANHAL_RX_BD_GET_SNR( pvBDHeader ) +
5397 pTLCb->atlSTAClients[ucSTAId].uLinkQualityAvg)/2;
5398 }/*Else, first data packet*/
5399 #endif
5400 }/*BT-AMP data packet*/
5401
5402 return VOS_FALSE;
5403}/*WLANTL_ProcessBAPFrame*/
5404
Jeff Johnson295189b2012-06-20 16:38:30 -07005405
5406/*==========================================================================
5407
5408 FUNCTION WLANTL_ProcessFCFrame
5409
5410 DESCRIPTION
5411 Internal utility function for processing incoming Flow Control frames. Enable
5412 or disable LWM mode based on the information.
5413
5414 DEPENDENCIES
5415 TL must be initiailized before this function gets called.
5416 FW sends up special flow control frame.
5417
5418 PARAMETERS
5419
5420 IN
5421 pvosGCtx pointer to vos global context
5422 pvBDHeader: pointer to the BD header
5423 pTLCb: TL control block
5424 pvBDHeader pointer to BD header.
5425
5426 IN/OUT
5427 pFirstDataPktArrived: static from caller function; used for rssi
5428 computation
5429 RETURN VALUE
5430 The result code associated with performing the operation
5431
5432 VOS_STATUS_E_INVAL: Input frame are invalid
5433 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5434 page fault
5435 VOS_STATUS_SUCCESS: Everything is good :)
5436
5437 SIDE EFFECTS
5438 The ingress and egress of each station will be updated. If needed, LWM mode will
5439 be enabled or disabled based on the flow control algorithm.
5440
5441============================================================================*/
5442v_BOOL_t
5443WLANTL_ProcessFCFrame
5444(
5445 v_PVOID_t pvosGCtx,
5446 vos_pkt_t* pvosDataBuff,
5447 v_PVOID_t pvBDHeader
5448)
5449{
5450#if 1 //enable processing of only fcStaTxDisabled bitmap for now. the else part is old better qos code.
5451 // need to revisit the old code for full implementation.
Hoonki Lee14621352013-04-16 17:51:19 -07005452 v_U8_t ucSTAId;
5453 v_U16_t ucStaValidBitmap;
5454 v_U16_t ucStaTxDisabledBitmap;
5455 WLANTL_CbType* pTLCb = NULL;
5456 #ifdef TL_DEBUG_FC
5457 v_U32_t rxTimeStamp;
5458 v_U32_t curTick;
5459 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 /*------------------------------------------------------------------------
Hoonki Lee14621352013-04-16 17:51:19 -07005461 Extract TL control block
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 ------------------------------------------------------------------------*/
5463 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5464 if ( NULL == pTLCb )
5465 {
5466 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5467 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_SuspendDataTx"));
5468 return VOS_STATUS_E_FAULT;
5469 }
Hoonki Lee14621352013-04-16 17:51:19 -07005470 ucStaValidBitmap = WDA_GET_RX_FC_VALID_STA_MASK(pvBDHeader);
5471 ucStaTxDisabledBitmap = WDA_GET_RX_FC_STA_TX_DISABLED_BITMAP(pvBDHeader);
5472#ifdef TL_DEBUG_FC
5473 rxTimeStamp = WDA_GET_RX_TIMESTAMP(pvBDHeader);
5474 /* hard code of MTU_GLOBAL_TIMER_ADDR to calculate the time between generated and processed */
5475 wpalReadRegister(0x03081400+0x1D4, &curTick);
Jeff Johnson295189b2012-06-20 16:38:30 -07005476
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005478 "%ld (%ld-%ld): Disabled %x Valid %x", curTick > rxTimeStamp ? curTick - rxTimeStamp : rxTimeStamp - (0xFFFFFFFF - curTick),
Hoonki Lee14621352013-04-16 17:51:19 -07005479 curTick, rxTimeStamp, ucStaTxDisabledBitmap, ucStaValidBitmap));
5480#endif
5481 for(ucSTAId = 0; ucStaValidBitmap != 0; ucStaValidBitmap >>=1, ucStaTxDisabledBitmap >>= 1, ucSTAId ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 {
Hoonki Lee14621352013-04-16 17:51:19 -07005483 if ( (0 == (ucStaValidBitmap & 0x1)) || (pTLCb->atlSTAClients[ucSTAId] && (0 == pTLCb->atlSTAClients[ucSTAId]->ucExists)) )
5484 continue;
5485
5486 if (ucStaTxDisabledBitmap & 0x1)
5487 {
5488 WLANTL_SuspendDataTx(pvosGCtx, &ucSTAId, NULL);
5489 }
5490 else
5491 {
5492 WLANTL_ResumeDataTx(pvosGCtx, &ucSTAId);
5493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 }
5495
5496#else
5497 VOS_STATUS vosStatus;
5498 tpHalFcRxBd pvFcRxBd = NULL;
5499 v_U8_t ucBitCheck = 0x1;
5500 v_U8_t ucStaValid = 0;
5501 v_U8_t ucSTAId = 0;
5502
5503 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
5504 "Received FC Response");
5505 if ( (NULL == pTLCb) || (NULL == pvosDataBuff))
5506 {
5507 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08005508 "WLAN TL:Invalid pointer in %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 return VOS_STATUS_E_FAULT;
5510 }
5511 vosStatus = vos_pkt_peek_data( pvosDataBuff, 0, (v_PVOID_t)&pvFcRxBd,
5512 sizeof(tHalFcRxBd));
5513
5514 if ( (VOS_STATUS_SUCCESS != vosStatus) || (NULL == pvFcRxBd) )
5515 {
5516 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5517 "WLAN TL:wrong FC Rx packet"));
5518 return VOS_STATUS_E_INVAL;
5519 }
5520
5521 // need to swap bytes in the FC contents.
5522 WLANHAL_SwapFcRxBd(&pvFcRxBd->fcSTATxQLen[0]);
5523
5524 //logic to enable/disable LWM mode for each station
5525 for( ucStaValid = (v_U8_t)pvFcRxBd->fcSTAValidMask; ucStaValid; ucStaValid >>= 1, ucBitCheck <<= 1, ucSTAId ++)
5526 {
5527 if ( (0 == (ucStaValid & 0x1)) || (0 == pTLCb->atlSTAClients[ucSTAId].ucExists) )
5528 {
5529 continue;
5530 }
5531
5532 if ( pvFcRxBd->fcSTAThreshIndMask & ucBitCheck )
5533 {
5534 //LWM event is reported by FW. Able to fetch more packet
5535 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5536 {
5537 //Now memory usage is below LWM. Station can send more packets.
5538 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = TRUE;
5539 }
5540 else
5541 {
5542 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08005543 "WLAN TL: FW report LWM event but the station %d is not in LWM mode", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 }
5545 }
5546
5547 //calculate uEgress_length/uIngress_length only after receiving enough packets
5548 if (WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5549 {
5550 //check memory usage info to see whether LWM mode should be enabled for the station
5551 v_U32_t uEgress_length = pTLCb->atlSTAClients[ucSTAId].uIngress_length +
5552 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed - pvFcRxBd->fcSTATxQLen[ucSTAId];
5553
5554 //if ((float)uEgress_length/(float)pTLCb->atlSTAClients[ucSTAId].uIngress_length
5555 // <= WLANTL_LWM_EGRESS_INGRESS_THRESHOLD)
5556 if ( (pTLCb->atlSTAClients[ucSTAId].uIngress_length > uEgress_length) &&
5557 ((pTLCb->atlSTAClients[ucSTAId].uIngress_length - uEgress_length ) >=
5558 (pTLCb->atlSTAClients[ucSTAId].uIngress_length >> 2))
5559 )
5560 {
5561 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005562 "WLAN TL:Enable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = TRUE;
5564 }
5565 else
5566 {
5567 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5568 {
5569 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08005570 "WLAN TL:Disable LWM mode for station %d", ucSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled = FALSE;
5572 }
5573
5574 }
5575
5576 //remember memory usage in FW starting from this round
5577 pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed = pvFcRxBd->fcSTATxQLen[ucSTAId];
5578 pTLCb->atlSTAClients[ucSTAId].uIngress_length = 0;
5579 } //(WLANTL_LWM_INGRESS_SAMPLE_THRESHOLD <= pTLCb->atlSTAClients[ucSTAId].uIngress_length)
5580
5581 if( pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled )
5582 {
5583 //always update current maximum allowed memeory usage
5584 pTLCb->atlSTAClients[ucSTAId].uBuffThresholdMax = WLANTL_STA_BMU_THRESHOLD_MAX -
5585 pvFcRxBd->fcSTATxQLen[ucSTAId];
5586 }
5587
5588 }
5589#endif
5590
5591 return VOS_STATUS_SUCCESS;
5592}
Jeff Johnson295189b2012-06-20 16:38:30 -07005593
5594
5595/*==========================================================================
5596
5597 FUNCTION WLANTL_RxFrames
5598
5599 DESCRIPTION
5600 Callback registered by TL and called by BAL when a packet is received
5601 over the bus. Upon the call of this function TL will make the necessary
5602 decision with regards to the forwarding or queuing of this packet and
5603 the layer it needs to be delivered to.
5604
5605 DEPENDENCIES
5606 TL must be initiailized before this function gets called.
5607 If the frame carried is a data frame then the station for which it is
5608 destined to must have been previously registered with TL.
5609
5610 PARAMETERS
5611
5612 IN
5613 pvosGCtx: pointer to the global vos context; a handle to TL's
5614 or BAL's control block can be extracted from its context
5615
5616 vosDataBuff: it will contain a pointer to the first buffer received,
5617 if there is more then one packet they will be chained
5618 using vOSS buffers.
5619
5620 RETURN VALUE
5621 The result code associated with performing the operation
5622
5623 VOS_STATUS_E_INVAL: Input parameters are invalid
5624 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
5625 page fault
5626 VOS_STATUS_SUCCESS: Everything is good :)
5627
5628 SIDE EFFECTS
5629
5630============================================================================*/
5631VOS_STATUS
5632WLANTL_RxFrames
5633(
5634 v_PVOID_t pvosGCtx,
5635 vos_pkt_t *pFrameDataBuff
5636)
5637{
5638 vos_pkt_t* vosDataBuff = (vos_pkt_t*)pFrameDataBuff;
5639 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305640 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 WLANTL_STAFuncType pfnSTAFsm;
5642 vos_pkt_t* vosTempBuff;
5643 v_U8_t ucSTAId;
5644 VOS_STATUS vosStatus;
5645 v_U8_t ucFrmType;
5646 v_PVOID_t pvBDHeader = NULL;
5647 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
5648 v_U8_t ucTid = 0;
5649 v_BOOL_t broadcast = VOS_FALSE;
5650 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07005651 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 v_U32_t uDPUSig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 v_U16_t usPktLen;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005654#ifdef FEATURE_WLAN_TDLS_INTERNAL
5655 v_U8_t ucMPDUHLen = 0 ;
5656 v_U16_t usEtherType = 0;
5657#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005658 v_BOOL_t bForwardIAPPwithLLC = VOS_FALSE;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305659#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5660 v_S7_t currentAvgRSSI = 0;
5661 v_U8_t ac;
5662
5663#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005664
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
5666
5667 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5668 "WLAN TL:TL Receive Frames called"));
5669
5670 /*------------------------------------------------------------------------
5671 Sanity check
5672 ------------------------------------------------------------------------*/
5673 if ( NULL == vosDataBuff )
5674 {
5675 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5676 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
5677 return VOS_STATUS_E_INVAL;
5678 }
5679
Katya Nigam3802f202013-12-16 19:27:14 +05305680 /*------------------------------------------------------------------------
5681 Popolaute timestamp as the time when packet arrives
5682 ---------------------------------------------------------------------- */
5683 vosDataBuff->timestamp = vos_timer_get_system_ticks();
5684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 /*------------------------------------------------------------------------
5686 Extract TL control block
5687 ------------------------------------------------------------------------*/
5688 pTLCb = VOS_GET_TL_CB(pvosGCtx);
5689 if ( NULL == pTLCb )
5690 {
5691 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5692 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
5693 return VOS_STATUS_E_FAULT;
5694 }
5695
5696 /*---------------------------------------------------------------------
5697 Save the initial buffer - this is the first received buffer
5698 ---------------------------------------------------------------------*/
5699 vosTempBuff = vosDataBuff;
5700
5701 while ( NULL != vosTempBuff )
5702 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08005703 broadcast = VOS_FALSE;
5704 selfBcastLoopback = VOS_FALSE;
5705
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
5707
5708 /*---------------------------------------------------------------------
5709 Peek at BD header - do not remove
5710 !!! Optimize me: only part of header is needed; not entire one
5711 ---------------------------------------------------------------------*/
5712 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 1/*Swap BD*/ );
5713
5714 if ( NULL == pvBDHeader )
5715 {
5716 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5717 "WLAN TL:Cannot extract BD header"));
5718 /* Drop packet */
5719 vos_pkt_return_packet(vosTempBuff);
5720 vosTempBuff = vosDataBuff;
5721 continue;
5722 }
5723
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 /*---------------------------------------------------------------------
5725 Check if FC frame reported from FW
5726 ---------------------------------------------------------------------*/
5727 if(WDA_IS_RX_FC(pvBDHeader))
5728 {
5729 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5730 "WLAN TL:receive one FC frame"));
5731
5732 WLANTL_ProcessFCFrame(pvosGCtx, vosTempBuff, pvBDHeader);
5733 /* Drop packet */
5734 vos_pkt_return_packet(vosTempBuff);
5735 vosTempBuff = vosDataBuff;
5736 continue;
5737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005738
5739 /* AMSDU HW bug fix
5740 * After 2nd AMSDU subframe HW could not handle BD correctly
5741 * HAL workaround is needed */
5742 if(WDA_GET_RX_ASF(pvBDHeader))
5743 {
5744 WDA_DS_RxAmsduBdFix(pvosGCtx, pvBDHeader);
5745 }
5746
5747 /*---------------------------------------------------------------------
5748 Extract frame control field from 802.11 header if present
5749 (frame translation not done)
5750 ---------------------------------------------------------------------*/
5751
5752 vosStatus = WDA_DS_GetFrameTypeSubType( pvosGCtx, vosTempBuff,
5753 pvBDHeader, &ucFrmType );
5754 if ( VOS_STATUS_SUCCESS != vosStatus )
5755 {
5756 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5757 "WLAN TL:Cannot extract Frame Control Field"));
5758 /* Drop packet */
5759 vos_pkt_return_packet(vosTempBuff);
5760 vosTempBuff = vosDataBuff;
5761 continue;
5762 }
5763
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005764#ifdef FEATURE_WLAN_TDLS_INTERNAL
5765 if ( WLANTL_IS_DATA_FRAME(ucFrmType))
5766 {
5767 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(pvBDHeader);
5768 WLANTL_GetEtherType_2(pvBDHeader, vosTempBuff, ucMPDUHLen, &usEtherType) ;
5769 }
5770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 vos_pkt_get_packet_length(vosTempBuff, &usPktLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005772
5773 /*---------------------------------------------------------------------
5774 Check if management and send to PE
5775 ---------------------------------------------------------------------*/
5776
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005777 if ( WLANTL_IS_MGMT_FRAME(ucFrmType)
5778#ifdef FEATURE_WLAN_TDLS_INTERNAL
5779 || (WLANTL_IS_TDLS_FRAME(usEtherType))
5780#endif
5781 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 {
5783 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5784 "WLAN TL:Sending packet to management client"));
5785 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
5786 {
5787 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
5788 "WLAN TL:Cannot flatten packet - dropping"));
5789 /* Drop packet */
5790 vos_pkt_return_packet(vosTempBuff);
5791 vosTempBuff = vosDataBuff;
5792 continue;
5793 }
5794 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5795 /* Read RSSI and update */
5796 if(!WLANTL_STA_ID_INVALID(ucSTAId))
5797 {
5798#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
5799 /* Read RSSI and update */
5800 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
5801 WLANTL_MGMT_FRAME_TYPE,
5802 pvBDHeader,
5803 ucSTAId,
5804 VOS_FALSE,
5805 NULL);
5806#else
5807 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
5808#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05305809 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5810 {
5811 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5812 "Handle RX Management Frame fail within Handoff "
5813 "support module"));
5814 /* Do Not Drop packet at here
5815 * Revisit why HO module return fail
5816 * vos_pkt_return_packet(vosTempBuff);
5817 * vosTempBuff = vosDataBuff;
5818 * continue;
5819 */
5820 }
5821 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
5822
5823 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5824 {
5825 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5826 FL("Failed to Read SNR")));
5827 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05305828#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5829 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5830 if ( NULL != pClientSTA)
5831 {
5832 pClientSTA->interfaceStats.mgmtRx++;
Dino Mycle3b9536d2014-07-09 22:05:24 +05305833 }
5834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 }
5836
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
5838 }
5839 else /* Data Frame */
5840 {
5841 ucSTAId = (v_U8_t)WDA_GET_RX_STAID( pvBDHeader );
5842 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
Dino Mycle3b9536d2014-07-09 22:05:24 +05305843#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5844 ac = WLANTL_TID_2_AC[ucTid];
5845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005846
5847 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5848 "WLAN TL:Data packet received for STA %d", ucSTAId));
5849
5850 /*------------------------------------------------------------------
5851 This should be corrected when multipe sta support is added !!!
5852 for now bcast frames will be sent to the last registered STA
5853 ------------------------------------------------------------------*/
5854 if ( WDA_IS_RX_BCAST(pvBDHeader))
5855 {
5856 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
5857 "WLAN TL:TL rx Bcast frame - sending to last registered station"));
5858 broadcast = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 /*-------------------------------------------------------------------
5860 If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
5861 pkt we sent looping back to us. To be dropped if we are non BTAMP
5862 -------------------------------------------------------------------*/
5863 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
5864 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
5865 {
5866 selfBcastLoopback = VOS_TRUE;
5867 }
5868 }/*if bcast*/
5869
5870 if ( WLANTL_STA_ID_INVALID(ucSTAId) )
5871 {
5872 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5873 "WLAN TL:STA ID invalid - dropping pkt"));
5874 /* Drop packet */
5875 vos_pkt_return_packet(vosTempBuff);
5876 vosTempBuff = vosDataBuff;
5877 continue;
5878 }
5879
5880 /*----------------------------------------------------------------------
5881 No need to lock cache access because cache manipulation only happens
5882 in the transport thread/task context
5883 - These frames are to be forwarded to the station upon registration
5884 which happens in the main thread context
5885 The caching here can happen in either Tx or Rx thread depending
5886 on the current SSC scheduling
5887 - also we need to make sure that the frames in the cache are fwd-ed to
5888 the station before the new incoming ones
5889 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05305890 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
5891 if (NULL == pClientSTA)
5892 {
5893 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5894 "WLAN TL:STA not allocated memory. Dropping packet"));
5895 vos_pkt_return_packet(vosTempBuff);
5896 vosTempBuff = vosDataBuff;
5897 continue;
5898 }
5899
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005900#ifdef FEATURE_WLAN_TDLS
5901 if (( pClientSTA->ucExists ) &&
5902 (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType) &&
5903 (pClientSTA->ucTxSuspended))
5904 vos_atomic_set_U8( &pClientSTA->ucTxSuspended, 0 );
5905 else if ( !broadcast && (pClientSTA->ucExists == 0 ) )
5906 {
5907 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
5908
5909 /* from the direct peer while it is not registered to TL yet */
5910 if ( (pMacHeader->fc.fromDS == 0) &&
5911 (pMacHeader->fc.toDS == 0) )
5912 {
5913 v_U8_t ucAddr3STAId;
5914
5915 ucAddr3STAId = WDA_GET_RX_ADDR3_IDX(pvBDHeader);
5916
5917 if ( WLANTL_STA_ID_INVALID(ucAddr3STAId) )
5918 {
5919 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5920 "WLAN TL:STA ID %d invalid - dropping pkt", ucAddr3STAId));
5921 /* Drop packet */
5922 vos_pkt_return_packet(vosTempBuff);
5923 vosTempBuff = vosDataBuff;
5924 continue;
5925 }
5926
5927 if (!(pTLCb->atlSTAClients[ucAddr3STAId] && pTLCb->atlSTAClients[ucAddr3STAId]->ucExists &&
5928 (WLAN_STA_INFRA == pTLCb->atlSTAClients[ucAddr3STAId]->wSTADesc.wSTAType) &&
5929 (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucAddr3STAId]->tlState)))
5930 {
5931 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005932 "%s: staId %d addr3Id %d tlState %d. Unkown Receiver/Transmitter Dropping packet", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005933 ucSTAId, ucAddr3STAId, pTLCb->atlSTAClients[ucAddr3STAId]->tlState));
5934 vos_pkt_return_packet(vosTempBuff);
5935 vosTempBuff = vosDataBuff;
5936 continue;
5937 }
5938 else
5939 {
5940 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005941 "%s: staId %d doesn't exist, but mapped to AP staId %d", __func__,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005942 ucSTAId, ucAddr3STAId));
5943 ucSTAId = ucAddr3STAId;
5944 pClientSTA = pTLCb->atlSTAClients[ucAddr3STAId];
5945 }
5946 }
5947 }
5948#endif
5949
Katya Nigam63902932014-06-26 19:04:23 +05305950 if (( pClientSTA->enableCaching == 1 ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames,
5952 * libra buffers all Broadcast/Multicast packets after authentication with AP,
5953 * So it will lead to low resource condition in Rx Data Path.*/
Katya Nigam63902932014-06-26 19:04:23 +05305954 ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 {
Katya Nigam6201c3e2014-05-27 17:51:42 +05305956 if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
5957 {
5958 //drop packet for Self STA index
5959 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
5960 "%s: Packet dropped for Self STA with staId %d ", __func__, ucSTAId ));
5961
5962 vos_pkt_return_packet(vosTempBuff);
5963 vosTempBuff = vosDataBuff;
5964 continue;
5965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
5967 //Station has not yet been registered with TL - cache the frame
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005968 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Arif Hussainf2b00992013-11-17 21:46:15 -08005969 "%s: staId %d exist %d tlState %d cache rx frame", __func__, ucSTAId,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07005970 pClientSTA->ucExists, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 WLANTL_CacheSTAFrame( pTLCb, ucSTAId, vosTempBuff, uDPUSig, broadcast, ucFrmType);
5972 vosTempBuff = vosDataBuff;
5973 continue;
5974 }
5975
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005976#ifdef FEATURE_WLAN_ESE_UPLOAD
5977 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005978 {
5979 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005980 Filter the IAPP frames for ESE connection;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005981 if data it will return false and it
5982 will be routed through the regular data path
5983 --------------------------------------------------------------------*/
5984 if ( WLANTL_IsIAPPFrame(pvBDHeader,
5985 vosTempBuff))
5986 {
5987 bForwardIAPPwithLLC = VOS_TRUE;
5988 }
5989 }
5990#endif
5991
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005992#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
5993 if ((pClientSTA->wSTADesc.ucIsEseSta)|| broadcast)
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 {
5995 /*--------------------------------------------------------------------
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005996 Filter the IAPP frames for ESE connection;
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 if data it will return false and it
5998 will be routed through the regular data path
5999 --------------------------------------------------------------------*/
6000 if ( WLANTL_IsIAPPFrame(pvBDHeader,
6001 vosTempBuff))
6002 {
6003 if ( VOS_STATUS_SUCCESS != vos_pkt_flatten_rx_pkt(&vosTempBuff))
6004 {
6005 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6006 "WLAN TL:Cannot flatten packet - dropping"));
6007 /* Drop packet */
6008 vos_pkt_return_packet(vosTempBuff);
6009 } else {
6010
6011 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006012 "WLAN TL: Received ESE IAPP Frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006013
6014 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx( pvosGCtx, vosTempBuff);
6015 }
6016 vosTempBuff = vosDataBuff;
6017 continue;
6018 }
6019 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006020#endif /* defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD) */
Jeff Johnson295189b2012-06-20 16:38:30 -07006021
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306022 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 {
6024 /*--------------------------------------------------------------------
6025 Process the ctrl BAP frame; if data it will return false and it
6026 will be routed through the regular data path
6027 --------------------------------------------------------------------*/
6028 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6029 vosTempBuff,
6030 pTLCb,
6031 &first_data_pkt_arrived,
6032 ucSTAId))
6033 {
6034 vosTempBuff = vosDataBuff;
6035 continue;
6036 }
6037 }/*if BT-AMP station*/
6038 else if(selfBcastLoopback == VOS_TRUE)
6039 {
6040 /* Drop packet */
6041 vos_pkt_return_packet(vosTempBuff);
6042 vosTempBuff = vosDataBuff;
6043 continue;
6044 }
6045
6046 /*---------------------------------------------------------------------
6047 Data packet received, send to state machine
6048 ---------------------------------------------------------------------*/
6049 wSTAEvent = WLANTL_RX_EVENT;
6050
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306051 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 pfnSTATbl[wSTAEvent];
6053
6054 if ( NULL != pfnSTAFsm )
6055 {
6056#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6057 /* Read RSSI and update */
6058 vosStatus = WLANTL_HSHandleRXFrame(pvosGCtx,
6059 WLANTL_DATA_FRAME_TYPE,
6060 pvBDHeader,
6061 ucSTAId,
6062 broadcast,
6063 vosTempBuff);
6064 broadcast = VOS_FALSE;
6065#else
6066 vosStatus = WLANTL_ReadRSSI(pvosGCtx, pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006067#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306068 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 {
6070 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6071 "Handle RX Data Frame fail within Handoff support module"));
6072 /* Do Not Drop packet at here
6073 * Revisit why HO module return fail
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306074 * vos_pkt_return_packet(vosTempBuff);
6075 * vosTempBuff = vosDataBuff;
6076 * continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 */
6078 }
Dino Mycle3b9536d2014-07-09 22:05:24 +05306079#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6080 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6081 if ( NULL != pClientSTA)
6082 {
6083 tpSirMacMgmtHdr pMacHeader = WDA_GET_RX_MAC_HEADER( pvBDHeader );
Mahesh A Saptasagarbbdcf122014-10-28 20:57:11 +05306084 if (!IS_BROADCAST_ADD(pMacHeader->da) && IS_MULTICAST_ADD(pMacHeader->da))
Dino Mycle3b9536d2014-07-09 22:05:24 +05306085 {
6086 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMcast++;
6087 }
6088
6089 WLANTL_HSGetDataRSSI(pvosGCtx, pvBDHeader, ucSTAId,
6090 &currentAvgRSSI);
6091 pClientSTA->interfaceStats.rssiData = currentAvgRSSI;
6092
6093 pClientSTA->interfaceStats.accessCategoryStats[ac].rxMpdu++;
6094 if (WDA_IS_RX_AN_AMPDU (pvBDHeader))
6095 {
6096 pClientSTA->interfaceStats.accessCategoryStats[ac].rxAmpdu++;
6097 }
6098 }
6099
6100
6101#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05306102 vosStatus = WLANTL_ReadSNR(pvosGCtx, pvBDHeader, ucSTAId);
6103
6104 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
6105 {
6106 TLLOGW(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6107 FL("Failed to Read SNR")));
6108 }
6109
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006110 pfnSTAFsm( pvosGCtx, ucSTAId, &vosTempBuff, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 }
6112 else
6113 {
6114 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
6115 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306116 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 /* Drop packet */
6118 vos_pkt_return_packet(vosTempBuff);
6119 vosTempBuff = vosDataBuff;
6120 continue;
6121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 }/* else data frame*/
6123
6124 vosTempBuff = vosDataBuff;
6125 }/*while chain*/
6126
6127 return VOS_STATUS_SUCCESS;
6128}/* WLANTL_RxFrames */
6129
Dino Mycle3b9536d2014-07-09 22:05:24 +05306130#ifdef WLAN_FEATURE_LINK_LAYER_STATS
6131/*==========================================================================
6132
6133 FUNCTION WLANTL_CollectInterfaceStats
6134
6135 DESCRIPTION
6136 Utility function used by TL to send the statitics
6137
6138 DEPENDENCIES
6139
6140
6141 PARAMETERS
6142
6143 IN
6144
6145 ucSTAId: station for which the statistics need to collected
6146
6147 vosDataBuff: it will contain the pointer to the corresponding
6148 structure
6149
6150 RETURN VALUE
6151 The result code associated with performing the operation
6152
6153 VOS_STATUS_E_INVAL: Input parameters are invalid
6154 VOS_STATUS_SUCCESS: Everything is good :)
6155
6156 SIDE EFFECTS
6157
6158============================================================================*/
6159VOS_STATUS
6160WLANTL_CollectInterfaceStats
6161(
6162 v_PVOID_t pvosGCtx,
6163 v_U8_t ucSTAId,
6164 WLANTL_InterfaceStatsType *vosDataBuff
6165)
6166{
6167 WLANTL_CbType* pTLCb = NULL;
6168 /*------------------------------------------------------------------------
6169 Sanity check
6170 ------------------------------------------------------------------------*/
6171 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
6172 {
6173 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6174 "WLAN TL:Invalid station id requested on WLANTL_CollectStats"));
6175 return VOS_STATUS_E_FAULT;
6176 }
6177 /*------------------------------------------------------------------------
6178 Extract TL control block
6179 ------------------------------------------------------------------------*/
6180 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6181 if ( NULL == pTLCb )
6182 {
6183 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6184 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_CollectStats"));
6185 return VOS_STATUS_E_FAULT;
6186 }
6187
6188 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
6189 {
6190 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6191 "WLAN TL:Client Memory was not allocated on %s", __func__));
6192 return VOS_STATUS_E_FAILURE;
6193 }
6194 vos_mem_copy(vosDataBuff, &pTLCb->atlSTAClients[ucSTAId]->interfaceStats,
6195 sizeof(WLANTL_InterfaceStatsType));
6196 return VOS_STATUS_SUCCESS;
6197}
6198
6199#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Jeff Johnson295189b2012-06-20 16:38:30 -07006200
6201/*==========================================================================
6202
6203 FUNCTION WLANTL_RxCachedFrames
6204
6205 DESCRIPTION
6206 Utility function used by TL to forward the cached frames to a particular
6207 station;
6208
6209 DEPENDENCIES
6210 TL must be initiailized before this function gets called.
6211 If the frame carried is a data frame then the station for which it is
6212 destined to must have been previously registered with TL.
6213
6214 PARAMETERS
6215
6216 IN
6217 pTLCb: pointer to TL handle
6218
6219 ucSTAId: station for which we need to forward the packets
6220
6221 vosDataBuff: it will contain a pointer to the first cached buffer
6222 received, if there is more then one packet they will be
6223 chained using vOSS buffers.
6224
6225 RETURN VALUE
6226 The result code associated with performing the operation
6227
6228 VOS_STATUS_E_INVAL: Input parameters are invalid
6229 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6230 page fault
6231 VOS_STATUS_SUCCESS: Everything is good :)
6232
6233 SIDE EFFECTS
6234
6235============================================================================*/
6236VOS_STATUS
6237WLANTL_RxCachedFrames
6238(
6239 WLANTL_CbType* pTLCb,
6240 v_U8_t ucSTAId,
6241 vos_pkt_t* vosDataBuff
6242)
6243{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306244 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 WLANTL_STAFuncType pfnSTAFsm;
6246 vos_pkt_t* vosTempBuff;
6247 VOS_STATUS vosStatus;
6248 v_PVOID_t pvBDHeader = NULL;
6249 WLANTL_STAEventType wSTAEvent = WLANTL_RX_EVENT;
6250 v_U8_t ucTid = 0;
6251 v_BOOL_t broadcast = VOS_FALSE;
6252 v_BOOL_t bSigMatch = VOS_FALSE;
6253 v_BOOL_t selfBcastLoopback = VOS_FALSE;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07006254 static v_U8_t first_data_pkt_arrived;
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 v_U32_t uDPUSig;
6256 v_U8_t ucUcastSig;
6257 v_U8_t ucBcastSig;
6258 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6259
6260 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6261 "WLAN TL:TL Receive Cached Frames called"));
6262
6263 /*------------------------------------------------------------------------
6264 Sanity check
6265 ------------------------------------------------------------------------*/
6266 if ( NULL == vosDataBuff )
6267 {
6268 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6269 "WLAN TL:Invalid parameter sent on WLANTL_RxFrames"));
6270 return VOS_STATUS_E_INVAL;
6271 }
6272
Mihir Sheteae6f02b2014-04-11 19:49:21 +05306273 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6274
6275 if ( NULL == pClientSTA )
6276 {
6277 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6278 "WLAN TL:Client Memory was not allocated on %s", __func__));
6279 return VOS_STATUS_E_FAILURE;
6280 }
6281
6282 MTRACE(vos_trace(VOS_MODULE_ID_TL, TRACE_CODE_TL_FORWARD_CACHED_FRAMES,
6283 ucSTAId, 1<<16 | pClientSTA->tlCacheInfo.cacheSize));
6284
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 /*---------------------------------------------------------------------
6286 Save the initial buffer - this is the first received buffer
6287 ---------------------------------------------------------------------*/
6288 vosTempBuff = vosDataBuff;
6289
6290 while ( NULL != vosTempBuff )
6291 {
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -08006292 broadcast = VOS_FALSE;
6293 selfBcastLoopback = VOS_FALSE;
6294
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 vos_pkt_walk_packet_chain( vosDataBuff, &vosDataBuff, 1/*true*/ );
6296
6297 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6298 "WLAN TL:Sending new cached packet to station %d", ucSTAId));
6299 /*---------------------------------------------------------------------
6300 Peek at BD header - do not remove
6301 !!! Optimize me: only part of header is needed; not entire one
6302 ---------------------------------------------------------------------*/
6303 vosStatus = WDA_DS_PeekRxPacketInfo( vosTempBuff, (v_PVOID_t)&pvBDHeader, 0 );
6304
6305 if ( NULL == pvBDHeader )
6306 {
6307 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6308 "WLAN TL:Cannot extract BD header"));
6309 /* Drop packet */
6310 vos_pkt_return_packet(vosTempBuff);
6311 vosTempBuff = vosDataBuff;
6312 continue;
6313 }
6314
6315 uDPUSig = WDA_GET_RX_DPUSIG( pvBDHeader );
6316
6317 /* AMSDU HW bug fix
6318 * After 2nd AMSDU subframe HW could not handle BD correctly
6319 * HAL workaround is needed */
6320 if(WDA_GET_RX_ASF(pvBDHeader))
6321 {
6322 WDA_DS_RxAmsduBdFix(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb),
6323 pvBDHeader);
6324 }
6325
6326 ucTid = (v_U8_t)WDA_GET_RX_TID( pvBDHeader );
6327
6328 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6329 "WLAN TL:Data packet cached for STA %d", ucSTAId);
6330
6331 /*------------------------------------------------------------------
6332 This should be corrected when multipe sta support is added !!!
6333 for now bcast frames will be sent to the last registered STA
6334 ------------------------------------------------------------------*/
6335 if ( WDA_IS_RX_BCAST(pvBDHeader))
6336 {
6337 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6338 "WLAN TL:TL rx Bcast frame "));
6339 broadcast = VOS_TRUE;
6340
6341 /* If Addr1 is b/mcast, but Addr3 is our own self MAC, it is a b/mcast
6342 * pkt we sent looping back to us. To be dropped if we are non BTAMP
6343 */
6344 if( WLANHAL_RX_BD_ADDR3_SELF_IDX ==
6345 (v_U8_t)WDA_GET_RX_ADDR3_IDX( pvBDHeader ))
6346 {
6347 selfBcastLoopback = VOS_TRUE;
6348 }
6349 }/*if bcast*/
6350
6351 /*-------------------------------------------------------------------------
6352 Check if the packet that we cached matches the DPU signature of the
6353 newly added station
6354 -------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306355 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
6356
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306357 if ( NULL == pClientSTA )
6358 {
6359 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6360 "WLAN TL:Client Memory was not allocated on %s", __func__));
6361 return VOS_STATUS_E_FAILURE;
6362 }
6363
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 if ( broadcast )
6365 {
6366 ucBcastSig = (v_U8_t)uDPUSig;
6367 bSigMatch = (( WLAN_TL_INVALID_B_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306368 pClientSTA->wSTADesc.ucBcastSig ) &&
6369 ( ucBcastSig == pClientSTA->wSTADesc.ucBcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 }
6371 else
6372 {
6373 ucUcastSig = (v_U8_t)uDPUSig;
6374 bSigMatch = (( WLAN_TL_INVALID_U_SIG !=
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306375 pClientSTA->wSTADesc.ucUcastSig ) &&
6376 ( ucUcastSig == pClientSTA->wSTADesc.ucUcastSig ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 }
6378
6379 /*-------------------------------------------------------------------------
6380 If the packet doesn't match - drop it
6381 -------------------------------------------------------------------------*/
6382 if ( !bSigMatch )
6383 {
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006384 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 "WLAN TL: Cached packet does not match DPU Sig of the new STA - drop "
6386 " DPU Sig %d UC %d BC %d B %d",
6387 uDPUSig,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306388 pClientSTA->wSTADesc.ucUcastSig,
Rajesh Chauhana6b08f42013-06-18 19:01:26 -07006389 pClientSTA->wSTADesc.ucBcastSig,
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 broadcast));
6391
6392 /* Drop packet */
6393 vos_pkt_return_packet(vosTempBuff);
6394 vosTempBuff = vosDataBuff;
6395 continue;
6396
6397 }/*if signature mismatch*/
6398
6399 /*------------------------------------------------------------------------
6400 Check if BT-AMP frame:
6401 - additional processing needed in this case to separate BT-AMP date
6402 from BT-AMP Ctrl path
6403 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306404 if ( WLAN_STA_BT_AMP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 {
6406 /*--------------------------------------------------------------------
6407 Process the ctrl BAP frame; if data it will return false and it
6408 will be routed through the regular data path
6409 --------------------------------------------------------------------*/
6410 if ( WLANTL_ProcessBAPFrame( pvBDHeader,
6411 vosTempBuff,
6412 pTLCb,
6413 &first_data_pkt_arrived,
6414 ucSTAId))
6415 {
6416 vosTempBuff = vosDataBuff;
6417 continue;
6418 }
6419 }/*if BT-AMP station*/
6420 else if(selfBcastLoopback == VOS_TRUE)
6421 {
6422 /* Drop packet */
6423 vos_pkt_return_packet(vosTempBuff);
6424 vosTempBuff = vosDataBuff;
6425 continue;
6426 }
6427
6428 /*---------------------------------------------------------------------
6429 Data packet received, send to state machine
6430 ---------------------------------------------------------------------*/
6431 wSTAEvent = WLANTL_RX_EVENT;
6432
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306433 pfnSTAFsm = tlSTAFsm[pClientSTA->tlState].
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 pfnSTATbl[wSTAEvent];
6435
6436 if ( NULL != pfnSTAFsm )
6437 {
6438#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6439 /* Read RSSI and update */
6440 vosStatus = WLANTL_HSHandleRXFrame(vos_get_global_context(
6441 VOS_MODULE_ID_TL,pTLCb),
6442 WLANTL_DATA_FRAME_TYPE,
6443 pvBDHeader,
6444 ucSTAId,
6445 broadcast,
6446 vosTempBuff);
6447 broadcast = VOS_FALSE;
6448#else
6449 vosStatus = WLANTL_ReadRSSI(vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), pvBDHeader, ucSTAId);
Kiet Lam47325522014-03-10 11:50:46 -07006450#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
6452 {
6453 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6454 "Handle RX Data Frame fail within Handoff support module"));
6455 /* Do Not Drop packet at here
6456 * Revisit why HO module return fail
6457 vos_pkt_return_packet(vosTempBuff);
6458 vosTempBuff = vosDataBuff;
6459 continue;
6460 */
6461 }
6462 pfnSTAFsm( vos_get_global_context(VOS_MODULE_ID_TL,pTLCb), ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006463 &vosTempBuff, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 }
6465 else
6466 {
6467 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6468 "WLAN TL:NULL state function, STA:%d, State: %d- dropping packet",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05306469 ucSTAId, pClientSTA->tlState));
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 /* Drop packet */
6471 vos_pkt_return_packet(vosTempBuff);
6472 vosTempBuff = vosDataBuff;
6473 continue;
6474 }
6475
6476 vosTempBuff = vosDataBuff;
6477 }/*while chain*/
6478
6479 return VOS_STATUS_SUCCESS;
6480}/* WLANTL_RxCachedFrames */
6481
6482/*==========================================================================
Katya Nigam664f5032014-05-05 12:24:32 +05306483 FUNCTION WLANTL_RxProcessMsg
6484
6485 DESCRIPTION
6486 Called by VOSS when a message was serialized for TL through the
6487 rx thread/task.
6488
6489 DEPENDENCIES
6490 The TL must be initialized before this function can be called.
6491
6492 PARAMETERS
6493
6494 IN
6495 pvosGCtx: pointer to the global vos context; a handle to TL's
6496 control block can be extracted from its context
6497 message: type and content of the message
6498
6499
6500 RETURN VALUE
6501 The result code associated with performing the operation
6502
6503 VOS_STATUS_E_INVAL: invalid input parameters
6504 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6505 page fault
6506 VOS_STATUS_SUCCESS: Everything is good :)
6507
6508 Other values can be returned as a result of a function call, please check
6509 corresponding API for more info.
6510 SIDE EFFECTS
6511
6512============================================================================*/
6513VOS_STATUS
6514WLANTL_RxProcessMsg
6515(
6516 v_PVOID_t pvosGCtx,
6517 vos_msg_t* message
6518)
6519{
6520 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6521 v_U32_t uData;
6522 v_U8_t ucSTAId;
6523 v_U8_t ucUcastSig;
6524 v_U8_t ucBcastSig;
6525
6526 /*------------------------------------------------------------------------
6527 Sanity check
6528 ------------------------------------------------------------------------*/
6529 if ( NULL == message )
6530 {
6531 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6532 "WLAN TL:Invalid parameter sent on WLANTL_RxProcessMessage"));
6533 return VOS_STATUS_E_INVAL;
6534 }
6535
6536 /*------------------------------------------------------------------------
6537 Process message
6538 ------------------------------------------------------------------------*/
6539 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6540 "WLAN TL:Received message: %d through rx flow", message->type));
6541
6542 switch( message->type )
6543 {
6544
6545 case WLANTL_RX_FWD_CACHED:
6546 /*---------------------------------------------------------------------
6547 The data sent with the message has the following structure:
6548 | 00 | ucBcastSignature | ucUcastSignature | ucSTAID |
6549 each field above is one byte
6550 ---------------------------------------------------------------------*/
6551 uData = message->bodyval;
6552 ucSTAId = ( uData & 0x000000FF);
6553 ucUcastSig = ( uData & 0x0000FF00)>>8;
6554 ucBcastSig = (v_U8_t)(( uData & 0x00FF0000)>>16);
6555 vosStatus = WLANTL_ForwardSTAFrames( pvosGCtx, ucSTAId,
6556 ucUcastSig, ucBcastSig);
6557 break;
6558
6559 default:
6560 /*no processing for now*/
6561 break;
6562 }
6563
6564 return VOS_STATUS_SUCCESS;
6565}
6566
6567
6568/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 FUNCTION WLANTL_ResourceCB
6570
6571 DESCRIPTION
6572 Called by the TL when it has packets available for transmission.
6573
6574 DEPENDENCIES
6575 The TL must be registered with BAL before this function can be called.
6576
6577 PARAMETERS
6578
6579 IN
6580 pvosGCtx: pointer to the global vos context; a handle to TL's
6581 or BAL's control block can be extracted from its context
6582
6583 RETURN VALUE
6584 The result code associated with performing the operation
6585
6586 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
6587 page fault
6588 VOS_STATUS_SUCCESS: Everything is good :)
6589
6590 SIDE EFFECTS
6591
6592============================================================================*/
6593VOS_STATUS
6594WLANTL_ResourceCB
6595(
6596 v_PVOID_t pvosGCtx,
6597 v_U32_t uCount
6598)
6599{
6600 WLANTL_CbType* pTLCb = NULL;
6601 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6602
6603 /*------------------------------------------------------------------------
6604 Sanity check
6605 Extract TL control block
6606 ------------------------------------------------------------------------*/
6607 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6608 if ( NULL == pTLCb )
6609 {
6610 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6611 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
6612 return VOS_STATUS_E_FAULT;
6613 }
6614
6615 pTLCb->uResCount = uCount;
6616
6617
6618 /*-----------------------------------------------------------------------
6619 Resume Tx if enough res and not suspended
6620 -----------------------------------------------------------------------*/
6621 if (( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
6622 ( 0 == pTLCb->ucTxSuspended ))
6623 {
6624 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
6625 "WLAN TL:Issuing Xmit start request to BAL for avail res ASYNC"));
6626 return WDA_DS_StartXmit(pvosGCtx);
6627 }
6628
6629 return VOS_STATUS_SUCCESS;
6630}/* WLANTL_ResourceCB */
6631
6632
Gopichand Nakkala11acd112012-12-31 16:04:04 -08006633/*==========================================================================
6634 FUNCTION WLANTL_IsTxXmitPending
6635
6636 DESCRIPTION
6637 Called by the WDA when it wants to know whether WDA_DS_TX_START_XMIT msg
6638 is pending in TL msg queue
6639
6640 DEPENDENCIES
6641 The TL must be registered with WDA before this function can be called.
6642
6643 PARAMETERS
6644
6645 IN
6646 pvosGCtx: pointer to the global vos context; a handle to TL's
6647 or WDA's control block can be extracted from its context
6648
6649 RETURN VALUE
6650 The result code associated with performing the operation
6651
6652 0: No WDA_DS_TX_START_XMIT msg pending
6653 1: Msg WDA_DS_TX_START_XMIT already pending in TL msg queue
6654
6655 SIDE EFFECTS
6656
6657============================================================================*/
6658v_BOOL_t
6659WLANTL_IsTxXmitPending
6660(
6661 v_PVOID_t pvosGCtx
6662)
6663{
6664
6665 WLANTL_CbType* pTLCb = NULL;
6666 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6667
6668 /*------------------------------------------------------------------------
6669 Sanity check
6670 Extract TL control block
6671 ------------------------------------------------------------------------*/
6672 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6673 if ( NULL == pTLCb )
6674 {
6675 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6676 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_IsTxXmitPending "));
6677 return FALSE;
6678 }
6679
6680 return pTLCb->isTxTranmitMsgPending;
6681
6682}/*WLANTL_IsTxXmitPending */
6683
6684/*==========================================================================
6685 FUNCTION WLANTL_SetTxXmitPending
6686
6687 DESCRIPTION
6688 Called by the WDA when it wants to indicate that WDA_DS_TX_START_XMIT msg
6689 is pending in TL msg queue
6690
6691 DEPENDENCIES
6692 The TL must be registered with WDA before this function can be called.
6693
6694 PARAMETERS
6695
6696 IN
6697 pvosGCtx: pointer to the global vos context; a handle to TL's
6698 or WDA's control block can be extracted from its context
6699
6700 RETURN VALUE None
6701
6702 SIDE EFFECTS
6703
6704============================================================================*/
6705
6706v_VOID_t
6707WLANTL_SetTxXmitPending
6708(
6709 v_PVOID_t pvosGCtx
6710)
6711{
6712
6713 WLANTL_CbType* pTLCb = NULL;
6714 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6715
6716 /*------------------------------------------------------------------------
6717 Sanity check
6718 Extract TL control block
6719 ------------------------------------------------------------------------*/
6720 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6721 if ( NULL == pTLCb )
6722 {
6723 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6724 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_SetTxXmitPending"));
6725 return;
6726 }
6727
6728 pTLCb->isTxTranmitMsgPending = 1;
6729 return;
6730
6731}/*WLANTL_SetTxXmitPending */
6732
6733/*==========================================================================
6734 FUNCTION WLANTL_ClearTxXmitPending
6735
6736 DESCRIPTION
6737 Called by the WDA when it wants to indicate that no WDA_DS_TX_START_XMIT msg
6738 is pending in TL msg queue
6739
6740 DEPENDENCIES
6741 The TL must be registered with WDA before this function can be called.
6742
6743 PARAMETERS
6744
6745 IN
6746 pvosGCtx: pointer to the global vos context; a handle to TL's
6747 or WDA's control block can be extracted from its context
6748
6749 RETURN VALUE None
6750
6751 SIDE EFFECTS
6752
6753============================================================================*/
6754
6755v_VOID_t
6756WLANTL_ClearTxXmitPending
6757(
6758 v_PVOID_t pvosGCtx
6759)
6760{
6761
6762 WLANTL_CbType* pTLCb = NULL;
6763 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
6764
6765 /*------------------------------------------------------------------------
6766 Sanity check
6767 Extract TL control block
6768 ------------------------------------------------------------------------*/
6769 pTLCb = VOS_GET_TL_CB(pvosGCtx);
6770 if ( NULL == pTLCb )
6771 {
6772 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6773 "WLAN TL:Invalid TL pointer from pvosGCtx in WLANTL_ClearTxXmitPending "));
6774 return;
6775 }
6776
6777 pTLCb->isTxTranmitMsgPending = 0;
6778 return;
6779}/*WLANTL_ClearTxXmitPending */
6780
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306781/*==========================================================================
6782 FUNCTION WLANTL_TxThreadDebugHandler
6783
6784 DESCRIPTION
6785 Printing TL Snapshot dump, processed under TxThread context, currently
6786 information regarding the global TlCb struture. Dumps information related
6787 to per active STA connection currently in use by TL.
6788
6789 DEPENDENCIES
6790 The TL must be initialized before this gets called.
6791
6792 PARAMETERS
6793
6794 IN
6795 pvosGCtx: pointer to the global vos context; a handle to TL's
6796 or WDA's control block can be extracted from its context
6797
6798 RETURN VALUE None
6799
6800 SIDE EFFECTS
6801
6802============================================================================*/
6803
6804v_VOID_t
6805WLANTL_TxThreadDebugHandler
6806(
6807 v_PVOID_t *pVosContext
6808)
6809{
6810 WLANTL_CbType* pTLCb = NULL;
6811 WLANTL_STAClientType* pClientSTA = NULL;
6812 int i = 0;
6813 tWDA_CbContext *pWDA = NULL;
6814
6815 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6816 "WLAN TL: %s Enter ", __func__));
6817
6818 pTLCb = VOS_GET_TL_CB(pVosContext);
6819 pWDA = (tWDA_CbContext *)vos_get_global_context(VOS_MODULE_ID_WDA, pVosContext);
6820
6821 if ( NULL == pVosContext || NULL == pTLCb )
6822 {
6823 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6824 "Global VoS Context or TL Context are NULL"));
6825 return;
6826 }
6827
6828 if (NULL != pWDA)
6829 {
6830 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6831 "WDA uTxFlowMask: %d", pWDA->uTxFlowMask));
6832 }
6833 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6834 "************************TL DUMP INFORMATION**************"));
6835
6836 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6837 "uDelayedTriggerFrmInt:%d\tuMinFramesProcThres:%d",
6838 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt,
6839 pTLCb->tlConfigInfo.uMinFramesProcThres));
6840
6841 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6842 "Management Frame Client exists: %d",
6843 pTLCb->tlMgmtFrmClient.ucExists));
6844 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6845 "usPendingTxCompleteCount: %d\tucTxSuspended: %d",
6846 pTLCb->usPendingTxCompleteCount,
6847 pTLCb->ucTxSuspended));
6848
6849 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6850 "uResCount: %d", pTLCb->uResCount));
6851
6852 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6853 "ucRegisteredStaId: %d\tucCurrentSTA: %d",
6854 pTLCb->ucRegisteredStaId, pTLCb->ucCurrentSTA));
6855
6856 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6857 "UrgentFrameProcessing: %s\tuFramesProcThres: %d",
6858 (pTLCb->bUrgent?"True":"False"), pTLCb->uFramesProcThres));
6859
6860 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6861 "isTxTranmitMsgPending: %d\t isBMPS: %s",
6862 pTLCb->isTxTranmitMsgPending, pTLCb->isBMPS?"True":"False"));
6863
6864#ifdef FEATURE_WLAN_TDLS
6865 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6866 "TDLS Peer Count: %d", pTLCb->ucTdlsPeerCount));
6867#endif
6868
6869 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6870 "++++++++++++++++++++Registerd Client Information++++++++++"));
6871
6872 for ( i =0; i<WLAN_MAX_STA_COUNT; i++ )
6873 {
6874 pClientSTA = pTLCb->atlSTAClients[i];
6875 if( NULL == pClientSTA || 0 == pClientSTA->ucExists)
6876 {
6877 continue;
6878 }
6879
6880 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6881 "######################STA Index: %d ############################",i));
6882 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "WLAN_STADescType:"));
6883 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6884 "STAId: %d\t STA MAC Address: %pM", pClientSTA->wSTADesc.ucSTAId,
6885 pClientSTA->wSTADesc.vSTAMACAddress.bytes));
6886 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6887 "STA Type: %d\tProtectedFrame: %d",
6888 pClientSTA->wSTADesc.wSTAType, pClientSTA->wSTADesc.ucProtectedFrame));
6889 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6890 "QoS: %d\tRxFrameTrans: %d\tTxFrameTrans: %d",
6891 pClientSTA->wSTADesc.ucQosEnabled, pClientSTA->wSTADesc.ucSwFrameRXXlation,
6892 pClientSTA->wSTADesc.ucSwFrameTXXlation));
6893 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6894 "ucUcastSig: %d\tucBcastSig: %d", pClientSTA->wSTADesc.ucUcastSig,
6895 pClientSTA->wSTADesc.ucBcastSig));
6896
6897 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6898 "ClientIndex: %d\t Exists: %d", i, pClientSTA->ucExists));
6899 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6900 "TL State: %d\t TL Priority: %d", pClientSTA->tlState,
6901 pClientSTA->tlPri));
6902 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6903 "ucTxSuspended: %d\tucPktPending: %d", pClientSTA->ucTxSuspended,
6904 pClientSTA->ucPktPending));
6905 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6906 "ucEAPOLPktPending: %d\tucNoMoreData: %d",
6907 pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
6908 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Katya Nigam63902932014-06-26 19:04:23 +05306909 "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306910 pClientSTA->fcStaTxDisabled));
6911 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6912 "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
6913 pClientSTA->ucServicedAC));
6914 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6915 "TID: %d\tautTxCount[0]: %d\tauRxCount[0]: %d",0, pClientSTA->auTxCount[0],
6916 pClientSTA->auRxCount[0]));
6917 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6918 "aucAcMask[0]: %d\taucAcMask[1]: %d\taucAcMask[2]: %d\taucAcMask[3]: %d\t",
6919 pClientSTA->aucACMask[0], pClientSTA->aucACMask[1],
6920 pClientSTA->aucACMask[2], pClientSTA->aucACMask[3]));
6921 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6922 "ucCurrentWeight: %d", pClientSTA->ucCurrentWeight));
6923
6924 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
6925 {
6926 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6927 "TrafficStatistics for SOFTAP Station:"));
6928 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6929 "RUF=%d\tRMF=%d\tRBF=%d", pClientSTA->trafficStatistics.rxUCFcnt,
6930 pClientSTA->trafficStatistics.rxMCFcnt,
6931 pClientSTA->trafficStatistics.rxBCFcnt));
6932 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6933 "RUB=%d\tRMB=%d\tRBB=%d", pClientSTA->trafficStatistics.rxUCBcnt,
6934 pClientSTA->trafficStatistics.rxMCBcnt,
6935 pClientSTA->trafficStatistics.rxBCBcnt));
6936 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6937 "TUF=%d\tTMF=%d\tTBF=%d", pClientSTA->trafficStatistics.txUCFcnt,
6938 pClientSTA->trafficStatistics.txMCFcnt,
6939 pClientSTA->trafficStatistics.txBCFcnt));
6940 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6941 "TUB=%d\tTMB=%d\tTBB=%d", pClientSTA->trafficStatistics.txUCBcnt,
6942 pClientSTA->trafficStatistics.txMCBcnt,
6943 pClientSTA->trafficStatistics.txBCBcnt));
6944 }
6945 }
6946 return;
6947}
6948
6949/*==========================================================================
Mihir Shetefd62d9d2014-08-06 15:08:21 +05306950 FUNCTION WLANTL_FatalErrorHandler
6951
6952 DESCRIPTION
6953 Handle Fatal errors detected on the TX path.
6954 Currently issues SSR to recover from the error.
6955
6956 DEPENDENCIES
6957 The TL must be initialized before this gets called.
6958
6959 PARAMETERS
6960
6961 IN
6962 pvosGCtx: pointer to the global vos context; a handle to TL's
6963 or WDA's control block can be extracted from its context
6964
6965 RETURN VALUE None
6966
6967 SIDE EFFECTS
6968
6969============================================================================*/
6970v_VOID_t
6971WLANTL_FatalErrorHandler
6972(
6973 v_PVOID_t *pVosContext
6974)
6975{
6976
6977 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
6978 "WLAN TL: %s Enter ", __func__));
6979
6980 if ( NULL == pVosContext )
6981 {
6982 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
6983 "%s: Global VoS Context or TL Context are NULL",
6984 __func__));
6985 return;
6986 }
6987
6988 /*
6989 * Issue SSR. vos_wlanRestart has tight checks to make sure that
6990 * we do not send an FIQ if previous FIQ is not processed
6991 */
6992 vos_wlanRestart();
6993}
6994
6995/*==========================================================================
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306996 FUNCTION WLANTL_TLDebugMessage
6997
6998 DESCRIPTION
6999 Post a TL Snapshot request, posts message in TxThread.
7000
7001 DEPENDENCIES
7002 The TL must be initialized before this gets called.
7003
7004 PARAMETERS
7005
7006 IN
7007 displaySnapshot Boolean showing whether to dump the snapshot or not.
7008
7009 RETURN VALUE None
7010
7011 SIDE EFFECTS
7012
7013============================================================================*/
7014
7015v_VOID_t
7016WLANTL_TLDebugMessage
7017(
7018 v_BOOL_t displaySnapshot
7019)
7020{
7021 vos_msg_t vosMsg;
7022 VOS_STATUS status;
7023
7024 if(displaySnapshot)
7025 {
7026 vosMsg.reserved = 0;
7027 vosMsg.bodyptr = NULL;
7028 vosMsg.type = WLANTL_TX_SNAPSHOT;
7029
7030 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7031 if(status != VOS_STATUS_SUCCESS)
7032 {
7033 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "TX Msg Posting Failed with status: %d",status));
7034 return;
7035 }
7036 }
7037 return;
7038}
Jeff Johnson295189b2012-06-20 16:38:30 -07007039
Mihir Shetefd62d9d2014-08-06 15:08:21 +05307040/*==========================================================================
7041 FUNCTION WLANTL_FatalError
7042
7043 DESCRIPTION
7044 Fatal error reported in TX path, post an event to TX Thread for further
7045 handling
7046
7047 DEPENDENCIES
7048 The TL must be initialized before this gets called.
7049
7050 PARAMETERS
7051
7052 VOID
7053
7054 RETURN VALUE None
7055
7056 SIDE EFFECTS
7057
7058============================================================================*/
7059
7060v_VOID_t
7061WLANTL_FatalError
7062(
7063 v_VOID_t
7064)
7065{
7066 vos_msg_t vosMsg;
7067 VOS_STATUS status;
7068
7069 vosMsg.reserved = 0;
7070 vosMsg.bodyptr = NULL;
7071 vosMsg.type = WLANTL_TX_FATAL_ERROR;
7072
7073 status = vos_tx_mq_serialize( VOS_MODULE_ID_TL, &vosMsg);
7074 if(status != VOS_STATUS_SUCCESS)
7075 {
7076 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7077 "%s: TX Msg Posting Failed with status: %d",
7078 __func__,status));
7079 }
7080 return;
7081}
Jeff Johnson295189b2012-06-20 16:38:30 -07007082/*============================================================================
7083 TL STATE MACHINE
7084============================================================================*/
7085
7086/*==========================================================================
7087 FUNCTION WLANTL_STATxConn
7088
7089 DESCRIPTION
7090 Transmit in connected state - only EAPOL and WAI packets allowed
7091
7092 DEPENDENCIES
7093 The STA must be registered with TL before this function can be called.
7094
7095 PARAMETERS
7096
7097 IN
7098 pvosGCtx: pointer to the global vos context; a handle to TL's
7099 control block can be extracted from its context
7100 ucSTAId: identifier of the station being processed
7101 vosDataBuff: pointer to the tx vos buffer
7102
7103 RETURN VALUE
7104 The result code associated with performing the operation
7105
7106 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7107 page fault
7108 VOS_STATUS_SUCCESS: Everything is good :)
7109
7110 Other return values are possible coming from the called functions.
7111 Please check API for additional info.
7112
7113 SIDE EFFECTS
7114
7115============================================================================*/
7116VOS_STATUS
7117WLANTL_STATxConn
7118(
7119 v_PVOID_t pvosGCtx,
7120 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007121 vos_pkt_t** pvosDataBuff,
7122 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007123)
7124{
7125 v_U16_t usPktLen;
7126 VOS_STATUS vosStatus;
7127 v_MACADDR_t vDestMacAddr;
7128 vos_pkt_t* vosDataBuff = NULL;
7129 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307130 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 WLANTL_MetaInfoType tlMetaInfo;
7132 v_U8_t ucTypeSubtype = 0;
7133 v_U8_t ucTid;
7134 v_U8_t extraHeadSpace = 0;
7135 v_U8_t ucWDSEnabled = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007136 v_U8_t ucAC, ucACMask, i;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307137 v_U32_t txFlag = HAL_TX_NO_ENCRYPTION_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7139
7140 /*------------------------------------------------------------------------
7141 Sanity check
7142 Extract TL control block
7143 ------------------------------------------------------------------------*/
7144 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7145 if ( NULL == pTLCb )
7146 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007147 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7148 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxConn");
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 *pvosDataBuff = NULL;
7150 return VOS_STATUS_E_FAULT;
7151 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307152 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7153
7154 if ( NULL == pClientSTA )
7155 {
7156 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7157 "WLAN TL:Client Memory was not allocated on %s", __func__));
7158 return VOS_STATUS_E_FAILURE;
7159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007160
7161 /*-------------------------------------------------------------------
7162 Disable AC temporary - if successfull retrieve re-enable
7163 The order is justified because of the possible scenario
7164 - TL tryes to fetch packet for AC and it returns NULL
7165 - TL analyzes the data it has received to see if there are
7166 any more pkts available for AC -> if not TL will disable AC
7167 - however it is possible that while analyzing results TL got
7168 preempted by a pending indication where the mask was again set
7169 TL will not check again and as a result when it resumes
7170 execution it will disable AC
7171 To prevent this the AC will be disabled here and if retrieve
7172 is successfull it will be re-enabled
7173 -------------------------------------------------------------------*/
7174
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007175
7176 //LTI:pTLCb->atlSTAClients[ucSTAId].
7177 //LTI: aucACMask[pTLCb->atlSTAClients[ucSTAId].ucCurrentAC] = 0;
7178
7179 /*------------------------------------------------------------------------
7180 Fetch packet from HDD
7181 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007182#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307183 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307184 !(vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007185 !pTLCb->ucTdlsPeerCount)
7186 {
7187#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307188 if ((WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307189 !(vos_concurrent_open_sessions_running()))
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007190 {
Sunil Ravid5406f22013-01-22 00:18:31 -08007191#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307192 ucAC = pClientSTA->ucCurrentAC;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007193
7194 /*-------------------------------------------------------------------
7195 Disable AC temporary - if successfull retrieve re-enable
7196 The order is justified because of the possible scenario
7197 - TL tryes to fetch packet for AC and it returns NULL
7198 - TL analyzes the data it has received to see if there are
7199 any more pkts available for AC -> if not TL will disable AC
7200 - however it is possible that while analyzing results TL got
7201 preempted by a pending indication where the mask was again set
7202 TL will not check again and as a result when it resumes
7203 execution it will disable AC
7204 To prevent this the AC will be disabled here and if retrieve
7205 is successfull it will be re-enabled
7206 -------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307207 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007208 }
7209 else
7210 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307211 //softap case
7212 ucAC = pTLCb->uCurServedAC;
7213 pClientSTA->aucACMask[ucAC] = 0;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007215
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307216 /*You make an initial assumption that HDD has no more data and if the
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 assumption was wrong you reset the flags to their original state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307218 This will prevent from exposing a race condition between checking with HDD
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 for packets and setting the flags to false*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307220 //LTI: vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 0);
7221 //LTI: pTLCb->atlSTAClients[ucSTAId].ucNoMoreData = 1;
7222 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
7223 WLAN_TL_AC_ARRAY_2_MASK( pClientSTA, ucACMask, i);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307224 /*You make an initial assumption that HDD has no more data and if the
7225 assumption was wrong you reset the flags to their original state
7226 This will prevent from exposing a race condition between checking with HDD
7227 for packets and setting the flags to false*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007228 if ( 0 == ucACMask )
7229 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307230 pClientSTA->ucNoMoreData = 1;
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007231 }
7232 else
7233 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307234 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007235 }
7236
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007237
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007238 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007239 "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 +05307240 ucAC, ucACMask, pClientSTA->ucPktPending);
Jeff Johnson295189b2012-06-20 16:38:30 -07007241
7242 /*------------------------------------------------------------------------
7243 Fetch tx packet from HDD
7244 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007245
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307246 vosStatus = pClientSTA->pfnSTAFetchPkt( pvosGCtx,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007247 &ucSTAId,
7248 ucAC,
7249 &vosDataBuff, &tlMetaInfo );
Jeff Johnson295189b2012-06-20 16:38:30 -07007250
7251 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7252 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007253 TLLOG1(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 "WLAN TL:No more data at HDD status %d", vosStatus));
7255 *pvosDataBuff = NULL;
7256
7257 /*--------------------------------------------------------------------
7258 Reset AC for the serviced station to the highest priority AC
7259 -> due to no more data at the station
7260 Even if this AC is not supported by the station, correction will be
7261 made in the main TL loop
7262 --------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307263 pClientSTA->ucCurrentAC = WLANTL_AC_VO;
7264 pClientSTA->ucCurrentWeight = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007265
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08007266 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07007267 "WLAN TL: WLANTL_STATxConn no more packets in HDD for AC: %d AC Mask: %d",
7268 ucAC, ucACMask);
7269
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 return vosStatus;
7271 }
7272
7273 /*There are still packets in HDD - set back the pending packets and
7274 the no more data assumption*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307275 vos_atomic_set_U8( &pClientSTA->ucPktPending, 1);
7276 pClientSTA->ucNoMoreData = 0;
7277 pClientSTA->aucACMask[ucAC] = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007278
Jeff Johnson295189b2012-06-20 16:38:30 -07007279#ifdef WLAN_PERF
7280 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7281 (v_PVOID_t)0);
7282
7283#endif /*WLAN_PERF*/
7284
7285
7286#ifdef FEATURE_WLAN_WAPI
7287 /*------------------------------------------------------------------------
7288 If the packet is neither an Eapol packet nor a WAI packet then drop it
7289 ------------------------------------------------------------------------*/
7290 if ( 0 == tlMetaInfo.ucIsEapol && 0 == tlMetaInfo.ucIsWai )
7291 {
Madan Mohan Koyyalamudid93f4942012-10-05 15:05:40 -07007292 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 "WLAN TL:Only EAPOL or WAI packets allowed before authentication"));
7294
7295 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307296 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 VOS_STATUS_E_BADMSG);
7298 vosDataBuff = NULL;
7299 *pvosDataBuff = NULL;
7300 return VOS_STATUS_SUCCESS;
7301 }
7302#else
7303 if ( 0 == tlMetaInfo.ucIsEapol )
7304 {
7305 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7306 "WLAN TL:Received non EAPOL packet before authentication"));
7307
7308 /* Fail tx for packet */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307309 pClientSTA->pfnSTATxComp( pvosGCtx, vosDataBuff,
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 VOS_STATUS_E_BADMSG);
7311 vosDataBuff = NULL;
7312 *pvosDataBuff = NULL;
7313 return VOS_STATUS_SUCCESS;
7314 }
7315#endif /* FEATURE_WLAN_WAPI */
7316
7317 /*-------------------------------------------------------------------------
7318 Check TID
7319 -------------------------------------------------------------------------*/
7320 ucTid = tlMetaInfo.ucTID;
7321
7322 /*Make sure TID is valid*/
7323 if ( WLANTL_TID_INVALID(ucTid))
7324 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007325 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7327 ucTid));
7328 ucTid = 0;
7329 }
7330
7331 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7332 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxConn"));
7333
7334#ifdef FEATURE_WLAN_WAPI
7335 /*------------------------------------------------------------------------
7336 Translate 802.3 frame to 802.11 if Frame translation is enabled or if
7337 frame is a WAI frame.
7338 ------------------------------------------------------------------------*/
7339 if ( ( 1 == tlMetaInfo.ucIsWai ) ||
7340 ( 0 == tlMetaInfo.ucDisableFrmXtl ) )
7341#else
7342 /*------------------------------------------------------------------------
7343 Translate 802.3 frame to 802.11 if Frame translation is enabled
7344 ------------------------------------------------------------------------*/
7345 if ( ( 0 == tlMetaInfo.ucDisableFrmXtl ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307346 ( 0 != pClientSTA->wSTADesc.ucSwFrameTXXlation) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007347#endif //#ifdef FEATURE_WLAN_WAPI
7348 {
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007349 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7350 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007351 &tlMetaInfo, &ucWDSEnabled,
7352 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 if ( VOS_STATUS_SUCCESS != vosStatus )
7354 {
7355 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7356 "WLAN TL:Error when translating header WLANTL_STATxConn"));
7357
7358 return vosStatus;
7359 }
7360
7361 tlMetaInfo.ucDisableFrmXtl = 1;
7362 }
7363
7364 /*-------------------------------------------------------------------------
7365 Call HAL to fill BD header
7366 -------------------------------------------------------------------------*/
7367 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7368
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307369 if ( pClientSTA->wSTADesc.ucQosEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 {
7371 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7372 }
7373
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307374#ifdef FEATURE_WLAN_WAPI
7375 /* TL State does not transition to AUTHENTICATED till GTK is installed, So in
7376 * case of WPA where GTK handshake is done after the 4 way handshake, the
7377 * unicast 2/2 EAPOL packet from the STA->AP has to be encrypted even before
7378 * the TL is in authenticated state. Since the PTK has been installed
7379 * already (after the 4 way handshake) we make sure that all traffic
7380 * is encrypted henceforth.(Note: TL is still not in AUTHENTICATED state so
7381 * we will only allow EAPOL data or WAI in case of WAPI)
7382 */
7383 if (tlMetaInfo.ucIsEapol && pClientSTA->ptkInstalled)
7384 {
7385 txFlag = 0;
7386 }
7387#else
7388 if (pClientSTA->ptkInstalled)
7389 {
7390 txFlag = 0;
7391 }
7392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007393
7394 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx, vosDataBuff , &vDestMacAddr,
7395 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307396 pClientSTA->wSTADesc.ucQosEnabled, ucWDSEnabled,
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307398 ucTypeSubtype, &pClientSTA->wSTADesc.vSelfMACAddress,
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05307399 ucTid, txFlag,
Madan Mohan Koyyalamudi1541a5b2012-10-29 16:18:21 -07007400 tlMetaInfo.usTimeStamp, tlMetaInfo.ucIsEapol || tlMetaInfo.ucIsWai, tlMetaInfo.ucUP );
Jeff Johnson295189b2012-06-20 16:38:30 -07007401
7402 if ( VOS_STATUS_SUCCESS != vosStatus )
7403 {
7404 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7405 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7406 *pvosDataBuff = NULL;
7407 return vosStatus;
7408 }
7409
7410 /*-----------------------------------------------------------------------
7411 Update tx counter for BA session query for tx side
7412 !1 - should this be done for EAPOL frames?
7413 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307414 pClientSTA->auTxCount[ucTid]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07007415
7416 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307417 (v_PVOID_t)pClientSTA->pfnSTATxComp );
Jeff Johnson295189b2012-06-20 16:38:30 -07007418
7419 /*------------------------------------------------------------------------
7420 Save data to input pointer for TL core
7421 ------------------------------------------------------------------------*/
7422 *pvosDataBuff = vosDataBuff;
7423 /*security frames cannot be delayed*/
7424 pTLCb->bUrgent = TRUE;
7425
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 /* TX Statistics */
7427 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7428 {
7429 /* This is TX UC frame */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307430 pClientSTA->trafficStatistics.txUCFcnt++;
7431 pClientSTA->trafficStatistics.txUCBcnt += usPktLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007433
7434 return VOS_STATUS_SUCCESS;
7435}/* WLANTL_STATxConn */
7436
7437
7438/*==========================================================================
7439 FUNCTION WLANTL_STATxAuth
7440
7441 DESCRIPTION
7442 Transmit in authenticated state - all data allowed
7443
7444 DEPENDENCIES
7445 The STA must be registered with TL before this function can be called.
7446
7447 PARAMETERS
7448
7449 IN
7450 pvosGCtx: pointer to the global vos context; a handle to TL's
7451 control block can be extracted from its context
7452 ucSTAId: identifier of the station being processed
7453 vosDataBuff: pointer to the tx vos buffer
7454
7455 RETURN VALUE
7456 The result code associated with performing the operation
7457
7458 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7459 page fault
7460 VOS_STATUS_SUCCESS: Everything is good :)
7461
7462 Other return values are possible coming from the called functions.
7463 Please check API for additional info.
7464
7465 SIDE EFFECTS
7466
7467============================================================================*/
7468VOS_STATUS
7469WLANTL_STATxAuth
7470(
7471 v_PVOID_t pvosGCtx,
7472 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007473 vos_pkt_t** pvosDataBuff,
7474 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007475)
7476{
7477 v_U16_t usPktLen;
7478 VOS_STATUS vosStatus;
7479 v_MACADDR_t vDestMacAddr;
7480 vos_pkt_t* vosDataBuff = NULL;
7481 WLANTL_CbType* pTLCb = NULL;
7482 WLANTL_MetaInfoType tlMetaInfo;
7483 v_U8_t ucTypeSubtype = 0;
7484 WLANTL_ACEnumType ucAC;
7485 WLANTL_ACEnumType ucNextAC;
7486 v_U8_t ucTid;
7487 v_U8_t ucSwFrmXtl = 0;
7488 v_U8_t extraHeadSpace = 0;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307489 WLANTL_STAClientType *pStaClient = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 v_U8_t ucWDSEnabled = 0;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307491 v_U32_t ucTxFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007492 v_U8_t ucACMask, i;
7493 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7494
7495 /*------------------------------------------------------------------------
7496 Sanity check
7497 Extract TL control block
7498 ------------------------------------------------------------------------*/
7499 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7500 if (( NULL == pTLCb ) || ( NULL == pvosDataBuff ))
7501 {
7502 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0298bd02013-11-14 19:58:38 -08007503 "WLAN TL:Invalid input params on WLANTL_STATxAuth TL %p DB %p",
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 pTLCb, pvosDataBuff));
7505 if (NULL != pvosDataBuff)
7506 {
7507 *pvosDataBuff = NULL;
7508 }
7509 if(NULL != pTLCb)
7510 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307511 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
7512 {
7513 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7514 "WLAN TL:Client Memory was not allocated on %s", __func__));
7515 return VOS_STATUS_E_FAILURE;
7516 }
7517 pTLCb->atlSTAClients[ucSTAId]->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 }
7519 return VOS_STATUS_E_FAULT;
7520 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307521 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007522
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307523 if ( NULL == pStaClient )
7524 {
7525 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7526 "WLAN TL:Client Memory was not allocated on %s", __func__));
7527 return VOS_STATUS_E_FAILURE;
7528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007529
7530 vos_mem_zero(&tlMetaInfo, sizeof(tlMetaInfo));
7531 /*------------------------------------------------------------------------
7532 Fetch packet from HDD
7533 ------------------------------------------------------------------------*/
Sunil Ravid5406f22013-01-22 00:18:31 -08007534#ifdef FEATURE_WLAN_TDLS
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307535 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307536 (!vos_concurrent_open_sessions_running()) &&
Sunil Ravid5406f22013-01-22 00:18:31 -08007537 !pTLCb->ucTdlsPeerCount)
7538 {
7539#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 if ((WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType) &&
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +05307541 (!vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 {
7543#endif
7544 ucAC = pStaClient->ucCurrentAC;
7545
7546 /*-------------------------------------------------------------------
7547 Disable AC temporary - if successfull retrieve re-enable
7548 The order is justified because of the possible scenario
7549 - TL tryes to fetch packet for AC and it returns NULL
7550 - TL analyzes the data it has received to see if there are
7551 any more pkts available for AC -> if not TL will disable AC
7552 - however it is possible that while analyzing results TL got
7553 preempted by a pending indication where the mask was again set
7554 TL will not check again and as a result when it resumes
7555 execution it will disable AC
7556 To prevent this the AC will be disabled here and if retrieve
7557 is successfull it will be re-enabled
7558 -------------------------------------------------------------------*/
7559 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 0;
7560
7561 // don't reset it, as other AC queues in HDD may have packets
7562 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 }
7564 else
7565 {
7566 //softap case
7567 ucAC = pTLCb->uCurServedAC;
7568 pStaClient->aucACMask[ucAC] = 0;
7569
7570 //vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007572
7573 WLAN_TL_AC_ARRAY_2_MASK( pStaClient, ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 /*You make an initial assumption that HDD has no more data and if the
7575 assumption was wrong you reset the flags to their original state
7576 This will prevent from exposing a race condition between checking with HDD
7577 for packets and setting the flags to false*/
7578 if ( 0 == ucACMask )
7579 {
7580 vos_atomic_set_U8( &pStaClient->ucPktPending, 0);
7581 pStaClient->ucNoMoreData = 1;
7582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007583
7584 vosStatus = pStaClient->pfnSTAFetchPkt( pvosGCtx,
7585 &ucSTAId,
7586 ucAC,
7587 &vosDataBuff, &tlMetaInfo );
7588
7589
7590 if (( VOS_STATUS_SUCCESS != vosStatus ) || ( NULL == vosDataBuff ))
7591 {
7592
7593 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
7594 "WLAN TL:Failed while attempting to fetch pkt from HDD %d",
7595 vosStatus);
7596 *pvosDataBuff = NULL;
7597 /*--------------------------------------------------------------------
7598 Reset AC for the serviced station to the highest priority AC
7599 -> due to no more data at the station
7600 Even if this AC is not supported by the station, correction will be
7601 made in the main TL loop
7602 --------------------------------------------------------------------*/
7603 pStaClient->ucCurrentAC = WLANTL_AC_VO;
7604 pStaClient->ucCurrentWeight = 0;
7605
7606 return vosStatus;
7607 }
7608
Jeff Johnsone7245742012-09-05 17:12:55 -07007609 WLANTL_StatHandleTXFrame(pvosGCtx, ucSTAId, vosDataBuff, NULL, &tlMetaInfo);
Jeff Johnsone7245742012-09-05 17:12:55 -07007610
Jeff Johnson295189b2012-06-20 16:38:30 -07007611 /*There are still packets in HDD - set back the pending packets and
7612 the no more data assumption*/
7613 vos_atomic_set_U8( &pStaClient->ucPktPending, 1);
7614 pStaClient->ucNoMoreData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007615
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7617 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 // don't need to set it, as we don't reset it in this function.
7619 //vos_atomic_set_U8( &pTLCb->atlSTAClients[ucSTAId].ucPktPending, 1);
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007621
7622#ifdef WLAN_PERF
7623 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
7624 (v_PVOID_t)0);
7625#endif /*WLAN_PERF*/
7626
7627 /*-------------------------------------------------------------------------
7628 Check TID
7629 -------------------------------------------------------------------------*/
7630 ucTid = tlMetaInfo.ucTID;
7631
7632 /*Make sure TID is valid*/
7633 if ( WLANTL_TID_INVALID(ucTid))
7634 {
Rajesh Chauhan2df40bf2013-08-22 11:26:12 -07007635 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 "WLAN TL:Invalid TID sent in meta info %d - defaulting to 0 (BE)",
7637 ucTid));
7638 ucTid = 0;
7639 }
7640
7641 /*Save for UAPSD timer consideration*/
7642 pStaClient->ucServicedAC = ucAC;
7643
7644 if ( ucAC == pStaClient->ucCurrentAC )
7645 {
7646 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7647 pStaClient->ucCurrentWeight--;
7648 }
7649 else
7650 {
7651 pStaClient->ucCurrentAC = ucAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307652 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucAC] - 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007653
7654 pStaClient->aucACMask[pStaClient->ucCurrentAC] = 1;
7655
7656 }
7657
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 if (WLAN_STA_SOFTAP != pStaClient->wSTADesc.wSTAType)
7659 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 if ( 0 == pStaClient->ucCurrentWeight )
7661 {
7662 WLANTL_ACEnumType tempAC = ucAC;
7663 /*-----------------------------------------------------------------------
7664 Choose next AC - !!! optimize me
7665 -----------------------------------------------------------------------*/
7666 while ( 0 != ucACMask )
7667 {
7668 ucNextAC = (WLANTL_ACEnumType)(( tempAC - 1 ) & WLANTL_MASK_AC);
7669 if ( 0 != pStaClient->aucACMask[ucNextAC] )
7670 {
7671 pStaClient->ucCurrentAC = ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307672 pStaClient->ucCurrentWeight = pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
Jeff Johnson295189b2012-06-20 16:38:30 -07007673
7674 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7675 "WLAN TL: Changing serviced AC to: %d with Weight: %d",
7676 pStaClient->ucCurrentAC ,
7677 pStaClient->ucCurrentWeight));
7678 break;
7679 }
7680 tempAC = ucNextAC;
7681 }
7682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007684
7685 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7686 "WLAN TL:Attaching BD header to pkt on WLANTL_STATxAuth"));
7687
7688 /*------------------------------------------------------------------------
7689 Translate 802.3 frame to 802.11
7690 ------------------------------------------------------------------------*/
7691 if ( 0 == tlMetaInfo.ucDisableFrmXtl )
7692 {
7693 /* Needs frame translation */
7694 // if the client has not enabled SW-only frame translation
7695 // and if the frame is a unicast frame
7696 // (HW frame translation does not support multiple broadcast domains
7697 // so we use SW frame translation for broadcast/multicast frames)
7698#ifdef FEATURE_WLAN_WAPI
7699 // and if the frame is not a WAPI frame
7700#endif
7701 // then use HW_based frame translation
7702
7703 if ( ( 0 == pStaClient->wSTADesc.ucSwFrameTXXlation ) &&
7704 ( 0 == tlMetaInfo.ucBcast ) &&
7705 ( 0 == tlMetaInfo.ucMcast )
7706#ifdef FEATURE_WLAN_WAPI
7707 && ( tlMetaInfo.ucIsWai != 1 )
7708#endif
7709 )
7710 {
7711#ifdef WLAN_PERF
7712 v_U32_t uFastFwdOK = 0;
7713
7714 /* HW based translation. See if the frame could be fast forwarded */
7715 WDA_TLI_FastHwFwdDataFrame( pvosGCtx, vosDataBuff , &vosStatus,
7716 &uFastFwdOK, &tlMetaInfo, &pStaClient->wSTADesc);
7717
7718 if( VOS_STATUS_SUCCESS == vosStatus )
7719 {
7720 if(uFastFwdOK)
7721 {
7722 /* Packet could be fast forwarded now */
7723 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7724 (v_PVOID_t)pStaClient->pfnSTATxComp );
7725
7726 *pvosDataBuff = vosDataBuff;
7727
7728 /* TODO: Do we really need to update WLANTL_HSHandleTXFrame()
7729 stats for every pkt? */
7730 pStaClient->auTxCount[tlMetaInfo.ucTID]++;
7731 return vosStatus;
7732 }
7733 /* can't be fast forwarded, fall through normal (slow) path. */
7734 }
7735 else
7736 {
7737
7738 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7739 "WLAN TL:Failed while attempting to fastFwd BD %d", vosStatus));
7740 *pvosDataBuff = NULL;
7741 return vosStatus;
7742 }
7743#endif /*WLAN_PERF*/
7744 }
7745 else
7746 {
7747 /* SW based translation */
7748
7749#ifdef FEATURE_WLAN_WAPI
7750 gUcIsWai = tlMetaInfo.ucIsWai,
7751#endif
7752
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007753 vosStatus = WLANTL_Translate8023To80211Header( vosDataBuff, &vosStatus,
7754 pTLCb, &ucSTAId,
Ravi Joshid0699502013-07-08 15:48:47 -07007755 &tlMetaInfo, &ucWDSEnabled,
7756 &extraHeadSpace);
Jeff Johnson295189b2012-06-20 16:38:30 -07007757 if ( VOS_STATUS_SUCCESS != vosStatus )
7758 {
7759 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7760 "WLAN TL:Error when translating header WLANTL_STATxAuth"));
7761 return vosStatus;
7762 }
7763
7764 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08007765 "WLAN TL software translation success"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 ucSwFrmXtl = 1;
7767 tlMetaInfo.ucDisableFrmXtl = 1;
7768 }
7769 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307770#ifdef FEATURE_WLAN_TDLS
7771 /*In case of TDLS, if the packet is destined to TDLS STA ucSTAId may
7772 change. so update the pStaClient accordingly */
7773 pStaClient = pTLCb->atlSTAClients[ucSTAId];
Jeff Johnson295189b2012-06-20 16:38:30 -07007774
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307775 if ( NULL == pStaClient )
7776 {
7777 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7778 "pStaClient is NULL %s", __func__));
7779 return VOS_STATUS_E_FAILURE;
7780 }
7781#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 /*-------------------------------------------------------------------------
7783 Call HAL to fill BD header
7784 -------------------------------------------------------------------------*/
7785 ucTypeSubtype |= (WLANTL_80211_DATA_TYPE << 4);
7786
7787 if ( pStaClient->wSTADesc.ucQosEnabled )
7788 {
7789 ucTypeSubtype |= (WLANTL_80211_DATA_QOS_SUBTYPE);
7790 }
7791
7792 ucTxFlag = (0 != pStaClient->wUAPSDInfo[ucAC].ucSet)?
7793 HAL_TRIGGER_ENABLED_AC_MASK:0;
7794
7795#ifdef FEATURE_WLAN_WAPI
7796 if ( pStaClient->wSTADesc.ucIsWapiSta == 1 )
7797 {
7798#ifdef LIBRA_WAPI_SUPPORT
7799 ucTxFlag = ucTxFlag | HAL_WAPI_STA_MASK;
7800#endif //LIBRA_WAPI_SUPPORT
7801 if ( tlMetaInfo.ucIsWai == 1 )
7802 {
7803 ucTxFlag = ucTxFlag | HAL_TX_NO_ENCRYPTION_MASK;
7804 }
7805 }
7806#endif /* FEATURE_WLAN_WAPI */
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007807#ifdef FEATURE_WLAN_TDLS
7808 if ( pStaClient->wSTADesc.wSTAType == WLAN_STA_TDLS )
7809 {
7810 ucTxFlag = ucTxFlag | HAL_TDLS_PEER_STA_MASK;
7811 }
7812#endif /* FEATURE_WLAN_TDLS */
Abhishek Singhfa011222014-04-14 10:57:08 +05307813 if( tlMetaInfo.ucIsArp )
7814 {
7815 /*Send ARP at lowest Phy rate and through WQ5 */
7816 ucTxFlag |= HAL_USE_BD_RATE_MASK;
Abhishek Singhfa011222014-04-14 10:57:08 +05307817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007818
7819 vosStatus = (VOS_STATUS)WDA_DS_BuildTxPacketInfo( pvosGCtx,
7820 vosDataBuff , &vDestMacAddr,
7821 tlMetaInfo.ucDisableFrmXtl, &usPktLen,
7822 pStaClient->wSTADesc.ucQosEnabled, ucWDSEnabled,
7823 extraHeadSpace,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307824 ucTypeSubtype, &pStaClient->wSTADesc.vSelfMACAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 ucTid, ucTxFlag, tlMetaInfo.usTimeStamp,
7826 tlMetaInfo.ucIsEapol, tlMetaInfo.ucUP );
7827
7828 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
7829 {
7830 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7831 "Fill TX BD Error status %d", vosStatus));
7832
7833 return vosStatus;
7834 }
7835
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 /* TX Statistics */
7837 if (!(tlMetaInfo.ucBcast || tlMetaInfo.ucMcast))
7838 {
7839 /* This is TX UC frame */
7840 pStaClient->trafficStatistics.txUCFcnt++;
7841 pStaClient->trafficStatistics.txUCBcnt += usPktLen;
7842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007843
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007844#ifndef FEATURE_WLAN_TDLS
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 /*-----------------------------------------------------------------------
7846 Update tx counter for BA session query for tx side
7847 -----------------------------------------------------------------------*/
7848 pStaClient->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007849#else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307850 pTLCb->atlSTAClients[ucSTAId]->auTxCount[ucTid]++;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08007851#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007852
7853 /* This code is to send traffic with lower priority AC when we does not
7854 get admitted to send it. Today HAL does not downgrade AC so this code
7855 does not get executed.(In other words, HAL doesnÂ’t change tid. The if
7856 statement is always false.)
7857 NOTE: In the case of LA downgrade occurs in HDD (that was the change
7858 Phani made during WMM-AC plugfest). If WM & BMP also took this approach,
7859 then there will be no need for any AC downgrade logic in TL/WDI. */
7860#if 0
7861 if (( ucTid != tlMetaInfo.ucTID ) &&
7862 ( 0 != pStaClient->wSTADesc.ucQosEnabled ) &&
7863 ( 0 != ucSwFrmXtl ))
7864 {
7865 /*---------------------------------------------------------------------
7866 !! FIX me: Once downgrading is clear put in the proper change
7867 ---------------------------------------------------------------------*/
7868 ucQCOffset = WLANHAL_TX_BD_HEADER_SIZE + WLANTL_802_11_HEADER_LEN;
7869
7870 //!!!Fix this replace peek with extract
7871 vos_pkt_peek_data( vosDataBuff, ucQCOffset,(v_PVOID_t)&pucQosCtrl,
7872 sizeof(*pucQosCtrl));
7873 *pucQosCtrl = ucTid; //? proper byte order
7874 }
7875#endif
7876
7877 if ( VOS_STATUS_SUCCESS != vosStatus )
7878 {
7879 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7880 "WLAN TL:Failed while attempting to fill BD %d", vosStatus));
7881 *pvosDataBuff = NULL;
7882 return vosStatus;
7883 }
7884
7885 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
7886 (v_PVOID_t)pStaClient->pfnSTATxComp );
7887
7888 *pvosDataBuff = vosDataBuff;
7889
7890 /*BE & BK can be delayed, VO and VI not frames cannot be delayed*/
7891 if ( pStaClient->ucServicedAC > WLANTL_AC_BE )
7892 {
7893 pTLCb->bUrgent= TRUE;
7894 }
7895
7896 return VOS_STATUS_SUCCESS;
7897}/* WLANTL_STATxAuth */
7898
7899/*==========================================================================
7900 FUNCTION WLANTL_STATxDisc
7901
7902 DESCRIPTION
7903 Transmit in disconnected state - no data allowed
7904
7905 DEPENDENCIES
7906 The STA must be registered with TL before this function can be called.
7907
7908 PARAMETERS
7909
7910 IN
7911 pvosGCtx: pointer to the global vos context; a handle to TL's
7912 control block can be extracted from its context
7913 ucSTAId: identifier of the station being processed
7914 vosDataBuff: pointer to the tx vos buffer
7915
7916 RETURN VALUE
7917 The result code associated with performing the operation
7918
7919 VOS_STATUS_SUCCESS: Everything is good :)
7920
7921 SIDE EFFECTS
7922
7923============================================================================*/
7924VOS_STATUS
7925WLANTL_STATxDisc
7926(
7927 v_PVOID_t pvosGCtx,
7928 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07007929 vos_pkt_t** pvosDataBuff,
7930 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07007931)
7932{
7933 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307934 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
7936
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 /*------------------------------------------------------------------------
7938 Sanity check
7939 Extract TL control block
7940 ------------------------------------------------------------------------*/
7941 pTLCb = VOS_GET_TL_CB(pvosGCtx);
7942 if ( NULL == pTLCb )
7943 {
7944 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7945 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STATxAuth"));
7946 *pvosDataBuff = NULL;
7947 return VOS_STATUS_E_FAULT;
7948 }
7949
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307950 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
7951
7952 if ( NULL == pClientSTA )
7953 {
7954 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
7955 "WLAN TL:Client Memory was not allocated on %s", __func__));
7956 return VOS_STATUS_E_FAILURE;
7957 }
7958
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 /*------------------------------------------------------------------------
7960 Error
7961 ------------------------------------------------------------------------*/
7962 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
7963 "WLAN TL:Packet should not be transmitted in state disconnected ignoring"
7964 " request"));
7965
7966 *pvosDataBuff = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307967 pClientSTA->ucNoMoreData = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007968
7969 //Should not be anything pending in disconnect state
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05307970 vos_atomic_set_U8( &pClientSTA->ucPktPending, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007971
7972 return VOS_STATUS_SUCCESS;
7973}/* WLANTL_STATxDisc */
7974
7975/*==========================================================================
7976 FUNCTION WLANTL_STARxConn
7977
7978 DESCRIPTION
7979 Receive in connected state - only EAPOL
7980
7981 DEPENDENCIES
7982 The STA must be registered with TL before this function can be called.
7983
7984 PARAMETERS
7985
7986 IN
7987 pvosGCtx: pointer to the global vos context; a handle to TL's
7988 control block can be extracted from its context
7989 ucSTAId: identifier of the station being processed
7990 vosDataBuff: pointer to the tx/rx vos buffer
7991
7992 RETURN VALUE
7993 The result code associated with performing the operation
7994
7995 VOS_STATUS_E_INVAL: invalid input parameters
7996 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
7997 page fault
7998 VOS_STATUS_SUCCESS: Everything is good :)
7999
8000 SIDE EFFECTS
8001
8002============================================================================*/
8003VOS_STATUS
8004WLANTL_STARxConn
8005(
8006 v_PVOID_t pvosGCtx,
8007 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008008 vos_pkt_t** pvosDataBuff,
8009 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008010)
8011{
8012 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 v_U16_t usEtherType = 0;
8015 v_U16_t usPktLen;
8016 v_U8_t ucMPDUHOffset;
8017 v_U16_t usMPDUDOffset;
8018 v_U16_t usMPDULen;
8019 v_U8_t ucMPDUHLen;
8020 v_U16_t usActualHLen = 0;
8021 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8022 vos_pkt_t* vosDataBuff;
8023 v_PVOID_t aucBDHeader;
8024 v_U8_t ucTid;
8025 WLANTL_RxMetaInfoType wRxMetaInfo;
8026 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8027
8028 /*------------------------------------------------------------------------
8029 Sanity check
8030 ------------------------------------------------------------------------*/
8031 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8032 {
8033 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8034 "WLAN TL:Invalid parameter sent on WLANTL_STARxConn"));
8035 return VOS_STATUS_E_INVAL;
8036 }
8037
8038 /*------------------------------------------------------------------------
8039 Extract TL control block
8040 ------------------------------------------------------------------------*/
8041 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8042 if ( NULL == pTLCb )
8043 {
8044 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8045 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ChangeSTAState"));
8046 return VOS_STATUS_E_FAULT;
8047 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308048 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8049
8050 if ( NULL == pClientSTA )
8051 {
8052 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8053 "WLAN TL:Client Memory was not allocated on %s", __func__));
8054 return VOS_STATUS_E_FAILURE;
8055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008056
8057 /*------------------------------------------------------------------------
8058 Extract BD header and check if valid
8059 ------------------------------------------------------------------------*/
8060 vosStatus = WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
8061
8062 if ( NULL == aucBDHeader )
8063 {
8064 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8065 "WLAN TL:Cannot extract BD header"));
8066 VOS_ASSERT( 0 );
8067 return VOS_STATUS_E_FAULT;
8068 }
8069
8070
8071 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8072 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8073 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8074 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8075 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8076
8077 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8078
8079 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8080 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d",
8081 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen));
8082
8083 /*It will cut out the 802.11 header if not used*/
8084 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8085 {
8086 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8087 "WLAN TL:BD header corrupted - dropping packet"));
8088 /* Drop packet */
8089 vos_pkt_return_packet(vosDataBuff);
8090 return VOS_STATUS_SUCCESS;
8091 }
8092
8093 vosStatus = WLANTL_GetEtherType(aucBDHeader,vosDataBuff,ucMPDUHLen,&usEtherType);
8094
8095 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8096 {
8097#ifdef FEATURE_WLAN_WAPI
8098 /* If frame is neither an EAPOL frame nor a WAI frame then we drop the frame*/
8099 /* TODO: Do we need a check to see if we are in WAPI mode? If not is it possible */
8100 /* that we get an EAPOL packet in WAPI mode or vice versa? */
8101 if ( WLANTL_LLC_8021X_TYPE != usEtherType && WLANTL_LLC_WAI_TYPE != usEtherType )
8102 {
Sunil Ravid5406f22013-01-22 00:18:31 -08008103 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008104 "WLAN TL:RX Frame not EAPOL or WAI EtherType %d - dropping", usEtherType );
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 /* Drop packet */
8106 vos_pkt_return_packet(vosDataBuff);
8107 }
8108#else
8109 if ( WLANTL_LLC_8021X_TYPE != usEtherType )
8110 {
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008111 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8112 "WLAN TL:RX Frame not EAPOL EtherType %d - dropping", usEtherType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 /* Drop packet */
8114 vos_pkt_return_packet(vosDataBuff);
8115 }
8116#endif /* FEATURE_WLAN_WAPI */
8117 else /* Frame is an EAPOL frame or a WAI frame*/
8118 {
Katya Nigam42e16e82014-02-04 16:28:55 +05308119 MTRACE(vos_trace(VOS_MODULE_ID_TL,
8120 TRACE_CODE_TL_RX_CONN_EAPOL, ucSTAId, usEtherType ));
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008121
Madan Mohan Koyyalamudid8000342012-11-08 14:55:26 -08008122 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi546e3f52012-10-05 12:17:57 -07008123 "WLAN TL:RX Frame EAPOL EtherType %d - processing", usEtherType);
8124
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308126 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation))
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 {
8128 if (usMPDUDOffset > ucMPDUHOffset)
8129 {
8130 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8131 }
8132
8133 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008134 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008135
8136 if ( VOS_STATUS_SUCCESS != vosStatus )
8137 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308138 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8140 /* Drop packet */
8141 vos_pkt_return_packet(vosDataBuff);
8142 return vosStatus;
8143 }
8144 }
8145 /*-------------------------------------------------------------------
8146 Increment receive counter
8147 -------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008148 if ( !WLANTL_TID_INVALID( ucTid) )
8149 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308150 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008151 }
8152 else
8153 {
8154 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8155 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8156 ucTid, ucSTAId, __func__));
8157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008158
8159 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8160 "WLAN TL:Sending EAPoL frame to station %d AC %d", ucSTAId, ucTid));
8161
8162 /*-------------------------------------------------------------------
8163 !!!Assuming TID = UP mapping
8164 -------------------------------------------------------------------*/
8165 wRxMetaInfo.ucUP = ucTid;
8166
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008168 "WLAN TL %s:Sending data chain to station", __func__));
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308169 if ( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 {
8171 wRxMetaInfo.ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308172 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 &wRxMetaInfo );
8174 }
8175 else
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308176 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 &wRxMetaInfo );
8178 }/*EAPOL frame or WAI frame*/
8179 }/*vos status success*/
8180
8181 return VOS_STATUS_SUCCESS;
8182}/* WLANTL_STARxConn */
8183
Jeff Johnson295189b2012-06-20 16:38:30 -07008184/*==========================================================================
8185 FUNCTION WLANTL_FwdPktToHDD
8186
8187 DESCRIPTION
8188 Determine the Destation Station ID and route the Frame to Upper Layer
8189
8190 DEPENDENCIES
8191
8192 PARAMETERS
8193
8194 IN
8195 pvosGCtx: pointer to the global vos context; a handle to TL's
8196 control block can be extracted from its context
8197 ucSTAId: identifier of the station being processed
8198 vosDataBuff: pointer to the rx vos buffer
8199
8200 RETURN VALUE
8201 The result code associated with performing the operation
8202
8203 VOS_STATUS_E_INVAL: invalid input parameters
8204 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8205 page fault
8206 VOS_STATUS_SUCCESS: Everything is good :)
8207
8208 SIDE EFFECTS
8209
8210============================================================================*/
8211
8212VOS_STATUS
8213WLANTL_FwdPktToHDD
8214(
8215 v_PVOID_t pvosGCtx,
8216 vos_pkt_t* pvosDataBuff,
8217 v_U8_t ucSTAId
8218)
8219{
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308220 v_MACADDR_t DestMacAddress;
8221 v_MACADDR_t *pDestMacAddress = &DestMacAddress;
8222 v_SIZE_t usMacAddSize = VOS_MAC_ADDR_SIZE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308224 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 vos_pkt_t* vosDataBuff ;
8226 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308227 v_U32_t* STAMetaInfoPtr;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308228 vos_pkt_t* vosNextDataBuff ;
8229 v_U8_t ucDesSTAId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 WLANTL_RxMetaInfoType wRxMetaInfo;
8231
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 /*------------------------------------------------------------------------
8233 Sanity check
8234 ------------------------------------------------------------------------*/
8235 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = pvosDataBuff )))
8236 {
8237 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8238 "WLAN TL:Invalid parameter sent on WLANTL_FwdPktToHdd"));
8239 return VOS_STATUS_E_INVAL;
8240 }
8241
8242 /*------------------------------------------------------------------------
8243 Extract TL control block
8244 ------------------------------------------------------------------------*/
8245 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8246 if ( NULL == pTLCb )
8247 {
8248 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8249 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_FwdPktToHdd"));
8250 return VOS_STATUS_E_FAULT;
8251 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308252
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008253 if(WLANTL_STA_ID_INVALID(ucSTAId))
8254 {
8255 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"ucSTAId %d is not valid",
8256 ucSTAId));
8257 return VOS_STATUS_E_INVAL;
8258 }
8259
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308260 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8261
8262 if ( NULL == pClientSTA )
8263 {
8264 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8265 "WLAN TL:Client Memory was not allocated on %s", __func__));
8266 return VOS_STATUS_E_FAILURE;
8267 }
8268
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 /* This the change required for SoftAp to handle Reordered Buffer. Since a STA
8270 may have packets destined to multiple destinations we have to process each packet
8271 at a time and determine its Destination. So the Voschain provided by Reorder code
8272 is unchain and forwarded to Upper Layer after Determining the Destination */
8273
8274 vosDataBuff = pvosDataBuff;
8275 while (vosDataBuff != NULL)
8276 {
8277 vos_pkt_walk_packet_chain( vosDataBuff, &vosNextDataBuff, 1/*true*/ );
8278 vos_pkt_get_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
Girish Gowli93e3edd2014-05-01 15:42:31 +05308279 (v_PVOID_t *)&STAMetaInfoPtr );
8280 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
8281 ucDesSTAId = (v_U8_t)(((uintptr_t)STAMetaInfoPtr) >> WLANTL_STAID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -07008282
8283 vosStatus = vos_pkt_extract_data( vosDataBuff, 0, (v_VOID_t *)pDestMacAddress, &usMacAddSize);
8284 if ( VOS_STATUS_SUCCESS != vosStatus )
8285 {
8286 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008287 "WLAN TL: recv corrupted data packet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 vos_pkt_return_packet(vosDataBuff);
8289 return vosStatus;
8290 }
8291
Arif Hussaina7c8e412013-11-20 11:06:42 -08008292 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
8293 "station mac "MAC_ADDRESS_STR,
8294 MAC_ADDR_ARRAY(pDestMacAddress->bytes)));
Jeff Johnson295189b2012-06-20 16:38:30 -07008295
8296 if (vos_is_macaddr_broadcast( pDestMacAddress ) || vos_is_macaddr_group(pDestMacAddress))
8297 {
8298 // destination is mc/bc station
8299 ucDesSTAId = WLAN_RX_BCMC_STA_ID;
8300 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008301 "%s: BC/MC packet, id %d", __func__, WLAN_RX_BCMC_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 }
8303 else
8304 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308305 if (vos_is_macaddr_equal(pDestMacAddress, &pClientSTA->wSTADesc.vSelfMACAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 {
8307 // destination is AP itself
8308 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8309 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008310 "%s: packet to AP itself, id %d", __func__, WLAN_RX_SAP_SELF_STA_ID));
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 }
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05308312 else if (( WLAN_MAX_STA_COUNT <= ucDesSTAId ) || (NULL != pTLCb->atlSTAClients[ucDesSTAId] && pTLCb->atlSTAClients[ucDesSTAId]->ucExists == 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 {
8314 // destination station is something else
8315 TLLOG4(VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO_LOW,
Arif Hussainf2b00992013-11-17 21:46:15 -08008316 "%s: get an station index larger than WLAN_MAX_STA_COUNT %d", __func__, ucDesSTAId));
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 ucDesSTAId = WLAN_RX_SAP_SELF_STA_ID;
8318 }
8319
8320
8321 //loopback unicast station comes here
8322 }
8323
Girish Gowli93e3edd2014-05-01 15:42:31 +05308324 wRxMetaInfo.ucUP = (v_U8_t)((uintptr_t)STAMetaInfoPtr & WLANTL_AC_MASK);
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 wRxMetaInfo.ucDesSTAId = ucDesSTAId;
8326
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308327 vosStatus = pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucDesSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 &wRxMetaInfo );
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308329 if ( VOS_STATUS_SUCCESS != vosStatus )
8330 {
8331 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008332 "WLAN TL: failed to send pkt to HDD"));
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +05308333 vos_pkt_return_packet(vosDataBuff);
8334
8335 return vosStatus;
8336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 vosDataBuff = vosNextDataBuff;
8338 }
8339 return VOS_STATUS_SUCCESS;
8340}
Jeff Johnson295189b2012-06-20 16:38:30 -07008341
8342/*==========================================================================
8343 FUNCTION WLANTL_STARxAuth
8344
8345 DESCRIPTION
8346 Receive in authenticated state - all data allowed
8347
8348 DEPENDENCIES
8349 The STA must be registered with TL before this function can be called.
8350
8351 PARAMETERS
8352
8353 IN
8354 pvosGCtx: pointer to the global vos context; a handle to TL's
8355 control block can be extracted from its context
8356 ucSTAId: identifier of the station being processed
8357 vosDataBuff: pointer to the rx vos buffer
8358
8359 RETURN VALUE
8360 The result code associated with performing the operation
8361
8362 VOS_STATUS_E_INVAL: invalid input parameters
8363 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8364 page fault
8365 VOS_STATUS_SUCCESS: Everything is good :)
8366
8367 SIDE EFFECTS
8368
8369============================================================================*/
8370VOS_STATUS
8371WLANTL_STARxAuth
8372(
8373 v_PVOID_t pvosGCtx,
8374 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008375 vos_pkt_t** pvosDataBuff,
8376 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008377)
8378{
8379 WLANTL_CbType* pTLCb = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308380 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 v_U8_t ucAsf; /* AMSDU sub frame */
8382 v_U16_t usMPDUDOffset;
8383 v_U8_t ucMPDUHOffset;
8384 v_U16_t usMPDULen;
8385 v_U8_t ucMPDUHLen;
8386 v_U16_t usActualHLen = 0;
8387 v_U8_t ucTid;
8388#ifdef FEATURE_WLAN_WAPI
Jeff Johnsone0343db2013-04-03 16:39:24 -07008389 v_U16_t usEtherType = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008390#endif
8391 v_U16_t usPktLen;
8392 vos_pkt_t* vosDataBuff ;
8393 v_PVOID_t aucBDHeader;
8394 VOS_STATUS vosStatus;
8395 WLANTL_RxMetaInfoType wRxMetaInfo;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -07008396 static v_U8_t ucPMPDUHLen;
Girish Gowli93e3edd2014-05-01 15:42:31 +05308397 v_U32_t* STAMetaInfoPtr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 v_U8_t ucEsf=0; /* first subframe of AMSDU flag */
8399 v_U64_t ullcurrentReplayCounter=0; /*current replay counter*/
8400 v_U64_t ullpreviousReplayCounter=0; /*previous replay counter*/
8401 v_U16_t ucUnicastBroadcastType=0; /*It denotes whether received frame is UC or BC*/
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008402 struct _BARFrmStruct *pBarFrame = NULL;
8403
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8405
8406 /*------------------------------------------------------------------------
8407 Sanity check
8408 ------------------------------------------------------------------------*/
8409 if (( NULL == pvosDataBuff ) || ( NULL == ( vosDataBuff = *pvosDataBuff )))
8410 {
8411 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8412 "WLAN TL:Invalid parameter sent on WLANTL_STARxAuth"));
8413 return VOS_STATUS_E_INVAL;
8414 }
8415
8416 /*------------------------------------------------------------------------
8417 Extract TL control block
8418 ------------------------------------------------------------------------*/
8419 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8420 if ( NULL == pTLCb )
8421 {
8422 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8423 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_STARxAuth"));
8424 return VOS_STATUS_E_FAULT;
8425 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308426 pClientSTA = pTLCb->atlSTAClients[ucSTAId];
8427
8428 if ( NULL == pClientSTA )
8429 {
8430 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8431 "WLAN TL:Client Memory was not allocated on %s", __func__));
8432 return VOS_STATUS_E_FAILURE;
8433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008434
8435 /*------------------------------------------------------------------------
8436 Extract BD header and check if valid
8437 ------------------------------------------------------------------------*/
8438 WDA_DS_PeekRxPacketInfo( vosDataBuff, (v_PVOID_t)&aucBDHeader, 0 );
8439
8440 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
8441 usMPDUDOffset = (v_U16_t)WDA_GET_RX_MPDU_DATA_OFFSET(aucBDHeader);
8442 usMPDULen = (v_U16_t)WDA_GET_RX_MPDU_LEN(aucBDHeader);
8443 ucMPDUHLen = (v_U8_t)WDA_GET_RX_MPDU_HEADER_LEN(aucBDHeader);
8444 ucTid = (v_U8_t)WDA_GET_RX_TID(aucBDHeader);
8445
Madan Mohan Koyyalamudi4fe30172012-10-18 20:13:40 -07008446 /* Fix for a hardware bug.
8447 * H/W does not update the tid field in BD header for BAR frames.
8448 * Fix is to read the tid field from MAC header of BAR frame */
8449 if( (WDA_GET_RX_TYPE(aucBDHeader) == SIR_MAC_CTRL_FRAME) &&
8450 (WDA_GET_RX_SUBTYPE(aucBDHeader) == SIR_MAC_CTRL_BAR))
8451 {
8452 pBarFrame = (struct _BARFrmStruct *)(WDA_GET_RX_MAC_HEADER(aucBDHeader));
8453 ucTid = pBarFrame->barControl.numTID;
8454 }
8455
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 /*Host based replay check is needed for unicast data frames*/
8457 ucUnicastBroadcastType = (v_U16_t)WDA_IS_RX_BCAST(aucBDHeader);
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 if(0 != ucMPDUHLen)
8459 {
8460 ucPMPDUHLen = ucMPDUHLen;
8461 }
8462
8463 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8464 "WLAN TL:BD header processing data: HO %d DO %d Len %d HLen %d"
8465 " Tid %d BD %d",
8466 ucMPDUHOffset, usMPDUDOffset, usMPDULen, ucMPDUHLen, ucTid,
8467 WLANHAL_RX_BD_HEADER_SIZE));
8468
8469 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
8470
8471 if ( VOS_STATUS_SUCCESS != WDA_DS_TrimRxPacketInfo( vosDataBuff ) )
8472 {
8473 if((WDA_GET_RX_ASF(aucBDHeader) && !WDA_GET_RX_ESF(aucBDHeader)))
8474 {
8475 /* AMSDU case, ucMPDUHOffset = 0
8476 * it should be hancdled seperatly */
8477 if(( usMPDUDOffset > ucMPDUHOffset ) &&
8478 ( usMPDULen >= ucMPDUHLen ) && ( usPktLen >= usMPDULen ) &&
8479 ( !WLANTL_TID_INVALID(ucTid) ))
8480 {
8481 ucMPDUHOffset = usMPDUDOffset - WLANTL_MPDU_HEADER_LEN;
8482 }
8483 else
8484 {
8485 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8486 "WLAN TL:BD header corrupted - dropping packet"));
8487 /* Drop packet */
8488 vos_pkt_return_packet(vosDataBuff);
8489 return VOS_STATUS_SUCCESS;
8490 }
8491 }
8492 else
8493 {
8494 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8495 "WLAN TL:BD header corrupted - dropping packet"));
8496 /* Drop packet */
8497 vos_pkt_return_packet(vosDataBuff);
8498 return VOS_STATUS_SUCCESS;
8499 }
8500 }
8501
8502#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308503 if ( pClientSTA->wSTADesc.ucIsWapiSta )
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 {
8505 vosStatus = WLANTL_GetEtherType(aucBDHeader, vosDataBuff, ucMPDUHLen, &usEtherType);
8506 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
8507 {
8508 if ( WLANTL_LLC_WAI_TYPE == usEtherType )
8509 {
8510 if ( !( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader)) )
8511 {
8512 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8513 "WLAN TL:WAI frame was received encrypted - dropping"));
8514 /* Drop packet */
8515 /*Temporary fix added to fix wapi rekey issue*/
8516 //vos_pkt_return_packet(vosDataBuff);
8517 //return vosStatus; //returning success
8518 }
8519 }
8520 else
8521 {
8522 if ( WLANHAL_RX_IS_UNPROTECTED_WPI_FRAME(aucBDHeader) )
8523 {
8524 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8525 "WLAN TL:Non-WAI frame was received unencrypted - dropping"));
8526 /* Drop packet */
8527 vos_pkt_return_packet(vosDataBuff);
8528 return vosStatus; //returning success
8529 }
8530 }
8531 }
8532 else //could not extract EtherType - this should not happen
8533 {
8534 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008535 "WLAN TL:Could not extract EtherType"));
8536 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 return vosStatus; //returning failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 }
8539 }
8540#endif /* FEATURE_WLAN_WAPI */
8541
8542 /*----------------------------------------------------------------------
8543 Increment receive counter
8544 !! not sure this is the best place to increase this - pkt might be
8545 dropped below or delayed in TL's queues
8546 - will leave it here for now
8547 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008548 if ( !WLANTL_TID_INVALID( ucTid) )
8549 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308550 pClientSTA->auRxCount[ucTid]++;
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -07008551 }
8552 else
8553 {
8554 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8555 "WLAN TL:Invalid tid %d (Station ID %d) on %s",
8556 ucTid, ucSTAId, __func__));
8557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008558
8559 /*------------------------------------------------------------------------
8560 Check if AMSDU and send for processing if so
8561 ------------------------------------------------------------------------*/
8562 ucAsf = (v_U8_t)WDA_GET_RX_ASF(aucBDHeader);
8563
8564 if ( 0 != ucAsf )
8565 {
8566 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8567 "WLAN TL:Packet is AMSDU sub frame - sending for completion"));
8568 vosStatus = WLANTL_AMSDUProcess( pvosGCtx, &vosDataBuff, aucBDHeader, ucSTAId,
8569 ucMPDUHLen, usMPDULen );
8570 if(NULL == vosDataBuff)
8571 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008572 //Packet is already freed
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 return VOS_STATUS_SUCCESS;
8574 }
8575 }
8576 /* After AMSDU header handled
8577 * AMSDU frame just same with normal frames */
8578 /*-------------------------------------------------------------------
8579 Translating header if necesary
8580 !! Fix me: rmv comments below
8581 ----------------------------------------------------------------------*/
8582 if (( 0 == WDA_GET_RX_FT_DONE(aucBDHeader) ) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308583 ( 0 != pClientSTA->wSTADesc.ucSwFrameRXXlation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008584 ( WLANTL_IS_DATA_FRAME(WDA_GET_RX_TYPE_SUBTYPE(aucBDHeader)) ))
8585 {
8586 if(0 == ucMPDUHLen)
8587 {
8588 ucMPDUHLen = ucPMPDUHLen;
8589 }
8590 if (usMPDUDOffset > ucMPDUHOffset)
8591 {
8592 usActualHLen = usMPDUDOffset - ucMPDUHOffset;
8593 }
8594 vosStatus = WLANTL_Translate80211To8023Header( vosDataBuff, &vosStatus, usActualHLen,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008595 ucMPDUHLen, pTLCb, ucSTAId, bForwardIAPPwithLLC);
Jeff Johnson295189b2012-06-20 16:38:30 -07008596
8597 if ( VOS_STATUS_SUCCESS != vosStatus )
8598 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +05308599 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 "WLAN TL:Failed to translate from 802.11 to 802.3 - dropping"));
8601 /* Drop packet */
8602 vos_pkt_return_packet(vosDataBuff);
8603 return vosStatus;
8604 }
8605 }
8606 /* Softap requires additional Info such as Destination STAID and Access
8607 Category. Voschain or Buffer returned by BA would be unchain and this
8608 Meta Data would help in routing the packets to appropriate Destination */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308609 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 {
Arun Kumar Khandavalli37cfc222014-01-09 22:32:40 +05308611 STAMetaInfoPtr = (v_U32_t *)(uintptr_t)(ucTid | (WDA_GET_RX_ADDR3_IDX(aucBDHeader) << WLANTL_STAID_OFFSET));
Jeff Johnson295189b2012-06-20 16:38:30 -07008612 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_TL,
8613 (v_PVOID_t)STAMetaInfoPtr);
8614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008615
8616 /*------------------------------------------------------------------------
8617 Check to see if re-ordering session is in place
8618 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308619 if ( 0 != pClientSTA->atlBAReorderInfo[ucTid].ucExists )
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 {
8621 WLANTL_MSDUReorder( pTLCb, &vosDataBuff, aucBDHeader, ucSTAId, ucTid );
8622 }
8623
Jeff Johnson295189b2012-06-20 16:38:30 -07008624if(0 == ucUnicastBroadcastType
8625#ifdef FEATURE_ON_CHIP_REORDERING
8626 && (WLANHAL_IsOnChipReorderingEnabledForTID(pvosGCtx, ucSTAId, ucTid) != TRUE)
8627#endif
8628)
8629{
8630 /* replay check code : check whether replay check is needed or not */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308631 if(VOS_TRUE == pClientSTA->ucIsReplayCheckValid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 {
8633 /* replay check is needed for the station */
8634
8635 /* check whether frame is AMSDU frame */
8636 if ( 0 != ucAsf )
8637 {
8638 /* Since virgo can't send AMSDU frames this leg of the code
8639 was not tested properly, it needs to be tested properly*/
8640 /* Frame is AMSDU frame. As per 802.11n only first
8641 subframe will have replay counter */
8642 ucEsf = WDA_GET_RX_ESF( aucBDHeader );
8643 if( 0 != ucEsf )
8644 {
8645 v_BOOL_t status;
8646 /* Getting 48-bit replay counter from the RX BD */
8647 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8648
8649 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008650 "WLAN TL: AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008651
8652 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308653 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008654
8655 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008656 "WLAN TL: AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008657
8658 /* It is first subframe of AMSDU thus it
8659 conatains replay counter perform the
8660 replay check for this first subframe*/
8661 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8662 if(VOS_FALSE == status)
8663 {
8664 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308665 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 }
8667 else
8668 {
8669 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008670 "WLAN TL: AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008671
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308672 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008674 "WLAN TL: AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308675 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008676
8677 /* Drop the packet */
8678 vos_pkt_return_packet(vosDataBuff);
8679 return VOS_STATUS_SUCCESS;
8680 }
8681 }
8682 }
8683 else
8684 {
8685 v_BOOL_t status;
8686
8687 /* Getting 48-bit replay counter from the RX BD */
8688 ullcurrentReplayCounter = WDA_DS_GetReplayCounter(aucBDHeader);
8689
8690 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008691 "WLAN TL: Non-AMSDU currentReplayCounter [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008692
8693 /* Getting 48-bit previous replay counter from TL control block */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308694 ullpreviousReplayCounter = pClientSTA->ullReplayCounter[ucTid];
Jeff Johnson295189b2012-06-20 16:38:30 -07008695
8696 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Arif Hussainf2b00992013-11-17 21:46:15 -08008697 "WLAN TL: Non-AMSDU previousReplayCounter [0x%llX]",ullpreviousReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008698
8699 /* It is not AMSDU frame so perform
8700 reaply check for each packet, as
8701 each packet contains valid replay counter*/
8702 status = WLANTL_IsReplayPacket( ullcurrentReplayCounter, ullpreviousReplayCounter);
8703 if(VOS_FALSE == status)
8704 {
8705 /* Not a replay paket, update previous replay counter in TL CB */
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308706 pClientSTA->ullReplayCounter[ucTid] = ullcurrentReplayCounter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 }
8708 else
8709 {
8710 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008711 "WLAN TL: Non-AMSDU Drop the replay packet with PN : [0x%llX]",ullcurrentReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008712
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308713 pClientSTA->ulTotalReplayPacketsDetected++;
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -08008715 "WLAN TL: Non-AMSDU total dropped replay packets on STA ID %X is [0x%X]",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308716 ucSTAId, pClientSTA->ulTotalReplayPacketsDetected);
Jeff Johnson295189b2012-06-20 16:38:30 -07008717
8718 /* Repaly packet, drop the packet */
8719 vos_pkt_return_packet(vosDataBuff);
8720 return VOS_STATUS_SUCCESS;
8721 }
8722 }
8723 }
8724}
8725/*It is a broadast packet DPU has already done replay check for
8726 broadcast packets no need to do replay check of these packets*/
Jeff Johnson295189b2012-06-20 16:38:30 -07008727
8728 if ( NULL != vosDataBuff )
8729 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308730 if( WLAN_STA_SOFTAP == pClientSTA->wSTADesc.wSTAType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 {
8732 WLANTL_FwdPktToHDD( pvosGCtx, vosDataBuff, ucSTAId );
8733 }
8734 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 {
8736 wRxMetaInfo.ucUP = ucTid;
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07008737 wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
Gopichand Nakkala4a2fc1a2013-05-17 16:59:39 +05308738#ifdef FEATURE_WLAN_TDLS
8739 if (WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
8740 {
8741 wRxMetaInfo.isStaTdls = TRUE;
8742 }
8743 else
8744 {
8745 wRxMetaInfo.isStaTdls = FALSE;
8746 }
8747#endif
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05308748 pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 &wRxMetaInfo );
8750 }
8751 }/* if not NULL */
8752
8753 return VOS_STATUS_SUCCESS;
8754}/* WLANTL_STARxAuth */
8755
8756
8757/*==========================================================================
8758 FUNCTION WLANTL_STARxDisc
8759
8760 DESCRIPTION
8761 Receive in disconnected state - no data allowed
8762
8763 DEPENDENCIES
8764 The STA must be registered with TL before this function can be called.
8765
8766 PARAMETERS
8767
8768 IN
8769 pvosGCtx: pointer to the global vos context; a handle to TL's
8770 control block can be extracted from its context
8771 ucSTAId: identifier of the station being processed
8772 vosDataBuff: pointer to the rx vos buffer
8773
8774 RETURN VALUE
8775 The result code associated with performing the operation
8776
8777 VOS_STATUS_SUCCESS: Everything is good :)
8778
8779 SIDE EFFECTS
8780
8781============================================================================*/
8782VOS_STATUS
8783WLANTL_STARxDisc
8784(
8785 v_PVOID_t pvosGCtx,
8786 v_U8_t ucSTAId,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008787 vos_pkt_t** pvosDataBuff,
8788 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07008789)
8790{
8791 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8792
8793 /*------------------------------------------------------------------------
8794 Sanity check
8795 ------------------------------------------------------------------------*/
8796 if (( NULL == pvosDataBuff ) || ( NULL == *pvosDataBuff ))
8797 {
8798 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8799 "WLAN TL:Invalid parameter sent on WLANTL_STARxDisc"));
8800 return VOS_STATUS_E_INVAL;
8801 }
8802
8803 /*------------------------------------------------------------------------
8804 Error - drop packet
8805 ------------------------------------------------------------------------*/
8806 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8807 "WLAN TL:Packet should not be received in state disconnected"
8808 " - dropping"));
8809 vos_pkt_return_packet(*pvosDataBuff);
8810 *pvosDataBuff = NULL;
8811
8812 return VOS_STATUS_SUCCESS;
8813}/* WLANTL_STARxDisc */
8814
8815/*==========================================================================
8816 Processing main loops for MAIN and TX threads
8817 ==========================================================================*/
8818
8819/*==========================================================================
8820 FUNCTION WLANTL_McProcessMsg
8821
8822 DESCRIPTION
8823 Called by VOSS when a message was serialized for TL through the
8824 main thread/task.
8825
8826 DEPENDENCIES
8827 The TL must be initialized before this function can be called.
8828
8829 PARAMETERS
8830
8831 IN
8832 pvosGCtx: pointer to the global vos context; a handle to TL's
8833 control block can be extracted from its context
8834 message: type and content of the message
8835
8836
8837 RETURN VALUE
8838 The result code associated with performing the operation
8839
8840 VOS_STATUS_E_INVAL: invalid input parameters
8841 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
8842 page fault
8843 VOS_STATUS_SUCCESS: Everything is good :)
8844
8845 SIDE EFFECTS
8846
8847============================================================================*/
8848VOS_STATUS
8849WLANTL_McProcessMsg
8850(
8851 v_PVOID_t pvosGCtx,
8852 vos_msg_t* message
8853)
8854{
8855 WLANTL_CbType* pTLCb = NULL;
8856 tAddBAInd* ptAddBaInd = NULL;
8857 tDelBAInd* ptDelBaInd = NULL;
8858 tAddBARsp* ptAddBaRsp = NULL;
8859 vos_msg_t vosMessage;
8860 VOS_STATUS vosStatus;
8861 tpFlushACRsp FlushACRspPtr;
8862 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
8863
8864 /*------------------------------------------------------------------------
8865 Sanity check
8866 ------------------------------------------------------------------------*/
8867 if ( NULL == message )
8868 {
8869 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8870 "WLAN TL:Invalid parameter sent on WLANTL_ProcessMainMessage"));
8871 return VOS_STATUS_E_INVAL;
8872 }
8873
8874 /*------------------------------------------------------------------------
8875 Extract TL control block
8876 ------------------------------------------------------------------------*/
8877 pTLCb = VOS_GET_TL_CB(pvosGCtx);
8878 if ( NULL == pTLCb )
8879 {
8880 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8881 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_ProcessMainMessage"));
8882 return VOS_STATUS_E_FAULT;
8883 }
8884
8885 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8886 "WLAN TL:Received message: %d through main flow", message->type));
8887
8888 switch( message->type )
8889 {
8890 case WDA_TL_FLUSH_AC_RSP:
8891 // Extract the message from the message body
8892 FlushACRspPtr = (tpFlushACRsp)(message->bodyptr);
8893 // Make sure the call back function is not null.
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -07008894 if ( NULL == pTLCb->tlBAPClient.pfnFlushOpCompleteCb )
8895 {
8896 VOS_ASSERT(0);
8897 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8898 "WLAN TL:Invalid TL pointer pfnFlushOpCompleteCb"));
8899 return VOS_STATUS_E_FAULT;
8900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008901
8902 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8903 "Received message: Flush complete received by TL"));
8904
8905 // Since we have the response back from HAL, just call the BAP client
8906 // registered call back from TL. There is only 1 possible
8907 // BAP client. So directly reference tlBAPClient
8908 pTLCb->tlBAPClient.pfnFlushOpCompleteCb( pvosGCtx,
8909 FlushACRspPtr->ucSTAId,
8910 FlushACRspPtr->ucTid, FlushACRspPtr->status );
8911
8912 // Free the PAL memory, we are done with it.
8913 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8914 "Flush complete received by TL: Freeing %p", FlushACRspPtr));
8915 vos_mem_free((v_VOID_t *)FlushACRspPtr);
8916 break;
8917
8918 case WDA_HDD_ADDBA_REQ:
8919 ptAddBaInd = (tAddBAInd*)(message->bodyptr);
8920 vosStatus = WLANTL_BaSessionAdd( pvosGCtx,
8921 ptAddBaInd->baSession.baSessionID,
8922 ptAddBaInd->baSession.STAID,
8923 ptAddBaInd->baSession.baTID,
8924 (v_U32_t)ptAddBaInd->baSession.baBufferSize,
8925 ptAddBaInd->baSession.winSize,
8926 ptAddBaInd->baSession.SSN);
8927 ptAddBaRsp = vos_mem_malloc(sizeof(*ptAddBaRsp));
8928
8929 if ( NULL == ptAddBaRsp )
8930 {
8931 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8932 "WLAN TL: fatal failure, cannot allocate BA Rsp structure"));
8933 VOS_ASSERT(0);
8934 return VOS_STATUS_E_NOMEM;
8935 }
8936
8937 if ( VOS_STATUS_SUCCESS == vosStatus )
8938 {
8939 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8940 "WLAN TL: Sending success indication to HAL for ADD BA"));
8941 /*Send success*/
8942 ptAddBaRsp->mesgType = WDA_HDD_ADDBA_RSP;
8943 vosMessage.type = WDA_HDD_ADDBA_RSP;
8944 }
8945 else
8946 {
8947 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
8948 "WLAN TL: Sending failure indication to HAL for ADD BA"));
8949
8950 /*Send failure*/
8951 ptAddBaRsp->mesgType = WDA_BA_FAIL_IND;
8952 vosMessage.type = WDA_BA_FAIL_IND;
8953 }
8954
8955 ptAddBaRsp->mesgLen = sizeof(tAddBARsp);
8956 ptAddBaRsp->baSessionID = ptAddBaInd->baSession.baSessionID;
8957 /* This is default, reply win size has to be handled BA module, FIX THIS */
8958 ptAddBaRsp->replyWinSize = WLANTL_MAX_WINSIZE;
8959 vosMessage.bodyptr = ptAddBaRsp;
8960
8961 vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
8962 WLANTL_McFreeMsg (pvosGCtx, message);
8963 break;
8964 case WDA_DELETEBA_IND:
8965 ptDelBaInd = (tDelBAInd*)(message->bodyptr);
8966 vosStatus = WLANTL_BaSessionDel(pvosGCtx,
8967 ptDelBaInd->staIdx,
8968 ptDelBaInd->baTID);
8969
8970 if ( VOS_STATUS_SUCCESS != vosStatus )
8971 {
8972 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
8973 "WLAN TL: Failed to del BA session STA:%d TID:%d Status :%d",
8974 ptDelBaInd->staIdx,
8975 ptDelBaInd->baTID,
8976 vosStatus));
8977 }
8978 WLANTL_McFreeMsg (pvosGCtx, message);
8979 break;
8980 default:
8981 /*no processing for now*/
8982 break;
8983 }
8984
8985 return VOS_STATUS_SUCCESS;
8986}/* WLANTL_ProcessMainMessage */
8987
8988/*==========================================================================
8989 FUNCTION WLANTL_McFreeMsg
8990
8991 DESCRIPTION
8992 Called by VOSS to free a given TL message on the Main thread when there
8993 are messages pending in the queue when the whole system is been reset.
8994 For now, TL does not allocate any body so this function shout translate
8995 into a NOOP
8996
8997 DEPENDENCIES
8998 The TL must be initialized before this function can be called.
8999
9000 PARAMETERS
9001
9002 IN
9003 pvosGCtx: pointer to the global vos context; a handle to TL's
9004 control block can be extracted from its context
9005 message: type and content of the message
9006
9007
9008 RETURN VALUE
9009 The result code associated with performing the operation
9010
9011 VOS_STATUS_SUCCESS: Everything is good :)
9012
9013 SIDE EFFECTS
9014
9015============================================================================*/
9016VOS_STATUS
9017WLANTL_McFreeMsg
9018(
9019 v_PVOID_t pvosGCtx,
9020 vos_msg_t* message
9021)
9022{
9023 WLANTL_CbType* pTLCb = NULL;
9024 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9025
9026 /*------------------------------------------------------------------------
9027 Sanity check
9028 ------------------------------------------------------------------------*/
9029 if ( NULL == message )
9030 {
9031 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9032 "WLAN TL:Invalid parameter sent on WLANTL_McFreeMsg"));
9033 return VOS_STATUS_E_INVAL;
9034 }
9035
9036 /*------------------------------------------------------------------------
9037 Extract TL control block
9038 ------------------------------------------------------------------------*/
9039 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9040 if ( NULL == pTLCb )
9041 {
9042 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9043 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_McFreeMsg"));
9044 return VOS_STATUS_E_FAULT;
9045 }
9046
9047 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9048 "WLAN TL:Received message: %d through main free", message->type));
9049
9050 switch( message->type )
9051 {
9052 case WDA_HDD_ADDBA_REQ:
9053 case WDA_DELETEBA_IND:
9054 /*vos free body pointer*/
9055 vos_mem_free(message->bodyptr);
9056 message->bodyptr = NULL;
9057 break;
9058 default:
9059 /*no processing for now*/
9060 break;
9061 }
9062
9063 return VOS_STATUS_SUCCESS;
9064}/*WLANTL_McFreeMsg*/
9065
9066/*==========================================================================
9067 FUNCTION WLANTL_TxProcessMsg
9068
9069 DESCRIPTION
9070 Called by VOSS when a message was serialized for TL through the
9071 tx thread/task.
9072
9073 DEPENDENCIES
9074 The TL must be initialized before this function can be called.
9075
9076 PARAMETERS
9077
9078 IN
9079 pvosGCtx: pointer to the global vos context; a handle to TL's
9080 control block can be extracted from its context
9081 message: type and content of the message
9082
9083
9084 RETURN VALUE
9085 The result code associated with performing the operation
9086
9087 VOS_STATUS_E_INVAL: invalid input parameters
9088 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9089 page fault
9090 VOS_STATUS_SUCCESS: Everything is good :)
9091
9092 Other values can be returned as a result of a function call, please check
9093 corresponding API for more info.
9094 SIDE EFFECTS
9095
9096============================================================================*/
9097VOS_STATUS
9098WLANTL_TxProcessMsg
9099(
9100 v_PVOID_t pvosGCtx,
9101 vos_msg_t* message
9102)
9103{
9104 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009105 void (*callbackRoutine) (void *callbackContext);
9106 void *callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9108
9109 /*------------------------------------------------------------------------
9110 Sanity check
9111 ------------------------------------------------------------------------*/
9112 if ( NULL == message )
9113 {
9114 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9115 "WLAN TL:Invalid parameter sent on WLANTL_ProcessTxMessage"));
9116 return VOS_STATUS_E_INVAL;
9117 }
9118
9119 /*------------------------------------------------------------------------
9120 Process message
9121 ------------------------------------------------------------------------*/
9122 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9123 "WLAN TL:Received message: %d through tx flow", message->type));
9124
9125 switch( message->type )
9126 {
9127 case WLANTL_TX_SIG_SUSPEND:
9128 vosStatus = WLANTL_SuspendCB( pvosGCtx,
9129 (WLANTL_SuspendCBType)message->bodyptr,
9130 message->reserved);
9131 break;
9132 case WLANTL_TX_RES_NEEDED:
9133 vosStatus = WLANTL_GetTxResourcesCB( pvosGCtx );
9134 break;
Katya Nigam664f5032014-05-05 12:24:32 +05309135
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 case WDA_DS_TX_START_XMIT:
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309137 WLANTL_ClearTxXmitPending(pvosGCtx);
9138 vosStatus = WDA_DS_TxFrames( pvosGCtx );
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 break;
9140
9141 case WDA_DS_FINISH_ULA:
Arun Kumar Khandavalli8d1979d2014-01-09 21:12:25 +05309142 callbackContext = message->bodyptr;
9143 callbackRoutine = message->callback;
9144 if ( NULL != callbackRoutine )
9145 {
9146 callbackRoutine(callbackContext);
9147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009149
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309150 case WLANTL_TX_SNAPSHOT:
9151 /*Dumping TL State and then continuing to print
9152 the DXE Dump*/
9153 WLANTL_TxThreadDebugHandler(pvosGCtx);
9154 WDA_TransportChannelDebug(NULL, VOS_TRUE, VOS_FALSE);
9155 break;
9156
Mihir Shetefd62d9d2014-08-06 15:08:21 +05309157 case WLANTL_TX_FATAL_ERROR:
9158 WLANTL_FatalErrorHandler(pvosGCtx);
9159 break;
9160
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 default:
9162 /*no processing for now*/
9163 break;
9164 }
9165
9166 return vosStatus;
9167}/* WLANTL_TxProcessMsg */
9168
9169/*==========================================================================
9170 FUNCTION WLANTL_McFreeMsg
9171
9172 DESCRIPTION
9173 Called by VOSS to free a given TL message on the Main thread when there
9174 are messages pending in the queue when the whole system is been reset.
9175 For now, TL does not allocate any body so this function shout translate
9176 into a NOOP
9177
9178 DEPENDENCIES
9179 The TL must be initialized before this function can be called.
9180
9181 PARAMETERS
9182
9183 IN
9184 pvosGCtx: pointer to the global vos context; a handle to TL's
9185 control block can be extracted from its context
9186 message: type and content of the message
9187
9188
9189 RETURN VALUE
9190 The result code associated with performing the operation
9191
9192 VOS_STATUS_SUCCESS: Everything is good :)
9193
9194 SIDE EFFECTS
9195
9196============================================================================*/
9197VOS_STATUS
9198WLANTL_TxFreeMsg
9199(
9200 v_PVOID_t pvosGCtx,
9201 vos_msg_t* message
9202)
9203{
9204 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9205
9206 /*Nothing to do for now!!!*/
9207 return VOS_STATUS_SUCCESS;
9208}/*WLANTL_TxFreeMsg*/
9209
Jeff Johnson295189b2012-06-20 16:38:30 -07009210/*==========================================================================
9211
9212 FUNCTION WLANTL_TxFCFrame
9213
9214 DESCRIPTION
9215 Internal utility function to send FC frame. Enable
9216 or disable LWM mode based on the information.
9217
9218 DEPENDENCIES
9219 TL must be initiailized before this function gets called.
9220 FW sends up special flow control frame.
9221
9222 PARAMETERS
9223
9224 IN
9225 pvosGCtx: pointer to the global vos context; a handle to TL's
9226 control block can be extracted from its context
9227
9228 RETURN VALUE
9229 The result code associated with performing the operation
9230
9231 VOS_STATUS_E_INVAL: Input pointers are NULL.
9232 VOS_STATUS_E_FAULT: Something is wrong.
9233 VOS_STATUS_SUCCESS: Everything is good.
9234
9235 SIDE EFFECTS
9236 Newly formed FC frame is generated and waits to be transmitted. Previously unsent frame will
9237 be released.
9238
9239============================================================================*/
9240VOS_STATUS
9241WLANTL_TxFCFrame
9242(
9243 v_PVOID_t pvosGCtx
9244)
9245{
9246#if 0
9247 WLANTL_CbType* pTLCb = NULL;
9248 VOS_STATUS vosStatus;
9249 tpHalFcTxBd pvFcTxBd = NULL;
9250 vos_pkt_t * pPacket = NULL;
9251 v_U8_t ucSTAId = 0;
9252 v_U8_t ucBitCheck = 1;
9253
9254 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009255 "WLAN TL: Send FC frame %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009256
9257 /*------------------------------------------------------------------------
9258 Sanity check
9259 ------------------------------------------------------------------------*/
9260 if ( NULL == pvosGCtx )
9261 {
9262 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009263 "WLAN TL:Invalid parameter %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 return VOS_STATUS_E_INVAL;
9265 }
9266 /*------------------------------------------------------------------------
9267 Extract TL control block
9268 ------------------------------------------------------------------------*/
9269 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9270
9271 if (NULL == pTLCb)
9272 {
9273 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009274 "WLAN TL:Invalid pointer in %s \n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 return VOS_STATUS_E_INVAL;
9276 }
9277
9278 //Get one voss packet
9279 vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, sizeof(tHalFcTxBd), 1,
9280 VOS_FALSE, NULL, NULL );
9281
9282 if ( VOS_STATUS_SUCCESS != vosStatus )
9283 {
9284 return VOS_STATUS_E_INVAL;
9285 }
9286
9287 vosStatus = vos_pkt_reserve_head( pPacket, (void *)&pvFcTxBd, sizeof(tHalFcTxBd));
9288
9289 if( VOS_STATUS_SUCCESS != vosStatus )
9290 {
9291 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009292 "%s: failed to reserve FC TX BD %d\n",__func__, sizeof(tHalFcTxBd)));
Jeff Johnson295189b2012-06-20 16:38:30 -07009293 vos_pkt_return_packet( pPacket );
9294 return VOS_STATUS_E_FAULT;
9295 }
9296
9297 //Generate most recent tlFCInfo. Most fields are correct.
9298 pTLCb->tlFCInfo.fcSTAThreshEnabledMask = 0;
9299 pTLCb->tlFCInfo.fcSTATxMoreDataMask = 0;
9300 for( ucSTAId = 0, ucBitCheck = 1 ; ucSTAId < WLAN_MAX_STA_COUNT; ucBitCheck <<= 1, ucSTAId ++)
9301 {
9302 if (0 == pTLCb->atlSTAClients[ucSTAId].ucExists)
9303 {
9304 continue;
9305 }
9306
9307 if (pTLCb->atlSTAClients[ucSTAId].ucPktPending)
9308 {
9309 pTLCb->tlFCInfo.fcSTATxMoreDataMask |= ucBitCheck;
9310 }
9311
9312 if ( (pTLCb->atlSTAClients[ucSTAId].ucLwmModeEnabled) &&
9313 (pTLCb->atlSTAClients[ucSTAId].bmuMemConsumed > pTLCb->atlSTAClients[ucSTAId].uLwmThreshold))
9314 {
9315 pTLCb->tlFCInfo.fcSTAThreshEnabledMask |= ucBitCheck;
9316
9317 pTLCb->tlFCInfo.fcSTAThresh[ucSTAId] = (tANI_U8)pTLCb->atlSTAClients[ucSTAId].uLwmThreshold;
9318
9319 pTLCb->atlSTAClients[ucSTAId].ucLwmEventReported = FALSE;
9320 }
9321
9322 }
9323
9324 //request immediate feedback
9325 pTLCb->tlFCInfo.fcConfig |= 0x4;
9326
9327 //fill in BD to sent
9328 vosStatus = WLANHAL_FillFcTxBd(pvosGCtx, &pTLCb->tlFCInfo, (void *)pvFcTxBd);
9329
9330 if( VOS_STATUS_SUCCESS != vosStatus )
9331 {
9332 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009333 "%s: Fill FC TX BD unsuccessful\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 vos_pkt_return_packet( pPacket );
9335 return VOS_STATUS_E_FAULT;
9336 }
9337
9338 if (NULL != pTLCb->vosTxFCBuf)
9339 {
9340 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009341 "%s: Previous FC TX BD not sent\n", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 vos_pkt_return_packet(pTLCb->vosTxFCBuf);
9343 }
9344
9345 pTLCb->vosTxFCBuf = pPacket;
9346
9347 vos_pkt_set_user_data_ptr( pPacket, VOS_PKT_USER_DATA_ID_TL,
9348 (v_PVOID_t)WLANTL_TxCompDefaultCb);
9349 vosStatus = WDA_DS_StartXmit(pvosGCtx);
9350
9351 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009352 "WLAN TL: send FC frame leave %s", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -07009353#endif
9354 return VOS_STATUS_SUCCESS;
9355}
9356
Jeff Johnson295189b2012-06-20 16:38:30 -07009357
9358/*==========================================================================
9359 FUNCTION WLANTL_GetTxResourcesCB
9360
9361 DESCRIPTION
9362 Processing function for Resource needed signal. A request will be issued
9363 to BAL to get more tx resources.
9364
9365 DEPENDENCIES
9366 The TL must be initialized before this function can be called.
9367
9368 PARAMETERS
9369
9370 IN
9371 pvosGCtx: pointer to the global vos context; a handle to TL's
9372 control block can be extracted from its context
9373
9374
9375 RETURN VALUE
9376 The result code associated with performing the operation
9377
9378 VOS_STATUS_E_FAULT: pointer to TL cb is NULL ; access would cause a
9379 page fault
9380 VOS_STATUS_SUCCESS: Everything is good :)
9381
9382 Other values can be returned as a result of a function call, please check
9383 corresponding API for more info.
9384 SIDE EFFECTS
9385
9386============================================================================*/
9387VOS_STATUS
9388WLANTL_GetTxResourcesCB
9389(
9390 v_PVOID_t pvosGCtx
9391)
9392{
9393 WLANTL_CbType* pTLCb = NULL;
9394 v_U32_t uResCount = WDA_TLI_MIN_RES_DATA;
9395 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
9396 v_U8_t ucMgmt = 0;
9397 v_U8_t ucBAP = 0;
9398 v_U8_t ucData = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009399#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9400 tBssSystemRole systemRole;
9401 tpAniSirGlobal pMac;
9402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9404 /*------------------------------------------------------------------------
9405 Extract TL control block
9406 ------------------------------------------------------------------------*/
9407 pTLCb = VOS_GET_TL_CB(pvosGCtx);
9408 if ( NULL == pTLCb )
9409 {
9410 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9411 "WLAN TL:Invalid TL pointer from pvosGCtx on"
9412 " WLANTL_ProcessTxMessage"));
9413 return VOS_STATUS_E_FAULT;
9414 }
9415
9416 /*------------------------------------------------------------------------
9417 Get tx resources from BAL
9418 ------------------------------------------------------------------------*/
9419 vosStatus = WDA_DS_GetTxResources( pvosGCtx, &uResCount );
9420
9421 if ( (VOS_STATUS_SUCCESS != vosStatus) && (VOS_STATUS_E_RESOURCES != vosStatus))
9422 {
9423 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9424 "WLAN TL:TL failed to get resources from BAL, Err: %d",
9425 vosStatus));
9426 return vosStatus;
9427 }
9428
9429 /* Currently only Linux BAL returns the E_RESOURCES error code when it is running
9430 out of BD/PDUs. To make use of this interrupt for throughput enhancement, similar
9431 changes should be done in BAL code of AMSS and WM */
9432 if (VOS_STATUS_E_RESOURCES == vosStatus)
9433 {
9434#ifdef VOLANS_PERF
9435 WLANHAL_EnableIdleBdPduInterrupt(pvosGCtx, (tANI_U8)bdPduInterruptGetThreshold);
9436 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9437 "WLAN TL: Enabling Idle BD/PDU interrupt, Current resources = %d", uResCount);
9438#else
9439 return VOS_STATUS_E_FAILURE;
9440#endif
9441 }
9442
9443 pTLCb->uResCount = uResCount;
9444
9445
Jeff Johnson295189b2012-06-20 16:38:30 -07009446#ifdef WLAN_SOFTAP_FLOWCTRL_EN
9447 /* FIXME: disabled since creating issues in power-save, needs to be addressed */
9448 pTLCb->sendFCFrame ++;
9449 pMac = vos_get_context(VOS_MODULE_ID_WDA, pvosGCtx);
9450 systemRole = wdaGetGlobalSystemRole(pMac);
9451 if (eSYSTEM_AP_ROLE == systemRole)
9452 {
9453 if (pTLCb->sendFCFrame % 16 == 0)
9454 {
9455 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9456 "Transmit FC"));
9457 WLANTL_TxFCFrame (pvosGCtx);
9458 }
9459 }
9460#endif //WLAN_SOFTAP_FLOWCTRL_EN
Jeff Johnson295189b2012-06-20 16:38:30 -07009461
9462 ucData = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_DATA );
9463 ucBAP = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_BAP ) &&
9464 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff );
9465 ucMgmt = ( pTLCb->uResCount >= WDA_TLI_MIN_RES_MF ) &&
9466 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff );
9467
9468 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9469 "WLAN TL: Eval Resume tx Res: %d DATA: %d BAP: %d MGMT: %d",
9470 pTLCb->uResCount, ucData, ucBAP, ucMgmt));
9471
9472 if (( 0 == pTLCb->ucTxSuspended ) &&
9473 (( 0 != ucData ) || ( 0 != ucMgmt ) || ( 0 != ucBAP ) ) )
9474 {
9475 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9476 "Issuing Xmit start request to BAL for avail res SYNC"));
9477 vosStatus =WDA_DS_StartXmit(pvosGCtx);
9478 }
9479 return vosStatus;
9480}/*WLANTL_GetTxResourcesCB*/
9481
9482/*==========================================================================
9483 Utility functions
9484 ==========================================================================*/
9485
9486/*==========================================================================
9487 FUNCTION WLANTL_Translate8023To80211Header
9488
9489 DESCRIPTION
9490 Inline function for translating and 802.11 header into an 802.3 header.
9491
9492 DEPENDENCIES
9493
9494
9495 PARAMETERS
9496
9497 IN
9498 pTLCb: TL control block
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009499 IN/OUT
9500 ucStaId: station ID. Incase of TDLS, this returns actual TDLS
9501 station ID used
Jeff Johnson295189b2012-06-20 16:38:30 -07009502
9503 IN/OUT
9504 vosDataBuff: vos data buffer, will contain the new header on output
9505
9506 OUT
9507 pvosStatus: status of the operation
9508
9509 RETURN VALUE
9510
9511 VOS_STATUS_SUCCESS: Everything is good :)
9512
9513 Other error codes might be returned from the vos api used in the function
9514 please check those return values.
9515
9516 SIDE EFFECTS
9517
9518============================================================================*/
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009519VOS_STATUS
9520WLANTL_Translate8023To80211Header
9521(
9522 vos_pkt_t* vosDataBuff,
9523 VOS_STATUS* pvosStatus,
9524 WLANTL_CbType* pTLCb,
9525 v_U8_t *pucStaId,
Ravi Joshid0699502013-07-08 15:48:47 -07009526 WLANTL_MetaInfoType *tlMetaInfo,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009527 v_U8_t *ucWDSEnabled,
9528 v_U8_t *extraHeadSpace
9529)
Jeff Johnson295189b2012-06-20 16:38:30 -07009530{
9531 WLANTL_8023HeaderType w8023Header;
9532 WLANTL_80211HeaderType *pw80211Header; // Allocate an aligned BD and then fill it.
9533 VOS_STATUS vosStatus;
9534 v_U8_t MandatoryucHeaderSize = WLAN80211_MANDATORY_HEADER_SIZE;
9535 v_U8_t ucHeaderSize = 0;
9536 v_VOID_t *ppvBDHeader = NULL;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309537 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 v_U8_t ucQoSOffset = WLAN80211_MANDATORY_HEADER_SIZE;
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009539 v_U8_t ucStaId;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009540#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009541 v_BOOL_t bIAPPTxwithLLC = VOS_FALSE;
9542 v_SIZE_t wIAPPSnapSize = WLANTL_LLC_HEADER_LEN;
9543 v_U8_t wIAPPSnap[WLANTL_LLC_HEADER_LEN] = {0};
9544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 *ucWDSEnabled = 0; // default WDS off.
9546 vosStatus = vos_pkt_pop_head( vosDataBuff, &w8023Header,
9547 sizeof(w8023Header));
9548
9549 if ( VOS_STATUS_SUCCESS != vosStatus )
9550 {
9551 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9552 "WLAN TL: Packet pop header fails on WLANTL_Translate8023To80211Header"));
9553 return vosStatus;
9554 }
9555
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009556 if( NULL == pucStaId )
9557 {
9558 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9559 "WLAN TL: Invalid pointer for StaId"));
9560 return VOS_STATUS_E_INVAL;
9561 }
9562 ucStaId = *pucStaId;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309563 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9564
9565 if ( NULL == pClientSTA )
9566 {
9567 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9568 "WLAN TL:Client Memory was not allocated on %s", __func__));
9569 return VOS_STATUS_E_FAILURE;
9570 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009571
Kiran Venkatappaa044eb92012-12-17 15:48:49 -08009572#ifdef FEATURE_WLAN_TDLS
9573
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309574 if ( WLAN_STA_INFRA == pTLCb->atlSTAClients[ucStaId]->wSTADesc.wSTAType
9575 && pTLCb->ucTdlsPeerCount )
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009576 {
9577 v_U8_t ucIndex = 0;
9578 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
9579 {
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309580 if ( ucIndex != ucStaId && pTLCb->atlSTAClients[ucIndex] && pTLCb->atlSTAClients[ucIndex]->ucExists &&
Gopichand Nakkala471708b2013-06-04 20:03:01 +05309581 (pTLCb->atlSTAClients[ucIndex]->tlState == WLANTL_STA_AUTHENTICATED) &&
9582 (!pTLCb->atlSTAClients[ucIndex]->ucTxSuspended) &&
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309583 vos_mem_compare( (void*)pTLCb->atlSTAClients[ucIndex]->wSTADesc.vSTAMACAddress.bytes,
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009584 (void*)w8023Header.vDA, 6) )
9585 {
9586 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
9587 "WLAN TL: Got a TDLS station. Using that index"));
9588 ucStaId = ucIndex;
9589 *pucStaId = ucStaId;
Madan Mohan Koyylamudi64258222013-01-30 14:35:10 +05309590 pClientSTA = pTLCb->atlSTAClients[ucStaId];
9591 if ( NULL == pClientSTA )
9592 {
9593 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9594 "WLAN TL:Client Memory was not allocated on %s", __func__));
9595 return VOS_STATUS_E_FAILURE;
9596 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009597 break;
9598 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009599 }
Kiran Venkatappacab0d352012-12-17 13:09:22 -08009600 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009601#endif
9602
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009603#ifdef FEATURE_WLAN_ESE_UPLOAD
9604if ((0 == w8023Header.usLenType) && (pClientSTA->wSTADesc.ucIsEseSta))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009605{
9606 vos_pkt_extract_data(vosDataBuff,0,&wIAPPSnap[0],&wIAPPSnapSize);
9607 if (vos_mem_compare(wIAPPSnap,WLANTL_AIRONET_SNAP_HEADER,WLANTL_LLC_HEADER_LEN))
9608 {
9609 /*The SNAP and the protocol type are already in the data buffer.
9610 They are filled by the application (wpa_supplicant). So, Skip Adding LLC below.*/
9611 bIAPPTxwithLLC = VOS_TRUE;
9612 }
9613 else
9614 {
9615 bIAPPTxwithLLC = VOS_FALSE;
9616 }
9617}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009618#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009619
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009620 if ((0 != pClientSTA->wSTADesc.ucAddRmvLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009621#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009622 && (!bIAPPTxwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009623#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009624 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 {
9626 /* Push the length */
9627 vosStatus = vos_pkt_push_head(vosDataBuff,
9628 &w8023Header.usLenType, sizeof(w8023Header.usLenType));
9629
9630 if ( VOS_STATUS_SUCCESS != vosStatus )
9631 {
9632 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9633 "WLAN TL: Packet push ether type fails on"
9634 " WLANTL_Translate8023To80211Header"));
9635 return vosStatus;
9636 }
9637
9638#ifdef BTAMP_TEST
9639 // The STA side will execute this, a hack to test BTAMP by using the
9640 // infra setup. On real BTAMP this will come from BAP itself.
9641 {
9642 static v_U8_t WLANTL_BT_AMP_LLC_HEADER[] = {0xAA, 0xAA, 0x03, 0x00, 0x19, 0x58 };
9643 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_BT_AMP_LLC_HEADER,
9644 sizeof(WLANTL_BT_AMP_LLC_HEADER));
9645
9646 if ( VOS_STATUS_SUCCESS != vosStatus )
9647 {
9648 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9649 "WLAN TL: Packet push LLC header fails on"
9650 " WLANTL_Translate8023To80211Header"));
9651 return vosStatus;
9652 }
9653 }
9654#else
9655 vosStatus = vos_pkt_push_head(vosDataBuff, WLANTL_LLC_HEADER,
9656 sizeof(WLANTL_LLC_HEADER));
9657
9658 if ( VOS_STATUS_SUCCESS != vosStatus )
9659 {
9660 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9661 "WLAN TL: Packet push LLC header fails on"
9662 " WLANTL_Translate8023To80211Header"));
9663 return vosStatus;
9664 }
9665#endif
9666 }/*If add LLC is enabled*/
9667 else
9668 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009669#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009670 bIAPPTxwithLLC = VOS_FALSE; /*Reset the Flag here to start afresh with the next TX pkt*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009671#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9673 "WLAN TL: STA Client registered to not remove LLC"
9674 " WLANTL_Translate8023To80211Header"));
9675 }
9676
9677#ifdef BTAMP_TEST
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309678 pClientSTA->wSTADesc.wSTAType = WLAN_STA_BT_AMP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009679#endif
9680
9681 // Find the space required for the 802.11 header format
9682 // based on the frame control fields.
9683 ucHeaderSize = MandatoryucHeaderSize;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309684 if (pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 {
9686 ucHeaderSize += sizeof(pw80211Header->usQosCtrl);
9687 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309688 if (pClientSTA->wSTADesc.wSTAType == WLAN_STA_BT_AMP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 {
9690 ucHeaderSize += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 ucQoSOffset += sizeof(pw80211Header->optvA4);
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 }
9693
9694 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9695 " WLANTL_Translate8023To80211Header : Header size = %d ", ucHeaderSize));
9696
9697 vos_pkt_reserve_head( vosDataBuff, &ppvBDHeader, ucHeaderSize );
9698 if ( NULL == ppvBDHeader )
9699 {
9700 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9701 "WLAN TL:VOSS packet corrupted "));
9702 *pvosStatus = VOS_STATUS_E_INVAL;
9703 return *pvosStatus;
9704 }
9705
Jeff Johnson295189b2012-06-20 16:38:30 -07009706
9707 // OK now we have the space. Fill the 80211 header
9708 /* Fill A2 */
9709 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9710 // only clear the required space.
9711 vos_mem_set( pw80211Header, ucHeaderSize, 0 );
9712 vos_mem_copy( pw80211Header->vA2, w8023Header.vSA, VOS_MAC_ADDR_SIZE);
9713
9714
9715#ifdef FEATURE_WLAN_WAPI
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309716 if (( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9717 pClientSTA->ptkInstalled ) && gUcIsWai != 1)
Jeff Johnson295189b2012-06-20 16:38:30 -07009718#else
Gopichand Nakkala8b54e912013-03-11 10:44:21 +05309719 if ( WLANTL_STA_AUTHENTICATED == pClientSTA->tlState ||
9720 pClientSTA->ptkInstalled )
Jeff Johnson295189b2012-06-20 16:38:30 -07009721#endif
9722 {
9723 pw80211Header->wFrmCtrl.wep =
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309724 pClientSTA->wSTADesc.ucProtectedFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 }
9726
9727 pw80211Header->usDurationId = 0;
9728 pw80211Header->usSeqCtrl = 0;
9729
9730 pw80211Header->wFrmCtrl.type = WLANTL_80211_DATA_TYPE;
9731
9732
9733
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309734 if(pClientSTA->wSTADesc.ucQosEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 {
9736 pw80211Header->wFrmCtrl.subType = WLANTL_80211_DATA_QOS_SUBTYPE;
9737
Ravi Joshid0699502013-07-08 15:48:47 -07009738 *((v_U16_t *)((v_U8_t *)ppvBDHeader + ucQoSOffset)) = tlMetaInfo->ucUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009739
9740 }
9741 else
9742 {
9743 pw80211Header->wFrmCtrl.subType = 0;
9744
9745 // NO NO NO - there is not enough memory allocated to write the QOS ctrl
9746 // field, it will overwrite the first 2 bytes of the data packet(LLC header)
9747 // pw80211Header->usQosCtrl = 0;
9748 }
9749
9750
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309751 switch( pClientSTA->wSTADesc.wSTAType )
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 {
Ravi Joshid0699502013-07-08 15:48:47 -07009753 case WLAN_STA_IBSS:
Jeff Johnson295189b2012-06-20 16:38:30 -07009754 pw80211Header->wFrmCtrl.toDS = 0;
9755 pw80211Header->wFrmCtrl.fromDS = 0;
Ravi Joshid0699502013-07-08 15:48:47 -07009756
9757 /*
9758 * If the frame is a multicast frame, then, the Address1
9759 * should be the destination address filled in the packet. Which is
9760 * the multicast address. Otherwise, set it to BSSID
9761 */
9762 if (0 == tlMetaInfo->ucBcast && 1 == tlMetaInfo->ucMcast)
9763 {
9764 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9765 (v_MACADDR_t*)&w8023Header.vDA);
9766 }
9767 else
9768 {
9769 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
9770 &pClientSTA->wSTADesc.vSTAMACAddress);
9771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309773 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 VOS_MAC_ADDR_SIZE);
9775 break;
9776
Ravi Joshid0699502013-07-08 15:48:47 -07009777 case WLAN_STA_BT_AMP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 *ucWDSEnabled = 1; // WDS on.
9779 pw80211Header->wFrmCtrl.toDS = 1;
9780 pw80211Header->wFrmCtrl.fromDS = 1;
9781 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309782 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 vos_mem_copy( pw80211Header->vA2,
Ravi Joshid0699502013-07-08 15:48:47 -07009784 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009785 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309786 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 /* fill the optional A4 header */
9788 vos_mem_copy( pw80211Header->optvA4,
Ravi Joshid0699502013-07-08 15:48:47 -07009789 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009791 "BTAMP CASE NOW ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009792 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 break;
9794
Ravi Joshid0699502013-07-08 15:48:47 -07009795 case WLAN_STA_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 *ucWDSEnabled = 0; // WDS off.
9797 pw80211Header->wFrmCtrl.toDS = 0;
9798 pw80211Header->wFrmCtrl.fromDS = 1;
9799 /*Copy the DA to A1*/
9800 vos_mem_copy( pw80211Header->vA1, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9801 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA2,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309802 &pClientSTA->wSTADesc.vSelfMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 vos_mem_copy( pw80211Header->vA3,
Ravi Joshid0699502013-07-08 15:48:47 -07009804 w8023Header.vSA, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009806 "sw 802 to 80211 softap case ---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009807 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009809#ifdef FEATURE_WLAN_TDLS
Ravi Joshid0699502013-07-08 15:48:47 -07009810 case WLAN_STA_TDLS:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009811 pw80211Header->wFrmCtrl.toDS = 0;
9812 pw80211Header->wFrmCtrl.fromDS = 0;
9813 /*Fix me*/
9814 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309815 &pClientSTA->wSTADesc.vSTAMACAddress);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009816 vos_mem_copy( pw80211Header->vA3,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309817 &pClientSTA->wSTADesc.vBSSIDforIBSS ,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009818 VOS_MAC_ADDR_SIZE);
9819 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009820 ("TL:TDLS CASE NOW ---------staid=%d"), ucStaId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009821 break;
9822#endif
Ravi Joshid0699502013-07-08 15:48:47 -07009823 case WLAN_STA_INFRA:
9824 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 pw80211Header->wFrmCtrl.toDS = 1;
9826 pw80211Header->wFrmCtrl.fromDS = 0;
9827 vos_copy_macaddr( (v_MACADDR_t*)&pw80211Header->vA1,
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +05309828 &pClientSTA->wSTADesc.vSTAMACAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 vos_mem_copy( pw80211Header->vA3, w8023Header.vDA , VOS_MAC_ADDR_SIZE);
9830 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009831 "REGULAR INFRA LINK CASE---------staid=%d",
Ravi Joshid0699502013-07-08 15:48:47 -07009832 ucStaId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 break;
9834 }
9835 // OK now we have the space. Fill the 80211 header
9836 /* Fill A2 */
9837 pw80211Header = (WLANTL_80211HeaderType *)(ppvBDHeader);
9838 return VOS_STATUS_SUCCESS;
9839}/*WLANTL_Translate8023To80211Header*/
9840
9841
9842/*=============================================================================
9843 BEGIN LOG FUNCTION !!! Remove me or clean me
9844=============================================================================*/
Ravi Kumar Vaishnavb7652402013-01-18 19:05:15 -08009845#if 0 //def WLANTL_DEBUG
Jeff Johnson295189b2012-06-20 16:38:30 -07009846
9847#define WLANTL_DEBUG_FRAME_BYTE_PER_LINE 16
9848#define WLANTL_DEBUG_FRAME_BYTE_PER_BYTE 4
9849
9850static v_VOID_t WLANTL_DebugFrame
9851(
9852 v_PVOID_t dataPointer,
9853 v_U32_t dataSize
9854)
9855{
9856 v_U8_t lineBuffer[WLANTL_DEBUG_FRAME_BYTE_PER_LINE];
9857 v_U32_t numLines;
9858 v_U32_t numBytes;
9859 v_U32_t idx;
9860 v_U8_t *linePointer;
9861
9862 numLines = dataSize / WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9863 numBytes = dataSize % WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9864 linePointer = (v_U8_t *)dataPointer;
9865
9866 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:Frame Debug Frame Size %d, Pointer 0x%p", dataSize, dataPointer));
9867 for(idx = 0; idx < numLines; idx++)
9868 {
9869 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9870 memcpy(lineBuffer, linePointer, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9871 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR,
9872 "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",
9873 lineBuffer[0], lineBuffer[1], lineBuffer[2], lineBuffer[3], lineBuffer[4], lineBuffer[5], lineBuffer[6], lineBuffer[7],
9874 lineBuffer[8], lineBuffer[9], lineBuffer[10], lineBuffer[11], lineBuffer[12], lineBuffer[13], lineBuffer[14], lineBuffer[15]));
9875 linePointer += WLANTL_DEBUG_FRAME_BYTE_PER_LINE;
9876 }
9877
9878 if(0 == numBytes)
9879 return;
9880
9881 memset(lineBuffer, 0, WLANTL_DEBUG_FRAME_BYTE_PER_LINE);
9882 memcpy(lineBuffer, linePointer, numBytes);
9883 for(idx = 0; idx < WLANTL_DEBUG_FRAME_BYTE_PER_LINE / WLANTL_DEBUG_FRAME_BYTE_PER_BYTE; idx++)
9884 {
9885 TLLOGE(VOS_TRACE(VOS_MODULE_ID_SAL, VOS_TRACE_LEVEL_ERROR, "WLAN TL:0x%2x 0x%2x 0x%2x 0x%2x",
9886 lineBuffer[idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[1 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE],
9887 lineBuffer[2 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE], lineBuffer[3 + idx * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE]));
9888 if(((idx + 1) * WLANTL_DEBUG_FRAME_BYTE_PER_BYTE) >= numBytes)
9889 break;
9890 }
9891
9892 return;
9893}
9894#endif
9895
9896/*=============================================================================
9897 END LOG FUNCTION
9898=============================================================================*/
9899
9900/*==========================================================================
9901 FUNCTION WLANTL_Translate80211To8023Header
9902
9903 DESCRIPTION
9904 Inline function for translating and 802.11 header into an 802.3 header.
9905
9906 DEPENDENCIES
9907
9908
9909 PARAMETERS
9910
9911 IN
9912 pTLCb: TL control block
9913 ucStaId: station ID
9914 ucHeaderLen: Length of the header from BD
9915 ucActualHLen: Length of header including padding or any other trailers
9916
9917 IN/OUT
9918 vosDataBuff: vos data buffer, will contain the new header on output
9919
9920 OUT
9921 pvosStatus: status of the operation
9922
9923 RETURN VALUE
9924
9925 The result code associated with performing the operation
9926 VOS_STATUS_SUCCESS: Everything is good :)
9927
9928 SIDE EFFECTS
9929
9930============================================================================*/
9931VOS_STATUS
9932WLANTL_Translate80211To8023Header
9933(
9934 vos_pkt_t* vosDataBuff,
9935 VOS_STATUS* pvosStatus,
9936 v_U16_t usActualHLen,
9937 v_U8_t ucHeaderLen,
9938 WLANTL_CbType* pTLCb,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009939 v_U8_t ucSTAId,
9940 v_BOOL_t bForwardIAPPwithLLC
Jeff Johnson295189b2012-06-20 16:38:30 -07009941)
9942{
9943 WLANTL_8023HeaderType w8023Header;
9944 WLANTL_80211HeaderType w80211Header;
9945 v_U8_t aucLLCHeader[WLANTL_LLC_HEADER_LEN];
9946 VOS_STATUS vosStatus;
9947 v_U16_t usDataStartOffset = 0;
9948 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
9949
9950 if ( sizeof(w80211Header) < ucHeaderLen )
9951 {
9952 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
9953 "Warning !: Check the header size for the Rx frame structure=%d received=%dn",
9954 sizeof(w80211Header), ucHeaderLen));
9955 ucHeaderLen = sizeof(w80211Header);
9956 }
9957
9958 // This will take care of headers of all sizes, 3 address, 3 addr QOS,
9959 // WDS non-QOS and WDS QoS etc. We have space for all in the 802.11 header structure.
9960 vosStatus = vos_pkt_pop_head( vosDataBuff, &w80211Header, ucHeaderLen);
9961
9962 if ( VOS_STATUS_SUCCESS != vosStatus )
9963 {
9964 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
9965 "WLAN TL: Failed to pop 80211 header from packet %d",
9966 vosStatus));
9967
9968 return vosStatus;
9969 }
9970
9971 switch ( w80211Header.wFrmCtrl.fromDS )
9972 {
9973 case 0:
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 if ( w80211Header.wFrmCtrl.toDS )
9975 {
9976 //SoftAP AP mode
9977 vos_mem_copy( w8023Header.vDA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
9978 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9979 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -08009980 "WLAN TL SoftAP: 802 3 DA %08x SA %08x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 w8023Header.vDA, w8023Header.vSA));
9982 }
9983 else
9984 {
9985 /* IBSS */
9986 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9987 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 break;
9990 case 1:
9991 if ( w80211Header.wFrmCtrl.toDS )
9992 {
9993 /* BT-AMP case */
9994 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
9995 vos_mem_copy( w8023Header.vSA, w80211Header.vA2, VOS_MAC_ADDR_SIZE);
9996 }
9997 else
9998 { /* Infra */
9999 vos_mem_copy( w8023Header.vDA, w80211Header.vA1, VOS_MAC_ADDR_SIZE);
10000 vos_mem_copy( w8023Header.vSA, w80211Header.vA3, VOS_MAC_ADDR_SIZE);
10001 }
10002 break;
10003 }
10004
10005 if( usActualHLen > ucHeaderLen )
10006 {
10007 usDataStartOffset = usActualHLen - ucHeaderLen;
10008 }
10009
10010 if ( 0 < usDataStartOffset )
10011 {
10012 vosStatus = vos_pkt_trim_head( vosDataBuff, usDataStartOffset );
10013
10014 if ( VOS_STATUS_SUCCESS != vosStatus )
10015 {
10016 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10017 "WLAN TL: Failed to trim header from packet %d",
10018 vosStatus));
10019 return vosStatus;
10020 }
10021 }
10022
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010023 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10024 {
10025 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10026 "WLAN TL:Client Memory was not allocated on %s", __func__));
10027 return VOS_STATUS_E_FAILURE;
10028 }
10029
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010030 if ( 0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucAddRmvLLC
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010031#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010032 && (!bForwardIAPPwithLLC)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010033#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010034 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 {
10036 // Extract the LLC header
10037 vosStatus = vos_pkt_pop_head( vosDataBuff, aucLLCHeader,
10038 WLANTL_LLC_HEADER_LEN);
10039
10040 if ( VOS_STATUS_SUCCESS != vosStatus )
10041 {
Kaushik, Sushante386ee12014-05-01 15:50:52 +053010042 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 "WLAN TL: Failed to pop LLC header from packet %d",
10044 vosStatus));
10045
10046 return vosStatus;
10047 }
10048
10049 //Extract the length
10050 vos_mem_copy(&w8023Header.usLenType,
10051 &aucLLCHeader[WLANTL_LLC_HEADER_LEN - sizeof(w8023Header.usLenType)],
10052 sizeof(w8023Header.usLenType) );
10053 }
10054 else
10055 {
10056 vosStatus = vos_pkt_get_packet_length(vosDataBuff,
10057 &w8023Header.usLenType);
10058
10059 if ( VOS_STATUS_SUCCESS != vosStatus )
10060 {
10061 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10062 "WLAN TL: Failed to get packet length %d",
10063 vosStatus));
10064
10065 return vosStatus;
10066 }
10067
10068 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10069 "WLAN TL: BTAMP len (ethertype) fld = %d",
10070 w8023Header.usLenType));
10071 w8023Header.usLenType = vos_cpu_to_be16(w8023Header.usLenType);
10072 }
10073
10074 vos_pkt_push_head(vosDataBuff, &w8023Header, sizeof(w8023Header));
10075
10076#ifdef BTAMP_TEST
10077 {
10078 // AP side will execute this.
10079 v_U8_t *temp_w8023Header = NULL;
10080 vosStatus = vos_pkt_peek_data( vosDataBuff, 0,
10081 &temp_w8023Header, sizeof(w8023Header) );
10082 }
10083#endif
10084#if 0 /*TL_DEBUG*/
10085 vos_pkt_get_packet_length(vosDataBuff, &usLen);
10086 vos_pkt_pop_head( vosDataBuff, aucData, usLen);
10087
10088 WLANTL_DebugFrame(aucData, usLen);
10089
10090 vos_pkt_push_head(vosDataBuff, aucData, usLen);
10091
10092#endif
10093
10094 *pvosStatus = VOS_STATUS_SUCCESS;
10095
10096 return VOS_STATUS_SUCCESS;
10097}/*WLANTL_Translate80211To8023Header*/
10098
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010099/*==========================================================================
10100 FUNCTION WLANTL_FindFrameTypeBcMcUc
10101
10102 DESCRIPTION
10103 Utility function to find whether received frame is broadcast, multicast
10104 or unicast.
10105
10106 DEPENDENCIES
10107 The STA must be registered with TL before this function can be called.
10108
10109 PARAMETERS
10110
10111 IN
10112 pTLCb: pointer to the TL's control block
10113 ucSTAId: identifier of the station being processed
10114 vosDataBuff: pointer to the vos buffer
10115
10116 IN/OUT
10117 pucBcMcUc: pointer to buffer, will contain frame type on return
10118
10119 RETURN VALUE
10120 The result code associated with performing the operation
10121
10122 VOS_STATUS_E_INVAL: invalid input parameters
10123 VOS_STATUS_E_BADMSG: failed to extract info from data buffer
10124 VOS_STATUS_SUCCESS: success
10125
10126 SIDE EFFECTS
10127 None.
10128============================================================================*/
10129VOS_STATUS
10130WLANTL_FindFrameTypeBcMcUc
10131(
10132 WLANTL_CbType *pTLCb,
10133 v_U8_t ucSTAId,
10134 vos_pkt_t *vosDataBuff,
10135 v_U8_t *pucBcMcUc
10136)
10137{
10138 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
10139 v_PVOID_t aucBDHeader;
10140 v_PVOID_t pvPeekData;
10141 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10142
10143 /*------------------------------------------------------------------------
10144 Sanity check
10145 ------------------------------------------------------------------------*/
10146 if ((NULL == pTLCb) ||
10147 (NULL == vosDataBuff) ||
10148 (NULL == pucBcMcUc))
10149 {
10150 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10151 "WLAN TL:Invalid parameter in WLANTL_FindFrameTypeBcMcUc"));
10152 return VOS_STATUS_E_INVAL;
10153 }
10154
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010155 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
10156 {
10157 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10158 "WLAN TL:Client Memory was not allocated on %s", __func__));
10159 return VOS_STATUS_E_FAILURE;
10160 }
10161
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010162 /*------------------------------------------------------------------------
10163 Extract BD header and check if valid
10164 ------------------------------------------------------------------------*/
10165 vosStatus = WDA_DS_PeekRxPacketInfo(vosDataBuff, (v_PVOID_t)&aucBDHeader, 0/*Swap BD*/ );
10166
10167 if (NULL == aucBDHeader)
10168 {
10169 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10170 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Cannot extract BD header"));
10171 VOS_ASSERT(0);
10172 return VOS_STATUS_E_BADMSG;
10173 }
10174
10175 if ((0 == WDA_GET_RX_FT_DONE(aucBDHeader)) &&
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010176 (0 != pTLCb->atlSTAClients[ucSTAId]->wSTADesc.ucSwFrameRXXlation))
Madan Mohan Koyyalamudia148e1e2012-11-30 14:52:59 -080010177 {
10178 /* Its an 802.11 frame, extract MAC address 1 */
10179 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10180 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.11 frame, peeking Addr1"));
10181 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(1),
10182 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10183 }
10184 else
10185 {
10186 /* Its an 802.3 frame, extract Destination MAC address */
10187 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10188 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - 802.3 frame, peeking DA"));
10189 vosStatus = vos_pkt_peek_data(vosDataBuff, WLANTL_MAC_ADDR_ALIGN(0),
10190 (v_PVOID_t)&pvPeekData, VOS_MAC_ADDR_SIZE);
10191 }
10192
10193 if (VOS_STATUS_SUCCESS != vosStatus)
10194 {
10195 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10196 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Failed to peek MAC address"));
10197 return vosStatus;
10198 }
10199
10200 if (((tANI_U8 *)pvPeekData)[0] == 0xff)
10201 {
10202 *pucBcMcUc = WLANTL_FRAME_TYPE_BCAST;
10203 }
10204 else
10205 {
10206 if ((((tANI_U8 *)pvPeekData)[0] & 0x01) == 0x01)
10207 *pucBcMcUc = WLANTL_FRAME_TYPE_MCAST;
10208 else
10209 *pucBcMcUc = WLANTL_FRAME_TYPE_UCAST;
10210 }
10211
10212 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10213 "WLAN TL:WLANTL_FindFrameTypeBcMcUc - Addr1Byte1 is: %x",
10214 ((tANI_U8 *)pvPeekData)[0]));
10215
10216 return VOS_STATUS_SUCCESS;
10217}
10218
Jeff Johnson295189b2012-06-20 16:38:30 -070010219#if 0
10220#ifdef WLAN_PERF
10221/*==========================================================================
10222 FUNCTION WLANTL_FastHwFwdDataFrame
10223
10224 DESCRIPTION
10225 Fast path function to quickly forward a data frame if HAL determines BD
10226 signature computed here matches the signature inside current VOSS packet.
10227 If there is a match, HAL and TL fills in the swapped packet length into
10228 BD header and DxE header, respectively. Otherwise, packet goes back to
10229 normal (slow) path and a new BD signature would be tagged into BD in this
10230 VOSS packet later by the WLANHAL_FillTxBd() function.
10231
10232 DEPENDENCIES
10233
10234 PARAMETERS
10235
10236 IN
10237 pvosGCtx VOS context
10238 vosDataBuff Ptr to VOSS packet
10239 pMetaInfo For getting frame's TID
10240 pStaInfo For checking STA type
10241
10242 OUT
10243 pvosStatus returned status
10244 puFastFwdOK Flag to indicate whether frame could be fast forwarded
10245
10246 RETURN VALUE
10247 No return.
10248
10249 SIDE EFFECTS
10250
10251============================================================================*/
10252static void
10253WLANTL_FastHwFwdDataFrame
10254(
10255 v_PVOID_t pvosGCtx,
10256 vos_pkt_t* vosDataBuff,
10257 VOS_STATUS* pvosStatus,
10258 v_U32_t* puFastFwdOK,
10259 WLANTL_MetaInfoType* pMetaInfo,
10260 WLAN_STADescType* pStaInfo
10261
10262)
10263{
10264 v_PVOID_t pvPeekData;
10265 v_U8_t ucDxEBDWLANHeaderLen = WLANTL_BD_HEADER_LEN(0) + sizeof(WLANBAL_sDXEHeaderType);
10266 v_U8_t ucIsUnicast;
10267 WLANBAL_sDXEHeaderType *pDxEHeader;
10268 v_PVOID_t pvBDHeader;
10269 v_PVOID_t pucBuffPtr;
10270 v_U16_t usPktLen;
10271
10272 /*-----------------------------------------------------------------------
10273 Extract packet length
10274 -----------------------------------------------------------------------*/
10275
10276 vos_pkt_get_packet_length( vosDataBuff, &usPktLen);
10277
10278 /*-----------------------------------------------------------------------
10279 Extract MAC address
10280 -----------------------------------------------------------------------*/
10281 *pvosStatus = vos_pkt_peek_data( vosDataBuff,
10282 WLANTL_MAC_ADDR_ALIGN(0),
10283 (v_PVOID_t)&pvPeekData,
10284 VOS_MAC_ADDR_SIZE );
10285
10286 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10287 {
10288 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10289 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10290 *pvosStatus));
10291 *pvosStatus = VOS_STATUS_E_INVAL;
10292 return;
10293 }
10294
10295 /*-----------------------------------------------------------------------
10296 Reserve head room for DxE header, BD, and WLAN header
10297 -----------------------------------------------------------------------*/
10298
10299 vos_pkt_reserve_head( vosDataBuff, &pucBuffPtr,
10300 ucDxEBDWLANHeaderLen );
10301 if ( NULL == pucBuffPtr )
10302 {
10303 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10304 "WLAN TL:No enough space in VOSS packet %p for DxE/BD/WLAN header", vosDataBuff));
10305 *pvosStatus = VOS_STATUS_E_INVAL;
10306 return;
10307 }
10308 pDxEHeader = (WLANBAL_sDXEHeaderType *)pucBuffPtr;
10309 pvBDHeader = (v_PVOID_t) &pDxEHeader[1];
10310
10311 /* UMA Tx acceleration is enabled.
10312 * UMA would help convert frames to 802.11, fill partial BD fields and
10313 * construct LLC header. To further accelerate this kind of frames,
10314 * HAL would attempt to reuse the BD descriptor if the BD signature
10315 * matches to the saved BD descriptor.
10316 */
10317 if(pStaInfo->wSTAType == WLAN_STA_IBSS)
10318 ucIsUnicast = !(((tANI_U8 *)pvPeekData)[0] & 0x01);
10319 else
10320 ucIsUnicast = 1;
10321
10322 *puFastFwdOK = (v_U32_t) WLANHAL_TxBdFastFwd(pvosGCtx, pvPeekData, pMetaInfo->ucTID, ucIsUnicast, pvBDHeader, usPktLen );
10323
10324 /* Can't be fast forwarded. Trim the VOS head back to original location. */
10325 if(! *puFastFwdOK){
10326 vos_pkt_trim_head(vosDataBuff, ucDxEBDWLANHeaderLen);
10327 }else{
10328 /* could be fast forwarded. Now notify BAL DxE header filling could be completely skipped
10329 */
10330 v_U32_t uPacketSize = WLANTL_BD_HEADER_LEN(0) + usPktLen;
10331 vos_pkt_set_user_data_ptr( vosDataBuff, VOS_PKT_USER_DATA_ID_BAL,
10332 (v_PVOID_t)uPacketSize);
10333 pDxEHeader->size = SWAP_ENDIAN_UINT32(uPacketSize);
10334 }
10335 *pvosStatus = VOS_STATUS_SUCCESS;
10336 return;
10337}
10338#endif /*WLAN_PERF*/
10339#endif
10340
10341#if 0
10342/*==========================================================================
10343 FUNCTION WLANTL_PrepareBDHeader
10344
10345 DESCRIPTION
10346 Inline function for preparing BD header before HAL processing.
10347
10348 DEPENDENCIES
10349 Just notify HAL that suspend in TL is complete.
10350
10351 PARAMETERS
10352
10353 IN
10354 vosDataBuff: vos data buffer
10355 ucDisableFrmXtl: is frame xtl disabled
10356
10357 OUT
10358 ppvBDHeader: it will contain the BD header
10359 pvDestMacAdddr: it will contain the destination MAC address
10360 pvosStatus: status of the combined processing
10361 pusPktLen: packet len.
10362
10363 RETURN VALUE
10364 No return.
10365
10366 SIDE EFFECTS
10367
10368============================================================================*/
10369void
10370WLANTL_PrepareBDHeader
10371(
10372 vos_pkt_t* vosDataBuff,
10373 v_PVOID_t* ppvBDHeader,
10374 v_MACADDR_t* pvDestMacAdddr,
10375 v_U8_t ucDisableFrmXtl,
10376 VOS_STATUS* pvosStatus,
10377 v_U16_t* pusPktLen,
10378 v_U8_t ucQosEnabled,
10379 v_U8_t ucWDSEnabled,
10380 v_U8_t extraHeadSpace
10381)
10382{
10383 v_U8_t ucHeaderOffset;
10384 v_U8_t ucHeaderLen;
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 v_U8_t ucBDHeaderLen = WLANTL_BD_HEADER_LEN(ucDisableFrmXtl);
10386
10387 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
10388 /*-------------------------------------------------------------------------
10389 Get header pointer from VOSS
10390 !!! make sure reserve head zeros out the memory
10391 -------------------------------------------------------------------------*/
10392 vos_pkt_get_packet_length( vosDataBuff, pusPktLen);
10393
10394 if ( WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl) > *pusPktLen )
10395 {
10396 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10397 "WLAN TL: Length of the packet smaller than expected network"
10398 " header %d", *pusPktLen ));
10399
10400 *pvosStatus = VOS_STATUS_E_INVAL;
10401 return;
10402 }
10403
10404 vos_pkt_reserve_head( vosDataBuff, ppvBDHeader,
10405 ucBDHeaderLen );
10406 if ( NULL == *ppvBDHeader )
10407 {
10408 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10409 "WLAN TL:VOSS packet corrupted on Attach BD header"));
10410 *pvosStatus = VOS_STATUS_E_INVAL;
10411 return;
10412 }
10413
10414 /*-----------------------------------------------------------------------
10415 Extract MAC address
10416 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070010417 {
10418 v_SIZE_t usMacAddrSize = VOS_MAC_ADDR_SIZE;
10419 *pvosStatus = vos_pkt_extract_data( vosDataBuff,
10420 ucBDHeaderLen +
10421 WLANTL_MAC_ADDR_ALIGN(ucDisableFrmXtl),
10422 (v_PVOID_t)pvDestMacAdddr,
10423 &usMacAddrSize );
10424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010425 if ( VOS_STATUS_SUCCESS != *pvosStatus )
10426 {
10427 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10428 "WLAN TL:Failed while attempting to extract MAC Addr %d",
10429 *pvosStatus));
10430 }
10431 else
10432 {
10433 /*---------------------------------------------------------------------
10434 Fill MPDU info fields:
10435 - MPDU data start offset
10436 - MPDU header start offset
10437 - MPDU header length
10438 - MPDU length - this is a 16b field - needs swapping
10439 --------------------------------------------------------------------*/
10440 ucHeaderOffset = ucBDHeaderLen;
10441 ucHeaderLen = WLANTL_MAC_HEADER_LEN(ucDisableFrmXtl);
10442
10443 if ( 0 != ucDisableFrmXtl )
10444 {
10445 if ( 0 != ucQosEnabled )
10446 {
10447 ucHeaderLen += WLANTL_802_11_HEADER_QOS_CTL;
10448 }
10449
10450 // Similar to Qos we need something for WDS format !
10451 if ( ucWDSEnabled != 0 )
10452 {
10453 // If we have frame translation enabled
10454 ucHeaderLen += WLANTL_802_11_HEADER_ADDR4_LEN;
10455 }
10456 if ( extraHeadSpace != 0 )
10457 {
10458 // Decrease the packet length with the extra padding after the header
10459 *pusPktLen = *pusPktLen - extraHeadSpace;
10460 }
10461 }
10462
10463 WLANHAL_TX_BD_SET_MPDU_HEADER_LEN( *ppvBDHeader, ucHeaderLen);
10464 WLANHAL_TX_BD_SET_MPDU_HEADER_OFFSET( *ppvBDHeader, ucHeaderOffset);
10465 WLANHAL_TX_BD_SET_MPDU_DATA_OFFSET( *ppvBDHeader,
10466 ucHeaderOffset + ucHeaderLen + extraHeadSpace);
10467 WLANHAL_TX_BD_SET_MPDU_LEN( *ppvBDHeader, *pusPktLen);
10468
10469 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10470 "WLAN TL: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d",
10471 ucHeaderLen, ucHeaderOffset,
10472 (ucHeaderOffset + ucHeaderLen + extraHeadSpace),
10473 *pusPktLen, extraHeadSpace));
10474 }/* if peek MAC success*/
10475
10476}/* WLANTL_PrepareBDHeader */
10477#endif
10478
Jeff Johnson295189b2012-06-20 16:38:30 -070010479//THIS IS A HACK AND NEEDS TO BE FIXED FOR CONCURRENCY
10480/*==========================================================================
10481 FUNCTION WLAN_TLGetNextTxIds
10482
10483 DESCRIPTION
10484 Gets the next station and next AC in the list that should be served by the TL.
10485
10486 Multiple Station Scheduling and TL queue management.
10487
10488 4 HDD BC/MC data packet queue status is specified as Station 0's status. Weights used
10489 in WFQ algorith are initialized in WLANTL_OPEN and contained in tlConfigInfo field.
10490 Each station has fields of ucPktPending and AC mask to tell whether a AC has traffic
10491 or not.
10492
10493 Stations are served in a round-robin fashion from highest priority to lowest priority.
10494 The number of round-robin times of each prioirty equals to the WFQ weights and differetiates
10495 the traffic of different prioirty. As such, stations can not provide low priority packets if
10496 high priority packets are all served.
10497
10498 DEPENDENCIES
10499
10500 PARAMETERS
10501
10502 IN
10503 pvosGCtx: pointer to the global vos context; a handle to TL's
10504 control block can be extracted from its context
10505
10506 OUT
10507 pucSTAId: Station ID
10508
10509 RETURN VALUE
10510 The result code associated with performing the operation
10511
10512 VOS_STATUS_SUCCESS: Everything is good
10513
10514 SIDE EFFECTS
10515
10516 TL context contains currently served station ID in ucCurrentSTA field, currently served AC
10517 in uCurServedAC field, and unserved weights of current AC in uCurLeftWeight.
10518 When existing from the function, these three fields are changed accordingly.
10519
10520============================================================================*/
10521VOS_STATUS
10522WLAN_TLAPGetNextTxIds
10523(
10524 v_PVOID_t pvosGCtx,
10525 v_U8_t* pucSTAId
10526)
10527{
10528 WLANTL_CbType* pTLCb;
10529 v_U8_t ucACFilter = 1;
10530 v_U8_t ucNextSTA ;
10531 v_BOOL_t isServed = TRUE; //current round has find a packet or not
10532 v_U8_t ucACLoopNum = WLANTL_AC_VO + 1; //number of loop to go
10533 v_U8_t uFlowMask; // TX FlowMask from WDA
10534 uint8 ucACMask;
Gopichand Nakkala96237bc2013-01-04 12:20:29 -080010535 uint8 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 /*------------------------------------------------------------------------
10537 Extract TL control block
10538 ------------------------------------------------------------------------*/
10539 //ENTER();
10540
10541 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10542 if ( NULL == pTLCb )
10543 {
10544 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10545 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLAPGetNextTxIds"));
10546 return VOS_STATUS_E_FAULT;
10547 }
10548
10549 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10550 {
10551 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10552 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10553 return VOS_STATUS_E_FAULT;
10554 }
10555
10556 ucNextSTA = pTLCb->ucCurrentSTA;
10557
10558 ++ucNextSTA;
10559
10560 if ( WLAN_MAX_STA_COUNT <= ucNextSTA )
10561 {
10562 //one round is done.
10563 ucNextSTA = 0;
10564 pTLCb->ucCurLeftWeight--;
10565 isServed = FALSE;
10566 if ( 0 == pTLCb->ucCurLeftWeight )
10567 {
10568 //current prioirty is done
10569 if ( WLANTL_AC_BK == (WLANTL_ACEnumType)pTLCb->uCurServedAC )
10570 {
10571 //end of current VO, VI, BE, BK loop. Reset priority.
10572 pTLCb->uCurServedAC = WLANTL_AC_VO;
10573 }
10574 else
10575 {
10576 pTLCb->uCurServedAC --;
10577 }
10578
10579 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10580
10581 } // (0 == pTLCb->ucCurLeftWeight)
10582 } //( WLAN_MAX_STA_COUNT == ucNextSTA )
10583
10584 //decide how many loops to go. if current loop is partial, do one extra to make sure
10585 //we cover every station
10586 if ((1 == pTLCb->ucCurLeftWeight) && (ucNextSTA != 0))
10587 {
10588 ucACLoopNum ++; // now is 5 loops
10589 }
10590
10591 /* Start with highest priority. ucNextSTA, pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight
10592 all have previous values.*/
10593 for (; ucACLoopNum > 0; ucACLoopNum--)
10594 {
10595
10596 ucACFilter = 1 << pTLCb->uCurServedAC;
10597
10598 // pTLCb->ucCurLeftWeight keeps previous results.
10599 for (; (pTLCb->ucCurLeftWeight > 0) && (uFlowMask & ucACFilter); pTLCb->ucCurLeftWeight-- )
10600 {
10601
10602 for ( ; ucNextSTA < WLAN_MAX_STA_COUNT; ucNextSTA ++ )
10603 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010604 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10605 {
10606 continue;
10607 }
10608 WLAN_TL_AC_ARRAY_2_MASK (pTLCb->atlSTAClients[ucNextSTA], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010609
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010610 if ( (0 == pTLCb->atlSTAClients[ucNextSTA]->ucExists) ||
10611 ((0 == pTLCb->atlSTAClients[ucNextSTA]->ucPktPending) && !(ucACMask)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070010612 (0 == (ucACMask & ucACFilter)) )
10613
10614 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010615 //current station does not exist or have any packet to serve.
10616 continue;
10617 }
10618
10619 if (WLANTL_STA_AUTHENTICATED != pTLCb->atlSTAClients[ucNextSTA]->tlState)
10620 {
10621 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10622 "%s Sta %d not in auth state so skipping it.",
10623 __func__, ucNextSTA));
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 continue;
10625 }
10626
10627 //go to next station if current station can't send due to flow control
10628 //Station is allowed to send when it is not in LWM mode. When station is in LWM mode,
10629 //station is allowed to send only after FW reports FW memory is below threshold and on-fly
10630 //packets are less then allowed value
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010631 if ( (TRUE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmModeEnabled) &&
10632 ((FALSE == pTLCb->atlSTAClients[ucNextSTA]->ucLwmEventReported) ||
10633 (0 < pTLCb->atlSTAClients[ucNextSTA]->uBuffThresholdMax))
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 )
10635 {
10636 continue;
10637 }
10638
10639
10640 // Find a station. Weight is updated already.
10641 *pucSTAId = ucNextSTA;
10642 pTLCb->ucCurrentSTA = ucNextSTA;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010643 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC = pTLCb->uCurServedAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010644
10645 TLLOG4(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_LOW,
10646 " TL serve one station AC: %d W: %d StaId: %d",
10647 pTLCb->uCurServedAC, pTLCb->ucCurLeftWeight, pTLCb->ucCurrentSTA ));
10648
10649 return VOS_STATUS_SUCCESS;
10650 } //STA loop
10651
10652 ucNextSTA = 0;
10653 if ( FALSE == isServed )
10654 {
10655 //current loop finds no packet.no need to repeat for the same priority
10656 break;
10657 }
10658 //current loop is partial loop. go for one more loop.
10659 isServed = FALSE;
10660
10661 } //Weight loop
10662
10663 if (WLANTL_AC_BK == pTLCb->uCurServedAC)
10664 {
10665 pTLCb->uCurServedAC = WLANTL_AC_VO;
10666 }
10667 else
10668 {
10669 pTLCb->uCurServedAC--;
10670 }
10671 pTLCb->ucCurLeftWeight = pTLCb->tlConfigInfo.ucAcWeights[pTLCb->uCurServedAC];
10672
10673 }// AC loop
10674
10675 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussainf2b00992013-11-17 21:46:15 -080010676 " TL can't find one station to serve" ));
Jeff Johnson295189b2012-06-20 16:38:30 -070010677
10678 pTLCb->uCurServedAC = WLANTL_AC_BK;
10679 pTLCb->ucCurLeftWeight = 1;
10680 //invalid number will be captured by caller
10681 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10682
10683 *pucSTAId = pTLCb->ucCurrentSTA;
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 return VOS_STATUS_E_FAULT;
10685}
10686
10687
10688/*==========================================================================
10689 FUNCTION WLAN_TLGetNextTxIds
10690
10691 DESCRIPTION
10692 Gets the next station and next AC in the list
10693
10694 DEPENDENCIES
10695
10696 PARAMETERS
10697
10698 IN
10699 pvosGCtx: pointer to the global vos context; a handle to TL's
10700 control block can be extracted from its context
10701
10702 OUT
10703 pucSTAId: Station ID
10704
10705
10706 RETURN VALUE
10707 The result code associated with performing the operation
10708
10709 VOS_STATUS_SUCCESS: Everything is good :)
10710
10711 SIDE EFFECTS
10712
10713============================================================================*/
10714VOS_STATUS
10715WLAN_TLGetNextTxIds
10716(
10717 v_PVOID_t pvosGCtx,
10718 v_U8_t* pucSTAId
10719)
10720{
10721 WLANTL_CbType* pTLCb;
10722 v_U8_t ucNextAC;
10723 v_U8_t ucNextSTA;
10724 v_U8_t ucCount;
10725 v_U8_t uFlowMask; // TX FlowMask from WDA
10726 v_U8_t ucACMask = 0;
10727 v_U8_t i = 0;
10728
10729 tBssSystemRole systemRole; //RG HACK to be removed
10730 tpAniSirGlobal pMac;
10731
10732 pMac = vos_get_context(VOS_MODULE_ID_PE, pvosGCtx);
10733 if ( NULL == pMac )
10734 {
10735 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010736 "%s: Invalid pMac", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070010737 return VOS_STATUS_E_FAULT;
10738 }
10739
10740 systemRole = wdaGetGlobalSystemRole(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010741
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 /*------------------------------------------------------------------------
10743 Extract TL control block
10744 ------------------------------------------------------------------------*/
10745 pTLCb = VOS_GET_TL_CB(pvosGCtx);
10746 if ( NULL == pTLCb )
10747 {
10748 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10749 "WLAN TL:Invalid TL pointer from pvosGCtx on WLAN_TLGetNextTxIds"));
10750 return VOS_STATUS_E_FAULT;
10751 }
10752
Sunil Ravid5406f22013-01-22 00:18:31 -080010753#ifdef FEATURE_WLAN_TDLS
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053010754 if ((eSYSTEM_AP_ROLE == systemRole) ||
10755 (vos_concurrent_open_sessions_running()) || pTLCb->ucTdlsPeerCount)
Sunil Ravid5406f22013-01-22 00:18:31 -080010756#else
Agarwal Ashishcd86f7b2014-06-16 17:11:58 +053010757 if ((eSYSTEM_AP_ROLE == systemRole) ||
10758 (vos_concurrent_open_sessions_running()))
Sunil Ravid5406f22013-01-22 00:18:31 -080010759#endif
10760 {
10761 return WLAN_TLAPGetNextTxIds(pvosGCtx,pucSTAId);
10762 }
10763
10764
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 if ( VOS_STATUS_SUCCESS != WDA_DS_GetTxFlowMask( pvosGCtx, &uFlowMask ) )
10766 {
10767 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10768 "WLAN TL:Failed to retrieve Flow control mask from WDA"));
10769 return VOS_STATUS_E_FAULT;
10770 }
10771
10772 /*STA id - no priority yet implemented */
10773 /*-----------------------------------------------------------------------
10774 Choose the next STA for tx - for now go in a round robin fashion
10775 through all the stations that have pending packets
10776 -------------------------------------------------------------------------*/
10777 ucNextSTA = pTLCb->ucCurrentSTA;
10778
10779 pTLCb->ucCurrentSTA = WLAN_MAX_STA_COUNT;
10780 for ( ucCount = 0;
10781 ucCount < WLAN_MAX_STA_COUNT;
10782 ucCount++ )
10783 {
10784 ucNextSTA = ( (ucNextSTA+1) >= WLAN_MAX_STA_COUNT )?0:(ucNextSTA+1);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010785 if(NULL == pTLCb->atlSTAClients[ucNextSTA])
10786 {
10787 continue;
10788 }
10789 if (( pTLCb->atlSTAClients[ucNextSTA]->ucExists ) &&
10790 ( pTLCb->atlSTAClients[ucNextSTA]->ucPktPending ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010792 if (WLANTL_STA_AUTHENTICATED == pTLCb->atlSTAClients[ucNextSTA]->tlState)
10793 {
10794 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10795 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10796 pTLCb->ucCurrentSTA = ucNextSTA;
10797 break;
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010798 }
10799 else
10800 {
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -080010801 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10802 "%s Sta %d is not in auth state, skipping this sta.",
10803 __func__, ucNextSTA));
Tushnim Bhattacharyya5dd94562013-03-20 20:15:03 -070010804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010805 }
10806 }
10807
10808 *pucSTAId = pTLCb->ucCurrentSTA;
10809
10810 if ( WLANTL_STA_ID_INVALID( *pucSTAId ) )
10811 {
10812 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10813 "WLAN TL:No station registered with TL at this point"));
10814
10815 return VOS_STATUS_E_FAULT;
10816
10817 }
10818
10819 /*Convert the array to a mask for easier operation*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010820 WLAN_TL_AC_ARRAY_2_MASK( pTLCb->atlSTAClients[*pucSTAId], ucACMask, i);
Jeff Johnson295189b2012-06-20 16:38:30 -070010821
10822 if ( 0 == ucACMask )
10823 {
10824 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10825 "WLAN TL: Mask 0 "
10826 "STA ID: %d on WLAN_TLGetNextTxIds", *pucSTAId));
10827
10828 /*setting STA id to invalid if mask is 0*/
10829 *pucSTAId = WLAN_MAX_STA_COUNT;
10830
10831 return VOS_STATUS_E_FAULT;
10832 }
10833
10834 /*-----------------------------------------------------------------------
10835 AC is updated whenever a packet is fetched from HDD -> the current
10836 weight of such an AC cannot be 0 -> in this case TL is expected to
10837 exit this function at this point during the main Tx loop
10838 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010839 if ( 0 < pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight )
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 {
10841 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10842 "WLAN TL: Maintaining serviced AC to: %d for Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010843 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10844 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010845 return VOS_STATUS_SUCCESS;
10846 }
10847
10848 /*-----------------------------------------------------------------------
10849 Choose highest priority AC - !!! optimize me
10850 -----------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010851 ucNextAC = pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC;
Jeff Johnson295189b2012-06-20 16:38:30 -070010852 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10853 "Next AC: %d", ucNextAC));
10854
10855 while ( 0 != ucACMask )
10856 {
10857 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10858 " AC Mask: %d Next: %d Res : %d",
10859 ucACMask, ( 1 << ucNextAC ), ( ucACMask & ( 1 << ucNextAC ))));
10860
10861 if ( 0 != ( ucACMask & ( 1 << ucNextAC ) & uFlowMask ))
10862 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010863 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC =
Jeff Johnson295189b2012-06-20 16:38:30 -070010864 (WLANTL_ACEnumType)ucNextAC;
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010865 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight =
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 pTLCb->tlConfigInfo.ucAcWeights[ucNextAC];
10867
10868 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10869 "WLAN TL: Switching serviced AC to: %d with Weight: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010870 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC ,
10871 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 break;
10873 }
10874
10875 ucNextAC = ( ucNextAC - 1 ) & WLANTL_MASK_AC;
10876
10877 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10878 "Next AC %d", ucNextAC));
10879
10880 }
10881
10882 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10883 " C AC: %d C W: %d",
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053010884 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentAC,
10885 pTLCb->atlSTAClients[*pucSTAId]->ucCurrentWeight));
Jeff Johnson295189b2012-06-20 16:38:30 -070010886
10887 return VOS_STATUS_SUCCESS;
10888}/* WLAN_TLGetNextTxIds */
10889
Jeff Johnson295189b2012-06-20 16:38:30 -070010890
10891
10892/*==========================================================================
10893 DEFAULT HANDLERS: Registered at initialization with TL
10894 ==========================================================================*/
10895
10896/*==========================================================================
10897
10898 FUNCTION WLANTL_MgmtFrmRxDefaultCb
10899
10900 DESCRIPTION
10901 Default Mgmt Frm rx callback: asserts all the time. If this function gets
10902 called it means there is no registered rx cb pointer for Mgmt Frm.
10903
10904 DEPENDENCIES
10905
10906 PARAMETERS
10907 Not used.
10908
10909 RETURN VALUE
10910
10911 VOS_STATUS_E_FAILURE: Always FAILURE.
10912
10913============================================================================*/
10914VOS_STATUS
10915WLANTL_MgmtFrmRxDefaultCb
10916(
10917 v_PVOID_t pvosGCtx,
10918 v_PVOID_t vosBuff
10919)
10920{
10921 if ( NULL != vosBuff )
10922 {
10923 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10924 "WLAN TL:Fatal failure: No registered Mgmt Frm client on pkt RX"));
10925 /* Drop packet */
10926 vos_pkt_return_packet((vos_pkt_t *)vosBuff);
10927 }
10928
Jeff Johnson295189b2012-06-20 16:38:30 -070010929 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
10930 "WLAN TL: No registered Mgmt Frm client on pkt RX. Load/Unload in progress, Ignore"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010931
10932 return VOS_STATUS_E_FAILURE;
10933}/*WLANTL_MgmtFrmRxDefaultCb*/
10934
10935/*==========================================================================
10936
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053010937 FUNCTION WLANTL_BAPRxDefaultCb
Jeff Johnson295189b2012-06-20 16:38:30 -070010938
10939 DESCRIPTION
10940 Default BAP rx callback: asserts all the time. If this function gets
10941 called it means there is no registered rx cb pointer for BAP.
10942
10943 DEPENDENCIES
10944
10945 PARAMETERS
10946 Not used.
10947
10948 RETURN VALUE
10949
10950 VOS_STATUS_E_FAILURE: Always FAILURE.
10951
10952============================================================================*/
10953VOS_STATUS
10954WLANTL_BAPRxDefaultCb
10955(
10956 v_PVOID_t pvosGCtx,
10957 vos_pkt_t* vosDataBuff,
10958 WLANTL_BAPFrameEnumType frameType
10959)
10960{
10961 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
10962 "WLAN TL:Fatal failure: No registered BAP client on BAP pkt RX"));
10963#ifndef BTAMP_TEST
10964 VOS_ASSERT(0);
10965#endif
10966 return VOS_STATUS_E_FAILURE;
10967}/*WLANTL_MgmtFrmRxDefaultCb*/
10968
10969/*==========================================================================
10970
10971 FUNCTION WLANTL_STARxDefaultCb
10972
10973 DESCRIPTION
10974 Default STA rx callback: asserts all the time. If this function gets
10975 called it means there is no registered rx cb pointer for station.
10976 (Mem corruption most likely, it should never happen)
10977
10978 DEPENDENCIES
10979
10980 PARAMETERS
10981 Not used.
10982
10983 RETURN VALUE
10984
10985 VOS_STATUS_E_FAILURE: Always FAILURE.
10986
10987============================================================================*/
10988VOS_STATUS
10989WLANTL_STARxDefaultCb
10990(
10991 v_PVOID_t pvosGCtx,
10992 vos_pkt_t* vosDataBuff,
10993 v_U8_t ucSTAId,
10994 WLANTL_RxMetaInfoType* pRxMetaInfo
10995)
10996{
10997 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
10998 "WLAN TL: No registered STA client rx cb for STAID: %d dropping pkt",
10999 ucSTAId));
11000 vos_pkt_return_packet(vosDataBuff);
Madan Mohan Koyyalamudi6c2977d2013-09-04 15:42:45 +053011001 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011002}/*WLANTL_MgmtFrmRxDefaultCb*/
11003
11004
11005/*==========================================================================
11006
11007 FUNCTION WLANTL_STAFetchPktDefaultCb
11008
11009 DESCRIPTION
11010 Default fetch callback: asserts all the time. If this function gets
11011 called it means there is no registered fetch cb pointer for station.
11012 (Mem corruption most likely, it should never happen)
11013
11014 DEPENDENCIES
11015
11016 PARAMETERS
11017 Not used.
11018
11019 RETURN VALUE
11020
11021 VOS_STATUS_E_FAILURE: Always FAILURE.
11022
11023============================================================================*/
11024VOS_STATUS
11025WLANTL_STAFetchPktDefaultCb
11026(
11027 v_PVOID_t pvosGCtx,
11028 v_U8_t* pucSTAId,
11029 WLANTL_ACEnumType ucAC,
11030 vos_pkt_t** vosDataBuff,
11031 WLANTL_MetaInfoType* tlMetaInfo
11032)
11033{
11034 TLLOGP(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
11035 "WLAN TL:Fatal failure: No registered STA client on data pkt RX"));
11036 VOS_ASSERT(0);
11037 return VOS_STATUS_E_FAILURE;
11038}/*WLANTL_MgmtFrmRxDefaultCb*/
11039
11040/*==========================================================================
11041
11042 FUNCTION WLANTL_TxCompDefaultCb
11043
11044 DESCRIPTION
11045 Default tx complete handler. It will release the completed pkt to
11046 prevent memory leaks.
11047
11048 PARAMETERS
11049
11050 IN
11051 pvosGCtx: pointer to the global vos context; a handle to
11052 TL/HAL/PE/BAP/HDD control block can be extracted from
11053 its context
11054 vosDataBuff: pointer to the VOSS data buffer that was transmitted
11055 wTxSTAtus: status of the transmission
11056
11057
11058 RETURN VALUE
11059 The result code associated with performing the operation; please
11060 check vos_pkt_return_packet for possible error codes.
11061
11062 Please check vos_pkt_return_packet API for possible return values.
11063
11064============================================================================*/
11065VOS_STATUS
11066WLANTL_TxCompDefaultCb
11067(
11068 v_PVOID_t pvosGCtx,
11069 vos_pkt_t* vosDataBuff,
11070 VOS_STATUS wTxSTAtus
11071)
11072{
11073 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11074 "WLAN TL:TXComp not registered, releasing pkt to prevent mem leak"));
11075 return vos_pkt_return_packet(vosDataBuff);
11076}/*WLANTL_TxCompDefaultCb*/
11077
11078
11079/*==========================================================================
11080 Cleanup functions
11081 ==========================================================================*/
11082
11083/*==========================================================================
11084
11085 FUNCTION WLANTL_CleanCB
11086
11087 DESCRIPTION
11088 Cleans TL control block
11089
11090 DEPENDENCIES
11091
11092 PARAMETERS
11093
11094 IN
11095 pTLCb: pointer to TL's control block
11096 ucEmpty: set if TL has to clean up the queues and release pedning pkts
11097
11098 RETURN VALUE
11099 The result code associated with performing the operation
11100
11101 VOS_STATUS_E_INVAL: invalid input parameters
11102 VOS_STATUS_SUCCESS: Everything is good :)
11103
11104 SIDE EFFECTS
11105
11106============================================================================*/
11107VOS_STATUS
11108WLANTL_CleanCB
11109(
11110 WLANTL_CbType* pTLCb,
11111 v_U8_t ucEmpty
11112)
11113{
11114 v_U8_t ucIndex;
11115 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11116
11117 /*-------------------------------------------------------------------------
11118 Sanity check
11119 -------------------------------------------------------------------------*/
11120 if ( NULL == pTLCb )
11121 {
11122 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11123 "WLAN TL:Invalid parameter sent on WLANTL_CleanCB"));
11124 return VOS_STATUS_E_INVAL;
11125 }
11126
11127 /* number of packets sent to BAL waiting for tx complete confirmation */
11128 pTLCb->usPendingTxCompleteCount = 0;
11129
11130 /* global suspend flag */
11131 vos_atomic_set_U8( &pTLCb->ucTxSuspended, 1);
11132
11133 /* resource flag */
11134 pTLCb->uResCount = 0;
11135
11136
11137 /*-------------------------------------------------------------------------
11138 Client stations
11139 -------------------------------------------------------------------------*/
11140 for ( ucIndex = 0; ucIndex < WLAN_MAX_STA_COUNT ; ucIndex++)
11141 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011142 if(NULL != pTLCb->atlSTAClients[ucIndex])
11143 {
11144 WLANTL_CleanSTA( pTLCb->atlSTAClients[ucIndex], ucEmpty);
11145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 }
11147
11148 /*-------------------------------------------------------------------------
11149 Management Frame client
11150 -------------------------------------------------------------------------*/
11151 pTLCb->tlMgmtFrmClient.ucExists = 0;
11152
11153 if ( ( 0 != ucEmpty) &&
11154 ( NULL != pTLCb->tlMgmtFrmClient.vosPendingDataBuff ))
11155 {
11156 vos_pkt_return_packet(pTLCb->tlMgmtFrmClient.vosPendingDataBuff);
11157 }
11158
11159 pTLCb->tlMgmtFrmClient.vosPendingDataBuff = NULL;
11160
11161 /* set to a default cb in order to prevent constant checking for NULL */
11162 pTLCb->tlMgmtFrmClient.pfnTlMgmtFrmRx = WLANTL_MgmtFrmRxDefaultCb;
11163
11164 /*-------------------------------------------------------------------------
11165 BT AMP client
11166 -------------------------------------------------------------------------*/
11167 pTLCb->tlBAPClient.ucExists = 0;
11168
11169 if (( 0 != ucEmpty) &&
11170 ( NULL != pTLCb->tlBAPClient.vosPendingDataBuff ))
11171 {
11172 vos_pkt_return_packet(pTLCb->tlBAPClient.vosPendingDataBuff);
11173 }
11174
11175 if (( 0 != ucEmpty) &&
11176 ( NULL != pTLCb->vosDummyBuf ))
11177 {
11178 vos_pkt_return_packet(pTLCb->vosDummyBuf);
11179 }
11180
11181 pTLCb->tlBAPClient.vosPendingDataBuff = NULL;
11182
11183 pTLCb->vosDummyBuf = NULL;
11184 pTLCb->vosTempBuf = NULL;
11185 pTLCb->ucCachedSTAId = WLAN_MAX_STA_COUNT;
11186
11187 /* set to a default cb in order to prevent constant checking for NULL */
11188 pTLCb->tlBAPClient.pfnTlBAPRx = WLANTL_BAPRxDefaultCb;
11189
11190 pTLCb->ucRegisteredStaId = WLAN_MAX_STA_COUNT;
11191
11192 return VOS_STATUS_SUCCESS;
11193
11194}/* WLANTL_CleanCB*/
11195
11196/*==========================================================================
11197
11198 FUNCTION WLANTL_CleanSTA
11199
11200 DESCRIPTION
11201 Cleans a station control block.
11202
11203 DEPENDENCIES
11204
11205 PARAMETERS
11206
11207 IN
11208 pvosGCtx: pointer to the global vos context; a handle to TL's
11209 control block can be extracted from its context
11210 ucEmpty: if set the queues and pending pkts will be emptyed
11211
11212 RETURN VALUE
11213 The result code associated with performing the operation
11214
11215 VOS_STATUS_E_INVAL: invalid input parameters
11216 VOS_STATUS_SUCCESS: Everything is good :)
11217
11218 SIDE EFFECTS
11219
11220============================================================================*/
11221VOS_STATUS
11222WLANTL_CleanSTA
11223(
11224 WLANTL_STAClientType* ptlSTAClient,
11225 v_U8_t ucEmpty
11226)
11227{
11228 v_U8_t ucIndex;
11229 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11230
11231 /*-------------------------------------------------------------------------
11232 Sanity check
11233 -------------------------------------------------------------------------*/
11234 if ( NULL == ptlSTAClient )
11235 {
11236 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11237 "WLAN TL:Invalid parameter sent on WLANTL_CleanSTA"));
11238 return VOS_STATUS_E_INVAL;
11239 }
11240
11241 /*------------------------------------------------------------------------
11242 Clear station from TL
11243 ------------------------------------------------------------------------*/
11244 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11245 "WLAN TL: Clearing STA Client ID: %d, Empty flag: %d",
11246 ptlSTAClient->wSTADesc.ucSTAId, ucEmpty ));
11247
11248 ptlSTAClient->pfnSTARx = WLANTL_STARxDefaultCb;
11249 ptlSTAClient->pfnSTATxComp = WLANTL_TxCompDefaultCb;
11250 ptlSTAClient->pfnSTAFetchPkt = WLANTL_STAFetchPktDefaultCb;
11251
11252 ptlSTAClient->tlState = WLANTL_STA_INIT;
11253 ptlSTAClient->tlPri = WLANTL_STA_PRI_NORMAL;
11254
11255 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSTAMACAddress );
11256 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vBSSIDforIBSS );
11257 vos_zero_macaddr( &ptlSTAClient->wSTADesc.vSelfMACAddress );
11258
11259 ptlSTAClient->wSTADesc.ucSTAId = 0;
11260 ptlSTAClient->wSTADesc.wSTAType = WLAN_STA_MAX;
11261
11262 ptlSTAClient->wSTADesc.ucQosEnabled = 0;
11263 ptlSTAClient->wSTADesc.ucAddRmvLLC = 0;
11264 ptlSTAClient->wSTADesc.ucSwFrameTXXlation = 0;
11265 ptlSTAClient->wSTADesc.ucSwFrameRXXlation = 0;
11266 ptlSTAClient->wSTADesc.ucProtectedFrame = 0;
11267
11268 /*-------------------------------------------------------------------------
11269 AMSDU information for the STA
11270 -------------------------------------------------------------------------*/
11271 if ( ( 0 != ucEmpty ) &&
11272 ( NULL != ptlSTAClient->vosAMSDUChainRoot ))
11273 {
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011274 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0298bd02013-11-14 19:58:38 -080011275 "WLAN TL:Non NULL vosAMSDUChainRoot on WLANTL_CleanSTA, "
Madan Mohan Koyyalamudic0e5bd82012-09-18 17:12:27 -070011276 "suspecting a memory corruption"));
11277
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 }
11279
11280 ptlSTAClient->vosAMSDUChain = NULL;
11281 ptlSTAClient->vosAMSDUChainRoot = NULL;
11282
11283 vos_mem_zero( (v_PVOID_t)ptlSTAClient->aucMPDUHeader,
11284 WLANTL_MPDU_HEADER_LEN);
11285 ptlSTAClient->ucMPDUHeaderLen = 0;
11286
11287 /*-------------------------------------------------------------------------
11288 Reordering information for the STA
11289 -------------------------------------------------------------------------*/
11290 for ( ucIndex = 0; ucIndex < WLAN_MAX_TID ; ucIndex++)
11291 {
11292 if(0 == ptlSTAClient->atlBAReorderInfo[ucIndex].ucExists)
11293 {
11294 continue;
11295 }
11296 if(NULL != ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer)
11297 {
11298 ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->isAvailable = VOS_TRUE;
11299 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex].reorderBuffer->arrayBuffer[0], 0, WLANTL_MAX_WINSIZE * sizeof(v_PVOID_t));
11300 }
11301 vos_timer_destroy(&ptlSTAClient->atlBAReorderInfo[ucIndex].agingTimer);
11302 memset(&ptlSTAClient->atlBAReorderInfo[ucIndex], 0, sizeof(WLANTL_BAReorderType));
11303 }
11304
11305 /*-------------------------------------------------------------------------
11306 QOS information for the STA
11307 -------------------------------------------------------------------------*/
11308 ptlSTAClient->ucCurrentAC = WLANTL_AC_VO;
11309 ptlSTAClient->ucCurrentWeight = 0;
11310 ptlSTAClient->ucServicedAC = WLANTL_AC_BK;
11311
11312 vos_mem_zero( ptlSTAClient->aucACMask, sizeof(ptlSTAClient->aucACMask));
11313 vos_mem_zero( &ptlSTAClient->wUAPSDInfo, sizeof(ptlSTAClient->wUAPSDInfo));
11314
11315
11316 /*--------------------------------------------------------------------
11317 Stats info
11318 --------------------------------------------------------------------*/
11319 vos_mem_zero( ptlSTAClient->auRxCount,
11320 sizeof(ptlSTAClient->auRxCount[0])* WLAN_MAX_TID);
11321 vos_mem_zero( ptlSTAClient->auTxCount,
11322 sizeof(ptlSTAClient->auTxCount[0])* WLAN_MAX_TID);
11323 ptlSTAClient->rssiAvg = 0;
11324
11325 /*Tx not suspended and station fully registered*/
11326 vos_atomic_set_U8( &ptlSTAClient->ucTxSuspended, 0);
11327 vos_atomic_set_U8( &ptlSTAClient->ucNoMoreData, 1);
11328
11329 if ( 0 == ucEmpty )
11330 {
11331 ptlSTAClient->wSTADesc.ucUcastSig = WLAN_TL_INVALID_U_SIG;
11332 ptlSTAClient->wSTADesc.ucBcastSig = WLAN_TL_INVALID_B_SIG;
11333 }
11334
11335 ptlSTAClient->ucExists = 0;
11336
11337 /*--------------------------------------------------------------------
11338 Statistics info
11339 --------------------------------------------------------------------*/
11340 memset(&ptlSTAClient->trafficStatistics,
11341 0,
11342 sizeof(WLANTL_TRANSFER_STA_TYPE));
11343
11344 /*fix me!!: add new values from the TL Cb for cleanup */
11345 return VOS_STATUS_SUCCESS;
11346}/* WLANTL_CleanSTA */
11347
11348
11349/*==========================================================================
11350 FUNCTION WLANTL_EnableUAPSDForAC
11351
11352 DESCRIPTION
11353 Called by HDD to enable UAPSD. TL in turn calls WDA API to enable the
11354 logic in FW/SLM to start sending trigger frames. Previously TL had the
11355 trigger frame logic which later moved down to FW. Hence
11356 HDD -> TL -> WDA -> FW call flow.
11357
11358 DEPENDENCIES
11359 The TL must be initialized before this function can be called.
11360
11361 PARAMETERS
11362
11363 IN
11364 pvosGCtx: pointer to the global vos context; a handle to TL's
11365 control block can be extracted from its context
11366 ucSTAId: station Id
11367 ucAC: AC for which U-APSD is being enabled
11368 ucTid: TID for which U-APSD is setup
11369 ucUP: used to place in the trigger frame generation
11370 ucServiceInt: service interval used by TL to send trigger frames
11371 ucSuspendInt: suspend interval used by TL to determine that an
11372 app is idle and should start sending trigg frms less often
11373 wTSDir: direction of TSpec
11374
11375 RETURN VALUE
11376 The result code associated with performing the operation
11377
11378 VOS_STATUS_SUCCESS: Everything is good :)
11379
11380 SIDE EFFECTS
11381
11382============================================================================*/
11383VOS_STATUS
11384WLANTL_EnableUAPSDForAC
11385(
11386 v_PVOID_t pvosGCtx,
11387 v_U8_t ucSTAId,
11388 WLANTL_ACEnumType ucAC,
11389 v_U8_t ucTid,
11390 v_U8_t ucUP,
11391 v_U32_t uServiceInt,
11392 v_U32_t uSuspendInt,
11393 WLANTL_TSDirType wTSDir
11394)
11395{
11396
11397 WLANTL_CbType* pTLCb = NULL;
11398 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
11399 tUapsdInfo halUAPSDInfo;
11400 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11401
11402 /*------------------------------------------------------------------------
11403 Sanity check
11404 Extract TL control block
11405 ------------------------------------------------------------------------*/
11406 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11407 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011408 || WLANTL_AC_INVALID(ucAC))
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 {
11410 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11411 "WLAN TL:Invalid input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053011412 " TL: %p STA: %d AC: %d",
11413 pTLCb, ucSTAId, ucAC));
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 return VOS_STATUS_E_FAULT;
11415 }
11416
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011417 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11418 {
11419 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11420 "WLAN TL:Client Memory was not allocated on %s", __func__));
11421 return VOS_STATUS_E_FAILURE;
11422 }
11423
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 /*Set this flag in order to remember that this is a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011425 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011426
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011427#ifdef FEATURE_WLAN_TDLS
11428 if(pTLCb->atlSTAClients[ucSTAId]->wSTADesc.wSTAType != WLAN_STA_TDLS)
11429#endif
11430 {
11431 if( 0 == uServiceInt )
11432 {
11433 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +053011434 "WLAN TL:Input params on WLANTL_EnableUAPSDForAC"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011435 " SI: %d", uServiceInt ));
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011437
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011438 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11439 "WLAN TL:Enabling U-APSD in FW for STA: %d AC: %d SI: %d SPI: %d "
11440 "DI: %d",
11441 ucSTAId, ucAC, uServiceInt, uSuspendInt,
11442 pTLCb->tlConfigInfo.uDelayedTriggerFrmInt));
Jeff Johnson295189b2012-06-20 16:38:30 -070011443
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053011444 /*Save all info for HAL*/
11445 halUAPSDInfo.staidx = ucSTAId;
11446 halUAPSDInfo.ac = ucAC;
11447 halUAPSDInfo.up = ucUP;
11448 halUAPSDInfo.srvInterval = uServiceInt;
11449 halUAPSDInfo.susInterval = uSuspendInt;
11450 halUAPSDInfo.delayInterval = pTLCb->tlConfigInfo.uDelayedTriggerFrmInt;
11451
11452 /*Notify HAL*/
11453 vosStatus = WDA_EnableUapsdAcParams(pvosGCtx, ucSTAId, &halUAPSDInfo);
11454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 return vosStatus;
11456
11457}/*WLANTL_EnableUAPSDForAC*/
11458
11459
11460/*==========================================================================
11461 FUNCTION WLANTL_DisableUAPSDForAC
11462
11463 DESCRIPTION
11464 Called by HDD to disable UAPSD. TL in turn calls WDA API to disable the
11465 logic in FW/SLM to stop sending trigger frames. Previously TL had the
11466 trigger frame logic which later moved down to FW. Hence
11467 HDD -> TL -> WDA -> FW call flow.
11468
11469 DEPENDENCIES
11470 The TL must be initialized before this function can be called.
11471
11472 PARAMETERS
11473
11474 IN
11475 pvosGCtx: pointer to the global vos context; a handle to TL's
11476 control block can be extracted from its context
11477 ucSTAId: station Id
11478 ucAC: AC for which U-APSD is being enabled
11479
11480
11481 RETURN VALUE
11482 The result code associated with performing the operation
11483
11484 VOS_STATUS_SUCCESS: Everything is good :)
11485
11486 SIDE EFFECTS
11487
11488============================================================================*/
11489VOS_STATUS
11490WLANTL_DisableUAPSDForAC
11491(
11492 v_PVOID_t pvosGCtx,
11493 v_U8_t ucSTAId,
11494 WLANTL_ACEnumType ucAC
11495)
11496{
11497 WLANTL_CbType* pTLCb;
11498 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
11499
11500 /*------------------------------------------------------------------------
11501 Sanity check
11502 Extract TL control block
11503 ------------------------------------------------------------------------*/
11504 pTLCb = VOS_GET_TL_CB(pvosGCtx);
11505 if (( NULL == pTLCb ) || WLANTL_STA_ID_INVALID( ucSTAId )
11506 || WLANTL_AC_INVALID(ucAC) )
11507 {
11508 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11509 "WLAN TL:Invalid input params on WLANTL_DisableUAPSDForAC"
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053011510 " TL: %p STA: %d AC: %d", pTLCb, ucSTAId, ucAC ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 return VOS_STATUS_E_FAULT;
11512 }
11513
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011514 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
11515 {
11516 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11517 "WLAN TL:Client Memory was not allocated on %s", __func__));
11518 return VOS_STATUS_E_FAILURE;
11519 }
11520
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 /*Reset this flag as this is no longer a trigger enabled AC*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011522 pTLCb->atlSTAClients[ucSTAId]->wUAPSDInfo[ucAC].ucSet = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011523
11524 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
11525 "WLAN TL:Disabling U-APSD in FW for STA: %d AC: %d ",
11526 ucSTAId, ucAC));
11527
11528 /*Notify HAL*/
11529 WDA_DisableUapsdAcParams(pvosGCtx, ucSTAId, ucAC);
11530
11531 return VOS_STATUS_SUCCESS;
11532}/* WLANTL_DisableUAPSDForAC */
11533
11534#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
11535/*==========================================================================
11536 FUNCTION WLANTL_RegRSSIIndicationCB
11537
11538 DESCRIPTION Registration function to get notification if RSSI cross
11539 threshold.
11540 Client should register threshold, direction, and notification
11541 callback function pointer
11542
11543 DEPENDENCIES NONE
11544
11545 PARAMETERS in pAdapter - Global handle
11546 in rssiValue - RSSI threshold value
11547 in triggerEvent - Cross direction should be notified
11548 UP, DOWN, and CROSS
11549 in crossCBFunction - Notification CB Function
11550 in usrCtxt - user context
11551
11552 RETURN VALUE VOS_STATUS
11553
11554 SIDE EFFECTS NONE
11555
11556============================================================================*/
11557VOS_STATUS WLANTL_RegRSSIIndicationCB
11558(
11559 v_PVOID_t pAdapter,
11560 v_S7_t rssiValue,
11561 v_U8_t triggerEvent,
11562 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11563 VOS_MODULE_ID moduleID,
11564 v_PVOID_t usrCtxt
11565)
11566{
11567 VOS_STATUS status = VOS_STATUS_SUCCESS;
11568
11569 status = WLANTL_HSRegRSSIIndicationCB(pAdapter,
11570 rssiValue,
11571 triggerEvent,
11572 crossCBFunction,
11573 moduleID,
11574 usrCtxt);
11575
11576 return status;
11577}
11578
11579/*==========================================================================
11580 FUNCTION WLANTL_DeregRSSIIndicationCB
11581
11582 DESCRIPTION Remove specific threshold from list
11583
11584 DEPENDENCIES NONE
11585
11586 PARAMETERS in pAdapter - Global handle
11587 in rssiValue - RSSI threshold value
11588 in triggerEvent - Cross direction should be notified
11589 UP, DOWN, and CROSS
11590
11591 RETURN VALUE VOS_STATUS
11592
11593 SIDE EFFECTS NONE
11594
11595============================================================================*/
11596VOS_STATUS WLANTL_DeregRSSIIndicationCB
11597(
11598 v_PVOID_t pAdapter,
11599 v_S7_t rssiValue,
11600 v_U8_t triggerEvent,
11601 WLANTL_RSSICrossThresholdCBType crossCBFunction,
11602 VOS_MODULE_ID moduleID
11603)
11604{
11605 VOS_STATUS status = VOS_STATUS_SUCCESS;
11606
11607 status = WLANTL_HSDeregRSSIIndicationCB(pAdapter,
11608 rssiValue,
11609 triggerEvent,
11610 crossCBFunction,
11611 moduleID);
11612 return status;
11613}
11614
11615/*==========================================================================
11616 FUNCTION WLANTL_SetAlpha
11617
11618 DESCRIPTION ALPLA is weight value to calculate AVG RSSI
11619 avgRSSI = (ALPHA * historyRSSI) + ((10 - ALPHA) * newRSSI)
11620 avgRSSI has (ALPHA * 10)% of history RSSI weight and
11621 (10 - ALPHA)% of newRSSI weight
11622 This portion is dynamically configurable.
11623 Default is ?
11624
11625 DEPENDENCIES NONE
11626
11627 PARAMETERS in pAdapter - Global handle
11628 in valueAlpah - ALPHA
11629
11630 RETURN VALUE VOS_STATUS
11631
11632 SIDE EFFECTS NONE
11633
11634============================================================================*/
11635VOS_STATUS WLANTL_SetAlpha
11636(
11637 v_PVOID_t pAdapter,
11638 v_U8_t valueAlpha
11639)
11640{
11641 VOS_STATUS status = VOS_STATUS_SUCCESS;
11642
11643 status = WLANTL_HSSetAlpha(pAdapter, valueAlpha);
11644 return status;
11645}
11646
11647/*==========================================================================
11648
11649 FUNCTION
11650
11651 DESCRIPTION
11652
11653 PARAMETERS
11654
11655 RETURN VALUE
11656
11657============================================================================*/
11658VOS_STATUS WLANTL_BMPSRSSIRegionChangedNotification
11659(
11660 v_PVOID_t pAdapter,
11661 tpSirRSSINotification pRSSINotification
11662)
11663{
11664 VOS_STATUS status = VOS_STATUS_SUCCESS;
11665
11666 status = WLANTL_HSBMPSRSSIRegionChangedNotification(pAdapter, pRSSINotification);
11667 return status;
11668}
11669
11670/*==========================================================================
11671 FUNCTION WLANTL_RegGetTrafficStatus
11672
11673 DESCRIPTION Registration function for traffic status monitoring
11674 During measure period count data frames.
11675 If frame count is larger then IDLE threshold set as traffic ON
11676 or OFF.
11677 And traffic status is changed send report to client with
11678 registered callback function
11679
11680 DEPENDENCIES NONE
11681
11682 PARAMETERS in pAdapter - Global handle
11683 in idleThreshold - Traffic on or off threshold
11684 in measurePeriod - Traffic state check period
11685 in trfficStatusCB - traffic status changed notification
11686 CB function
11687 in usrCtxt - user context
11688
11689 RETURN VALUE VOS_STATUS
11690
11691 SIDE EFFECTS NONE
11692
11693============================================================================*/
11694VOS_STATUS WLANTL_RegGetTrafficStatus
11695(
11696 v_PVOID_t pAdapter,
11697 v_U32_t idleThreshold,
11698 v_U32_t measurePeriod,
11699 WLANTL_TrafficStatusChangedCBType trfficStatusCB,
11700 v_PVOID_t usrCtxt
11701)
11702{
11703 VOS_STATUS status = VOS_STATUS_SUCCESS;
11704
11705 status = WLANTL_HSRegGetTrafficStatus(pAdapter,
11706 idleThreshold,
11707 measurePeriod,
11708 trfficStatusCB,
11709 usrCtxt);
11710 return status;
11711}
11712#endif
11713/*==========================================================================
11714 FUNCTION WLANTL_GetStatistics
11715
11716 DESCRIPTION Get traffic statistics for identified station
11717
11718 DEPENDENCIES NONE
11719
11720 PARAMETERS in pAdapter - Global handle
11721 in statType - specific statistics field to reset
11722 out statBuffer - traffic statistics buffer
11723
11724 RETURN VALUE VOS_STATUS
11725
11726 SIDE EFFECTS NONE
11727
11728============================================================================*/
11729VOS_STATUS WLANTL_GetStatistics
11730(
11731 v_PVOID_t pAdapter,
11732 WLANTL_TRANSFER_STA_TYPE *statBuffer,
11733 v_U8_t STAid
11734)
11735{
11736 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011737 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 VOS_STATUS status = VOS_STATUS_SUCCESS;
11739 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11740
11741 /*------------------------------------------------------------------------
11742 Sanity check
11743 Extract TL control block
11744 ------------------------------------------------------------------------*/
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011745 if ( NULL == pTLCb )
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 {
11747 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11748 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11749 return VOS_STATUS_E_FAULT;
11750 }
11751
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011752 pClientSTA = pTLCb->atlSTAClients[STAid];
11753
11754 if ( NULL == pClientSTA )
11755 {
11756 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11757 "WLAN TL:Client Memory was not allocated on %s", __func__));
11758 return VOS_STATUS_E_FAILURE;
11759 }
11760
11761 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 {
11763 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11764 "WLAN TL: %d STA ID does not exist", STAid));
11765 return VOS_STATUS_E_INVAL;
11766 }
11767
11768 if(NULL == statBuffer)
11769 {
11770 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11771 "WLAN TL:Invalid TL statistics buffer pointer on WLANTL_GetStatistics"));
11772 return VOS_STATUS_E_INVAL;
11773 }
11774
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011775 statistics = &pClientSTA->trafficStatistics;
Katya Nigam493ff652014-02-11 14:31:04 +053011776 vos_mem_copy(statBuffer, statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
Jeff Johnson295189b2012-06-20 16:38:30 -070011777
11778 return status;
11779}
11780
11781/*==========================================================================
11782 FUNCTION WLANTL_ResetStatistics
11783
11784 DESCRIPTION Reset statistics structure for identified station ID
11785 Reset means set values as 0
11786
11787 DEPENDENCIES NONE
11788
11789 PARAMETERS in pAdapter - Global handle
11790 in statType - specific statistics field to reset
11791
11792 RETURN VALUE VOS_STATUS
11793
11794 SIDE EFFECTS NONE
11795
11796============================================================================*/
11797VOS_STATUS WLANTL_ResetStatistics
11798(
11799 v_PVOID_t pAdapter,
11800 v_U8_t STAid
11801)
11802{
11803 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011804 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 VOS_STATUS status = VOS_STATUS_SUCCESS;
11806 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11807
11808 /*------------------------------------------------------------------------
11809 Sanity check
11810 Extract TL control block
11811 ------------------------------------------------------------------------*/
11812 if (NULL == pTLCb)
11813 {
11814 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11815 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11816 return VOS_STATUS_E_FAULT;
11817 }
11818
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011819 pClientSTA = pTLCb->atlSTAClients[STAid];
11820
11821 if ( NULL == pClientSTA )
11822 {
11823 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11824 "WLAN TL:Client Memory was not allocated on %s", __func__));
11825 return VOS_STATUS_E_FAILURE;
11826 }
11827
11828 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 {
11830 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11831 "WLAN TL: %d STA ID does not exist", STAid));
11832 return VOS_STATUS_E_INVAL;
11833 }
11834
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011835 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 vos_mem_zero((v_VOID_t *)statistics, sizeof(WLANTL_TRANSFER_STA_TYPE));
11837
11838 return status;
11839}
11840
11841/*==========================================================================
11842 FUNCTION WLANTL_GetSpecStatistic
11843
11844 DESCRIPTION Get specific field within statistics structure for
11845 identified station ID
11846
11847 DEPENDENCIES NONE
11848
11849 PARAMETERS in pAdapter - Global handle
11850 in statType - specific statistics field to reset
11851 in STAid - Station ID
11852 out buffer - Statistic value
11853
11854 RETURN VALUE VOS_STATUS
11855
11856 SIDE EFFECTS NONE
11857
11858============================================================================*/
11859VOS_STATUS WLANTL_GetSpecStatistic
11860(
11861 v_PVOID_t pAdapter,
11862 WLANTL_TRANSFER_STATIC_TYPE statType,
11863 v_U32_t *buffer,
11864 v_U8_t STAid
11865)
11866{
11867 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011868 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 VOS_STATUS status = VOS_STATUS_SUCCESS;
11870 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
11871
11872 /*------------------------------------------------------------------------
11873 Sanity check
11874 Extract TL control block
11875 ------------------------------------------------------------------------*/
11876 if (NULL == pTLCb)
11877 {
11878 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11879 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
11880 return VOS_STATUS_E_FAULT;
11881 }
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011882 pClientSTA = pTLCb->atlSTAClients[STAid];
Jeff Johnson295189b2012-06-20 16:38:30 -070011883
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011884 if ( NULL == pClientSTA )
11885 {
11886 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11887 "WLAN TL:Client Memory was not allocated on %s", __func__));
11888 return VOS_STATUS_E_FAILURE;
11889 }
11890
11891 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 {
11893 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11894 "WLAN TL: %d STA ID does not exist", STAid));
11895 return VOS_STATUS_E_INVAL;
11896 }
11897
11898 if(NULL == buffer)
11899 {
11900 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
11901 "WLAN TL:Invalid TL statistic buffer pointer on WLANTL_GetStatistics"));
11902 return VOS_STATUS_E_INVAL;
11903 }
11904
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053011905 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 switch(statType)
11907 {
11908 case WLANTL_STATIC_TX_UC_FCNT:
11909 *buffer = statistics->txUCFcnt;
11910 break;
11911
11912 case WLANTL_STATIC_TX_MC_FCNT:
11913 *buffer = statistics->txMCFcnt;
11914 break;
11915
11916 case WLANTL_STATIC_TX_BC_FCNT:
11917 *buffer = statistics->txBCFcnt;
11918 break;
11919
11920 case WLANTL_STATIC_TX_UC_BCNT:
11921 *buffer = statistics->txUCBcnt;
11922 break;
11923
11924 case WLANTL_STATIC_TX_MC_BCNT:
11925 *buffer = statistics->txMCBcnt;
11926 break;
11927
11928 case WLANTL_STATIC_TX_BC_BCNT:
11929 *buffer = statistics->txBCBcnt;
11930 break;
11931
11932 case WLANTL_STATIC_RX_UC_FCNT:
11933 *buffer = statistics->rxUCFcnt;
11934 break;
11935
11936 case WLANTL_STATIC_RX_MC_FCNT:
11937 *buffer = statistics->rxMCFcnt;
11938 break;
11939
11940 case WLANTL_STATIC_RX_BC_FCNT:
11941 *buffer = statistics->rxBCFcnt;
11942 break;
11943
11944 case WLANTL_STATIC_RX_UC_BCNT:
11945 *buffer = statistics->rxUCBcnt;
11946 break;
11947
11948 case WLANTL_STATIC_RX_MC_BCNT:
11949 *buffer = statistics->rxMCBcnt;
11950 break;
11951
11952 case WLANTL_STATIC_RX_BC_BCNT:
11953 *buffer = statistics->rxBCBcnt;
11954 break;
11955
11956 case WLANTL_STATIC_RX_BCNT:
11957 *buffer = statistics->rxBcnt;
11958 break;
11959
11960 case WLANTL_STATIC_RX_BCNT_CRC_OK:
11961 *buffer = statistics->rxBcntCRCok;
11962 break;
11963
11964 case WLANTL_STATIC_RX_RATE:
11965 *buffer = statistics->rxRate;
11966 break;
11967
11968 default:
11969 *buffer = 0;
11970 status = VOS_STATUS_E_INVAL;
11971 break;
11972 }
11973
11974
11975 return status;
11976}
11977
11978/*==========================================================================
11979 FUNCTION WLANTL_ResetSpecStatistic
11980
11981 DESCRIPTION Reset specific field within statistics structure for
11982 identified station ID
11983 Reset means set as 0
11984
11985 DEPENDENCIES NONE
11986
11987 PARAMETERS in pAdapter - Global handle
11988 in statType - specific statistics field to reset
11989 in STAid - Station ID
11990
11991 RETURN VALUE VOS_STATUS
11992
11993 SIDE EFFECTS NONE
11994
11995============================================================================*/
11996VOS_STATUS WLANTL_ResetSpecStatistic
11997(
11998 v_PVOID_t pAdapter,
11999 WLANTL_TRANSFER_STATIC_TYPE statType,
12000 v_U8_t STAid
12001)
12002{
12003 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012004 WLANTL_STAClientType* pClientSTA = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 VOS_STATUS status = VOS_STATUS_SUCCESS;
12006 WLANTL_TRANSFER_STA_TYPE *statistics = NULL;
12007
12008 /*------------------------------------------------------------------------
12009 Sanity check
12010 Extract TL control block
12011 ------------------------------------------------------------------------*/
12012 if (NULL == pTLCb)
12013 {
12014 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12015 "WLAN TL:Invalid TL pointer on WLANTL_GetStatistics"));
12016 return VOS_STATUS_E_FAULT;
12017 }
12018
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012019 pClientSTA = pTLCb->atlSTAClients[STAid];
12020
12021 if ( NULL == pClientSTA )
12022 {
12023 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12024 "WLAN TL:Client Memory was not allocated on %s", __func__));
12025 return VOS_STATUS_E_FAILURE;
12026 }
12027
12028 if(0 == pClientSTA->ucExists)
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 {
12030 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12031 "WLAN TL: %d STA ID does not exist", STAid));
12032 return VOS_STATUS_E_INVAL;
12033 }
12034
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012035 statistics = &pClientSTA->trafficStatistics;
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 switch(statType)
12037 {
12038 case WLANTL_STATIC_TX_UC_FCNT:
12039 statistics->txUCFcnt = 0;
12040 break;
12041
12042 case WLANTL_STATIC_TX_MC_FCNT:
12043 statistics->txMCFcnt = 0;
12044 break;
12045
12046 case WLANTL_STATIC_TX_BC_FCNT:
12047 statistics->txBCFcnt = 0;
12048 break;
12049
12050 case WLANTL_STATIC_TX_UC_BCNT:
12051 statistics->txUCBcnt = 0;
12052 break;
12053
12054 case WLANTL_STATIC_TX_MC_BCNT:
12055 statistics->txMCBcnt = 0;
12056 break;
12057
12058 case WLANTL_STATIC_TX_BC_BCNT:
12059 statistics->txBCBcnt = 0;
12060 break;
12061
12062 case WLANTL_STATIC_RX_UC_FCNT:
12063 statistics->rxUCFcnt = 0;
12064 break;
12065
12066 case WLANTL_STATIC_RX_MC_FCNT:
12067 statistics->rxMCFcnt = 0;
12068 break;
12069
12070 case WLANTL_STATIC_RX_BC_FCNT:
12071 statistics->rxBCFcnt = 0;
12072 break;
12073
12074 case WLANTL_STATIC_RX_UC_BCNT:
12075 statistics->rxUCBcnt = 0;
12076 break;
12077
12078 case WLANTL_STATIC_RX_MC_BCNT:
12079 statistics->rxMCBcnt = 0;
12080 break;
12081
12082 case WLANTL_STATIC_RX_BC_BCNT:
12083 statistics->rxBCBcnt = 0;
12084 break;
12085
12086 case WLANTL_STATIC_RX_BCNT:
12087 statistics->rxBcnt = 0;
12088 break;
12089
12090 case WLANTL_STATIC_RX_BCNT_CRC_OK:
12091 statistics->rxBcntCRCok = 0;
12092 break;
12093
12094 case WLANTL_STATIC_RX_RATE:
12095 statistics->rxRate = 0;
12096 break;
12097
12098 default:
12099 status = VOS_STATUS_E_INVAL;
12100 break;
12101 }
12102
12103 return status;
12104}
12105
12106
12107/*==========================================================================
12108
12109 FUNCTION
12110
12111 DESCRIPTION Read RSSI value out of a RX BD
12112
12113 PARAMETERS: Caller must validate all parameters
12114
12115 RETURN VALUE
12116
12117============================================================================*/
12118VOS_STATUS WLANTL_ReadRSSI
12119(
12120 v_PVOID_t pAdapter,
12121 v_PVOID_t pBDHeader,
12122 v_U8_t STAid
12123)
12124{
12125 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12126 v_S7_t currentRSSI, currentRSSI0, currentRSSI1;
12127
12128
12129 if(NULL == tlCtxt)
12130 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012131 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "%s Invalid TL handle", __func__));
Jeff Johnson295189b2012-06-20 16:38:30 -070012132 return VOS_STATUS_E_INVAL;
12133 }
12134
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012135 if ( NULL == tlCtxt->atlSTAClients[STAid] )
12136 {
12137 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12138 "WLAN TL:Client Memory was not allocated on %s", __func__));
12139 return VOS_STATUS_E_FAILURE;
12140 }
12141
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 currentRSSI0 = WLANTL_GETRSSI0(pBDHeader);
12143 currentRSSI1 = WLANTL_GETRSSI1(pBDHeader);
12144 currentRSSI = (currentRSSI0 > currentRSSI1) ? currentRSSI0 : currentRSSI1;
12145
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012146 tlCtxt->atlSTAClients[STAid]->rssiAvg = currentRSSI;
Jeff Johnson295189b2012-06-20 16:38:30 -070012147
12148 return VOS_STATUS_SUCCESS;
12149}
12150
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012151/*==========================================================================
12152
12153 FUNCTION
12154
12155 DESCRIPTION Read SNR value out of a RX BD
12156
12157 PARAMETERS: Caller must validate all parameters
12158
12159 RETURN VALUE
12160
12161============================================================================*/
12162VOS_STATUS WLANTL_ReadSNR
12163(
12164 v_PVOID_t pAdapter,
12165 v_PVOID_t pBDHeader,
12166 v_U8_t STAid
12167)
12168{
12169 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12170 v_S7_t currentSNR;
12171
12172
12173 if (NULL == tlCtxt)
12174 {
12175 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12176 "%s Invalid TL handle", __func__));
12177 return VOS_STATUS_E_INVAL;
12178 }
12179
12180 if (NULL == tlCtxt->atlSTAClients[STAid])
12181 {
12182 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12183 "WLAN TL:Client Memory was not allocated on %s", __func__));
12184 return VOS_STATUS_E_FAILURE;
12185 }
12186
12187 currentSNR = WLANTL_GETSNR(pBDHeader);
12188
Madan Mohan Koyyalamudi43acf032013-09-27 04:33:28 +053012189 /* SNR reported in the Buffer Descriptor is scaled up by 2(SNR*2),
12190 * Get the correct SNR value
12191 */
12192 currentSNR = currentSNR >> 1;
12193
12194 /* SNR reported by HW cannot be more than 35dB due to HW limitations */
12195 currentSNR = (WLANTL_MAX_HW_SNR > currentSNR ? currentSNR :
12196 WLANTL_MAX_HW_SNR);
12197
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012198 TLLOG2(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12199 "%s: snrsum: %d snridx: %d prevsnravg: %d",
12200 __func__,
12201 tlCtxt->atlSTAClients[STAid]->snrSum,
12202 tlCtxt->atlSTAClients[STAid]->snrIdx,
12203 tlCtxt->atlSTAClients[STAid]->prevSnrAvg));
12204
12205 /* The SNR returned for all purposes is the average SNR over
12206 * WLANTL_MAX_SNR_DATA_SMAPLES.When data samples
12207 * > WLANTL_MAX_SNR_DATA_SAMPLES are obtained,
12208 * store the average of the samples in prevSnrAvg
12209 * and start a new averaging window. The prevSnrAvg is used when
12210 * enough data samples are not available when applications
12211 * actually query for SNR.
12212 *
12213 * SEE: WLANTL_GetSnr()
12214 */
12215 if (tlCtxt->atlSTAClients[STAid]->snrIdx >= WLANTL_MAX_SNR_DATA_SAMPLES)
12216 {
12217 tlCtxt->atlSTAClients[STAid]->prevSnrAvg =
12218 tlCtxt->atlSTAClients[STAid]->snrSum /
12219 tlCtxt->atlSTAClients[STAid]->snrIdx;
12220 tlCtxt->atlSTAClients[STAid]->snrSum = 0;
12221 tlCtxt->atlSTAClients[STAid]->snrIdx = 0;
12222 }
12223 tlCtxt->atlSTAClients[STAid]->snrSum += currentSNR;
12224 tlCtxt->atlSTAClients[STAid]->snrIdx += 1;
12225
12226 return VOS_STATUS_SUCCESS;
12227}
Jeff Johnson295189b2012-06-20 16:38:30 -070012228
12229/*
12230 DESCRIPTION
12231 TL returns the weight currently maintained in TL.
12232 IN
12233 pvosGCtx: pointer to the global vos context; a handle to TL's
12234 or SME's control block can be extracted from its context
12235
12236 OUT
12237 pACWeights: Caller allocated memory for filling in weights
12238
12239 RETURN VALUE VOS_STATUS
12240*/
12241VOS_STATUS
12242WLANTL_GetACWeights
12243(
12244 v_PVOID_t pvosGCtx,
12245 v_U8_t* pACWeights
12246)
12247{
12248 WLANTL_CbType* pTLCb = NULL;
12249 v_U8_t ucIndex;
12250 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12251
12252 /*------------------------------------------------------------------------
12253 Sanity check
12254 ------------------------------------------------------------------------*/
12255 if ( NULL == pACWeights )
12256 {
12257 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12258 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12259 return VOS_STATUS_E_INVAL;
12260 }
12261
12262 /*------------------------------------------------------------------------
12263 Extract TL control block and check existance
12264 ------------------------------------------------------------------------*/
12265 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12266 if ( NULL == pTLCb )
12267 {
12268 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12269 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12270 return VOS_STATUS_E_FAULT;
12271 }
12272 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12273 {
12274 pACWeights[ucIndex] = pTLCb->tlConfigInfo.ucAcWeights[ucIndex];
12275 }
12276
12277 return VOS_STATUS_SUCCESS;
12278}
12279
12280
12281
12282/*
12283 DESCRIPTION
12284 Change the weight currently maintained by TL.
12285 IN
12286 pvosGCtx: pointer to the global vos context; a handle to TL's
12287 or SME's control block can be extracted from its context
12288 pACWeights: Caller allocated memory contain the weights to use
12289
12290
12291 RETURN VALUE VOS_STATUS
12292*/
12293VOS_STATUS
12294WLANTL_SetACWeights
12295(
12296 v_PVOID_t pvosGCtx,
12297 v_U8_t* pACWeights
12298)
12299{
12300 WLANTL_CbType* pTLCb = NULL;
12301 v_U8_t ucIndex;
12302 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12303
12304 /*------------------------------------------------------------------------
12305 Sanity check
12306 ------------------------------------------------------------------------*/
12307 if ( NULL == pACWeights )
12308 {
12309 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12310 "WLAN TL:Invalid parameter sent on WLANTL_GetACWeights"));
12311 return VOS_STATUS_E_INVAL;
12312 }
12313
12314 /*------------------------------------------------------------------------
12315 Extract TL control block and check existance
12316 ------------------------------------------------------------------------*/
12317 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12318 if ( NULL == pTLCb )
12319 {
12320 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12321 "WLAN TL:Invalid TL pointer from pvosGCtx on WLANTL_GetACWeights"));
12322 return VOS_STATUS_E_FAULT;
12323 }
12324 for ( ucIndex = 0; ucIndex < WLANTL_MAX_AC ; ucIndex++)
12325 {
12326 pTLCb->tlConfigInfo.ucAcWeights[ucIndex] = pACWeights[ucIndex];
12327 }
12328
12329 return VOS_STATUS_SUCCESS;
12330}
12331
12332
12333/*==========================================================================
12334
12335 FUNCTION
12336
12337 DESCRIPTION
12338
12339 PARAMETERS
12340
12341 RETURN VALUE
12342
12343============================================================================*/
12344void WLANTL_PowerStateChangedCB
12345(
12346 v_PVOID_t pAdapter,
12347 tPmcState newState
12348)
12349{
12350 WLANTL_CbType *tlCtxt = VOS_GET_TL_CB(pAdapter);
12351
12352 if (NULL == tlCtxt)
12353 {
12354 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053012355 "%s: Invalid TL Control Block", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -070012356 return;
12357 }
12358
12359 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO, "Power state changed, new state is %d", newState );
12360 switch(newState)
12361 {
12362 case FULL_POWER:
12363 tlCtxt->isBMPS = VOS_FALSE;
12364 break;
12365
12366 case BMPS:
12367#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
12368 WLANTL_SetFWRSSIThresholds(pAdapter);
12369#endif
12370
12371 tlCtxt->isBMPS = VOS_TRUE;
12372 break;
12373
12374 case IMPS:
12375 case LOW_POWER:
12376 case REQUEST_BMPS:
12377 case REQUEST_FULL_POWER:
12378 case REQUEST_IMPS:
12379 case STOPPED:
12380 case REQUEST_START_UAPSD:
12381 case REQUEST_STOP_UAPSD:
12382 case UAPSD:
12383 case REQUEST_STANDBY:
12384 case STANDBY:
12385 case REQUEST_ENTER_WOWL:
12386 case REQUEST_EXIT_WOWL:
12387 case WOWL:
12388 TLLOGW(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN, "Not handle this events %d", newState ));
12389 break;
12390
12391 default:
12392 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, "Not a valid event %d", newState ));
12393 break;
12394 }
12395
12396 return;
12397}
12398/*==========================================================================
12399 FUNCTION WLANTL_GetEtherType
12400
12401 DESCRIPTION Extract Ether type information from the BD
12402
12403 DEPENDENCIES NONE
12404
12405 PARAMETERS in aucBDHeader - BD header
12406 in vosDataBuff - data buffer
12407 in ucMPDUHLen - MPDU header length
12408 out pUsEtherType - pointer to Ethertype
12409
12410 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12411 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12412 the packet was dropped
12413
12414 SIDE EFFECTS NONE
12415
12416============================================================================*/
12417static VOS_STATUS WLANTL_GetEtherType
12418(
12419 v_U8_t * aucBDHeader,
12420 vos_pkt_t * vosDataBuff,
12421 v_U8_t ucMPDUHLen,
12422 v_U16_t * pUsEtherType
12423)
12424{
12425 v_U8_t ucOffset;
12426 v_U16_t usEtherType = *pUsEtherType;
12427 v_SIZE_t usLLCSize = sizeof(usEtherType);
12428 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12429
12430 /*------------------------------------------------------------------------
12431 Check if LLC is present - if not, TL is unable to determine type
12432 ------------------------------------------------------------------------*/
12433 if ( VOS_FALSE == WDA_IS_RX_LLC_PRESENT( aucBDHeader ) )
12434 {
12435 ucOffset = WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12436 }
12437 else
12438 {
12439 ucOffset = ucMPDUHLen + WLANTL_LLC_PROTO_TYPE_OFFSET;
12440 }
12441
12442 /*------------------------------------------------------------------------
12443 Extract LLC type
12444 ------------------------------------------------------------------------*/
12445 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12446 (v_PVOID_t)&usEtherType, &usLLCSize);
12447
12448 if (( VOS_STATUS_SUCCESS != vosStatus ) ||
12449 ( sizeof(usEtherType) != usLLCSize ))
12450
12451 {
12452 TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12453 "WLAN TL:Error extracting Ether type from data packet"));
12454 /* Drop packet */
12455 vos_pkt_return_packet(vosDataBuff);
12456 vosStatus = VOS_STATUS_E_FAILURE;
12457 }
12458 else
12459 {
12460 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12461 "WLAN TL:Ether type retrieved before endianess conv: %d",
12462 usEtherType));
12463
12464 usEtherType = vos_be16_to_cpu(usEtherType);
12465 *pUsEtherType = usEtherType;
12466
12467 TLLOG2(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12468 "WLAN TL:Ether type retrieved: %d", usEtherType));
12469 }
12470
12471 return vosStatus;
12472}
12473
Jeff Johnson295189b2012-06-20 16:38:30 -070012474/*==========================================================================
12475 FUNCTION WLANTL_GetSoftAPStatistics
12476
12477 DESCRIPTION Collect the cumulative statistics for all Softap stations
12478
12479 DEPENDENCIES NONE
12480
12481 PARAMETERS in pvosGCtx - Pointer to the global vos context
12482 bReset - If set TL statistics will be cleared after reading
12483 out statsSum - pointer to collected statistics
12484
12485 RETURN VALUE VOS_STATUS_SUCCESS : if the Statistics are successfully extracted
12486
12487 SIDE EFFECTS NONE
12488
12489============================================================================*/
12490VOS_STATUS WLANTL_GetSoftAPStatistics(v_PVOID_t pAdapter, WLANTL_TRANSFER_STA_TYPE *statsSum, v_BOOL_t bReset)
12491{
12492 v_U8_t i = 0;
12493 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12494 WLANTL_CbType *pTLCb = VOS_GET_TL_CB(pAdapter);
12495 WLANTL_TRANSFER_STA_TYPE statBufferTemp;
12496 vos_mem_zero((v_VOID_t *)&statBufferTemp, sizeof(WLANTL_TRANSFER_STA_TYPE));
12497 vos_mem_zero((v_VOID_t *)statsSum, sizeof(WLANTL_TRANSFER_STA_TYPE));
12498
12499
12500 if ( NULL == pTLCb )
12501 {
12502 return VOS_STATUS_E_FAULT;
12503 }
12504
12505 // Sum up all the statistics for stations of Soft AP from TL
12506 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
12507 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012508 if ( NULL == pTLCb->atlSTAClients[i])
12509 {
12510 continue;
12511 }
12512 if (pTLCb->atlSTAClients[i]->wSTADesc.wSTAType == WLAN_STA_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 {
12514 vosStatus = WLANTL_GetStatistics(pAdapter, &statBufferTemp, i);// Can include staId 1 because statistics not collected for it
12515
12516 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12517 return VOS_STATUS_E_FAULT;
12518
12519 // Add to the counters
12520 statsSum->txUCFcnt += statBufferTemp.txUCFcnt;
12521 statsSum->txMCFcnt += statBufferTemp.txMCFcnt;
12522 statsSum->txBCFcnt += statBufferTemp.txBCFcnt;
12523 statsSum->txUCBcnt += statBufferTemp.txUCBcnt;
12524 statsSum->txMCBcnt += statBufferTemp.txMCBcnt;
12525 statsSum->txBCBcnt += statBufferTemp.txBCBcnt;
12526 statsSum->rxUCFcnt += statBufferTemp.rxUCFcnt;
12527 statsSum->rxMCFcnt += statBufferTemp.rxMCFcnt;
12528 statsSum->rxBCFcnt += statBufferTemp.rxBCFcnt;
12529 statsSum->rxUCBcnt += statBufferTemp.rxUCBcnt;
12530 statsSum->rxMCBcnt += statBufferTemp.rxMCBcnt;
12531 statsSum->rxBCBcnt += statBufferTemp.rxBCBcnt;
12532
12533 if (bReset)
12534 {
12535 vosStatus = WLANTL_ResetStatistics(pAdapter, i);
12536 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
12537 return VOS_STATUS_E_FAULT;
12538 }
12539 }
12540 }
12541
12542 return vosStatus;
12543}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012544#ifdef FEATURE_WLAN_TDLS_INTERNAL
12545/*==========================================================================
12546 FUNCTION WLANTL_GetEtherType_2
12547
12548 DESCRIPTION Extract Ether type information from the BD
12549
12550 DEPENDENCIES NONE
12551
12552 PARAMETERS in aucBDHeader - BD header
12553 in vosDataBuff - data buffer
12554 in ucMPDUHLen - MPDU header length
12555 out pUsEtherType - pointer to Ethertype
12556
12557 RETURN VALUE VOS_STATUS_SUCCESS : if the EtherType is successfully extracted
12558 VOS_STATUS_FAILURE : if the EtherType extraction failed and
12559 the packet was dropped
12560
12561 SIDE EFFECTS NONE
12562
12563============================================================================*/
12564static VOS_STATUS WLANTL_GetEtherType_2
12565(
12566 v_U8_t * aucBDHeader,
12567 vos_pkt_t * vosDataBuff,
12568 v_U8_t ucMPDUHLen,
12569 v_U16_t * pUsEtherType
12570)
12571{
12572 v_U8_t ucOffset;
12573 v_U16_t usEtherType = *pUsEtherType;
12574 v_SIZE_t usLLCSize = sizeof(usEtherType);
12575 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
12576 //v_U8_t ucLLCHeader;
12577 v_U8_t ucMPDUHOffset ;
12578 /*------------------------------------------------------------------------
12579 Check if LLC is present - if not, TL is unable to determine type
12580 ------------------------------------------------------------------------*/
12581 //ucMPDUHOffset = (v_U8_t)WLANHAL_RX_BD_GET_MPDU_H_OFFSET(aucBDHeader) ;
12582 //ucLLCHeader = (v_U8_t)WLANHAL_RX_BD_GET_LLC(aucBDHeader);
12583 ucMPDUHOffset = (v_U8_t)WDA_GET_RX_MPDU_HEADER_OFFSET(aucBDHeader);
12584
12585 if ( VOS_TRUE == WDA_IS_RX_LLC_PRESENT(aucBDHeader) )
12586 {
12587 ucOffset = ucMPDUHOffset + WLANTL_802_3_HEADER_LEN - sizeof(usEtherType);
12588 }
12589 else
12590 {
12591 ucOffset = WLANHAL_RX_BD_HEADER_SIZE + ucMPDUHLen
12592 + WLANTL_LLC_PROTO_TYPE_OFFSET;
12593 }
12594
12595 /*------------------------------------------------------------------------
12596 Extract LLC type
12597 ------------------------------------------------------------------------*/
12598 vosStatus = vos_pkt_extract_data( vosDataBuff, ucOffset,
12599 (v_PVOID_t)&usEtherType, &usLLCSize);
12600
12601 /* TODO: Do it in better way */
12602 if(vos_be16_to_cpu(usEtherType) == 0x890d)
12603 {
12604 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Arif Hussainf2b00992013-11-17 21:46:15 -080012605 ("TDLS frame llc %x"), vos_be16_to_cpu(usEtherType)) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012606 }
12607
12608 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12609 "WLAN TL:Ether type retrieved before endianess conv: %d",
12610 usEtherType);
12611
12612 usEtherType = vos_be16_to_cpu(usEtherType);
12613 *pUsEtherType = usEtherType;
12614
12615 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12616 "WLAN TL:Ether type retrieved: %d", usEtherType);
12617
12618 return vosStatus;
12619}
12620#endif /* FEATURE_WLAN_TDLS */
12621
Jeff Johnson295189b2012-06-20 16:38:30 -070012622/*===============================================================================
12623 FUNCTION WLANTL_IsReplayPacket
12624
12625 DESCRIPTION This function does replay check for valid stations
12626
12627 DEPENDENCIES Validity of replay check must be done before the function
12628 is called
12629
12630 PARAMETERS currentReplayCounter current replay counter taken from RX BD
12631 previousReplayCounter previous replay counter taken from TL CB
12632
12633 RETRUN VOS_TRUE packet is a replay packet
12634 VOS_FALSE packet is not a replay packet
12635
12636 SIDE EFFECTS none
12637 ===============================================================================*/
12638v_BOOL_t
12639WLANTL_IsReplayPacket
12640(
12641 v_U64_t ullcurrentReplayCounter,
12642 v_U64_t ullpreviousReplayCounter
12643)
12644{
12645 /* Do the replay check by comparing previous received replay counter with
12646 current received replay counter*/
12647 if(ullpreviousReplayCounter < ullcurrentReplayCounter)
12648 {
12649 /* Valid packet not replay */
12650 return VOS_FALSE;
12651 }
12652 else
12653 {
12654
12655 /* Current packet number is less than or equal to previuos received
12656 packet no, this means current packet is replay packet */
12657 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12658 "WLAN TL: Replay packet found with replay counter :[0x%llX]",ullcurrentReplayCounter);
12659
12660 return VOS_TRUE;
12661 }
12662}
12663
12664#if 0
12665/*===============================================================================
12666 FUNCTION WLANTL_GetReplayCounterFromRxBD
12667
12668 DESCRIPTION This function extracts 48-bit replay packet number from RX BD
12669
12670 DEPENDENCIES Validity of replay check must be done before the function
12671 is called
12672
12673 PARAMETERS pucRxHeader pointer to RX BD header
12674
12675 RETRUN v_U64_t Packet number extarcted from RX BD
12676
12677 SIDE EFFECTS none
12678 ===============================================================================*/
12679v_U64_t
12680WLANTL_GetReplayCounterFromRxBD
12681(
12682 v_U8_t *pucRxBDHeader
12683)
12684{
12685/* 48-bit replay counter is created as follows
12686 from RX BD 6 byte PMI command:
12687 Addr : AES/TKIP
12688 0x38 : pn3/tsc3
12689 0x39 : pn2/tsc2
12690 0x3a : pn1/tsc1
12691 0x3b : pn0/tsc0
12692
12693 0x3c : pn5/tsc5
12694 0x3d : pn4/tsc4 */
12695
12696#ifdef ANI_BIG_BYTE_ENDIAN
12697 v_U64_t ullcurrentReplayCounter = 0;
12698 /* Getting 48-bit replay counter from the RX BD */
12699 ullcurrentReplayCounter = WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12700 ullcurrentReplayCounter <<= 16;
12701 ullcurrentReplayCounter |= (( WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0xFFFF0000) >> 16);
12702 return ullcurrentReplayCounter;
12703#else
12704 v_U64_t ullcurrentReplayCounter = 0;
12705 /* Getting 48-bit replay counter from the RX BD */
12706 ullcurrentReplayCounter = (WLANHAL_RX_BD_GET_PMICMD_24TO25(pucRxBDHeader) & 0x0000FFFF);
12707 ullcurrentReplayCounter <<= 32;
12708 ullcurrentReplayCounter |= WLANHAL_RX_BD_GET_PMICMD_20TO23(pucRxBDHeader);
12709 return ullcurrentReplayCounter;
12710#endif
12711}
12712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012713
12714/*===============================================================================
12715 FUNCTION WLANTL_PostResNeeded
12716
12717 DESCRIPTION This function posts message to TL to reserve BD/PDU memory
12718
12719 DEPENDENCIES None
12720
12721 PARAMETERS pvosGCtx
12722
12723 RETURN None
12724
12725 SIDE EFFECTS none
12726 ===============================================================================*/
12727
12728void WLANTL_PostResNeeded(v_PVOID_t pvosGCtx)
12729{
12730 vos_msg_t vosMsg;
12731
12732 vosMsg.reserved = 0;
12733 vosMsg.bodyptr = NULL;
12734 vosMsg.type = WLANTL_TX_RES_NEEDED;
12735 VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
12736 "WLAN TL: BD/PDU available interrupt received, Posting message to TL");
12737 if(!VOS_IS_STATUS_SUCCESS(vos_tx_mq_serialize( VOS_MQ_ID_TL, &vosMsg)))
12738 {
12739 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012740 " %s fails to post message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 }
12742}
12743
12744/*===============================================================================
12745 FUNCTION WLANTL_UpdateRssiBmps
12746
12747 DESCRIPTION This function updates the TL's RSSI (in BMPS mode)
12748
12749 DEPENDENCIES None
12750
12751 PARAMETERS
12752
12753 pvosGCtx VOS context VOS Global context
12754 staId Station ID Station ID
12755 rssi RSSI (BMPS mode) RSSI in BMPS mode
12756
12757 RETURN None
12758
12759 SIDE EFFECTS none
12760 ===============================================================================*/
12761
12762void WLANTL_UpdateRssiBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t rssi)
12763{
12764 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12765
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012766 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 {
Madan Mohan Koyylamudi3b8400c2013-01-24 17:47:01 +053012768 pTLCb->atlSTAClients[staId]->rssiAvgBmps = rssi;
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 }
12770}
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012771
12772/*===============================================================================
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053012773 FUNCTION WLANTL_UpdateSnrBmps
12774
12775 DESCRIPTION This function updates the TL's SNR (in BMPS mode)
12776
12777 DEPENDENCIES None
12778
12779 PARAMETERS
12780
12781 pvosGCtx VOS context VOS Global context
12782 staId Station ID Station ID
12783 snr SNR (BMPS mode) SNR in BMPS mode
12784
12785 RETURN None
12786
12787 SIDE EFFECTS none
12788 ===============================================================================*/
12789
12790void WLANTL_UpdateSnrBmps(v_PVOID_t pvosGCtx, v_U8_t staId, v_S7_t snr)
12791{
12792 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12793
12794 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12795 {
12796 pTLCb->atlSTAClients[staId]->snrAvgBmps = snr;
12797 }
12798}
12799
12800/*===============================================================================
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053012801 FUNCTION WLANTL_UpdateLinkCapacity
12802
12803 DESCRIPTION This function updates the STA's Link Capacity in TL
12804
12805 DEPENDENCIES None
12806
12807 PARAMETERS
12808
12809 pvosGCtx VOS context VOS Global context
12810 staId Station ID Station ID
12811 linkCapacity linkCapacity Link Capacity
12812
12813 RETURN None
12814
12815 SIDE EFFECTS none
12816 ===============================================================================*/
12817
12818void WLANTL_UpdateLinkCapacity(v_PVOID_t pvosGCtx, v_U8_t staId, v_U32_t linkCapacity)
12819{
12820 WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
12821
12822 if (NULL != pTLCb && NULL != pTLCb->atlSTAClients[staId])
12823 {
12824 pTLCb->atlSTAClients[staId]->linkCapacity = linkCapacity;
12825 }
12826}
12827
12828
12829/*===========================================================================
12830
12831 FUNCTION WLANTL_GetSTALinkCapacity
12832
12833 DESCRIPTION
12834
12835 Returns Link Capacity of a particular STA.
12836
12837 DEPENDENCIES
12838
12839 A station must have been registered before its state can be retrieved.
12840
12841
12842 PARAMETERS
12843
12844 IN
12845 pvosGCtx: pointer to the global vos context; a handle to TL's
12846 control block can be extracted from its context
12847 ucSTAId: identifier of the station
12848
12849 OUT
12850 plinkCapacity: the current link capacity the connection to
12851 the given station
12852
12853
12854 RETURN VALUE
12855
12856 The result code associated with performing the operation
12857
12858 VOS_STATUS_E_INVAL: Input parameters are invalid
12859 VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to
12860 TL cb is NULL ; access would cause a page fault
12861 VOS_STATUS_E_EXISTS: Station was not registered
12862 VOS_STATUS_SUCCESS: Everything is good :)
12863
12864 SIDE EFFECTS
12865
12866============================================================================*/
12867VOS_STATUS
12868WLANTL_GetSTALinkCapacity
12869(
12870 v_PVOID_t pvosGCtx,
12871 v_U8_t ucSTAId,
12872 v_U32_t *plinkCapacity
12873)
12874{
12875 WLANTL_CbType* pTLCb = NULL;
12876 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
12877
12878 /*------------------------------------------------------------------------
12879 Sanity check
12880 ------------------------------------------------------------------------*/
12881 if ( NULL == plinkCapacity )
12882 {
12883 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12884 FL("WLAN TL:Invalid parameter")));
12885 return VOS_STATUS_E_INVAL;
12886 }
12887
12888 if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
12889 {
12890 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12891 FL("WLAN TL:Invalid station id")));
12892 return VOS_STATUS_E_FAULT;
12893 }
12894
12895 /*------------------------------------------------------------------------
12896 Extract TL control block and check existance
12897 ------------------------------------------------------------------------*/
12898 pTLCb = VOS_GET_TL_CB(pvosGCtx);
12899 if ( NULL == pTLCb )
12900 {
12901 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12902 FL("WLAN TL:Invalid TL pointer from pvosGCtx")));
12903 return VOS_STATUS_E_FAULT;
12904 }
12905
12906 if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
12907 {
12908 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
12909 FL("WLAN TL:Client Memory was not allocated")));
12910 return VOS_STATUS_E_FAILURE;
12911 }
12912
12913 if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
12914 {
12915 TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
12916 FL("WLAN TL:Station was not previously registered")));
12917 return VOS_STATUS_E_EXISTS;
12918 }
12919
12920 /*------------------------------------------------------------------------
12921 Get STA state
12922 ------------------------------------------------------------------------*/
12923 *plinkCapacity = pTLCb->atlSTAClients[ucSTAId]->linkCapacity;
12924
12925 return VOS_STATUS_SUCCESS;
12926}/* WLANTL_GetSTALinkCapacity */